操作日志
This commit is contained in:
@@ -13,6 +13,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/refutil"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||||
@@ -1035,6 +1039,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
||||||
skuBind.Status = tmpStatus
|
skuBind.Status = tmpStatus
|
||||||
}
|
}
|
||||||
|
err = AddEventDetail(model.OperateAdd, v.RealSkuID, model.ThingTypeSku, storeID, ctx.GetTrackInfo(), "", "")
|
||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
||||||
dao.WrapAddIDCULDEntity(skuBind, userName)
|
dao.WrapAddIDCULDEntity(skuBind, userName)
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
||||||
@@ -1059,8 +1064,8 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
skuBind = &v.StoreSkuBind
|
skuBind = &v.StoreSkuBind
|
||||||
|
|
||||||
if skuBindInfo.IsFocus == -1 && isCanChangePrice {
|
if skuBindInfo.IsFocus == -1 && isCanChangePrice {
|
||||||
|
err = AddEventDetail(model.OperateDelete, skuBind.SkuID, model.ThingTypeSku, storeID, ctx.GetTrackInfo(), "", "")
|
||||||
if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{
|
if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{
|
||||||
model.FieldStatus: model.StoreSkuBindStatusDeleted,
|
model.FieldStatus: model.StoreSkuBindStatusDeleted,
|
||||||
model.FieldJdSyncStatus: model.SyncFlagDeletedMask,
|
model.FieldJdSyncStatus: model.SyncFlagDeletedMask,
|
||||||
@@ -1072,7 +1077,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 用了SELECT FOR UPDATE后,只更新修改字段是没有必要的,暂时保留
|
// 用了SELECT FOR UPDATE后,只更新修改字段是没有必要的,暂时保留
|
||||||
updateFieldMap := make(map[string]int)
|
updateFieldMap := make(map[string]interface{})
|
||||||
if skuBindInfo.IsFocus == 1 { // 关注之后再关注不操作
|
if skuBindInfo.IsFocus == 1 { // 关注之后再关注不操作
|
||||||
// skuBind.Status = model.StoreSkuBindStatusDontSale // 缺省不可售?
|
// skuBind.Status = model.StoreSkuBindStatusDontSale // 缺省不可售?
|
||||||
// skuBind.DeletedAt = utils.DefaultTimeValue
|
// skuBind.DeletedAt = utils.DefaultTimeValue
|
||||||
@@ -1117,6 +1122,13 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
// skuBind.ElmID = inSkuBind.ElmID
|
// skuBind.ElmID = inSkuBind.ElmID
|
||||||
// updateFieldMap["ElmID"] = 1
|
// updateFieldMap["ElmID"] = 1
|
||||||
// }
|
// }
|
||||||
|
if updateFieldMap != nil {
|
||||||
|
afterData := utils.MustMarshal(updateFieldMap)
|
||||||
|
mapresult := refutil.FindMapAndStructMixed(updateFieldMap, skuBind)
|
||||||
|
beforeData := utils.MustMarshal(mapresult)
|
||||||
|
fmt
|
||||||
|
AddEventDetail(model.OperateUpdate, v.RealSkuID, model.ThingTypeSku, storeID, ctx.GetTrackInfo(), string(beforeData), string(afterData))
|
||||||
|
}
|
||||||
if len(updateFieldMap) > 0 {
|
if len(updateFieldMap) > 0 {
|
||||||
updateFieldMap[model.FieldJdSyncStatus] = 1
|
updateFieldMap[model.FieldJdSyncStatus] = 1
|
||||||
updateFieldMap[model.FieldEbaiSyncStatus] = 1
|
updateFieldMap[model.FieldEbaiSyncStatus] = 1
|
||||||
@@ -1166,6 +1178,20 @@ func getSkuSaleStatus(inSkuBind *StoreSkuBindSkuInfo, skuNameBindInfo *StoreSkuB
|
|||||||
return model.StoreSkuBindStatusNA
|
return model.StoreSkuBindStatusNA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddEventDetail(operateType, thingID, thingType, storeID int, accessUUID, beforeData, afterData string) (err error) {
|
||||||
|
operateEventDetail := &model.OperateEventDetail{
|
||||||
|
OperateType: operateType,
|
||||||
|
ThingID: thingID,
|
||||||
|
ThingType: thingType,
|
||||||
|
StoreID: storeID,
|
||||||
|
AccessUUID: accessUUID,
|
||||||
|
BeforeData: beforeData,
|
||||||
|
AfterData: afterData,
|
||||||
|
}
|
||||||
|
err = event.AddOperateEventDetail(operateEventDetail)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func formatAutoSaleTime(autoSaleTime time.Time) (outAutoSaleTime time.Time) {
|
func formatAutoSaleTime(autoSaleTime time.Time) (outAutoSaleTime time.Time) {
|
||||||
if utils.IsTimeZero(autoSaleTime) {
|
if utils.IsTimeZero(autoSaleTime) {
|
||||||
outAutoSaleTime = utils.DefaultTimeValue
|
outAutoSaleTime = utils.DefaultTimeValue
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ type OperateEventDetail struct {
|
|||||||
ThingType int `json:"thingType"` //各字段类型
|
ThingType int `json:"thingType"` //各字段类型
|
||||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
||||||
BeforeData string `orm:"size(32)" json:"beforeData"`
|
BeforeData string `orm:"size(255)" json:"beforeData"`
|
||||||
AfterData string `orm:"size(32)" json:"afterData"`
|
AfterData string `orm:"size(255)" json:"afterData"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *OperateEventDetail) TableIndex() [][]string {
|
func (v *OperateEventDetail) TableIndex() [][]string {
|
||||||
|
|||||||
@@ -91,6 +91,17 @@ func FilterMapByFieldList(mapData map[string]interface{}, fields []string) (vali
|
|||||||
return valid, invalid
|
return valid, invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FindMapAndStructMixed(mapData map[string]interface{}, obj interface{}) (valid map[string]interface{}) {
|
||||||
|
valid = make(map[string]interface{})
|
||||||
|
map2 := utils.Struct2FlatMap(obj)
|
||||||
|
for k, v := range map2 {
|
||||||
|
if mapData[k] != nil {
|
||||||
|
valid[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
|
|
||||||
func IsValueEqual(value1, value2 interface{}) bool {
|
func IsValueEqual(value1, value2 interface{}) bool {
|
||||||
if value1 == nil || value2 == nil {
|
if value1 == nil || value2 == nil {
|
||||||
return value1 == value2
|
return value1 == value2
|
||||||
|
|||||||
Reference in New Issue
Block a user