Authored by mingdan.ge

消息发送调用方式更改

@@ -97,5 +97,10 @@ @@ -97,5 +97,10 @@
97 <artifactId>yoho-message-sdk</artifactId> 97 <artifactId>yoho-message-sdk</artifactId>
98 <version>1.0.4-SNAPSHOT</version> 98 <version>1.0.4-SNAPSHOT</version>
99 </dependency> 99 </dependency>
  100 + <dependency>
  101 + <groupId>com.yoho.dsf</groupId>
  102 + <artifactId>yoho-msgcenter-sdk</artifactId>
  103 + <version>1.0.3-SNAPSHOT</version>
  104 + </dependency>
100 </dependencies> 105 </dependencies>
101 </project> 106 </project>
1 package com.yoho.unions.helper; 1 package com.yoho.unions.helper;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 -import com.rabbitmq.tools.json.JSONUtil;  
5 import com.yoho.core.common.utils.JsonUtil; 4 import com.yoho.core.common.utils.JsonUtil;
6 -import com.yoho.message.sdk.common.model.SendMessageRspBo;  
7 -import com.yoho.message.sdk.service.product.ISendProductMessage; 5 +import com.yoho.msgcenter.sdk.dto.MessageCenterEvent;
  6 +import com.yoho.msgcenter.sdk.handler.IMsgCenterHandler;
8 import com.yoho.unions.common.utils.DateUtil; 7 import com.yoho.unions.common.utils.DateUtil;
9 import org.slf4j.Logger; 8 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
@@ -12,8 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -12,8 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
13 12
14 import java.math.BigDecimal; 13 import java.math.BigDecimal;
15 -import java.util.HashMap;  
16 -import java.util.Map; 14 +import java.util.Arrays;
17 15
18 /** 16 /**
19 * 公众号消息推送 17 * 公众号消息推送
@@ -24,15 +22,7 @@ public class SendMessageHelper { @@ -24,15 +22,7 @@ public class SendMessageHelper {
24 static Logger log = LoggerFactory.getLogger(SendMessageHelper.class); 22 static Logger log = LoggerFactory.getLogger(SendMessageHelper.class);
25 23
26 @Autowired 24 @Autowired
27 - ISendProductMessage iSendProductMessage;  
28 -  
29 - //模版ID  
30 -// static Map<Integer, String> keyMap = new HashMap<Integer, String>(){{  
31 -// put(1,"AyIBF3VgCkk4V4s4NIuNmjcIe5IUeufmlMXv0oxcj74");//每日新产生佣金提醒  
32 -// put(2,"9nUlr41s8vvOgKZ-xA5_VV_Gqs-868_KxdRzDziYTa4");//提现打款提醒  
33 -// put(3,"IE7sO6J-r1iEd-G6dmuFaN64Qnk9lqJFmsBpO1YACWs");//可结算提醒  
34 -// put(4,"QtoMH65mEHuDYMAtNKLSrIxQKqNNdDLDl_dMOY1cHhw");//申请成功提醒  
35 -// }}; 25 + private IMsgCenterHandler msgHandler;
36 26
37 public void sendMessage(int uid, int type, int time, BigDecimal amount) { 27 public void sendMessage(int uid, int type, int time, BigDecimal amount) {
38 log.info("sendMessage enter,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount); 28 log.info("sendMessage enter,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
@@ -40,31 +30,39 @@ public class SendMessageHelper { @@ -40,31 +30,39 @@ public class SendMessageHelper {
40 log.info("sendMessage end,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount); 30 log.info("sendMessage end,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
41 return; 31 return;
42 } 32 }
43 -// String key = keyMap.get(type);  
44 -// if (key == null) {  
45 -// log.info("sendMessage end,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);  
46 -// return;  
47 -// }  
48 try { 33 try {
  34 + MessageCenterEvent centerEvent = new MessageCenterEvent();
  35 + centerEvent.setBusinessLine("yohobuy");
  36 + centerEvent.setUserType("UID");
  37 + centerEvent.setUserList(Arrays.asList(Integer.toString(uid)));
  38 + JSONObject params = new JSONObject();
49 String timeStr = DateUtil.long2DateStr(Long.valueOf(time) * 1000, DateUtil.DATE_TIME_FORMAT); 39 String timeStr = DateUtil.long2DateStr(Long.valueOf(time) * 1000, DateUtil.DATE_TIME_FORMAT);
50 - SendMessageRspBo sendMessageRspBo=null;  
51 if (type == 1) { 40 if (type == 1) {
52 //预估佣金提醒 41 //预估佣金提醒
53 - sendMessageRspBo=iSendProductMessage.estimateNotice(Integer.toString(uid), amount.toString(),timeStr ); 42 + centerEvent.setSendScene("YZ_ESTIMATE_SETTLE");
  43 + params.put("orderAmount", amount);
  44 + params.put("nowTime", timeStr);
54 } 45 }
55 if (type == 2) { 46 if (type == 2) {
56 //提现打款提醒 47 //提现打款提醒
57 - sendMessageRspBo=iSendProductMessage.cashAccountNotice(Integer.toString(uid), amount.toString(), timeStr); 48 + centerEvent.setSendScene("YZ_CRASH_ACCOUNT");
  49 + params.put("orderAmount", amount);
  50 + params.put("crashTime", timeStr);
58 } 51 }
59 if (type == 3) { 52 if (type == 3) {
60 //可结算提醒 53 //可结算提醒
61 - sendMessageRspBo=iSendProductMessage.commissionNotice(Integer.toString(uid), amount.toString(), timeStr); 54 + centerEvent.setSendScene("YZ_COMMISSION_SETTLE");
  55 + params.put("orderAmount", amount);
  56 + params.put("crashTime", timeStr);
62 } 57 }
63 if (type == 4) { 58 if (type == 4) {
64 //申请成功提醒 59 //申请成功提醒
65 - sendMessageRspBo=iSendProductMessage.joinSuccessNotice(Integer.toString(uid), timeStr); 60 + centerEvent.setSendScene("YZ_JOIN_SUCCESS");
  61 + params.put("passTime", timeStr);
66 } 62 }
67 - log.info("sendMessage end,uid is {},type is {},time is {},amount is {},sendMessageRspBo is {}.",uid,type,timeStr,amount, JsonUtil.objectToJSON(sendMessageRspBo)); 63 + centerEvent.setParams(params);
  64 + msgHandler.send(centerEvent);
  65 + log.info("sendMessage end,uid is {},type is {},time is {},amount is {},centerEvent is {}.",uid,type,timeStr,amount, JsonUtil.objectToJSON(centerEvent));
68 } catch (Exception e) { 66 } catch (Exception e) {
69 log.error("sendMessage error,e is {}.",e); 67 log.error("sendMessage error,e is {}.",e);
70 } 68 }