...
|
...
|
@@ -40,9 +40,11 @@ import com.yoho.error.exception.ServiceException; |
|
|
import com.yoho.lottery.dal.LotteryMapper;
|
|
|
import com.yoho.lottery.dal.LotteryRecordMapper;
|
|
|
import com.yoho.lottery.dal.PrizeMapper;
|
|
|
import com.yoho.lottery.dal.WeixinBindPrizeMapper;
|
|
|
import com.yoho.lottery.dal.model.Lottery;
|
|
|
import com.yoho.lottery.dal.model.LotteryRecord;
|
|
|
import com.yoho.lottery.dal.model.Prize;
|
|
|
import com.yoho.lottery.dal.model.WeixinBindPrize;
|
|
|
import com.yoho.product.model.GoodsImagesBo;
|
|
|
import com.yoho.service.model.order.request.OrderDetailRequest;
|
|
|
import com.yoho.service.model.order.request.OrderListRequest;
|
...
|
...
|
@@ -67,6 +69,13 @@ public class LotteryServiceImpl implements ILotteryService , ApplicationContextA |
|
|
private static final int STATE_MULTI = 3;
|
|
|
/** 不符合抽奖条件. */
|
|
|
private static final int STATE_NOT = 4;
|
|
|
|
|
|
/** 首次绑定送有货币成功. */
|
|
|
private static final int STATE_BIND_PRIZE_OK = 5;
|
|
|
/** 首次绑定送有货币失败. */
|
|
|
private static final int STATE_BIND_PRIZE_WRONG = 6;
|
|
|
/** 不是首次绑定. */
|
|
|
private static final int STATE_BIND_PRIZE_BAD = 6;
|
|
|
|
|
|
private static final String MSG_NO_PRIZE = "差一点就中奖啦!";
|
|
|
private static final String MSG_HAVE_PRIZE = "恭喜您,中奖啦!";
|
...
|
...
|
@@ -84,6 +93,9 @@ public class LotteryServiceImpl implements ILotteryService , ApplicationContextA |
|
|
|
|
|
@Resource
|
|
|
private LotteryRecordMapper lotteryRecordMapper;
|
|
|
|
|
|
@Resource
|
|
|
private WeixinBindPrizeMapper weixinBindPrizeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SendCouponHelper sendCouponHelper;
|
...
|
...
|
@@ -297,6 +309,32 @@ public class LotteryServiceImpl implements ILotteryService , ApplicationContextA |
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public LotteryRespData giveBindPrize(Integer userId) {
|
|
|
WeixinBindPrize prize = weixinBindPrizeMapper.selectByUid(userId);
|
|
|
LotteryRespData state = new LotteryRespData();
|
|
|
if (prize == null) {
|
|
|
logger.info("用户{}首次绑定发送50有货币奖励!", userId);
|
|
|
try {
|
|
|
WeixinBindPrize bindPrize = new WeixinBindPrize();
|
|
|
bindPrize.setUid(userId);
|
|
|
bindPrize.setRemark("用户首次绑定送50有货币");
|
|
|
bindPrize.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
weixinBindPrizeMapper.insert(bindPrize);
|
|
|
|
|
|
sendCouponHelper.sendYOHOBi(userId, 50);
|
|
|
state.setOrderLotteryCode(STATE_BIND_PRIZE_OK);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("用户{}首次绑定送50有货币出错,msg={}!", userId, e.getMessage());
|
|
|
state.setOrderLotteryCode(STATE_BIND_PRIZE_WRONG);
|
|
|
}
|
|
|
} else {
|
|
|
logger.info("用户{}不是首次绑定,不发送50有货币奖励!", userId);
|
|
|
state.setOrderLotteryCode(STATE_BIND_PRIZE_BAD);
|
|
|
}
|
|
|
return state;
|
|
|
}
|
|
|
|
|
|
@Cacheable(expireTime = CacheKeyAndTime.LOTTERY_USER_LOTTERY)
|
|
|
public LotteryRecord[] getLotteryRecordByIds(List<Integer> ids, int shardFactor) {
|
|
|
if (ids.isEmpty()) {
|
...
|
...
|
@@ -556,4 +594,5 @@ public class LotteryServiceImpl implements ILotteryService , ApplicationContextA |
|
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
lotteryService = (ILotteryService) applicationContext.getBean("lotteryServiceImpl");
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|