1.优惠券活动由定时器修改为延时任务执行。
2.修改shopEditDTO,不继承ShopDetail
This commit is contained in:
		
							parent
							
								
									bbf18b7b0a
								
							
						
					
					
						commit
						d5fab95707
					
				| @ -1,80 +0,0 @@ | |||||||
| package cn.lili.timetask.handler.impl.coupon; |  | ||||||
| 
 |  | ||||||
| import cn.hutool.core.date.DateTime; |  | ||||||
| import cn.hutool.core.date.DateUtil; |  | ||||||
| import cn.lili.modules.promotion.entity.dos.CouponActivity; |  | ||||||
| import cn.lili.modules.promotion.entity.enums.CouponActivityTypeEnum; |  | ||||||
| import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; |  | ||||||
| import cn.lili.modules.promotion.service.CouponActivityService; |  | ||||||
| import cn.lili.timetask.handler.EveryMinuteExecute; |  | ||||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |  | ||||||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |  | ||||||
| import org.springframework.beans.factory.annotation.Autowired; |  | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
| 
 |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * 优惠券活动状态监测 |  | ||||||
|  * |  | ||||||
|  * @author Bulbasaur |  | ||||||
|  * @date: 2021/5/24 10:08 上午 |  | ||||||
|  */ |  | ||||||
| @Component |  | ||||||
| public class CouponActivityExecute implements EveryMinuteExecute { |  | ||||||
| 
 |  | ||||||
|     @Autowired |  | ||||||
|     private CouponActivityService couponActivityService; |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public void execute() { |  | ||||||
|         //精确发券活动 |  | ||||||
|         specify(); |  | ||||||
|         //注册赠券的活动 |  | ||||||
|         registered(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 监测精确发券活动 |  | ||||||
|      * 达到活动时间发送优惠券 |  | ||||||
|      */ |  | ||||||
|     private void specify(){ |  | ||||||
|         DateTime dateTime=DateUtil.date(); |  | ||||||
|         List<CouponActivity> couponActivities=couponActivityService.list(new LambdaQueryWrapper<CouponActivity>() |  | ||||||
|                 .eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.SPECIFY.name()) |  | ||||||
|                 .le(CouponActivity::getStartTime, dateTime) |  | ||||||
|                 .eq(CouponActivity::getPromotionStatus,PromotionStatusEnum.NEW.name())); |  | ||||||
|         //如果有符合要求的优惠券活动,发送优惠券 |  | ||||||
|         if(couponActivities.size()>0){ |  | ||||||
|             for (CouponActivity couponActivity:couponActivities) { |  | ||||||
|                 couponActivityService.specify(couponActivity.getId()); |  | ||||||
| 
 |  | ||||||
|             //修改精准发券优惠券活动状态 |  | ||||||
|             couponActivityService.update(new LambdaUpdateWrapper<CouponActivity>() |  | ||||||
|                     .eq(CouponActivity::getId,couponActivity.getId()) |  | ||||||
|                     .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.END.name())); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|     } |  | ||||||
|     /** |  | ||||||
|      * 注册赠券活动状态监测 |  | ||||||
|      */ |  | ||||||
|     private void registered(){ |  | ||||||
|         //开启注册赠券优惠券活动 |  | ||||||
|         LambdaUpdateWrapper<CouponActivity> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); |  | ||||||
|         lambdaUpdateWrapper.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name()) |  | ||||||
|                 .eq(CouponActivity::getPromotionStatus, PromotionStatusEnum.NEW.name()) |  | ||||||
|                 .le(CouponActivity::getStartTime, DateUtil.date()) |  | ||||||
|                 .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.START.name()); |  | ||||||
|         couponActivityService.update(lambdaUpdateWrapper); |  | ||||||
| 
 |  | ||||||
|         //关闭注册赠券优惠券活动 |  | ||||||
|         LambdaUpdateWrapper<CouponActivity> endWrapper = new LambdaUpdateWrapper<>(); |  | ||||||
|         endWrapper.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name()) |  | ||||||
|                 .eq(CouponActivity::getPromotionStatus, PromotionStatusEnum.START.name()) |  | ||||||
|                 .le(CouponActivity::getEndTime, DateUtil.date()) |  | ||||||
|                 .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.END.name()); |  | ||||||
|         couponActivityService.update(endWrapper); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -2,7 +2,14 @@ package cn.lili.modules.promotion.serviceimpl; | |||||||
| 
 | 
 | ||||||
| import cn.hutool.json.JSONUtil; | import cn.hutool.json.JSONUtil; | ||||||
| import cn.lili.common.exception.ServiceException; | import cn.lili.common.exception.ServiceException; | ||||||
|  | import cn.lili.common.trigger.enums.DelayTypeEnums; | ||||||
|  | import cn.lili.common.trigger.interfaces.TimeTrigger; | ||||||
|  | import cn.lili.common.trigger.message.PromotionMessage; | ||||||
|  | import cn.lili.common.trigger.model.TimeExecuteConstant; | ||||||
|  | import cn.lili.common.trigger.model.TimeTriggerMsg; | ||||||
|  | import cn.lili.common.trigger.util.DelayQueueTools; | ||||||
| import cn.lili.common.utils.DateUtil; | import cn.lili.common.utils.DateUtil; | ||||||
|  | import cn.lili.config.rocketmq.RocketmqCustomProperties; | ||||||
| import cn.lili.modules.member.entity.dos.Member; | import cn.lili.modules.member.entity.dos.Member; | ||||||
| import cn.lili.modules.member.service.MemberService; | import cn.lili.modules.member.service.MemberService; | ||||||
| import cn.lili.modules.promotion.entity.dos.Coupon; | import cn.lili.modules.promotion.entity.dos.Coupon; | ||||||
| @ -10,9 +17,7 @@ import cn.lili.modules.promotion.entity.dos.CouponActivity; | |||||||
| import cn.lili.modules.promotion.entity.dos.CouponActivityItem; | import cn.lili.modules.promotion.entity.dos.CouponActivityItem; | ||||||
| import cn.lili.modules.promotion.entity.dos.MemberCoupon; | import cn.lili.modules.promotion.entity.dos.MemberCoupon; | ||||||
| import cn.lili.modules.promotion.entity.dto.CouponActivityDTO; | import cn.lili.modules.promotion.entity.dto.CouponActivityDTO; | ||||||
| import cn.lili.modules.promotion.entity.enums.CouponActivitySendTypeEnum; | import cn.lili.modules.promotion.entity.enums.*; | ||||||
| import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; |  | ||||||
| import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; |  | ||||||
| import cn.lili.modules.promotion.entity.vos.CouponActivityVO; | import cn.lili.modules.promotion.entity.vos.CouponActivityVO; | ||||||
| import cn.lili.modules.promotion.mapper.CouponActivityMapper; | import cn.lili.modules.promotion.mapper.CouponActivityMapper; | ||||||
| import cn.lili.modules.promotion.service.CouponActivityItemService; | import cn.lili.modules.promotion.service.CouponActivityItemService; | ||||||
| @ -47,6 +52,12 @@ public class CouponActivityServiceImpl extends ServiceImpl<CouponActivityMapper, | |||||||
|     private CouponActivityItemService couponActivityItemService; |     private CouponActivityItemService couponActivityItemService; | ||||||
|     @Autowired |     @Autowired | ||||||
|     private MemberService memberService; |     private MemberService memberService; | ||||||
|  |     //Rocketmq | ||||||
|  |     @Autowired | ||||||
|  |     private RocketmqCustomProperties rocketmqCustomProperties; | ||||||
|  |     //延时任务 | ||||||
|  |     @Autowired | ||||||
|  |     private TimeTrigger timeTrigger; | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public CouponActivityDTO addCouponActivity(CouponActivityDTO couponActivityDTO) { |     public CouponActivityDTO addCouponActivity(CouponActivityDTO couponActivityDTO) { | ||||||
| @ -60,6 +71,17 @@ public class CouponActivityServiceImpl extends ServiceImpl<CouponActivityMapper, | |||||||
|         this.save(couponActivityDTO); |         this.save(couponActivityDTO); | ||||||
|         //添加优惠券活动优惠券 |         //添加优惠券活动优惠券 | ||||||
|         this.addCouponActivityItems(couponActivityDTO); |         this.addCouponActivityItems(couponActivityDTO); | ||||||
|  | 
 | ||||||
|  |         //创建优惠券活动延时任务 | ||||||
|  |         PromotionMessage promotionMessage = new PromotionMessage(couponActivityDTO.getId(), PromotionTypeEnum.COUPON_ACTIVITY.name(), PromotionStatusEnum.START.name(), couponActivityDTO.getStartTime(), couponActivityDTO.getEndTime()); | ||||||
|  |         TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR, | ||||||
|  |                 couponActivityDTO.getStartTime().getTime(), | ||||||
|  |                 promotionMessage, | ||||||
|  |                 DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())), | ||||||
|  |                 rocketmqCustomProperties.getPromotionTopic()); | ||||||
|  |         //发送促销活动开始的延时任务 | ||||||
|  |         this.timeTrigger.addDelay(timeTriggerMsg); | ||||||
|  | 
 | ||||||
|         return couponActivityDTO; |         return couponActivityDTO; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import cn.lili.modules.search.service.EsGoodsIndexService; | |||||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.data.mongodb.core.MongoTemplate; | import org.springframework.data.mongodb.core.MongoTemplate; | ||||||
| @ -416,16 +417,17 @@ public class PromotionServiceImpl implements PromotionService { | |||||||
|      * @return 修改结果 |      * @return 修改结果 | ||||||
|      */ |      */ | ||||||
|     private boolean updateCouponActivity(PromotionMessage promotionMessage, PromotionTypeEnum promotionTypeEnum){ |     private boolean updateCouponActivity(PromotionMessage promotionMessage, PromotionTypeEnum promotionTypeEnum){ | ||||||
|         boolean result; | 
 | ||||||
|         CouponActivityVO couponActivityVO = this.mongoTemplate.findById(promotionMessage.getPromotionId(), CouponActivityVO.class); |         //如果是精准发券,进行发送优惠券 | ||||||
|         if (couponActivityVO == null) { |         CouponActivity couponActivity=couponActivityService.getById(promotionMessage.getPromotionId()); | ||||||
|             this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus()); |         if(couponActivity.getCouponActivityType().equals(CouponActivityTypeEnum.SPECIFY.name())){ | ||||||
|             return false; |             couponActivityService.specify(couponActivity.getId()); | ||||||
|         } |         } | ||||||
|         couponActivityVO.setPromotionStatus(promotionMessage.getPromotionStatus()); | 
 | ||||||
|         result = this.couponActivityService.update(promotionMessage.updateWrapper()); |         //修改活动状态 | ||||||
|         this.mongoTemplate.save(couponActivityVO); |         return couponActivityService.update(new LambdaUpdateWrapper<CouponActivity>() | ||||||
|         return result; |                         .eq(CouponActivity::getId,promotionMessage.getPromotionId()) | ||||||
|  |                         .set(CouponActivity::getPromotionStatus,promotionMessage.getPromotionStatus())); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -1,11 +1,23 @@ | |||||||
| package cn.lili.modules.store.entity.dto; | package cn.lili.modules.store.entity.dto; | ||||||
| 
 | 
 | ||||||
|  | import cn.lili.common.validation.Mobile; | ||||||
|  | import cn.lili.common.validation.Phone; | ||||||
| import cn.lili.modules.store.entity.dos.StoreDetail; | import cn.lili.modules.store.entity.dos.StoreDetail; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableField; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.fasterxml.jackson.annotation.JsonFormat; | ||||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  | import org.hibernate.validator.constraints.Length; | ||||||
|  | import org.springframework.format.annotation.DateTimeFormat; | ||||||
| 
 | 
 | ||||||
|  | import javax.persistence.Column; | ||||||
|  | import javax.persistence.Id; | ||||||
|  | import javax.validation.constraints.Email; | ||||||
|  | import javax.validation.constraints.Min; | ||||||
| import javax.validation.constraints.NotBlank; | import javax.validation.constraints.NotBlank; | ||||||
| import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||||
|  | import java.util.Date; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 店铺修改DTO |  * 店铺修改DTO | ||||||
| @ -14,7 +26,147 @@ import javax.validation.constraints.Size; | |||||||
|  * @date 2020-08-22 15:10:51 |  * @date 2020-08-22 15:10:51 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class StoreEditDTO extends StoreDetail { | public class StoreEditDTO { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @Id | ||||||
|  |     @TableId | ||||||
|  |     @TableField | ||||||
|  |     @Column(columnDefinition = "bigint(20)") | ||||||
|  |     @ApiModelProperty(value = "唯一标识", hidden = true) | ||||||
|  |     private String id; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "店铺不能为空") | ||||||
|  |     @ApiModelProperty(value = "店铺id") | ||||||
|  |     private String storeId; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 2, max = 200, message = "店铺名称长度为2-200位") | ||||||
|  |     @NotBlank(message = "店铺名称不能为空") | ||||||
|  |     @ApiModelProperty(value = "店铺名称") | ||||||
|  |     private String storeName; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "公司名称不能为空") | ||||||
|  |     @Size(min = 2, max = 100, message = "公司名称错误") | ||||||
|  |     @ApiModelProperty(value = "公司名称") | ||||||
|  |     private String companyName; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "公司地址不能为空") | ||||||
|  |     @Size(min = 1, max = 200, message = "公司地址,长度为1-200字符") | ||||||
|  |     @ApiModelProperty(value = "公司地址") | ||||||
|  |     private String companyAddress; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "公司地址地区Id") | ||||||
|  |     private String companyAddressIdPath; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "公司地址地区") | ||||||
|  |     private String companyAddressPath; | ||||||
|  | 
 | ||||||
|  |     @Mobile | ||||||
|  |     @ApiModelProperty(value = "公司电话") | ||||||
|  |     private String companyPhone; | ||||||
|  | 
 | ||||||
|  |     @Email | ||||||
|  |     @ApiModelProperty(value = "电子邮箱") | ||||||
|  |     private String companyEmail; | ||||||
|  | 
 | ||||||
|  |     @Min(value = 1, message = "员工总数,至少一位") | ||||||
|  |     @ApiModelProperty(value = "员工总数") | ||||||
|  |     private Integer employeeNum; | ||||||
|  | 
 | ||||||
|  |     @Min(value = 1, message = "注册资金,至少一位") | ||||||
|  |     @ApiModelProperty(value = "注册资金") | ||||||
|  |     private Double registeredCapital; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "联系人姓名为空") | ||||||
|  |     @Length(min = 2, max = 20, message = "联系人长度为:2-20位字符") | ||||||
|  |     @ApiModelProperty(value = "联系人姓名") | ||||||
|  |     private String linkName; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "手机号不能为空") | ||||||
|  |     @Phone | ||||||
|  |     @ApiModelProperty(value = "联系人电话") | ||||||
|  |     private String linkPhone; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 18, max = 18, message = "营业执照长度为18位字符") | ||||||
|  |     @ApiModelProperty(value = "营业执照号") | ||||||
|  |     private String licenseNum; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 1, max = 200, message = "法定经营范围长度为1-200位字符") | ||||||
|  |     @ApiModelProperty(value = "法定经营范围") | ||||||
|  |     private String scope; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "营业执照电子版不能为空") | ||||||
|  |     @ApiModelProperty(value = "营业执照电子版") | ||||||
|  |     private String licencePhoto; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "法人姓名不能为空") | ||||||
|  |     @Size(min = 2, max = 20, message = "法人姓名长度为2-20位字符") | ||||||
|  |     @ApiModelProperty(value = "法人姓名") | ||||||
|  |     private String legalName; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "法人身份证不能为空") | ||||||
|  |     @Size(min = 18, max = 18, message = "法人身份证号长度为18位") | ||||||
|  |     @ApiModelProperty(value = "法人身份证") | ||||||
|  |     private String legalId; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "法人身份证不能为空") | ||||||
|  |     @ApiModelProperty(value = "法人身份证照片") | ||||||
|  |     private String legalPhoto; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位") | ||||||
|  |     @NotBlank(message = "结算银行开户行名称不能为空") | ||||||
|  |     @ApiModelProperty(value = "结算银行开户行名称") | ||||||
|  |     private String settlementBankAccountName; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位") | ||||||
|  |     @NotBlank(message = "结算银行开户账号不能为空") | ||||||
|  |     @ApiModelProperty(value = "结算银行开户账号") | ||||||
|  |     private String settlementBankAccountNum; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位") | ||||||
|  |     @NotBlank(message = "结算银行开户支行名称不能为空") | ||||||
|  |     @ApiModelProperty(value = "结算银行开户支行名称") | ||||||
|  |     private String settlementBankBranchName; | ||||||
|  | 
 | ||||||
|  |     @Size(min = 1, max = 50, message = "结算银行支行联行号长度为1-200位") | ||||||
|  |     @NotBlank(message = "结算银行支行联行号不能为空") | ||||||
|  |     @ApiModelProperty(value = "结算银行支行联行号") | ||||||
|  |     private String settlementBankJointName; | ||||||
|  | 
 | ||||||
|  |     @NotBlank(message = "店铺经营类目不能为空") | ||||||
|  |     @ApiModelProperty(value = "店铺经营类目") | ||||||
|  |     @Column(columnDefinition = "TEXT") | ||||||
|  |     private String goodsManagementCategory; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "结算周期") | ||||||
|  |     private String settlementCycle; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "库存预警数量") | ||||||
|  |     private Integer stockWarning; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 同城配送达达店铺编码 | ||||||
|  |      */ | ||||||
|  |     @ApiModelProperty(value = "同城配送达达店铺编码") | ||||||
|  |     @TableField(value = "dd_code") | ||||||
|  |     private String ddCode; | ||||||
|  | 
 | ||||||
|  |     //店铺退货收件地址 | ||||||
|  |     @ApiModelProperty(value = "收货人姓名") | ||||||
|  |     private String salesConsigneeName; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "收件人手机") | ||||||
|  |     private String salesConsigneeMobile; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "地址Id, ','分割") | ||||||
|  |     private String salesConsigneeAddressId; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "地址名称, ','分割") | ||||||
|  |     private String salesConsigneeAddressPath; | ||||||
|  | 
 | ||||||
|  |     @ApiModelProperty(value = "详细地址") | ||||||
|  |     private String salesConsigneeDetail; | ||||||
| 
 | 
 | ||||||
|     @ApiModelProperty(value = "店铺状态") |     @ApiModelProperty(value = "店铺状态") | ||||||
|     private String storeDisable; |     private String storeDisable; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 lifenlong
						lifenlong