From 020b004121470e8b7511c16f666486c2ac36958e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 1 Dec 2023 17:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=96=E9=9F=B3=E9=85=8D?= =?UTF-8?q?=E9=80=81=E5=9B=9E=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/mtwmapi/mtwmapi_test.go | 4 +- platformapi/mtwmapi/retail_test.go | 33 +++++++++++++-- .../tiktok_shop/tiktok_api/api_test.go | 6 +-- .../tiktok_api/logistics_express.go | 42 +++++++------------ .../tiktok_api/order_type_const.go | 19 +++++++++ utils/riderInfo.go | 20 +-------- 6 files changed, 69 insertions(+), 55 deletions(-) diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index fbbec86d..e7afb693 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_jNSo7gNRUT-3-DsxVzpORA") //token_n4TwqCntWWuvQwAawzxC0w + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nrOXcZts7NkAsoc_oR5CZA") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 19b1b0c4..2019975b 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" "strings" "testing" + "time" ) // 测试添加分类 @@ -165,10 +166,36 @@ func TestBatchSetPrice(t *testing.T) { fmt.Println(err) } func TestRetailDelete(t *testing.T) { - err := api.RetailDelete(utils.GetUUID(), testPoiCode, "32427") - if err != nil { - t.Fatal(err) + poiCode := "19907139" + for { + cat, _ := api.RetailCatList(poiCode) + for _, v := range cat { + api.RetailCatDelete(poiCode, "", v.Name, 1) + } + foodList, err1 := api.RetailListAll(poiCode, 0) + if err1 != nil { + globals.SugarLogger.Debugf("====err1 := %v", err1) + return + } + + i := 0 + for _, v := range foodList { + err2 := api.RetailDelete("test_LiuLei", poiCode, v.AppFoodCode) + if err2 != nil { + globals.SugarLogger.Debugf("====err2 := %v", err1) + } + if i%40 == 0 { + time.Sleep(200 * time.Millisecond) + } + i++ + } + return } + + //err := api.RetailDelete(utils.GetUUID(), testPoiCode, "32427") + //if err != nil { + // t.Fatal(err) + //} } func TestRetailDat(t *testing.T) { diff --git a/platformapi/tiktok_shop/tiktok_api/api_test.go b/platformapi/tiktok_shop/tiktok_api/api_test.go index 5da5d4ca..01a4b31f 100644 --- a/platformapi/tiktok_shop/tiktok_api/api_test.go +++ b/platformapi/tiktok_shop/tiktok_api/api_test.go @@ -80,7 +80,7 @@ func TestApplyMarketAfterSale(t *testing.T) { func TestOrderStatusAndPsInfo(t *testing.T) { //appKey := `7152420904331429407` // 暂时定死 - //appSecret := `cc7ba367-2394-4cbb-81c6-26f0e929d1c6` //暂时定死 + //appSecret := `cc7ba367-2394-4cbb-81c6-26f0e929d1c6` // 暂时定死 //token := `{"access_token":"4a543151-f8fd-43d5-9c34-d19fe11fc51c","expires_in":1694069036,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"5a2aaca1-42f7-4b83-9358-8ed5d1d4bcd6","authority_id":""}` //a2 := NewExpress("7152420904331429407", "cc7ba367-2394-4cbb-81c6-26f0e929d1c6", token) //a2.CreateToken() @@ -92,8 +92,8 @@ func TestOrderStatusAndPsInfo(t *testing.T) { LogisticsProviderCode: utils.MyselfPsCode, LogisticsStatus: 0, LogisticsContext: "商家自配送,已送达", - Latitude: "103.94463969732", - Longitude: "30.620374717106", + Latitude: "109.8779542115685", + Longitude: "31.078094805818893", OpCode: TiktokLogisticsDELIVERED, } diff --git a/platformapi/tiktok_shop/tiktok_api/logistics_express.go b/platformapi/tiktok_shop/tiktok_api/logistics_express.go index 4ef4b638..c24315da 100644 --- a/platformapi/tiktok_shop/tiktok_api/logistics_express.go +++ b/platformapi/tiktok_shop/tiktok_api/logistics_express.go @@ -10,7 +10,6 @@ import ( doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" - "math" "sync" "time" ) @@ -201,18 +200,20 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}) error { case utils.MyselfPsCode: request.Param.DistributionCode = TiktokDeliveryTypeMerchant } - - // 纬度 - if param["latitude"].(string) != "" && param["longitude"].(string) != "" { - if len(param["latitude"].(string)) > len("39.978573") && len(param["longitude"].(string)) > len("116.5031060") { // 是否为百度坐标 - lat, lng := AutoGaoDe2BaiDu(param["latitude"].(string), param["longitude"].(string)) - request.Param.RiderLatitude = utils.String2Pointer(lat) - request.Param.RiderLongitude = utils.String2Pointer(lng) - } else { - request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string)) - request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string)) - } - } + request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string)) + request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string)) + //// 纬度 + //if param["latitude"].(string) != "" && param["longitude"].(string) != "" { + // if len(param["latitude"].(string)) > len("39.978573") && len(param["longitude"].(string)) > len("116.5031060") { // 是否为百度坐标 + // //lat, lng, _ := jxutils.IntCoordinate2MarsStandard(param["longitude"].(string), param["latitude"].(string), 1) + // lat, lng := AutoGaoDe2BaiDu(param["latitude"].(string), param["longitude"].(string)) + // request.Param.RiderLatitude = utils.String2Pointer(lat) + // request.Param.RiderLongitude = utils.String2Pointer(lng) + // } else { + // request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string)) + // request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string)) + // } + //} if param["logistics_provider_code"].(string) != "MERCHANT" { request.Param.DistributionDeliveryId = param["third_carrier_order_id"].(string) @@ -234,11 +235,6 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}) error { request.Param.CancelCode = utils.Int64ToPointer(200) // 其他原因 request.Param.CancelReason = utils.String2Pointer("骑手未能到店,更换骑手") // 其他原因 } - //if a.accessTokenObj == nil || a.accessTokenObj.CreateTokenData.AccessToken == "" { - // a.CreateToken() - //} else if a.expiresIn < time.Now().Unix() { - // a.RefreshToken() - //} result, err := request.Execute(a.accessTokenObj) if err != nil { @@ -249,13 +245,3 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}) error { } return nil } - -func AutoGaoDe2BaiDu(lat, lon string) (string, string) { - x := utils.Str2Float64(lon) - 0.0065 - y := utils.Str2Float64(lat) - 0.006 - z := math.Sqrt(x*x+y*y) - 0.00002*math.Sin(y*math.Pi) - theta := math.Atan2(y, x) - 0.000003*math.Cos(x*math.Pi) - tempLon := z * math.Cos(theta) - tempLat := z * math.Sin(theta) - return utils.Float64ToStr(tempLat), utils.Float64ToStr(tempLon) -} diff --git a/platformapi/tiktok_shop/tiktok_api/order_type_const.go b/platformapi/tiktok_shop/tiktok_api/order_type_const.go index c9520031..cbf0893b 100644 --- a/platformapi/tiktok_shop/tiktok_api/order_type_const.go +++ b/platformapi/tiktok_shop/tiktok_api/order_type_const.go @@ -227,3 +227,22 @@ const ( TiktokDeliveryTypeUU = "UU" //UU:UU跑腿 TiktokDeliveryTypeMerchant = "MERCHANT" //MERCHANT:商家自配送,使用此枚举需要提前和平台沟通 ) + +func JxVendorId2TiktokCode(vendorId int) string { + code := "" + switch vendorId { + case 101: + code = TiktokDeliveryTypeDaDa + case 102: + code = TiktokDeliveryTypeMeiTuan + case 103: + code = TiktokDeliveryTypeFengNiao + case 105: + code = TiktokDeliveryTypeUU + case 106: + code = TiktokDeliveryTypeSF + default: + code = TiktokDeliveryTypeMerchant + } + return code +} diff --git a/utils/riderInfo.go b/utils/riderInfo.go index e4fd905a..31385468 100644 --- a/utils/riderInfo.go +++ b/utils/riderInfo.go @@ -1,5 +1,6 @@ package utils +// 美团 const ( DaDaCode = "10002" // 达达配送 FnPsCode = "10004" // 蜂鸟配送 @@ -23,22 +24,3 @@ type RiderInfo struct { Longitude string `json:"longitude"` // 骑手当前的经度,美团使用的是高德坐标系。 OpCode string `json:"opcode"` // 抖音状态(抖音才需要) } - -func JxVendorId2TiktokCode(vendorId int) string { - code := "" - switch vendorId { - case 101: - code = DaDaCode - case 102: - code = MTPsCode - case 103: - code = FnPsCode - case 105: - code = UUPTCode - case 106: - code = SFPSCode - default: - code = MyselfPsCode - } - return code -}