|
|
|
@ -130,12 +130,130 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HighActivityAward getDetailById(Long id) { |
|
|
|
|
return highActivityAwardMapper.selectByPrimaryKey(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
public void deleteActivateAward(Long id) { |
|
|
|
|
HighActivityPrizeExample example = new HighActivityPrizeExample(); |
|
|
|
|
example.createCriteria().andActivityAwardIdEqualTo(id); |
|
|
|
|
List<HighActivityPrize> prize = highActivityPrizeMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
for (HighActivityPrize p : prize) { |
|
|
|
|
|
|
|
|
|
HighActivityAwardActualPrizeExample prizeExample = new HighActivityAwardActualPrizeExample(); |
|
|
|
|
prizeExample.createCriteria().andActivityAwardPrizeIdEqualTo(p.getId()); |
|
|
|
|
|
|
|
|
|
List<HighActivityAwardActualPrize> actualPrizeList = highActivityAwardActualPrizeM.selectByExample(prizeExample); |
|
|
|
|
|
|
|
|
|
for (HighActivityAwardActualPrize actualPrize: actualPrizeList ) { |
|
|
|
|
highActivityAwardActualPrizeM.deleteByPrimaryKey(actualPrize.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highActivityPrizeMapper.deleteByPrimaryKey(p.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighActivityAwardSerialNumExample numExample = new HighActivityAwardSerialNumExample(); |
|
|
|
|
numExample.createCriteria().andActivityAwardIdEqualTo(id); |
|
|
|
|
|
|
|
|
|
List<HighActivityAwardSerialNum> serialNumList = highActivityAwardSerialNumM.selectByExample(numExample); |
|
|
|
|
|
|
|
|
|
for (HighActivityAwardSerialNum serialNum: serialNumList) { |
|
|
|
|
|
|
|
|
|
highActivityAwardSerialNumM.deleteByPrimaryKey(serialNum.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highActivityAwardMapper.deleteByPrimaryKey(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighActivityAward> checkNumberPrizes(Long id) { |
|
|
|
|
|
|
|
|
|
HighActivityAwardExample example = new HighActivityAwardExample(); |
|
|
|
|
example.createCriteria().andActivityInfoIdEqualTo(id); |
|
|
|
|
|
|
|
|
|
List<HighActivityAward> activityAwardList = highActivityAwardMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
for (HighActivityAward activityAward : activityAwardList) { |
|
|
|
|
HighActivityAwardSerialNumExample numExample = new HighActivityAwardSerialNumExample(); |
|
|
|
|
numExample.createCriteria().andActivityAwardIdEqualTo(activityAward.getId()).andStatusEqualTo(1); |
|
|
|
|
activityAward.setExt3(String.valueOf(highActivityAwardSerialNumM.countByExample(numExample))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return activityAwardList; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
public void numberOfNewRewards(Long activityAwardId , Integer num) throws Exception { |
|
|
|
|
|
|
|
|
|
HighActivityAward highActivityAward = highActivityAwardMapper.selectByPrimaryKey(activityAwardId); |
|
|
|
|
|
|
|
|
|
HighActivityAwardSerialNum serialNum; |
|
|
|
|
HighActivityAwardActualPrize actualPrize; |
|
|
|
|
|
|
|
|
|
HighActivityPrizeExample prizeExample = new HighActivityPrizeExample(); |
|
|
|
|
prizeExample.createCriteria().andActivityAwardIdEqualTo(activityAwardId); |
|
|
|
|
|
|
|
|
|
List<HighActivityPrize> highActivityPrizes = highActivityPrizeMapper.selectByExample(prizeExample); |
|
|
|
|
|
|
|
|
|
highActivityAward.setNum(highActivityAward.getNum() + num); |
|
|
|
|
|
|
|
|
|
highActivityAwardMapper.updateByPrimaryKey(highActivityAward); |
|
|
|
|
|
|
|
|
|
// 生成中奖编号
|
|
|
|
|
for (int i = 0; i < num; i++) { |
|
|
|
|
serialNum = new HighActivityAwardSerialNum(); |
|
|
|
|
serialNum.setActivityInfoId(highActivityAward.getActivityInfoId()); |
|
|
|
|
serialNum.setActivityAwardId(highActivityAward.getId()); |
|
|
|
|
serialNum.setSerialNum("HFA" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
serialNum.setStatus(1); |
|
|
|
|
serialNum.setCreateTime(new Date()); |
|
|
|
|
highActivityAwardSerialNumM.insert(serialNum); |
|
|
|
|
|
|
|
|
|
// 循环奖品
|
|
|
|
|
for (HighActivityPrize list : highActivityPrizes) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 奖品类型 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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|