修改抖音配送回传

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

@@ -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,
}

View File

@@ -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)
}

View File

@@ -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
}