操作日志记录增加门店相关

This commit is contained in:
苏尹岚
2020-01-17 16:16:56 +08:00
parent 05ebeeb77c
commit 3aec482720
7 changed files with 33 additions and 23 deletions

View File

@@ -1084,9 +1084,11 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
// updateFieldMap["Price"] = 1
}
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
if tmpStatus != skuBind.Status {
updateFieldMap[model.FieldStatus] = 1
}
skuBind.Status = tmpStatus
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
updateFieldMap[model.FieldStatus] = 1
}
if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制
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 {
globals.SugarLogger.Infof("更改商品:%s, 可售时间不合法!时间范围:[%v] 至 [%v]", allBinds[0].Name, skuBindInfo.StatusSaleBegin, skuBindInfo.StatusSaleEnd)
} else {
updateFieldMap["StatusSaleBegin"] = int(skuBindInfo.StatusSaleBegin)
updateFieldMap["StatusSaleEnd"] = int(skuBindInfo.StatusSaleEnd)
if skuBind.StatusSaleBegin != skuBindInfo.StatusSaleBegin || skuBind.StatusSaleEnd != skuBindInfo.StatusSaleEnd {
updateFieldMap["StatusSaleBegin"] = 1
updateFieldMap["StatusSaleEnd"] = 1
}
skuBind.StatusSaleBegin = skuBindInfo.StatusSaleBegin
skuBind.StatusSaleEnd = skuBindInfo.StatusSaleEnd
}
@@ -1180,7 +1184,7 @@ func AddEventDetail(db *dao.DaoDB, ctx *jxcontext.Context, operateType, thingID,
ThingID: thingID,
ThingType: thingType,
StoreID: storeID,
AccessUUID: ctx.GetTrackInfo(),
AccessUUID: ctx.GetTrackInfo()[0:strings.Index(ctx.GetTrackInfo(), ",")],
BeforeData: beforeData,
AfterData: afterData,
}

View File

@@ -29,7 +29,7 @@ type CheckCookie struct {
Status string `json:"status"`
}
func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
func AddOperateEvent(ctx *jxcontext.Context, accessUUID, jsonData string) (err error) {
var (
apiFunction string
db = dao.GetDB()
@@ -43,12 +43,16 @@ func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
return err
}
}
if accessUUID != "" {
accessUUID = accessUUID[0:strings.Index(accessUUID, ",")]
}
event := &model.OperateEvent{
CreatedAt: time.Now(),
LastOperator: ctx.GetUserName(),
APIFunction: apiFunction,
UserID: ctx.GetUserID(),
AccessUUID: accessUUID,
JsonData: jsonData,
}
dao.Begin(db)
defer func() {
@@ -90,7 +94,7 @@ func DeleteOperateEventAndDetail(ctx *jxcontext.Context, deleteTime time.Time) (
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 (
fromTimeP time.Time
toTimeP time.Time
@@ -104,7 +108,7 @@ func GetOperateEvents(ctx *jxcontext.Context, apiFunction, name string, operateT
}
pageSize = jxutils.FormalizePageSize(pageSize)
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 {
return pageInfo, err
}

View File

@@ -44,7 +44,7 @@ var (
"08:00:00",
"18:00:00",
}
createStorePriceTimeList = []string{
createStorePriceTimeList = []string{
"02:00:00",
}
refreshPageActTimeList = []string{
@@ -156,7 +156,7 @@ func Init() {
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
}, createStorePriceTimeList)
ScheduleTimerFunc("GetCheckVendorCookie", func() {
event.GetCheckVendorCookie(jxcontext.AdminCtx, []int{0, 1, 3}, true)
event.GetCheckVendorCookie(jxcontext.AdminCtx, []int{0, 1, 3, 102}, true)
}, checkCookieList)
}
ScheduleTimerFunc("AutoSaleStoreSku", func() {

View File

@@ -40,7 +40,7 @@ func DeleteOperateEvent(db *DaoDB, deleteTime time.Time) (err error) {
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 := `
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, c.name
FROM operate_event a
@@ -61,13 +61,13 @@ func GetOperateEvents(db *DaoDB, apiFunction, name string, operateType int, skuI
sql += " AND a.created_at <= ?"
sqlParams = append(sqlParams, toTime)
}
if apiFunction != "" {
sql += " AND a.api_function = ?"
sqlParams = append(sqlParams, apiFunction)
if len(apiFunctions) > 0 {
sql += " AND a.api_function IN (" + GenQuestionMarks(len(apiFunctions)) + ")"
sqlParams = append(sqlParams, apiFunctions)
}
if operateType != 0 {
sql += " AND b.operate_type = ?"
sqlParams = append(sqlParams, operateType)
if len(operateTypes) > 0 {
sql += " AND b.operate_type IN (" + GenQuestionMarks(len(operateTypes)) + ")"
sqlParams = append(sqlParams, operateTypes)
}
if len(skuIDs) > 0 {
sql += " AND b.thing_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"

View File

@@ -9,6 +9,7 @@ type OperateEvent struct {
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
UserID string `orm:"column(user_id)" json:"userID"`
APIFunction string `orm:"column(api_function)" json:"apiFunction"`
JsonData string `orm:"size(3200)" json:"jsonData"`
}
func (v *OperateEvent) TableIndex() [][]string {

View File

@@ -117,8 +117,8 @@ type StoreSkuBind struct {
AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"`
StatusSaleBegin int16 `json:"statusSaleBegin"` //商品可售时间范围
StatusSaleEnd int16 `json:"statusSaleEnd"`
StatusSaleBegin int16 //商品可售时间范围
StatusSaleEnd int16
}
func (*StoreSkuBind) TableUnique() [][]string {

View File

@@ -14,9 +14,9 @@ type EventController struct {
// @Title 查询操作日志事件明细
// @Description 查询操作日志事件明细
// @Param token header string true "认证token"
// @Param apiFunction query string false "功能名"
// @Param apiFunctions 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 storeIDs query string false "门店ID列表"
// @Param fromTime query string false "开始日期包含格式2006-01-02 00:00:00)"
@@ -27,10 +27,11 @@ type EventController struct {
// @Failure 200 {object} controllers.CallResult
// @router /GetOperateEvents [get]
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) {
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList); err == nil {
retVal, err = event.GetOperateEvents(params.Ctx, params.ApiFunction, params.Name, params.OperateType, skuIDList, storeIDList, params.FromTime, params.ToTime, params.Offset, params.PageSize)
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList, params.ApiFunctions, &apiFunctionList, params.OperateTypes, &operateTypeList); err == nil {
retVal, err = event.GetOperateEvents(params.Ctx, params.Name, apiFunctionList, operateTypeList, skuIDList, storeIDList, params.FromTime, params.ToTime, params.Offset, params.PageSize)
}
return retVal, "", err
})