diff --git a/platformapi/ebaiapi/shop_sku_test.go b/platformapi/ebaiapi/shop_sku_test.go
index 96e9eee5..8fe75597 100644
--- a/platformapi/ebaiapi/shop_sku_test.go
+++ b/platformapi/ebaiapi/shop_sku_test.go
@@ -288,7 +288,7 @@ func TestDeleteSku(t *testing.T) {
Page: 1,
PageSize: 100,
}
- skuInfo, err := api.SkuList("669089", param1)
+ skuInfo, err := api.SkuList("100215", param1)
if err != nil {
fmt.Println(err)
return
@@ -300,7 +300,7 @@ func TestDeleteSku(t *testing.T) {
Page: i,
PageSize: 100,
}
- skuInfo2, err2 := api.SkuList("669089", param)
+ skuInfo2, err2 := api.SkuList("100215", param)
if err2 != nil {
fmt.Println(err2)
}
@@ -309,7 +309,7 @@ func TestDeleteSku(t *testing.T) {
}
}
for i := 1; i <= skuInfo.Pages; i++ {
- data, err := api.SkuDelete(utils.GetUUID(), "669089", skuIds[i-1:i*100], nil)
+ data, err := api.SkuDelete(utils.GetUUID(), "100215", skuIds[i-1:i*100], nil)
fmt.Println(data)
fmt.Println(err)
}
diff --git a/platformapi/ebaiapi/shop_test.go b/platformapi/ebaiapi/shop_test.go
index cbf4b111..db4a5a50 100644
--- a/platformapi/ebaiapi/shop_test.go
+++ b/platformapi/ebaiapi/shop_test.go
@@ -9,10 +9,73 @@ import (
func TestShopList(t *testing.T) {
result, err := api.ShopList(SysStatusAll)
+
if err != nil {
t.Fatal(err)
- } else {
- t.Log(utils.Format4Output(result, false))
+ }
+
+ data := make(map[string]int64, 0)
+ dataErr := make(map[string]int64, 0)
+ vendorKey := make([]int64, 0, 0)
+ for _, v := range result {
+ if len(v.ShopID) != 6 {
+ dataErr[v.ShopID] = v.BaiduShopID
+ vendorKey = append(vendorKey, v.BaiduShopID)
+ }
+ }
+
+ for _, vk := range vendorKey {
+ status2, _ := api.ShopBusStatusGet("", vk, "")
+ if status2 == 2 || status2 == 3 {
+ globals.SugarLogger.Debugf("==vk : %d", vk)
+ }
+ }
+ t.Log(utils.Format4Output(data, false))
+ t.Log(utils.Format4Output(dataErr, false))
+ t.Log(utils.Format4Output(vendorKey, false))
+
+ //t.Log(utils.Format4Output(data, false))
+ //t.Log(utils.Format4Output(dataErr, false))
+}
+
+//todo 修改ebai平台与本地映射
+func TestShopIDBatchUpdate(t *testing.T) {
+ var (
+ fBaiduShopIDs []string
+ fShopIDs []string
+ )
+ key := map[int64]string{
+ 509107995: "668893",
+ }
+ for k, v := range key {
+ k1 := utils.Int64ToStr(k)
+ remoteRel, err := api.ShopGet2("", k)
+ fmt.Sprintf("err====%v", err)
+ if remoteRel.ShopID != v {
+ fBaiduShopIDs = append(fBaiduShopIDs, k1)
+ fShopIDs = append(fShopIDs, v)
+ }
+ }
+ fmt.Sprintf("fBaiduIDs=====%s", fBaiduShopIDs)
+ fmt.Sprintf("fBaiduIDs=====%s", fShopIDs)
+ err := api.ShopIDBatchUpdate(fBaiduShopIDs, fShopIDs)
+ //err := api.ShopIDBatchUpdate([]string{utils.Int2Str(2235877567)}, []string{"100920"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ // err = api.ShopIDBatchUpdate([]string{utils.Int2Str(testShopBaiduID)}, []string{testShopID})
+ // if err != nil {
+ // t.Fatal(err)
+ // }
+}
+
+func TestShopIDBatchUpdate2(t *testing.T) {
+ data := map[string]int64{
+ "667252": 32267779552, "100200": 2233065993, "100489": 2233066035, "100876": 2233066089, "100306": 2233066125, "100805": 2233066147, "100726": 2233066189, "100999": 2233066221, "100972": 2233066288, "100933": 2233066508, "101667": 2235330385, "101691": 2233065954, "101686": 2235811199, "101075": 2235877563, "101793": 2233066050, "101040": 2234549767, "101747": 2235877564, "102091": 2267141526, "101666": 2267141507, "102001": 2267141468, "102316": 2267141488, "102126": 2267141487, "100717": 2233066054, "100203": 2233066065, "102170": 2267121508, "102197": 32267034115, "102404": 32267034132, "102362": 32267034127, "102116": 2267092843, "102130": 32267089386, "102154": 32267089387, "102418": 32267089392, "102501": 32267089401, "102495": 32267089402, "102525": 32267089415, "102505": 32267089419, "102535": 32267089420, "102536": 32267089421, "102547": 32267089424, "100617": 32267105197, "102610": 32267105203, "102615": 32267105205, "102653": 32267105211, "102667": 32267105218, "102709": 32267144438, "102745": 32267144444, "102776": 32267144467, "102086": 2267141477, "102888": 32267184020, "102806": 32267184025, "102869": 32267184037, "102849": 32267184061, "102698": 2233065970, "102575": 2267030904, "102976": 32267258872, "102992": 32267315045, "102293": 32267315069, "103093": 32267358106, "102973": 32267184017, "103088": 32267387505, "100922": 32267388562, "100326": 2235877566, "103062": 32267630601, "102997": 32267358124, "666918": 32267655031, "667176": 32267655039, "667154": 32267715494, "101107": 32267779547, "100162": 32267779555, "667084": 32267674079, "667398": 32267804825, "667421": 32267812971, "103127": 32267387534, "102180": 32267715495, "667339": 32267144482, "667445": 32267089406, "667083": 32267674060, "666916": 32267630644, "103085": 32267105208, "667400": 32267812970, "667139": 32267630624, "102925": 32267804790, "102063": 32267184031, "100117": 32267779369, "666921": 32267742254, "102383": 2234778219, "668786": 508226060, "669232": 512276503, "669201": 1176226197,
+ }
+ for k, v := range data {
+ err := api.ShopIDBatchUpdate([]string{utils.Int64ToStr(v)}, []string{k})
+ globals.SugarLogger.Debugf("err := %v", err)
}
}
@@ -131,37 +194,6 @@ func TestShopStatusGet(t *testing.T) {
}
}
-//todo 修改ebai平台与本地映射
-func TestShopIDBatchUpdate(t *testing.T) {
- var (
- fBaiduShopIDs []string
- fShopIDs []string
- )
- key := map[int64]string{
- 509107995: "668893",
- }
- for k, v := range key {
- k1 := utils.Int64ToStr(k)
- remoteRel, err := api.ShopGet2("", k)
- fmt.Sprintf("err====%v", err)
- if remoteRel.ShopID != v {
- fBaiduShopIDs = append(fBaiduShopIDs, k1)
- fShopIDs = append(fShopIDs, v)
- }
- }
- fmt.Sprintf("fBaiduIDs=====%s", fBaiduShopIDs)
- fmt.Sprintf("fBaiduIDs=====%s", fShopIDs)
- err := api.ShopIDBatchUpdate(fBaiduShopIDs, fShopIDs)
- //err := api.ShopIDBatchUpdate([]string{utils.Int2Str(2235877567)}, []string{"100920"})
- if err != nil {
- t.Fatal(err)
- }
- // err = api.ShopIDBatchUpdate([]string{utils.Int2Str(testShopBaiduID)}, []string{testShopID})
- // if err != nil {
- // t.Fatal(err)
- // }
-}
-
func TestSupplierList(t *testing.T) {
result, err := api.SupplierList()
if err != nil {
diff --git a/platformapi/jdapi/sku_test.go b/platformapi/jdapi/sku_test.go
index d16dd8c9..ccc78166 100644
--- a/platformapi/jdapi/sku_test.go
+++ b/platformapi/jdapi/sku_test.go
@@ -8,17 +8,11 @@ import (
"testing"
)
-//func TestQueryPageBrandInfo(t *testing.T) {
-// result, _, err := api.QueryPageBrandInfo(0, 0, 0, "京西")
-// if err != nil {
-// t.Fatal(err)
-// }
-// if len(result) == 0 {
-// t.Fatal("QueryPageBrandInfo brand list is empty!")
-// }
-// baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err)
-//}
-//
+func TestQueryPageBrandInfo(t *testing.T) {
+ fmt.Println((3 & 1) != 0)
+ fmt.Println(0&256 == 0)
+}
+
func TestQueryCategoriesByOrgCode(t *testing.T) {
result, err := api.QueryCategoriesByOrgCode()
if err != nil {
diff --git a/platformapi/jxprintapi/jxprintapi_test.go b/platformapi/jxprintapi/jxprintapi_test.go
index 7c0a7447..93d4e225 100644
--- a/platformapi/jxprintapi/jxprintapi_test.go
+++ b/platformapi/jxprintapi/jxprintapi_test.go
@@ -118,15 +118,29 @@ func TestName23(t *testing.T) {
url := "https://www.jxc4.com/v2/store/sku/UpdateStoresSkus"
var storeList = []int64{
- 100206, 100324, 100328, 100451, 100476, 101099, 102411, 102424, 102473, 102594, 102686, 102691, 102807, 102809, 102906, 102931, 103050, 103425, 666678, 666709, 668184, 668620, 668951, 668984, 669012, 669136, 669145, 669159,
+ 101036,
+ 668614,
+ 668986,
+ 668545,
+ 668642,
+ 100726,
+ 102475,
+ 668849,
+ 100129,
+ 669055,
+ 668659,
+ 668095,
+ 668631,
+ 668802,
+ 669025,
}
for _, v := range storeList {
- payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storeIDs\"\r\n\r\n[" + utils.Int64ToStr(v) + "]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n[{\"nameID\":9564,\"unitPrice\":2600}]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"causeFlag\"\r\n\r\n16\r\n-----011000010111000001101001--\r\n\r\n")
+ payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storeIDs\"\r\n\r\n[" + utils.Int64ToStr(v) + "]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n[{\"nameID\":11557,\"unitPrice\":5000}]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"causeFlag\"\r\n\r\n16\r\n-----011000010111000001101001--\r\n\r\n")
req, _ := http.NewRequest("PUT", url, payload)
- req.Header.Add("token", "TOKEN.V2.2452A93EEB9111EC9B06525400E86DC0.20240109-135510.localpass.A5DBAB2FAEB311EEB77C525400E86DC0.[18981810340]")
+ req.Header.Add("token", "TOKEN.V2.2452A93EEB9111EC9B06525400E86DC0.20240521-140307.localpass.CB50D7D0173711EFB566525400E86DC0.[18981810340]")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
_, err := http.DefaultClient.Do(req)
diff --git a/platformapi/mtwmapi/act.go b/platformapi/mtwmapi/act.go
index 73b6aa87..6d912492 100644
--- a/platformapi/mtwmapi/act.go
+++ b/platformapi/mtwmapi/act.go
@@ -438,7 +438,7 @@ func (a *API) RetailDiscountList(poiCode string, actType int) (actList []*GetSto
if len(tmpActList) < limit {
break
}
- offset++
+ offset = (offset + 1) * limit
} else {
return nil, err
}
@@ -581,11 +581,12 @@ func (a *API) InStoreCouponDelete(poiCode string, actIDList []string) (err error
// 查询商家券(店内发券)活动
// http://developer.waimai.meituan.com/home/docDetail/314
// 页码从1开始
-func (a *API) InStoreCouponList(poiCode string, pageNum, pageSize int) (couponActList []*CouponActInfo, err error) {
+func (a *API) InStoreCouponList(poiCode string, actType, pageNum, pageSize int) (couponActList []*CouponActInfo, err error) {
result, err := a.AccessAPI("act/instore/coupon/list", false, map[string]interface{}{
KeyAppPoiCode: poiCode,
"page_num": pageNum,
"page_size": pageSize,
+ "type": actType,
})
if err == nil {
err = utils.Map2StructByJson(result, &couponActList, false)
diff --git a/platformapi/mtwmapi/act_copy.go b/platformapi/mtwmapi/act_copy.go
new file mode 100644
index 00000000..fc72724a
--- /dev/null
+++ b/platformapi/mtwmapi/act_copy.go
@@ -0,0 +1,446 @@
+package mtwmapi
+
+import (
+ "encoding/json"
+ "git.rosy.net.cn/baseapi/utils"
+)
+
+//#region 买赠活动 (未测试,暂无门店有次活动)
+
+// BatchQueryBuyGiftsAll 批量查询门店买赠活动
+func (a *API) BatchQueryBuyGiftsAll(appPoiCode string) ([]*BatchQueryBuyGiftsAll, error) {
+ params := map[string]interface{}{
+ KeyAppPoiCode: appPoiCode,
+ "offset": 0,
+ "limit": 200,
+ }
+ i := 0
+
+ buyGifts := make([]*BatchQueryBuyGiftsAll, 0, 0)
+
+ for {
+ params["offset"] = i
+ result, err := a.AccessAPI2("act/buygifts/list", true, params, "data", "")
+ if err != nil {
+ return nil, err
+ }
+ buyGift := make([]*BatchQueryBuyGiftsAll, 0, 0)
+ resultStr, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+ if err = json.Unmarshal([]byte(resultStr), &buyGift); err != nil {
+ return nil, err
+ }
+ buyGifts = append(buyGifts, buyGift...)
+ if len(buyGift) < 200 {
+ break
+ }
+ i++
+ }
+
+ return buyGifts, nil
+}
+
+// BatchCreateBuyGifts 批量创建满赠活动,最大每组200数据
+func (a *API) BatchCreateBuyGifts(appPoiCode string, param []*BatchCreateBuyGiftsParam) (interface{}, error) {
+ params := map[string]interface{}{
+ KeyAppPoiCode: appPoiCode,
+ "act_data": string(utils.MustMarshal(param)),
+ }
+
+ result, err := a.AccessAPI2("act/buygifts/batchsave", false, params, resultKeySuccessMsg, "")
+
+ return result, err
+}
+
+//#endregion
+
+//#region 满减(商品满减/门店满减)活动
+
+// BatchGetDiscountList 批量获取门店满减活动列表 actType = 0 ,暂时不支持actType = 1 的返回,因为返回值里面没有商品详情
+func (a *API) BatchGetDiscountList(appPoiCode string, actType int) ([]*GetDiscountList, error) {
+ result, err := a.AccessAPI2("act/full/discount/list", false, map[string]interface{}{KeyAppPoiCode: appPoiCode, "act_type": actType}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+ discountList := make([]*GetDiscountList, 0, 0)
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &discountList); err != nil {
+ return nil, err
+ }
+
+ return discountList, nil
+}
+
+// BatchCreateDiscountList 批量创建满减活动
+// 下面接口暂时不支持actType = 1 的活动创建因为上面接口查询返回时没有返回商品ID的详细信息,没返回actDetails 的信息所以无法创建
+func (a *API) BatchCreateDiscountList(param *CreateDiscountList) (*CreateDiscountResult, error) {
+
+ result, err := a.AccessAPI2("act/full/discount/batchsave", false, utils.Struct2Map(param, "", false), "", "")
+ if err != nil {
+ return nil, err
+ }
+
+ createDiscountResult := &CreateDiscountResult{}
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &createDiscountResult); err != nil {
+ return nil, err
+ }
+
+ return createDiscountResult, nil
+}
+
+//#endregion
+
+//#region 运费满减活动,只能获取阶梯运费活动,不能获取立减活动,且两个活动互斥,同一时间段只生效一个活动
+
+// BatchGetShippingFee 查询运费满减活动配置
+func (a *API) BatchGetShippingFee(appPoiCode string) (*ShippingFeeResult, error) {
+ result, err := a.AccessAPI2("act/full/discount/shippingfee/list", true, map[string]interface{}{KeyAppPoiCode: appPoiCode}, "", "")
+ if err != nil {
+ return nil, err
+ }
+ shippingFee := &ShippingFeeResult{}
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &shippingFee); err != nil {
+ return nil, err
+ }
+
+ return shippingFee, nil
+}
+
+// BatchCreateShippingFee 创建运费满减活动
+func (a *API) BatchCreateShippingFee(AppPoiCode string, param []*ShippingFeeBatchCreateActData) (*ShippingResultData, error) {
+ byteData, err := json.Marshal(param)
+ if err != nil {
+ return nil, err
+ }
+ paramMap := map[string]interface{}{
+ AppPoiCode: AppPoiCode,
+ "act_data": string(byteData),
+ }
+ result, err := a.AccessAPI2("act/full/discount/shippingfee/batchsave", false, paramMap, "", "")
+ if err != nil {
+ return nil, err
+ }
+
+ shippingFeeCreate := &ShippingResultData{}
+ byteResult, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteResult, &shippingFeeCreate); err != nil {
+ return nil, err
+ }
+
+ return shippingFeeCreate, nil
+}
+
+//#endregion
+
+//#region 获取门店折扣爆品活动
+
+// QueryProductsAll 获取门店折扣爆品活动列表
+func (a *API) QueryProductsAll(poiCode string, actType int) (actList []*GetStoreRetailDiscountActData, err error) {
+ return a.RetailDiscountList(poiCode, actType)
+}
+
+// CreateProductsAct 创建门店折扣爆品活动
+func (a *API) CreateProductsAct(poiCode string, actType int, actData []*RetailDiscountActData) (actResult []*RetailDiscountActResult, failedList []*AppFoodResult, err error) {
+ return a.RetailDiscountBatchSave2(poiCode, actType, actData)
+}
+
+//##endregion
+
+//#region 查询商家券(店内发券)活动
+
+// QueryStoreCoupon 查询商家券店内发券
+func (a *API) QueryStoreCoupon(poiCode string) (couponActList []*CouponActInfo, err error) {
+ couponActList = make([]*CouponActInfo, 0, 0)
+ pageNum := 1
+ pageSize := 20
+ actType := 1
+ for {
+ actList, err := a.InStoreCouponList(poiCode, actType, pageNum, pageSize)
+ if err != nil {
+ return nil, err
+ }
+ if len(actList) != 0 {
+ couponActList = append(couponActList, actList...)
+ }
+
+ if len(actList) < pageSize && actType == 1 {
+ pageNum = 1
+ actType = 2
+ } else if len(actList) < pageSize && actType == 2 {
+ break
+ } else {
+ pageNum += 1
+ }
+ }
+ // 暂时只查询单店商家券
+ return couponActList, nil
+}
+
+// CreateStoreCouponBatch 批量新增单店店内商家券
+func (a *API) CreateStoreCouponBatch(poiCode string, limitTime *LimitTime, couponInfoList []*CouponInfo) (couponResultList []*CouponResult, err error) {
+ return a.InStoreCouponBatchSave(poiCode, limitTime, couponInfoList)
+}
+
+//#endregion
+
+//#region X件优惠活动
+
+// QueryBundlesAct 本接口用于商家查询门店内X元M件、X件Y折活动的基本信息。 actType,0-X元M件,2-X件Y折,不填默认为0(待上线)
+func (a *API) QueryBundlesAct(poiCode string, actType int) ([]*BundlesSuccessListDetail, error) {
+ result, err := a.AccessAPI2("act/item/bundles/list", true, map[string]interface{}{KeyAppPoiCode: poiCode, "type": actType}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+ bundlesList := make([]*BundlesSuccessListDetail, 0, 0)
+
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &bundlesList); err != nil {
+ return nil, err
+ }
+
+ return bundlesList, nil
+}
+
+func (a *API) QueryBundlesSku(appPoiCode string, actId string) ([]*BundlesSkuSuccessListDetail, error) {
+ result, err := a.AccessAPI2("act/item/bundles/foods/list", true, map[string]interface{}{KeyAppPoiCode: appPoiCode, "act_id": actId}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+ resultByte, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+ resultData := make([]*BundlesSkuSuccessListDetail, 0, 0)
+
+ if err = json.Unmarshal(resultByte, &resultData); err != nil {
+ return nil, err
+ }
+
+ return resultData, nil
+}
+
+// CreateBundlesAct 创建X件优惠活动
+func (a *API) CreateBundlesAct(poiCode string, param *CreateBundlesActParam) ([]*BundlesSuccessListDetail, error) {
+ paramByte, err := json.Marshal(param)
+ if err != nil {
+ return nil, err
+ }
+
+ result, err := a.AccessAPI2("act/item/bundles/save", true, map[string]interface{}{KeyAppPoiCode: poiCode, "act_data": string(paramByte)}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+ bundlesList := make([]*BundlesSuccessListDetail, 0, 0)
+
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &bundlesList); err != nil {
+ return nil, err
+ }
+
+ return bundlesList, nil
+}
+
+//#endregion
+
+//#region 加价购 [暂时不对接,获取不到商品的换购价格和库存]
+
+// QueryStoreRepurchase 查询门店所有加价购活动信息
+func (a *API) QueryStoreRepurchase(poiCode string) ([]*RepurchaseResult, error) {
+ result, err := a.AccessAPI2("act/markup/repurchase/list", true, map[string]interface{}{KeyAppPoiCode: poiCode}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+ repurchaseList := make([]*RepurchaseResult, 0, 0)
+
+ byteData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(byteData, &repurchaseList); err != nil {
+ return nil, err
+ }
+
+ return repurchaseList, nil
+}
+
+// QueryStoreSkuAct 查询门店商品层次的活动
+func (a *API) QueryStoreSkuAct() {
+ // act/markup/repurchase/main/food/list
+}
+
+// CreateStoreRepurchase 创建加价活动
+func (a *API) CreateStoreRepurchase(poiCode string, param *RepurchaseCreate) ([]*RepurchaseCreateResult, error) {
+ result, err := a.AccessAPI2("act/markup/repurchase/batchsave", false, map[string]interface{}{KeyAppPoiCode: poiCode, "act_data": param}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ byteResult, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ data := make([]*RepurchaseCreateResult, 0, 0)
+ if err := json.Unmarshal(byteResult, &data); err != nil {
+ return nil, err
+ }
+
+ return data, nil
+}
+
+//#endregion
+
+//#region 商品券活动
+
+// CreateCouponAct 创建门店商品券活动
+func (a *API) CreateCouponAct(param *CreateCouponAct) ([]*CreateStoreCouponActResult, error) {
+ byteParam, err := json.Marshal(param)
+ if err != nil {
+ return nil, err
+ }
+ result, err := a.AccessAPI2("act/goods/coupon/save", false, map[string]interface{}{"goods_coupon_data": string(byteParam)}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ resultData, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+ successList := make([]*CreateStoreCouponActResult, 0, 0)
+ if err := utils.UnmarshalUseNumber(resultData, &successList); err != nil {
+ return nil, err
+ }
+
+ return successList, nil
+}
+
+// GetStoreCouponAct 获取门店商品券活动
+func (a *API) GetStoreCouponAct(param *GetStoreCouponActParam) ([]*GetStoreCouponActSuccessList, error) {
+ paramMap := utils.Struct2Map(param, "", false)
+ result, err := a.AccessAPI2("act/goods/coupon/list", true, paramMap, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ data := make([]*GetStoreCouponActSuccessList, 0, 0)
+ for _, v := range result.([]interface{}) {
+ coupon := &GetStoreCouponActSuccessList{}
+ storeCouponAct, _ := json.Marshal(v)
+ if err = json.Unmarshal(storeCouponAct, coupon); err != nil {
+ return nil, err
+ }
+
+ //if len(coupon.ActPriceCouponInfo) != 0 || coupon.ActPriceCouponInfo != nil {
+ // actPriceCouponInfoObj := make([]GetStoreCouponActSuccessListActPriceCouponInfo, 0, 0)
+ // for _, apci := range coupon.ActPriceCouponInfo {
+ // apciObj := GetStoreCouponActSuccessListActPriceCouponInfo{}
+ // if err = json.Unmarshal([]byte(apci), apciObj); err != nil {
+ // return nil, err
+ // }
+ // actPriceCouponInfoObj = append(actPriceCouponInfoObj, apciObj)
+ // }
+ // coupon.ActPriceCouponInfoObj = actPriceCouponInfoObj
+ //}
+ //if len(coupon.DiscountCouponInfo) != 0 || coupon.DiscountCouponInfo != nil {
+ // discountCouponInfo := make([]GetStoreCouponActSuccessListDiscountCouponInfo, 0, 0)
+ // for _, dci := range coupon.DiscountCouponInfo {
+ // dciObj := GetStoreCouponActSuccessListDiscountCouponInfo{}
+ // if err = json.Unmarshal([]byte(dci), dciObj); err != nil {
+ // return nil, err
+ // }
+ // discountCouponInfo = append(discountCouponInfo, dciObj)
+ // }
+ // coupon.DiscountCouponInfoObj = discountCouponInfo
+ //}
+
+ data = append(data, coupon)
+ }
+
+ return data, nil
+}
+
+// GetCouponActSkuList 批量查询商品券活动中的商品
+func (a *API) GetCouponActSkuList(poiCode, actIds string) ([]*CouponActSkuListSuccessList, error) {
+ result, err := a.AccessAPI2("act/goods/coupon/goodslist", true, map[string]interface{}{"app_poi_code": poiCode, "act_ids": actIds}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ successList := make([]*CouponActSkuListSuccessList, 0, 0)
+ resultByte, err := json.Marshal(result)
+ if err != nil {
+ return nil, err
+ }
+
+ if err = json.Unmarshal(resultByte, &successList); err != nil {
+ return nil, err
+ }
+
+ return successList, nil
+}
+
+//#endregion
+
+//#region 第N件优惠活动
+
+// GetStoreNDiscount 获取门店第N件优惠活动
+func (a *API) GetStoreNDiscount(poiCode string) ([]*GetStoreXDiscountSuccessList, error) {
+ result, err := a.AccessAPI2("act/nth/discount/info", true, map[string]interface{}{KeyAppPoiCode: poiCode}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ data := make([]*GetStoreXDiscountSuccessList, 0, 0)
+ if err := json.Unmarshal([]byte(result.(string)), &data); err != nil {
+ return nil, err
+ }
+
+ return data, nil
+}
+
+// CreateStoreNDiscount 创建门店地N件优惠活动
+func (a *API) CreateStoreNDiscount(poiCode string, param *CreateStoreXDiscountParam) ([]*CreateStoreXDiscountResult, error) {
+ paramStr, err := json.Marshal(param)
+ if err != nil {
+ return nil, err
+ }
+
+ result, err := a.AccessAPI2("act/nth/discount/save", true, map[string]interface{}{KeyAppPoiCode: poiCode, "act_data": string(paramStr)}, "success_list", "")
+ if err != nil {
+ return nil, err
+ }
+
+ return result.([]*CreateStoreXDiscountResult), nil
+}
+
+//#endregion
diff --git a/platformapi/mtwmapi/act_copy_model.go b/platformapi/mtwmapi/act_copy_model.go
new file mode 100644
index 00000000..bcef7403
--- /dev/null
+++ b/platformapi/mtwmapi/act_copy_model.go
@@ -0,0 +1,482 @@
+package mtwmapi
+
+//#region 买赠活动
+
+// BatchCreateBuyGiftsParam 活动创建参数
+type BatchCreateBuyGiftsParam struct {
+ AppSpuCode string `json:"app_spu_code"` // APP方商品id
+ StartTime int64 `json:"start_time"` // 活动开始时间,传10位秒级的时间戳
+ EndTime int64 `json:"end_time"` // 活动结束时间,传10位秒级的时间戳
+ GiftsType int `json:"gifts_type"` // 赠品类型。取值范围:0-非本商品非在售商品;1-本商品;2-非本商品在售商品
+ GiftsName string `json:"gifts_name,omitempty"` // 为赠品名称
+ GiftsAppSpuCode string `json:"gifts_app_spu_code,omitempty"` // 非本商品在售商品id,当gifts_type=2时上传。
+ BuyNum int `json:"buy_num"` // 达到送赠品条件的商品购买数量,须上传大于0的正整数
+ GiftsNum int `json:"gifts_num"` // 达到购买数量时赠送的赠品数量。须上传大于0的为正整数。例如buy_num=2,gifts_num=3,则代表买2件商品,赠送3件赠品。
+ GiftsCharge float64 `json:"gifts_charge"` // 单个赠品的成本,单位是元。此字段信息须大于0,最多支持两位小数。注意,赠品成本为商家成本,不涉及美团成本。
+ GiftsDayLimit int `json:"gifts_day_limit"` // 当日活动赠品库存,字段类型int。须上传大于0的正整数或-1,如传-1则表示不限制活动赠品库存。
+}
+
+// BatchQueryBuyGiftsAll 活动创建参数
+type BatchQueryBuyGiftsAll struct {
+ ItemId int `json:"item_id"` // 活动id
+ AppSpuCode string `json:"app_spu_code"` // 活动商品,为APP方商品id,即商家中台系统里商品的编码(spu_code值)。
+ AppPoiCode string `json:"app_poi_code"` //
+ GiftsType int `json:"gifts_type"` // 赠品类型,参考值:0-非本商品非在售商品;1-本商品;2-非本商品在售商品。
+ GiftsName string `json:"gifts_name"` // 赠品名称
+ GiftsAppSpuCode string `json:"gifts_app_spu_code"` // 赠品的app_spu_code信息,非活动本商品的店内在售商品。
+ StartTime int64 `json:"start_time"` // 开始时间
+ EndTime int64 `json:"end_time"` // 结束时间
+ BuyNum int `json:"buy_num"` // 达到送赠品条件的商品购买数量
+ GiftsNum int `json:"gifts_num"` //
+ BuyGiftsNum int `json:"buy_gifts_num"` //
+ GiftsCharge float64 `json:"gifts_charge"` //
+ GiftsDayLimit int `json:"gifts_day_limit"` // 当日活动赠品库存,为大于0的正整数或-1,如为-1则表示不限制活动赠品库存。
+ Status int `json:"status"` // 活动当前的状态,参考值:2-待生效;1-生效;0-过期
+ ItemName string `json:"item_name"` // 活动名称
+ BuyGiftsModel string `json:"buy_gifts_model"` // 补贴模式,目前仅有“商家进货补贴模式(走结算流程)”模式。
+ Charge string `json:"charge"` // 成本相关,单位是元。参数包括: giftsCharge,赠品成本; giftsPoiCharge,商家承担成本; giftsMtCharge,美团承担成本。
+}
+
+type GiftsChargeObj struct {
+ GiftsPoiCharge string `json:"giftsPoiCharge"` // 商家成本
+ GiftsMtCharge int `json:"giftsMtCharge"` // 美团成本
+ GiftsCharge string `json:"giftsCharge"` // 赠品成本
+}
+
+//#endregion
+
+//#region 满减活动
+
+// GetDiscountList 获取满减活动列表
+type GetDiscountList struct {
+ ActDetails []struct {
+ ActId interface{} `json:"act_id"`
+ ActPrice float64 `json:"act_price"`
+ AppFoodCode interface{} `json:"app_food_code"`
+ AppPoiCode interface{} `json:"app_poi_code"`
+ AppSpuCode interface{} `json:"app_spu_code"`
+ DayLimit interface{} `json:"day_limit"`
+ EndTime interface{} `json:"end_time"`
+ Name interface{} `json:"name"`
+ OrderLimit interface{} `json:"order_limit"`
+ OriginPrice float64 `json:"origin_price"`
+ Period interface{} `json:"period"`
+ StartTime interface{} `json:"start_time"`
+ Status interface{} `json:"status"`
+ Stock interface{} `json:"stock"`
+ UserType interface{} `json:"user_type"`
+ WeeksTime interface{} `json:"weeks_time"`
+ } `json:"act_details"` // 满减活动详情
+ ActInfo struct { // 活动信息,json格式字符串。
+ ActIds string `json:"act_ids"`
+ ActName string `json:"act_name"`
+ ActType interface{} `json:"act_type"`
+ AutoDelay interface{} `json:"auto_delay"`
+ EndTime int64 `json:"end_time"`
+ StartTime int64 `json:"start_time"`
+ ExtraInfo struct {
+ Offset interface{} `json:"offset"`
+ TotalCount interface{} `json:"total_count"`
+ Limit interface{} `json:"limit"`
+ PageNum interface{} `json:"page_num"`
+ TaskId interface{} `json:"task_id"`
+ BatchActId int64 `json:"batch_act_id"` // 批次维度活动ID
+ SkuExtraInfo []struct {
+ AppSpuCode interface{} `json:"app_spu_code"` // 同入参app_spu_code或app_food_code,仅在指定商品满减时返回
+ SkuId interface{} `json:"sku_id"` // 同入参sku_id,
+ SkuActId interface{} `json:"sku_act_id"` // 商品维度的活动ID
+ } `json:"sku_extra_info"` // sku维度活动额外信息,仅在指定商品满减时返回
+ PageSize interface{} `json:"page_size"`
+ } `json:"extraInfo"`
+ Period interface{} `json:"period"`
+ Quantity int `json:"quantity"` // 参加指定商品满减活动的商品数,仅适用于指定商品满减活动类型。
+ Status int `json:"status"` // 活动状态。(1)指定商品满减活动状态:2-待生效;1-生效;0-过期。(2)全店满减活动状态:0-待生效;1-生效;2-过期。
+ WeeksTime interface{} `json:"weeks_time"`
+ } `json:"act_info"`
+ ActRemark string `json:"act_remark"`
+ AppPoiCode string `json:"app_poi_code"`
+}
+
+// CreateDiscountList 创建满减活动(门店/商品)
+type CreateDiscountList struct {
+ AppPoiCode string `json:"app_poi_code"` // APP方门店id
+ ActInfo string `json:"act_info"` // 活动信息 CreateDisCountActInfo
+ ActDetails string `json:"act_details"` // 活动详情信息,json格式数组。活动满减不能超过5层阶梯。[CreateDiscountActDetails]
+ AppFoods string `json:"app_foods"` // 活动商品信息,为json格式数组,此字段仅用于创建指定商品满减活动时上传 [CreateDiscountAppFoods]
+}
+
+type CreateDisCountActInfo struct {
+ ActName string `json:"act_name"` // 活动名字
+ StartTime int64 `json:"start_time"` // 开始时间
+ EndTime int64 `json:"end_time"` // 结束时间
+ ActType int `json:"act_type"` // 活动类型,取值范围:0-全店满减;1-指定商品满减。如此字段不传则默认act_type=1,表示指定商品满减类型;act_type=0时,不可以传app_foods字段。
+ WeeksTime string `json:"weeks_time"` // 生效活动周期, 1、仅当act_type传0(全店满减)时,支持传本参数; 2、取值范围及意义:1,2,3,4,5,6,7;分别表示周一至周日,多个星期之间用英文逗号分隔; 3、非必传,创建时如不传,则默认周期为"1,2,3,4,5,6,7"。 4、上传的周期相互不能重复
+ Period string `json:"period"` // 生效时间段, 1、仅当act_type传0(全店满减)时,支持传本参数; 2、精确到分钟,24小时制,格式为HH:MM-HH:MM,最多支持上传3个时段,多个时段之间用英文逗号分隔; 3、每个时段的开始时间必须小于结束时间。传的多个时段不允许有重叠。 4、上传多个时段时,必须按时间先后顺序进行上传。每个时段最短为30分钟。 5、非必传,创建时如不传则默认时段为"00:00:-23:59"。
+ AutoDelay int `json:"auto_delay"` // 每次活动到期后自动延期30天,传1表示开启。 1、仅当act_type传0(全店满减)时,支持传本参数。 2、仅支持传1,表示开启,每当活动到期时自动延期30天。 3、非必传,创建活动时如不传则为关闭状态,不自动延期。
+}
+
+type CreateDiscountActDetails struct {
+ OriginPrice int `json:"origin_price"` // 表示满的金额
+ ActPrice int `json:"act_price"` // 表示减的金额
+}
+
+type CreateDiscountAppFoods struct {
+ AppSpuCode string `json:"app_spu_code"` // PP方商品id,即商家中台系统里商品的编码
+ DayLimit int `json:"day_limit"` // 当日活动商品库存,仅支持上传大于0的整数或-1,如传-1时则表示不限制商品活动库存。
+}
+
+// CreateDiscountResult 创建满减活动返回值结构
+type CreateDiscountResult struct {
+ Data string `json:"data"` // ok
+ SuccessMsg string `json:"success_msg"` // 活动ID
+ ExtraInfo []DiscountData `json:"extra_info"` //
+ ResultCode int `json:"result_code"` // 1-全部操作成功,查询到的数据在data字段中;2-部分成功,成功的数据存储在data字段中,失败的数据存在error_list字段中;3-全部操作失败,失败的数据存在error_list字段中;4-请求失败,一般为签名或限流问题,关注error字段中的具体描述即可
+ SuccessMap []DiscountData `json:"success_map"` // 成功的集合信息
+}
+
+type DiscountData struct {
+ TaskId string `json:"task_id"` // 当商家使用异步排队方式请求接口时返回,商家可使用任务id查询任务进度
+ TaskDetailLink string `json:"task_detail_link"` // 创建异步排队任务成功,返回任务详情链接,通过浏览器打开链接查看任务处理结果
+ BatchActId string `json:"batch_act_id"` // 批次维度活动ID,
+ SkuExtraInfo []struct {
+ SkuActId int64 // 商品维度的活动ID
+ AppSpuCode string // 同入参app_spu_code
+ SkuId string // 同入参sku_id
+ } `json:"sku_extra_info"` // sku维度活动额外信息,仅在创建成功时返回,仅在指定商品满减时返回
+}
+
+//#endregion
+
+//#region 运费满减活动
+
+// ShippingFeeResult 满减运费活动配置
+type ShippingFeeResult struct {
+ ResultCode int `json:"result_code"` // 返回状态码
+ SuccessList []ShippingFeeDetail `json:"success_list"` // 成功上数据列表
+ Data []ShippingFeeDetail `json:"data"` // 好像是所有的数据列表
+}
+
+// ShippingFeeDetail 运费活动返回详情值
+type ShippingFeeDetail struct {
+ AppPoiCode string `json:"app_poi_code"` // 门店code
+ ActId int `json:"act_id"` // 活动ID
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ WeeksTime string `json:"weeks_time"` // 活动周期(周一-周末)
+ Period string `json:"period"` // 生效时间段,多个时段以英文逗号分隔;如创建活动时此字段未填写,则默认时段为"00:00:-23:59"。
+ ActDetail []struct {
+ LimitPrice float64 `json:"limit_price"` // 满减门槛
+ DiscountPrice float64 `json:"discount_price"` // 减配送费
+ PoiCharge float64 `json:"poi_charge"` // 门店承担费用
+ MtCharge float64 `json:"mt_charge"` // 美团承担费用
+ } `json:"act_detail"` // 活动详情
+ MaxPrice float64 `json:"max_price"` // 免配送费门槛
+ ActStatus string `json:"actStatus"` // 活动状态:NOT_START=待生效;IN_PROGRESS=已生效;EXPIRED=已过期;APPROVE=待审批;FREEZE=冻结中。
+}
+
+// ShippingFeeBatchCreate 批量创建阶梯满减活动
+type ShippingFeeBatchCreate struct {
+ AppPoiCode string `json:"app_poi_code"` // 门店code
+ ActData string `json:"act_data"` // 门店满减运费活动信息,json格式数组。(1)同一门店同一时间仅允许参加一个活动。(2)同一门店的生效中+待生效活动最多支持20组。
+}
+
+// ShippingFeeBatchCreateActData 活动详情
+type ShippingFeeBatchCreateActData struct {
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ WeeksTime string `json:"weeks_time"` // 活动周期(周一-周末)
+ Period string `json:"period"` // 生效时间段,多个时段以英文逗号分隔;如创建活动时此字段未填写,则默认时段为"00:00:-23:59"。
+ MaxPrice float64 `json:"max_price"` // 免配送费门槛
+ ActDetail []ShippingFeeBatchCreateActDataActDetail `json:"act_detail"` // 活动详情
+}
+
+type ShippingFeeBatchCreateActDataActDetail struct {
+ LimitPrice float64 `json:"limit_price"` // 满减门槛
+ DiscountPrice float64 `json:"discount_price"` // 减配送费
+}
+
+// ShippingResultData 运费满减活动创建返回值
+type ShippingResultData struct {
+ ResultCode int `json:"result_code"` // 返回状态码
+ SuccessList []ShippingFeeDetail `json:"success_list"` // 成功上数据列表
+ SuccessMsg []ShippingFeeDetail `json:"success_msg"` // 好像是所有的数据列表
+ Data string `json:"data"`
+ Msg string `json:"msg"`
+}
+
+//#endregion
+
+//#region 创建X元M件活动
+
+// CreateBundlesActParam 创建X件优惠活动
+type CreateBundlesActParam struct {
+ ActId int64 `json:"act_id"` // 更新时填写,活动ID
+ // 创建时填写
+ ActName string `json:"act_name"` // 活动名称
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ ActPrice float64 `json:"act_price"` // 活动价格
+ ActNum int `json:"act_num"` // 活动数量(表示“X元M件”中的M)
+ AppFoods []struct {
+ AppSpuCode string `json:"app_spu_code"` // 传APP方商品id
+ DayLimit int `json:"day_limit"` // 商品当日活动库存,须传大于0的整数或-1,如传-1则表示不限制商品活动库存。
+ } `json:"app_foods"` // 参加活动的商品信息
+}
+
+// BundlesSuccessListDetail 创建X件优惠活动返回值
+type BundlesSuccessListDetail struct {
+ ActId int64 `json:"act_id"` // 活动id
+ BatchActId int64 `json:"batch_act_id"` // 批次维度活动ID
+ ActDetails []struct {
+ Discount float64 `json:"discount"` // 活动折扣,表示“X件Y折”中的Y折
+ ActNum int `json:"act_num"` // 活动数量,表示“X件Y折”中的X件
+ } `json:"act_details"` // 活动优惠信息,最多返回3个阶梯(只有X件Y折返回该信息)
+ ExtraInfo struct {
+ BatchActId int64 `json:"batch_act_id"` // 批次维度活动ID
+ SkuExtraInfo []struct {
+ SkuActId int64 `json:"sku_act_id"` // 商品维度的活动ID,该ID是对act_id的补全
+ AppSpuCode string `json:"app_spu_code"` // 活动商品,传APP方商品id,即商家中台系统里商品的编码(spu_code值)。
+ SkuId string `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回null
+ }
+ } `json:"extraInfo"` // 活动额外信息,包括批次和商品维度活动id(X件Y折不返回该信息)
+ ActName string `json:"act_name"` // 活动名称
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ ActRemark string `json:"act_remark"` //活动文案
+}
+
+// BundlesSkuSuccessListDetail 查询X件商品优惠活动商品信息返回值
+type BundlesSkuSuccessListDetail struct {
+ AppSpuCode string `json:"app_spu_code"` // 活动商品,传APP方商品id,即商家中台系统里商品的编码(spu_code值)。
+ SkuId string `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回null
+ DayLimit int `json:"day_limit"` // 商品当日活动库存,须为大于0的整数或-1,如传-1则表示不限制。
+}
+
+//#endregion
+
+//#region 加价购活动
+
+// RepurchaseCreate 创建门店加价购活动
+type RepurchaseCreate struct {
+ // 修改时填写
+ ActId int64 `json:"act_id"` // 活动ID
+
+ // 创建时填写
+ ActName string `json:"act_name"` // 活动名称
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ ActPrice float64 `json:"act_price"` // 换购门槛,表示可参加本次换购活动的订单金额门店(不包含运费),
+ ActRemark string `json:"actRemark"` // 加价换购活动描述
+ AppFoods []RepurchaseCreateAppFoods `json:"app_foods"` // 参加换购的活动商品数据
+}
+
+type RepurchaseCreateAppFoods struct {
+ AppSpuCode string `json:"app_spu_code"` // 活动商品,传APP方商品id
+ ActPrice float64 `json:"act_price"` // 活动价(单价),表示换购一件此商品需额外支付的价格,单位元;活动价不能大于商品原价
+ DayLimit int `json:"day_limit"` // 商品当日活动库存,须为大于0的整数或-1,如传-1则表示不限制。
+}
+
+type RepurchaseCreateResult struct {
+ SkuActId string `json:"sku_act_id"` // 商品维度的活动ID,该ID是对act_id的补全
+ AppSpuCode string `json:"app_spu_code"` // 同入参app_spu_code
+ SkuId string `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回null
+}
+
+// RepurchaseResult 获取门店加价购活动返回值
+type RepurchaseResult struct {
+ ActId int64 `json:"act_id"` // 活动ID
+ ActName string `json:"act_name"` // 活动名称
+ StartTime int `json:"start_time"` // 开始时间
+ EndTime int `json:"end_time"` // 结束时间
+ ActPrice float64 `json:"act_price"` // 换购门槛,表示可参加本次换购活动的订单金额门店(不包含运费),
+ ActRemark string `json:"actRemark"` // 加价换购活动描述
+ OrderLimitTotal int `json:"order_limit_total"` // 每单可换购的商品总数,为大于0的整数或-1,如为-1则表示不限制。
+ ExtraInfo struct {
+ BatchActId int64 `json:"batch_act_id"` // 批次维度活动ID
+ SkuExtraInfo []struct {
+ SkuActId int64 `json:"sku_act_id"` // 商品维度的活动ID
+ AppSpuCode string `json:"app_spu_code"` // 活动商品,传APP方商品id
+ SkuId interface{} `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回nu
+ } `json:"sku_extra_info"` // sku维度活动额外信息
+ } `json:"extraInfo"` // 活动额外信息,包括批次和商品维度活动id
+}
+
+//#endregion
+
+//#region 商品券活动
+
+// CreateCouponAct 创建门店优惠券活动
+type CreateCouponAct struct {
+ AppPoiCodes string `json:"app_poi_codes"` // 可使用券的门店id列表,多个用英文逗号分隔
+ CouponName string `json:"coupon_name"` // 券名称,不能超过12个字符,仅支持汉字、数字和字母。
+ IsSinglePoi int `json:"is_single_poi"` // 券使用范围是否限制单门店,取值范围:0-门店通用券;1-单门店券。(1)门店通用券:如app_poi_codes字段传的门店ABC,则A门店领,ABC门店通用。(2)单门店券:A门店领,仅A门店用。
+ AppSpuCodes string `json:"app_spu_codes"` // 参加活动的商品,传APP方商品id,即商家中台系统里商品的编码(spu_code值)。(1)如不同门店内同一商品的app_spu_code不同,则视为不同商品,多个商品id用英文逗号分隔。(2)当创建按折扣的商品券活动且discount=0时,本参数仅支持传一个参加活动的商品
+ SpuData []CreateCouponActSpuData `json:"spu_data"` // 创建商品券活动支持按照sku维度创建,传入spu_data字段。若同时传入spu_data和app_spu_code字段,默认以spu_data数据为准进行创建商品券
+ TakeCouponStartTime int64 `json:"take_coupon_start_time"` // 领券开始时间,传10位秒级的时间戳。
+ TakeCouponEndTime int64 `json:"take_coupon_end_time"` // 领券结束时间,传10位秒级的时间戳。
+ UseCouponStartTime int64 `json:"use_coupon_start_time"` // 用券开始时间,传10位秒级的时间戳。
+ CouponLimitCount int64 `json:"coupon_limit_count"` // 活动期间每个用户领券的最大数量限制,范围1~99999999的整数。
+ Type int `json:"type"` // 商品券类型,取值范围:1-按活动价格;2-按折扣。
+ ActPriceCouponInfo []GetStoreCouponActSuccessListActPriceCouponInfo `json:"act_price_coupon_info"` // 按活动价格的商品券信息,json格式数组。按活动价格的商品券活动最多支持设置三层优惠。
+ DiscountCouponInfo []GetStoreCouponActSuccessListDiscountCouponInfo `json:"discount_coupon_info"` // 按折扣的商品券信息,json格式数组。(1)当discount大于0时,折扣商品券活动的优惠信息不能超过三层。(2)当discount等于0时,为商品兑换券活动,仅支持设置一层。
+}
+
+// CreateCouponActSpuData SpuData参数
+type CreateCouponActSpuData struct {
+ AppSpuCode string `json:"app_spu_code"` // APP方商品id
+ SkuId string `json:"sku_id"` // 是sku唯一标识码,字段信息限定长度不能超过40个字符。不允许上传emoji等表情符。
+ Upc string `json:"upc"` // upc
+}
+
+//// CreateActPriceCouponInfo ActPriceCouponInfo 参数
+//type CreateActPriceCouponInfo struct {
+// FullPrice int `json:"full_price"` // 券使用门槛金额,范围是1~999的正整数,单位元。
+// ReducePrice int `json:"reduce_price"` // 券金额,范围是1~999的正整数,单位元;表示达到使用门槛后可以减的金额
+// Stock int `json:"stock"` // 券库存,范围1-99999的正整数。(1)当选择单门店券时(is_single_poi=1),该库存指的是每门店的券库存。(2) 当选择门店通用券时(is_single_poi=0),该库存指的是所有门店共享的券库存
+// UseType int `json:"user_type"` // 可领券的用户,取值范围:0-新客&老客;1-门店联合新客(原新客,全部可用门店为新客);2-老客; 7-门店新客(当前门店为新客)。如不传此字段,则默认为0。
+//}
+//
+//// CreateDiscountCouponInfo DiscountCouponInfo 参数
+//type CreateDiscountCouponInfo struct {
+// FullPrice int `json:"full_price"` // 券使用门槛金额,范围是1~999的正整数,单位元。
+// Discount float64 `json:"discount"` // 折扣系数,需大于0且小于10,最多一位小数;或传0,表示兑换券。当discount=0时,则此活动为无门槛商品兑换券活动;此时app_spu_codes字段上传的商品数不能大于1个,且该商品不可再参加其他优惠活动。
+// MaxReducePrice int64 `json:"max_reduce_price"`
+// Stock int `json:"stock"` // 券库存,范围1-99999的正整数。(1)当选择单门店券时(is_single_poi=1),该库存指的是每门店的券库存。(2) 当选择门店通用券时(is_single_poi=0),该库存指的是所有门店共享的券库存
+// UseType int `json:"user_type"` // 可领券的用户,取值范围:0-新客&老客;1-门店联合新客(原新客,全部可用门店为新客);2-老客; 7-门店新客(当前门店为新客)。如不传此字段,则默认为0。
+//}
+
+// CreateStoreCouponActResult 获取门店优惠券活动
+type CreateStoreCouponActResult struct {
+ AppPoiCodes []string `json:"app_poi_codes"` // 门店ID列表
+ AppSpuCodes []string `json:"app_spu_codes"` // 成功商品列表
+ UpcList []string `json:"upc_list"` // 成功商品upc列表
+ ActId int64 `json:"act_id"` // 活动ID
+}
+
+// GetStoreCouponActParam 获取门店商品券活动
+type GetStoreCouponActParam struct {
+ AppPoiCode string `json:"app_poi_code"` // 门店ID
+ ActStatus int `json:"act_status"` // 活动当前状态,取值范围:-1-全部;0-未生效;1-已生效;2-已结束。
+ StartTime int64 `json:"start_time"` // 开始时间
+ EndTime int64 `json:"end_time"` // 结束时间
+ PageNum int `json:"page_num"` // 页码
+ PageSize int `json:"page_size"` // 页数
+}
+
+// GetStoreCouponActSuccessList 获取门店优惠券返回列表
+type GetStoreCouponActSuccessList struct {
+ ActId int64 `json:"actId"` // 活动id
+ AppPoiCodes string `json:"app_poi_codes"` // 可使用券的门店列表
+ CouponName string `json:"coupon_name"` // 券名称
+ IsSinglePoi int `json:"is_single_poi"` // 券使用范围是否限制单门店,参考值:0-门店通用券;1-单门店券。(1)门店通用券:如app_poi_codes字段传的门店ABC,则A门店领,ABC门店通用。(2)单门店券:A门店领,仅A门店用。
+ TakeCouponStartTime int64 `json:"take_coupon_start_time"` // 领券开始时间
+ TakeCouponEndTime int64 `json:"take_coupon_end_time"` // 领券结束时间
+ UseCouponStartTime int64 `json:"use_coupon_start_time"` // 用券开始时间
+ CouponLimitCount int64 `json:"coupon_limit_count"` // 活动期间每个用户领券的最大数量限制,范围1~99999999的整数
+ Type int64 `json:"type"` // 商品券类型,参考值:1-按活动价格;2-按折扣。
+ //ActPriceCouponInfo []interface{} `json:"act_price_coupon_info"` // 按活动价格的商品券信息,json格式数组。按活动价格的商品券活动最多支持设置三层优惠
+ ActPriceCouponInfo []GetStoreCouponActSuccessListActPriceCouponInfo `json:"-"`
+ //DiscountCouponInfo []interface{} `json:"discount_coupon_info"` // 按折扣的商品券信息,json格式数组。(1)当discount大于0时,为折扣商品券活动,优惠信息最多三层。(2)当discount等于0时,为商品兑换券活动,优惠信息仅一层
+ DiscountCouponInfo []GetStoreCouponActSuccessListDiscountCouponInfo `json:"-"`
+}
+
+// GetStoreCouponActSuccessListActPriceCouponInfo ActPriceCouponInfo数据
+type GetStoreCouponActSuccessListActPriceCouponInfo struct {
+ FullPrice int `json:"full_price"` // 券使用门槛金额,范围是1~999的正整数,单位元。
+ ReducePrice int `json:"reduce_price"` // 券金额,范围是1~999的正整数,单位元;表示达到使用门槛后可以减的金额。
+ Stock int `json:"stock"` // 券库存,范围1-99999的正整数。(1)当选择单门店券时(is_single_poi=1),该库存指的是每门店的券库存。(2) 当选择门店通用券时(is_single_poi=0),该库存指的是所有门店共享的券库存。
+ UserType int `json:"user_type"` // 可领券的用户,取值范围:null或0-新客&老客;1-门店联合新客(原新客,全部可用门店为新客);2-老客; 7-门店新客(当前门店为新客)。
+}
+
+// GetStoreCouponActSuccessListDiscountCouponInfo DiscountCouponInfo
+type GetStoreCouponActSuccessListDiscountCouponInfo struct {
+ FullPrice int `json:"full_price"` // 券使用门槛金额,范围是1~999的正整数,单位元。
+ Discount float64 `json:"discount"` // 折扣系数,范围0-10之间,最多一位小数;或为0,表示无门槛商品兑换券活
+ MaxReducePrice int `json:"max_reduce_price"` // 券最高可减金额,单位元。(1)当discount大于0时,为折扣商品券活动,优惠信息最多三层。(2)当discount等于0时,为商品兑换券活动,不支持设置最高可减金额,max_reduce_price默认为0。
+ Stock int `json:"stock"` // 券库存,范围1-99999的正整数。(1)当选择单门店券时(is_single_poi=1),该库存指的是每门店的券库存。(2) 当选择门店通用券时(is_single_poi=0),该库存指的是所有门店共享的券库存。
+ UserType int `json:"user_type"` // 可领券的用户,取值范围:null或0-新客&老客;1-门店联合新客(原新客,全部可用门店为新客);2-老客; 7-门店新客(当前门店为新客)。
+}
+
+// CouponActSkuListSuccessList 获取商品券活动商品列表
+type CouponActSkuListSuccessList struct {
+ ActId int `json:"actId"` // 活动ID
+ AppPoiCodes string `json:"app_poi_codes"` // 门店ID
+ CouponName string `json:"coupon_name"` // 活动名称
+ IsSinglePoi int `json:"is_single_poi"` // 券使用范围是否限制单门店,参考值:0-门店通用券;1-单门店券。(1)门店通用券:如app_poi_codes字段传的门店ABC,则A门店领,ABC门店通用。(2)单门店券:A门店领,仅A门店用。
+ AppSpuCodes string `json:"app_spu_codes"` // 商品ID
+ TakeCouponStartTime int64 `json:"take_coupon_start_time"` // 领券开始时间
+ TakeCouponEndTime int64 `json:"take_coupon_end_time"` // 领券结束时间
+ UseCouponStartTime int64 `json:"use_coupon_start_time"` // 使用开始时间
+ CouponLimitCount int64 `json:"coupon_limit_count"` // 用户领券最大数
+ Type int `json:"type"` // 商品券类型,参考值:1-按活动价格;2-按折扣。
+ ActPriceCouponInfo []GetStoreCouponActSuccessListActPriceCouponInfo `json:"act_price_coupon_info"` // 按活动价格的商品券信息,json格式数组。按活动价格的商品券活动最多支持设置三层优惠。
+ DiscountCouponInfo []GetStoreCouponActSuccessListDiscountCouponInfo `json:"discount_coupon_info"` // 按折扣的商品券信息,json格式数组。(1)当discount大于0时,为折扣商品券活动,优惠信息最多三层。(2)当discount等于0时,为商品兑换券活动,优惠信息仅一层。
+
+ ActStatus int `json:"act_status"`
+ AppFoodCodes string `json:"app_food_codes"`
+ CouponRetailType int `json:"coupon_retail_type"`
+ IsShare int `json:"is_share"`
+ SpuData []struct {
+ AppSpuCode string `json:"app_spu_code"`
+ SkuId string `json:"sku_id"`
+ Upc string `json:"upc"`
+ } `json:"spu_data"`
+ UseCouponEndTime int `json:"use_coupon_end_time"`
+ ValidityDays int `json:"validity_days"`
+}
+
+//#endregion
+
+//#region 第X件优惠活动
+
+// GetStoreXDiscountSuccessList 第X件优惠返回值
+type GetStoreXDiscountSuccessList struct {
+ ActId int64 `json:"act_id"`
+ BatchActId string `json:"batch_act_id"` // 批次维度活动ID,
+ StartTime int64 `json:"start_time"` // 开始时间
+ EndTime int64 `json:"end_time"` // 结束时间
+ ActName string `json:"act_name"` // 活动名字
+ ActSettingType int `json:"act_setting_type"` // 1)字段描述:活动子类型选择。 2)取值范围:0-第N件X折;1-第N件X元。 3)活动信息的字段规则根据此字段而变化
+ ActDetails []GetStoreXDiscountSuccessListActDetails `json:"act_details"` // 1)字段描述:活动具体信息。 2)至少有一阶,最多三阶。
+ ExtraInfo GetStoreXDiscountSuccessListExtraInfo `json:"extra_info"`
+}
+
+// GetStoreXDiscountSuccessListActDetails ActDetails
+type GetStoreXDiscountSuccessListActDetails struct {
+ Price string `json:"price"` // 1)字段描述:活动商品售价 2)取值范围:0≤X,最多支持两位小数。 3)此范围当“活动子类型”为1时有效
+ Discount string `json:"discount"` // 1)字段描述:活动商品折扣系数。 2)取值范围:0≤X≤9.99,最多支持两位小数。 3)此范围当“活动子类型”为0时有效
+ Index int `json:"index"` // 1)字段描述:活动商品件数。 2)取值范围:N:1≤N≤5
+}
+
+// GetStoreXDiscountSuccessListExtraInfo ExtraInfo
+type GetStoreXDiscountSuccessListExtraInfo struct {
+ BatchActId int64 `json:"batch_act_id"` // 批次维度活动ID
+ SkuExtraInfo []struct {
+ SkuActId int64 `json:"sku_act_id"` // 商品维度的活动ID,该ID是对act_id的补全
+ AppSpuCode string `json:"app_spu_code"` // 同入参app_spu_code
+ SkuId string `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回null
+ } `json:"sku_extra_info"` // sku维度活动额外信息
+}
+
+// CreateStoreXDiscountParam 创建地X件优惠活动
+type CreateStoreXDiscountParam struct {
+ ActId int64 `json:"act_id"`
+ ActName string `json:"act_name"` // 活动名字
+ StartTime int64 `json:"start_time"` // 开始时间
+ EndTime int64 `json:"end_time"` // 结束时间
+ ActSettingType int `json:"act_setting_type"` // 1)字段描述:活动子类型选择。 2)取值范围:0-第N件X折;1-第N件X元。 3)活动信息的字段规则根据此字段而变化
+ ActDetails []GetStoreXDiscountSuccessListActDetails `json:"act_details"` // 1)字段描述:活动具体信息。 2)至少有一阶,最多三阶。
+ ActProducts []struct {
+ AppSpuCode string `json:"app_spu_code"` // (原app_food_code字段) 1)字段描述:活动商品编码。 2)选择第N件X元时,所选商品原价必须大于活动价X。 3)仅支持单规格商品参加活动 4)商品原价乘活动件数必须大于活动价。 5)如填写了活动id,输入未在活动中存在的app_spu_code,默认为在该活动中新增参加活动的商品。 6)如填写了活动id,输入已在活动中存在的app_spu_code,则认为更新此活动中该商品库存信息。
+ DayLimit int `json:"day_limit"` // 1)字段描述:活动商品当日库存。 2)格式:正整数,不大于999999999。 3)如当日库存为无限,则传-1。
+ } `json:"act_products"`
+}
+
+// CreateStoreXDiscountResult 创建X件优惠返回值
+type CreateStoreXDiscountResult struct {
+ SkuActId int64 `json:"sku_act_id"` // 商品维度的活动ID,该ID是对act_id的补全
+ AppSpuCode string `json:"app_spu_code"` // 同入参app_spu_code
+ SkuId string `json:"sku_id"` // 商品规格id,本接口暂未支持多规格商品创建活动,均返回null
+}
+
+//#endregion
diff --git a/platformapi/mtwmapi/act_copy_test.go b/platformapi/mtwmapi/act_copy_test.go
new file mode 100644
index 00000000..066fcf67
--- /dev/null
+++ b/platformapi/mtwmapi/act_copy_test.go
@@ -0,0 +1,420 @@
+package mtwmapi
+
+import (
+ "encoding/json"
+ "fmt"
+ "git.rosy.net.cn/baseapi/utils"
+ "git.rosy.net.cn/jx-callback/globals"
+ "testing"
+ "time"
+)
+
+var fromStoreId = "7111680"
+var toStoreId = "8694010"
+
+func TestBatchQueryBuyGiftsAll(t *testing.T) {
+ var errData = make([]error, 0, 0)
+ buyGiftList, err := api.BatchQueryBuyGiftsAll(fromStoreId)
+
+ if err != nil {
+ errData = append(errData, fmt.Errorf("买赠活动异常:%v", errData))
+ return
+ }
+ if len(buyGiftList) == 0 {
+ errData = append(errData, fmt.Errorf("门店暂无买赠活动"))
+ return
+ }
+
+ param := make([]*BatchCreateBuyGiftsParam, 0, 0)
+ for _, v := range buyGiftList {
+ buyGift := &BatchCreateBuyGiftsParam{
+ AppSpuCode: v.AppSpuCode,
+ StartTime: v.StartTime,
+ EndTime: v.EndTime,
+ GiftsType: v.GiftsType,
+ GiftsName: v.GiftsName,
+ GiftsAppSpuCode: v.GiftsAppSpuCode,
+ BuyNum: v.BuyNum,
+ GiftsNum: v.GiftsNum,
+ GiftsCharge: v.GiftsCharge,
+ GiftsDayLimit: v.GiftsDayLimit,
+ }
+ // 赠品成本
+ giftsCharge := &GiftsChargeObj{}
+ if err := json.Unmarshal([]byte(v.Charge), giftsCharge); err != nil {
+ return
+ }
+
+ buyGift.GiftsCharge = utils.Str2Float64(fmt.Sprintf("%.2f", utils.Str2Float64(giftsCharge.GiftsCharge)))
+ param = append(param, buyGift)
+ }
+
+ result, err := api.BatchCreateBuyGifts(toStoreId, param)
+ globals.SugarLogger.Debugf("result := %s", utils.Format4Output(result, false))
+ globals.SugarLogger.Debugf("result := %v", err)
+}
+
+// 获取门店满减
+func TestBatchGetDiscountList(t *testing.T) {
+ // 全店满减活动
+ data, err := api.BatchGetDiscountList(fromStoreId, 0)
+ globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(data, false))
+ globals.SugarLogger.Debugf("err:= %v", err)
+ for k, v := range data {
+ param := &CreateDiscountList{
+ AppPoiCode: toStoreId,
+ ActInfo: "",
+ ActDetails: "",
+ AppFoods: "",
+ }
+ actInfo := &CreateDisCountActInfo{
+ StartTime: v.ActInfo.StartTime,
+ EndTime: v.ActInfo.EndTime,
+ ActType: 0, // 0 不传app_food
+ AutoDelay: 1,
+ }
+ if v.ActInfo.ActName != "" {
+ actInfo.ActName = v.ActInfo.ActName
+ } else {
+ actInfo.ActName = "全店满减" + utils.Int2Str(k)
+ }
+
+ actInfoByte, err := json.Marshal(actInfo)
+ if err != nil {
+ return
+ }
+ param.ActInfo = string(actInfoByte)
+
+ actDetails := make([]CreateDiscountActDetails, 0, 0)
+ for _, ads := range v.ActDetails {
+ actDetails = append(actDetails, CreateDiscountActDetails{
+ OriginPrice: utils.Float64TwoInt(ads.OriginPrice),
+ ActPrice: utils.Float64TwoInt(ads.ActPrice),
+ })
+ }
+ actDetailsByte, err := json.Marshal(actDetails)
+ if err != nil {
+ return
+ }
+ param.ActDetails = string(actDetailsByte)
+ api.BatchCreateDiscountList(param)
+ }
+}
+
+// 运费满减
+func TestGetShippingFee(t *testing.T) {
+ data, err := api.BatchGetShippingFee(fromStoreId)
+ if err != nil {
+ return
+ }
+
+ if data.SuccessList != nil && len(data.SuccessList) != 0 {
+ param := make([]*ShippingFeeBatchCreateActData, 0, 0)
+ for _, v := range data.SuccessList {
+ shippingFee := &ShippingFeeBatchCreateActData{
+ StartTime: v.StartTime,
+ EndTime: v.EndTime,
+ WeeksTime: v.WeeksTime,
+ Period: v.Period,
+ MaxPrice: v.MaxPrice,
+ }
+ actDetail := make([]ShippingFeeBatchCreateActDataActDetail, 0, 0)
+ for _, ad := range v.ActDetail {
+ actDetail = append(actDetail, ShippingFeeBatchCreateActDataActDetail{
+ LimitPrice: ad.LimitPrice,
+ DiscountPrice: ad.DiscountPrice,
+ })
+ }
+ shippingFee.ActDetail = actDetail
+
+ param = append(param, shippingFee)
+ }
+
+ resultData, err := api.BatchCreateShippingFee(toStoreId, param)
+ if err != nil {
+ return
+ }
+ if resultData.Data != "ok" {
+ return //resultData.Msg
+ }
+ return // nil
+ }
+
+ return // 满减运费活动获取失败
+ globals.SugarLogger.Debugf("==result := %s", utils.Format4Output(data, false))
+ globals.SugarLogger.Debugf("==err := %v", err)
+}
+
+// 创建折扣爆品活动
+func TestProductsAct(t *testing.T) {
+ secKillALL, err := api.QueryProductsAll(fromStoreId, RetailActTypeSecKill)
+ if err != nil {
+ return
+ }
+
+ killAct := make([]*RetailDiscountActData, 0, 0)
+ for _, v := range secKillALL {
+ kill := &RetailDiscountActData{
+ AppFoodCode: v.AppFoodCode,
+ UserType: v.UserType,
+ StartTime: v.StartTime,
+ EndTime: v.EndTime,
+ OrderLimit: v.OrderLimit,
+ DayLimit: v.DayLimit,
+ Period: v.Period,
+ WeeksTime: v.WeeksTime,
+ SettingType: v.SettingType,
+ ActPrice: v.ActPrice,
+ DiscountCoefficient: v.DiscountCoefficient,
+ Sequence: v.Sequence,
+ ItemID: v.ItemID,
+ OriginalPrice: v.OriginalPrice,
+ Stock: v.Stock,
+ Status: v.Status,
+ Name: v.Name,
+ }
+ killAct = append(killAct, kill)
+ }
+
+ //todo 折扣活动查询出来一万多条,暂时工单处理
+ directDownALL, err := api.QueryProductsAll(fromStoreId, RetailActTypeDirectDown)
+ for _, v := range directDownALL {
+ kill := &RetailDiscountActData{
+ AppFoodCode: v.AppFoodCode,
+ UserType: v.UserType,
+ StartTime: v.StartTime,
+ EndTime: v.EndTime,
+ OrderLimit: v.OrderLimit,
+ DayLimit: v.DayLimit,
+ Period: v.Period,
+ WeeksTime: v.WeeksTime,
+ SettingType: v.SettingType,
+ ActPrice: v.ActPrice,
+ DiscountCoefficient: v.DiscountCoefficient,
+ Sequence: v.Sequence,
+ ItemID: v.ItemID,
+ OriginalPrice: v.OriginalPrice,
+ Stock: v.Stock,
+ Status: v.Status,
+ Name: v.Name,
+ }
+ killAct = append(killAct, kill)
+ }
+ if len(killAct) != 0 {
+ _, _, err := api.CreateProductsAct(toStoreId, RetailActTypeSecKill, killAct)
+ if err != nil {
+ return
+ }
+
+ return
+ }
+
+}
+
+func TestQueryStoreCoupon(t *testing.T) {
+ couponList, err := api.QueryStoreCoupon(fromStoreId)
+ if err != nil {
+ return
+ }
+ if len(couponList) != 0 {
+ for _, v := range couponList {
+ couponInfoList := make([]*CouponInfo, 0, 0)
+ for _, ad := range v.ActData {
+ couponInfoList = append(couponInfoList, &CouponInfo{
+ LimitPrice: ad.LimitPrice,
+ CouponPrice: ad.CouponPrice,
+ UserType: ad.UserType,
+ ValidityDays: ad.ValidityDays,
+ Stock: ad.Stock,
+ })
+ }
+
+ limitTime := &LimitTime{
+ StartTime: v.StartTime,
+ EndTime: v.EndTime,
+ }
+
+ if _, err := api.CreateStoreCouponBatch(toStoreId, limitTime, couponInfoList); err != nil {
+ return
+ }
+ }
+ }
+ globals.SugarLogger.Debugf("======err := %v", err)
+ globals.SugarLogger.Debugf("======couponList := %s", utils.Format4Output(couponList, false))
+}
+
+// todo 创建X件Y折,X件减Y元活动查询不出来,商家端也不展示
+func TestQueryBundlesAct(t *testing.T) {
+ result := make([]*BundlesSuccessListDetail, 0, 0)
+ // X件M元
+ bundlesXM, _ := api.QueryBundlesAct(fromStoreId, 0)
+ if bundlesXM != nil {
+ result = append(result, bundlesXM...)
+ }
+ // X件Y折
+ bundlesXY, _ := api.QueryBundlesAct(fromStoreId, 2)
+ if bundlesXY != nil {
+ result = append(result, bundlesXY...)
+ }
+ globals.SugarLogger.Debugf("=bundlesXM := %s", utils.Format4Output(bundlesXM, false))
+ globals.SugarLogger.Debugf("=bundlesXY := %s", utils.Format4Output(bundlesXY, false))
+
+ for _, v := range result {
+ actSku, err := api.QueryBundlesSku(fromStoreId, utils.Int64ToStr(v.ActId))
+ globals.SugarLogger.Debugf("=actSku := %s", utils.Format4Output(actSku, false))
+ globals.SugarLogger.Debugf("=actSkuerr := %v", err)
+ }
+ // for _, as := range actSku {
+ // param := &CreateBundlesActParam{
+ // ActName: v.ActName,
+ // StartTime: v.StartTime,
+ // EndTime: v.EndTime,
+ // ActPrice: v.a,
+ // ActNum: v.a,
+ // AppFoods: nil,
+ // }
+ // api.CreateBundlesAct(toStoreId)
+ // }
+ //
+ //}
+ //for _, v := range result {
+ // param := &CreateBundlesActParam{
+ // ActId: 0, // 更新时填写
+ // ActName: v.ActName,
+ // StartTime: v.StartTime,
+ // EndTime: v.EndTime,
+ // ActPrice: 0,
+ // ActNum: 0,
+ // AppFoods: nil,
+ // }
+ // for _, ads := range v.ActDetails {
+ // param.ActPrice = ads.ActNum
+ // }
+ // api.CreateBundlesAct()
+ //}
+}
+
+// 加价购
+func TestQueryStoreRepurchase(t *testing.T) {
+
+ repurchase, err := api.QueryStoreRepurchase(fromStoreId)
+ //for _, v := range repurchase {
+ // param := &RepurchaseCreate{
+ // ActName: v.ActName,
+ // StartTime: v.StartTime,
+ // EndTime: v.EndTime,
+ // ActPrice: v.ActPrice,
+ // ActRemark: v.ActRemark,
+ // AppFoods: nil,
+ // }
+ // appFoods := make([]RepurchaseCreateAppFoods, 0, 0)
+ // for _, sei := range v.ExtraInfo.SkuExtraInfo {
+ // appFood := RepurchaseCreateAppFoods{
+ // AppSpuCode: sei.AppSpuCode,
+ // ActPrice: v.ActPrice,
+ // DayLimit: sei.,
+ // }
+ // }
+ // api.CreateStoreRepurchase(toStoreId,param)
+ //}
+ globals.SugarLogger.Debugf("=repurchase := %s", utils.Format4Output(repurchase, false))
+ globals.SugarLogger.Debugf("=bundlesXY := %v", err)
+}
+
+// 商品券
+func TestCreateCouponAct(t *testing.T) {
+
+ couponInfoAll := make([]*GetStoreCouponActSuccessList, 0, 0)
+ pageNumber := 1
+ pageSize := 100
+ for {
+ param := &GetStoreCouponActParam{
+ AppPoiCode: fromStoreId,
+ ActStatus: 1,
+ StartTime: time.Now().AddDate(-1, 0, 0).Unix(),
+ EndTime: time.Now().AddDate(1, 0, 0).Unix(),
+ PageNum: pageNumber,
+ PageSize: pageSize,
+ }
+
+ couponList, err := api.GetStoreCouponAct(param)
+ globals.SugarLogger.Debugf("=couponList := %s", utils.Format4Output(couponList, false))
+ globals.SugarLogger.Debugf("=err := %v", err)
+ if err != nil {
+ return
+ }
+ couponInfoAll = append(couponInfoAll, couponList...)
+ if len(couponList) < pageSize {
+ break
+ }
+ pageNumber++
+ }
+
+ for _, v := range couponInfoAll {
+ couponSkuList, err := api.GetCouponActSkuList(fromStoreId, utils.Int64ToStr(v.ActId))
+ if err != nil {
+ return
+ }
+
+ for _, csl := range couponSkuList {
+ param := &CreateCouponAct{
+ AppPoiCodes: csl.AppPoiCodes,
+ CouponName: csl.CouponName,
+ IsSinglePoi: csl.IsSinglePoi,
+ AppSpuCodes: csl.AppSpuCodes,
+ TakeCouponStartTime: csl.TakeCouponStartTime,
+ TakeCouponEndTime: csl.TakeCouponEndTime,
+ UseCouponStartTime: csl.UseCouponStartTime,
+ CouponLimitCount: csl.CouponLimitCount,
+ Type: csl.Type,
+ }
+
+ if csl.SpuData != nil && len(csl.SpuData) != 0 {
+ for _, sd := range csl.SpuData {
+ param.SpuData = append(param.SpuData, CreateCouponActSpuData{
+ AppSpuCode: sd.AppSpuCode,
+ SkuId: sd.SkuId,
+ Upc: sd.Upc,
+ })
+ }
+ }
+
+ if csl.ActPriceCouponInfo != nil && len(csl.ActPriceCouponInfo) != 0 {
+ //actPriceCouponInfoStr := make([]string, 0, 0)
+ //for _, apci := range csl.ActPriceCouponInfo {
+ // actPriceCouponInfo, _ := json.Marshal(apci)
+ // actPriceCouponInfoStr = append(actPriceCouponInfoStr, string(actPriceCouponInfo))
+ //}
+ param.ActPriceCouponInfo = csl.ActPriceCouponInfo
+ }
+ if csl.DiscountCouponInfo != nil && len(csl.DiscountCouponInfo) != 0 {
+ //discountCouponInfoStr := make([]string, 0, 0)
+ //for _, dci := range csl.DiscountCouponInfo {
+ // discountCouponInfo, _ := json.Marshal(dci)
+ // discountCouponInfoStr = append(discountCouponInfoStr, string(discountCouponInfo))
+ //}
+ param.DiscountCouponInfo = csl.DiscountCouponInfo
+ }
+
+ createCouponResult, err := api.CreateCouponAct(param)
+ if err != nil {
+ return
+ }
+ globals.SugarLogger.Debugf("=%v", createCouponResult)
+ }
+ }
+
+}
+
+func TestGetStoreNDiscount(t *testing.T) {
+ //discountResult, err := api.GetStoreNDiscount(fromStoreId)
+ //if err != nil {
+ // return
+ //}
+ //for _, v := range discountResult {
+ // api.CreateStoreNDiscount()
+ //}
+ //globals.SugarLogger.Debugf("dicountResult=%v", discountResult)
+ //globals.SugarLogger.Debugf("err =%v", err)
+
+}
diff --git a/platformapi/mtwmapi/act_test.go b/platformapi/mtwmapi/act_test.go
index 068f1048..7f3f3fcd 100644
--- a/platformapi/mtwmapi/act_test.go
+++ b/platformapi/mtwmapi/act_test.go
@@ -132,14 +132,6 @@ func TestNew(t *testing.T) {
}
}
-func TestInStoreCouponList(t *testing.T) {
- result, err := api.InStoreCouponList(testPoiCode, 1, 100)
- if err != nil {
- t.Fatal(err)
- }
- t.Log(utils.Format4Output(result, false))
-}
-
func TestParseErr4RetailDiscountDelete(t *testing.T) {
errStr := `
{"error_list":[{"act_id":1053302130,"error_msg":"活动ID不存在"},{"act_id":1053302127,"error_msg":"活动ID不存在"},{"act_id":1053302128,"error_msg":"活动ID不存在"},{"act_id":1053302129,"error_msg":"活动ID不存在"},{"act_id":1053302135,"error_msg":"活动ID不存在"},{"act_id":1053302132,"error_msg":"活动ID不存在"},{"act_id":1053302123,"error_msg":"活动ID不存在"},{"act_id":1053302125,"error_msg":"活动ID不存在"},{"act_id":1053302124,"error_msg":"活动ID不存在"},{"act_id":1053302133,"error_msg":"活动ID不存在"},{"act_id":1053302126,"error_msg":"活动ID不存在"},{"act_id":1053302134,"error_msg":"活动ID不存在"},{"act_id":1053302131,"error_msg":"活动ID不存在"}]}
diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go
index e1c61254..ab0fb50c 100644
--- a/platformapi/mtwmapi/mtwmapi_test.go
+++ b/platformapi/mtwmapi/mtwmapi_test.go
@@ -20,13 +20,13 @@ func init() {
baseapi.Init(sugarLogger)
// 菜市
- //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
+ api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
// 果园
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超
- api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_rzfK3TvMXrIDIlIT3s5CSg") //token_n4TwqCntWWuvQwAawzxC0w
+ //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_hVoW4uxX65tW2pJ-WxxEVw") //token_n4TwqCntWWuvQwAawzxC0w
cookieStr := `
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
`
diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go
index fac3ef73..cd500109 100644
--- a/platformapi/mtwmapi/order_test.go
+++ b/platformapi/mtwmapi/order_test.go
@@ -29,7 +29,7 @@ func getTimeFromTimestamp(timeStamp int64) time.Time {
}
func TestOrderGetOrderDetail(t *testing.T) {
- result, err := api.OrderGetOrderDetail(5900920842826988338, false)
+ result, err := api.OrderGetOrderDetail(2301030621026530024, false)
if err != nil {
t.Fatal(err)
}
diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go
index 62918708..84d4bfc3 100644
--- a/platformapi/mtwmapi/retail_test.go
+++ b/platformapi/mtwmapi/retail_test.go
@@ -229,8 +229,9 @@ func TestBatchSetPrice(t *testing.T) {
err := api.BatchSetRestockingPrice(utils.GetUUID(), "12422751", param)
fmt.Println(err)
}
+
func TestRetailDelete(t *testing.T) {
- poiCode := "20978764"
+ poiCode := "7954977"
i := 0
count := 0
@@ -243,11 +244,11 @@ func TestRetailDelete(t *testing.T) {
}
count += len(fromFoodList)
- //for k, v := range fromFoodList {
- // if err := api.RetailDelete(utils.Int2Str(k), poiCode, v.AppFoodCode); err != nil {
- // fmt.Println(err)
- // }
- //}
+ for k, v := range fromFoodList {
+ if err := api.RetailDelete(utils.Int2Str(k), poiCode, v.AppFoodCode); err != nil {
+ fmt.Println(err)
+ }
+ }
//stockList := make([]*BareStoreFoodInfo, 0, 100)
//for _, fl := range fromFoodList {
// stockList = append(stockList, &BareStoreFoodInfo{
diff --git a/platformapi/tao_vegetable/order_test.go b/platformapi/tao_vegetable/order_test.go
index 16ca64d6..f179c073 100644
--- a/platformapi/tao_vegetable/order_test.go
+++ b/platformapi/tao_vegetable/order_test.go
@@ -69,13 +69,19 @@ func TestQueryAfsOrderDetail(t *testing.T) {
}
+func Test222(t *testing.T) {
+ fmt.Println((3 & 1) != 0)
+}
+
// 接单
func TestDeliveryFinishACCEPTED(t *testing.T) {
+ orderID := 8000101702997900468
+ storeID := "JX102364"
param := &request591.AlibabaAelophyOrderWorkCallbackRequest{}
param.WorkCallbackRequest = &domain591.AlibabaAelophyOrderWorkCallbackWorkCallbackRequest{
- StoreId: utils.String2Pointer("lb019"),
- BizOrderId: utils.Int64ToPointer(5000952367288620290),
- Status: utils.String2Pointer(OrderStatusNew),
+ StoreId: utils.String2Pointer("JX102364"),
+ BizOrderId: utils.Int64ToPointer(int64(orderID)),
+ Status: utils.String2Pointer(OrderStatusSuccess),
StatusRemark: nil,
//DelivererName: utils.String2Pointer("张廷"),
//DelivererPhone: utils.String2Pointer("SIGN"),
@@ -83,9 +89,28 @@ func TestDeliveryFinishACCEPTED(t *testing.T) {
DelivererCompany: nil,
LogisticsNo: nil,
}
- apiTao.SetToken("50002C01524csKWniqfypk8dbshKRTeFIOIy1a46c0cfgsvodWjsseMsXqpvWvECMj1")
+
+ workCallbackSubOrderInfoList := make([]domain591.AlibabaAelophyOrderWorkCallbackWorkCallbackSubOrderInfo, 0, 0)
+ orderDetail, err := apiTao.QueryOrderDetail(&request591.AlibabaAelophyOrderGetRequest{OrderGetRequest: &domain591.AlibabaAelophyOrderGetOrderGetRequest{
+ StoreId: utils.String2Pointer(storeID),
+ BizOrderId: utils.Int64ToPointer(utils.Str2Int64(utils.Int2Str(orderID))),
+ }})
+ if err != nil {
+ return
+ }
+ for _, v := range *orderDetail.SubOrderResponseList {
+ workCallbackSubOrderInfo := domain591.AlibabaAelophyOrderWorkCallbackWorkCallbackSubOrderInfo{
+ BizSubOrderId: v.BizSubOrderId,
+ SkuCode: v.SkuCode,
+ PickSaleQuantity: utils.String2Pointer(utils.Float64ToStr(*v.BuySaleQuantity)),
+ PickStockQuantity: utils.String2Pointer(utils.Float64ToStr(*v.BuyStockQuantity)),
+ }
+ workCallbackSubOrderInfoList = append(workCallbackSubOrderInfoList, workCallbackSubOrderInfo)
+ }
+ param.WorkCallbackRequest.WorkCallbackSubOrderInfoList = &workCallbackSubOrderInfoList
+ apiTao.SetToken("50000C00432zMSClqLiSDjBr2NyiazjtFmsgTOdbBfti16a73f18k0XDfkUQywSmcjfC")
//apiTao.SetToken("50002C01524csKWniqfypk8dbshKRTeFIOIy1a46c0cfgsvodWjsseMsXqpvWvECMj1")
- err := apiTao.DeliveryFinish(param)
+ err = apiTao.DeliveryFinish(param)
fmt.Println(err)
}
diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go
index 8902c747..c8571418 100644
--- a/platformapi/tiktok_shop/tiktok_api/afs_test.go
+++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go
@@ -8,7 +8,7 @@ import (
)
// 京西速食(蔬菜)
-var token1 = `{"access_token":"8be82c25-3b46-41a6-8957-623b09cb2a5b","expires_in":1708521089,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"61c242d5-2b37-41a3-bf4a-199723621f58","authority_id":""}`
+var token1 = `{"access_token":"66e0618f-8e6b-43f8-baae-a9ca4e549cd8","expires_in":1716948768,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"eb392238-7f20-4ae4-ab5d-0b22543cbc4a","authority_id":""}`
// 美好菜市
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
@@ -36,7 +36,7 @@ func TestAggreOrNotAggreAfs(t *testing.T) {
}
func TestGetSkuDetailLocalID(t *testing.T) {
- data, err := a.GetSkuDetailLocalID("", "6094828")
+ data, err := a.GetSkuDetailLocalID("64270360", "30460")
globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
globals.SugarLogger.Debugf("data=%s", err)
}
diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go
index 2c800375..b830595b 100644
--- a/platformapi/tiktok_shop/tiktok_api/sku.go
+++ b/platformapi/tiktok_shop/tiktok_api/sku.go
@@ -312,10 +312,6 @@ func (a *API) GetSkuDetailLocalID(vendorStoreId, outProductId string) (*product_
param.StoreId = utils.Str2Int64(vendorStoreId)
result, err := request.Execute(a.accessTokenObj)
- if strings.Contains(result.SubMsg, "未找到或商品已删除") {
- return nil, nil
- }
-
if err != nil {
return nil, err
}
@@ -323,7 +319,7 @@ func (a *API) GetSkuDetailLocalID(vendorStoreId, outProductId string) (*product_
return nil, errors.New(result.SubMsg + ":" + result.LogId)
}
if result.Data.Status == 2 {
- return nil, nil
+ return nil, fmt.Errorf("商品已经删除")
}
return result.Data, nil
diff --git a/platformapi/trenditapi/trendit_test.go b/platformapi/trenditapi/trendit_test.go
index d128e7db..55b8f4fa 100644
--- a/platformapi/trenditapi/trendit_test.go
+++ b/platformapi/trenditapi/trendit_test.go
@@ -41,6 +41,69 @@ func TestAPI_Print(t *testing.T) {
fmt.Println(err)
}
+func TestAPI_AddPrinterOrder(t *testing.T) {
+
+ orderParams := []interface{}{}
+ data := `
+--------------------------------
+下单时间: %s
+期望送达: %s
+客户姓名: %s
+客户电话: %s
+店铺名称: %s
+订单编号: %s
+%s#%d
+%s
+` + `` + `--------------------------------
+客户地址: %s
+--------------------------------
+客户备注:%s
+--------------------------------
+商品名` + StrRepeat(" ", 15) + `数量` + StrRepeat(" ", 3) + `金额` + StrRepeat("-", 32) + `
+`
+ orderParams = append(orderParams,
+ "2024-05-21 13:10:00",
+ "2024-05-21 14:10:00",
+ "花花(先生)",
+ "18582476194,7712",
+ "成都若溪科技有限公司",
+ "2301082344187999120",
+ "美团外卖",
+ 19,
+ "2301082344187999120",
+ "仁恒置地广场 (12层)@#四川省成都市锦江区春熙路街道仁恒置地广场",
+ "【如遇缺货】:缺货时电话与我沟通 收货人隐私号 18582476194,7712,手机号 173****9503",
+ )
+
+ data += FormatPrintOrderItemBigV2("娃哈哈纯净水24瓶装", 8, 1)
+ data += `
共%d种%d件商品 实付:%s
+--------------#%d完-------------`
+ orderParams = append(orderParams, 1, 8, "321.00", 19)
+ context := fmt.Sprintf(data, orderParams...)
+
+ //context := `--------------------------------
+ //下单时间: 2024-05-21 13:10:00
+ //期望送达: 2024-05-21 14:10:00
+ //客户姓名: 花花(先生)
+ //客户电话: 18582476194,7712
+ //店铺名称: 成都若溪科技有限公司
+ //订单编号: 2301082344187999120
+ //美团外卖#19
+ //2301082344187999120
+ // 美团外卖#19--------------------------------
+ //客户地址: 仁恒置地广场 (12层)@#四川省成都市锦江区春熙路街道仁恒置地广场
+ //--------------------------------
+ //客户备注:【如遇缺货】:缺货时电话与我沟通 收货人隐私号 18582476194,7712,手机号 173****9503
+ //--------------------------------
+ //商品名 数量 金额
+ //--------------------------------
+ //1.哇哈哈纯净水24瓶装 x8 ¥321.0
共1种8件商品
+ //--------------#19完-------------`
+ result, err := api.Print("670020035344", context, "10")
+ fmt.Println(result)
+ fmt.Println(err)
+}
+
func TestCal(t *testing.T) {
fmt.Println(utils.Time2Str(time.Now()))
}