Просмотр исходного кода

添加生日积分定时任务发送短信

release_toaliyun_real
Burce 6 лет назад
Родитель
Сommit
6917c72182
2 измененных файлов: 36 добавлений и 3 удалений
  1. +32
    -3
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java
  2. +4
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java

+ 32
- 3
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<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());
}
}

+ 4
- 0
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) {


Загрузка…
Отмена
Сохранить