|
|
|
@@ -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<String, String> 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()); |
|
|
|
} |
|
|
|
} |