From a8ea29b52fa61e391da5b93b2fac3a687526a6b2 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 15:00:14 +0800 Subject: [PATCH 01/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 776408dab..70a3c7d61 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -17,7 +17,6 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" ) func actType2Txd(actType int) *int64 { @@ -130,14 +129,15 @@ func storeSku2ActData4Delete(actStoreSku []*model.ActStoreSku2, handler func(int } //删除活动的商品详情 -func actSku2Delete(actIDs []string) (map[string]domain.AlibabaRetailMarketingItemdiscountActivitySkuDeleteItemDiscountActivityElementOperateRequest, error) { +func actSku2Delete(actIDs []string, vendorOrgCode, vendorStoreID string) (map[string]domain.AlibabaRetailMarketingItemdiscountActivitySkuDeleteItemDiscountActivityElementOperateRequest, error) { var ( SkuElement []domain.AlibabaRetailMarketingItemdiscountActivitySkuDeleteSkuActivityElementDto deData = make(map[string]domain.AlibabaRetailMarketingItemdiscountActivitySkuDeleteItemDiscountActivityElementOperateRequest, 0) ) for _, v := range actIDs { i := utils.Str2Int64(v) - if skus, err := api.TaoVegetableApi.ActivitySkuQuery(i); err == nil { + //if skus, err := api.TaoVegetableApi.ActivitySkuQuery(i); err == nil { + if skus, err := getAPI(vendorOrgCode, 0, vendorStoreID).ActivitySkuQuery(i); err == nil { //查询商品 for _, sku := range skus { SkuElement = append(SkuElement, domain.AlibabaRetailMarketingItemdiscountActivitySkuDeleteSkuActivityElementDto{ @@ -145,7 +145,7 @@ func actSku2Delete(actIDs []string) (map[string]domain.AlibabaRetailMarketingIte }) } //查询活动详情 - act, err := api.TaoVegetableApi.ActivityQuery(i, "") + act, err := getAPI(vendorOrgCode, 0, vendorStoreID).ActivityQuery(i, "") if err != nil { return nil, err } @@ -175,7 +175,7 @@ func createOneShopAct(act *model.Act2, vendorStoreID string, actStoreSku []*mode if globals.EnableMtwmStoreWrite { globals.SugarLogger.Debugf("进入创建活动") //创建活动 - actID, err1 := api.TaoVegetableApi.ActivityCreate(*actData) + actID, err1 := getAPI(act.VendorOrgCode, 0, vendorStoreID).ActivityCreate(*actData) globals.SugarLogger.Debugf("createOneShopAct actData=%s,err=%v", utils.Format4Output(actData, false), err1) if err1 != nil || actID == 0 { failedList = append(failedList, &partner.StoreSkuInfoWithErr{ @@ -188,7 +188,7 @@ func createOneShopAct(act *model.Act2, vendorStoreID string, actStoreSku []*mode } //活动增加商品 actSkuData.ActId = &actID - err3, successSkuCode, failSkuCode := api.TaoVegetableApi.ActivitySkuCreate(*actSkuData) + err3, successSkuCode, failSkuCode := getAPI(act.VendorOrgCode, 0, vendorStoreID).ActivitySkuCreate(*actSkuData) globals.SugarLogger.Debugf("createOneShopAct actSkuData=%s,err=%v", utils.Format4Output(actSkuData, false), err3) err = err3 actStoreSkuMap := make(map[int]*model.ActStoreSku2) @@ -227,14 +227,14 @@ func cancelOneShopAct(act *model.Act2, vendorStoreID string, actStoreSku []*mode actStoreSkuMap[v.VendorActID] = v } //查找删除的活动商品 - sku2Delete, err := actSku2Delete(list) + sku2Delete, err := actSku2Delete(list, act.VendorOrgCode, vendorStoreID) if err != nil { return nil, err } //删除活动以及商品 for k, v := range sku2Delete { - if err = api.TaoVegetableApi.ActivitySkuDelete(v); err == nil { - err = api.TaoVegetableApi.ActivityDelete(*v.CreatorId, *v.CreatorName, utils.Str2Int64(k)) + if err = getAPI(act.VendorOrgCode, 0, vendorStoreID).ActivitySkuDelete(v); err == nil { + err = getAPI(act.VendorOrgCode, 0, vendorStoreID).ActivityDelete(*v.CreatorId, *v.CreatorName, utils.Str2Int64(k)) } if err != nil { failedList = append(failedList, &partner.StoreSkuInfoWithErr{ From c5033d25534e87de78b32ac8ec7a599ed0a9ea77 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 15:19:01 +0800 Subject: [PATCH 02/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 70a3c7d61..afee8e106 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -49,7 +49,7 @@ func act2TxdActivity(act *model.Act2) (activity *domain.AlibabaRetailMarketingIt CreatorName: &act.LastOperator, Description: &act.Advertising, Terminals: &[]int32{tao_vegetable.TerminalsAPP, tao_vegetable.TerminalsPOS}, - //StoreIds: &[]string{act.Act.}, + //StoreIds: &[]string{act.s}, DiscountType: actType2Txd(act.Type), StartTime: utils.Int64ToPointer(act.BeginAt.UnixNano() / int64(time.Millisecond)), EndTime: utils.Int64ToPointer(act.EndAt.UnixNano() / int64(time.Millisecond)), @@ -175,6 +175,7 @@ func createOneShopAct(act *model.Act2, vendorStoreID string, actStoreSku []*mode if globals.EnableMtwmStoreWrite { globals.SugarLogger.Debugf("进入创建活动") //创建活动 + actData.StoreIds = &[]string{vendorStoreID} actID, err1 := getAPI(act.VendorOrgCode, 0, vendorStoreID).ActivityCreate(*actData) globals.SugarLogger.Debugf("createOneShopAct actData=%s,err=%v", utils.Format4Output(actData, false), err1) if err1 != nil || actID == 0 { From 748a8ac40a93256fd836d66e870b7b0814b1cbfa Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 16:43:31 +0800 Subject: [PATCH 03/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index afee8e106..42866c9c5 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -2,6 +2,7 @@ package tao_vegetable import ( "fmt" + "math/rand" "time" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability2770/domain" @@ -45,10 +46,10 @@ func act2TxdActivity(act *model.Act2) (activity *domain.AlibabaRetailMarketingIt actName := act.GetRealActName() activity = &domain.AlibabaRetailMarketingItemdiscountActivityCreateItemDiscountActivityOperateRequest{ ActivityName: &actName, - CreatorId: &act.VendorActID, + CreatorId: utils.String2Pointer(utils.Int2Str(rand.Int())), CreatorName: &act.LastOperator, Description: &act.Advertising, - Terminals: &[]int32{tao_vegetable.TerminalsAPP, tao_vegetable.TerminalsPOS}, + Terminals: &[]int32{tao_vegetable.TerminalsAPP}, //StoreIds: &[]string{act.s}, DiscountType: actType2Txd(act.Type), StartTime: utils.Int64ToPointer(act.BeginAt.UnixNano() / int64(time.Millisecond)), From 2f93bca7fc829041b22e85f1413f89ba6144400f Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 16:50:12 +0800 Subject: [PATCH 04/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 42866c9c5..d97fcfd1b 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -107,7 +107,7 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle OrderLimitCnt: &limitCount, }, }}, - CreatorId: &v.VendorSkuID, + CreatorId: utils.String2Pointer(utils.Int2Str(rand.Int())), CreatorName: &v.LastOperator, OutActId: utils.String2Pointer(utils.Int2Str(v.ActID)), } From 1095857dd3e03ffdeb2080b4445376191749190a Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 17:29:32 +0800 Subject: [PATCH 05/10] 1 --- .../partner/purchase/tao_vegetable/act.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index d97fcfd1b..c5da7b861 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -62,10 +62,10 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle var ( limitCount = int64(1) userLimitCount = int64(1) - fixPriceMoney = int64(0) - discountRate = int64(0) - decreaseMoney = int64(0) - limitDaily = int64(0) + //fixPriceMoney = int64(0) + discountRate = int64(0) + //decreaseMoney = int64(0) + limitDaily = int64(1) ) if act.LimitCount > 0 { limitCount = int64(act.LimitCount) @@ -86,19 +86,19 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle sType := *actType2Txd(v.Type) switch sType { case tao_vegetable.DiscountTypeDeductMoney: - decreaseMoney = v.VendorPrice - v.ActualActPrice + //decreaseMoney = v.VendorPrice - v.ActualActPrice case tao_vegetable.DiscountTypeOnePrice: - fixPriceMoney = v.ActualActPrice + //fixPriceMoney = v.ActualActPrice case tao_vegetable.DiscountTypeDiscounts: discountRate = int64(v.PricePercentage * 10) } actData = &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddItemDiscountActivityElementOperateRequest{ SkuElements: &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ - SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), - FixPriceMoney: &fixPriceMoney, - DiscountRate: &discountRate, - DecreaseMoney: &decreaseMoney, + SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), + //FixPriceMoney: &fixPriceMoney, + DiscountRate: &discountRate, + //DecreaseMoney: &decreaseMoney, Limit: &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddLimitDto{ TotalLimitCnt: &stock, DailyTotalLimitCnt: &limitDaily, From 9146a54c1cd5b83a72939ee0539022425d1b36f0 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 17:37:25 +0800 Subject: [PATCH 06/10] 1 --- .../partner/purchase/tao_vegetable/act.go | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index c5da7b861..93f183abb 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -62,10 +62,10 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle var ( limitCount = int64(1) userLimitCount = int64(1) - //fixPriceMoney = int64(0) - discountRate = int64(0) - //decreaseMoney = int64(0) - limitDaily = int64(1) + fixPriceMoney = int64(0) + discountRate = int64(0) + decreaseMoney = int64(0) + limitDaily = int64(1) ) if act.LimitCount > 0 { limitCount = int64(act.LimitCount) @@ -83,21 +83,11 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle stock = int64(v.Stock) } - sType := *actType2Txd(v.Type) - switch sType { - case tao_vegetable.DiscountTypeDeductMoney: - //decreaseMoney = v.VendorPrice - v.ActualActPrice - case tao_vegetable.DiscountTypeOnePrice: - //fixPriceMoney = v.ActualActPrice - case tao_vegetable.DiscountTypeDiscounts: - discountRate = int64(v.PricePercentage * 10) - } - actData = &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddItemDiscountActivityElementOperateRequest{ SkuElements: &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), //FixPriceMoney: &fixPriceMoney, - DiscountRate: &discountRate, + //DiscountRate: &discountRate, //DecreaseMoney: &decreaseMoney, Limit: &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddLimitDto{ TotalLimitCnt: &stock, @@ -111,7 +101,25 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle CreatorName: &v.LastOperator, OutActId: utils.String2Pointer(utils.Int2Str(v.ActID)), } - //actData = append(actData, temp) + + sType := *actType2Txd(v.Type) + switch sType { + case tao_vegetable.DiscountTypeDeductMoney: + decreaseMoney = v.VendorPrice - v.ActualActPrice + actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + DecreaseMoney: &decreaseMoney, + }} + case tao_vegetable.DiscountTypeOnePrice: + fixPriceMoney = v.ActualActPrice + actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + FixPriceMoney: &fixPriceMoney, + }} + case tao_vegetable.DiscountTypeDiscounts: + discountRate = int64(v.PricePercentage * 10) + actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + DiscountRate: &discountRate, + }} + } } } return actData From 792f16a85e0095b54d88cbbc4eda3e41e1b37933 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 17:45:29 +0800 Subject: [PATCH 07/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 93f183abb..e0a7acbd3 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -107,17 +107,29 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle case tao_vegetable.DiscountTypeDeductMoney: decreaseMoney = v.VendorPrice - v.ActualActPrice actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), DecreaseMoney: &decreaseMoney, + Limit: &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddLimitDto{ + OrderLimitCnt: &limitCount, + }, }} case tao_vegetable.DiscountTypeOnePrice: fixPriceMoney = v.ActualActPrice actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), FixPriceMoney: &fixPriceMoney, + Limit: &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddLimitDto{ + OrderLimitCnt: &limitCount, + }, }} case tao_vegetable.DiscountTypeDiscounts: discountRate = int64(v.PricePercentage * 10) actData.SkuElements = &[]domain.AlibabaRetailMarketingItemdiscountActivitySkuAddSkuActivityElementDto{{ + SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), DiscountRate: &discountRate, + Limit: &domain.AlibabaRetailMarketingItemdiscountActivitySkuAddLimitDto{ + OrderLimitCnt: &limitCount, + }, }} } } From a9b3883f40abfc233d763190daedf10b63ed8569 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 17:50:01 +0800 Subject: [PATCH 08/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index e0a7acbd3..4b054ca30 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -25,7 +25,7 @@ func actType2Txd(actType int) *int64 { actType = tao_vegetable.DiscountTypeDeductMoney } else if actType == model.ActSkuSecKill { actType = tao_vegetable.DiscountTypeOnePrice - } else { + } else if actType == model.ActSkuDiscount { actType = tao_vegetable.DiscountTypeDiscounts } return utils.Int64ToPointer(int64(actType)) @@ -103,6 +103,7 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle } sType := *actType2Txd(v.Type) + globals.SugarLogger.Debugf("sType=%d", sType) switch sType { case tao_vegetable.DiscountTypeDeductMoney: decreaseMoney = v.VendorPrice - v.ActualActPrice From b3ae42fc6d0bcd3d5729ac8da94e937ce4680fad Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 17:53:39 +0800 Subject: [PATCH 09/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 4b054ca30..94ec9c0b6 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -77,6 +77,7 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle } for _, v := range actStoreSku { + globals.SugarLogger.Debugf("打印初始商品参数 sku=%s", utils.Format4Output(v, false)) if handler == nil || handler(v.SyncStatus) { stock := int64(0) if v.Stock > 0 { From 824b3c18506918dac694695e228ba7bd9906bf5c Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 7 Jul 2023 18:05:14 +0800 Subject: [PATCH 10/10] 1 --- business/partner/purchase/tao_vegetable/act.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/act.go b/business/partner/purchase/tao_vegetable/act.go index 94ec9c0b6..3a3cfea4b 100644 --- a/business/partner/purchase/tao_vegetable/act.go +++ b/business/partner/purchase/tao_vegetable/act.go @@ -20,7 +20,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" ) -func actType2Txd(actType int) *int64 { +func actType2Txd(actType int) int64 { if actType == model.ActSkuDirectDown { actType = tao_vegetable.DiscountTypeDeductMoney } else if actType == model.ActSkuSecKill { @@ -28,7 +28,7 @@ func actType2Txd(actType int) *int64 { } else if actType == model.ActSkuDiscount { actType = tao_vegetable.DiscountTypeDiscounts } - return utils.Int64ToPointer(int64(actType)) + return int64(actType) } func actOrderRules2Mtwm(actOrderRules []*model.ActOrderRule) (actDetails []*mtwmapi.FullDiscountActDetail) { @@ -51,7 +51,7 @@ func act2TxdActivity(act *model.Act2) (activity *domain.AlibabaRetailMarketingIt Description: &act.Advertising, Terminals: &[]int32{tao_vegetable.TerminalsAPP}, //StoreIds: &[]string{act.s}, - DiscountType: actType2Txd(act.Type), + DiscountType: utils.Int64ToPointer(actType2Txd(act.Type)), StartTime: utils.Int64ToPointer(act.BeginAt.UnixNano() / int64(time.Millisecond)), EndTime: utils.Int64ToPointer(act.EndAt.UnixNano() / int64(time.Millisecond)), } @@ -103,7 +103,7 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle OutActId: utils.String2Pointer(utils.Int2Str(v.ActID)), } - sType := *actType2Txd(v.Type) + sType := actType2Txd(v.Type) globals.SugarLogger.Debugf("sType=%d", sType) switch sType { case tao_vegetable.DiscountTypeDeductMoney: