|
@@ -3,19 +3,25 @@ package com.jpsoft.lotteryActivity.modules.business.controller;
|
|
|
|
|
|
import com.jpsoft.lotteryActivity.modules.base.entity.ActivityInfo;
|
|
|
import com.jpsoft.lotteryActivity.modules.base.entity.AwardInfo;
|
|
|
+import com.jpsoft.lotteryActivity.modules.base.entity.LotteryPersonnelInfo;
|
|
|
+import com.jpsoft.lotteryActivity.modules.base.entity.WinningInfo;
|
|
|
import com.jpsoft.lotteryActivity.modules.base.service.ActivityInfoService;
|
|
|
import com.jpsoft.lotteryActivity.modules.base.service.AwardInfoService;
|
|
|
+import com.jpsoft.lotteryActivity.modules.base.service.LotteryPersonnelInfoService;
|
|
|
+import com.jpsoft.lotteryActivity.modules.base.service.WinningInfoService;
|
|
|
import com.jpsoft.lotteryActivity.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.lotteryActivity.utils.StringUtils;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/business/startLottery")
|
|
@@ -28,9 +34,15 @@ public class StartLotteryController {
|
|
|
@Autowired
|
|
|
private AwardInfoService awardInfoService;
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
- public MessageResult<List<ActivityInfo>> list(){
|
|
|
+ @Autowired
|
|
|
+ private WinningInfoService winningInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LotteryPersonnelInfoService lotteryPersonnelInfoService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "list", method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<ActivityInfo>> list() {
|
|
|
MessageResult<List<ActivityInfo>> msgResult = new MessageResult<>();
|
|
|
|
|
|
List<ActivityInfo> activityInfoList = activityInfoService.list();
|
|
@@ -42,11 +54,10 @@ public class StartLotteryController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "findByActivityId",method = RequestMethod.POST)
|
|
|
- public MessageResult<List<AwardInfo>> findByActivityId(String activityId, HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "findByActivityId", method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<AwardInfo>> findByActivityId(String activityId, HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
@@ -60,4 +71,187 @@ public class StartLotteryController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取获奖人员列表")
|
|
|
+ @RequestMapping(value = "findWinningByActivityId", method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<Map>> findWinningByActivityId(String activityId, HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<List<Map>> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ List<AwardInfo> awardInfoList = awardInfoService.findByActivityId(activityId);
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ for (AwardInfo awardInfo : awardInfoList) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ List<WinningInfo> winningInfoList = winningInfoService.findByActivityIdAndAwardId(activityId, awardInfo.getId());
|
|
|
+
|
|
|
+ for (WinningInfo winningInfo : winningInfoList) {
|
|
|
+ LotteryPersonnelInfo lotteryPersonnelInfo = lotteryPersonnelInfoService.get(winningInfo.getLotteryPersonnelId());
|
|
|
+ if (lotteryPersonnelInfo != null) {
|
|
|
+ String phone = "";
|
|
|
+ if (StringUtils.isNoneEmpty(lotteryPersonnelInfo.getPhone())) {
|
|
|
+ phone = desensitizePhone(lotteryPersonnelInfo.getPhone());
|
|
|
+ }
|
|
|
+ winningInfo.setLotteryPersonnelPhone(phone);
|
|
|
+ winningInfo.setLotteryPersonnelImage(lotteryPersonnelInfo.getImage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("name", awardInfo.getName());
|
|
|
+ map.put("num", winningInfoList.size());
|
|
|
+ map.put("winningInfoList", winningInfoList);
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(mapList);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "参与抽奖人员列表")
|
|
|
+ @RequestMapping(value = "lotteryPersonnelList", method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<LotteryPersonnelInfo>> lotteryPersonnelList(String activityId, HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<List<LotteryPersonnelInfo>> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ List<LotteryPersonnelInfo> lotteryPersonnelInfoList = lotteryPersonnelInfoService.findByActivityId(activityId);
|
|
|
+
|
|
|
+ for (LotteryPersonnelInfo lotteryPersonnelInfo : lotteryPersonnelInfoList) {
|
|
|
+
|
|
|
+ String phone = "";
|
|
|
+ if (StringUtils.isNoneEmpty(lotteryPersonnelInfo.getPhone())) {
|
|
|
+ phone = desensitizePhone(lotteryPersonnelInfo.getPhone());
|
|
|
+ }
|
|
|
+ lotteryPersonnelInfo.setPhone(phone);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(lotteryPersonnelInfoList);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="获取信息")
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
+ public MessageResult<AwardInfo> edit(@PathVariable("id") String id){
|
|
|
+ MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ AwardInfo awardInfo = awardInfoService.get(id);
|
|
|
+
|
|
|
+ if (awardInfo != null) {
|
|
|
+ ActivityInfo activityInfo = activityInfoService.get(awardInfo.getActivityId());
|
|
|
+ if(activityInfo!=null){
|
|
|
+ awardInfo.setActivityName(activityInfo.getName());
|
|
|
+ }
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(awardInfo);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "开始抽奖")
|
|
|
+ @PostMapping("startLotteryAward")
|
|
|
+ public MessageResult<List<Map>> startLotteryAward(String activityId,String awardId) {
|
|
|
+ MessageResult<List<Map>> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<WinningInfo> winningInfoList = winningInfoService.startLottery(activityId,awardId);
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (WinningInfo winningInfo : winningInfoList) {
|
|
|
+ Map map = new HashMap();
|
|
|
+
|
|
|
+ String activityName = "";
|
|
|
+ String phone = "";
|
|
|
+ String lotteryPersonnelNickName = "";
|
|
|
+ String lotteryPersonnelImage = "";
|
|
|
+ String awardName = "";
|
|
|
+ String awardPrizeName = "";
|
|
|
+
|
|
|
+ ActivityInfo activityInfo = activityInfoService.get(winningInfo.getActivityId());
|
|
|
+ if (activityInfo != null) {
|
|
|
+ activityName = activityInfo.getName();
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("activityName", activityName);
|
|
|
+
|
|
|
+ LotteryPersonnelInfo lotteryPersonnelInfo = lotteryPersonnelInfoService.get(winningInfo.getLotteryPersonnelId());
|
|
|
+
|
|
|
+ if (lotteryPersonnelInfo != null) {
|
|
|
+ phone = desensitizePhone(lotteryPersonnelInfo.getPhone());
|
|
|
+ lotteryPersonnelNickName = lotteryPersonnelInfo.getNickName();
|
|
|
+ lotteryPersonnelImage = lotteryPersonnelInfo.getImage();
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("lotteryPersonnelPhone", phone);
|
|
|
+ map.put("lotteryPersonnelNickName", lotteryPersonnelNickName);
|
|
|
+ map.put("lotteryPersonnelImage", lotteryPersonnelImage);
|
|
|
+
|
|
|
+ AwardInfo awardInfo = awardInfoService.get(winningInfo.getAwardId());
|
|
|
+
|
|
|
+ if (awardInfo != null) {
|
|
|
+ awardName = awardInfo.getName();
|
|
|
+ awardPrizeName = awardInfo.getPrizeName();
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("awardName", awardName);
|
|
|
+ map.put("awardPrizeName", awardPrizeName);
|
|
|
+ map.put("lotteryPersonnelId", winningInfo.getLotteryPersonnelId());
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(mapList);
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String desensitizePhone(String phone) {
|
|
|
+ if (phone == null || phone.length() != 11) {
|
|
|
+ return phone; // 非11位手机号不处理
|
|
|
+ }
|
|
|
+ // 使用正则表达式替换中间4位
|
|
|
+ return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
|
|
+ }
|
|
|
+
|
|
|
}
|