dev-discount
袁野 3 years ago
parent d4c710a01f
commit 25435d859b
  1. 11
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  2. 8
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  3. 37
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java

@ -1,6 +1,7 @@
package com.hai.service;
import com.hai.entity.HighDiscountAgentCode;
import io.swagger.models.auth.In;
import java.util.List;
import java.util.Map;
@ -51,6 +52,16 @@ public interface HighDiscountAgentCodeService {
**/
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId);
/**
* @Author Sum1Dream
* @name getDiscountCodeByDiscountAgentId.java
* @Description // 根据关系id 查询 未领取的卡券
* @Date 14:20 2021/9/29
* @Param [discountAgentId]
* @return java.util.List<com.hai.entity.HighDiscountAgentCode>
**/
List<HighDiscountAgentCode> getDiscountCodeByStatus(Long discountAgentId , Integer status);
/**
* @Author 胡锐

@ -101,6 +101,14 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
return highDiscountAgentCodeMapper.selectByExample(example);
}
@Override
public List<HighDiscountAgentCode> getDiscountCodeByStatus(Long discountAgentId, Integer status) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();
HighDiscountAgentCodeExample.Criteria criteria = example.createCriteria();
criteria.andDiscountAgentIdEqualTo(discountAgentId).andStatusEqualTo(status);
example.setOrderByClause("create_time desc");
return highDiscountAgentCodeMapper.selectByExample(example);
}
@Override
public HighDiscountAgentCode getCodeById(Long id) {

@ -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);
}
}

Loading…
Cancel
Save