修改抖音配送回传

This commit is contained in:
邹宗楠
2023-12-01 17:26:51 +08:00
parent aa7f9f9d1d
commit 020b004121
6 changed files with 69 additions and 55 deletions

View File

@@ -20,13 +20,13 @@ func init() {
baseapi.Init(sugarLogger) baseapi.Init(sugarLogger)
// 菜市 // 菜市
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
// 果园 // 果园
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超 //商超
// api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_jNSo7gNRUT-3-DsxVzpORA") //token_n4TwqCntWWuvQwAawzxC0w api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nrOXcZts7NkAsoc_oR5CZA") //token_n4TwqCntWWuvQwAawzxC0w
cookieStr := ` cookieStr := `
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
` `

View File

@@ -7,6 +7,7 @@ import (
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"strings" "strings"
"testing" "testing"
"time"
) )
// 测试添加分类 // 测试添加分类
@@ -165,10 +166,36 @@ func TestBatchSetPrice(t *testing.T) {
fmt.Println(err) fmt.Println(err)
} }
func TestRetailDelete(t *testing.T) { func TestRetailDelete(t *testing.T) {
err := api.RetailDelete(utils.GetUUID(), testPoiCode, "32427") poiCode := "19907139"
if err != nil { for {
t.Fatal(err) 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) { func TestRetailDat(t *testing.T) {

View File

@@ -80,7 +80,7 @@ func TestApplyMarketAfterSale(t *testing.T) {
func TestOrderStatusAndPsInfo(t *testing.T) { func TestOrderStatusAndPsInfo(t *testing.T) {
//appKey := `7152420904331429407` // 暂时定死 //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":""}` //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 := NewExpress("7152420904331429407", "cc7ba367-2394-4cbb-81c6-26f0e929d1c6", token)
//a2.CreateToken() //a2.CreateToken()
@@ -92,8 +92,8 @@ func TestOrderStatusAndPsInfo(t *testing.T) {
LogisticsProviderCode: utils.MyselfPsCode, LogisticsProviderCode: utils.MyselfPsCode,
LogisticsStatus: 0, LogisticsStatus: 0,
LogisticsContext: "商家自配送,已送达", LogisticsContext: "商家自配送,已送达",
Latitude: "103.94463969732", Latitude: "109.8779542115685",
Longitude: "30.620374717106", Longitude: "31.078094805818893",
OpCode: TiktokLogisticsDELIVERED, OpCode: TiktokLogisticsDELIVERED,
} }

View File

@@ -10,7 +10,6 @@ import (
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core" doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"math"
"sync" "sync"
"time" "time"
) )
@@ -201,18 +200,20 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}) error {
case utils.MyselfPsCode: case utils.MyselfPsCode:
request.Param.DistributionCode = TiktokDeliveryTypeMerchant request.Param.DistributionCode = TiktokDeliveryTypeMerchant
} }
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") { // 是否为百度坐标 //if param["latitude"].(string) != "" && param["longitude"].(string) != "" {
lat, lng := AutoGaoDe2BaiDu(param["latitude"].(string), param["longitude"].(string)) // if len(param["latitude"].(string)) > len("39.978573") && len(param["longitude"].(string)) > len("116.5031060") { // 是否为百度坐标
request.Param.RiderLatitude = utils.String2Pointer(lat) // //lat, lng, _ := jxutils.IntCoordinate2MarsStandard(param["longitude"].(string), param["latitude"].(string), 1)
request.Param.RiderLongitude = utils.String2Pointer(lng) // lat, lng := AutoGaoDe2BaiDu(param["latitude"].(string), param["longitude"].(string))
} else { // request.Param.RiderLatitude = utils.String2Pointer(lat)
request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string)) // request.Param.RiderLongitude = utils.String2Pointer(lng)
request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string)) // } else {
} // request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string))
} // request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string))
// }
//}
if param["logistics_provider_code"].(string) != "MERCHANT" { if param["logistics_provider_code"].(string) != "MERCHANT" {
request.Param.DistributionDeliveryId = param["third_carrier_order_id"].(string) 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.CancelCode = utils.Int64ToPointer(200) // 其他原因
request.Param.CancelReason = utils.String2Pointer("骑手未能到店,更换骑手") // 其他原因 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) result, err := request.Execute(a.accessTokenObj)
if err != nil { if err != nil {
@@ -249,13 +245,3 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}) error {
} }
return nil 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)
}

View File

@@ -227,3 +227,22 @@ const (
TiktokDeliveryTypeUU = "UU" //UU:UU跑腿 TiktokDeliveryTypeUU = "UU" //UU:UU跑腿
TiktokDeliveryTypeMerchant = "MERCHANT" //MERCHANT:商家自配送,使用此枚举需要提前和平台沟通 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
}

View File

@@ -1,5 +1,6 @@
package utils package utils
// 美团
const ( const (
DaDaCode = "10002" // 达达配送 DaDaCode = "10002" // 达达配送
FnPsCode = "10004" // 蜂鸟配送 FnPsCode = "10004" // 蜂鸟配送
@@ -23,22 +24,3 @@ type RiderInfo struct {
Longitude string `json:"longitude"` // 骑手当前的经度,美团使用的是高德坐标系。 Longitude string `json:"longitude"` // 骑手当前的经度,美团使用的是高德坐标系。
OpCode string `json:"opcode"` // 抖音状态(抖音才需要) 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
}