京东商城订单修改
This commit is contained in:
@@ -16,6 +16,8 @@ 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>`)
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -384,10 +386,11 @@ func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrd
|
||||
}
|
||||
|
||||
type OrderDetailResult struct {
|
||||
ConsigneeName string `json:"consigneeName"`
|
||||
ConsigneeAddress string `json:"consigneeAddress"`
|
||||
ConsigneeMobile string `json:"consigneeMobile"`
|
||||
OrderCreatedAt string `json:"orderCreatedAt"`
|
||||
ConsigneeName string `json:"consigneeName"`
|
||||
ConsigneeAddress string `json:"consigneeAddress"`
|
||||
ConsigneeMobile string `json:"consigneeMobile"`
|
||||
ExpectedDeliveredTime string `json:"expectedDeliveredTime"`
|
||||
ActualPayPrice int64 `json:"actualPayPrice"`
|
||||
}
|
||||
|
||||
//订单详情
|
||||
@@ -399,6 +402,8 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult,
|
||||
if err == nil {
|
||||
orderDetailResult = &OrderDetailResult{}
|
||||
body := result["fakeData"].(string)
|
||||
expectedDeliveredTime := regexpOrderDetailDay.FindStringSubmatch(body)
|
||||
actualPayPrice := regexpOrderDetailPay.FindStringSubmatch(body)
|
||||
consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body)
|
||||
if len(consigneeTable) > 0 {
|
||||
consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1)
|
||||
@@ -411,6 +416,13 @@ func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult,
|
||||
orderDetailResult.ConsigneeMobile = consigneeMobiles[1]
|
||||
}
|
||||
}
|
||||
if len(expectedDeliveredTime) > 0 {
|
||||
times := strings.Split(expectedDeliveredTime[1], ",")
|
||||
orderDetailResult.ExpectedDeliveredTime = times[0] + " " + times[1][:strings.Index(times[1], ":")] + ":30:00"
|
||||
}
|
||||
if len(actualPayPrice) > 0 {
|
||||
orderDetailResult.ActualPayPrice = utils.Float64TwoInt64(utils.Str2Float64(strings.TrimSpace(actualPayPrice[1])) * 100)
|
||||
}
|
||||
}
|
||||
return orderDetailResult, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user