From 6917c72182a2c7822335a683e7f74b880ab55ca0 Mon Sep 17 00:00:00 2001 From: Burce Date: Fri, 16 Aug 2019 17:09:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=9F=E6=97=A5=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/schedule/CouponSendSchedule.java | 35 +++++++++++++++++-- .../java/com/iformall/enums/EnumMsgModel.java | 4 +++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java index 1f90ad40a..aa7efc333 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java @@ -3,11 +3,11 @@ package com.iformall.schedule; import com.alibaba.fastjson.JSONObject; import com.iformall.domain.dto.WxCUserBasicInfoDto; import com.iformall.domain.po.*; +import com.iformall.domain.po.msg.WxMsgRecord; import com.iformall.domain.vo.WxCouponSendVo; -import com.iformall.enums.EnumCouponSendSendType; -import com.iformall.enums.EnumCouponSendStatus; -import com.iformall.enums.EnumEnableType; +import com.iformall.enums.*; import com.iformall.mapper.*; +import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.DateUtils; import org.apache.commons.collections.CollectionUtils; @@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; @@ -58,6 +59,11 @@ public class CouponSendSchedule { @Autowired private WxCouponSendService wxCouponSendService ; + @Autowired + private WxScoreRulesService wxScoreRulesService ; + + @Autowired + private MqBaseProducer mqBaseProducer; @@ -303,6 +309,7 @@ public class CouponSendSchedule { // 发放免费券 try { WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getCouponId()); + sendSMS(cu,mall); wxCouponActionLogService.addOne(cu.getTenantId(), cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); } catch (Exception e) { logger.error("定时发券:发券失败 levelId=" + cu.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); @@ -343,4 +350,26 @@ public class CouponSendSchedule { } return false; } + + private void sendSMS(WxCUserBasicInfo cUserBasicInfo, WxMall mall) { + WxMsgRecord wxMsgRecord = new WxMsgRecord(); + wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); + wxMsgRecord.setReceiver(cUserBasicInfo.getPhone()); + wxMsgRecord.setTenantId(cUserBasicInfo.getTenantId()); + Map dynamicContentMap = new HashMap<>(); + WxScoreRules rules = wxScoreRulesService.getScoreRules(cUserBasicInfo.getTenantId()); + if (Objects.nonNull(rules) && Objects.nonNull(rules.getScale())) { + int birthdayScale = rules.getScale(); + float creditScale = new BigDecimal(birthdayScale).divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)).floatValue(); + dynamicContentMap.put("creditScale", String.valueOf(creditScale)); + wxMsgRecord.setModelType(EnumMsgModel.COUPON_BIRTHDAY_OPENED.getCode()); + } else { + //没有配置积分规则 + wxMsgRecord.setModelType(EnumMsgModel.COUPON_BIRTHDAY_OPENED_NO.getCode()); + } + dynamicContentMap.put("userName", cUserBasicInfo.getNickName()); + dynamicContentMap.put("mallName", mall.getName()); + wxMsgRecord.setDynamicContentMap(dynamicContentMap); + mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); + } } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java b/mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java index 65f7f97ca..f679a6f7a 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java @@ -30,6 +30,10 @@ public enum EnumMsgModel { FLOW_C_APPLY_NODIFY(20, "审批通知"), FLOW_C_PASS_NODIFY(21, "通过审批通知"), FLOW_C_REJECT_NODIFY(22, "驳回通知"), + + //会员生日券 + COUPON_BIRTHDAY_OPENED(28, "会员生日券开启"), + COUPON_BIRTHDAY_OPENED_NO(29, "会员生日券未开启"), ; public static EnumMsgModel getEnum(Integer code) {