From 3f5d62a7b4d20f6c63021361e7a48cab02e6cca3 Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期二, 03 九月 2024 15:15:23 +0800 Subject: [PATCH] 1.优惠券相关代码提交 --- src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java b/src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java index 8a137ef..4c03990 100644 --- a/src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java +++ b/src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java @@ -10,11 +10,13 @@ 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; @@ -41,6 +43,8 @@ @Autowired private CouponTemplateService2 couponTemplateService; + private CustomerService customerService; + @PostMapping("") @@ -52,13 +56,16 @@ 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); @@ -66,7 +73,9 @@ @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){ -- Gitblit v1.9.3