1
This commit is contained in:
62
platformapi/weixinapi/sns_send_order.go
Normal file
62
platformapi/weixinapi/sns_send_order.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package weixinapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SNSSendGoodsOrder 小程序订单发货 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
func (a *API) SNSSendGoodsOrder(param *SNSSendOrderParameter) error {
|
||||
body, _ := json.Marshal(param)
|
||||
if a.CBGetToken() == "" {
|
||||
a.CBRetrieveToken()
|
||||
}
|
||||
_, err := a.AccessAPI("wxa/sec/order/upload_shipping_info", nil, string(body))
|
||||
return err
|
||||
}
|
||||
|
||||
// SNSSendOrderParameter 小程序订单发货
|
||||
type SNSSendOrderParameter struct {
|
||||
OrderKey struct {
|
||||
OrderNumberType int `json:"order_number_type"`
|
||||
TransactionId string `json:"transaction_id"`
|
||||
Mchid string `json:"mchid"`
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
} `json:"order_key"`
|
||||
LogisticsType int `json:"logistics_type"`
|
||||
DeliveryMode int `json:"delivery_mode"`
|
||||
IsAllDelivered bool `json:"is_all_delivered"`
|
||||
ShippingList []ShippingList `json:"shipping_list"`
|
||||
UploadTime string `json:"upload_time"`
|
||||
Payer struct {
|
||||
Openid string `json:"openid"`
|
||||
} `json:"payer"`
|
||||
}
|
||||
type ShippingList struct {
|
||||
TrackingNo string `json:"tracking_no"`
|
||||
ExpressCompany string `json:"express_company"`
|
||||
ItemDesc string `json:"item_desc"`
|
||||
Contact struct {
|
||||
ConsignorContact string `json:"consignor_contact"`
|
||||
ReceiverContact string `json:"receiver_contact"`
|
||||
} `json:"contact"`
|
||||
}
|
||||
|
||||
// SNSDeliveryGoodsOrder 订单送达推送
|
||||
func (a *API) SNSDeliveryGoodsOrder(param *DeliveryOrder) error {
|
||||
body, _ := json.Marshal(param)
|
||||
if a.CBGetToken() == "" {
|
||||
a.CBRetrieveToken()
|
||||
}
|
||||
result, err := a.AccessAPI("wxa/sec/order/notify_confirm_receive", nil, string(body))
|
||||
fmt.Println(result)
|
||||
return err
|
||||
}
|
||||
|
||||
type DeliveryOrder struct {
|
||||
TransactionId string `json:"transaction_id"` // 原支付交易对应的微信订单号
|
||||
MerchantId string `json:"merchant_id"` // 支付下单商户的商户号,由微信支付生成并下发
|
||||
MerchantTradeNo string `json:"merchant_trade_no"` // 商户系统内部订单号
|
||||
SubMerchantId string `json:"sub_merchant_id"` // 二级商户号
|
||||
ReceivedTime int64 `json:"received_time"` // 10快递签收时间,时间戳形式。
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package weixinapi
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSNSRetrieveToken(t *testing.T) {
|
||||
result, err := api.SNSRetrieveToken("021UGn0006ICgQ13UC1005f2kD4UGn0r")
|
||||
@@ -37,3 +41,51 @@ func TestSNSGetUserInfo(t *testing.T) {
|
||||
}
|
||||
sugarLogger.Debug(result)
|
||||
}
|
||||
|
||||
func TestSNSSendGoodsOrder(t *testing.T) {
|
||||
param := &SNSSendOrderParameter{
|
||||
OrderKey: struct {
|
||||
OrderNumberType int `json:"order_number_type"`
|
||||
TransactionId string `json:"transaction_id"`
|
||||
Mchid string `json:"mchid"`
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
}{
|
||||
OrderNumberType: 2,
|
||||
TransactionId: "4200003055202603242074503838",
|
||||
},
|
||||
LogisticsType: 1,
|
||||
DeliveryMode: 1,
|
||||
IsAllDelivered: false,
|
||||
ShippingList: append([]ShippingList{}, ShippingList{
|
||||
TrackingNo: "88512032279168",
|
||||
ExpressCompany: "YD",
|
||||
ItemDesc: "背心袋测试",
|
||||
Contact: struct {
|
||||
ConsignorContact string `json:"consignor_contact"`
|
||||
ReceiverContact string `json:"receiver_contact"`
|
||||
}{},
|
||||
}),
|
||||
UploadTime: time.Now().Format(time.RFC3339),
|
||||
Payer: struct {
|
||||
Openid string `json:"openid"`
|
||||
}{
|
||||
Openid: "ojWb10P-E520p3WZSClXclSBR_20",
|
||||
},
|
||||
}
|
||||
|
||||
api.SNSSendGoodsOrder(param)
|
||||
}
|
||||
|
||||
func TestSNSDeliveryGoodsOrder(t *testing.T) {
|
||||
api.SNSDeliveryGoodsOrder(&DeliveryOrder{
|
||||
TransactionId: "4200003007202603198574473654",
|
||||
MerchantId: "",
|
||||
MerchantTradeNo: "",
|
||||
SubMerchantId: "",
|
||||
ReceivedTime: time.Now().Unix(),
|
||||
})
|
||||
}
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
fmt.Println(411 / 50)
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ func init() {
|
||||
|
||||
// 果园
|
||||
//api = New("wx2d6949f724b2541d", "11f3c380551c4683c149990b004d6df9")
|
||||
// 菜市 wixnapp2
|
||||
//api = New("wx4b5930c13f8b1170", "2a57228a716ce991a52739f0ff41111d")
|
||||
api = New("wx2bb99eb5d2c9b82c", "6bbbed1443cc062c20a015a64c07a531")
|
||||
// 菜市 wixnapp2(物料/菜市)
|
||||
api = New("wx4b5930c13f8b1170", "2a57228a716ce991a52739f0ff41111d")
|
||||
//api = New("wx2bb99eb5d2c9b82c", "6bbbed1443cc062c20a015a64c07a531")
|
||||
//api.CBSetToken("79_3x4gI4IFn9JKJd0EouSLe2HYFFoscRntAYCTZec4VLBlgivhOR0D2vp0mF0u6T-DmzbnAXotpTs_5Yp5Knxak7bfaMDzoaFMZM14r5n4CKpNTOaLH4PSyap2TnALTKgAHASAR")
|
||||
api.CBSetToken("duyaeVYUsz8LuKBqJeQO1NX6KmoC43yfMsbJybcRJ3e")
|
||||
api.CBSetToken("102_563eM-1LcfFzyjU00n-W036LZg1IHVzSrIi0FEj4ylD915aYUpB9nOJBe21UKFBhHHs_xzoyZXvcO_HOQ1-De-F9-W3H1CHyHFQe8SiCORnMlSnQaQkIPXTiMpERZWcAEAUCZ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user