|
@@ -1,5 +1,6 @@
|
|
package com.ruoyi.wx.web.service.impl;
|
|
package com.ruoyi.wx.web.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.framework.recovery.domain.WxUserLottery;
|
|
import com.ruoyi.framework.recovery.domain.WxUserLottery;
|
|
@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -24,13 +26,17 @@ public class WxLotteryUserServiceImpl implements IWxLotteryUserService {
|
|
String wxOpenid = SecurityUtils.getLoginWxUser().getWxUser().getWxOpenid();
|
|
String wxOpenid = SecurityUtils.getLoginWxUser().getWxUser().getWxOpenid();
|
|
lottery.setOpenId(wxOpenid);
|
|
lottery.setOpenId(wxOpenid);
|
|
List<WxUserLottery> userLotteries = wxUserLotteryMapper.selectWxUserLotteryList(lottery);
|
|
List<WxUserLottery> userLotteries = wxUserLotteryMapper.selectWxUserLotteryList(lottery);
|
|
|
|
+ if (CollectionUtil.isEmpty(userLotteries)) {
|
|
|
|
+ return new LotteryVo();
|
|
|
|
+ }
|
|
List<String> lotteryIds = new ArrayList<>();
|
|
List<String> lotteryIds = new ArrayList<>();
|
|
for (WxUserLottery userLottery : userLotteries) {
|
|
for (WxUserLottery userLottery : userLotteries) {
|
|
lotteryIds.add(userLottery.getLotteryNum());
|
|
lotteryIds.add(userLottery.getLotteryNum());
|
|
}
|
|
}
|
|
|
|
+ // TODO 修改返回参数为List<LotteryVo>
|
|
LotteryVo result = new LotteryVo();
|
|
LotteryVo result = new LotteryVo();
|
|
result.setLotteryCodes(lotteryIds);
|
|
result.setLotteryCodes(lotteryIds);
|
|
- result.setLotteryNum(lotteryIds.size());
|
|
|
|
|
|
+ result.setLotteryType("1");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -44,7 +50,7 @@ public class WxLotteryUserServiceImpl implements IWxLotteryUserService {
|
|
if (total > 10) {
|
|
if (total > 10) {
|
|
throw new ServiceException("超出抽奖数量阈值");
|
|
throw new ServiceException("超出抽奖数量阈值");
|
|
}
|
|
}
|
|
- List<WxUserLottery> dto = new ArrayList<>();
|
|
|
|
|
|
+ // 构建抽奖记录
|
|
for (int i = 0 ; i < lotteryDto.getNum() ; i++) {
|
|
for (int i = 0 ; i < lotteryDto.getNum() ; i++) {
|
|
WxUserLottery info = new WxUserLottery();
|
|
WxUserLottery info = new WxUserLottery();
|
|
info.setOpenId(wxOpenid);
|
|
info.setOpenId(wxOpenid);
|
|
@@ -52,7 +58,10 @@ public class WxLotteryUserServiceImpl implements IWxLotteryUserService {
|
|
lotteryCode = lotteryCode + i;
|
|
lotteryCode = lotteryCode + i;
|
|
info.setLotteryNum(lotteryCode);
|
|
info.setLotteryNum(lotteryCode);
|
|
info.setLotteryType(lotteryDto.getType());
|
|
info.setLotteryType(lotteryDto.getType());
|
|
|
|
+ info.setCreateDate(new Date());
|
|
|
|
+ wxUserLotteryMapper.insertWxUserLottery(info);
|
|
}
|
|
}
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|