Merge branch 'develop_openim' into develop

# Conflicts:
#	src/main/ui/manage.html
master
kira 6 years ago
commit 4c97b2cc8a

@ -149,4 +149,6 @@ public interface RetailAppService {
void applyToCompliance(JSONObject device); void applyToCompliance(JSONObject device);
JSONObject sendVerifyEmail(JSONObject device); JSONObject sendVerifyEmail(JSONObject device);
void openimCheck(JSONObject device);
} }

@ -30,6 +30,7 @@ import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionMod
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.manage.notice.core.NoticeManage;
import au.com.royalpay.payment.manage.notice.core.NoticePartner; import au.com.royalpay.payment.manage.notice.core.NoticePartner;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper;
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
@ -166,6 +167,8 @@ public class RetailAppServiceImp implements RetailAppService {
private ClientModifySupport clientModifySupport; private ClientModifySupport clientModifySupport;
@Resource @Resource
private ClearingLogMapper clearingLogMapper; private ClearingLogMapper clearingLogMapper;
@Resource
private CustomerServiceService customerServiceService;
private Map<String, AppMsgSender> senderMap = new HashMap<>(); private Map<String, AppMsgSender> senderMap = new HashMap<>();
private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" }; private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" };
@ -410,6 +413,12 @@ public class RetailAppServiceImp implements RetailAppService {
return result; return result;
} }
@Override
public void openimCheck(JSONObject device) {
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
customerServiceService.checkAndSave(account);
}
@Override @Override
public void updateClient(JSONObject device, AppClientBean appClientBean) { public void updateClient(JSONObject device, AppClientBean appClientBean) {
String clientType = device.getString("client_type"); String clientType = device.getString("client_type");

@ -1,34 +1,5 @@
package au.com.royalpay.payment.manage.appclient.web; package au.com.royalpay.payment.manage.appclient.web;
import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService; import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService;
@ -55,6 +26,35 @@ import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE;
/** /**
* Created by yishuqian on 28/03/2017. * Created by yishuqian on 28/03/2017.
*/ */
@ -540,4 +540,9 @@ public class RetailAppController {
return attachmentClient.uploadFile(file,false); return attachmentClient.uploadFile(file,false);
} }
@RequestMapping(value = "/openim/check",method = RequestMethod.POST)
public void openimCheck(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
retailAppService.openimCheck(device);
}
} }

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.mappers.openim;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yixian on 2016-10-27.
*/
@AutoMapper(tablename = "sys_openim", pkName = "id")
public interface OpenimMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findOne(@Param("user_id") String user_id);
@AutoSql(type = SqlType.SELECT)
JSONObject findByAccountId(@Param("account_id") String account_id,@Param("account_type") String account_type);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject member);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject member);
}

@ -0,0 +1,34 @@
package au.com.royalpay.payment.manage.openim;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.tools.CommonConsts;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/7/11
*/
@RestController
@RequestMapping("/sys/openim")
public class OpenimController {
@Resource
private CustomerServiceService customerServiceService;
@RequestMapping(value = "/check",method = RequestMethod.POST)
@RequireManager
public void sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
customerServiceService.checkAndSave(manager);
}
}

@ -0,0 +1,170 @@
package au.com.royalpay.payment.manage.openim.beans;
/**
* @author kira
* @date 2018/7/11
*/
public class OpenimUser {
private String nick;
private String icon_url;
private String email;
private String mobile;
private String taobaoid;
private String userid;
private String passowrd;
private String remark;
private String extra;
private String career;
private String vip;
private String address;
private String name;
private Integer age;
private String gender;
private String wechat;
private String qq;
private String weibo;
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
public String getIcon_url() {
return icon_url;
}
public void setIcon_url(String icon_url) {
this.icon_url = icon_url;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getTaobaoid() {
return taobaoid;
}
public void setTaobaoid(String taobaoid) {
this.taobaoid = taobaoid;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getPassowrd() {
return passowrd;
}
public void setPassowrd(String passowrd) {
this.passowrd = passowrd;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
public String getCareer() {
return career;
}
public void setCareer(String career) {
this.career = career;
}
public String getVip() {
return vip;
}
public void setVip(String vip) {
this.vip = vip;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getWechat() {
return wechat;
}
public void setWechat(String wechat) {
this.wechat = wechat;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getWeibo() {
return weibo;
}
public void setWeibo(String weibo) {
this.weibo = weibo;
}
}

@ -0,0 +1,48 @@
package au.com.royalpay.payment.manage.openim.beans;
import java.util.List;
/**
* @author kira
* @date 2018/7/11
*/
public class PushMsgBean {
private String from_user;
private List<String> to_users;
private String summary;
private String data;
public String getFrom_user() {
return from_user;
}
public void setFrom_user(String from_user) {
this.from_user = from_user;
}
public List<String> getTo_users() {
return to_users;
}
public void setTo_users(List<String> to_users) {
this.to_users = to_users;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}

@ -0,0 +1,12 @@
package au.com.royalpay.payment.manage.openim.core;
import com.alibaba.fastjson.JSONObject;
/**
* @author kira
* @date 2018/7/11
*/
public interface CustomerServiceService {
void checkAndSave(JSONObject account);
}

@ -0,0 +1,20 @@
package au.com.royalpay.payment.manage.openim.core;
import com.alibaba.fastjson.JSONObject;
/**
* @author kira
* @date 2018/7/11
*/
public interface OpenimApi {
void addUser(JSONObject record);
void updateUser();
void pushMsh();
JSONObject getUserInfo(String userId);
}

@ -0,0 +1,130 @@
package au.com.royalpay.payment.manage.openim.core;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.OpenImUser;
import com.taobao.api.domain.Userinfos;
import com.taobao.api.request.OpenimCustmsgPushRequest;
import com.taobao.api.request.OpenimRelationsGetRequest;
import com.taobao.api.request.OpenimUsersAddRequest;
import com.taobao.api.request.OpenimUsersGetRequest;
import com.taobao.api.request.OpenimUsersUpdateRequest;
import com.taobao.api.response.OpenimCustmsgPushResponse;
import com.taobao.api.response.OpenimRelationsGetResponse;
import com.taobao.api.response.OpenimUsersAddResponse;
import com.taobao.api.response.OpenimUsersGetResponse;
import com.taobao.api.response.OpenimUsersUpdateResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author kira
* @date 2018/7/11
*/
@Service
public class OpenimClient {
Logger logger = LoggerFactory.getLogger(getClass());
// private final String appkey = "24960261";
// private final String secret = "7639427973bd671be15c9d0c1e9c90b4";
private final String appkey = "24962653";
private final String secret = "1c1a1320c4e6f24df24e3fe41c3fc00a";
private final String url = "https://eco.taobao.com/router/rest";
public JSONObject getUser(String userId) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersGetRequest req = new OpenimUsersGetRequest();
// 批量为userid逗号分隔字符串
req.setUserids(userId);
OpenimUsersGetResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
logger.info("openim get user fail", e);
}
return JSONObject.parseObject(rsp.getBody());
}
public void addUser(List<Userinfos> users) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
req.setUserinfos(users);
OpenimUsersAddResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
logger.info("openim add user fail", e);
}
JSONObject result = JSONObject.parseObject(rsp.getBody());
if (result.getJSONObject("openim_users_add_response").getJSONObject("fail_msg").size() > 0) {
logger.info("openim add user fail reason:"
+ result.getJSONObject("openim_users_add_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
throw new ServerErrorException("System error");
}
}
public void updateUser(List<Userinfos> users) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersUpdateRequest req = new OpenimUsersUpdateRequest();
req.setUserinfos(users);
OpenimUsersUpdateResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
logger.info("openim update user fail", e);
}
JSONObject result = JSONObject.parseObject(rsp.getBody());
if (result.getJSONObject("openim_users_update_response").getJSONObject("fail_msg").size() > 0) {
logger.info("openim update user fail reason:"
+ result.getJSONObject("openim_users_update_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
throw new ServerErrorException("System error");
}
}
public void pushMsg(OpenimCustmsgPushRequest.CustMsg msg) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimCustmsgPushRequest req = new OpenimCustmsgPushRequest();
req.setCustmsg(msg);
OpenimCustmsgPushResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
logger.info("openim push msg fail", e);
}
JSONObject result = JSONObject.parseObject(rsp.getBody());
if (result.getJSONObject("openim_custmsg_push_response").getJSONObject("fail_msg").size() > 0) {
logger.info("openim push message fail reason:"
+ result.getJSONObject("openim_custmsg_push_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
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);
OpenimRelationsGetRequest req = new OpenimRelationsGetRequest();
req.setBegDate("20180701");
req.setEndDate("20180711");
OpenImUser obj1 = new OpenImUser();
obj1.setUid("imuser123");
obj1.setTaobaoAccount(false);
req.setUser(obj1);
OpenimRelationsGetResponse rsp = null;
try {
rsp = client.execute(req);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println(rsp.getBody());
}
}

@ -0,0 +1,53 @@
package au.com.royalpay.payment.manage.openim.core.impl;
import au.com.royalpay.payment.manage.mappers.openim.OpenimMapper;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
import au.com.royalpay.payment.manage.openim.core.OpenimApi;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/7/11
*/
@Service
public class CustomerServiceServiceImpl implements CustomerServiceService {
@Resource
private OpenimMapper openimMapper;
@Resource
private OpenimApi openimApi;
@Override
public void checkAndSave(JSONObject account) {
boolean isPartner = true;
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
isPartner = true;
}
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
isPartner = false;
}
String uid = account.getString("username")+ (isPartner ? "_partner": "_manager");
JSONObject record = openimMapper.findOne(uid);
if(record==null){
JSONObject saveRecord = new JSONObject();
saveRecord.put("nick",account.getString("display_name"));
if(isPartner){
saveRecord.put("user_id",account.getString("username")+"_partner");
saveRecord.put("account_type","partner");
saveRecord.put("account_id",account.getString("account_id"));
}else {
saveRecord.put("user_id",account.getString("username")+"_manager");
saveRecord.put("account_type","manager");
saveRecord.put("account_id",account.getString("manager_id"));
}
openimApi.addUser(saveRecord);
}
}
}

@ -0,0 +1,64 @@
package au.com.royalpay.payment.manage.openim.core.impl;
import au.com.royalpay.payment.manage.mappers.openim.OpenimMapper;
import au.com.royalpay.payment.manage.openim.core.OpenimApi;
import au.com.royalpay.payment.manage.openim.core.OpenimClient;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.taobao.api.domain.Userinfos;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/7/11
*/
@Service
public class OpenimApiImpl implements OpenimApi {
@Resource
private OpenimClient openimClient;
@Resource
private OpenimMapper openimMapper;
@Override
public void addUser(JSONObject user) {
List<Userinfos> saveList = new ArrayList<>();
Userinfos record = new Userinfos();
record.setUserid(user.getString("user_id"));
record.setNick(user.getString("nick"));
record.setPassword("XXXXXX");
saveList.add(record);
openimClient.addUser(saveList);
JSONObject openim = new JSONObject();
openim.put("id", IdUtil.getId());
openim.put("user_id", record.getUserid());
openim.put("password_aes", record.getPassword());
openim.put("account_id", user.getString("account_id"));
openim.put("account_type", user.getString("account_type"));
openimMapper.save(openim);
}
@Override
public void updateUser() {
}
@Override
public void pushMsh() {
}
@Override
public JSONObject getUserInfo(String userId) {
return openimClient.getUser(userId);
}
}

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.3.3/scripts/kit.js" charset="utf-8"></script>
<script type="text/javascript" data-th-inline="javascript">
window.uid = /*[[*{uid}]]*/null;
window.credential = /*[[*{password}]]*/null;
window.onload = function(){
WKIT.init({
container: document.getElementById('J_demo'),
width: 700,
height: 500,
uid: window.uid,
appkey: 24962653,
credential: window.credential,
touid: 'imuser1234',
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
pluginUrl: 'http://www.taobao.com/market/seller/openim/plugindemo.php'
});
}
</script>
</head>
</html>
Loading…
Cancel
Save