- 重构京东活动API
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
@@ -32,7 +30,7 @@ type OrderDiscountRuleRequest struct {
|
||||
DiscountRate float32 `json:"discountRate,omitempty"`
|
||||
AddPrice int `json:"addPrice,omitempty"` // 分
|
||||
GiftList []*OrderDiscountGift `json:"giftList,omitempty"`
|
||||
LadderLimit int `json:"ladderLimit,omitempty"`
|
||||
LadderLimit int `json:"ladderLimit"`
|
||||
}
|
||||
|
||||
type OrderDiscountActivity struct {
|
||||
@@ -69,19 +67,45 @@ type ActivityOpQueryResultResponse struct {
|
||||
}
|
||||
|
||||
type ActivityOpQueryInfoResponse struct {
|
||||
ActivityID int64 `json:"activityID"`
|
||||
OutActivityID string `json:"outActivityId"`
|
||||
PromotionName string `json:"promotionName"`
|
||||
BeginDate time.Time `json:"beginDate"`
|
||||
EndDate time.Time `json:"endDate"`
|
||||
Awords string `json:"awords"`
|
||||
State int `json:"state"`
|
||||
OrderLadder string `json:"orderLadder"`
|
||||
StationList []int `json:"stationList"`
|
||||
SkuList []int `json:"skuList"`
|
||||
LadderList []int `json:"ladderList"`
|
||||
ActivityID int64 `json:"activityID"`
|
||||
OutActivityID string `json:"outActivityId"`
|
||||
PromotionName string `json:"promotionName"`
|
||||
BeginDate *utils.JavaDate `json:"beginDate"`
|
||||
EndDate *utils.JavaDate `json:"endDate"`
|
||||
Awords string `json:"awords"`
|
||||
State int `json:"state"`
|
||||
OrderLadder string `json:"orderLadder"`
|
||||
StationList []struct {
|
||||
OrgName string `json:"orgName"`
|
||||
StationNo int64 `json:"stationNo"`
|
||||
OutStationNo string `json:"outStationNo"`
|
||||
StationName string `json:"stationName"`
|
||||
} `json:"stationList"`
|
||||
SkuList []struct {
|
||||
OrgName string `json:"orgName"`
|
||||
SkuID int64 `json:"skuId"`
|
||||
OutSkuID string `json:"outSkuId"`
|
||||
SkuName string `json:"skuName"`
|
||||
} `json:"skuList"`
|
||||
LadderList []struct {
|
||||
BenefitMaxCount int `json:"benefitMaxCount"`
|
||||
DiscountAmount int `json:"discountAmount"`
|
||||
DiscountRate float32 `json:"discountRate"`
|
||||
LowMoney int `json:"lowMoney"`
|
||||
LowerLimitCount int `json:"lowerLimitCount"`
|
||||
OpGiftSkuList []struct {
|
||||
OrgName string `json:"orgName"`
|
||||
SkuID int64 `json:"skuId"`
|
||||
OutSkuID string `json:"outSkuId"`
|
||||
SkuName string `json:"skuName"`
|
||||
StockCount int `json:"stockCount"`
|
||||
} `json:"opGiftSkuList"`
|
||||
OrderLadder string `json:"orderLadder"`
|
||||
} `json:"ladderList"`
|
||||
}
|
||||
|
||||
// 订单级促销活动提交接口
|
||||
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=cf98af94d4124ca287af6cfe48f0f3aa
|
||||
func (a *API) OrderDiscountSubmitActivity(actInfo *OrderDiscountActivity) (activityID int64, err error) {
|
||||
result, err := a.AccessAPINoPage("orderdiscount/submitActivity", utils.Struct2FlatMap(actInfo), nil, nil, nil)
|
||||
if err == nil {
|
||||
@@ -90,60 +114,46 @@ func (a *API) OrderDiscountSubmitActivity(actInfo *OrderDiscountActivity) (activ
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 订单级促销活动查询活动提交处理结果接口
|
||||
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=b04e5426948349a78db1c5c9585d8df7
|
||||
func (a *API) OrderDiscountQuerySubmitActivityResult(activityID int64) (response *ActivityOpQueryResultResponse, err error) {
|
||||
result, err := a.AccessAPINoPage("orderdiscount/querySubmitActivityResult", map[string]interface{}{
|
||||
"activityId": activityID,
|
||||
"operator": "jxc4",
|
||||
"traceId": utils.GetUUID(),
|
||||
}, nil, nil, nil)
|
||||
}, nil, nil, genNoPageResultParser("code", "detail", "result", "0"))
|
||||
if err == nil {
|
||||
resultMap := result.(map[string]interface{})
|
||||
response = &ActivityOpQueryResultResponse{
|
||||
SubCode: utils.Interface2String(resultMap["subCode"]),
|
||||
SubMsg: utils.Interface2String(resultMap["subMsg"]),
|
||||
}
|
||||
for _, v := range resultMap["resultList"].([]interface{}) {
|
||||
vMap := v.(map[string]interface{})
|
||||
response.ResultList = append(response.ResultList, &ActivityOpResultInfo{
|
||||
ActivityID: utils.MustInterface2Int64(vMap["activityId"]),
|
||||
PromName: utils.Interface2String(vMap["promName"]),
|
||||
StationNo: utils.MustInterface2Int64(vMap["stationNo"]),
|
||||
SkuID: utils.MustInterface2Int64(vMap["skuId"]),
|
||||
OutActivityID: utils.Interface2String(vMap["outActivityId"]),
|
||||
OutSkuID: utils.Interface2String(vMap["outSkuId"]),
|
||||
OutStationNo: utils.Interface2String(vMap["outStationNo"]),
|
||||
})
|
||||
}
|
||||
err = utils.Map2StructByJson(result.([]interface{})[0], &response, true)
|
||||
}
|
||||
return response, err
|
||||
}
|
||||
|
||||
// func (a *API) OrderDiscountQueryActivityInfo(activityID int64) (response *OrderDiscountResultResponse, err error) {
|
||||
// result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfo", map[string]interface{}{
|
||||
// "activityId": activityID,
|
||||
// "sourceFrom": 3,
|
||||
// "operator": "",
|
||||
// "traceId": "",
|
||||
// "version": "",
|
||||
// }, nil, nil, nil)
|
||||
// if err == nil {
|
||||
// resultMap := result.(map[string]interface{})
|
||||
// response = &OrderDiscountResultResponse{
|
||||
// SubCode: utils.Interface2String(resultMap["subCode"]),
|
||||
// SubMsg: utils.Interface2String(resultMap["subMsg"]),
|
||||
// }
|
||||
// for _, v := range resultMap["resultList"].([]interface{}) {
|
||||
// vMap := v.(map[string]interface{})
|
||||
// response.ResultList = append(response.ResultList, &OrderDiscountResultInfo{
|
||||
// ActivityID: utils.MustInterface2Int64(vMap["activityId"]),
|
||||
// PromName: utils.Interface2String(vMap["promName"]),
|
||||
// StationNo: utils.MustInterface2Int64(vMap["stationNo"]),
|
||||
// SkuID: utils.MustInterface2Int64(vMap["skuId"]),
|
||||
// OutActivityId: utils.Interface2String(vMap["outActivityId"]),
|
||||
// OutSkuId: utils.Interface2String(vMap["outSkuId"]),
|
||||
// OutStationNo: utils.Interface2String(vMap["outStationNo"]),
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// return response, err
|
||||
// }
|
||||
// 订单级促销活动查询促销详情接口
|
||||
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=116d7dfe0b4e4122be300ce26b4e5381
|
||||
func (a *API) OrderDiscountQueryActivityInfo(activityID int64) (response *ActivityOpQueryInfoResponse, err error) {
|
||||
result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfo", map[string]interface{}{
|
||||
"activityId": activityID,
|
||||
"sourceFrom": 3,
|
||||
"operator": "",
|
||||
"traceId": "",
|
||||
"version": "",
|
||||
}, nil, nil, genNoPageResultParser("code", "detail", "result", "0"))
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(result, &response, true)
|
||||
}
|
||||
return response, err
|
||||
}
|
||||
|
||||
// 订单级促销活动取消接口
|
||||
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=42509fdfeec14105a516b07b774a3055
|
||||
func (a *API) OrderDiscountCancelActivity(activityID int64, operator, traceID string) (err error) {
|
||||
if traceID == "" {
|
||||
traceID = utils.GetUUID()
|
||||
}
|
||||
_, err = a.AccessAPINoPage("orderdiscount/cancelActivity", map[string]interface{}{
|
||||
"activityId": activityID,
|
||||
"operator": operator,
|
||||
"traceId": traceID,
|
||||
}, nil, nil, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user