This commit is contained in:
邹宗楠
2026-07-06 15:35:36 +08:00
parent af5c780485
commit 9054474ea0
7 changed files with 38 additions and 34 deletions

View File

@@ -157,8 +157,8 @@ func TestClient(t *testing.T) {
// 预下单 // 预下单
func TestGetOrder(t *testing.T) { func TestGetOrder(t *testing.T) {
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "tMNyQk52Q7VA36Q9XXbTdX") api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "tMNyQk52Q7VA36Q9XXbTdX")
token, _ := api.GetAccessToken() //token, _ := api.GetAccessToken()
api.accessToken = token.BusinessDataObj.AccessToken api.accessToken = "a3e04dde-4930-4145-871d-8c2a99039d55"
aa := []*GoodsItemsList{ aa := []*GoodsItemsList{
{"白菜", 1, 100, 100, "30011", 1, "备注:大白菜"}, {"白菜", 1, 100, 100, "30011", 1, "备注:大白菜"},
@@ -166,12 +166,12 @@ func TestGetOrder(t *testing.T) {
// {"白菜3", 1, 100, 100, "1004", 1, "备注:大白菜2"}, // {"白菜3", 1, 100, 100, "1004", 1, "备注:大白菜2"},
} }
deliveryFee, baseDeliveryFee, err := api.PreCreateByShopFn(&PreCreateOrder{ deliveryFee, baseDeliveryFee, err := api.PreCreateByShopFn(&PreCreateOrder{
PartnerOrderCode: "817102016000041", PartnerOrderCode: "2102193962599091789",
OrderType: 1, OrderType: 1,
PositionSource: 3, PositionSource: 3,
ReceiverAddress: "四川成都", ReceiverAddress: "浙江省宁波市鄞州区邱隘镇回龙村盛莫路以西回龙村农产品集中交易点(地铁工地后面(回龙菜市场)",
ReceiverLongitude: 104.093445, ReceiverLongitude: 121.627465,
ReceiverLatitude: 30.661585, ReceiverLatitude: 29.818844,
GoodsTotalAmountCent: 100, GoodsTotalAmountCent: 100,
GoodsActualAmountCent: 100, GoodsActualAmountCent: 100,
GoodsWeight: 0.25, GoodsWeight: 0.25,
@@ -180,7 +180,7 @@ func TestGetOrder(t *testing.T) {
//ServiceGoodsId: nil, //ServiceGoodsId: nil,
//BaseGoodsId: nil, //BaseGoodsId: nil,
//OutShopCode: "637910", //OutShopCode: "637910",
ChainStoreID: "209476483", ChainStoreID: "220418619",
}) })
fmt.Println(err) fmt.Println(err)
fmt.Println(deliveryFee) fmt.Println(deliveryFee)

View File

@@ -30,9 +30,9 @@ func init() {
// 天天果园 // 天天果园
//api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26") //api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
// 京东果园 320406 // 京东果园 320406
//api = New("de4a9818-b171-41ed-ba37-0b060cad001f", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4") api = New("317e2b80-c884-4227-b20e-684cf3466290", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
// 京东秒送 // 京东秒送
api = New("697379cc-dde4-4b42-b845-5257ac5b4312", "64C3C0F83C23398B706BDAF3C8276B5A", "10b7d760b8504bf98e6faeba2561c7b9") //api = New("697379cc-dde4-4b42-b845-5257ac5b4312", "64C3C0F83C23398B706BDAF3C8276B5A", "10b7d760b8504bf98e6faeba2561c7b9")
// 京东白货 // 京东白货
//api = New("9053e4fd-4e0e-4e9e-8ab1-f348e5cbf3e7", "4602bd4b84984186815dbc03299c7094", "386ab19719d9470487011217d0c57349") //api = New("9053e4fd-4e0e-4e9e-8ab1-f348e5cbf3e7", "4602bd4b84984186815dbc03299c7094", "386ab19719d9470487011217d0c57349")
// 果切 379599 // 果切 379599

View File

@@ -806,6 +806,7 @@ func (a *API) GetCorporationInfo2(picUrl string) (data *GetOrderDetailByLicenseI
} }
return return
} }
func MonthSaleNum2Int(monthSaleNumStr string) (monthSaleNum int) { func MonthSaleNum2Int(monthSaleNumStr string) (monthSaleNum int) {
searchResult := monthSaleNumReg.FindStringSubmatch(monthSaleNumStr) searchResult := monthSaleNumReg.FindStringSubmatch(monthSaleNumStr)
if searchResult != nil && len(searchResult[1]) > 0 && len(searchResult[2]) > 0 { if searchResult != nil && len(searchResult[1]) > 0 && len(searchResult[2]) > 0 {

View File

@@ -25,7 +25,7 @@ func init() {
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超 //商超
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_kjEKYoGKSl0L4XqfEt9GUA") //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_uVZfu5hlW_UZQiR_i1tL0Q")
//cookieStr := ` //cookieStr := `
// acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; // acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
//` //`

View File

@@ -862,28 +862,12 @@ func (a *API) GetOrderAddress(orderId int64, reasonType int) (address string, er
} }
// UploadMediaToOrder 订单上传图片,订单在骑手取货前且未超过订单预计送达时间时可以进行图片上传 // UploadMediaToOrder 订单上传图片,订单在骑手取货前且未超过订单预计送达时间时可以进行图片上传
func (a *API) UploadMediaToOrder(orderId string, images []string) error { func (a *API) UploadMediaToOrder(orderId string, images interface{}) error {
imageList := make([]*UploadMedia, 0, len(images)) byteData := utils.MustMarshal(images)
for _, v := range images { _, err := a.AccessAPI("ecommerce/order/uploadMedia", false, map[string]interface{}{"order_id": orderId, "media_list": string(byteData)})
imageList = append(imageList, &UploadMedia{
Url: v,
Type: 0,
ConfigSnapshotId: 0,
ItemId: 0,
Seq: 0,
InnerSeq: 0,
RequireId: 0,
MediaCode: "",
})
}
byteData := utils.MustMarshal(imageList)
data, err := a.AccessAPI("ecommerce/order/uploadMedia", false, map[string]interface{}{"order_id": orderId, "media_list": string(byteData)})
if err != nil { if err != nil {
return err return err
} }
fmt.Println(data)
return nil return nil
} }

View File

@@ -31,10 +31,20 @@ func getTimeFromTimestamp(timeStamp int64) time.Time {
} }
func TestOrderGetOrderDetail(t *testing.T) { func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(3802140943223203896, false) result, err := api.OrderGetOrderDetail(3802193810228584437, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if utils.MustInterface2Int64(result["force_require_picture"]) == 1 {
forceRequirePicture := utils.MustInterface2Int64(result["force_require_picture"]) // 是否强制返图 0不强制返图1强制返图
auditStatus := utils.MustInterface2Int64(result["audit_status"]) // 需要强制返图时有意义,返图状态 1编辑中、2待审核、3系统审核通过、4下单人审核通过、5下单人审核驳回 非强制返图或强制返图返图前值为0
fmt.Println(forceRequirePicture)
fmt.Println(auditStatus)
dispatchCondition := utils.Interface2String(result["dispatch_condition"]) // 发货条件明细该字段当前只在强制返图场景下返回以及使用。enable_dispatch=true则可发货dispatch_condition_detail为不可发货的所有条件明细如需关注不可发货原因则要查看
orderRealMediaDetail := utils.Interface2String(result["orderRealMediaDetail"]) // 实拍规则要求及实拍后的图片与ocr识别信息没返回(null),则三方用老的传图方式上传
fmt.Println(dispatchCondition)
fmt.Println(orderRealMediaDetail)
}
globals.SugarLogger.Debugf("%d", int(utils.MustInterface2Int64(result["day_seq"]))) globals.SugarLogger.Debugf("%d", int(utils.MustInterface2Int64(result["day_seq"])))
globals.SugarLogger.Debugf("====%s", utils.Format4Output(result["poi_receive_detail_yuan"], false)) globals.SugarLogger.Debugf("====%s", utils.Format4Output(result["poi_receive_detail_yuan"], false))
if len(result) == 0 { if len(result) == 0 {
@@ -47,6 +57,14 @@ func TestOrderGetOrderDetail(t *testing.T) {
//globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false)) //globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false))
} }
type dispatchConditionList struct {
enable_dispatch bool `json:"enable_dispatch"` // 是否可发配true-可发配false-不可发配
dispatch_condition_detail []struct {
enable_dispatch bool `json:"enable_dispatch"` // 是否可发配true-可发配false-不可发配
condition_type int `json:"condition_type"` // 发货条件类型1-返图标准化强制实拍返图
} `json:"dispatch_condition_detail"` // 发货条件明细,记录了哪些限制条件满足,哪些未满足
}
func TestJsuan(t *testing.T) { func TestJsuan(t *testing.T) {
fmt.Println(StandardPrice2Int2(-12.39)) fmt.Println(StandardPrice2Int2(-12.39))
} }

View File

@@ -406,7 +406,7 @@ func TestRetailRecommendTag(t *testing.T) {
// 删除商品 // 删除商品
func TestRetailDelete(t *testing.T) { func TestRetailDelete(t *testing.T) {
poiCode := "32219557" poiCode := "31690278"
i := 0 i := 0
count := 0 count := 0
@@ -439,19 +439,20 @@ func TestRetailDelete(t *testing.T) {
// 测试删除门店分类列表 // 测试删除门店分类列表
func TestDeleteCat(t *testing.T) { func TestDeleteCat(t *testing.T) {
result, err := api.RetailCatList("20760911") result, err := api.RetailCatList("31690278")
fmt.Println(result, err) fmt.Println(result, err)
for _, v := range result { for _, v := range result {
if v.Children != nil { if v.Children != nil {
for _, v2 := range v.Children { for _, v2 := range v.Children {
err = api.RetailCatDelete("31226355", "", v2.Name, 1) err = api.RetailCatDelete("31690278", "", v2.Name, 1)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
} else { } else {
err = api.RetailCatDelete("31226355", "", v.Name, 1) err = api.RetailCatDelete("31690278", "", v.Name, 1)
if err != nil { if err != nil {
continue
t.Fatal(err) t.Fatal(err)
} }
} }