| | |
| | | import com.mzl.flower.dto.request.coupon.QueryCouponRecordDTO; |
| | | import com.mzl.flower.dto.response.coupon.CouponRecordResultVO; |
| | | import com.mzl.flower.dto.response.coupon.CouponRecordVO; |
| | | import com.mzl.flower.dto.response.customer.CustomerDTO; |
| | | import com.mzl.flower.entity.coupon.CouponRecordDO; |
| | | import com.mzl.flower.entity.coupon.CouponTemplateDO; |
| | | import com.mzl.flower.enums.CouponStatusEnum; |
| | | import com.mzl.flower.service.coupon.CouponRecordService; |
| | | import com.mzl.flower.service.coupon.CouponTemplateService2; |
| | | import com.mzl.flower.service.customer.CustomerService; |
| | | import com.mzl.flower.utils.ConverterUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Autowired |
| | | private CouponTemplateService2 couponTemplateService; |
| | | |
| | | private CustomerService customerService; |
| | | |
| | | |
| | | |
| | | @PostMapping("") |
| | |
| | | throw new ValidationException("优惠券不存在"); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(couponTemplateDO.getStatus()) && !couponTemplateDO.getStatus().equals(CouponStatusEnum.INACTIVE.getStatus())){ |
| | | if(StringUtils.isNotBlank(couponTemplateDO.getStatus()) && couponTemplateDO.getStatus().equals(CouponStatusEnum.INACTIVE.getStatus())){ |
| | | throw new ValidationException("优惠券还未发布"); |
| | | } |
| | | if(StringUtils.isNotBlank(couponTemplateDO.getStatus()) && !couponTemplateDO.getStatus().equals(CouponStatusEnum.EXPIRED.getStatus())){ |
| | | if(StringUtils.isNotBlank(couponTemplateDO.getStatus()) && couponTemplateDO.getStatus().equals(CouponStatusEnum.EXPIRED.getStatus())){ |
| | | throw new ValidationException("优惠券已下架"); |
| | | } |
| | | |
| | | // 根据当前获取获取商户的ID |
| | | final CustomerDTO currentCustomer = customerService.getCurrentCustomer(); |
| | | dto.setCustomerId(currentCustomer.getId()); |
| | | |
| | | couponRecordService.createCouponRecord(dto); |
| | | return returnData(R.SUCCESS.getCode(), null); |
| | |
| | | |
| | | @PutMapping("/{id}") |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody CreateCouponRecordDTO dto) { |
| | | public ResponseEntity<ReturnDataDTO> update(@PathVariable String id,@Validated @RequestBody CreateCouponRecordDTO dto) { |
| | | |
| | | dto.setId(id); |
| | | |
| | | CouponRecordDO couponRecordDO= couponRecordService.getById(dto.getId()); |
| | | if(null==couponRecordDO){ |