Showing
4 changed files
with
120 additions
and
0 deletions
@@ -73,6 +73,29 @@ public class SendCouponHelper { | @@ -73,6 +73,29 @@ public class SendCouponHelper { | ||
73 | return result; | 73 | return result; |
74 | } | 74 | } |
75 | 75 | ||
76 | + /** | ||
77 | + * 发送有货币 | ||
78 | + * | ||
79 | + * @param uid | ||
80 | + * @param num | ||
81 | + * @return | ||
82 | + */ | ||
83 | + public boolean sendYOHOBi(int uid, int num, int type) { | ||
84 | + YohoCoinRecordReq req = buildYohoCoinCostReq(uid, num, type); | ||
85 | + final String serviceName = "users.addRecord"; | ||
86 | + boolean result = false; | ||
87 | + try { | ||
88 | + log.info("BrandActivityServiceImpl sendYOHOBi req------ is {}", req); | ||
89 | + CommonRspBO rspBO = serviceCaller.call(serviceName, req, CommonRspBO.class); | ||
90 | + if (rspBO != null && rspBO.getCode() == 200) { | ||
91 | + result = true; | ||
92 | + } | ||
93 | + } catch (Exception e) { | ||
94 | + log.warn("in method sendYOHOBIEvent ,invoke {} occurs error,detail is {}", serviceName, e); | ||
95 | + } | ||
96 | + return result; | ||
97 | + } | ||
98 | + | ||
76 | // 构造参数 | 99 | // 构造参数 |
77 | private YohoCoinRecordReq buildYohoCoinCostReq(int uid, int num) { | 100 | private YohoCoinRecordReq buildYohoCoinCostReq(int uid, int num) { |
78 | YohoCoinRecordReq req = new YohoCoinRecordReq(); | 101 | YohoCoinRecordReq req = new YohoCoinRecordReq(); |
@@ -93,4 +116,26 @@ public class SendCouponHelper { | @@ -93,4 +116,26 @@ public class SendCouponHelper { | ||
93 | req.setHistory(yohoCoinLogReqBO); | 116 | req.setHistory(yohoCoinLogReqBO); |
94 | return req; | 117 | return req; |
95 | } | 118 | } |
119 | + | ||
120 | + // 构造参数 | ||
121 | + private YohoCoinRecordReq buildYohoCoinCostReq(int uid, int num, int type) { | ||
122 | + YohoCoinRecordReq req = new YohoCoinRecordReq(); | ||
123 | + | ||
124 | + YohoCoinCostReqBO yohoCoinCostReq = new YohoCoinCostReqBO(); | ||
125 | + yohoCoinCostReq.setUid(uid); | ||
126 | + yohoCoinCostReq.setNum(num); | ||
127 | + yohoCoinCostReq.setType(Byte.valueOf(String.valueOf(type)));// 抽奖送币 | ||
128 | + yohoCoinCostReq.setParams("{}"); | ||
129 | + yohoCoinCostReq.setOrderCode("0"); | ||
130 | + req.setCost(yohoCoinCostReq); | ||
131 | + | ||
132 | + YohoCoinLogReqBO yohoCoinLogReqBO = new YohoCoinLogReqBO(); | ||
133 | + yohoCoinLogReqBO.setUid(uid); | ||
134 | + yohoCoinLogReqBO.setChangeNum(Short.valueOf(String.valueOf(num))); | ||
135 | + yohoCoinLogReqBO.setChangeType(Byte.valueOf(String.valueOf(type))); | ||
136 | + yohoCoinLogReqBO.setChangeParams("{}"); | ||
137 | + req.setHistory(yohoCoinLogReqBO); | ||
138 | + return req; | ||
139 | + } | ||
140 | + | ||
96 | } | 141 | } |
1 | +package com.yoho.activity.controller; | ||
2 | + | ||
3 | +import com.yoho.activity.common.ApiResponse; | ||
4 | +import com.yoho.activity.service.IUserdaySigninService; | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Controller; | ||
9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
10 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
11 | + | ||
12 | +/** | ||
13 | + * 会员日,签到 | ||
14 | + */ | ||
15 | +@Controller | ||
16 | +@RequestMapping("/UserdaySigninController") | ||
17 | +public class UserdaySigninController { | ||
18 | + | ||
19 | + private static final Logger log = LoggerFactory.getLogger(UserdaySigninController.class); | ||
20 | + | ||
21 | + @Autowired | ||
22 | + IUserdaySigninService userdaySigninService; | ||
23 | + | ||
24 | + @RequestMapping("/signin") | ||
25 | + @ResponseBody | ||
26 | + public ApiResponse signin(int uid) throws Exception { | ||
27 | + log.debug("enter signin. param uid={}", uid); | ||
28 | + userdaySigninService.signin(uid); | ||
29 | + return new ApiResponse(new Object()); | ||
30 | + } | ||
31 | + | ||
32 | +} |
1 | +package com.yoho.activity.service.impl; | ||
2 | + | ||
3 | +import com.yoho.activity.common.helper.SendCouponHelper; | ||
4 | +import com.yoho.activity.service.IUserdaySigninService; | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Service; | ||
9 | + | ||
10 | +/** | ||
11 | + * 会员日,签到 | ||
12 | + */ | ||
13 | +@Service | ||
14 | +public class UserdaySigninServiceImpl implements IUserdaySigninService { | ||
15 | + | ||
16 | + private static final Logger log = LoggerFactory.getLogger(UserdaySigninServiceImpl.class); | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private SendCouponHelper sendCouponHelper; | ||
20 | + | ||
21 | + @Override | ||
22 | + public void signin(int uid) throws Exception { | ||
23 | + log.info("enter signin. param uid={}", uid); | ||
24 | + | ||
25 | + // (1)校验uid | ||
26 | + if (1 > uid) { | ||
27 | + throw new Exception("参数不合法"); | ||
28 | + } | ||
29 | + | ||
30 | + // (2)发送有货币,完成签到 | ||
31 | + sendCouponHelper.sendYOHOBi(uid, 100, 5); | ||
32 | + } | ||
33 | +} |
-
Please register or login to post a comment