StoreSkuAct
This commit is contained in:
@@ -41,8 +41,9 @@ var (
|
||||
)
|
||||
|
||||
// 是否按单一门店商品维度创建活动
|
||||
func isCreateTypeSingle() bool {
|
||||
return !globals.IsProductEnv()
|
||||
func isCreateTypeSingleStoreSku() bool {
|
||||
return false
|
||||
// return !globals.IsProductEnv()
|
||||
}
|
||||
|
||||
func splitPromotionSku(skus []*jdapi.PromotionSku, maxCount int) (skusList [][]*jdapi.PromotionSku) {
|
||||
@@ -219,6 +220,23 @@ func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.
|
||||
return vendorActID, err
|
||||
}
|
||||
|
||||
func proxyCreateSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.ActStoreSku2) (vendorActID string, err error) {
|
||||
if isCreateTypeSingleStoreSku() && len(actStoreSku) > 1 {
|
||||
errList := errlist.New()
|
||||
vendorActID := act.VendorActID
|
||||
act.VendorActID = "placeholder"
|
||||
for _, v := range actStoreSku {
|
||||
_, err := createSkuAct(ctx, act, []*model.ActStoreSku2{v})
|
||||
errList.AddErr(err)
|
||||
}
|
||||
act.VendorActID = vendorActID
|
||||
err = errList.GetErrListAsOne()
|
||||
} else {
|
||||
vendorActID, err = createSkuAct(ctx, act, actStoreSku)
|
||||
}
|
||||
return vendorActID, err
|
||||
}
|
||||
|
||||
func cancelSkuActSkus(ctx *jxcontext.Context, act *model.Act2, vendorActID string, actStoreSku []*model.ActStoreSku2) (err error) {
|
||||
if vendorActID != "" {
|
||||
if skuList := storeSku2Jd(actStoreSku, model.IsSyncStatusNeedDelete); len(skuList) > 0 {
|
||||
@@ -282,7 +300,7 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
updateItems = append(updateItems, partner.Act2Update(ctx, act, model.SyncFlagModifiedMask))
|
||||
}
|
||||
} else if model.IsSyncStatusNew(act.SyncStatus) {
|
||||
if act.VendorActID, err = createSkuAct(ctx, act, actStoreSkuList4Create); err == nil {
|
||||
if act.VendorActID, err = proxyCreateSkuAct(ctx, act, actStoreSkuList4Create); err == nil {
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(ctx, actStoreSkuList4Create, model.SyncFlagNewMask)...)
|
||||
updateItems = append(updateItems, partner.Act2Update(ctx, act, model.SyncFlagNewMask))
|
||||
} else {
|
||||
@@ -294,7 +312,7 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
} else if model.IsSyncStatusUpdate(act.SyncStatus) {
|
||||
errList := errlist.New()
|
||||
if len(actStoreSkuList4Create) > 0 {
|
||||
if _, err = createSkuAct(ctx, act, actStoreSkuList4Create); err == nil {
|
||||
if _, err = proxyCreateSkuAct(ctx, act, actStoreSkuList4Create); err == nil {
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(ctx, actStoreSkuList4Create, model.SyncFlagNewMask)...)
|
||||
} else {
|
||||
errList.AddErr(err)
|
||||
|
||||
Reference in New Issue
Block a user