|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PutMapping("/{id}") | 
|---|
|  |  |  | @ApiOperation(value = "修改", notes = "修改") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody CreateCouponTemplatePointDTO dto) { | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> update(@PathVariable String id,@Validated @RequestBody CreateCouponTemplatePointDTO dto) { | 
|---|
|  |  |  | // 信息校验 | 
|---|
|  |  |  | dto.setId(id); | 
|---|
|  |  |  | valid(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CouponTemplateDO couponTemplateDO = couponTemplateService.getById(dto.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CreateCouponTemplateBO couponTemplateBO = new CreateCouponTemplateBO(); | 
|---|
|  |  |  | BeanUtils.copyProperties(couponTemplateDO,couponTemplateBO); | 
|---|
|  |  |  | BeanUtils.copyProperties(dto, couponTemplateBO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置成积分优惠券 | 
|---|
|  |  |  | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PutMapping("/batch/expire") | 
|---|
|  |  |  | @PostMapping("/batch/expire") | 
|---|
|  |  |  | @ApiOperation(value = "批量下架", notes = "批量下架") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> expireBatch(BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> expireBatch(@RequestBody BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | couponTemplateService.expireBatchCouponTemplate(dto); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PutMapping("/batch/active") | 
|---|
|  |  |  | @PostMapping("/batch/active") | 
|---|
|  |  |  | @ApiOperation(value = "批量发布", notes = "批量发布") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> activeBatch(BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> activeBatch(@RequestBody BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | couponTemplateService.activeBatchCouponTemplate(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @DeleteMapping("/batch/del") | 
|---|
|  |  |  | @PostMapping("/batch/del") | 
|---|
|  |  |  | @ApiOperation(value = "批量删除", notes = "批量删除") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> deleteBatch(BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> deleteBatch(@RequestBody BatchCouponTemplateDTO dto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | couponTemplateService.deleteBatchCouponTemplate(dto); | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(), null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void valid(CreateCouponTemplatePointDTO dto){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(dto.getCouponDiscountType()) | 
|---|
|  |  |  | && dto.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType()) | 
|---|
|  |  |  | && dto.getMinOrderAmount().compareTo(dto.getCouponDiscountValue()) < 0) { | 
|---|
|  |  |  | throw new ValidationException("订单金额不能小于折扣金额"); | 
|---|
|  |  |  | if (StringUtils.isNotBlank(dto.getCouponDiscountType()) && dto.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(dto.getMinOrderAmount().compareTo(BigDecimal.ZERO)<=0){ | 
|---|
|  |  |  | throw new ValidationException("优惠券使用条件不能小于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dto.getMinOrderAmount().compareTo(dto.getCouponDiscountValue()) < 0){ | 
|---|
|  |  |  | throw new ValidationException("优惠券使用条件不能小于面值金额"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(dto.getCouponDiscountType()) | 
|---|
|  |  |  | && dto.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType()) | 
|---|
|  |  |  | && dto.getCouponDiscountValue().compareTo(BigDecimal.ZERO) <= 0) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/exchange") | 
|---|
|  |  |  | @ApiOperation(value = "小程序-积分优惠券兑换", notes = "小程序-积分优惠券兑换") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> exchangeCoupon(@Validated @RequestBody ExchangeCouponDTO dto) { | 
|---|
|  |  |  | couponTemplateService.exchangeCoupon(dto); | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(), null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|