| @@ -1,5 +1,7 @@ | |||||
| alter table wx_tags add column is_del int(1) not null default 0 comment '是否已删除,1-是,0-否'; | 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); | 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 ''; | alter table wx_business add column final_tenant_id varchar(5) comment ''; | ||||
| @@ -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'); | |||||
| @@ -50,7 +50,7 @@ public class WxMsgModelSchedule { | |||||
| public void querySmsTemplate() { | public void querySmsTemplate() { | ||||
| WxMsgModel msgModel = new WxMsgModel(); | WxMsgModel msgModel = new WxMsgModel(); | ||||
| msgModel.setStatus(EnumMsgModelStatus.AUDITING.getCode()); | msgModel.setStatus(EnumMsgModelStatus.AUDITING.getCode()); | ||||
| List<WxMsgModel> aliYunList = wxMsgModelMapper.findAliYunList(msgModel); | |||||
| List<WxMsgModel> aliYunList = wxMsgModelMapper.findList(msgModel); | |||||
| if(!aliYunList.isEmpty()){ | if(!aliYunList.isEmpty()){ | ||||
| Map<String, List<WxMsgModel>> collect = aliYunList.stream().collect(groupingBy(WxMsgModel::getTenantId)); | Map<String, List<WxMsgModel>> collect = aliYunList.stream().collect(groupingBy(WxMsgModel::getTenantId)); | ||||
| for (String tenantId:collect.keySet()) { | for (String tenantId:collect.keySet()) { | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| @@ -30,10 +31,25 @@ public class WxMsgModel extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="reason",name="reason") | @io.swagger.annotations.ApiModelProperty(value="reason",name="reason") | ||||
| private String reason; | private String reason; | ||||
| @io.swagger.annotations.ApiModelProperty(value="templateType",name="templateType") | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumMsgModelType",name="templateType") | |||||
| private Integer templateType; | private Integer templateType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="通道模板code",name="modelCode") | @io.swagger.annotations.ApiModelProperty(value="通道模板code",name="modelCode") | ||||
| private String 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; | |||||
| } | |||||
| } | } | ||||
| @@ -69,6 +69,11 @@ public class WxMsg extends BaseMsg { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "couponInjectId", name = "couponInjectId") | @io.swagger.annotations.ApiModelProperty(value = "couponInjectId", name = "couponInjectId") | ||||
| private Long 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) | @TableField(exist = false) | ||||
| @io.swagger.annotations.ApiModelProperty(value = "模板消息", name = "wxTemplateMsg") | @io.swagger.annotations.ApiModelProperty(value = "模板消息", name = "wxTemplateMsg") | ||||
| @@ -8,10 +8,6 @@ public interface WxMsgModelMapper extends CommonMapper<WxMsgModel, String> { | |||||
| List<WxMsgModel> findList(WxMsgModel wxMsgModel); | List<WxMsgModel> findList(WxMsgModel wxMsgModel); | ||||
| List<WxMsgModel> findAliYunList(WxMsgModel msgModel); | |||||
| int updateByCode(WxMsgModel wxMsgModel); | int updateByCode(WxMsgModel wxMsgModel); | ||||
| } | } | ||||
| @@ -240,6 +240,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| wxmsg.setErrorNumber(0); | wxmsg.setErrorNumber(0); | ||||
| //1、标签短信2、精准发券 | //1、标签短信2、精准发券 | ||||
| wxmsg.setWay(EnumSendWay.COUPON.getCode()); | wxmsg.setWay(EnumSendWay.COUPON.getCode()); | ||||
| wxmsg.setSmsChannel(wxMsgConfig.getSmsChannel()); | |||||
| wxMsgService.sendMsgFromCouponInject(wxmsg,wxMsgConfig,record); | wxMsgService.sendMsgFromCouponInject(wxmsg,wxMsgConfig,record); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -22,6 +22,8 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.sms.EnumSMSChannel; | |||||
| import com.iformall.sms.SMSFactory; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -90,6 +92,10 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| @Lazy | @Lazy | ||||
| @Autowired | @Autowired | ||||
| TtCUserService ttCUserService; | TtCUserService ttCUserService; | ||||
| @Lazy | |||||
| @Autowired | |||||
| SMSFactory smsFactory; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -103,8 +109,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| int success = wxMsgCallbackMapper.queryMsgSendTotal(params); | int success = wxMsgCallbackMapper.queryMsgSendTotal(params); | ||||
| params.put("status", "0"); | params.put("status", "0"); | ||||
| int error = wxMsgCallbackMapper.queryMsgSendTotal(params); | 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); | PageInfo<WxMsg> pageInfo = new PageInfo<>(templist); | ||||
| @@ -121,8 +127,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| int success = wxMsgCallbackMapper.queryMsgSendTotal(params); | int success = wxMsgCallbackMapper.queryMsgSendTotal(params); | ||||
| params.put("status", "0"); | params.put("status", "0"); | ||||
| int error = wxMsgCallbackMapper.queryMsgSendTotal(params); | 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()){ | if(null != wxMsg.getModelId() && wxMsg.getWay() == EnumSendWay.APPINFOR.getCode()){ | ||||
| WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(wxMsg.getModelId()); | WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(wxMsg.getModelId()); | ||||
| wxMsg.setWxTemplateMsg(wxTemplateMsg); | wxMsg.setWxTemplateMsg(wxTemplateMsg); | ||||
| @@ -275,7 +281,6 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| } | } | ||||
| return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); | ||||
| } | } | ||||
| if (phones.isEmpty()) {//没有手工输入手机号时解析标签,有,继续流转 | if (phones.isEmpty()) {//没有手工输入手机号时解析标签,有,继续流转 | ||||
| if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | ||||
| List<WxCUserBasicInfo> list = | List<WxCUserBasicInfo> list = | ||||
| @@ -323,6 +328,18 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| logger.info("短信数量不足"); | logger.info("短信数量不足"); | ||||
| return new ResultData(ErrorCode.MSG_SUM_INSUFFICENT); | 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); | saveOrUpdate(wxMsg, wxMsgConfig); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| }else if(wxMsg.getWay() == EnumSendWay.APPINFOR.getCode()){ | }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 | @Async | ||||
| @Override | @Override | ||||
| @@ -357,6 +380,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| wxMsg1.setSignature(wxMsg.getSignature()); | wxMsg1.setSignature(wxMsg.getSignature()); | ||||
| wxMsg1.setMsg(wxMsg.getMsg()); | wxMsg1.setMsg(wxMsg.getMsg()); | ||||
| wxMsg1.setModelId(wxMsg.getModelId()); | wxMsg1.setModelId(wxMsg.getModelId()); | ||||
| wxMsg1.setSmsChannel(wxMsg.getSmsChannel()); | |||||
| if (extra > 0 && i == index) { | if (extra > 0 && i == index) { | ||||
| List<String> phoneList = Arrays.asList(split).subList(i * 1000, length); | List<String> phoneList = Arrays.asList(split).subList(i * 1000, length); | ||||
| String phones = StringUtils.join(phoneList, ","); | String phones = StringUtils.join(phoneList, ","); | ||||
| @@ -6,9 +6,9 @@ package com.iformall.sms; | |||||
| */ | */ | ||||
| public enum EnumSMSChannel { | 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) { | public static EnumSMSChannel getEnum(Integer code) { | ||||
| for (EnumSMSChannel value : values()) { | for (EnumSMSChannel value : values()) { | ||||
| @@ -21,10 +21,12 @@ public enum EnumSMSChannel { | |||||
| private Integer code; | private Integer code; | ||||
| private String message; | private String message; | ||||
| private Integer perSize;//每条短信最大字数,0:无限制,都按1条算 | |||||
| EnumSMSChannel(Integer code, String message) { | |||||
| EnumSMSChannel(Integer code, String message,Integer perSize) { | |||||
| this.code = code; | this.code = code; | ||||
| this.message = message; | this.message = message; | ||||
| this.perSize = perSize; | |||||
| } | } | ||||
| public Integer getCode() { | public Integer getCode() { | ||||
| @@ -34,4 +36,8 @@ public enum EnumSMSChannel { | |||||
| public String getMessage() { | public String getMessage() { | ||||
| return message; | return message; | ||||
| } | } | ||||
| public Integer getPerSize() { | |||||
| return perSize; | |||||
| } | |||||
| } | } | ||||
| @@ -105,7 +105,7 @@ | |||||
| <select id="queryMsgSendTotal" parameterType="hashmap" resultType="int"> | <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> | </select> | ||||
| <update id="updateByBatchNo" parameterType="com.iformall.domain.po.WxMsgCallback"> | <update id="updateByBatchNo" parameterType="com.iformall.domain.po.WxMsgCallback"> | ||||
| @@ -24,10 +24,13 @@ | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | <result column="status" jdbcType="INTEGER" property="status" /> | ||||
| <result column="way" jdbcType="INTEGER" property="way" /> | <result column="way" jdbcType="INTEGER" property="way" /> | ||||
| <result column="coupon_inject_id" jdbcType="BIGINT" property="couponInjectId" /> | <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> | </resultMap> | ||||
| <sql id="allColumns"> | <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> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -74,16 +74,7 @@ | |||||
| from wx_msg_model | from wx_msg_model | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </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 id="updateByCode" parameterType="com.iformall.domain.po.WxMsgModel"> | ||||
| update wx_msg_model set status=#{status},reason=#{reason} where `model_code` = #{modelCode} | update wx_msg_model set status=#{status},reason=#{reason} where `model_code` = #{modelCode} | ||||
| </update> | </update> | ||||