- 活动平台实际测试通过
This commit is contained in:
@@ -178,14 +178,18 @@ func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.
|
||||
}
|
||||
|
||||
func cancelSkuActSkus(ctx *jxcontext.Context, actType int, vendorActID string, actStoreSku []*model.ActStoreSku2) (err error) {
|
||||
if skuList := storeSku2Jd(actStoreSku, model.IsSyncStatusNeedDelete); len(skuList) > 0 {
|
||||
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, ctx.GetAccessUUID())
|
||||
if vendorActID != "" {
|
||||
if skuList := storeSku2Jd(actStoreSku, model.IsSyncStatusNeedDelete); len(skuList) > 0 {
|
||||
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, ctx.GetAccessUUID())
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func cancelSkuAct(ctx *jxcontext.Context, actType int, vendorActID string) (err error) {
|
||||
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", ctx.GetAccessUUID())
|
||||
if vendorActID != "" {
|
||||
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", ctx.GetAccessUUID())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -200,25 +204,19 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
for storeID := range actStoreSkuMap {
|
||||
for _, actStoreSku := range actStoreSkuMap[storeID] {
|
||||
vendorActInfoMap[actStoreSku.VendorActID] = append(vendorActInfoMap[actStoreSku.VendorActID], actStoreSku)
|
||||
if model.IsSyncStatusNeedCreate(actStoreSku.SyncStatus) {
|
||||
actStoreSkuList4Create = append(actStoreSkuList4Create, actStoreSku)
|
||||
} else if model.IsSyncStatusNeedDelete(actStoreSku.SyncStatus) {
|
||||
if model.IsSyncStatusDelete(actStoreSku.SyncStatus) {
|
||||
vendorActID := actStoreSku.VendorActID
|
||||
if vendorActID == "" {
|
||||
vendorActID = act.VendorActID
|
||||
}
|
||||
deleteActInfoMap[vendorActID] = append(deleteActInfoMap[vendorActID], actStoreSku)
|
||||
} else if model.IsSyncStatusNew(actStoreSku.SyncStatus) {
|
||||
actStoreSkuList4Create = append(actStoreSkuList4Create, actStoreSku)
|
||||
}
|
||||
}
|
||||
}
|
||||
err = func() (err error) {
|
||||
if model.IsSyncStatusNeedCreate(act.SyncStatus) {
|
||||
if act.VendorActID, err = createSkuAct(ctx, act, actStoreSkuList4Create); err != nil {
|
||||
return err
|
||||
}
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(actStoreSkuList4Create, model.SyncFlagNewMask)...)
|
||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagNewMask))
|
||||
} else if model.IsSyncStatusNeedDelete(act.SyncStatus) {
|
||||
if model.IsSyncStatusDelete(act.SyncStatus) {
|
||||
for vendorActID := range vendorActInfoMap {
|
||||
if vendorActID != "" {
|
||||
if err = cancelSkuAct(ctx, act.Type, vendorActID); err != nil {
|
||||
@@ -230,7 +228,13 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(actStoreSkuList, model.SyncFlagDeletedMask)...)
|
||||
}
|
||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagDeletedMask))
|
||||
} else if model.IsSyncStatusNeedUpdate(act.SyncStatus) {
|
||||
} else if model.IsSyncStatusNew(act.SyncStatus) {
|
||||
if act.VendorActID, err = createSkuAct(ctx, act, actStoreSkuList4Create); err != nil {
|
||||
return err
|
||||
}
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(actStoreSkuList4Create, model.SyncFlagNewMask)...)
|
||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagNewMask))
|
||||
} else if model.IsSyncStatusUpdate(act.SyncStatus) {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(updateItems, false))
|
||||
if len(actStoreSkuList4Create) > 0 {
|
||||
if _, err = createSkuAct(ctx, act, actStoreSkuList4Create); err != nil {
|
||||
@@ -258,6 +262,7 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
return err
|
||||
}()
|
||||
db := dao.GetDB()
|
||||
globals.SugarLogger.Debug(utils.Format4Output(updateItems, false))
|
||||
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
||||
if err == nil {
|
||||
err = err2
|
||||
|
||||
Reference in New Issue
Block a user