- 活动平台实际测试通过

This commit is contained in:
gazebo
2019-07-04 12:07:43 +08:00
parent a93b6889b3
commit 2d5a2e8274
8 changed files with 99 additions and 41 deletions

View File

@@ -184,7 +184,10 @@ func cancelSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actStoreSkuM
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
vendorActID := batchItemList[0].(string)
actStoreSkuList := actStoreSkuMap[vendorActID]
if err = ActivityDisable(utils.Str2Int64(vendorActID), utils.Int2Str(actStoreSkuList[0].StoreID), 0, 0); err == nil {
if vendorActID != "" {
err = ActivityDisable(utils.Str2Int64(vendorActID), utils.Int2Str(actStoreSkuList[0].StoreID), 0, 0)
}
if err == nil {
retVal = []interface{}{actStoreSkuList}
}
return retVal, err
@@ -274,31 +277,31 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
if vendorActIDMap[storeID] == "" && actStoreSku.VendorActID != "" {
vendorActIDMap[storeID] = actStoreSku.VendorActID
}
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) {
createdList, err2 := createSkuAct(ctx, nil, act, actStoreSkuList4Create)
updateItems = append(updateItems, partner.ActStoreSku2Update(createdList, model.SyncFlagNewMask)...)
if err = err2; err == nil {
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagNewMask))
}
} else if model.IsSyncStatusNeedDelete(act.SyncStatus) {
if model.IsSyncStatusDelete(act.SyncStatus) {
canceledList, err2 := cancelSkuAct(ctx, nil, vendorActInfoMap)
updateItems = append(updateItems, partner.ActStoreSku2Update(canceledList, model.SyncFlagDeletedMask)...)
if err = err2; err == nil {
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagDeletedMask))
}
} else if model.IsSyncStatusNeedUpdate(act.SyncStatus) {
} else if model.IsSyncStatusNew(act.SyncStatus) {
createdList, err2 := createSkuAct(ctx, nil, act, actStoreSkuList4Create)
updateItems = append(updateItems, partner.ActStoreSku2Update(createdList, model.SyncFlagNewMask)...)
if err = err2; err == nil {
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 {
addedList, err2 := addSkuActSkus(ctx, nil, act, actStoreSkuList4Create, vendorActIDMap)

View File

@@ -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

View File

@@ -153,27 +153,27 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
actStoreSkuMap := partner.SplitActStoreSku(actStoreSkuList)
for storeID := range actStoreSkuMap {
for _, actStoreSku := range actStoreSkuMap[storeID] {
if model.IsSyncStatusNeedCreate(actStoreSku.SyncStatus) {
actStoreSkuList4Create = append(actStoreSkuList4Create, actStoreSku)
} else if model.IsSyncStatusNeedDelete(actStoreSku.SyncStatus) {
if model.IsSyncStatusDelete(actStoreSku.SyncStatus) {
actStoreSkuList4Delete = append(actStoreSkuList4Delete, actStoreSku)
} else if model.IsSyncStatusNew(actStoreSku.SyncStatus) {
actStoreSkuList4Create = append(actStoreSkuList4Create, actStoreSku)
}
}
}
err = func() (err error) {
if model.IsSyncStatusNeedCreate(act.SyncStatus) {
createdList, err2 := createSkuAct(ctx, nil, act, actStoreSkuList4Create)
updateItems = append(updateItems, partner.ActStoreSku2Update(createdList, model.SyncFlagNewMask)...)
if err = err2; err == nil {
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagNewMask))
}
} else if model.IsSyncStatusNeedDelete(act.SyncStatus) {
if model.IsSyncStatusDelete(act.SyncStatus) {
canceledList, err2 := cancelSkuAct(ctx, nil, actStoreSkuList)
updateItems = append(updateItems, partner.ActStoreSku2Update(canceledList, model.SyncFlagDeletedMask)...)
if err = err2; err == nil {
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagDeletedMask))
}
} else if model.IsSyncStatusNeedUpdate(act.SyncStatus) {
} else if model.IsSyncStatusNew(act.SyncStatus) {
createdList, err2 := createSkuAct(ctx, nil, act, actStoreSkuList4Create)
updateItems = append(updateItems, partner.ActStoreSku2Update(createdList, model.SyncFlagNewMask)...)
if err = err2; err == nil {
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 {
addedList, err2 := createSkuAct(ctx, nil, act, actStoreSkuList4Create)