| | |
| | | package com.mzl.flower.dto.response.coupon; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.mzl.flower.base.AbstractTransDTO; |
| | | import com.mzl.flower.base.annotation.DictTrans; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @ApiModel("积分记录") |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 领取后有效类型(COUPON_usage_time_type)天、小时、分钟 |
| | | */ |
| | | @ApiModelProperty(value = "领取后有效类型(COUPON_USAGE_TIME_TYPE)") |
| | | @DictTrans(target = "usageTimeTypeName",codeType = "COUPON_USAGE_TIME_TYPE") |
| | | private String usageTimeType; |
| | | |
| | | /** |
| | | * 领取后有效时间整数,比如90(天,小时,分钟) |
| | | */ |
| | | @ApiModelProperty(value = "领取后有效时间整数") |
| | | private Integer usageTimeNum; |
| | | |
| | | @ApiModelProperty(value = "使用时间类型(COUPON_USAGE_TYPE)") |
| | | @DictTrans(target = "usageTypeName",codeType = "COUPON_USAGE_TYPE") |
| | | private String usageType; |
| | | |
| | | @ApiModelProperty(value = "使用时间类型") |
| | | private String usageTypeName; |
| | | |
| | | @ApiModelProperty(value = "领取后有效类型名称") |
| | | private String usageTimeTypeName; |
| | | |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | @DictTrans(target = "getTypeName",codeType = "COUPON_GET_TYPE") |
| | | private String getType; |
| | | |
| | | /** |
| | | * 领取渠道(COUPON_GET_TYPE)首页弹窗、活动入口、领券中心 |
| | | */ |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | private String getTypeName; |
| | | |
| | | /** |
| | | * 每人限领 |
| | | */ |
| | | @ApiModelProperty(value = "每人限领") |
| | | private Integer getLimit; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "领取后有效时间整数") |
| | | private Integer usageTimeNum; |
| | | |
| | | |
| | | @ApiModelProperty(value = "使用时间类型(COUPON_USAGE_TYPE)") |
| | | @DictTrans(target = "usageTypeName",codeType = "COUPON_USAGE_TYPE") |
| | | private String usageType; |
| | | |
| | | @ApiModelProperty(value = "使用时间类型") |
| | | private String usageTypeName; |
| | | |
| | | @ApiModelProperty(value = "领取后有效类型名称") |
| | | private String usageTimeTypeName; |
| | | |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | @DictTrans(target = "getTypeName",codeType = "COUPON_GET_TYPE") |
| | | private String getType; |
| | | |
| | | /** |
| | | * 领取渠道(COUPON_GET_TYPE)首页弹窗、活动入口、领券中心 |
| | | */ |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | private String getTypeName; |
| | | |
| | | /** |
| | | * 每人限领 |
| | | */ |
| | | @ApiModelProperty(value = "每人限领") |
| | | private Integer getLimit; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "会员等级对象") |
| | | private Member member; |
| | | |
| | | |
| | | |
| | | @ApiModelProperty(value = "使用时间类型(COUPON_USAGE_TYPE)") |
| | | @DictTrans(target = "usageTypeName",codeType = "COUPON_USAGE_TYPE") |
| | | private String usageType; |
| | | |
| | | @ApiModelProperty(value = "使用时间类型") |
| | | private String usageTypeName; |
| | | |
| | | |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | @DictTrans(target = "getTypeName",codeType = "COUPON_GET_TYPE") |
| | | private String getType; |
| | | |
| | | /** |
| | | * 领取渠道(COUPON_GET_TYPE)首页弹窗、活动入口、领券中心 |
| | | */ |
| | | @ApiModelProperty(value = "领取渠道(COUPON_GET_TYPE)") |
| | | private String getTypeName; |
| | | |
| | | /** |
| | | * 每人限领 |
| | | */ |
| | | @ApiModelProperty(value = "每人限领") |
| | | private Integer getLimit; |
| | | |
| | | } |
| | |
| | | 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.payment.*; |
| | |
| | | |
| | | @Autowired |
| | | private OrderItemSettlementService orderItemSettlementService; |
| | | |
| | | @Autowired |
| | | private CouponRecordService couponRecordService; |
| | | |
| | | @Scheduled(cron = "1 0/20 * * * ?") |
| | | public void calculateAvePrice() { |
| | |
| | | billService.generateBill(date.plusDays(-1)); |
| | | 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")); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.mzl.flower.dto.response.coupon.CouponRecordVO; |
| | | import com.mzl.flower.entity.coupon.CouponRecordDO; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | void checkCouponExpired(QueryMineCouponRecordDTO dto); |
| | | |
| | | boolean checkCurMonVipCouponExists(String couponId, Long customId, LocalDateTime startDateTime,LocalDateTime endDateTime); |
| | | |
| | | |
| | | } |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | couponRecordDO.setEffectiveStart(firstDayStart); |
| | | couponRecordDO.setEffectiveEnd(lastDayEnd); |
| | | couponRecordDO.setMemberId(couponTemplateDO.getMemberId()); |
| | | |
| | | // 创建信息 |
| | | couponRecordDO.create(); |
| | | return couponRecordDO; |
| | | }).collect(Collectors.toList()); |
| | | if(!checkCurMonVipCouponExists(couponRecordDO.getCouponId(),couponRecordDO.getCustomerId(),firstDayStart,lastDayEnd)){ |
| | | return couponRecordDO; |
| | | }else{ |
| | | return null; |
| | | } |
| | | |
| | | }).filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 批量保存等级下的优惠券信息 |
| | | saveBatch(gradeCouponRecordList); |
| | |
| | | // 将未使用的优惠券直接过期 |
| | | couponRecordMapperCustom.checkCouponExpired(dto); |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkCurMonVipCouponExists(String couponId, Long customId, LocalDateTime startDateTime, LocalDateTime endDateTime) { |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime firstDayStart = now.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0).withNano(0); |
| | | LocalDateTime lastDayEnd = now.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59).withNano(0); |
| | | if(null==startDateTime){ |
| | | startDateTime=firstDayStart; |
| | | } |
| | | if(null==endDateTime){ |
| | | endDateTime=lastDayEnd; |
| | | } |
| | | |
| | | QueryWrapper<CouponRecordDO> queryWrapper=new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(CouponRecordDO::getDeleted,TrueOrFalseEnum.FALSE.isFlag()) |
| | | .eq(CouponRecordDO::getCouponId,couponId) |
| | | .eq(CouponRecordDO::getCustomerId,customId) |
| | | .eq(CouponRecordDO::getEffectiveStart,startDateTime) |
| | | .eq(CouponRecordDO::getEffectiveEnd,endDateTime); |
| | | return baseMapper.selectCount(queryWrapper)>0; |
| | | |
| | | } |
| | | } |