提交赠券流程代码

dev-discount
袁野 3 years ago
parent 8dc5084dd8
commit aed5235578
  1. 37
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java
  3. 6
      hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java
  4. 1
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  5. 26
      hai-service/src/main/java/com/hai/service/HighDiscountInventoryRecordService.java
  6. 49
      hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java
  7. 47
      hai-service/src/main/java/com/hai/service/HighDiscountPackageDiscountActualService.java
  8. 1
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  9. 34
      hai-service/src/main/java/com/hai/service/impl/HighDiscountInventoryRecordServiceImpl.java
  10. 48
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java
  11. 45
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageDiscountActualServiceImpl.java
  12. 39
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
  13. 58
      hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java

@ -12,10 +12,7 @@ import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponService; import com.hai.service.*;
import com.hai.service.HighDiscountPackageDetailsService;
import com.hai.service.HighDiscountPackageService;
import com.hai.service.HighDiscountService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -55,6 +52,8 @@ public class HighDiscountPackageController {
@Resource @Resource
private HighDiscountService highDiscountService; private HighDiscountService highDiscountService;
@Resource
private HighDiscountInventoryRecordService discountInventoryRecordService;
@RequestMapping(value = "/getDiscountPackageList", method = RequestMethod.GET) @RequestMapping(value = "/getDiscountPackageList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -421,6 +420,11 @@ public class HighDiscountPackageController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
} }
if (highDiscountPackage.getSurplusStock() == null || highDiscountPackage.getSurplusStock() == 0 ) {
log.error("highCouponPackage -> upDiscountPackage() error!","当前库存不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前库存不足");
}
highDiscountPackage.setStatus(1); highDiscountPackage.setStatus(1);
highDiscountPackage.setUpdatedTime(new Date()); highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
@ -539,4 +543,29 @@ public class HighDiscountPackageController {
} }
} }
@RequestMapping(value = "/getDiscountInventoryRecordServList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取优惠券包记录列表")
public ResponseData getDiscountInventoryRecordServList(
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
Map<String,Object> map = new HashMap<>();
map.put("companyId", userInfoModel.getBsCompany().getId());
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(discountInventoryRecordService.getDiscountInventoryRecordServList(map)));
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -46,7 +46,7 @@ public class HighOpenApiController {
@RequestMapping(value = "/getUserOrderPreList", method = RequestMethod.GET) @RequestMapping(value = "/getUserOrderPreList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取用户预约订单") @ApiOperation(value = "获取专属优惠券")
public ResponseData getUserOrderPreList(@RequestParam(name = "usingAttribution", required = false) Integer usingAttribution, public ResponseData getUserOrderPreList(@RequestParam(name = "usingAttribution", required = false) Integer usingAttribution,
@RequestParam(name = "phone", required = true) String phone, @RequestParam(name = "phone", required = true) String phone,
@RequestParam(name = "year", required = false) String year) { @RequestParam(name = "year", required = false) String year) {

@ -165,10 +165,10 @@ public class HighUserDiscountController {
} }
} }
@RequestMapping(value = "/getUserOrderPreList", method = RequestMethod.GET) @RequestMapping(value = "/getUserExclusiveDiscount", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取用户预约订单") @ApiOperation(value = "获取用户专属优惠券")
public ResponseData getUserOrderPreList(@RequestParam(name = "usingAttribution", required = false) Integer usingAttribution, public ResponseData getUserExclusiveDiscount(@RequestParam(name = "usingAttribution", required = false) Integer usingAttribution,
@RequestParam(name = "year", required = false) String year, @RequestParam(name = "year", required = false) String year,
HttpServletRequest request) { HttpServletRequest request) {
try { try {

@ -72,6 +72,7 @@ public interface HighDiscountAgentCodeService {
/** /**
* 查询已分配的优惠券总数 * 查询已分配的优惠券总数
* @param discountAgentId * @param discountAgentId

@ -0,0 +1,26 @@
package com.hai.service;
import com.hai.entity.HighDiscountInventoryRecord;
import java.util.List;
import java.util.Map;
/**
* @serviceName HighDiscountInventoryRecordService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 优惠券包库存记录接口
* @createTime 4:35 下午 2021/12/8
**/
public interface HighDiscountInventoryRecordService {
/**
* @Author Sum1Dream
* @name getDiscountInventoryRecordServList.java
* @Description //查询优惠券包库存记录列表
* @Date 4:36 下午 2021/12/8
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.util.List<com.hai.entity.HighDiscountInventoryRecord>
*/
List<HighDiscountInventoryRecord> getDiscountInventoryRecordServList(Map<String , Object> map);
}

@ -0,0 +1,49 @@
package com.hai.service;
import com.hai.entity.HighDiscountPackageActual;
import java.util.List;
import java.util.Map;
/**
* @serviceName HighDiscountPackageActualService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 优惠券包实际库存接口
* @createTime 3:02 下午 2021/12/8
**/
public interface HighDiscountPackageActualService {
/**
* @Author Sum1Dream
* @name insertHighDiscountPackageActual.java
* @Description // 新增优惠券包实际库存
* @Date 3:03 下午 2021/12/8
* @Param [com.hai.entity.HighDiscountPackageActual]
* @return void
*/
void insertHighDiscountPackageActual(HighDiscountPackageActual highDiscountPackageActual);
/**
* @Author Sum1Dream
* @name updateHighDiscountPackageActual.java
* @Description // 修改优惠券包实际库存
* @Date 3:04 下午 2021/12/8
* @Param [com.hai.entity.HighDiscountPackageActual]
* @return void
*/
void updateHighDiscountPackageActual(HighDiscountPackageActual highDiscountPackageActual);
/**
* @Author Sum1Dream
* @name getHighDiscountPackageActualList.java
* @Description // 查询优惠券包列表;
* @Date 3:05 下午 2021/12/8
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.util.List<com.hai.entity.HighDiscountPackageActual>
*/
List<HighDiscountPackageActual> getHighDiscountPackageActualList(Integer discountPackageId);
}

@ -0,0 +1,47 @@
package com.hai.service;
import com.hai.entity.HighDiscountPackageDiscountActual;
import java.util.List;
/**
* @serviceName HighDiscountPackageDiscountActualService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 优惠券包实际库存优惠券实际
* @createTime 3:13 下午 2021/12/8
**/
public interface HighDiscountPackageDiscountActualService {
/**
* @Author Sum1Dream
* @name insertHighDiscountPackageDiscountActual.java
* @Description // 新增优惠券包实际库存
* @Date 3:03 下午 2021/12/8
* @Param [com.hai.entity.HighDiscountPackageDiscountActual]
* @return void
*/
void insertHighDiscountPackageDiscountActual(HighDiscountPackageDiscountActual highDiscountPackageDiscountActual);
/**
* @Author Sum1Dream
* @name updateHighDiscountPackageDiscountActual.java
* @Description // 修改优惠券包实际库存
* @Date 3:04 下午 2021/12/8
* @Param [com.hai.entity.HighDiscountPackageDiscountActual]
* @return void
*/
void updateHighDiscountPackageDiscountActual(HighDiscountPackageDiscountActual highDiscountPackageDiscountActual);
/**
* @Author Sum1Dream
* @name getHighDiscountPackageDiscountActualList.java
* @Description // 查询优惠券包列表;
* @Date 3:05 下午 2021/12/8
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.util.List<com.hai.entity.HighDiscountPackageDiscountActual>
*/
List<HighDiscountPackageDiscountActual> getHighDiscountPackageDiscountActualList(Integer discountPackageActualId);
}

@ -115,6 +115,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
return highDiscountAgentCodeMapper.selectByPrimaryKey(id); return highDiscountAgentCodeMapper.selectByPrimaryKey(id);
} }
@Override @Override
public Integer getTotalDiscount(Long discountAgentId) { public Integer getTotalDiscount(Long discountAgentId) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample(); HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();

@ -0,0 +1,34 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountInventoryRecordMapper;
import com.hai.entity.HighDiscountInventoryRecord;
import com.hai.entity.HighDiscountInventoryRecordExample;
import com.hai.service.HighDiscountInventoryRecordService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("highDiscountInventoryRecordService")
public class HighDiscountInventoryRecordServiceImpl implements HighDiscountInventoryRecordService {
@Resource
private HighDiscountInventoryRecordMapper discountInventoryRecordMapper;
@Override
public List<HighDiscountInventoryRecord> getDiscountInventoryRecordServList(Map<String, Object> map) {
HighDiscountInventoryRecordExample example = new HighDiscountInventoryRecordExample();
HighDiscountInventoryRecordExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getInteger(map , "companyId"));
}
example.setOrderByClause("created_time");
return discountInventoryRecordMapper.selectByExample(example);
}
}

@ -0,0 +1,48 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountPackageActualMapper;
import com.hai.dao.HighDiscountPackageDiscountActualMapper;
import com.hai.entity.HighDiscountPackageActual;
import com.hai.entity.HighDiscountPackageActualExample;
import com.hai.service.HighDiscountPackageActualService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @serviceName HighDiscountPackageActualServiceImpl.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 优惠券包实际库存
* @createTime 3:06 下午 2021/12/8
**/
@Service("highDiscountPackageActualService")
public class HighDiscountPackageActualServiceImpl implements HighDiscountPackageActualService {
@Resource
private HighDiscountPackageActualMapper discountPackageActualMapper;
@Override
public void insertHighDiscountPackageActual(HighDiscountPackageActual highDiscountPackageActual) {
discountPackageActualMapper.insert(highDiscountPackageActual);
}
@Override
public void updateHighDiscountPackageActual(HighDiscountPackageActual highDiscountPackageActual) {
discountPackageActualMapper.updateByPrimaryKey(highDiscountPackageActual);
}
@Override
public List<HighDiscountPackageActual> getHighDiscountPackageActualList(Integer discountPackageId) {
HighDiscountPackageActualExample example = new HighDiscountPackageActualExample();
HighDiscountPackageActualExample.Criteria criteria = example.createCriteria();
criteria.andDiscountPackageIdEqualTo(discountPackageId).andStatusEqualTo(1);
return discountPackageActualMapper.selectByExample(example);
}
}

@ -0,0 +1,45 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountPackageDiscountActualMapper;
import com.hai.entity.HighDiscountPackageDiscountActual;
import com.hai.entity.HighDiscountPackageDiscountActualExample;
import com.hai.service.HighDiscountPackageDiscountActualService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @serviceName HighDiscountPackageDiscountActualServiceImpl.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 优惠券包实际库存优惠券实际接口
* @createTime 3:15 下午 2021/12/8
**/
@Service("highDiscountPackageDiscountActualService")
public class HighDiscountPackageDiscountActualServiceImpl implements HighDiscountPackageDiscountActualService {
@Resource
private HighDiscountPackageDiscountActualMapper discountPackageDiscountActualMapper;
@Override
public void insertHighDiscountPackageDiscountActual(HighDiscountPackageDiscountActual highDiscountPackageDiscountActual) {
discountPackageDiscountActualMapper.insert(highDiscountPackageDiscountActual);
}
@Override
public void updateHighDiscountPackageDiscountActual(HighDiscountPackageDiscountActual highDiscountPackageDiscountActual) {
discountPackageDiscountActualMapper.updateByPrimaryKey(highDiscountPackageDiscountActual);
}
@Override
public List<HighDiscountPackageDiscountActual> getHighDiscountPackageDiscountActualList(Integer discountPackageActualId) {
HighDiscountPackageDiscountActualExample example = new HighDiscountPackageDiscountActualExample();
HighDiscountPackageDiscountActualExample.Criteria criteria = example.createCriteria();
criteria.andDiscountPackageActualIdEqualTo(discountPackageActualId).andStatusEqualTo(1);
return discountPackageDiscountActualMapper.selectByExample(example);
}
}

@ -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.dao.*; import com.hai.dao.*;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
@ -40,15 +43,15 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
@Resource @Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService; private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighDiscountInventoryRecordMapper highDiscountInventoryRecordMapper;
@Resource @Resource
private HighDiscountPackageActualMapper discountPackageActualMapper; private HighDiscountPackageActualMapper discountPackageActualMapper;
@Resource @Resource
private HighDiscountPackageDiscountActualMapper discountPackageDiscountActualMapper; private HighDiscountPackageDiscountActualMapper discountPackageDiscountActualMapper;
@Resource
private HighDiscountInventoryRecordMapper discountInventoryRecordMapper;
@Override @Override
public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) { public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) {
@ -166,6 +169,10 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue(), detailsList.getAgentId()); HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue(), detailsList.getAgentId());
List<HighDiscountAgentCode> discountAgentCodeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1); List<HighDiscountAgentCode> discountAgentCodeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1);
if (discountAgentCodeList.size() < detailsList.getNum()) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , detailsList.getDiscountName() +"优惠券库存不足");
}
// 赠送优惠券 // 赠送优惠券
for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList.subList(0, detailsList.getNum())) { for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList.subList(0, detailsList.getNum())) {
HighDiscountPackageDiscountActual discountPackageDiscountActual = new HighDiscountPackageDiscountActual(); HighDiscountPackageDiscountActual discountPackageDiscountActual = new HighDiscountPackageDiscountActual();
@ -175,6 +182,8 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
discountPackageDiscountActual.setCreatedTime(new Date()); discountPackageDiscountActual.setCreatedTime(new Date());
discountPackageDiscountActual.setAgentDiscountCodeId(discountAgentCode.getId()); discountPackageDiscountActual.setAgentDiscountCodeId(discountAgentCode.getId());
discountPackageDiscountActual.setStatus(1); discountPackageDiscountActual.setStatus(1);
discountPackageDiscountActual.setDiscountId(detailsList.getDiscountId().longValue());
discountPackageDiscountActual.setAgentId(detailsList.getAgentId());
discountPackageDiscountActualMapper.insert(discountPackageDiscountActual); discountPackageDiscountActualMapper.insert(discountPackageDiscountActual);
// 修改优惠券二维码状态 // 修改优惠券二维码状态
@ -186,7 +195,27 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
} }
} }
highDiscountPackage.setTotalStock(num); // 设置库存
highDiscountPackage.setSurplusStock(highDiscountPackage.getSurplusStock() + num); int surplusStock = highDiscountPackage.getSurplusStock() == null ? 0 :highDiscountPackage.getSurplusStock();
int totalStock = highDiscountPackage.getTotalStock() == null ? 0 :highDiscountPackage.getTotalStock();
// 新增补库记录
HighDiscountInventoryRecord discountInventoryRecord = new HighDiscountInventoryRecord();
discountInventoryRecord.setDiscountPackageId(highDiscountPackage.getId());
discountInventoryRecord.setDiscountPackageTitle(highDiscountPackage.getTitle());
discountInventoryRecord.setCreatedUserId(userInfoModel.getSecUser().getId().intValue());
discountInventoryRecord.setCompanyId(userInfoModel.getBsCompany().getId().intValue());
discountInventoryRecord.setCreatedTime(new Date());
discountInventoryRecord.setStatus(1);
discountInventoryRecord.setStockNum(num);
discountInventoryRecord.setFrontStockNum(highDiscountPackage.getSurplusStock());
discountInventoryRecord.setNowStockNum(surplusStock + num);
discountInventoryRecordMapper.insert(discountInventoryRecord);
// 设置库存
highDiscountPackage.setSurplusStock(surplusStock + num);
highDiscountPackage.setTotalStock(totalStock + num);
highDiscountPackageMapper.updateByPrimaryKey(highDiscountPackage);
} }
} }

@ -9,6 +9,8 @@ import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator; import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.dao.HighDiscountPackageActualMapper;
import com.hai.dao.HighDiscountPackageDiscountActualMapper;
import com.hai.dao.HighDiscountPackageRecordMapper; import com.hai.dao.HighDiscountPackageRecordMapper;
import com.hai.dao.HighDiscountUserRelMapper; import com.hai.dao.HighDiscountUserRelMapper;
import com.hai.entity.*; import com.hai.entity.*;
@ -54,9 +56,15 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService {
@Resource @Resource
private HighDiscountService highDiscountService; private HighDiscountService highDiscountService;
@Resource
private HighDiscountPackageActualService discountPackageActualService;
@Resource
private HighDiscountPackageDiscountActualService discountPackageDiscountActualService;
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) @Transactional(propagation= Propagation.REQUIRES_NEW)
public JSONObject GetMembershipLevel(String phone , String regionId) throws Exception { public JSONObject GetMembershipLevel(String phone , String regionId) throws Exception {
SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId)); SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
@ -107,41 +115,33 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService {
HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0); HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0);
Map<String , Object> mapRule = new HashMap<>(); highDiscountPackage.setSurplusStock(highDiscountPackage.getSurplusStock() - 1);
mapRule.put("discountPackageId", highDiscountPackage.getId()); highDiscountPackageService.updateDiscountPackage(highDiscountPackage);
// 查询优惠券包规则
List<HighDiscountPackageDetails> discountPackageDetailsList = highDiscountPackageDetailsService.getDiscountPackageDetailsList(mapRule);
// 循环 优惠券包规则详情 列表 // 查询优惠券包实际库存
for (HighDiscountPackageDetails detailsList: discountPackageDetailsList) { HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0);
// 查询代理商与优惠券关系 列表 // 修改优惠券包实际库存状态
List<HighDiscountAgentRel> discountAgentRels = highDiscountAgentRelService.getRelByDiscountId(detailsList.getDiscountId().longValue()); discountPackageActual.setStatus(0);
discountPackageActual.setUserId(highUser.getId().intValue());
discountPackageActual.setAllocationTime(new Date());
discountPackageActualService.updateHighDiscountPackageActual(discountPackageActual);
HighDiscountAgentRel discountAgentRel = new HighDiscountAgentRel(); // 查询优惠券包实际库存中实际优惠券数量
List<HighDiscountPackageDiscountActual> discountPackageDiscountActual = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(discountPackageActual.getId());
for (HighDiscountAgentRel discountAgentRelList: discountAgentRels) { // 循环赠送优惠券
// 判断当前是否足够库存赠送 for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) {
if (discountAgentRelList.getStockCount() > detailsList.getNum()) {
discountAgentRel = discountAgentRelList;
break;
}
}
List<HighDiscountAgentCode> discountAgentCodeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
// 赠送优惠券
for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList.subList(0, detailsList.getNum())) {
HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel();
highDiscountUserRel.setDiscountId(discountAgentRel.getDiscountId()); highDiscountUserRel.setDiscountId(actualList.getDiscountId());
highDiscountUserRel.setUserId(highUser.getId()); highDiscountUserRel.setUserId(highUser.getId());
highDiscountUserRel.setAgentId(discountAgentRel.getAgentId()); highDiscountUserRel.setAgentId(actualList.getAgentId());
highDiscountUserRel.setDiscountAgentCodeId(discountAgentCode.getId()); highDiscountUserRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId());
highDiscountUserRel.setStatus(1); highDiscountUserRel.setStatus(1);
highDiscountUserRel.setCreateTime(new Date()); highDiscountUserRel.setCreateTime(new Date());
HighDiscount highDiscount = highDiscountService.getDiscountById(discountAgentRel.getDiscountId()); HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.getDiscountId());
// 计算使用有效期 // 计算使用有效期
Calendar userEndTime = Calendar.getInstance(); Calendar userEndTime = Calendar.getInstance();
@ -152,14 +152,18 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService {
userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay()); userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay());
highDiscountUserRel.setUseEndTime(userEndTime.getTime()); highDiscountUserRel.setUseEndTime(userEndTime.getTime());
HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId());
// 修改优惠券二维码状态 // 修改优惠券二维码状态
discountAgentCode.setStatus(2); discountAgentCode.setStatus(2);
highDiscountAgentCodeService.updateCode(discountAgentCode); highDiscountAgentCodeService.updateCode(discountAgentCode);
// 新增优惠券与用户的绑定关系 // 新增优惠券与用户的绑定关系
highDiscountUserRelMapper.insert(highDiscountUserRel); highDiscountUserRelMapper.insert(highDiscountUserRel);
}
// 修改优惠券包实际库存实际优惠券状态
actualList.setStatus(0);
discountPackageDiscountActualService.updateHighDiscountPackageDiscountActual(actualList);
} }
// 增加赠送记录 // 增加赠送记录

Loading…
Cancel
Save