From 389d29366dfc4e36c18246c75e81ac6d1a1464a5 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Sat, 14 Aug 2021 09:52:56 +0800 Subject: [PATCH] aa --- platformapi/ebaiapi/activity.go | 101 +++++++++++++++++++++++ platformapi/ebaiapi/activity_test.go | 13 ++- platformapi/ebaiapi/order_test.go | 2 +- platformapi/jdshopapi/store_page_test.go | 12 +-- platformapi/mtwmapi/act_test.go | 2 +- platformapi/mtwmapi/mtwmapi_test.go | 4 +- 6 files changed, 122 insertions(+), 12 deletions(-) diff --git a/platformapi/ebaiapi/activity.go b/platformapi/ebaiapi/activity.go index 81b12a5b..701c827c 100644 --- a/platformapi/ebaiapi/activity.go +++ b/platformapi/ebaiapi/activity.go @@ -44,6 +44,15 @@ var ( "38", //:跨seller商品满减券, "39", //:跨seller运费券 } + + //优惠类型 + DiscountTypeMap = map[int]string{ + 1: "减钱", + 2: "折扣", + 3: "一口价", + 4: "买赠", + 5: "下单返券", + } ) type ActivityRule struct { @@ -272,6 +281,7 @@ func (a *API) ActivitySkuUpdateBatch(activityID int64, actSkuInfoList []*Activit func (a *API) ActMultiChannelQueryIDs(shopID string, baiduShopID int64, actType string) (actIDs []int64, err error) { params := a.genShopIDParams(shopID, baiduShopID, 0) params["query_activity_type"] = actType + params["page_size"] = 100 result, err := a.AccessAPI("act.multi.channel.queryids", params) if err == nil { if result.Data != nil { @@ -283,3 +293,94 @@ func (a *API) ActMultiChannelQueryIDs(shopID string, baiduShopID int64, actType } return actIDs, err } + +type ActMultiChannelQueryInfosResult struct { + Activityplatform int `json:"activityPlatform"` + Childtype int `json:"childType"` + Periodsandruleapilist []struct { + Periods []struct { + Weekday string `json:"weekday"` + Closetime string `json:"closeTime"` + Opentime string `json:"openTime"` + } `json:"periods"` + } `json:"periodsAndRuleApiList"` + Skulist []*ActMultiChannelQueryInfosSkuList `json:"skuList"` + Deliverychannel int `json:"deliveryChannel"` + Limitruleapi struct { + Usertotalcountlimit int `json:"userTotalCountLimit"` + Userdaycountlimit int `json:"userDayCountLimit"` + } `json:"limitRuleApi"` + Activityname string `json:"activityName"` + Activityid int64 `json:"activityId"` + Createtime int64 `json:"createTime"` + Starttime int64 `json:"startTime"` + Endtime int64 `json:"endTime"` + Skutotal int `json:"skuTotal"` + Activitytype int `json:"activityType"` + Status int `json:"status"` +} + +type ActMultiChannelQueryInfosSkuList struct { + Itemid int64 `json:"itemId"` + Periodsandruleapilist []struct { + Ruleapi struct { + Subsidyapi struct { + Agentsubsidy int `json:"agentSubsidy"` + Elemesubsidy int `json:"elemeSubsidy"` + Shopsubsidy int `json:"shopSubsidy"` + } `json:"subsidyApi"` + Discount int `json:"discount"` + Discounttype int `json:"discountType"` + } `json:"ruleApi"` + } `json:"periodsAndRuleApiList"` + Wid int64 `json:"wid"` + Limitruleapi struct { + Usertotalcountlimit int `json:"userTotalCountLimit"` + Detaildaycountlimit int `json:"detailDayCountLimit"` + Detailcountlimit int `json:"detailCountLimit"` + Userdaycountlimit int `json:"userDayCountLimit"` + } `json:"limitRuleApi"` + Realstock int `json:"realStock"` + Dayrealstock int `json:"dayRealStock"` + Storeid int `json:"storeId"` + Upcname string `json:"upcName"` + Skuid string `json:"skuId"` +} + +// 多渠道查询活动详情 +func (a *API) ActMultiChannelQueryInfos(activityID, shopID string, baiduShopID int64) (actMultiChannelQueryInfosResult *ActMultiChannelQueryInfosResult, err error) { + pageSize := 100 + params := a.genShopIDParams(shopID, baiduShopID, 0) + params["activity_id"] = activityID + params["page_size"] = pageSize + result, err := a.AccessAPI("act.multi.channel.queryinfos", params) + if err == nil { + if result.Data != nil { + utils.Map2StructByJson(result.Data.(map[string]interface{}), &actMultiChannelQueryInfosResult, false) + if actMultiChannelQueryInfosResult.Skutotal > pageSize { + for page := 2; page < actMultiChannelQueryInfosResult.Skutotal/pageSize+2; page++ { + actMultiChannelQueryInfosResult.Skulist = append(actMultiChannelQueryInfosResult.Skulist, a.ActMultiChannelQueryInfosPage(activityID, shopID, baiduShopID, page)...) + } + } else { + return actMultiChannelQueryInfosResult, err + } + } + } + return actMultiChannelQueryInfosResult, err +} + +// 多渠道查询活动详情 +func (a *API) ActMultiChannelQueryInfosPage(activityID, shopID string, baiduShopID int64, page int) (actMultiChannelQueryInfosSkuList []*ActMultiChannelQueryInfosSkuList) { + pageSize := 100 + params := a.genShopIDParams(shopID, baiduShopID, 0) + params["activity_id"] = activityID + params["page_size"] = pageSize + params["page"] = page + result, err := a.AccessAPI("act.multi.channel.queryinfos", params) + if err == nil { + if result.Data != nil { + utils.Map2StructByJson(result.Data.(map[string]interface{})["skuList"], &actMultiChannelQueryInfosSkuList, false) + } + } + return actMultiChannelQueryInfosSkuList +} diff --git a/platformapi/ebaiapi/activity_test.go b/platformapi/ebaiapi/activity_test.go index 9e87cb1c..4a130060 100644 --- a/platformapi/ebaiapi/activity_test.go +++ b/platformapi/ebaiapi/activity_test.go @@ -70,7 +70,7 @@ func TestActivityUpdate(t *testing.T) { } func TestActivityGet(t *testing.T) { - activityInfo, err := api.ActivityGet(0, "", 0, 0) + activityInfo, err := api.ActivityGet(6000000380161091, "", 100000045925, 0) if err != nil { t.Fatal(err) } else { @@ -95,7 +95,16 @@ func TestActivitySkuList(t *testing.T) { } func TestActMultiChannelQueryIDs(t *testing.T) { - result, err := api.ActMultiChannelQueryIDs("", 200000066556, "2") + result, err := api.ActMultiChannelQueryIDs("", 100000045925, "2") + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) + +} + +func TestActMultiChannelQueryInfos(t *testing.T) { + result, err := api.ActMultiChannelQueryInfos("6000000418366727", "", 100000045925) if err != nil { t.Fatal(err) } diff --git a/platformapi/ebaiapi/order_test.go b/platformapi/ebaiapi/order_test.go index f43abf00..a115d3de 100644 --- a/platformapi/ebaiapi/order_test.go +++ b/platformapi/ebaiapi/order_test.go @@ -7,7 +7,7 @@ import ( ) func TestOrderGet(t *testing.T) { - result, err := api.OrderGet("5027183668737301717") + result, err := api.OrderGet("2157781636259071682") if err != nil { t.Fatal(err) } else { diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index cec62b60..837e7acd 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -5,7 +5,6 @@ import ( "crypto/aes" "crypto/cipher" "encoding/base64" - "encoding/hex" "fmt" "git.rosy.net.cn/baseapi/utils" "golang.org/x/text/encoding/simplifiedchinese" @@ -758,7 +757,7 @@ func h8l82int(h, l string) (i int64) { for j := 0; j < flag2; j++ { s2 = "0" + s2 } - i, _ = strconv.ParseInt(s1+s2, 2, 10) + i, _ = strconv.ParseInt(s1+s2, 2, 32) return i } @@ -778,10 +777,11 @@ func TestUpdateStatus(t *testing.T) { // json.Unmarshal(result, &mobile) //} //fmt.Println(utils.Format4Output(mobile, true)) - str := "z" - printDataGBK, _ := Utf8ToGbk([]byte(str)) - printData := hex.EncodeToString(printDataGBK) - fmt.Println(printData) + //data := "1e00180200015032303231303631353030303031308628e9" + //orderNo := h8l82int(data[len(data)-6:len(data)-4], data[len(data)-4:len(data)-2]) + //base, _ := strconv.ParseInt(data[len(data)-6:len(data)-4]+data[len(data)-4:len(data)-2], 16, 10) + i, _ := strconv.ParseInt("8628", 16, 32) + fmt.Println(xtob("86"), xtob("28"), i) } func sss() (data2 []byte) { diff --git a/platformapi/mtwmapi/act_test.go b/platformapi/mtwmapi/act_test.go index 90af8216..d04421b6 100644 --- a/platformapi/mtwmapi/act_test.go +++ b/platformapi/mtwmapi/act_test.go @@ -154,7 +154,7 @@ func TestRetailDiscountBatchSave(t *testing.T) { } func TestRetailDiscountList(t *testing.T) { - result, err := api.RetailDiscountList(testPoiCode, RetailActTypeDirectDown) + result, err := api.RetailDiscountList("12405467", RetailActTypeDirectDown) if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index b1e8313f..90a7f319 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -19,13 +19,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - // api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_tE0txRtx7CRuPIOjh2BH4w") //token_nH_IlcWQKAkZBqklwItNRw + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_gbUPuDi9v0BKfnjdFz5IYw") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; `