Authored by mingdan.ge

消息发送调用方式更改

... ... @@ -97,5 +97,10 @@
<artifactId>yoho-message-sdk</artifactId>
<version>1.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-msgcenter-sdk</artifactId>
<version>1.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
... ...
package com.yoho.unions.helper;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.tools.json.JSONUtil;
import com.yoho.core.common.utils.JsonUtil;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.product.ISendProductMessage;
import com.yoho.msgcenter.sdk.dto.MessageCenterEvent;
import com.yoho.msgcenter.sdk.handler.IMsgCenterHandler;
import com.yoho.unions.common.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -12,8 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
/**
* 公众号消息推送
... ... @@ -24,15 +22,7 @@ public class SendMessageHelper {
static Logger log = LoggerFactory.getLogger(SendMessageHelper.class);
@Autowired
ISendProductMessage iSendProductMessage;
//模版ID
// static Map<Integer, String> keyMap = new HashMap<Integer, String>(){{
// put(1,"AyIBF3VgCkk4V4s4NIuNmjcIe5IUeufmlMXv0oxcj74");//每日新产生佣金提醒
// put(2,"9nUlr41s8vvOgKZ-xA5_VV_Gqs-868_KxdRzDziYTa4");//提现打款提醒
// put(3,"IE7sO6J-r1iEd-G6dmuFaN64Qnk9lqJFmsBpO1YACWs");//可结算提醒
// put(4,"QtoMH65mEHuDYMAtNKLSrIxQKqNNdDLDl_dMOY1cHhw");//申请成功提醒
// }};
private IMsgCenterHandler msgHandler;
public void sendMessage(int uid, int type, int time, BigDecimal amount) {
log.info("sendMessage enter,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
... ... @@ -40,31 +30,39 @@ public class SendMessageHelper {
log.info("sendMessage end,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
return;
}
// String key = keyMap.get(type);
// if (key == null) {
// log.info("sendMessage end,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
// return;
// }
try {
MessageCenterEvent centerEvent = new MessageCenterEvent();
centerEvent.setBusinessLine("yohobuy");
centerEvent.setUserType("UID");
centerEvent.setUserList(Arrays.asList(Integer.toString(uid)));
JSONObject params = new JSONObject();
String timeStr = DateUtil.long2DateStr(Long.valueOf(time) * 1000, DateUtil.DATE_TIME_FORMAT);
SendMessageRspBo sendMessageRspBo=null;
if (type == 1) {
//预估佣金提醒
sendMessageRspBo=iSendProductMessage.estimateNotice(Integer.toString(uid), amount.toString(),timeStr );
centerEvent.setSendScene("YZ_ESTIMATE_SETTLE");
params.put("orderAmount", amount);
params.put("nowTime", timeStr);
}
if (type == 2) {
//提现打款提醒
sendMessageRspBo=iSendProductMessage.cashAccountNotice(Integer.toString(uid), amount.toString(), timeStr);
centerEvent.setSendScene("YZ_CRASH_ACCOUNT");
params.put("orderAmount", amount);
params.put("crashTime", timeStr);
}
if (type == 3) {
//可结算提醒
sendMessageRspBo=iSendProductMessage.commissionNotice(Integer.toString(uid), amount.toString(), timeStr);
centerEvent.setSendScene("YZ_COMMISSION_SETTLE");
params.put("orderAmount", amount);
params.put("crashTime", timeStr);
}
if (type == 4) {
//申请成功提醒
sendMessageRspBo=iSendProductMessage.joinSuccessNotice(Integer.toString(uid), timeStr);
centerEvent.setSendScene("YZ_JOIN_SUCCESS");
params.put("passTime", timeStr);
}
log.info("sendMessage end,uid is {},type is {},time is {},amount is {},sendMessageRspBo is {}.",uid,type,timeStr,amount, JsonUtil.objectToJSON(sendMessageRspBo));
centerEvent.setParams(params);
msgHandler.send(centerEvent);
log.info("sendMessage end,uid is {},type is {},time is {},amount is {},centerEvent is {}.",uid,type,timeStr,amount, JsonUtil.objectToJSON(centerEvent));
} catch (Exception e) {
log.error("sendMessage error,e is {}.",e);
}
... ...