master
kira 6 years ago
parent 89d1d26a4a
commit a0e0827bc4

@ -150,7 +150,9 @@ public interface RetailAppService {
JSONObject sendVerifyEmail(JSONObject device);
void openimCheck(JSONObject device);
JSONObject openimCheck(JSONObject device);
void addUnreadMsg(JSONObject device,JSONObject param);
JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean);

@ -417,9 +417,14 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
public void openimCheck(JSONObject device) {
public JSONObject openimCheck(JSONObject device) {
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
customerServiceService.checkAndSave(account);
return customerServiceService.checkAndSave(account);
}
@Override
public void addUnreadMsg(JSONObject device, JSONObject param) {
customerServiceService.addUnreadMsg(param);
}
@Override

@ -545,7 +545,12 @@ public class RetailAppController {
}
@RequestMapping(value = "/openim/check",method = RequestMethod.POST)
public void openimCheck(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
public JSONObject openimCheck(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
return retailAppService.openimCheck(device);
}
@RequestMapping(value = "/openim/chat",method = RequestMethod.POST)
public void openimChat(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject param) {
retailAppService.openimCheck(device);
}

@ -20,4 +20,8 @@ public interface CustomerServiceService {
void onoff(JSONObject manager,boolean status);
void addUnreadMsg(JSONObject params);
void sendUnreadWxMsg();
}

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -30,8 +29,6 @@ import java.util.List;
*/
@Service
public class OpenimClient {
Logger logger = LoggerFactory.getLogger(getClass());
@Value("${im.openim.appkey}")
private String appkey;
@ -113,28 +110,4 @@ public class OpenimClient {
throw new ServerErrorException("System error");
}
}
public static void main(String[] args) {
String appkey = "24960261";
String secret = "7639427973bd671be15c9d0c1e9c90b4";
String url = "https://eco.taobao.com/router/rest";
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
List<Userinfos> list2 = new ArrayList<Userinfos>();
Userinfos obj3 = new Userinfos();
list2.add(obj3);
obj3.setNick("king");
obj3.setIconUrl("https://ss0.baidu.com/73t1bjeh1BF3odCf/it/u=1948403834,955109320&fm=85&s=0D06E5134AD145F30C8D6D680300303A");
obj3.setUserid("huangjin");
obj3.setPassword("xxxxxx");
req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println(rsp.getBody());
}
}

@ -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){

Loading…
Cancel
Save