新增查询京东商场结算价
This commit is contained in:
@@ -30,6 +30,7 @@ func init() {
|
|||||||
// const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII"
|
// const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII"
|
||||||
const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHD6O37OTAHUCKU6ALXATYTGMHNFLM4XRLVSFUQAJR77M4URSZRKVO55243TDVXLO25PP4UYSPTTPMNRUFXDNP4WPE566Q6V4AH32F7HT"
|
const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHD6O37OTAHUCKU6ALXATYTGMHNFLM4XRLVSFUQAJR77M4URSZRKVO55243TDVXLO25PP4UYSPTTPMNRUFXDNP4WPE566Q6V4AH32F7HT"
|
||||||
api.SetJdCookie(cookieValue)
|
api.SetJdCookie(cookieValue)
|
||||||
|
api.SetCookie("user", "VCQUVHVJI4ELNGFZOYMCDYDUSHEJMPXZRZXSNBRB4MVBNENP72REAAZR3R4SGDJ5ZI4FLYLLN5EGBBMTFCWHZVESIWBNLKZPLHWD6UIBTPXOF5IXM6AVA3V6TUNZD5UJS43AROJ2IRPZWEN5AGZYBUEGD3MSKKBKBSRP3DSEQXLITYNBLFZCHXCA7L4KGOSJRMM7R5IQP7QGLGRQB27AOE4YMLRJ3UPTZADPWJOYB3UZ7UZHLBVZRREEX647O3WQUU4BYXUOFZPIPRR77W3PQV543E")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTest(t *testing.T) {
|
func TestTest(t *testing.T) {
|
||||||
|
|||||||
@@ -424,6 +424,59 @@ func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, is
|
|||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) AccessStorePage3(fullURL string, params map[string]interface{}, resultKey string) (retVal interface{}, err error) {
|
||||||
|
if a.GetCookieCount() == 0 {
|
||||||
|
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||||
|
}
|
||||||
|
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||||
|
func() *http.Request {
|
||||||
|
request, _ := http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", params), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
a.FillRequestCookies(request)
|
||||||
|
return request
|
||||||
|
},
|
||||||
|
a.config,
|
||||||
|
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||||
|
if jsonResult1 == nil {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
|
}
|
||||||
|
retVal = jsonResult1
|
||||||
|
var errMsg string
|
||||||
|
code, ok := jsonResult1["resultCode"].(string)
|
||||||
|
if !ok {
|
||||||
|
if statusMap, ok := jsonResult1["status"].(map[string]interface{}); !ok {
|
||||||
|
if jsonResult1["operTag"] != nil {
|
||||||
|
return platformapi.ErrLevelSuccess, nil
|
||||||
|
}
|
||||||
|
return platformapi.ErrLevelGeneralFail, utils.NewErrorCode(utils.Format4Output(jsonResult1, true), "999")
|
||||||
|
} else {
|
||||||
|
code = utils.Int64ToStr(utils.ForceInterface2Int64(statusMap["errorCode"]))
|
||||||
|
errMsg = utils.Interface2String(statusMap["message"])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errMsg = utils.Interface2String(jsonResult1["msg"])
|
||||||
|
}
|
||||||
|
if code == "200" {
|
||||||
|
if resultKey != "" {
|
||||||
|
retVal = jsonResult1[resultKey]
|
||||||
|
}
|
||||||
|
return platformapi.ErrLevelSuccess, nil
|
||||||
|
}
|
||||||
|
newErr := utils.NewErrorCode(errMsg, code)
|
||||||
|
if _, ok := pageExceedLimitCodes[code]; ok {
|
||||||
|
return platformapi.ErrLevelExceedLimit, newErr
|
||||||
|
} else if _, ok := pageCanRetryCodes[code]; ok {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, newErr
|
||||||
|
} else {
|
||||||
|
baseapi.SugarLogger.Debugf("jd AccessStorePage failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
|
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) AccessStorePage(fullURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
func (a *API) AccessStorePage(fullURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||||
result, err := a.AccessStorePage2(fullURL, params, isPost, ResultKeyResult)
|
result, err := a.AccessStorePage2(fullURL, params, isPost, ResultKeyResult)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -942,3 +995,82 @@ func (a *API) UpdateClosetStatus(jdStoreID, closeStatus int) (err error) {
|
|||||||
_, err = a.AccessStorePage2("https://sta-store.jddj.com/store/updateClosetStatus", jdParams, true, "")
|
_, err = a.AccessStorePage2("https://sta-store.jddj.com/store/updateClosetStatus", jdParams, true, "")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetJdShopOrdersResult struct {
|
||||||
|
SummaryDueAmount float64 `json:"summaryDueAmount"`
|
||||||
|
BillList struct {
|
||||||
|
Result []struct {
|
||||||
|
OrderTypeCode int `json:"orderTypeCode"`
|
||||||
|
PayChannelName string `json:"payChannelName"`
|
||||||
|
BaseCommissionInvoiceFee int `json:"baseCommissionInvoiceFee"`
|
||||||
|
TieredCommissionInvoiceFee int `json:"tieredCommissionInvoiceFee"`
|
||||||
|
OrderID int64 `json:"orderId"`
|
||||||
|
Subsidy float64 `json:"subsidy"`
|
||||||
|
SettleStatus string `json:"settleStatus"`
|
||||||
|
PaymentSubsidies float64 `json:"paymentSubsidies"`
|
||||||
|
DeliveryTypeStr string `json:"deliveryTypeStr"`
|
||||||
|
PackageBill float64 `json:"packageBill"`
|
||||||
|
StoreFreightSubsidy float64 `json:"storeFreightSubsidy"`
|
||||||
|
OfflineSettlementAmount float64 `json:"offlineSettlementAmount"`
|
||||||
|
EffectiveGMV int `json:"effectiveGMV"`
|
||||||
|
TieredCommissionFee int `json:"tieredCommissionFee"`
|
||||||
|
OrgCode int `json:"orgCode"`
|
||||||
|
AfsAmount int `json:"afsAmount"`
|
||||||
|
StationName string `json:"stationName"`
|
||||||
|
Commission float64 `json:"commission"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
WithdrawID string `json:"withdrawId"`
|
||||||
|
BusinessFinishTime int64 `json:"businessFinishTime"`
|
||||||
|
StationID int `json:"stationId"`
|
||||||
|
SettleOrderIDStr string `json:"settleOrderIdStr"`
|
||||||
|
FreightBill int `json:"freightBill"`
|
||||||
|
GiftcardBill int `json:"giftcardBill"`
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
|
OrderSourceName string `json:"orderSourceName"`
|
||||||
|
PickupServiceAmount float64 `json:"pickupServiceAmount"`
|
||||||
|
RelationID int `json:"relationId"`
|
||||||
|
GoodsBill float64 `json:"goodsBill"`
|
||||||
|
SettleOrderID int64 `json:"settleOrderId"`
|
||||||
|
MarketBill float64 `json:"marketBill"`
|
||||||
|
StoreFreightAmount float64 `json:"storeFreightAmount"`
|
||||||
|
BusinessStartTime int64 `json:"businessStartTime"`
|
||||||
|
OriginalAmount float64 `json:"originalAmount"`
|
||||||
|
DueAmount float64 `json:"dueAmount"`
|
||||||
|
BillOrderType int `json:"billOrderType"`
|
||||||
|
StoreSubsidy float64 `json:"storeSubsidy"`
|
||||||
|
AccountTime string `json:"accountTime"`
|
||||||
|
PickupAmount float64 `json:"pickupAmount"`
|
||||||
|
SettleFinishTime int `json:"settleFinishTime"`
|
||||||
|
BaseCommissionFee int `json:"baseCommissionFee"`
|
||||||
|
} `json:"result"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
Pages int `json:"pages"`
|
||||||
|
StartRow int `json:"startRow"`
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
EndRow int `json:"endRow"`
|
||||||
|
PageNum int `json:"pageNum"`
|
||||||
|
} `json:"billList"`
|
||||||
|
SummaryGoodsBill float64 `json:"summaryGoodsBill"`
|
||||||
|
CurrentDueAmount float64 `json:"currentDueAmount"`
|
||||||
|
SummaryPositiveAmount float64 `json:"summaryPositiveAmount"`
|
||||||
|
CurrentGoodsBill float64 `json:"currentGoodsBill"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取京东商城订单结算价
|
||||||
|
//https://dfsc.imdada.cn/settle/search/daoJiaBillList
|
||||||
|
func (a *API) GetJdShopOrders(orderStartTime, orderEndTime, orgCode, loginName string) (getJdShopOrdersResult *GetJdShopOrdersResult, err error) {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"orgCode": orgCode,
|
||||||
|
"orderStartTime": orderStartTime,
|
||||||
|
"orderEndTime": orderEndTime,
|
||||||
|
"pageNum": 1,
|
||||||
|
"pageSize": 100,
|
||||||
|
"loginName": loginName,
|
||||||
|
"jdFusion": true,
|
||||||
|
}
|
||||||
|
result, err := a.AccessStorePage3("https://dfsc.imdada.cn/settle/search/daoJiaBillList", jdParams, "")
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result.(map[string]interface{})["content"], &getJdShopOrdersResult, false)
|
||||||
|
}
|
||||||
|
return getJdShopOrdersResult, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -264,3 +264,11 @@ func TestUpdateClosetStatus(t *testing.T) {
|
|||||||
err := api.UpdateClosetStatus(801246, 1)
|
err := api.UpdateClosetStatus(801246, 1)
|
||||||
fmt.Println("test1", err)
|
fmt.Println("test1", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetJdShopOrders(t *testing.T) {
|
||||||
|
result, err := api.GetJdShopOrders("20200506", "20200508", "320406", "jd_jxcs1223")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user