|
|
|
@ -88,10 +88,11 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HighDiscountPackage getCallExclusive(Integer usingAttribution , Integer companyId) { |
|
|
|
|
public HighDiscountPackage getCallExclusive(Integer usingAttribution, Integer companyId) { |
|
|
|
|
HighDiscountPackageExample example = new HighDiscountPackageExample(); |
|
|
|
|
HighDiscountPackageExample.Criteria criteria = example.createCriteria(); |
|
|
|
|
criteria.andUsingAttributionEqualTo(usingAttribution).andStatusNotEqualTo(4).andCompanyIdEqualTo(companyId);; |
|
|
|
|
criteria.andUsingAttributionEqualTo(usingAttribution).andStatusNotEqualTo(4).andCompanyIdEqualTo(companyId); |
|
|
|
|
; |
|
|
|
|
return highDiscountPackageMapper.selectByExample(example).get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -139,10 +140,10 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) |
|
|
|
|
public void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num) { |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
public void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel, Integer num) { |
|
|
|
|
|
|
|
|
|
Map<String , Object> mapRule = new HashMap<>(); |
|
|
|
|
Map<String, Object> mapRule = new HashMap<>(); |
|
|
|
|
mapRule.put("discountPackageId", highDiscountPackage.getId()); |
|
|
|
|
|
|
|
|
|
// 查询优惠券包规则
|
|
|
|
@ -158,14 +159,34 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
|
for (int i = 0; i < num; i++) { |
|
|
|
|
discountPackageActual.setCreatedTime(new Date()); |
|
|
|
|
discountPackageActualMapper.insert(discountPackageActual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 循环 优惠券包规则详情 列表
|
|
|
|
|
for (HighDiscountPackageDetails detailsList: discountPackageDetailsList) { |
|
|
|
|
for (HighDiscountPackageDetails detailsList : discountPackageDetailsList) { |
|
|
|
|
// 查询代理商与优惠券关系 列表
|
|
|
|
|
List<HighDiscountAgentRel> discountAgentRels = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue() , detailsList.getAgentId()); |
|
|
|
|
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue(), detailsList.getAgentId()); |
|
|
|
|
List<HighDiscountAgentCode> discountAgentCodeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1); |
|
|
|
|
|
|
|
|
|
// 赠送优惠券
|
|
|
|
|
for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList.subList(0, detailsList.getNum())) { |
|
|
|
|
HighDiscountPackageDiscountActual discountPackageDiscountActual = new HighDiscountPackageDiscountActual(); |
|
|
|
|
discountPackageDiscountActual.setDiscountPackageId(highDiscountPackage.getId()); |
|
|
|
|
discountPackageDiscountActual.setDiscountPackageActualId(discountPackageActual.getId()); |
|
|
|
|
discountPackageDiscountActual.setCreatedUserId(userInfoModel.getSecUser().getId().intValue()); |
|
|
|
|
discountPackageDiscountActual.setCreatedTime(new Date()); |
|
|
|
|
discountPackageDiscountActual.setAgentDiscountCodeId(discountAgentCode.getId()); |
|
|
|
|
discountPackageDiscountActual.setStatus(1); |
|
|
|
|
discountPackageDiscountActualMapper.insert(discountPackageDiscountActual); |
|
|
|
|
|
|
|
|
|
// 修改优惠券二维码状态
|
|
|
|
|
discountAgentCode.setStatus(5); |
|
|
|
|
highDiscountAgentCodeService.updateCode(discountAgentCode); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highDiscountPackage.setTotalStock(num); |
|
|
|
|
highDiscountPackage.setSurplusStock(highDiscountPackage.getSurplusStock() + num); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|