dev-discount
胡锐 3 years ago
commit 8dc5084dd8
  1. 44
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java
  2. 11
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  3. 12
      hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java
  4. 8
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  5. 87
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
  6. 2
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java

@ -165,6 +165,8 @@ public class HighDiscountPackageController {
highDiscountPackage.setCreatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackage.setTotalStock(0);
highDiscountPackage.setSurplusStock(0);
highDiscountPackageService.insertDiscountPackage(highDiscountPackage);
@ -376,7 +378,7 @@ public class HighDiscountPackageController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId"));
if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
@ -412,7 +414,7 @@ public class HighDiscountPackageController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId"));
if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1 ) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
@ -448,7 +450,7 @@ public class HighDiscountPackageController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId"));
if (highDiscountPackage == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
@ -501,4 +503,40 @@ public class HighDiscountPackageController {
}
}
@RequestMapping(value="/addDiscountPackageStock",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加优惠券包库存")
public ResponseData addDiscountPackageStock(@RequestBody JSONObject object, HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId"));
if (highDiscountPackage == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","当前优惠券包不存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "");
}
if (object.getInteger("num") == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","请传入库存数量");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "");
}
highDiscountPackageService.addDiscountPackageStock(highDiscountPackage , userInfoModel , object.getInteger("num"));
return ResponseMsgUtil.success("增加库存成功");
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -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 胡锐

@ -3,8 +3,10 @@ package com.hai.service;
import com.hai.entity.HighDiscount;
import com.hai.entity.HighDiscountPackage;
import com.hai.entity.HighDiscountPackageRecord;
import com.hai.model.UserInfoModel;
import io.swagger.models.auth.In;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@ -77,5 +79,15 @@ public interface HighDiscountPackageService {
*/
List<HighDiscountPackageRecord> getDiscountPackageRecordList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @name addDiscountPackageStock.java
* @Description // 新增优惠券包库存
* @Date 11:32 上午 2021/12/7
* @Param [com.hai.entity.HighDiscountPackage]
* @return void
*/
void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num);
}

@ -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) {

@ -1,16 +1,19 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountPackageMapper;
import com.hai.dao.HighDiscountPackageRecordMapper;
import com.hai.dao.*;
import com.hai.entity.*;
import com.hai.service.HighDiscountPackageService;
import com.hai.model.UserInfoModel;
import com.hai.service.*;
import com.hai.service.HighDiscountPackageService;
import org.apache.commons.collections4.MapUtils;
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 java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @serviceName HighDiscountPackageServiceImpl.java
@ -28,6 +31,24 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
@Resource
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
public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) {
@ -67,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);
}
@ -116,4 +138,55 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
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);
}
}

@ -34,7 +34,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
OutRechargePriceExample example = new OutRechargePriceExample();
OutRechargePriceExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(1);
criteria.andStatusNotEqualTo(0);
if (StringUtils.isNotBlank(map.get("type"))) {
criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));

Loading…
Cancel
Save