|
|
|
@ -7,6 +7,8 @@ import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.openim.beans.OpenimUserVO;
|
|
|
|
|
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
|
|
|
|
|
import au.com.royalpay.payment.manage.openim.core.OpenimApi;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
|
|
|
|
@ -20,7 +22,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
@ -41,6 +45,9 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysCustomerServiceMapper sysCustomerServiceMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private MpWechatApiProvider mpWechatApiProvider;
|
|
|
|
|
private final Map<String,Long> unReadMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
@Value("${im.openim.appkey}")
|
|
|
|
|
private String appkey;
|
|
|
|
@ -130,6 +137,44 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
|
|
|
|
|
udpateOrSave(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addUnreadMsg(JSONObject params) {
|
|
|
|
|
String key = params.getString("uid");
|
|
|
|
|
if(unReadMap.containsKey(key)) {
|
|
|
|
|
unReadMap.put(key, unReadMap.get(key) + 1);
|
|
|
|
|
}else {
|
|
|
|
|
unReadMap.put(key,1L);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendUnreadWxMsg() {
|
|
|
|
|
unReadMap.entrySet().parallelStream().forEach(p->{
|
|
|
|
|
JSONObject account = clientAccountMapper.findByUsername(p.getKey());
|
|
|
|
|
if(StringUtils.isNotEmpty(account.getString("wx_openid"))){
|
|
|
|
|
// TemplateMessage msg = initAccountMsg(tradeInfo, client.getString("short_name"), time, String.valueOf(counts), openId, paymentApi.getTemplateId("transaction-daily"));
|
|
|
|
|
// MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
// paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
}
|
|
|
|
|
p.getKey();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TemplateMessage initAccountMsg(JSONObject tradeInfo, String short_name, String time, String clientCounts, String openId, String templateId) {
|
|
|
|
|
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(openId, templateId, null);
|
|
|
|
|
String detail = "收款总额:" + tradeInfo.getBigDecimal("total") + "$, 收款笔数:" + tradeInfo.getString("orders") + ", 付款人数:" + tradeInfo.getString("customers");
|
|
|
|
|
msg.put("first", "每日交易汇总数据(" + tradeInfo.getString("trade_date") + ")", "#000000");
|
|
|
|
|
msg.put("keyword1", short_name, "#000000");
|
|
|
|
|
msg.put("keyword2", time, "#000000");
|
|
|
|
|
msg.put("keyword3", clientCounts + "家", "#000000");
|
|
|
|
|
msg.put("keyword4", detail, "#0000ff");
|
|
|
|
|
msg.put("remark", "详情请查看商户后台、APP或皇家支付小程序", "#000000");
|
|
|
|
|
msg.setMiniprogram("wx54445a7c56432d57", "/pages/welcome/welcome");
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void udpateOrSave(JSONObject servant){
|
|
|
|
|
JSONObject record = sysCustomerServiceMapper.findByManagerId(servant.getString("manager_id"));
|
|
|
|
|
if(record==null){
|
|
|
|
|