- 重构京东活动API
This commit is contained in:
158
platformapi/jdapi/promotion_audit.go
Normal file
158
platformapi/jdapi/promotion_audit.go
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
package jdapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
AuditPromotionStateNew = 101 // 待开始
|
||||||
|
AuditPromotionStateOnGoing = 102 // 进行中
|
||||||
|
AuditPromotionStateEnded = 103 // 结束
|
||||||
|
AuditPromotionStateCanceled = 104 // 取消
|
||||||
|
AuditPromotionStateAll = 105 // 全部
|
||||||
|
)
|
||||||
|
|
||||||
|
type OpenPlatActivityQResponse struct {
|
||||||
|
AddLadderList []struct {
|
||||||
|
BenefitMaxCount int `json:"benefitMaxCount"`
|
||||||
|
DiscountAmount int `json:"discountAmount"`
|
||||||
|
DiscountRate float32 `json:"discountRate"`
|
||||||
|
LowMoney int `json:"lowMoney"`
|
||||||
|
LowerLimitCount int `json:"lowerLimitCount"`
|
||||||
|
OrderLadder string `json:"orderLadder"`
|
||||||
|
} `json:"addLadderList"`
|
||||||
|
Awords string `json:"awords"`
|
||||||
|
BeginDate *utils.JavaDate `json:"beginDate"`
|
||||||
|
CostRadios int `json:"costRadios"`
|
||||||
|
EndDate *utils.JavaDate `json:"endDate"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
IsMerchant int `json:"isMerchant"`
|
||||||
|
OrderLadder string `json:"orderLadder"`
|
||||||
|
OrgCode string `json:"orgCode"`
|
||||||
|
OutActivityID string `json:"outActivityId"`
|
||||||
|
PromotionName string `json:"promotionName"`
|
||||||
|
SkuBeanList []struct {
|
||||||
|
SkuID int64 `json:"skuId"`
|
||||||
|
SkuName int64 `json:"skuName"`
|
||||||
|
} `json:"skuBeanList"`
|
||||||
|
State int `json:"state"`
|
||||||
|
StationBeanList []struct {
|
||||||
|
OrgCode interface{} `json:"orgCode"`
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
|
OutStationNo string `json:"outStationNo"`
|
||||||
|
StationName string `json:"stationName"`
|
||||||
|
StationNo int `json:"stationNo"`
|
||||||
|
} `json:"stationBeanList"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PromotionSkuResult struct {
|
||||||
|
LimitDaily int
|
||||||
|
LimitDevice int
|
||||||
|
LimitPin int
|
||||||
|
PlatformRatio int
|
||||||
|
PromotionPrice int
|
||||||
|
SkuId int64
|
||||||
|
StationNo int64
|
||||||
|
StoreRatio int
|
||||||
|
}
|
||||||
|
|
||||||
|
type PromotionInfo struct {
|
||||||
|
BeginTime time.Time
|
||||||
|
EndTime time.Time
|
||||||
|
PromotionInfoId int64
|
||||||
|
PromotionState int
|
||||||
|
PromotionType int
|
||||||
|
Source string
|
||||||
|
SkuResultList []*PromotionSkuResult
|
||||||
|
}
|
||||||
|
|
||||||
|
type PromotionLspQueryInfoResult struct {
|
||||||
|
BeginTime *utils.JavaDate `json:"beginTime"`
|
||||||
|
EndTime *utils.JavaDate `json:"endTime"`
|
||||||
|
PromotionInfoID int `json:"promotionInfoId"`
|
||||||
|
PromotionState int `json:"promotionState"`
|
||||||
|
PromotionType int `json:"promotionType"`
|
||||||
|
SkuResultList []struct {
|
||||||
|
BeginTime *utils.JavaDate `json:"beginTime"`
|
||||||
|
EndTime *utils.JavaDate `json:"endTime"`
|
||||||
|
LimitDaily int `json:"limitDaily"`
|
||||||
|
LimitDevice int `json:"limitDevice"`
|
||||||
|
LimitPin int `json:"limitPin"`
|
||||||
|
PlatformRatio int `json:"platformRatio"`
|
||||||
|
PromotionPrice int `json:"promotionPrice"`
|
||||||
|
PromotionState int `json:"promotionState"`
|
||||||
|
PromotionType int `json:"promotionType"`
|
||||||
|
SkuId int64 `json:"skuId"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
StationNo int64 `json:"stationNo"`
|
||||||
|
StoreRatio int `json:"storeRatio"`
|
||||||
|
} `json:"skuResultList"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) OrderDiscountQueryActivityInfoById(activityID int64, promotionType, state int, operator string) (response *OpenPlatActivityQResponse, err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"activityId": activityID,
|
||||||
|
"type": promotionType,
|
||||||
|
"traceId": utils.GetUUID(),
|
||||||
|
"operator": operator,
|
||||||
|
"requestTime": time.Now().UnixNano() / 1000000,
|
||||||
|
}
|
||||||
|
if state > 0 {
|
||||||
|
params["state"] = state
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfoById", params, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "10000"))
|
||||||
|
if err == nil {
|
||||||
|
err = utils.Map2StructByJson(result, &response, false)
|
||||||
|
}
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) QueryPromotionInfo(promotionInfoId int64) (promotionInfo *PromotionInfo, err error) {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"promotionInfoId": promotionInfoId,
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPINoPage("singlePromote/queryPromotionInfo", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||||
|
if err == nil {
|
||||||
|
data := result.(map[string]interface{})
|
||||||
|
// baseapi.SugarLogger.Debug(utils.Format4Output(data, false))
|
||||||
|
promotionInfo = &PromotionInfo{
|
||||||
|
BeginTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["beginTime"].(map[string]interface{})["time"]) / 1000),
|
||||||
|
EndTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["endTime"].(map[string]interface{})["time"]) / 1000),
|
||||||
|
PromotionInfoId: utils.MustInterface2Int64(data["promotionInfoId"]),
|
||||||
|
PromotionState: int(utils.MustInterface2Int64(data["promotionState"])),
|
||||||
|
PromotionType: int(utils.MustInterface2Int64(data["promotionType"])),
|
||||||
|
Source: utils.Interface2String(data["source"]),
|
||||||
|
}
|
||||||
|
skuResultList := data["skuResultList"].([]interface{})
|
||||||
|
promotionInfo.SkuResultList = make([]*PromotionSkuResult, len(skuResultList))
|
||||||
|
for k, v := range skuResultList {
|
||||||
|
skuResult := v.(map[string]interface{})
|
||||||
|
promotionInfo.SkuResultList[k] = &PromotionSkuResult{
|
||||||
|
LimitDaily: int(utils.MustInterface2Int64(skuResult["limitDaily"])),
|
||||||
|
LimitDevice: int(utils.MustInterface2Int64(skuResult["limitDevice"])),
|
||||||
|
LimitPin: int(utils.MustInterface2Int64(skuResult["limitPin"])),
|
||||||
|
PlatformRatio: int(utils.MustInterface2Int64(skuResult["platformRatio"])),
|
||||||
|
PromotionPrice: int(utils.MustInterface2Int64(skuResult["promotionPrice"])),
|
||||||
|
SkuId: utils.MustInterface2Int64(skuResult["skuId"]),
|
||||||
|
StationNo: utils.MustInterface2Int64(skuResult["stationNo"]),
|
||||||
|
StoreRatio: int(utils.MustInterface2Int64(skuResult["storeRatio"])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return promotionInfo, nil
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) QueryPromotionInfo2(promotionInfoId int64) (promotionInfo *PromotionLspQueryInfoResult, err error) {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"promotionInfoId": promotionInfoId,
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPINoPage("singlePromote/queryPromotionInfo", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
||||||
|
if err == nil {
|
||||||
|
err = utils.Map2StructByJson(result, &promotionInfo, false)
|
||||||
|
}
|
||||||
|
return promotionInfo, err
|
||||||
|
}
|
||||||
23
platformapi/jdapi/promotion_audit_test.go
Normal file
23
platformapi/jdapi/promotion_audit_test.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package jdapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOrderDiscountQueryActivityInfoById(t *testing.T) {
|
||||||
|
result, err := api.OrderDiscountQueryActivityInfoById(1297945, OrderDiscountActivityTypeManJian, 0, "test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestQueryPromotionInfo2(t *testing.T) {
|
||||||
|
result, err := api.QueryPromotionInfo2(43430316)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package jdapi
|
package jdapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ type OrderDiscountRuleRequest struct {
|
|||||||
DiscountRate float32 `json:"discountRate,omitempty"`
|
DiscountRate float32 `json:"discountRate,omitempty"`
|
||||||
AddPrice int `json:"addPrice,omitempty"` // 分
|
AddPrice int `json:"addPrice,omitempty"` // 分
|
||||||
GiftList []*OrderDiscountGift `json:"giftList,omitempty"`
|
GiftList []*OrderDiscountGift `json:"giftList,omitempty"`
|
||||||
LadderLimit int `json:"ladderLimit,omitempty"`
|
LadderLimit int `json:"ladderLimit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderDiscountActivity struct {
|
type OrderDiscountActivity struct {
|
||||||
@@ -69,19 +67,45 @@ type ActivityOpQueryResultResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ActivityOpQueryInfoResponse struct {
|
type ActivityOpQueryInfoResponse struct {
|
||||||
ActivityID int64 `json:"activityID"`
|
ActivityID int64 `json:"activityID"`
|
||||||
OutActivityID string `json:"outActivityId"`
|
OutActivityID string `json:"outActivityId"`
|
||||||
PromotionName string `json:"promotionName"`
|
PromotionName string `json:"promotionName"`
|
||||||
BeginDate time.Time `json:"beginDate"`
|
BeginDate *utils.JavaDate `json:"beginDate"`
|
||||||
EndDate time.Time `json:"endDate"`
|
EndDate *utils.JavaDate `json:"endDate"`
|
||||||
Awords string `json:"awords"`
|
Awords string `json:"awords"`
|
||||||
State int `json:"state"`
|
State int `json:"state"`
|
||||||
OrderLadder string `json:"orderLadder"`
|
OrderLadder string `json:"orderLadder"`
|
||||||
StationList []int `json:"stationList"`
|
StationList []struct {
|
||||||
SkuList []int `json:"skuList"`
|
OrgName string `json:"orgName"`
|
||||||
LadderList []int `json:"ladderList"`
|
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) {
|
func (a *API) OrderDiscountSubmitActivity(actInfo *OrderDiscountActivity) (activityID int64, err error) {
|
||||||
result, err := a.AccessAPINoPage("orderdiscount/submitActivity", utils.Struct2FlatMap(actInfo), nil, nil, nil)
|
result, err := a.AccessAPINoPage("orderdiscount/submitActivity", utils.Struct2FlatMap(actInfo), nil, nil, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -90,60 +114,46 @@ func (a *API) OrderDiscountSubmitActivity(actInfo *OrderDiscountActivity) (activ
|
|||||||
return 0, err
|
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) {
|
func (a *API) OrderDiscountQuerySubmitActivityResult(activityID int64) (response *ActivityOpQueryResultResponse, err error) {
|
||||||
result, err := a.AccessAPINoPage("orderdiscount/querySubmitActivityResult", map[string]interface{}{
|
result, err := a.AccessAPINoPage("orderdiscount/querySubmitActivityResult", map[string]interface{}{
|
||||||
"activityId": activityID,
|
"activityId": activityID,
|
||||||
"operator": "jxc4",
|
"operator": "jxc4",
|
||||||
"traceId": utils.GetUUID(),
|
"traceId": utils.GetUUID(),
|
||||||
}, nil, nil, nil)
|
}, nil, nil, genNoPageResultParser("code", "detail", "result", "0"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
resultMap := result.(map[string]interface{})
|
err = utils.Map2StructByJson(result.([]interface{})[0], &response, true)
|
||||||
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"]),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (a *API) OrderDiscountQueryActivityInfo(activityID int64) (response *OrderDiscountResultResponse, err error) {
|
// 订单级促销活动查询促销详情接口
|
||||||
// result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfo", map[string]interface{}{
|
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=116d7dfe0b4e4122be300ce26b4e5381
|
||||||
// "activityId": activityID,
|
func (a *API) OrderDiscountQueryActivityInfo(activityID int64) (response *ActivityOpQueryInfoResponse, err error) {
|
||||||
// "sourceFrom": 3,
|
result, err := a.AccessAPINoPage("orderdiscount/queryActivityInfo", map[string]interface{}{
|
||||||
// "operator": "",
|
"activityId": activityID,
|
||||||
// "traceId": "",
|
"sourceFrom": 3,
|
||||||
// "version": "",
|
"operator": "",
|
||||||
// }, nil, nil, nil)
|
"traceId": "",
|
||||||
// if err == nil {
|
"version": "",
|
||||||
// resultMap := result.(map[string]interface{})
|
}, nil, nil, genNoPageResultParser("code", "detail", "result", "0"))
|
||||||
// response = &OrderDiscountResultResponse{
|
if err == nil {
|
||||||
// SubCode: utils.Interface2String(resultMap["subCode"]),
|
err = utils.Map2StructByJson(result, &response, true)
|
||||||
// SubMsg: utils.Interface2String(resultMap["subMsg"]),
|
}
|
||||||
// }
|
return response, err
|
||||||
// for _, v := range resultMap["resultList"].([]interface{}) {
|
}
|
||||||
// vMap := v.(map[string]interface{})
|
|
||||||
// response.ResultList = append(response.ResultList, &OrderDiscountResultInfo{
|
// 订单级促销活动取消接口
|
||||||
// ActivityID: utils.MustInterface2Int64(vMap["activityId"]),
|
// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=211&apiid=42509fdfeec14105a516b07b774a3055
|
||||||
// PromName: utils.Interface2String(vMap["promName"]),
|
func (a *API) OrderDiscountCancelActivity(activityID int64, operator, traceID string) (err error) {
|
||||||
// StationNo: utils.MustInterface2Int64(vMap["stationNo"]),
|
if traceID == "" {
|
||||||
// SkuID: utils.MustInterface2Int64(vMap["skuId"]),
|
traceID = utils.GetUUID()
|
||||||
// OutActivityId: utils.Interface2String(vMap["outActivityId"]),
|
}
|
||||||
// OutSkuId: utils.Interface2String(vMap["outSkuId"]),
|
_, err = a.AccessAPINoPage("orderdiscount/cancelActivity", map[string]interface{}{
|
||||||
// OutStationNo: utils.Interface2String(vMap["outStationNo"]),
|
"activityId": activityID,
|
||||||
// })
|
"operator": operator,
|
||||||
// }
|
"traceId": traceID,
|
||||||
// }
|
}, nil, nil, nil)
|
||||||
// return response, err
|
return err
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ func TestOrderDiscountSubmitActivity(t *testing.T) {
|
|||||||
LimitUserTotalNumber: 1,
|
LimitUserTotalNumber: 1,
|
||||||
RuleRequestList: []*OrderDiscountRuleRequest{
|
RuleRequestList: []*OrderDiscountRuleRequest{
|
||||||
&OrderDiscountRuleRequest{
|
&OrderDiscountRuleRequest{
|
||||||
LowerLimitAmount: 100,
|
LowerLimitAmount: 1000,
|
||||||
DiscountAmount: 1000,
|
DiscountAmount: 100,
|
||||||
DiscountRate: 0.5,
|
DiscountRate: 8.5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -35,9 +35,24 @@ func TestOrderDiscountSubmitActivity(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderDiscountQuerySubmitActivityResult(t *testing.T) {
|
func TestOrderDiscountQuerySubmitActivityResult(t *testing.T) {
|
||||||
result, err := api.OrderDiscountQuerySubmitActivityResult(3)
|
result, err := api.OrderDiscountQuerySubmitActivityResult(10000044)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log(result)
|
t.Log(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOrderDiscountQueryActivityInfo(t *testing.T) {
|
||||||
|
result, err := api.OrderDiscountQueryActivityInfo(10000044)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOrderDiscountCancelActivity(t *testing.T) {
|
||||||
|
err := api.OrderDiscountCancelActivity(10000044, "test", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,27 +29,6 @@ const (
|
|||||||
PromotionStateEnded = 9
|
PromotionStateEnded = 9
|
||||||
)
|
)
|
||||||
|
|
||||||
type PromotionSkuResult struct {
|
|
||||||
LimitDaily int
|
|
||||||
LimitDevice int
|
|
||||||
LimitPin int
|
|
||||||
PlatformRatio int
|
|
||||||
PromotionPrice int
|
|
||||||
SkuId int64
|
|
||||||
StationNo int64
|
|
||||||
StoreRatio int
|
|
||||||
}
|
|
||||||
|
|
||||||
type PromotionInfo struct {
|
|
||||||
BeginTime time.Time
|
|
||||||
EndTime time.Time
|
|
||||||
PromotionInfoId int64
|
|
||||||
PromotionState int
|
|
||||||
PromotionType int
|
|
||||||
Source string
|
|
||||||
SkuResultList []*PromotionSkuResult
|
|
||||||
}
|
|
||||||
|
|
||||||
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
|
func getPromotionCmd(inCmd string, promotionType int) (outCmd string) {
|
||||||
if promotionType == PromotionTypeDirectDown {
|
if promotionType == PromotionTypeDirectDown {
|
||||||
outCmd = "singlePromote/" + inCmd
|
outCmd = "singlePromote/" + inCmd
|
||||||
@@ -190,39 +169,3 @@ func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId string)
|
|||||||
_, err = a.AccessAPINoPage(getPromotionCmd("cancelPromotion", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
_, err = a.AccessAPINoPage(getPromotionCmd("cancelPromotion", promotionType), jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0"))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) QueryPromotionInfo(promotionInfoId int64) (promotionInfo *PromotionInfo, err error) {
|
|
||||||
jdParams := map[string]interface{}{
|
|
||||||
"promotionInfoId": promotionInfoId,
|
|
||||||
}
|
|
||||||
result, err := a.AccessAPINoPage("singlePromote/queryPromotionInfo", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0"))
|
|
||||||
if err == nil {
|
|
||||||
data := result.(map[string]interface{})
|
|
||||||
// baseapi.SugarLogger.Debug(utils.Format4Output(data, false))
|
|
||||||
promotionInfo = &PromotionInfo{
|
|
||||||
BeginTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["beginTime"].(map[string]interface{})["time"]) / 1000),
|
|
||||||
EndTime: utils.Timestamp2Time(utils.MustInterface2Int64(data["endTime"].(map[string]interface{})["time"]) / 1000),
|
|
||||||
PromotionInfoId: utils.MustInterface2Int64(data["promotionInfoId"]),
|
|
||||||
PromotionState: int(utils.MustInterface2Int64(data["promotionState"])),
|
|
||||||
PromotionType: int(utils.MustInterface2Int64(data["promotionType"])),
|
|
||||||
Source: utils.Interface2String(data["source"]),
|
|
||||||
}
|
|
||||||
skuResultList := data["skuResultList"].([]interface{})
|
|
||||||
promotionInfo.SkuResultList = make([]*PromotionSkuResult, len(skuResultList))
|
|
||||||
for k, v := range skuResultList {
|
|
||||||
skuResult := v.(map[string]interface{})
|
|
||||||
promotionInfo.SkuResultList[k] = &PromotionSkuResult{
|
|
||||||
LimitDaily: int(utils.MustInterface2Int64(skuResult["limitDaily"])),
|
|
||||||
LimitDevice: int(utils.MustInterface2Int64(skuResult["limitDevice"])),
|
|
||||||
LimitPin: int(utils.MustInterface2Int64(skuResult["limitPin"])),
|
|
||||||
PlatformRatio: int(utils.MustInterface2Int64(skuResult["platformRatio"])),
|
|
||||||
PromotionPrice: int(utils.MustInterface2Int64(skuResult["promotionPrice"])),
|
|
||||||
SkuId: utils.MustInterface2Int64(skuResult["skuId"]),
|
|
||||||
StationNo: utils.MustInterface2Int64(skuResult["stationNo"]),
|
|
||||||
StoreRatio: int(utils.MustInterface2Int64(skuResult["storeRatio"])),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return promotionInfo, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user