|
@@ -2,12 +2,15 @@ package com.yoho.activity.service.impl; |
|
@@ -2,12 +2,15 @@ package com.yoho.activity.service.impl; |
2
|
|
2
|
|
3
|
import com.yoho.activity.common.helper.SendCouponHelper;
|
3
|
import com.yoho.activity.common.helper.SendCouponHelper;
|
4
|
import com.yoho.activity.service.IUserdayDrawPrizeService;
|
4
|
import com.yoho.activity.service.IUserdayDrawPrizeService;
|
|
|
5
|
+import com.yoho.core.rest.client.ServiceCaller;
|
|
|
6
|
+import com.yoho.service.model.request.YohoCoinLogReqBO;
|
5
|
import com.yoho.userday.dal.model.UserdayPrizeLog;
|
7
|
import com.yoho.userday.dal.model.UserdayPrizeLog;
|
6
|
import org.slf4j.Logger;
|
8
|
import org.slf4j.Logger;
|
7
|
import org.slf4j.LoggerFactory;
|
9
|
import org.slf4j.LoggerFactory;
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.stereotype.Service;
|
11
|
import org.springframework.stereotype.Service;
|
10
|
|
12
|
|
|
|
13
|
+import javax.annotation.Resource;
|
11
|
import java.util.List;
|
14
|
import java.util.List;
|
12
|
import java.util.Random;
|
15
|
import java.util.Random;
|
13
|
|
16
|
|
|
@@ -21,6 +24,8 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
@@ -21,6 +24,8 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
21
|
|
24
|
|
22
|
@Autowired
|
25
|
@Autowired
|
23
|
private SendCouponHelper sendCouponHelper;
|
26
|
private SendCouponHelper sendCouponHelper;
|
|
|
27
|
+ @Resource
|
|
|
28
|
+ ServiceCaller serviceCaller;
|
24
|
|
29
|
|
25
|
@Override
|
30
|
@Override
|
26
|
public int drawPrize(int uid) throws Exception {
|
31
|
public int drawPrize(int uid) throws Exception {
|
|
@@ -31,7 +36,18 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
@@ -31,7 +36,18 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
31
|
throw new Exception("参数不合法");
|
36
|
throw new Exception("参数不合法");
|
32
|
}
|
37
|
}
|
33
|
|
38
|
|
34
|
- // (2)根据中奖规则获取有货币数量
|
39
|
+ // (2)判断有货币数量是否足够抽奖
|
|
|
40
|
+ YohoCoinLogReqBO yohoCoinLogReqBO = new YohoCoinLogReqBO();
|
|
|
41
|
+ yohoCoinLogReqBO.setUid(uid);
|
|
|
42
|
+ int num = serviceCaller.call("users.getYohoCoinNum", yohoCoinLogReqBO, Integer.class);
|
|
|
43
|
+ if (20 > num) {
|
|
|
44
|
+ throw new Exception("有货币数量不足");
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ // (3)消耗有货币用于抽奖
|
|
|
48
|
+ sendCouponHelper.sendYOHOBi(uid, -20, 12);
|
|
|
49
|
+
|
|
|
50
|
+ // (4)根据中奖规则获取有货币数量
|
35
|
int yohoCoinNum = 0;
|
51
|
int yohoCoinNum = 0;
|
36
|
int random = new Random().nextInt(1000);
|
52
|
int random = new Random().nextInt(1000);
|
37
|
if (999 == random) {
|
53
|
if (999 == random) {
|
|
@@ -47,12 +63,12 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
@@ -47,12 +63,12 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
47
|
}
|
63
|
}
|
48
|
log.info("drawPrize: draw prize complete. uid={}, yohoCoinNum={}, random={}", uid, yohoCoinNum, random);
|
64
|
log.info("drawPrize: draw prize complete. uid={}, yohoCoinNum={}, random={}", uid, yohoCoinNum, random);
|
49
|
|
65
|
|
50
|
- // (3)发送有货币
|
66
|
+ // (5)发送有货币
|
51
|
if (0 < yohoCoinNum) {
|
67
|
if (0 < yohoCoinNum) {
|
52
|
- sendCouponHelper.sendYOHOBi(uid, yohoCoinNum);
|
68
|
+ sendCouponHelper.sendYOHOBi(uid, yohoCoinNum, 6);
|
53
|
}
|
69
|
}
|
54
|
|
70
|
|
55
|
- // (4)返回
|
71
|
+ // (6)返回
|
56
|
return yohoCoinNum;
|
72
|
return yohoCoinNum;
|
57
|
}
|
73
|
}
|
58
|
|
74
|
|