150 lines
6.3 KiB
Go
150 lines
6.3 KiB
Go
package jdapi
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
const (
|
|
OrderDiscountActivityTypeManJian = 1 // 满减
|
|
OrderDiscountActivityTypeHuanGou = 1202 // 换购
|
|
OrderDiscountActivityTypeManZeng = 1203 // 满赠
|
|
OrderDiscountActivityTypeManJianJian = 1206 // 满件减
|
|
OrderDiscountActivityTypeManJianZhe = 1207 // 满件折
|
|
OrderDiscountActivityTypeKunBang = 1208 // 捆绑
|
|
OrderDiscountActivityTypeMeiManJian = 2210 // 每满减
|
|
|
|
ParticipationModeAllSku = 1 // 全部商品维度
|
|
ParticipationModePartSku = 2 // 部分商品维度
|
|
)
|
|
|
|
type OrderDiscountGift struct {
|
|
SkuID string `json:"skuId"`
|
|
StockCount int `json:"stockCount"`
|
|
}
|
|
|
|
type OrderDiscountRuleRequest struct {
|
|
LowerLimitAmount int `json:"lowerLimitAmount,omitempty"`
|
|
DiscountAmount int `json:"discountAmount,omitempty"`
|
|
UpperLimitCount int `json:"upperLimitCount,omitempty"`
|
|
LowerLimitCount int `json:"lowerLimitCount,omitempty"`
|
|
DiscountRate float32 `json:"discountRate,omitempty"`
|
|
AddPrice int `json:"addPrice,omitempty"` // 分
|
|
GiftList []*OrderDiscountGift `json:"giftList,omitempty"`
|
|
LadderLimit int `json:"ladderLimit,omitempty"`
|
|
}
|
|
|
|
type OrderDiscountActivity struct {
|
|
OutActivityID string `json:"outActivityId"` // 必须
|
|
PromName string `json:"promName"` // 必须
|
|
PromType int `json:"promType"` // 必须
|
|
BeginTime string `json:"beginTime"` // 必须
|
|
EndTime string `json:"endTime"` // 必须
|
|
ParticipationMode int `json:"participationMode"` // 必须
|
|
OutStationNos []string `json:"outStationNos,omitempty"`
|
|
StationNos []string `json:"stationNos,omitempty"`
|
|
OutSkuIds []string `json:"outSkuIds,omitempty"`
|
|
SkuIds []string `json:"skuIds,omitempty"`
|
|
LimitOrderTotalNumber int `json:"limitOrderTotalNumber"` // 必须
|
|
LimitUserTotalNumber int `json:"limitUserTotalNumber,omitempty"`
|
|
Display string `json:"display"` // 必须
|
|
RuleRequestList []*OrderDiscountRuleRequest `json:"ruleRequestList,omitempty"`
|
|
}
|
|
|
|
type ActivityOpResultInfo struct {
|
|
ActivityID int64 `json:"activityID"`
|
|
PromName string `json:"promName"`
|
|
StationNo int64 `json:"stationNo"`
|
|
SkuID int64 `json:"skuID"`
|
|
OutActivityID string `json:"outActivityId"`
|
|
OutSkuID string `json:"outSkuId"`
|
|
OutStationNo string `json:"outStationNo"`
|
|
}
|
|
|
|
type ActivityOpQueryResultResponse struct {
|
|
SubCode string `json:"subCode"`
|
|
SubMsg string `json:"subMsg"`
|
|
ResultList []*ActivityOpResultInfo `json:"resultList"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
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 {
|
|
return utils.MustInterface2Int64((result.(map[string]interface{}))["activityId"]), nil
|
|
}
|
|
return 0, err
|
|
}
|
|
|
|
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)
|
|
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"]),
|
|
})
|
|
}
|
|
}
|
|
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
|
|
// }
|