SendMessageHelper.java
2.91 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
package com.yoho.unions.helper;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.product.ISendProductMessage;
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.HashMap;
import java.util.Map;
/**
* 公众号消息推送
* Created by mingdan.ge on 2018/9/19.
*/
@Component
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");//申请成功提醒
// }};
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 (type < 1 || type > 4) {
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 {
String timeStr = DateUtil.long2DateStr(time * 1000, DateUtil.DATE_TIME_FORMAT);
System.out.println(timeStr);
SendMessageRspBo sendMessageRspBo=null;
if (type == 1) {
//预估佣金提醒
sendMessageRspBo=iSendProductMessage.estimateNotice(Integer.toString(uid), amount.toString(),timeStr );
}
if (type == 2) {
//提现打款提醒
sendMessageRspBo=iSendProductMessage.cashAccountNotice(Integer.toString(uid), amount.toString(), timeStr);
}
if (type == 3) {
//可结算提醒
sendMessageRspBo=iSendProductMessage.commissionNotice(Integer.toString(uid), amount.toString(), timeStr);
}
if (type == 4) {
//申请成功提醒
sendMessageRspBo=iSendProductMessage.joinSuccessNotice(Integer.toString(uid), timeStr);
}
log.info("sendMessage enter,uid is {},type is {},time is {},amount is {},sendMessageRspBo is {}.",uid,type,time,sendMessageRspBo);
} catch (Exception e) {
log.error("sendMessage error,e is {}.",e);
}
}
}