src/main/java/com/mzl/flower/dto/response/coupon/CouponRecordResultVO.java
@@ -130,5 +130,58 @@ @ApiModelProperty(value = "优惠券ID") private String couponId; /** * 用户id */ @ApiModelProperty(value = "用户id") private String userId; /** * 商户ID */ @ApiModelProperty(value = "商户ID") private Long customerId; /** * 使用订单 */ @ApiModelProperty(value = "使用订单") private String orderId; /** * 使用时间 */ @ApiModelProperty(value = "使用时间") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss" ,timezone="GMT+8") @DateTimeFormat private LocalDateTime usedTime; /** * 优惠券种类(活动优惠券、用户优惠券、会员优惠券,积分优惠券) */ @ApiModelProperty(value = "优惠券种类(活动优惠券、用户优惠券、会员优惠券,积分优惠券)") @DictTrans(target = "categoryName",codeType = "COUPON_CATEGORY") private String category; /** * 优惠券代码 */ @ApiModelProperty(value = "优惠券代码") private String couponCode; /** * 积分数量 */ @ApiModelProperty(value = "积分数量") private Integer point; /** * 会员等级 */ @ApiModelProperty(value = "会员等级") private Integer memberId; @ApiModelProperty(value = "优惠券种类名称") private String categoryName; } src/main/java/com/mzl/flower/dto/response/coupon/CouponTemplateVipVO.java
@@ -147,4 +147,10 @@ @ApiModelProperty(value = "每人限领") private Integer getLimit; /** * 发放数量 */ @ApiModelProperty(value = "发放数量") private Integer couponAmount; } src/main/java/com/mzl/flower/schedule/ScheduleService.java
@@ -9,6 +9,7 @@ import com.mzl.flower.mapper.flower.FlowerCategoryMapper; import com.mzl.flower.mapper.partner.PartnerMapper; import com.mzl.flower.mapper.payment.OrderMapper; import com.mzl.flower.service.coupon.CouponRecordService; import com.mzl.flower.service.flower.FlowerCategoryService; import com.mzl.flower.service.flower.FlowerService; import com.mzl.flower.service.menber.impl.GrowthValueDealService; @@ -61,6 +62,9 @@ @Autowired private GrowthValueDealService growthValueDealService; @Autowired private CouponRecordService couponRecordService; @Scheduled(cron = "1 0/20 * * * ?") public void calculateAvePrice() { @@ -210,4 +214,20 @@ log.info("成长值扣除结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); } @Scheduled(cron = "0 30 0 1 * ?") public void grantVipCouponRecordList() { log.info("会员优惠券开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); couponRecordService.grantVipCouponRecordList(); log.info("会员优惠券结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); } @Scheduled(cron = "0 30 0 1 * ?") public void expiredCouponRecordLastMon() { log.info("会员优惠券开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); couponRecordService.expiredCouponRecordLastMon(); log.info("会员优惠券结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); } } src/main/java/com/mzl/flower/service/coupon/CouponRecordService.java
@@ -41,7 +41,7 @@ * 根据当月日期设置上个月的日期的优惠券过期 * @return */ boolean expiredCouponRecordByListCurMonth(); boolean expiredCouponRecordLastMon(); Integer statisCouponTemplateCount(QueryCouponStatisticsBO queryCouponStatisticsBO); src/main/java/com/mzl/flower/service/impl/coupon/CouponRecordServiceImpl.java
@@ -292,6 +292,9 @@ couponTemplateDO.setGetStartDate(firstDayStart); couponTemplateDO.setGetEndDate(lastDayEnd); // 设置总数为当前会员的人数 couponTemplateDO.setCouponAmount(CollectionUtils.isNotEmpty(customerList)?customerList.size():0); // 设置默认类型固定 couponTemplateDO.setUsageType(CouponUsageTypeEnum.FIXED.getType()); @@ -311,7 +314,7 @@ } @Override public boolean expiredCouponRecordByListCurMonth() { public boolean expiredCouponRecordLastMon() { try{ LocalDateTime now = LocalDateTime.now(); @@ -461,7 +464,6 @@ public boolean cancelCouponUsage(String couponId, String orderId) { // 查询订单使用的优惠券 final CouponRecordDO couponRecordDO = getCouponByOrderId(orderId); // TODO couponRecordDO.setStatus(CouponUsedStatusEnum.UNUSED.getType()); couponRecordDO.setUsedTime(null); couponRecordDO.setOrderId(null); src/main/java/com/mzl/flower/web/v2/coupon/CouponRecordController.java
@@ -10,13 +10,11 @@ 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; @@ -43,9 +41,6 @@ @Autowired private CouponTemplateService2 couponTemplateService; private CustomerService customerService; @PostMapping("") @ApiOperation(value = "新增", notes = "新增") @@ -62,10 +57,6 @@ 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); src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml
@@ -34,8 +34,9 @@ <result column="status" property="status" /> <result column="point" property="point" /> <result column="member_id" property="memberId" /> </resultMap> <update id="activeBatchCouponTemplate"> update t_coupon_template set status='active',update_by=#{param.updateBy},update_time=now() where id in <foreach collection="param.idList" item="item" open="(" separator="," close=")">