Authored by bblu

会员日

... ... @@ -25,8 +25,8 @@ public class UserdayPrizeLogController {
@ResponseBody
public ApiResponse addPrizeLog(int uid, int prize_type) throws Exception {
log.debug("enter addPrizeLog. param uid={}, prize_type={}", uid, prize_type);
userdayPrizeLogService.addPrizeLog(uid, prize_type);
return new ApiResponse(new Object());
int result = userdayPrizeLogService.addPrizeLog(uid, prize_type);
return new ApiResponse(result);
}
@RequestMapping("/existsPrizeLog")
... ...
... ... @@ -9,7 +9,7 @@ public interface IUserdayPrizeLogService {
UserdayPrizeLog queryPrizeLogForLeaveWords(int uid) throws Exception;
void addPrizeLog(int uid, int prize_type) throws Exception;
int addPrizeLog(int uid, int prize_type) throws Exception;
boolean existsPrizeLog(int uid, int prize_type) throws Exception;
}
... ...
... ... @@ -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;
}
... ...
... ... @@ -40,7 +40,7 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
}
@Override
public void addPrizeLog(int uid, int prize_type) throws Exception {
public int addPrizeLog(int uid, int prize_type) throws Exception {
log.info("enter addPrizeLog. param uid={}, prize_type={}", uid, prize_type);
// (1)校验uid, prize_type
... ... @@ -58,6 +58,8 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
// (3)保存抽奖日志
UserdayPrizeLog userdayPrizeLog = new UserdayPrizeLog(uid, prize_type, prize_value, DateUtil.currentTimeSeconds());
userdayPrizeLogDAO.insertLog(userdayPrizeLog);
return prize_value;
}
@Override
... ...