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