|
@@ -77,7 +77,7 @@ public class WinningInfoController {
|
|
|
|
|
|
|
|
int affectCount = 0;
|
|
int affectCount = 0;
|
|
|
|
|
|
|
|
- for (WinningInfo winningInfo:winningInfoList) {
|
|
|
|
|
|
|
+ for (WinningInfo winningInfo : winningInfoList) {
|
|
|
winningInfo.setId(UUID.randomUUID().toString());
|
|
winningInfo.setId(UUID.randomUUID().toString());
|
|
|
winningInfo.setDelFlag(false);
|
|
winningInfo.setDelFlag(false);
|
|
|
winningInfo.setCreateBy(subject);
|
|
winningInfo.setCreateBy(subject);
|
|
@@ -231,6 +231,7 @@ public class WinningInfoController {
|
|
|
@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
@RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
|
|
@RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
|
|
|
|
|
+ @RequestParam(value = "exportType", defaultValue = "") String exportType,
|
|
|
HttpServletRequest request) {
|
|
HttpServletRequest request) {
|
|
|
String subject = (String) request.getAttribute("subject");
|
|
String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
|
@@ -261,6 +262,7 @@ public class WinningInfoController {
|
|
|
|
|
|
|
|
String activityName = "";
|
|
String activityName = "";
|
|
|
String phone = "";
|
|
String phone = "";
|
|
|
|
|
+ String desensitizationPhone = "";
|
|
|
String lotteryPersonnelNickName = "";
|
|
String lotteryPersonnelNickName = "";
|
|
|
String lotteryPersonnelImage = "";
|
|
String lotteryPersonnelImage = "";
|
|
|
String awardName = "";
|
|
String awardName = "";
|
|
@@ -281,7 +283,13 @@ public class WinningInfoController {
|
|
|
lotteryPersonnelImage = lotteryPersonnelInfo.getImage();
|
|
lotteryPersonnelImage = lotteryPersonnelInfo.getImage();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(phone)) {
|
|
|
|
|
+ desensitizationPhone = desensitizePhone(phone);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
map.put("lotteryPersonnelPhone", phone);
|
|
map.put("lotteryPersonnelPhone", phone);
|
|
|
|
|
+ map.put("desensitizationPhone", desensitizationPhone);
|
|
|
map.put("lotteryPersonnelNickName", lotteryPersonnelNickName);
|
|
map.put("lotteryPersonnelNickName", lotteryPersonnelNickName);
|
|
|
map.put("lotteryPersonnelImage", lotteryPersonnelImage);
|
|
map.put("lotteryPersonnelImage", lotteryPersonnelImage);
|
|
|
|
|
|
|
@@ -300,7 +308,18 @@ public class WinningInfoController {
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exportFlag) {
|
|
if (exportFlag) {
|
|
|
- String filePath = exportXls(mapList);
|
|
|
|
|
|
|
+ String filePath = "";
|
|
|
|
|
+ if (StringUtils.isNotEmpty(exportType)) {
|
|
|
|
|
+ if("2".equals(exportType)){
|
|
|
|
|
+ filePath = exportXls2(mapList);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ filePath = exportXls(mapList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ filePath = exportXls(mapList);
|
|
|
|
|
+ }
|
|
|
msgResult.setData(filePath);
|
|
msgResult.setData(filePath);
|
|
|
} else {
|
|
} else {
|
|
|
Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
|
|
Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
|
|
@@ -318,6 +337,14 @@ public class WinningInfoController {
|
|
|
return msgResult;
|
|
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");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private String exportXls(List<Map> mapList) {
|
|
private String exportXls(List<Map> mapList) {
|
|
|
String downloadUrl = "";
|
|
String downloadUrl = "";
|
|
@@ -364,16 +391,59 @@ public class WinningInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ private String exportXls2(List<Map> mapList) {
|
|
|
|
|
+ String downloadUrl = "";
|
|
|
|
|
+
|
|
|
|
|
+ Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
+ Sheet sheet = workbook.createSheet();
|
|
|
|
|
+
|
|
|
|
|
+ //表头
|
|
|
|
|
+ Row rowTitle = sheet.createRow(0);
|
|
|
|
|
+
|
|
|
|
|
+ String[] titles = new String[]{"序号", "中奖人电话", "奖项", "所属活动"};
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < titles.length; i++) {
|
|
|
|
|
+ Cell cell = rowTitle.createCell(i);
|
|
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = mapList.get(i);
|
|
|
|
|
+
|
|
|
|
|
+ Row row = sheet.createRow(i + 1);
|
|
|
|
|
+
|
|
|
|
|
+ int colIndex = 0;
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(i + 1);
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.lotteryActivity.utils.StringUtils.strValue(map.get("desensitizationPhone"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.lotteryActivity.utils.StringUtils.strValue(map.get("awardName"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.lotteryActivity.utils.StringUtils.strValue(map.get("activityName"), ""));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ workbook.write(output);
|
|
|
|
|
+
|
|
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
|
+
|
|
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig, "winningInfoList", "中奖人名单.xls", input);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return downloadUrl;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "测试抽奖")
|
|
@ApiOperation(value = "测试抽奖")
|
|
|
@PostMapping("startLottery")
|
|
@PostMapping("startLottery")
|
|
|
- public MessageResult<List<Map>> startLottery(String activityId,String awardId, @RequestAttribute String subject) {
|
|
|
|
|
|
|
+ public MessageResult<List<Map>> startLottery(String activityId, String awardId, @RequestAttribute String subject) {
|
|
|
MessageResult<List<Map>> msgResult = new MessageResult<>();
|
|
MessageResult<List<Map>> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- List<WinningInfo> winningInfoList = winningInfoService.startLottery(activityId,awardId);
|
|
|
|
|
|
|
+ List<WinningInfo> winningInfoList = winningInfoService.startLottery(activityId, awardId);
|
|
|
|
|
|
|
|
List<Map> mapList = new ArrayList<>();
|
|
List<Map> mapList = new ArrayList<>();
|
|
|
|
|
|