diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java index 9ecf6bfa5..712ac48ca 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java @@ -60,4 +60,6 @@ public interface ManagerMapper { List findByIds(List ids); List listOpenIdByRole(@Param("mask") int mask); + + List listServants(@Param("mask") int mask); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.java new file mode 100644 index 000000000..db617a130 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.java @@ -0,0 +1,31 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; + +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-06-29. + */ +@AutoMapper(tablename = "sys_customer_service", pkName = "manager_id") +public interface SysCustomerServiceMapper { + List findOnline(); + + @AutoSql(type = SqlType.SELECT) + JSONObject findByManagerId(@Param("manager_id")String manager_id); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject record); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject record); + + void onoff(@Param("managerId") String managerId, @Param("status") int status); +} + diff --git a/src/main/java/au/com/royalpay/payment/manage/openim/OpenimController.java b/src/main/java/au/com/royalpay/payment/manage/openim/OpenimController.java index cdc9bd2e0..c2e2bf56d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/openim/OpenimController.java +++ b/src/main/java/au/com/royalpay/payment/manage/openim/OpenimController.java @@ -2,12 +2,15 @@ package au.com.royalpay.payment.manage.openim; import au.com.royalpay.payment.manage.openim.beans.OpenimUserVO; import au.com.royalpay.payment.manage.openim.core.CustomerServiceService; +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.RequireManager; import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.ModelAttribute; +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; @@ -30,8 +33,8 @@ public class OpenimController { @RequestMapping(value = "/check", method = RequestMethod.PUT) @RequireManager - public void sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { - customerServiceService.checkAndSave(manager); + public JSONObject sendMsg(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return customerServiceService.checkAndSave(manager); } @RequestMapping(value = "/findOne", method = RequestMethod.GET) @@ -47,4 +50,9 @@ public class OpenimController { return customerServiceService.query(clientMoniker,userNames); } + @ManagerMapping(value = "/servant/onoff", method = RequestMethod.PUT,role = {ManagerRole.ADMIN}) + public void listServants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestBody boolean onoff) { + customerServiceService.onoff(loginManager,onoff); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/openim/core/CustomerServiceService.java b/src/main/java/au/com/royalpay/payment/manage/openim/core/CustomerServiceService.java index e15d002d6..72207a9bb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/openim/core/CustomerServiceService.java +++ b/src/main/java/au/com/royalpay/payment/manage/openim/core/CustomerServiceService.java @@ -12,9 +12,12 @@ import java.util.List; */ public interface CustomerServiceService { - void checkAndSave(JSONObject account); + JSONObject checkAndSave(JSONObject account); OpenimUserVO findOne(int clientId,String userName); List query(String clientMoniker,String userNames); + + void onoff(JSONObject manager,boolean status); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/openim/core/OpenimClient.java b/src/main/java/au/com/royalpay/payment/manage/openim/core/OpenimClient.java index 73b50bab8..848d3d8d7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/openim/core/OpenimClient.java +++ b/src/main/java/au/com/royalpay/payment/manage/openim/core/OpenimClient.java @@ -122,7 +122,8 @@ public class OpenimClient { Userinfos obj3 = new Userinfos(); list2.add(obj3); obj3.setNick("king"); - obj3.setUserid("kirawang"); + 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; diff --git a/src/main/java/au/com/royalpay/payment/manage/openim/core/impl/CustomerServiceServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/openim/core/impl/CustomerServiceServiceImpl.java index 90e713310..3be3c1ad2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/openim/core/impl/CustomerServiceServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/openim/core/impl/CustomerServiceServiceImpl.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.openim.core.impl; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; +import au.com.royalpay.payment.manage.mappers.system.SysCustomerServiceMapper; 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; @@ -11,6 +12,7 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -36,11 +38,11 @@ public class CustomerServiceServiceImpl implements CustomerServiceService { private ClientAccountMapper clientAccountMapper; @Resource private ManagerMapper managerMapper; - - private final String password = "XXXXXX"; + @Resource + private SysCustomerServiceMapper sysCustomerServiceMapper; @Override - public void checkAndSave(JSONObject account) { + public JSONObject checkAndSave(JSONObject account) { JSONObject client = null; boolean isPartner = true; if (StringUtils.isNotEmpty(account.getString("account_id"))) { @@ -48,27 +50,25 @@ public class CustomerServiceServiceImpl implements CustomerServiceService { if (client == null) { throw new BadRequestException("Merchant Not Found"); } - account =clientAccountMapper.findById(account.getString("account_id")); + account = clientAccountMapper.findById(account.getString("account_id")); isPartner = true; } if (StringUtils.isNotEmpty(account.getString("manager_id"))) { - account =managerMapper.findDetail(account.getString("manager_id")); + account = managerMapper.findDetail(account.getString("manager_id")); isPartner = false; } String uid = account.getString("username") + (isPartner ? "(" + client.getString("client_moniker") + ")" : ""); JSONObject saveRecord = new JSONObject(); saveRecord.put("nick", account.getString("display_name")); + saveRecord.put("password", DigestUtils.md5Hex("uid")); if (isPartner) { saveRecord.put("user_id", uid); - saveRecord.put("account_type", "partner"); - saveRecord.put("account_id", account.getString("account_id")); + saveRecord.put("servants", sysCustomerServiceMapper.findOnline()); } else { saveRecord.put("user_id", uid); - saveRecord.put("account_type", "manager"); - saveRecord.put("account_id", account.getString("manager_id")); } - saveRecord.put("password", password); openimApi.addUser(saveRecord); + return saveRecord; } @Override @@ -117,4 +117,25 @@ public class CustomerServiceServiceImpl implements CustomerServiceService { }); return result; } + + @Override + public void onoff(JSONObject manager, boolean onoff) { + JSONObject record = new JSONObject(); + record.put("manager_id",manager.getString("manager_id")); + record.put("onoff",onoff); + udpateOrSave(record); + } + + private void udpateOrSave(JSONObject servant){ + JSONObject record = sysCustomerServiceMapper.findByManagerId(servant.getString("manager_id")); + if(record==null){ + JSONObject manager = managerMapper.findById(servant.getString("manager_id")); + servant.put("manager_id",manager.getString("manager_id")); + servant.put("user_id",manager.getString("username")); + sysCustomerServiceMapper.save(servant); + }else { + sysCustomerServiceMapper.update(servant); + } + + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java index dbe89191a..9cfe39363 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/ManagerAccountsService.java @@ -26,5 +26,5 @@ public interface ManagerAccountsService { JSONObject getBDConfig(String bd_id); - JSONObject getUser(String managerId); -} + List listServants(JSONObject loginManager); +} \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java index b2bd1da36..0d58548cc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java @@ -138,11 +138,8 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { } @Override - public JSONObject getUser(String managerId) { - JSONObject manager = managerMapper.findDetail(managerId); - JSONObject result = new JSONObject(); - result.put("username",manager.getString("username")); - return result; + public List listServants(JSONObject loginManager) { + return managerMapper.listServants(ManagerRole.SERVANT.getMask()); } private void checkOrg(JSONObject loginManager,JSONObject manager){ diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java index 6c7a88e44..cdb8cd904 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java @@ -82,20 +82,20 @@ public class ManagerAccountsController { managerAccountsService.disable(userId, loginManager); } - @ManagerMapping(value = "/current", method = RequestMethod.GET, role = {ManagerRole.ADMIN}) - public JSONObject getUser(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { - return managerAccountsService.getUser(loginManager.getString("manager_id")); - } - @ManagerMapping(value = "/roles/bd_leader", method = RequestMethod.GET) public List listBDLeaders(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { return managerAccountsService.listBDLeaders(loginManager); } - @ManagerMapping(value = "/group/group_bds", method = RequestMethod.GET) public List listGroupBds(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { return managerAccountsService.listGroupBds(loginManager); } + @ManagerMapping(value = "/roles/servant", method = RequestMethod.GET,role = {ManagerRole.ADMIN}) + public List listServants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { + return managerAccountsService.listServants(loginManager); + } + + } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml index 69928a84a..3237c85c0 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml @@ -94,4 +94,14 @@ WHERE role & #{mask} >0 AND wx_openid IS NOT NULL AND is_valid = 1 ]]> + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.xml new file mode 100644 index 000000000..e98391125 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysCustomerServiceMapper.xml @@ -0,0 +1,14 @@ + + + + + + + udpate sys_customer_servie + set status = #{status} + where manager_id = #{managerId} + + \ No newline at end of file diff --git a/src/main/ui/service_client.html b/src/main/ui/service_client.html index 09d9cb6ef..12f078bd1 100644 --- a/src/main/ui/service_client.html +++ b/src/main/ui/service_client.html @@ -17,6 +17,7 @@ if(getQueryString('uid')){ window.uid = getQueryString('uid'); window.touid = getQueryString('uid'); + window.password = getQueryString('p'); } WKIT.init({ container: document.getElementById('J_demo'), @@ -24,7 +25,7 @@ height: 500, uid: window.uid, appkey: 24960261, - credential: 'XXXXXX', + credential: window.password, touid: window.touid, pluginUrl: '/service_contact_list.html?uid=' + window.uid, diff --git a/src/main/ui/service_customer.html b/src/main/ui/service_customer.html index 7c38f08ae..5cf27b94b 100644 --- a/src/main/ui/service_customer.html +++ b/src/main/ui/service_customer.html @@ -12,7 +12,7 @@ container: document.getElementById('J_demo'), width: 700, height: 500, - uid: 'kirawang', + uid: 'huangjin', appkey: 24960261, credential: 'xxxxxx', touid: 'imuser123', diff --git a/src/main/ui/static/boot/managerMainApp.js b/src/main/ui/static/boot/managerMainApp.js index bd24c302b..18ff3becb 100644 --- a/src/main/ui/static/boot/managerMainApp.js +++ b/src/main/ui/static/boot/managerMainApp.js @@ -178,12 +178,8 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo } $scope.customerService = function () { $http.put('/sys/openim/check').then(function (resp) { - $http.get('/sys/manager_accounts/current').then(function (resp) { - console.log(resp.data); - window.open('/service_client.html?uid='+resp.data.username,'_blank'); - }) + window.open('/service_client.html?p='+resp.data.password+'&uid='+resp.data.user_id,'_blank'); }); - } }]); diff --git a/src/main/ui/static/config/sysconfigs/sysconfigs.js b/src/main/ui/static/config/sysconfigs/sysconfigs.js index ccda9b062..c61e6b0da 100644 --- a/src/main/ui/static/config/sysconfigs/sysconfigs.js +++ b/src/main/ui/static/config/sysconfigs/sysconfigs.js @@ -34,6 +34,10 @@ define(['angular', 'uiRouter'], function (angular) { url: '/mail', templateUrl: '/static/config/sysconfigs/templates/mail_subscribe.html', controller: 'mailSubscribeCtrl' + }).state('sysconfig.servantsConfig', { + url: '/servantsConfig', + templateUrl: '/static/config/sysconfigs/templates/servants_config.html', + controller: 'servantsConfigCtrl' })/*.state('sysconfig.payment_config',{ url: '/payment_config', templateUrl: '/static/config/sysconfigs/templates/payemnt_config.html', @@ -61,6 +65,25 @@ define(['angular', 'uiRouter'], function (angular) { app.controller('sysConfigCtrl', ['$scope', function ($scope) { }]); + + app.controller('servantsConfigCtrl', ['$scope','$http','commonDialog', function ($scope,$http,commonDialog) { + $scope.loadServants = function () { + $http.get('/sys/manager_accounts/roles/servant').then(function (resp) { + $scope.servants = resp.data; + }) + }; + $scope.loadServants(); + $scope.onoff = function (servant) { + var param = {onoff:servant.onoff}; + $http.put('/sys/openim/roles/servant',param).then(function (resp) { + },function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }); + }; + }]); + + + app.controller('basicConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { $scope.loadSysConfigs = function () { $http.get('/sysconfig/base').then(function (resp) { diff --git a/src/main/ui/static/config/sysconfigs/templates/servants_config.html b/src/main/ui/static/config/sysconfigs/templates/servants_config.html new file mode 100644 index 000000000..0db5725b7 --- /dev/null +++ b/src/main/ui/static/config/sysconfigs/templates/servants_config.html @@ -0,0 +1,52 @@ +
+

Mail Not Subscribe

+ +
+
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
Display NameOperation
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html index 4a8705ecd..78162910a 100644 --- a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html +++ b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html @@ -30,6 +30,11 @@ Partner Permission Config + + + Servants Config + +