1
This commit is contained in:
@@ -956,7 +956,6 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isExd bool) (num int64, err error) {
|
func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isExd bool) (num int64, err error) {
|
||||||
globals.SugarLogger.Debugf("===========================1 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
skuName := &model.SkuName{}
|
skuName := &model.SkuName{}
|
||||||
skuName.ID = nameID
|
skuName.ID = nameID
|
||||||
@@ -973,7 +972,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
payload["name"] = newSkuName
|
payload["name"] = newSkuName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================2 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
|
|
||||||
delete(payload, "isSpu")
|
delete(payload, "isSpu")
|
||||||
delete(payload, "seq")
|
delete(payload, "seq")
|
||||||
@@ -982,7 +980,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
valid = utils.RemoveGeneralMapKeys(valid, model.FieldSpecQuality, model.FieldSpecUnit)
|
valid = utils.RemoveGeneralMapKeys(valid, model.FieldSpecQuality, model.FieldSpecUnit)
|
||||||
_, hasPlaces := payload["places"]
|
_, hasPlaces := payload["places"]
|
||||||
flag := updateOrCreateSkuVendorCategoryMap(db, ctx, nameID, payload, nil, false)
|
flag := updateOrCreateSkuVendorCategoryMap(db, ctx, nameID, payload, nil, false)
|
||||||
globals.SugarLogger.Debugf("===========================3 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
if len(valid) > 0 || hasPlaces || flag {
|
if len(valid) > 0 || hasPlaces || flag {
|
||||||
if valid["Upc"] != nil {
|
if valid["Upc"] != nil {
|
||||||
//if upc, _ := valid["Upc"].(string); upc == "" {
|
//if upc, _ := valid["Upc"].(string); upc == "" {
|
||||||
@@ -1019,7 +1016,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================4 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
var eclpID string
|
var eclpID string
|
||||||
if payload["eclpID"] != nil {
|
if payload["eclpID"] != nil {
|
||||||
eclpID = payload["eclpID"].(string)
|
eclpID = payload["eclpID"].(string)
|
||||||
@@ -1046,7 +1042,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================5 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
if !isExd && eclpID == "" {
|
if !isExd && eclpID == "" {
|
||||||
if err = OnUpdateThing(ctx, db, nil, int64(nameID), model.ThingTypeSkuName); err != nil {
|
if err = OnUpdateThing(ctx, db, nil, int64(nameID), model.ThingTypeSkuName); err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
@@ -1074,7 +1069,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================6 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
skuList, err2 := dao.GetSkus(db, nil, []int{nameID}, nil, nil, nil)
|
skuList, err2 := dao.GetSkus(db, nil, []int{nameID}, nil, nil, nil)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
for _, v := range skuList {
|
for _, v := range skuList {
|
||||||
@@ -1094,13 +1088,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================7 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
skuIDs, err2 := dao.GetSkuIDByNames(db, []int{nameID})
|
skuIDs, err2 := dao.GetSkuIDByNames(db, []int{nameID})
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================8 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
// 判断是否改价
|
// 判断是否改价
|
||||||
if payload["price"] != nil {
|
if payload["price"] != nil {
|
||||||
@@ -1124,13 +1116,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("===========================9 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
// 更新skuIds对应在store_sku_bind中的价格体系,解决老版本改价之前关注的商品,在价格修改后,store_sku_bind中京西价未修改的问题
|
// 更新skuIds对应在store_sku_bind中的价格体系,解决老版本改价之前关注的商品,在价格修改后,store_sku_bind中京西价未修改的问题
|
||||||
if _, err = SetStoreSkuSyncStatus2(db, nil, partner.GetSingleStoreVendorIDs(), skuIDs, model.SyncFlagModifiedMask); err != nil {
|
if _, err = SetStoreSkuSyncStatus2(db, nil, partner.GetSingleStoreVendorIDs(), skuIDs, model.SyncFlagModifiedMask); err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================10 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
}
|
}
|
||||||
dao.Commit(db, txDB)
|
dao.Commit(db, txDB)
|
||||||
|
|
||||||
@@ -1138,21 +1128,29 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
//_, err = CurVendorSync.SyncSku(ctx, db, nameID, -1, false, false, userName)
|
//_, err = CurVendorSync.SyncSku(ctx, db, nameID, -1, false, false, userName)
|
||||||
//errList.AddErr(err)
|
//errList.AddErr(err)
|
||||||
globals.SugarLogger.Debugf("===========================11 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
|
|
||||||
storeIds, err := GetSyncSkuStoreId(db, skuIDs)
|
jxutils.CallMsgHandlerAsync(func() {
|
||||||
if err != nil {
|
storeIds, _ := GetSyncSkuStoreId(db, skuIDs)
|
||||||
return 0, err
|
if len(storeIds) > model.NO {
|
||||||
}
|
CurVendorSync.SyncStoresSkus(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), storeIds, skuIDs, false, false, true)
|
||||||
_, err2 = CurVendorSync.SyncStoresSkus(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), storeIds, skuIDs, false, false, true)
|
}
|
||||||
errList.AddErr(err2)
|
}, "")
|
||||||
globals.SugarLogger.Debugf("===========================12 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
err = errList.GetErrListAsOne()
|
// 修改之前的bug,运营在修改商品之后,可能是价格或者其他什么发生变化,去重新更新一下各个平台的商品
|
||||||
|
// 但是会出现商品所属门店或者分组比较多,然后更新异常慢,采用异步处理一下,但是本方法会出现很多更新异常
|
||||||
|
// 商品未创建,图片啊,价格啊什么的
|
||||||
|
//storeIds, err := GetSyncSkuStoreId(db, skuIDs)
|
||||||
|
//if err != nil {
|
||||||
|
// return 0, err
|
||||||
|
//}
|
||||||
|
//_, err2 = CurVendorSync.SyncStoresSkus(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), storeIds, skuIDs, false, false, true)
|
||||||
|
//errList.AddErr(err2)
|
||||||
|
//err = errList.GetErrListAsOne()
|
||||||
|
|
||||||
if globals.IsAddEvent {
|
if globals.IsAddEvent {
|
||||||
mapBefore := refutil.FindMapAndStructMixed(valid, beforSkuName)
|
mapBefore := refutil.FindMapAndStructMixed(valid, beforSkuName)
|
||||||
err = AddEventDetail(db, ctx, model.OperateUpdate, nameID, model.ThingTypeSkuName, 0, BuildDiffData(mapBefore), BuildDiffData(valid))
|
err = AddEventDetail(db, ctx, model.OperateUpdate, nameID, model.ThingTypeSkuName, 0, BuildDiffData(mapBefore), BuildDiffData(valid))
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("===========================13 %s", utils.Format4Output(time.Now(), false))
|
|
||||||
}
|
}
|
||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user