|
|
@ -1,16 +1,19 @@ |
|
|
|
package com.hai.service.impl; |
|
|
|
package com.hai.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.hai.dao.HighDiscountPackageMapper; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.dao.HighDiscountPackageRecordMapper; |
|
|
|
|
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.service.HighDiscountPackageService; |
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
|
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.HighDiscountPackageService; |
|
|
|
import com.hai.service.HighDiscountPackageService; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Isolation; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.List; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @serviceName HighDiscountPackageServiceImpl.java |
|
|
|
* @serviceName HighDiscountPackageServiceImpl.java |
|
|
@ -28,6 +31,24 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper; |
|
|
|
private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountPackageDetailsService highDiscountPackageDetailsService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountAgentRelService highDiscountAgentRelService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountInventoryRecordMapper highDiscountInventoryRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountPackageActualMapper discountPackageActualMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountPackageDiscountActualMapper discountPackageDiscountActualMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) { |
|
|
|
public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) { |
|
|
|
|
|
|
|
|
|
|
@ -67,10 +88,11 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public HighDiscountPackage getCallExclusive(Integer usingAttribution , Integer companyId) { |
|
|
|
public HighDiscountPackage getCallExclusive(Integer usingAttribution, Integer companyId) { |
|
|
|
HighDiscountPackageExample example = new HighDiscountPackageExample(); |
|
|
|
HighDiscountPackageExample example = new HighDiscountPackageExample(); |
|
|
|
HighDiscountPackageExample.Criteria criteria = example.createCriteria(); |
|
|
|
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); |
|
|
|
return highDiscountPackageMapper.selectByExample(example).get(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,4 +138,55 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
|
|
|
|
|
|
|
|
return highDiscountPackageRecordMapper.selectByExample(example); |
|
|
|
return highDiscountPackageRecordMapper.selectByExample(example); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel, Integer num) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapRule = new HashMap<>(); |
|
|
|
|
|
|
|
mapRule.put("discountPackageId", highDiscountPackage.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询优惠券包规则
|
|
|
|
|
|
|
|
List<HighDiscountPackageDetails> discountPackageDetailsList = highDiscountPackageDetailsService.getDiscountPackageDetailsList(mapRule); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成优惠券包实际库存实体
|
|
|
|
|
|
|
|
HighDiscountPackageActual discountPackageActual = new HighDiscountPackageActual(); |
|
|
|
|
|
|
|
discountPackageActual.setDiscountPackageId(highDiscountPackage.getId()); |
|
|
|
|
|
|
|
discountPackageActual.setCreatedUserId(userInfoModel.getSecUser().getId().intValue()); |
|
|
|
|
|
|
|
// 状态: 1: 待分配 2:预分配(售卖)3:已分配
|
|
|
|
|
|
|
|
discountPackageActual.setStatus(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < num; i++) { |
|
|
|
|
|
|
|
discountPackageActual.setCreatedTime(new Date()); |
|
|
|
|
|
|
|
discountPackageActualMapper.insert(discountPackageActual); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 循环 优惠券包规则详情 列表
|
|
|
|
|
|
|
|
for (HighDiscountPackageDetails detailsList : discountPackageDetailsList) { |
|
|
|
|
|
|
|
// 查询代理商与优惠券关系 列表
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|