BusinessNoticeBiz.java
10.3 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package com.cjs.cms.biz.user;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cjs.cms.dao.user.BusinessNoticeDao;
import com.cjs.cms.dao.user.WeixinDao;
import com.cjs.cms.model.user.BusinessNoticeInfo;
import com.cjs.cms.model.user.WxUserInfo;
import com.cjs.cms.util.lang.DateEnum;
import com.cjs.cms.util.lang.DateUtil;
import com.cjs.cms.util.web.SendMessageUtil;
/**
* 微信业务通知
* @author kongmingke
*
*/
@Service
public class BusinessNoticeBiz {
@Autowired
private BusinessNoticeDao noticeDao;
@Autowired
private WeixinDao weixinDao;
@Autowired
private SendMessageUtil sendMsg;
@Autowired
private WeiXinBiz weiXinBiz;
Logger log = LogManager.getLogger();
/**
* 托管鉴定发送微信通知
*/
public void sendNotice() {
List<Map<String, Object>> noticeInfos = noticeDao.queryNotice();
if (noticeInfos != null && noticeInfos.size() > 0) {
for (Map<String, Object> map : noticeInfos) {
//添加鉴定通知信息表
BusinessNoticeInfo info = new BusinessNoticeInfo();
WxUserInfo wxUserInfo = weixinDao.queryByUserId(map.get("FUND_ACCOUNT").toString());
if (wxUserInfo != null) {
try {
Map<String, String> noticeInfo = new HashMap<String, String>();
noticeInfo.put("openId", wxUserInfo.getOpenId());
noticeInfo.put("applyNo", map.get("APPLY_NO").toString());
noticeInfo.put("applyCount", map.get("APPLY_COUNT").toString());
noticeInfo.put("approvalCount", map.get("APPROVAL_COUNT").toString());
noticeInfo.put("backAmount", map.get("BACK_AMOUNT").toString());
weiXinBiz.postTemplate(noticeInfo,
"/template/trustapplyInfo?openId={openId}&applyNo={applyNo}&applyCount={applyCount}&approvalCount={approvalCount}&backAmount={backAmount}");
info.setNoticeType("0");
info.setNoticeStatus("1");
info.setNoticeContent("您好,您托管的藏品已鉴评完毕!预约号:" + map.get("APPLY_NO") + ",交付数量:"
+ map.get("APPLY_COUNT") + ",通过数量:"
+ map.get("APPROVAL_COUNT") + ",未通过数量:"
+ map.get("BACK_AMOUNT")
+ ",详情可登录官网进行查询。官网地址:www.zhao.com");
} catch (Exception e) {
info.setNoticeStatus("0");
log.error("", e);
}
} else {
int result = sendMsg.send(map.get("TELPHONE")
.toString(), "您托管的" + map.get("OTC_NAME")
+ "已鉴评完毕,即日起关注官方微信或登陆官网会员中心查看详情。如有疑问详询4009690800");
info.setNoticeType("1");
info.setNoticeStatus("1");
info.setNoticeContent("您托管的" + map.get("OTC_NAME")
+ "已鉴评完毕,即日起关注官方微信或登陆官网会员中心查看详情。如有疑问详询4009690800");
}
info.setBusinessKey(map.get("APPLY_NO").toString());
info.setBusinessType("10");
info.setNoticeDate(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE)));
info.setNoticeTime(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_TIME)));
try {
noticeDao.insertNotice(info);
} catch (Exception e) {
log.error("", e);
}
}
}
}
/**
* 出金发送微信通知
*/
public void outNotice() {
//出金
Map<String, Object> params = new HashMap<String, Object>();
params.put("businessFlag", 2042);
params.put("businessType", "12");
List<Map<String, Object>> outInfos = noticeDao.queryOutOrPay(params);
if (outInfos != null && outInfos.size() > 0) {
for (Map<String, Object> map : outInfos) {
//添加鉴定通知信息表
BusinessNoticeInfo info = new BusinessNoticeInfo();
log.info(map);
log.info("当前出金用户账号" + map.get("CLIENT_ID").toString());
WxUserInfo wxUserInfo = weixinDao.queryByUserId(map.get("CLIENT_ID").toString());
log.info("微信绑定用户账号" + wxUserInfo);
if (wxUserInfo != null) {
log.info("微信用户已绑定");
try {
Map<String, String> noticeInfo = new HashMap<String, String>();
noticeInfo.put("openId", wxUserInfo.getOpenId());
noticeInfo.put("userId", map.get("CLIENT_ID").toString());
noticeInfo.put("occurBalance", map.get("OCCUR_BALANCE").toString());
noticeInfo.put("postBalance", map.get("POST_BALANCE").toString());
weiXinBiz.postTemplate(noticeInfo,
"/template/outInfo?openId={openId}&userId={userId}&occurBalance={occurBalance}&postBalance={postBalance}");
log.info("出金微信模板发送成功");
info.setNoticeType("0");
info.setNoticeStatus("1");
info.setNoticeContent("您好,您的出金已受理!出金账号:" + map.get("CLIENT_ID") + ",出金金额:"
+ map.get("OCCUR_BALANCE") + ",账户余额:"
+ map.get("POST_BALANCE")
+ ",提现金额会在第二个工作日下午14点前到账,请注意查看!");
} catch (Exception e) {
info.setNoticeStatus("0");
log.error("", e);
}
info.setBusinessKey(map.get("POSITION_STR").toString());
info.setBusinessType("12");
info.setNoticeDate(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE)));
info.setNoticeTime(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_TIME)));
try {
noticeDao.insertNotice(info);
} catch (Exception e) {
log.error("", e);
}
}
/*else {
int result = sendMsg.send(map.get("TELPHONE").toString(),
"您的出金已经受理,即日起关注官方微信或登陆官网会员中心查看详情。如有疑问详询4009690800");
info.setNoticeType("1");
info.setNoticeStatus("1");
info.setNoticeContent("您的出金已经受理,即日起关注官方微信或登陆官网会员中心查看详情。如有疑问详询4009690800");
}*/
}
}
}
/**
* 入金发送微信通知
*/
public void payNotice() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("businessFlag", 2041);
params.put("businessType", "11");
List<Map<String, Object>> payInfos = noticeDao.queryOutOrPay(params);
if (payInfos != null && payInfos.size() > 0) {
for (Map<String, Object> map : payInfos) {
//添加微信通知信息表
BusinessNoticeInfo info = new BusinessNoticeInfo();
WxUserInfo wxUserInfo = weixinDao.queryByUserId(map.get("CLIENT_ID").toString());
if (wxUserInfo != null) {
try {
Map<String, String> noticeInfo = new HashMap<String, String>();
noticeInfo.put("openId", wxUserInfo.getOpenId());
noticeInfo.put("userId", map.get("CLIENT_ID").toString());
noticeInfo.put("occurBalance", map.get("OCCUR_BALANCE").toString());
noticeInfo.put("postBalance", map.get("POST_BALANCE").toString());
weiXinBiz.postTemplate(noticeInfo,
"/template/paySave?openId={openId}&userId={userId}&occurBalance={occurBalance}&postBalance={postBalance}");
info.setNoticeType("0");
info.setNoticeStatus("1");
info.setNoticeContent("您好,您的入金已成功!入金账号:" + map.get("CLIENT_ID") + ",入金金额:"
+ map.get("OCCUR_BALANCE") + ",账户余额:"
+ map.get("POST_BALANCE")
+ ",详情可登录官网或者客户单进行查询。官网地址:www.zhao.com!");
} catch (Exception e) {
info.setNoticeStatus("0");
log.error("", e);
}
info.setBusinessKey(map.get("POSITION_STR").toString());
info.setBusinessType("11");
info.setNoticeDate(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE)));
info.setNoticeTime(
Integer.parseInt(DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_TIME)));
try {
noticeDao.insertNotice(info);
} catch (Exception e) {
log.error("", e);
}
}
}
}
}
}