kira 6 years ago
parent b3f1d26e7c
commit 954b9b6fd2

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

@ -1,34 +1,5 @@
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.manage.activities.app_index.core.AppActService;
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.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.
*/
@ -540,4 +540,9 @@ public class RetailAppController {
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,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);
}

@ -1,8 +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);
}

@ -6,12 +6,15 @@ 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;
@ -29,14 +32,16 @@ import java.util.List;
@Service
public class OpenimClient {
Logger logger = LoggerFactory.getLogger(getClass());
private final String appkey = "24960261";
private final String secret = "7639427973bd671be15c9d0c1e9c90b4";
// 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){
public JSONObject getUser(String userId) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersGetRequest req = new OpenimUsersGetRequest();
// 批量为userid逗号分隔字符串
// 批量为userid逗号分隔字符串
req.setUserids(userId);
OpenimUsersGetResponse rsp = null;
try {
@ -47,8 +52,6 @@ public class OpenimClient {
return JSONObject.parseObject(rsp.getBody());
}
public void addUser(List<Userinfos> users) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
@ -59,9 +62,10 @@ public class OpenimClient {
} 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()>1){
logger.info("openim add user fail reason:"+result.getJSONObject("openim_users_add_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
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");
}
}
@ -76,14 +80,15 @@ public class OpenimClient {
} 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()>1){
logger.info("openim add user fail reason:"+result.getJSONObject("openim_users_add_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
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 JSONObject pushMsg(OpenimCustmsgPushRequest.CustMsg msg){
public void pushMsg(OpenimCustmsgPushRequest.CustMsg msg) {
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
OpenimCustmsgPushRequest req = new OpenimCustmsgPushRequest();
req.setCustmsg(msg);
@ -93,55 +98,33 @@ public class OpenimClient {
} catch (ApiException e) {
logger.info("openim push msg fail", e);
}
return JSONObject.parseObject(rsp.getBody());
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 JSONObject test(){
// TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
// OpenimUsersUpdateRequest req = new OpenimUsersUpdateRequest();
// List<Userinfos> list2 = new ArrayList<Userinfos>();
// Userinfos obj3 = new Userinfos();
// list2.add(obj3);
// obj3.setNick("king");
// obj3.setIconUrl("http://xxx.com/xxx");
// obj3.setEmail("uid@taobao.com");
// obj3.setMobile("18600000000");
// obj3.setTaobaoid("tbnick123");
// obj3.setUserid("imuserkcbknefe123");
// obj3.setPassword("xxxxxx");
// obj3.setRemark("demo");
// obj3.setExtra("{}");
// obj3.setCareer("demo");
// obj3.setVip("{}");
// obj3.setAddress("demo");
// obj3.setName("demo");
// obj3.setAge(123L);
// obj3.setGender("M");
// obj3.setWechat("demo");
// obj3.setQq("demo");
// obj3.setWeibo("demo");
// req.setUserinfos(list2);
// OpenimUsersUpdateResponse rsp = null;
// try {
// rsp = client.execute(req);
// } catch (ApiException e) {
// e.printStackTrace();
// }
// System.out.println(rsp.getBody());
// return JSONObject.parseObject(rsp.getBody());
//
// }
// public static void main(String[] args) {
// OpenimClient asd = new OpenimClient();
// JSONObject zxc = asd.test();
// System.out.println(zxc);
// System.out.println(zxc);
// System.out.println(zxc);
// JSONObject qwe = JSONObject.parseObject("{\"openim_users_add_response\":{\"uid_fail\":{\"string\":[\"imuser123asdasdasd\"]},\"uid_succ\":{},\"fail_msg\":{\"string\":[\"data exist\"]}}}");
//
// System.out.println(qwe.getJSONObject("openim_users_add_response").getJSONObject("fail_msg").getJSONArray("string").toJSONString());
// System.out.println(qwe);
// System.out.println(qwe);
// }
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);
}
}
}

@ -1,10 +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>

@ -307,13 +307,13 @@ margin-bottom: 10%;"/>
<!--</a>-->
<!--</li>-->
<!-- <li ui-sref-active="active" ng-if="('encourage'|withModule)">
<li ui-sref-active="active" ng-if="('encourage'|withModule)">
<a ui-sref="encourageAct">
<i class="fa fa-gift"></i> <span>鼓励金</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('act_customer_redpack'|withModule)">
<!-- <li ui-sref-active="active" ng-if="('act_customer_redpack'|withModule)">
<a ui-sref="customer_redpack">
<i class="fa fa-gift"></i> <span>红包返现</span>
</a>

Loading…
Cancel
Save