SendMessageHelper.java
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.yoho.unions.helper;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.JsonUtil;
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Arrays;
/**
* 公众号消息推送
* Created by mingdan.ge on 2018/9/19.
*/
@Component
public class SendMessageHelper {
static Logger log = LoggerFactory.getLogger(SendMessageHelper.class);
@Autowired
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);
if (1==1) {
//关闭推手项目所有消息推送
log.info("sendMessage close,type error,uid is {},type is {},time is {},amount is {}.",uid,type,time,amount);
return;
}
if (type < 1 || type > 5) {
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.setSecurityKey("1a15a75d-b30f-4d74-a791-d654647a8c77");
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);
if (type == 1) {
//预估佣金提醒
centerEvent.setSendScene("YZ_ESTIMATE_SETTLE");
params.put("orderAmount", amount);
params.put("nowTime", timeStr);
}
if (type == 2) {
//提现打款提醒
centerEvent.setSendScene("YZ_CRASH_ACCOUNT");
params.put("orderAmount", amount);
params.put("crashTime", timeStr);
}
if (type == 3) {
//可结算提醒
centerEvent.setSendScene("YZ_COMMISSION_SETTLE");
params.put("orderAmount", amount);
params.put("crashTime", timeStr);
}
if (type == 4) {
//申请成功提醒
centerEvent.setSendScene("YZ_JOIN_SUCCESS");
params.put("passTime", timeStr);
}
if (type == 5) {
//申请成功提醒
centerEvent.setSendScene("YZ_ID_CARD_REVIEW");
params.put("reviewDate", timeStr);
centerEvent.setSecurityKey("8f22150f-1fb2-461b-8f92-ee45698f1a19");
}
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);
}
}
}