lin 3 лет назад
Родитель
Сommit
c0fba3acd7
12 измененных файлов: 77 добавлений и 28 удалений
  1. +2
    -0
      mallinkAdmin/src/main/resources/db/migration/V20230323000001_business.sql
  2. +5
    -0
      mallinkAdmin/src/main/resources/db/migration/V20230323000001_msg.sql
  3. +1
    -1
      mallinkSchedule/src/main/java/com/iformall/schedule/WxMsgModelSchedule.java
  4. +17
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxMsgModel.java
  5. +5
    -0
      mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java
  6. +1
    -5
      mallinkService/src/main/java/com/iformall/mapper/WxMsgModelMapper.java
  7. +1
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java
  8. +29
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java
  9. +10
    -4
      mallinkService/src/main/java/com/iformall/sms/EnumSMSChannel.java
  10. +1
    -1
      mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml
  11. +4
    -1
      mallinkService/src/main/resources/mapper/WxMsgMapper.xml
  12. +1
    -10
      mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml

+ 2
- 0
mallinkAdmin/src/main/resources/db/migration/V20230323000001_business.sql Просмотреть файл

@@ -1,5 +1,7 @@
alter table wx_tags add column is_del int(1) not null default 0 comment '是否已删除,1-是,0-否';

delete from wx_tags_type where id in (14,17);

update wx_tags set is_del = 1 where type_id in (14,17);

alter table wx_business add column final_tenant_id varchar(5) comment '';


+ 5
- 0
mallinkAdmin/src/main/resources/db/migration/V20230323000001_msg.sql Просмотреть файл

@@ -0,0 +1,5 @@
alter table wx_msg add column per_count int(3) not null default 1 comment '每条消息发送条数';
alter table wx_msg add column sms_channel int(3) not null default 11 comment '发送渠道 EnumSMSChannel';
update wx_msg set sms_channel = 12 where tenant_id in ('1035','1036');



+ 1
- 1
mallinkSchedule/src/main/java/com/iformall/schedule/WxMsgModelSchedule.java Просмотреть файл

@@ -50,7 +50,7 @@ public class WxMsgModelSchedule {
public void querySmsTemplate() {
WxMsgModel msgModel = new WxMsgModel();
msgModel.setStatus(EnumMsgModelStatus.AUDITING.getCode());
List<WxMsgModel> aliYunList = wxMsgModelMapper.findAliYunList(msgModel);
List<WxMsgModel> aliYunList = wxMsgModelMapper.findList(msgModel);
if(!aliYunList.isEmpty()){
Map<String, List<WxMsgModel>> collect = aliYunList.stream().collect(groupingBy(WxMsgModel::getTenantId));
for (String tenantId:collect.keySet()) {


+ 17
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxMsgModel.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.domain.po;

import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
@@ -30,10 +31,25 @@ public class WxMsgModel extends TenantEntity {

@io.swagger.annotations.ApiModelProperty(value="reason",name="reason")
private String reason;
@io.swagger.annotations.ApiModelProperty(value="templateType",name="templateType")
@io.swagger.annotations.ApiModelProperty(value="EnumMsgModelType",name="templateType")
private Integer templateType;
@io.swagger.annotations.ApiModelProperty(value="通道模板code",name="modelCode")
private String modelCode;
public Integer calcuteContentSize(int perSize) {
if (StringUtils.isBlank(content) || perSize <= 0 ) {
return 1;
}
if (content.length() <= perSize) {
return 1;
}
int count = content.length() % perSize;
int countSize = count * perSize;
if (countSize < content.length()) {
return count+1;
}
return count;
}

}


+ 5
- 0
mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java Просмотреть файл

@@ -69,6 +69,11 @@ public class WxMsg extends BaseMsg {

@io.swagger.annotations.ApiModelProperty(value = "couponInjectId", name = "couponInjectId")
private Long couponInjectId;
@io.swagger.annotations.ApiModelProperty(value = "发送渠道 EnumSMSChannel", name = "smsChannel")
private Integer smsChannel;
@io.swagger.annotations.ApiModelProperty(value = "每条消息发送条数", name = "perCount")
private Integer perCount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value = "模板消息", name = "wxTemplateMsg")


+ 1
- 5
mallinkService/src/main/java/com/iformall/mapper/WxMsgModelMapper.java Просмотреть файл

@@ -8,10 +8,6 @@ public interface WxMsgModelMapper extends CommonMapper<WxMsgModel, String> {

List<WxMsgModel> findList(WxMsgModel wxMsgModel);

List<WxMsgModel> findAliYunList(WxMsgModel msgModel);


int updateByCode(WxMsgModel wxMsgModel);


}

+ 1
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java Просмотреть файл

@@ -240,6 +240,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService {
wxmsg.setErrorNumber(0);
//1、标签短信2、精准发券
wxmsg.setWay(EnumSendWay.COUPON.getCode());
wxmsg.setSmsChannel(wxMsgConfig.getSmsChannel());
wxMsgService.sendMsgFromCouponInject(wxmsg,wxMsgConfig,record);
return new ResultData();
}


+ 29
- 5
mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java Просмотреть файл

@@ -22,6 +22,8 @@ import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.*;
import com.iformall.sms.EnumSMSChannel;
import com.iformall.sms.SMSFactory;
import com.iformall.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -90,6 +92,10 @@ public class WxMsgServiceImpl implements WxMsgService {
@Lazy
@Autowired
TtCUserService ttCUserService;
@Lazy
@Autowired
SMSFactory smsFactory;

@Override
public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) {
@@ -103,8 +109,8 @@ public class WxMsgServiceImpl implements WxMsgService {
int success = wxMsgCallbackMapper.queryMsgSendTotal(params);
params.put("status", "0");
int error = wxMsgCallbackMapper.queryMsgSendTotal(params);
temp.setSuccessNumber(success);
temp.setErrorNumber(error);
temp.setSuccessNumber(success*temp.getPerCount());
temp.setErrorNumber(error*temp.getPerCount());
}

PageInfo<WxMsg> pageInfo = new PageInfo<>(templist);
@@ -121,8 +127,8 @@ public class WxMsgServiceImpl implements WxMsgService {
int success = wxMsgCallbackMapper.queryMsgSendTotal(params);
params.put("status", "0");
int error = wxMsgCallbackMapper.queryMsgSendTotal(params);
wxMsg.setSuccessNumber(success);
wxMsg.setErrorNumber(error);
wxMsg.setSuccessNumber(success*wxMsg.getPerCount());
wxMsg.setErrorNumber(error*wxMsg.getPerCount());
if(null != wxMsg.getModelId() && wxMsg.getWay() == EnumSendWay.APPINFOR.getCode()){
WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(wxMsg.getModelId());
wxMsg.setWxTemplateMsg(wxTemplateMsg);
@@ -275,7 +281,6 @@ public class WxMsgServiceImpl implements WxMsgService {
}
return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR);
}

if (phones.isEmpty()) {//没有手工输入手机号时解析标签,有,继续流转
if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){
List<WxCUserBasicInfo> list =
@@ -323,6 +328,18 @@ public class WxMsgServiceImpl implements WxMsgService {
logger.info("短信数量不足");
return new ResultData(ErrorCode.MSG_SUM_INSUFFICENT);
}
EnumSMSChannel smsChannel = EnumSMSChannel.getEnum(wxMsgConfig.getSmsChannel());
if (null == smsChannel) {
return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND,"短信配置渠道错误");
}
wxMsg.setSmsChannel(smsChannel.getCode());
WxMsgModel wxMsgModel = wxMsgModelMapper.selectById(wxMsg.getModelId());
if (null == wxMsgModel) {
return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND,"短信模版未查询到");
}
wxMsg.setPerCount(calcuteMsgCount(wxMsgModel,smsChannel));
wxMsg.setExpectSendNumber(wxMsg.getExpectSendNumber()*wxMsg.getPerCount());
saveOrUpdate(wxMsg, wxMsgConfig);
return new ResultData();
}else if(wxMsg.getWay() == EnumSendWay.APPINFOR.getCode()){
@@ -334,6 +351,12 @@ public class WxMsgServiceImpl implements WxMsgService {
}
}

private Integer calcuteMsgCount(WxMsgModel wxMsgModel,EnumSMSChannel smsChannel) {
if (null != smsChannel.getPerSize() && smsChannel.getPerSize() > 0 ) {
return wxMsgModel.calcuteContentSize(smsChannel.getPerSize());
}
return 1;
}

@Async
@Override
@@ -357,6 +380,7 @@ public class WxMsgServiceImpl implements WxMsgService {
wxMsg1.setSignature(wxMsg.getSignature());
wxMsg1.setMsg(wxMsg.getMsg());
wxMsg1.setModelId(wxMsg.getModelId());
wxMsg1.setSmsChannel(wxMsg.getSmsChannel());
if (extra > 0 && i == index) {
List<String> phoneList = Arrays.asList(split).subList(i * 1000, length);
String phones = StringUtils.join(phoneList, ",");


+ 10
- 4
mallinkService/src/main/java/com/iformall/sms/EnumSMSChannel.java Просмотреть файл

@@ -6,9 +6,9 @@ package com.iformall.sms;
*/
public enum EnumSMSChannel {

ALIYUN(11, "ALIYUN"),
ALIYUN_ZDY(12, "ALIYUN_ZDY"),
WIWIDE(0,"WIWIDE");
ALIYUN(11, "ALIYUN",60),
ALIYUN_ZDY(12, "ALIYUN_ZDY(客户的阿里云短信)",0),
WIWIDE(0,"WIWIDE",0);

public static EnumSMSChannel getEnum(Integer code) {
for (EnumSMSChannel value : values()) {
@@ -21,10 +21,12 @@ public enum EnumSMSChannel {

private Integer code;
private String message;
private Integer perSize;//每条短信最大字数,0:无限制,都按1条算

EnumSMSChannel(Integer code, String message) {
EnumSMSChannel(Integer code, String message,Integer perSize) {
this.code = code;
this.message = message;
this.perSize = perSize;
}

public Integer getCode() {
@@ -34,4 +36,8 @@ public enum EnumSMSChannel {
public String getMessage() {
return message;
}

public Integer getPerSize() {
return perSize;
}
}

+ 1
- 1
mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml Просмотреть файл

@@ -105,7 +105,7 @@
<select id="queryMsgSendTotal" parameterType="hashmap" resultType="int">
select count(*) from wx_msg_callback where msg_id=#{msgId} and status=#{status}
select count(1) from wx_msg_callback where msg_id=#{msgId} and status=#{status}
</select>

<update id="updateByBatchNo" parameterType="com.iformall.domain.po.WxMsgCallback">


+ 4
- 1
mallinkService/src/main/resources/mapper/WxMsgMapper.xml Просмотреть файл

@@ -24,10 +24,13 @@
<result column="status" jdbcType="INTEGER" property="status" />
<result column="way" jdbcType="INTEGER" property="way" />
<result column="coupon_inject_id" jdbcType="BIGINT" property="couponInjectId" />
<result column="per_count" jdbcType="INTEGER" property="perCount" />
<result column="sms_channel" jdbcType="INTEGER" property="smsChannel" />
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`tags`,`status`,`way`,`coupon_inject_id`
`id`,`tenant_id`,`parent_tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,
`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`tags`,`status`,`way`,`coupon_inject_id`,`per_count`,`sms_channel`
</sql>

<sql id="dynamicWhereConditions">


+ 1
- 10
mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml Просмотреть файл

@@ -74,16 +74,7 @@
from wx_msg_model
<include refid="dynamicWhereConditions"/>
</select>


<select id="findAliYunList" parameterType="com.iformall.domain.po.WxMsgModel" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_msg_model
where ifnull(model_code,'') != ''
and `status` = #{status}
</select>

<update id="updateByCode" parameterType="com.iformall.domain.po.WxMsgModel">
update wx_msg_model set status=#{status},reason=#{reason} where `model_code` = #{modelCode}
</update>


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