提交代码

dev-discount
胡锐 3 years ago
parent 96203b04da
commit d5d05b13af
  1. 46
      hai-cweb/src/main/java/com/cweb/controller/HighActivityController.java
  2. 13
      hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java

@ -1,5 +1,6 @@
package com.cweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -14,10 +15,7 @@ import com.hai.entity.*;
import com.hai.enum_type.ActivityInfoStatus;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighActivityAwardService;
import com.hai.service.HighActivityAwardUserService;
import com.hai.service.HighActivityInfoService;
import com.hai.service.HighActivityUserLotteryNumService;
import com.hai.service.*;
import com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -57,6 +55,9 @@ public class HighActivityController {
@Resource
private HighActivityAwardUserService highActivityAwardUserService;
@Resource
private HighActivityPrizeService highActivityPrizeService;
@Resource
private HighActivityUserLotteryNumService highActivityUserLotteryNumService;
@ -132,7 +133,24 @@ public class HighActivityController {
if (activity != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", activity);
map.put("activityAward", highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id")));
// 奖励
JSONArray awardList = JSONArray.parseArray(JSONArray.toJSONString(highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id"))));
for (Object awardObject : awardList) {
JSONObject award = (JSONObject) awardObject;
// 查询奖品
String prizeStr = "";
List<HighActivityPrize> list = highActivityPrizeService.getListByAwardId(award.getLong("id"));
for (HighActivityPrize prize : list) {
if (StringUtils.isBlank(prizeStr)) {
prizeStr = prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
} else {
prizeStr += "、"+prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
}
}
award.put("prizeStr", prizeStr);
}
map.put("activityAward", awardList);
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);
@ -153,7 +171,23 @@ public class HighActivityController {
if (detail != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", detail);
map.put("activityAward", highActivityAwardService.getListByActivityId(detail.getId()));
// 奖励
JSONArray awardList = JSONArray.parseArray(JSONArray.toJSONString(highActivityAwardService.getListByActivityId(activityId)));
for (Object awardObject : awardList) {
JSONObject award = (JSONObject) awardObject;
// 查询奖品
String prizeStr = "";
List<HighActivityPrize> list = highActivityPrizeService.getListByAwardId(award.getLong("id"));
for (HighActivityPrize prize : list) {
if (StringUtils.isBlank(prizeStr)) {
prizeStr = prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
} else {
prizeStr += "、"+prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
}
}
award.put("prizeStr", prizeStr);
}
map.put("activityAward", awardList);
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);

@ -65,6 +65,7 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo
// 增加中奖记录
highActivityAwardUserService.insertAwardUser(serialNum.getId(),userId);
// 异步领取奖品,减少接口响应时间
new Thread(() -> {
// 领取奖品
receivePrize(serialNum,userId);
@ -73,18 +74,6 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo
JSONObject jsonObject = new JSONObject();
jsonObject.put("activityAwardId", serialNum.getActivityAwardId());
jsonObject.put("serialNum", serialNum.getSerialNum());
// 查询中奖的奖品
JSONArray prizeArray = new JSONArray();
List<HighActivityPrize> prizeList = highActivityPrizeService.getListByAwardId(serialNum.getActivityAwardId());
for (HighActivityPrize prize : prizeList) {
JSONObject prizeObject = new JSONObject();
prizeObject.put("prizeName", prize.getPrizeName());
prizeObject.put("prizeNum", prize.getPrizeNum());
prizeArray.add(prize);
}
jsonObject.put("prizeList", prizeArray);
return jsonObject;
}

Loading…
Cancel
Save