'提交代码'

dev-discount
199901012 4 years ago
parent 5620edca7d
commit 42c3ccfc49
  1. 66
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  2. 2
      hai-service/src/main/java/com/hai/common/exception/ErrorCode.java
  3. 8
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  4. 12
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java

@ -1,5 +1,6 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -16,6 +17,7 @@ import com.hai.model.HighCouponModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighApproveService;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.HighMerchantService;
import io.swagger.annotations.Api;
@ -54,6 +56,9 @@ public class HighCouponController {
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighApproveService highApproveService;
@ -118,7 +123,6 @@ public class HighCouponController {
}
}
@RequestMapping(value="/updateCoupon",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改卡卷")
@ -206,6 +210,12 @@ public class HighCouponController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_UNABLE_UP_SHELF, "");
}
// 根据卡卷查询 销售码库存
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) {
log.error("HighCouponController -> upShelfApprove() error!","卡卷库存数量错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_ERROR, "");
}
HighApprove approve = new HighApprove();
approve.setObjectType(ApproveType.UP_SHELF_APPROVE.getType());
approve.setObjectId(id);
@ -282,4 +292,58 @@ public class HighCouponController {
}
}
@RequestMapping(value="/importStock",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "导入卡卷库存(外部卷)")
public ResponseData importStock(@RequestParam(name = "couponId", required = true) Long couponId) {
try {
Map<String, Object> map = new HashMap<>();
return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map)));
} catch (Exception e) {
log.error("HighCouponController -> getCouponList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/writeStock",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "填写卡卷库存(内部劵)")
public ResponseData writeStock(@RequestBody String reqBody, HttpServletRequest request){
try {
JSONObject jsonObject = JSONObject.parseObject(reqBody);
Long couponId = jsonObject.getLong("couponId");
Long salesEndTime = jsonObject.getLong("salesEndTime");
Long useEndTime = jsonObject.getLong("useEndTime");
Integer generateNum = jsonObject.getInteger("generateNum");
if(couponId == null || salesEndTime == null || useEndTime == null || generateNum == null) {
log.error("HighCouponController -> writeStock() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查找商户
HighCouponModel coupon = highCouponService.getCouponById(couponId);
if (coupon == null) {
log.error("HighCouponController -> insertCoupon() error!","未找到商户");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, "");
}
if (coupon.getCouponType() != 1) {
log.error("HighCouponController -> insertCoupon() error!","卡卷类型错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_TYPE_ERROR, "");
}
highCouponCodeService.generateCode(couponId, new Date(salesEndTime), new Date(useEndTime),generateNum);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighCouponController -> getCouponList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -85,6 +85,8 @@ public enum ErrorCode {
COUPON_UNABLE_UP_SHELF("2113","卡卷状态错误"),
NOT_FOUND_APPROVE("2114","未找到审批记录"),
APPROVE_PROCESSED("2115","审批已处理"),
COUPON_STOCK_ERROR("2116","卡卷库存数量错误"),
COUPON_TYPE_ERROR("2117","卡卷类型错误"),
STATUS_ERROR("3000","状态错误"),
ADD_DATA_ERROR("3001","增加数据失败"),

@ -3,6 +3,7 @@ package com.hai.service;
import com.hai.entity.HighCouponCode;
import com.hai.model.HighCouponCodeModel;
import java.util.Date;
import java.util.List;
/**
@ -19,6 +20,13 @@ public interface HighCouponCodeService {
**/
void insertCouponCode(HighCouponCode highCouponCode);
/**
* @Author 胡锐
* @Description 生成销售码 数量
* @Date 2021/3/17 20:47
**/
void generateCode(Long couponId, Date salesEndTime, Date useEndTime, Integer generateNum);
/**
*
* @Title: getStockCountByCoupon

@ -25,6 +25,18 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
highCouponCodeMapper.insert(highCouponCode);
}
@Override
public void generateCode(Long couponId, Date salesEndTime, Date useEndTime, Integer generateNum) {
HighCouponCode highCouponCode;
for (int i = 0; i < generateNum;i++) {
highCouponCode = new HighCouponCode();
highCouponCode.setCouponId(couponId);
highCouponCode.setSalesEndTime(salesEndTime);
highCouponCode.setUseEndTime(useEndTime);
highCouponCode.setCreateTime(new Date());
}
}
@Override
public Integer getStockCountByCoupon(Long couponId) {
HighCouponCodeExample example = new HighCouponCodeExample();

Loading…
Cancel
Save