操作日志记录增加门店相关
This commit is contained in:
@@ -1084,9 +1084,11 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
// updateFieldMap["Price"] = 1
|
// updateFieldMap["Price"] = 1
|
||||||
}
|
}
|
||||||
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
||||||
|
if tmpStatus != skuBind.Status {
|
||||||
|
updateFieldMap[model.FieldStatus] = 1
|
||||||
|
}
|
||||||
skuBind.Status = tmpStatus
|
skuBind.Status = tmpStatus
|
||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
|
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
|
||||||
updateFieldMap[model.FieldStatus] = 1
|
|
||||||
}
|
}
|
||||||
if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制
|
if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制
|
||||||
price := jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
|
price := jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
|
||||||
@@ -1107,8 +1109,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
if err := ValidateStruct(skuBindInfo); err != nil {
|
if err := ValidateStruct(skuBindInfo); err != nil {
|
||||||
globals.SugarLogger.Infof("更改商品:%s, 可售时间不合法!时间范围:[%v] 至 [%v]", allBinds[0].Name, skuBindInfo.StatusSaleBegin, skuBindInfo.StatusSaleEnd)
|
globals.SugarLogger.Infof("更改商品:%s, 可售时间不合法!时间范围:[%v] 至 [%v]", allBinds[0].Name, skuBindInfo.StatusSaleBegin, skuBindInfo.StatusSaleEnd)
|
||||||
} else {
|
} else {
|
||||||
updateFieldMap["StatusSaleBegin"] = int(skuBindInfo.StatusSaleBegin)
|
if skuBind.StatusSaleBegin != skuBindInfo.StatusSaleBegin || skuBind.StatusSaleEnd != skuBindInfo.StatusSaleEnd {
|
||||||
updateFieldMap["StatusSaleEnd"] = int(skuBindInfo.StatusSaleEnd)
|
updateFieldMap["StatusSaleBegin"] = 1
|
||||||
|
updateFieldMap["StatusSaleEnd"] = 1
|
||||||
|
}
|
||||||
skuBind.StatusSaleBegin = skuBindInfo.StatusSaleBegin
|
skuBind.StatusSaleBegin = skuBindInfo.StatusSaleBegin
|
||||||
skuBind.StatusSaleEnd = skuBindInfo.StatusSaleEnd
|
skuBind.StatusSaleEnd = skuBindInfo.StatusSaleEnd
|
||||||
}
|
}
|
||||||
@@ -1180,7 +1184,7 @@ func AddEventDetail(db *dao.DaoDB, ctx *jxcontext.Context, operateType, thingID,
|
|||||||
ThingID: thingID,
|
ThingID: thingID,
|
||||||
ThingType: thingType,
|
ThingType: thingType,
|
||||||
StoreID: storeID,
|
StoreID: storeID,
|
||||||
AccessUUID: ctx.GetTrackInfo(),
|
AccessUUID: ctx.GetTrackInfo()[0:strings.Index(ctx.GetTrackInfo(), ",")],
|
||||||
BeforeData: beforeData,
|
BeforeData: beforeData,
|
||||||
AfterData: afterData,
|
AfterData: afterData,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type CheckCookie struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
|
func AddOperateEvent(ctx *jxcontext.Context, accessUUID, jsonData string) (err error) {
|
||||||
var (
|
var (
|
||||||
apiFunction string
|
apiFunction string
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -43,12 +43,16 @@ func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if accessUUID != "" {
|
||||||
|
accessUUID = accessUUID[0:strings.Index(accessUUID, ",")]
|
||||||
|
}
|
||||||
event := &model.OperateEvent{
|
event := &model.OperateEvent{
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
LastOperator: ctx.GetUserName(),
|
LastOperator: ctx.GetUserName(),
|
||||||
APIFunction: apiFunction,
|
APIFunction: apiFunction,
|
||||||
UserID: ctx.GetUserID(),
|
UserID: ctx.GetUserID(),
|
||||||
AccessUUID: accessUUID,
|
AccessUUID: accessUUID,
|
||||||
|
JsonData: jsonData,
|
||||||
}
|
}
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -90,7 +94,7 @@ func DeleteOperateEventAndDetail(ctx *jxcontext.Context, deleteTime time.Time) (
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOperateEvents(ctx *jxcontext.Context, apiFunction, name string, operateType int, skuIDs, storeIDs []int, fromTime, toTime string, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
func GetOperateEvents(ctx *jxcontext.Context, name string, apiFunctions []string, operateTypes, skuIDs, storeIDs []int, fromTime, toTime string, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||||
var (
|
var (
|
||||||
fromTimeP time.Time
|
fromTimeP time.Time
|
||||||
toTimeP time.Time
|
toTimeP time.Time
|
||||||
@@ -104,7 +108,7 @@ func GetOperateEvents(ctx *jxcontext.Context, apiFunction, name string, operateT
|
|||||||
}
|
}
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
offset = jxutils.FormalizePageOffset(offset)
|
offset = jxutils.FormalizePageOffset(offset)
|
||||||
operateEventExt, totalCount, err := dao.GetOperateEvents(db, apiFunction, name, operateType, skuIDs, storeIDs, fromTimeP, toTimeP, offset, pageSize)
|
operateEventExt, totalCount, err := dao.GetOperateEvents(db, name, apiFunctions, operateTypes, skuIDs, storeIDs, fromTimeP, toTimeP, offset, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return pageInfo, err
|
return pageInfo, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ var (
|
|||||||
"08:00:00",
|
"08:00:00",
|
||||||
"18:00:00",
|
"18:00:00",
|
||||||
}
|
}
|
||||||
createStorePriceTimeList = []string{
|
createStorePriceTimeList = []string{
|
||||||
"02:00:00",
|
"02:00:00",
|
||||||
}
|
}
|
||||||
refreshPageActTimeList = []string{
|
refreshPageActTimeList = []string{
|
||||||
@@ -156,7 +156,7 @@ func Init() {
|
|||||||
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
|
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
|
||||||
}, createStorePriceTimeList)
|
}, createStorePriceTimeList)
|
||||||
ScheduleTimerFunc("GetCheckVendorCookie", func() {
|
ScheduleTimerFunc("GetCheckVendorCookie", func() {
|
||||||
event.GetCheckVendorCookie(jxcontext.AdminCtx, []int{0, 1, 3}, true)
|
event.GetCheckVendorCookie(jxcontext.AdminCtx, []int{0, 1, 3, 102}, true)
|
||||||
}, checkCookieList)
|
}, checkCookieList)
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func DeleteOperateEvent(db *DaoDB, deleteTime time.Time) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOperateEvents(db *DaoDB, apiFunction, name string, operateType int, skuIDs, storeIDs []int, fromTime, toTime time.Time, offset, pageSize int) (operateEventExt []*OperateEventExt, totalCount int, err error) {
|
func GetOperateEvents(db *DaoDB, name string, apiFunctions []string, operateTypes, skuIDs, storeIDs []int, fromTime, toTime time.Time, offset, pageSize int) (operateEventExt []*OperateEventExt, totalCount int, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, c.name
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, c.name
|
||||||
FROM operate_event a
|
FROM operate_event a
|
||||||
@@ -61,13 +61,13 @@ func GetOperateEvents(db *DaoDB, apiFunction, name string, operateType int, skuI
|
|||||||
sql += " AND a.created_at <= ?"
|
sql += " AND a.created_at <= ?"
|
||||||
sqlParams = append(sqlParams, toTime)
|
sqlParams = append(sqlParams, toTime)
|
||||||
}
|
}
|
||||||
if apiFunction != "" {
|
if len(apiFunctions) > 0 {
|
||||||
sql += " AND a.api_function = ?"
|
sql += " AND a.api_function IN (" + GenQuestionMarks(len(apiFunctions)) + ")"
|
||||||
sqlParams = append(sqlParams, apiFunction)
|
sqlParams = append(sqlParams, apiFunctions)
|
||||||
}
|
}
|
||||||
if operateType != 0 {
|
if len(operateTypes) > 0 {
|
||||||
sql += " AND b.operate_type = ?"
|
sql += " AND b.operate_type IN (" + GenQuestionMarks(len(operateTypes)) + ")"
|
||||||
sqlParams = append(sqlParams, operateType)
|
sqlParams = append(sqlParams, operateTypes)
|
||||||
}
|
}
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
sql += " AND b.thing_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
sql += " AND b.thing_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type OperateEvent struct {
|
|||||||
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
||||||
UserID string `orm:"column(user_id)" json:"userID"`
|
UserID string `orm:"column(user_id)" json:"userID"`
|
||||||
APIFunction string `orm:"column(api_function)" json:"apiFunction"`
|
APIFunction string `orm:"column(api_function)" json:"apiFunction"`
|
||||||
|
JsonData string `orm:"size(3200)" json:"jsonData"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *OperateEvent) TableIndex() [][]string {
|
func (v *OperateEvent) TableIndex() [][]string {
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ type StoreSkuBind struct {
|
|||||||
|
|
||||||
AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"`
|
AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"`
|
||||||
|
|
||||||
StatusSaleBegin int16 `json:"statusSaleBegin"` //商品可售时间范围
|
StatusSaleBegin int16 //商品可售时间范围
|
||||||
StatusSaleEnd int16 `json:"statusSaleEnd"`
|
StatusSaleEnd int16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*StoreSkuBind) TableUnique() [][]string {
|
func (*StoreSkuBind) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ type EventController struct {
|
|||||||
// @Title 查询操作日志事件明细
|
// @Title 查询操作日志事件明细
|
||||||
// @Description 查询操作日志事件明细
|
// @Description 查询操作日志事件明细
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param apiFunction query string false "功能名"
|
// @Param apiFunctions query string false "功能名列表"
|
||||||
// @Param name query string false "操作人姓名,支持模糊查询"
|
// @Param name query string false "操作人姓名,支持模糊查询"
|
||||||
// @Param operateType query int false "操作类型,1为修改,2为新增,4为删除"
|
// @Param operateTypes query string false "操作类型列表,1为修改,2为新增,4为删除"
|
||||||
// @Param skuIDs query string false "商品ID列表"
|
// @Param skuIDs query string false "商品ID列表"
|
||||||
// @Param storeIDs query string false "门店ID列表"
|
// @Param storeIDs query string false "门店ID列表"
|
||||||
// @Param fromTime query string false "开始日期(包含),格式(2006-01-02 00:00:00)"
|
// @Param fromTime query string false "开始日期(包含),格式(2006-01-02 00:00:00)"
|
||||||
@@ -27,10 +27,11 @@ type EventController struct {
|
|||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetOperateEvents [get]
|
// @router /GetOperateEvents [get]
|
||||||
func (c *EventController) GetOperateEvents() {
|
func (c *EventController) GetOperateEvents() {
|
||||||
var storeIDList, skuIDList []int
|
var storeIDList, skuIDList, operateTypeList []int
|
||||||
|
var apiFunctionList []string
|
||||||
c.callGetOperateEvents(func(params *tEventGetOperateEventsParams) (retVal interface{}, errCode string, err error) {
|
c.callGetOperateEvents(func(params *tEventGetOperateEventsParams) (retVal interface{}, errCode string, err error) {
|
||||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList); err == nil {
|
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList, params.ApiFunctions, &apiFunctionList, params.OperateTypes, &operateTypeList); err == nil {
|
||||||
retVal, err = event.GetOperateEvents(params.Ctx, params.ApiFunction, params.Name, params.OperateType, skuIDList, storeIDList, params.FromTime, params.ToTime, params.Offset, params.PageSize)
|
retVal, err = event.GetOperateEvents(params.Ctx, params.Name, apiFunctionList, operateTypeList, skuIDList, storeIDList, params.FromTime, params.ToTime, params.Offset, params.PageSize)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user