From eef53fb1bb4b7b73f1fc99f23047f12f91dee03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 2 Mar 2021 16:18:38 +0800 Subject: [PATCH] aa --- platformapi/jdshopapi/store_page_test.go | 4 +-- platformapi/mtwmapi/mtwmapi.go | 44 ++++++++++++++++++++++++ platformapi/mtwmapi/poi.go | 9 +++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 3ca847ec..e9261f0c 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -9,6 +9,7 @@ import ( "math" "sort" "testing" + "time" "git.rosy.net.cn/baseapi/utils" ) @@ -234,8 +235,7 @@ func TestUpdateDeliveryPromise(t *testing.T) { } func TestUploadImageNew(t *testing.T) { - i := []int{103075, 100129, 100117, 102726, 666677, 666997, 100156, 666987, 100118, 103113, 100144, 101039, 100153, 100881, 667142, 102630, 101897, 102613, 666799, 103177, 100766, 103035, 103090, 102167, 100326, 100454, 102416, 102789, 103037, 101176, 102713, 667057, 102482, 102938, 100920, 102614, 102624, 102675, 102902, 102956, 666748, 666876, 100115, 100141, 100524, 100670, 102671, 102987, 103022, 100206, 100274, 101780, 102138, 102206, 102255, 102785, 102951, 102996, 103111, 667058, 100610, 101099, 102293, 102819, 102824, 102857, 102865, 666751, 100654, 101111, 101945, 101960, 102795, 667093, 100121, 100193, 100230, 102481, 102772, 102969, 103063, 103094, 100126, 100175, 100210, 100270, 102706, 102930, 103116, 666672, 666712, 101840, 102241, 102595, 102686, 102736, 102973, 666735, 666790, 666792, 100205, 100453, 100905, 102147, 102320, 102767, 102925, 102937, 102962, 102994, 103002, 100409, 101956, 102353, 102475, 102794, 102852, 102921, 102928, 102980, 103183, 666669, 666733, 666861, 100204, 100225, 100476, 100699, 102354, 102915, 102923, 102929, 102952, 103069, 100215, 100279, 100458, 100517, 100664, 101013, 101666, 103093, 103191, 103425, 666996, 100132, 100278, 100328, 101032, 102022, 102355, 102364, 102436, 102763, 102776, 102893, 102924, 102966, 666779, 666906, 667110, 100290, 100455, 100471, 101875, 102126, 102479, 103103, 103199, 666767, 666992, 103003, 103088, 666667, 666711, 666930, 101979, 102046, 103201, 666819, 666879, 100116, 100157, 100712, 101061, 101736, 101755, 102561, 102960, 103193, 666905, 666993, 100299, 100334, 100987, 101112, 102264, 102278, 102704, 102752, 102771, 102997, 666828, 666863, 100501, 100681, 101012, 102002, 666746, 666853, 666898, 666985, 667109, 100336, 100543, 102426, 102933, 103194, 100366, 101942, 102186, 102533, 103151, 103200, 666729, 666820, 666854, 666954, 667033, 667064, 100361, 101750, 102374, 102977, 102991, 103015, 103170, 666864, 666890, 666933, 100840, 101983, 102648, 102932, 103018, 103050, 103065, 103171, 666932, 667091, 100002, 100140, 100150, 100828, 100853, 100867, 101000, 102488, 102782, 102807, 102995, 103029, 100124, 102172, 102637, 102705, 102934, 103098, 666855, 667014, 667076, 100714, 102480, 102519, 102594, 102600, 103089, 103189, 667113, 667136, 100134, 100451, 101078, 102047, 103033, 103085, 103127, 666739, 666784, 666891, 666975, 100167, 100782, 101042, 102424, 102723, 102741, 102793, 102883, 102888, 666852, 667003, 100433, 102742, 102836, 103112, 666740, 666835, 666887, 667007, 100130, 100487, 100546, 100982, 102181, 666782, 666961, 666973, 667005, 667038, 667075, 100145, 100369, 100444, 100720, 100741, 101028, 102853, 102953, 103057, 103082, 100032, 100041, 100396, 100837, 102371, 102473, 102718, 102998, 103361, 103408, 666788, 666800, 666948, 666980, 667001, 667006, 100650, 102498, 102676, 666812, 666826, 666929, 666955, 667028, 667094, 667125, 100529, 102720, 102749, 102882, 103032, 666775, 666803, 666927, 666944, 100065, 100162, 100296, 103036, 103055, 103184, 666707, 666839, 666964, 667067, 100470, 102068, 102358, 102733, 103181, 100015, 100549, 100849, 101732, 101763, 102074, 102780, 102821, 102859, 103083, 103118, 103416, 666771, 666802, 102562, 102856, 103160, 666811, 666818, 666850, 666984, 666988, 667071, 100267, 100309, 101916, 103051, 103165, 666783, 666889, 666900, 101008, 102300, 102750, 102958, 103161, 666756, 666786, 666836, 666840, 666880, 666977, 666983, 100123, 100165, 100351, 100548, 100767, 102670, 102711, 102876, 103009, 666823, 666834, 666917, 667051, 100217, 100883, 100971, 102483, 102981, 666793, 666858, 666940, 666945, 667112, 667133, 100935, 101031, 103179, 100024, 100190, 102955, 103143, 103176, 103198, 666825, 666869, 667135, 103074, 100221, 100325, 100463, 100477, 100600, 100661, 100827, 100945, 100946, 101712, 101722, 101815, 101834, 101887, 101896, 101935, 101948, 101997, 102012, 102016, 102023, 102063, 102092, 102180, 102245, 102267, 102275, 102280, 102383, 102405, 102411, 102443, 102444, 102531, 102557, 102652, 102661, 102691, 102721, 102735, 102740, 102759, 102808, 102815, 102858, 102896, 102901, 102906, 102911, 102926, 102946, 102954, 102971, 102974, 102976, 103001, 103008, 103028, 103095, 103106, 103115, 103119, 103145, 103168, 103178, 103188, 103414, 103433, 666705, 666738, 666745, 666747, 666772, 666776, 666785, 666791, 666821, 666822, 666873, 666885, 666888, 666919, 666942, 667010, 667055, 667059, 667117, 667157, 667158, 667176, 667145, 100022, 667234, 667206, 667273, 102788, 102150, 101097, 102379, 100943, 666916, 100273, 666884, 667114, 667205, 667202, 667370, 667366, 667365, 667359, 667356, 667352, 667351, 667349, 667339, 667338, 667336, 667335, 667334, 667332, 667331, 667329, 667324, 667321, 667315, 667312, 667310, 667309, 667308, 667307, 667305, 667304, 667303, 667302, 667296, 667297, 667294, 667292, 667291, 667288, 667284, 667280, 667278, 667277, 667266, 667264, 667263, 667257, 667245, 667242, 667240, 667236, 667223, 667220, 667211, 667208, 667204, 667201, 667200, 667177, 667166, 667159, 667155, 667154, 667147, 667139, 667134, 667129, 667128, 667080, 667029, 667016, 666907, 666862, 666842, 666838, 666770, 666765, 666715, 103136, 100601, 667333, 667381, 667363, 667340, 667386, 667423, 667040, 667419, 667395, 667388, 667443, 667355, 667394, 667390, 667420, 667364, 667389, 667383, 667361, 103182, 667414, 667476, 667465, 667481, 667510, 102377, 101088, 102642, 667469, 666921} - fmt.Println(len(i)) + fmt.Println(time.Now().YearDay()) } //给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。 diff --git a/platformapi/mtwmapi/mtwmapi.go b/platformapi/mtwmapi/mtwmapi.go index 6521b801..78180fbe 100644 --- a/platformapi/mtwmapi/mtwmapi.go +++ b/platformapi/mtwmapi/mtwmapi.go @@ -214,6 +214,50 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{ return retVal, err } +func (a *API) AccessAPI3(cmd string, isGet bool, bizParams map[string]interface{}) (retVal interface{}, err error) { + params := make(map[string]interface{}) + params["timestamp"] = time.Now().Unix() + params["app_id"] = a.appID + params = utils.MergeMaps(params, bizParams) + signURL := a.genURL(cmd) + "?" + params[signKey] = a.signParams(signURL, params) + err = platformapi.AccessPlatformAPIWithRetry(a.client, + func() *http.Request { + var request *http.Request + if isGet { + fullURL := utils.GenerateGetURL(apiURL, cmd, params) + // baseapi.SugarLogger.Debug(fullURL) + request, _ = http.NewRequest(http.MethodGet, fullURL, nil) + } else { + fullURL := a.genURL(cmd) + // baseapi.SugarLogger.Debug(utils.Map2URLValues(params).Encode()) + request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode())) + request.Header.Set("Content-Type", "application/x-www-form-urlencoded") + request.Header.Set("charset", "UTF-8") + } + // request.Close = true //todo 为了性能考虑还是不要关闭 + return request + }, + a.config, + func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { + if jsonResult1 == nil { + return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") + } + // 不管有无错误,都尝试取得数据(因为有出错,但有有效数据返回的情况),比如ecommerce/order/getOrderIdByDaySeq + retVal = jsonResult1 + if errObj, ok := jsonResult1["data"]; ok { + errorInfo := errObj.(string) + if errorInfo != "ok" { + baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true)) + newErr := utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"]))) + return errLevel, newErr + } + } + return platformapi.ErrLevelSuccess, nil + }) + return retVal, err +} + func (a *API) AccessAPI(cmd string, isGet bool, bizParams map[string]interface{}) (retVal interface{}, err error) { return a.AccessAPI2(cmd, isGet, bizParams, resultKeyData, "") } diff --git a/platformapi/mtwmapi/poi.go b/platformapi/mtwmapi/poi.go index ede71162..81fc87b8 100644 --- a/platformapi/mtwmapi/poi.go +++ b/platformapi/mtwmapi/poi.go @@ -244,9 +244,12 @@ type MultiPoiShippingInfo struct { } //https://open-shangou.meituan.com/home/docDetail/530 -func (a *API) PoiSettleSave(poiSettleSaveParam *PoiSettleSaveParam) (err error) { - _, err = a.AccessAPI("ecommerce/poi/settle/multi/save", false, utils.Struct2FlatMap(poiSettleSaveParam)) - return err +func (a *API) PoiSettleSave(poiSettleSaveParam *PoiSettleSaveParam) (vendorStoreID string, err error) { + result, err := a.AccessAPI3("ecommerce/poi/settle/multi/save", false, utils.Struct2FlatMap(poiSettleSaveParam)) + if err == nil { + vendorStoreID = result.(map[string]interface{})["success_list"].([]interface{})[0].(map[string]interface{})["app_poi_code"].(string) + } + return vendorStoreID, err } type PoiSettleCategoryListResult struct {