| @@ -1,6 +1,6 @@ | |||||
| spring: | spring: | ||||
| profiles: | profiles: | ||||
| include: rocketMQ | |||||
| include: rabbitMQ | |||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| url: jdbc:mysql://202.165.179.86:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false | url: jdbc:mysql://202.165.179.86:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false | ||||
| @@ -9,7 +9,6 @@ import com.iformall.service.impl.SendEmailServiceImpl; | |||||
| import com.iformall.service.impl.SendSmartAppMsgServiceImpl; | import com.iformall.service.impl.SendSmartAppMsgServiceImpl; | ||||
| import com.iformall.service.impl.SendSmsServiceImpl; | import com.iformall.service.impl.SendSmsServiceImpl; | ||||
| import com.iformall.utils.JsonUtil; | import com.iformall.utils.JsonUtil; | ||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -18,7 +17,6 @@ import org.springframework.stereotype.Service; | |||||
| /** | /** | ||||
| * 消息消费入口 | * 消息消费入口 | ||||
| */ | */ | ||||
| @Slf4j | |||||
| @Service | @Service | ||||
| public class MqBaseConsumer { | public class MqBaseConsumer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | private final Logger log = LoggerFactory.getLogger(this.getClass()); | ||||
| @@ -35,10 +33,9 @@ public class MqBaseConsumer { | |||||
| public void doMessage(String message) { | public void doMessage(String message) { | ||||
| log.info("received message: {}", message); | log.info("received message: {}", message); | ||||
| BaseMsg baseMsg = null; | BaseMsg baseMsg = null; | ||||
| try { | try { | ||||
| log.info("received message: {}", message); | |||||
| baseMsg = (BaseMsg)JsonUtil.readValue(message,BaseMsg.class); | baseMsg = (BaseMsg)JsonUtil.readValue(message,BaseMsg.class); | ||||
| if(EnumMsgRecordType.SMS.getCode().equals(baseMsg.getMsgType())){ | if(EnumMsgRecordType.SMS.getCode().equals(baseMsg.getMsgType())){ | ||||
| @@ -54,7 +51,6 @@ public class MqBaseConsumer { | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); | baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); | ||||
| wxMsgRecordMapper.update(baseMsg); | wxMsgRecordMapper.update(baseMsg); | ||||
| }catch (Exception e){ | }catch (Exception e){ | ||||
| e.printStackTrace(); | |||||
| if(null != baseMsg){ | if(null != baseMsg){ | ||||
| baseMsg.setStatusMessage(e.getMessage()); | baseMsg.setStatusMessage(e.getMessage()); | ||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | ||||
| @@ -18,7 +18,7 @@ public class BaseMsg implements Serializable { | |||||
| //消息状态 0默认1发送成功2消费成功3消费失败 | //消息状态 0默认1发送成功2消费成功3消费失败 | ||||
| private Integer msgStatus; | private Integer msgStatus; | ||||
| //消费结果信息 | |||||
| //结果信息 | |||||
| private String statusMessage; | private String statusMessage; | ||||
| @@ -45,7 +45,6 @@ public class WxMsgRecord extends BaseMsg { | |||||
| //动态替换内容 | //动态替换内容 | ||||
| private Map<String,String> dynamicContentMap; | private Map<String,String> dynamicContentMap; | ||||
| private String dynamicContent; | |||||
| public String getMsgJson() { | public String getMsgJson() { | ||||
| @@ -65,13 +64,6 @@ public class WxMsgRecord extends BaseMsg { | |||||
| this.dynamicContentMap = dynamicContentMap; | this.dynamicContentMap = dynamicContentMap; | ||||
| } | } | ||||
| public String getDynamicContent() { | |||||
| return dynamicContent; | |||||
| } | |||||
| public void setDynamicContent(String dynamicContent) { | |||||
| this.dynamicContent = dynamicContent; | |||||
| } | |||||
| public Long getId() { | public Long getId() { | ||||
| return id; | return id; | ||||
| @@ -8,6 +8,7 @@ public enum EnumMsgRecordStatus { | |||||
| SEND_SUCC(1, "发送成功"), | SEND_SUCC(1, "发送成功"), | ||||
| CONSUME_SUCC(2, "消费成功"), | CONSUME_SUCC(2, "消费成功"), | ||||
| CONSUME_FAIL(3, "消费失败"), | CONSUME_FAIL(3, "消费失败"), | ||||
| ; | ; | ||||
| public static EnumMsgRecordStatus getEnum(Integer code) { | public static EnumMsgRecordStatus getEnum(Integer code) { | ||||
| @@ -24,7 +24,6 @@ import java.util.UUID; | |||||
| * @Description: RocketMQ消息生产者 | * @Description: RocketMQ消息生产者 | ||||
| */ | */ | ||||
| @Service | @Service | ||||
| @Slf4j | |||||
| @Profile(MQConfig.Impl.RABBIT_MQ) | @Profile(MQConfig.Impl.RABBIT_MQ) | ||||
| public class RabbitMqMessageProducer implements MqBaseProducer { | public class RabbitMqMessageProducer implements MqBaseProducer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | private final Logger log = LoggerFactory.getLogger(this.getClass()); | ||||
| @@ -30,7 +30,6 @@ import java.util.UUID; | |||||
| * @Description: RocketMQ消息生产者 | * @Description: RocketMQ消息生产者 | ||||
| */ | */ | ||||
| @Service | @Service | ||||
| @Slf4j | |||||
| @Profile(MQConfig.Impl.ROCKET_MQ) | @Profile(MQConfig.Impl.ROCKET_MQ) | ||||
| public class RocketMqMessageProducer implements MqBaseProducer { | public class RocketMqMessageProducer implements MqBaseProducer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | private final Logger log = LoggerFactory.getLogger(this.getClass()); | ||||
| @@ -70,8 +69,8 @@ public class RocketMqMessageProducer implements MqBaseProducer { | |||||
| @Override | @Override | ||||
| public void onSuccess(SendResult sendResult) { | public void onSuccess(SendResult sendResult) { | ||||
| log.info("Message Producer: Send Message Success {}", sendResult); | log.info("Message Producer: Send Message Success {}", sendResult); | ||||
| // data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | |||||
| // wxMsgRecordMapper.update(data); | |||||
| data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | |||||
| wxMsgRecordMapper.update(data); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -13,11 +13,8 @@ import com.iformall.service.WxMsgService; | |||||
| import com.iformall.service.WxMsgValidationcodeService; | import com.iformall.service.WxMsgValidationcodeService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import com.iformall.utils.WiwideUtil; | import com.iformall.utils.WiwideUtil; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.List; | import java.util.List; | ||||
| /** | /** | ||||
| @@ -26,7 +23,6 @@ import java.util.List; | |||||
| */ | */ | ||||
| @Service | @Service | ||||
| public class SendCallBackSmsServiceImpl implements MsgSendService { | public class SendCallBackSmsServiceImpl implements MsgSendService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | @Autowired | ||||
| private WxMsgConfigMapper wxMsgConfigMapper; | private WxMsgConfigMapper wxMsgConfigMapper; | ||||
| @Autowired | @Autowired | ||||
| @@ -116,8 +112,7 @@ public class SendCallBackSmsServiceImpl implements MsgSendService { | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | ||||
| wxMsgService.addMsgCallback(wxMsg, batchNo); | wxMsgService.addMsgCallback(wxMsg, batchNo); | ||||
| } else { | } else { | ||||
| logger.error("SendCallBackSmsServiceImpl 运营商返回失败,wxmsg.id:{},message:{}",id,result); | |||||
| throw new MallinkException(ErrorCode.MSG_SEND_INTERFACE_ERROR); | |||||
| throw new MallinkException(1001,"运营商返回失败:"+result); | |||||
| } | } | ||||
| } | } | ||||
| @@ -44,7 +44,6 @@ public class SendEmailServiceImpl implements MsgSendService { | |||||
| helper.setText(mailMsg.getMsg(), true); | helper.setText(mailMsg.getMsg(), true); | ||||
| sender.send(message); | sender.send(message); | ||||
| logger.info("html邮件已经发送。"); | |||||
| }else if(StringUtils.isNotBlank(mailMsg.getFilePath())){ | }else if(StringUtils.isNotBlank(mailMsg.getFilePath())){ | ||||
| MimeMessage message = sender.createMimeMessage(); | MimeMessage message = sender.createMimeMessage(); | ||||
| String filePath = mailMsg.getFilePath(); | String filePath = mailMsg.getFilePath(); | ||||
| @@ -59,7 +58,6 @@ public class SendEmailServiceImpl implements MsgSendService { | |||||
| helper.addAttachment(fileName, file); | helper.addAttachment(fileName, file); | ||||
| sender.send(message); | sender.send(message); | ||||
| logger.info("带附件的邮件已经发送。"); | |||||
| }else if(StringUtils.isNotBlank(mailMsg.getRscI()) && StringUtils.isNotBlank(mailMsg.getRscPath())){ | }else if(StringUtils.isNotBlank(mailMsg.getRscI()) && StringUtils.isNotBlank(mailMsg.getRscPath())){ | ||||
| MimeMessage message = sender.createMimeMessage(); | MimeMessage message = sender.createMimeMessage(); | ||||
| MimeMessageHelper helper = new MimeMessageHelper(message, true); | MimeMessageHelper helper = new MimeMessageHelper(message, true); | ||||
| @@ -72,7 +70,6 @@ public class SendEmailServiceImpl implements MsgSendService { | |||||
| helper.addInline(mailMsg.getRscI(), res); | helper.addInline(mailMsg.getRscI(), res); | ||||
| sender.send(message); | sender.send(message); | ||||
| logger.info("嵌入静态资源的邮件已经发送。"); | |||||
| }else{ | }else{ | ||||
| SimpleMailMessage message = new SimpleMailMessage(); | SimpleMailMessage message = new SimpleMailMessage(); | ||||
| message.setFrom(from); | message.setFrom(from); | ||||
| @@ -98,9 +98,8 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| } | } | ||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | ||||
| wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode,batchNo); | wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode,batchNo); | ||||
| logger.error("短信运营商返回成功,手机号:{}",phone); | |||||
| }else{ | }else{ | ||||
| logger.error("短信运营商返回失败,手机号:{},返回信息:{}",phone,result); | |||||
| throw new MallinkException(1001,"运营商返回失败:"+result); | |||||
| } | } | ||||
| } | } | ||||
| @@ -23,9 +23,7 @@ public class WxMsgRecordServiceImpl implements WxMsgRecordService { | |||||
| data.setUuid(UUID.randomUUID().toString()); | data.setUuid(UUID.randomUUID().toString()); | ||||
| if(data instanceof WxMsgRecord){ | if(data instanceof WxMsgRecord){ | ||||
| WxMsgRecord msgRecord = (WxMsgRecord)data; | WxMsgRecord msgRecord = (WxMsgRecord)data; | ||||
| if(msgRecord.getDynamicContentMap() != null && msgRecord.getDynamicContentMap().size() > 0) { | |||||
| msgRecord.setDynamicContent(JsonUtil.obj2Json(msgRecord.getDynamicContentMap())); | |||||
| } | |||||
| msgRecord.setMsgJson(JsonUtil.obj2Json(data)); | |||||
| wxMsgRecordMapper.insertSelective(msgRecord); | wxMsgRecordMapper.insertSelective(msgRecord); | ||||
| }else if(data instanceof WxMsg || data instanceof MailMsg){ | }else if(data instanceof WxMsg || data instanceof MailMsg){ | ||||
| WxMsgRecord msgRecord = new WxMsgRecord(); | WxMsgRecord msgRecord = new WxMsgRecord(); | ||||
| @@ -22,7 +22,6 @@ | |||||
| <result column="uuid" property="uuid" /> | <result column="uuid" property="uuid" /> | ||||
| <result column="signature" property="signature" /> | <result column="signature" property="signature" /> | ||||
| <result column="model_type" property="modelType" /> | <result column="model_type" property="modelType" /> | ||||
| <result column="dynamic_content" property="dynamicContent" /> | |||||
| <result column="msg_json" property="msgJson" /> | <result column="msg_json" property="msgJson" /> | ||||
| @@ -30,7 +29,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| id,tenant_id,domain,msg_type,msg,send_time,model_id,sender,sender_user_id,sender_user_name,receiver,receiver_user_id, | id,tenant_id,domain,msg_type,msg,send_time,model_id,sender,sender_user_id,sender_user_name,receiver,receiver_user_id, | ||||
| receiver_user_name,msg_status,status_message,createtime,updatetime,uuid,signature,model_type,dynamic_content,msg_json | |||||
| receiver_user_name,msg_status,status_message,createtime,updatetime,uuid,signature,model_type,msg_json | |||||
| </sql> | </sql> | ||||
| @@ -70,7 +69,6 @@ | |||||
| <if test=" null != statusMessage ">,status_message = #{statusMessage}</if> | <if test=" null != statusMessage ">,status_message = #{statusMessage}</if> | ||||
| <where> | <where> | ||||
| <if test=" null != uuid ">and uuid = #{uuid}</if> | <if test=" null != uuid ">and uuid = #{uuid}</if> | ||||
| <if test=" null != id ">and id = #{id}</if> | |||||
| </where> | </where> | ||||
| </update> | </update> | ||||