dev-discount
胡锐 3 years ago
commit 52814ddf40
  1. 12
      hai-bweb/src/main/java/com/bweb/controller/HighActivityController.java
  2. 2
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  3. 50
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java
  4. 3
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java

@ -39,8 +39,8 @@ import java.util.*;
* @author hurui
*/
@Controller
@RequestMapping(value = "/activity")
@Api(value = "活动业务接口")
@RequestMapping(value = "/activityAward")
@Api(value = "活动奖励接口")
public class HighActivityController {
private static Logger log = LoggerFactory.getLogger(HighActivityController.class);
@ -78,10 +78,10 @@ public class HighActivityController {
// 组装奖品
if (body.getJSONArray("activityPrizes") != null && body.getJSONArray("activityPrizes").size() > 0) {
for (Object object : body.getJSONArray("ruleArray")) {
for (Object object : body.getJSONArray("activityPrizes")) {
JSONObject activityObject = (JSONObject)object;
if (
activityObject.getInteger("prizeType") == null ||
activityObject.getInteger("agentId") == null ||
activityObject.getLong("prizeId") == null ||
StringUtils.isBlank(activityObject.getString("prizeName")) ||
activityObject.getInteger("prizeNum") == null
@ -92,7 +92,7 @@ public class HighActivityController {
activityPrize = new HighActivityPrize();
activityPrize.setPrizeType(activityObject.getInteger("prizeType"));
activityPrize.setPrizeType(2);
activityPrize.setPrizeId(activityObject.getLong("prizeId"));
activityPrize.setPrizeName(activityObject.getString("prizeName"));
activityPrize.setPrizeNum(activityObject.getInteger("prizeNum"));
@ -127,7 +127,7 @@ public class HighActivityController {
highActivityAwardService.editHighActivateAward(highActivityAward , activityPrizes);
return ResponseMsgUtil.success("1");
return ResponseMsgUtil.success("成功");
} catch (Exception e) {
log.error("HighActivityController -> userLottery() error!",e);

@ -49,7 +49,7 @@ public interface HighDiscountAgentCodeService {
* @Param [discountAgentId]
* @return java.util.List<com.hai.entity.HighDiscountAgentCode>
**/
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId , Integer num);
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId);
/**
* @Author 胡锐

@ -1,5 +1,8 @@
package com.hai.service.impl;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.dao.HighActivityAwardActualPrizeMapper;
@ -38,6 +41,9 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighActivityAwardActualPrizeMapper highActivityAwardActualPrizeM;
@Override
public List<HighActivityAward> getListByActivityId(Long activityId) {
@ -61,10 +67,21 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
highActivityAwardMapper.updateByPrimaryKey(highActivityAward);
}
HighActivityAwardSerialNum serialNum;
// 增加奖品
for (HighActivityPrize list : highActivityPrizes) {
list.setActivityAwardId(highActivityAward.getId());
list.setCreateTime(new Date());
list.setUpdateTime(new Date());
list.setStatus(1);
highActivityPrizeMapper.insert(list);
}
HighActivityAwardSerialNum serialNum;
HighActivityAwardActualPrize actualPrize;
// 生成中奖编号
for (int i = 0; i < highActivityAward.getNum(); i++) {
serialNum = new HighActivityAwardSerialNum();
serialNum.setActivityInfoId(highActivityAward.getActivityInfoId());
@ -74,17 +91,27 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
serialNum.setCreateTime(new Date());
highActivityAwardSerialNumM.insert(serialNum);
// 增加奖品
// 循环奖品
for (HighActivityPrize list : highActivityPrizes) {
list.setActivityAwardId(highActivityAward.getId());
list.setCreateTime(new Date());
list.setStatus(1);
highActivityPrizeMapper.insert(list);
// 奖品类型 1:卡券 2:优惠券
if (list.getPrizeType() == 2) {
int startNum = 0;
int endNum = 0;
endNum += list.getPrizeNum();
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1()));
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId() , list.getPrizeNum());
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
if (list.getPrizeNum() > codeList.size()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, "");
}
for (HighDiscountAgentCode agentCode: codeList.subList(startNum, endNum)) {
agentCode.setStatus(5);
for (HighDiscountAgentCode agentCode: codeList) {
actualPrize = new HighActivityAwardActualPrize();
actualPrize.setActivityAwardPrizeId(list.getId());
actualPrize.setActivityAwardSerialNumId(serialNum.getId());
@ -92,10 +119,15 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
actualPrize.setActualPrizeId(agentCode.getId());
actualPrize.setStatus(1);
actualPrize.setCreateTime(new Date());
highActivityAwardActualPrizeM.insert(actualPrize);
highDiscountAgentCodeService.updateCode(agentCode);
}
startNum += list.getPrizeNum();
}
}
}

@ -92,12 +92,11 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
}
@Override
public List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId , Integer num) {
public List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();
HighDiscountAgentCodeExample.Criteria criteria = example.createCriteria();
criteria.andDiscountAgentIdEqualTo(discountAgentId).andStatusEqualTo(1);
example.setLimit(num);
example.setOrderByClause("create_time desc");
return highDiscountAgentCodeMapper.selectByExample(example);
}

Loading…
Cancel
Save