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