京东物流
This commit is contained in:
@@ -189,14 +189,14 @@ type WaybillReceiveParam struct {
|
||||
// VloumLong int `json:"vloumLong"` //否 无 包裹长(单位:cm,保留小数点后两位)
|
||||
// VloumWidth int `json:"vloumWidth"` //否 无 包裹宽(单位:cm,保留小数点后两位)
|
||||
// VloumHeight int `json:"vloumHeight"` //否 无 包裹高(单位:cm,保留小数点后两位)
|
||||
Vloumn int `json:"vloumn"` //是 10000 体积(单位:cm3,保留小数点后两位)
|
||||
// Description string `json:"description"` //否 无 商品描述
|
||||
Vloumn int `json:"vloumn"` //是 10000 体积(单位:cm3,保留小数点后两位)
|
||||
Description string `json:"description"` //否 无 商品描述
|
||||
// CollectionValue int `json:"collectionValue"` //否 1 是否代收货款(是:1,否:0。不填或者超出范围,默认是0)
|
||||
// CollectionMoney int `json:"collectionMoney"` //否 98.00 代收货款金额(保留小数点后两位)
|
||||
// GuaranteeValue int `json:"guaranteeValue"` //否 1 是否保价(是:1,否:0。不填或者超出范围,默认是0)
|
||||
// GuaranteeValueAmount int `json:"guaranteeValueAmount"` //否 100.00 保价金额(保留小数点后两位)
|
||||
// SignReturn int `json:"signReturn"` //否 1 签单返还(签单返还类型:0 不返单,1 普通返单,2 校验身份返单,3 电子签返单,4 电子返单+普通返单)
|
||||
// Aging int `json:"aging"` //否 1 时效(普通:1,工作日:2,非工作日:3,晚间:4。O2O一小时达:5。O2O定时达:6。不填或者超出范围,默认是1)
|
||||
Aging int `json:"aging"` //否 1 时效(普通:1,工作日:2,非工作日:3,晚间:4。O2O一小时达:5。O2O定时达:6。不填或者超出范围,默认是1)
|
||||
// TransType int `json:"transType"` //否 1 运输类型(陆运:1,航空:2。不填或者超出范围,默认是1)
|
||||
// Remark string `json:"remark"` //否 无 运单备注,长度:20,说明:打印面单时备注内容也会显示在快递面单上
|
||||
// GoodsType int `json:"goodsType"` //否 无 配送业务类型( 1:普通,3:填仓,4:特配,6:控温,7:冷藏,8:冷冻,9:深冷)默认是1
|
||||
@@ -413,9 +413,12 @@ func (a *API) QueryStock(goodsNo string) (queryStockResult []*QueryStockResult,
|
||||
|
||||
//京东物流接单接口
|
||||
//https://open.jd.com/home/home#/doc/api?apiCateId=64&apiId=2122&apiName=jingdong.ldop.waybill.receive
|
||||
func (a *API) WaybillReceive(waybillReceiveParam *WaybillReceiveParam) (err error) {
|
||||
_, err = a.AccessAPI("jingdong.ldop.waybill.receive", prodURL, utils.Struct2FlatMap(waybillReceiveParam))
|
||||
return err
|
||||
func (a *API) WaybillReceive(waybillReceiveParam *WaybillReceiveParam) (deliveryId string, err error) {
|
||||
result, err := a.AccessAPI("jingdong.ldop.waybill.receive", prodURL, utils.Struct2FlatMap(waybillReceiveParam))
|
||||
if err == nil {
|
||||
deliveryId = result["jingdong_ldop_waybill_receive_responce"].(map[string]map[string]string)["receiveorderinfo_result"]["deliveryId"]
|
||||
}
|
||||
return deliveryId, err
|
||||
}
|
||||
|
||||
//京东物流取消接口
|
||||
|
||||
@@ -97,14 +97,18 @@ func TestWaybillReceive(t *testing.T) {
|
||||
err := api.WaybillReceive(&WaybillReceiveParam{
|
||||
SalePlat: SalePlatSourceDelivery,
|
||||
CustomerCode: CustomerCode,
|
||||
OrderID: utils.GetUUID(),
|
||||
SenderName: "测试",
|
||||
SenderAddress: "测试地址1",
|
||||
ReceiveName: "测试",
|
||||
ReceiveAddress: "测试地址1",
|
||||
OrderID: "883289609977992",
|
||||
SenderName: "金牛店",
|
||||
SenderAddress: "四川省成都市金牛区加州湾v派",
|
||||
SenderTel: "18160030913",
|
||||
ReceiveName: "明珠怡园",
|
||||
ReceiveAddress: "四川省成都市天府大道",
|
||||
ReceiveTel: "18160030913",
|
||||
PackageCount: 1,
|
||||
Weight: 1,
|
||||
Weight: 100,
|
||||
Vloumn: 10000,
|
||||
Description: "测试",
|
||||
Aging: 5,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -114,7 +118,7 @@ func TestWaybillReceive(t *testing.T) {
|
||||
|
||||
func TestCancelWayBill(t *testing.T) {
|
||||
err := api.CancelWayBill(&CancelWayBillParam{
|
||||
WaybillCode: "11",
|
||||
WaybillCode: "JDVD00717018403",
|
||||
CustomerCode: CustomerCode,
|
||||
Source: "JOS",
|
||||
CancelReason: "测试",
|
||||
|
||||
@@ -20,6 +20,8 @@ const (
|
||||
JdsImgDescURL = `<img src=" //img10.360buyimg.com/imgzone/jfs/t1/111969/32/6692/171733/5ebbb9daE5bedb5b2/38350dca19e2b9d2.jpg" style="width: auto; height: auto; max-width: 100%;">`
|
||||
JdsStoreImg = "http://image.jxc4.com/image/2659335b16e3880e367759b8fc675933.tem.png"
|
||||
JdsStoreCategoryName = "pop-mendian-Selfdelivery"
|
||||
JdsMobileKey = "5a8f3244786ea9b8"
|
||||
JdsMobileToken = `j9ma4js4tphmu2ajmlr1590716634146mdnd~NmZeSyVEbFNSdH58dlVdAH50AAlpRHpTBiUjb35DFm5vLUROOBEzLUF7G28iAAFBKBgVFA1EPwIVKDclGENXbm8iVlQiAwpTTx1lKSsTCG5vfmsaZlRiQVodZWEYQwtub35rGmgCY0laIiF+JlRcBX4lBFppUGcUVSBweHYEC1AudwFaZwUuEz9jaxFmCB5fEWYNZHMANx0QJBtvaD1PWj4waxprOnQfBjYoPyAEHxw+LFhIfwwyXwAuKhFmTTEQPSprGms6dF4MMyMoNk4CQCkhRXw0EjcYDx1lYRhDHUYRZg1kcw4iBRMyfRFmTTEQPS1rGms6dEBVbXRhdk1fAGFwGw1nOnQMQW1lKCAFHlVvfhVeIVMhU09jJD5mW08KPjROVjQPIRNQdj4oNwUaQj50BktpFiACCTE0fDAPAloqJgAafUQ1U1ljKnk9GAxePi1aSihWZgZWOHV7PFBYC31wBwhmX2BGWnN2dTxUTx5vIERWc1x0RQEqcHUrUBgQYWZeS3NcdEBBbWUnLQJPCG99DgFoRCs=|~1591240251425~1~20200318~eyJ2aXdlIjoiMCIsImJhaW4iOnsiaWMiOiIxIiwibGUiOiIxMDAiLCJjdCI6IjAiLCJkdCI6ImkifX0=~1~-776~giiz|1d3o-m7,ki,m7,ki;gw4;1df8l-m8,u5,m8,u5;1d9-lc,tr,gu,d;1d7-ke,tc,fw,1i;1de-i3,sb,dl,h;1d8-gw,ru,ce,0;1d8-fs,rb,bb,g;1dg-db,qi,db,py;1d8-c2,q2,ax,8c;1d8-av,pl,u,2c;1d8-9u,p6,8,76;1dg-7x,ok,6i,6k;1d8-74,oa,5p,6a;1d8-6g,nx,50,1f;1d8-5q,no,4a,16;1dg-4h,ms,31,a;1d8-3u,mb,2f,4b;1d8-3a,lw,3,h;1d8-2q,li,1b,3;1dg-1r,kw,c,p;1d8-1l,ku,6,n;1d8-1i,ks,3,l;1d1l-1i,kt,3,m;1d7-1i,kv,3,o;1d8-1l,kv,6,o;1d8-1q,kw,b,p;1d8-1x,kw,i,p;1dg-2t,kw,1e,p;1d8-38,kw,1,p;1d9-3q,kw,j,p;1d4f-7k,l5,4d,y;1d15-7p,ld,4i,16;1d2v-7t,ls,g,d;bd2j-7t,ls,g,d;doei:,1,1,0,0,1,1000,-1000,1000,-1000;dmei:,1,1,1,1000,-1000,1000,-1000,1000,-1000;emc:,d:62;emmm:,d:28-0;emcf:,d:62;ivli:;iivl:;ivcvj:;scvje:;ewhi:;1591240230712,1591240251421,0,0,35,35,0,32,0,0,0;1gxs`
|
||||
|
||||
JdsStoreStatusRest = 6
|
||||
JdsStoreStatusOnline = 1
|
||||
|
||||
@@ -16,6 +16,6 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api.SetCookieWithStr(`
|
||||
thor=00513FC363111586B2C0E065A90E33C12B3DB5AF76E18DEC4599554F59EFEB73FC0087764E39454B497E643E3FA637624CA63BEADEDBA6B21C79BC276EA4BBBAE97117AD7E5406A3C336B0DF5BDC8E247E0619CC24640201DBC9E1B2B4299675BD66F01F55A50E782904AAA3F75FA73E203988B3E04DB9D68FAA27BCDAAE08258D143E4E3FB374F6BB1EC9C4DA7BD548;
|
||||
thor=80FAF09E9A09B6E618A68057BDFCFCB81E6C186883AB46A9F4A4D44F89DF482B3B39F419A8731615D5DBB85B9F4595752D431AE9A98EF1EF640306D0A749B9CFECCD1AB4A086A54D885995E5B44BF3C8810880D168DFCF087B93ADC23F163D84CCEE1B79D0FF55AD9197DB0AAACB1DDFFE656ECA7BED9E1CD2720A0501358F4A2E7DC0D494E2F7347697EF19125EF3A3;
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailMobile = regexp.MustCompile(`<span id="mobile">(.*?)</span>`)
|
||||
regexpOrderDetailDay = regexp.MustCompile(`<td class="pubwhite">配送日期:</td>[\s\S]*?<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailPay = regexp.MustCompile(`<td class="pubwhite">应支付金额:</td>[\s\S]*?<td>[\s\S]*?¥(.*?[\s\S]*?)</td>`)
|
||||
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailMobile = regexp.MustCompile(`<span id="mobile">(.*?)</span>`)
|
||||
regexpOrderDetailDay = regexp.MustCompile(`<td class="pubwhite">配送日期:</td>[\s\S]*?<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailPay = regexp.MustCompile(`<td class="pubwhite">应支付金额:</td>[\s\S]*?<td>[\s\S]*?¥(.*?[\s\S]*?)</td>`)
|
||||
regexpOrderDetailMobileKey = regexp.MustCompile(`accesskey="(.*?)"`)
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -391,6 +392,7 @@ type OrderDetailResult struct {
|
||||
ConsigneeMobile string `json:"consigneeMobile"`
|
||||
ExpectedDeliveredTime string `json:"expectedDeliveredTime"`
|
||||
ActualPayPrice int64 `json:"actualPayPrice"`
|
||||
MobileKey string `json:"mobileKey"`
|
||||
}
|
||||
|
||||
//订单详情
|
||||
@@ -405,6 +407,7 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult,
|
||||
expectedDeliveredTime := regexpOrderDetailDay.FindStringSubmatch(body)
|
||||
actualPayPrice := regexpOrderDetailPay.FindStringSubmatch(body)
|
||||
consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body)
|
||||
mobileKey := regexpOrderDetailMobileKey.FindStringSubmatch(body)
|
||||
if len(consigneeTable) > 0 {
|
||||
consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1)
|
||||
consigneeMobiles := regexpOrderDetailMobile.FindStringSubmatch(consigneeTable[1])
|
||||
@@ -423,6 +426,24 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult,
|
||||
if len(actualPayPrice) > 0 {
|
||||
orderDetailResult.ActualPayPrice = utils.Float64TwoInt64(utils.Str2Float64(strings.TrimSpace(actualPayPrice[1])) * 100)
|
||||
}
|
||||
if len(mobileKey) > 0 {
|
||||
orderDetailResult.MobileKey = mobileKey[1]
|
||||
}
|
||||
}
|
||||
return orderDetailResult, err
|
||||
}
|
||||
|
||||
//尝试获取订单的真实手机号
|
||||
//https://https://neworder.shop.jd.com/order/json/phoneSensltiveInfo
|
||||
func (a *API) PhoneSensltiveInfo(orderId, accessKey string) (fakeMobile string, err error) {
|
||||
result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/json/phoneSensltiveInfo", map[string]interface{}{
|
||||
"orderId": orderId,
|
||||
"accessKey": accessKey,
|
||||
"accessType": "0",
|
||||
"token": JdsMobileToken,
|
||||
}, true)
|
||||
if err == nil {
|
||||
fakeMobile = result["model"].(map[string]interface{})["phone"].(string)
|
||||
}
|
||||
return fakeMobile, err
|
||||
}
|
||||
|
||||
@@ -73,3 +73,11 @@ func TestOrderDetail(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestPhoneSensltiveInfo(t *testing.T) {
|
||||
result, err := api.PhoneSensltiveInfo("122792618177", "1e608a10060e75be7fc6c85645d6b2b7")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user