...
|
...
|
@@ -2,12 +2,15 @@ package com.yoho.activity.service.impl; |
|
|
|
|
|
import com.yoho.activity.common.helper.SendCouponHelper;
|
|
|
import com.yoho.activity.service.IUserdayDrawPrizeService;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.service.model.request.YohoCoinLogReqBO;
|
|
|
import com.yoho.userday.dal.model.UserdayPrizeLog;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Random;
|
|
|
|
...
|
...
|
@@ -21,6 +24,8 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
|
|
|
|
@Autowired
|
|
|
private SendCouponHelper sendCouponHelper;
|
|
|
@Resource
|
|
|
ServiceCaller serviceCaller;
|
|
|
|
|
|
@Override
|
|
|
public int drawPrize(int uid) throws Exception {
|
...
|
...
|
@@ -31,7 +36,18 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
|
throw new Exception("参数不合法");
|
|
|
}
|
|
|
|
|
|
// (2)根据中奖规则获取有货币数量
|
|
|
// (2)判断有货币数量是否足够抽奖
|
|
|
YohoCoinLogReqBO yohoCoinLogReqBO = new YohoCoinLogReqBO();
|
|
|
yohoCoinLogReqBO.setUid(uid);
|
|
|
int num = serviceCaller.call("users.getYohoCoinNum", yohoCoinLogReqBO, Integer.class);
|
|
|
if (20 > num) {
|
|
|
throw new Exception("有货币数量不足");
|
|
|
}
|
|
|
|
|
|
// (3)消耗有货币用于抽奖
|
|
|
sendCouponHelper.sendYOHOBi(uid, -20, 12);
|
|
|
|
|
|
// (4)根据中奖规则获取有货币数量
|
|
|
int yohoCoinNum = 0;
|
|
|
int random = new Random().nextInt(1000);
|
|
|
if (999 == random) {
|
...
|
...
|
@@ -47,12 +63,12 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService |
|
|
}
|
|
|
log.info("drawPrize: draw prize complete. uid={}, yohoCoinNum={}, random={}", uid, yohoCoinNum, random);
|
|
|
|
|
|
// (3)发送有货币
|
|
|
// (5)发送有货币
|
|
|
if (0 < yohoCoinNum) {
|
|
|
sendCouponHelper.sendYOHOBi(uid, yohoCoinNum);
|
|
|
sendCouponHelper.sendYOHOBi(uid, yohoCoinNum, 6);
|
|
|
}
|
|
|
|
|
|
// (4)返回
|
|
|
// (6)返回
|
|
|
return yohoCoinNum;
|
|
|
}
|
|
|
|
...
|
...
|
|