1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package ikc
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type couponIkc struct {
}
//Coupon 优惠券
var Coupon = couponIkc{}
type CouponListRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
CouponDesc string `json:"couponDesc"`
Amount float64 `json:"amount"`
ThresholdAmount float64 `json:"thresholdAmount"`
LiveId string `json:"liveId"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
CurrentNum int `json:"currentNum"`
RestrictNum int `json:"restrictNum"`
} `json:"data"`
}
//List 列表
func (*couponIkc) List(ctx context.Context, liveIds string) (res *CouponListRes, err error) {
method := "coupon/list"
result, err := post(ctx, method, g.Map{
"liveIds": liveIds,
})
_ = gjson.New(result).Scan(&res)
return
}
type CouponDrawRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data struct {
CouponUsedId string `json:"couponUsedId"`
Id string `json:"id"`
Name string `json:"name"`
Type int `json:"type"`
CouponDesc string `json:"couponDesc"`
Time string `json:"time"`
OverTime int64 `json:"overTime"`
Amount string `json:"amount"`
ThresholdAmount string `json:"thresholdAmount"`
} `json:"data"`
}
//Draw 领取
//`UserId` 外部渠道商用户ID
//`couponId` 优惠券ID
func (*couponIkc) Draw(ctx context.Context, UserId, couponId string) (res *CouponDrawRes, err error) {
method := "coupon/draw"
result, err := post(ctx, method, g.Map{
"outerUserId": UserId,
"couponId": couponId,
})
_ = gjson.New(result).Scan(&res)
return
}
type CouponRecommendReq struct {
UserId string `json:"outerUserId"` //外部渠道商用户ID
ProductList []CouponRecommendItem `json:"productList"`
}
type CouponRecommendItem struct {
LiveId string `json:"liveId"` //活动 ID
ProductId string `json:"productId"` //商品 ID
Count int `json:"count"` //数量
}
type CouponRecommendRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
Id string `json:"id"`
CouponId string `json:"couponId"`
Amount float64 `json:"amount"`
Name string `json:"name"`
CouponDesc string `json:"couponDesc"`
ThresholdAmount float64 `json:"thresholdAmount"`
Time string `json:"time"`
IsDefRecommend int `json:"isDefRecommend"`
} `json:"data"`
}
//Recommend 已领推荐优惠券
func (*couponIkc) Recommend(ctx context.Context, req CouponRecommendReq) (res *CouponRecommendRes, err error) {
method := "coupon/recommends"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type CouponHadReq struct {
UserId string `json:"outerUserId"` //外部渠道商用户ID
Status string `json:"status"` //优惠券状态 0-未使用 2-已使用或者已失效
PageNo int `json:"pageNo"`
PageSize int `json:"pageSize"`
}
type CouponHadRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data struct {
Total int `json:"total"`
UserCouponList []struct {
Id string `json:"id"`
UseId string `json:"useId"`
Name string `json:"name"`
CouponDesc string `json:"couponDesc"`
Amount float64 `json:"amount"`
ThresholdAmount float64 `json:"thresholdAmount"`
OverTime string `json:"overTime"`
Status int `json:"status"`
Time string `json:"time"`
Type int `json:"type"`
} `json:"userCouponList"`
} `json:"data"`
}
//Had 已领优惠券查询
func (*couponIkc) Had(ctx context.Context, req CouponHadReq) (res *CouponHadRes, err error) {
method := "coupon/user-had"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}