|
|
|
@ -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,28 +91,43 @@ 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); |
|
|
|
|
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1())); |
|
|
|
|
|
|
|
|
|
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId() , list.getPrizeNum()); |
|
|
|
|
|
|
|
|
|
for (HighDiscountAgentCode agentCode: codeList) { |
|
|
|
|
actualPrize = new HighActivityAwardActualPrize(); |
|
|
|
|
actualPrize.setActivityAwardPrizeId(list.getId()); |
|
|
|
|
actualPrize.setActivityAwardSerialNumId(serialNum.getId()); |
|
|
|
|
actualPrize.setActualPrizeType(2); |
|
|
|
|
actualPrize.setActualPrizeId(agentCode.getId()); |
|
|
|
|
actualPrize.setStatus(1); |
|
|
|
|
actualPrize.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 奖品类型 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()); |
|
|
|
|
|
|
|
|
|
if (list.getPrizeNum() > codeList.size()) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (HighDiscountAgentCode agentCode: codeList.subList(startNum, endNum)) { |
|
|
|
|
|
|
|
|
|
agentCode.setStatus(5); |
|
|
|
|
|
|
|
|
|
actualPrize = new HighActivityAwardActualPrize(); |
|
|
|
|
actualPrize.setActivityAwardPrizeId(list.getId()); |
|
|
|
|
actualPrize.setActivityAwardSerialNumId(serialNum.getId()); |
|
|
|
|
actualPrize.setActualPrizeType(2); |
|
|
|
|
actualPrize.setActualPrizeId(agentCode.getId()); |
|
|
|
|
actualPrize.setStatus(1); |
|
|
|
|
actualPrize.setCreateTime(new Date()); |
|
|
|
|
highActivityAwardActualPrizeM.insert(actualPrize); |
|
|
|
|
highDiscountAgentCodeService.updateCode(agentCode); |
|
|
|
|
} |
|
|
|
|
startNum += list.getPrizeNum(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|