Procházet zdrojové kódy

修复 聊天时取企业管理员信息

wangdy před 8 roky
rodič
revize
34316157d2

+ 12 - 0
src/main/java/com/uas/platform/b2c/common/account/controller/EnterpriseController.java

@@ -1,6 +1,8 @@
 package com.uas.platform.b2c.common.account.controller;
 
 import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.account.model.UserBaseInfo;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
@@ -33,6 +35,16 @@ public class EnterpriseController {
 		return enterpriseService.getEnterpriseInfo(enuu);
 	}
 
+	/**
+	 * 根据UU获取管理员信息
+	 * @param enuu 企业uu号
+	 * @return 完整的企业信息
+	 */
+	@RequestMapping(value = "/{enuu}/admin", method = RequestMethod.GET)
+	public UserBaseInfo getEnterpriseAdminInfo(@PathVariable Long enuu){
+		return enterpriseService.getEnterpriseAdminInfo(enuu);
+	}
+
 	/**
 	 * 修改企业基本资料
 	 *

+ 4 - 0
src/main/java/com/uas/platform/b2c/common/account/service/EnterpriseService.java

@@ -2,12 +2,16 @@ package com.uas.platform.b2c.common.account.service;
 
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.account.model.UserBaseInfo;
 import com.uas.platform.b2c.trade.support.ResultMap;
 
 public interface EnterpriseService {
 
 	// 根据企业uu获取企业信息
 	public Enterprise getEnterpriseInfo(Long uu);
+
+	// 根据企业uu获取管理员信息
+	public UserBaseInfo getEnterpriseAdminInfo(Long uu);
 	
 	// 得到企业是否有需要结算单据状态
 	public Enterprise getReceiptStatus(Enterprise enter);

+ 5 - 0
src/main/java/com/uas/platform/b2c/common/account/service/impl/EnterpriseServiceImpl.java

@@ -42,6 +42,11 @@ public class EnterpriseServiceImpl implements EnterpriseService{
 		return enterpriseDao.findByUu(uu);
 	}
 
+	@Override
+	public UserBaseInfo getEnterpriseAdminInfo(Long uu) {
+		return userBaseInfoDao.findUserByUserUU(enterpriseDao.findByUu(uu).getEnAdminuu());
+	}
+
 	@Override
 	public Enterprise getReceiptStatus(Enterprise enter) {
 		List<Receipt> receipts = receiptDao.findBySellerenuu(enter.getUu());

+ 76 - 19
src/main/webapp/resources/js/common/module/chat_web_module.js

@@ -19,6 +19,25 @@ define([ 'common/query/chat', 'common/query/enterprise' ], function() {
 			}
 			return param;
 		}
+
+		function getAdminInfo(enUU) {
+			/*Enterprise.getEnterpriseAdminInfo({enuu : enUU}, function(data) {
+				var phone = data.userTel;
+				if (!/^1\d{10}$/.test(phone)){
+					return phone;
+				}
+			},function(response) {
+				return;
+			});
+*/
+			var promise = Enterprise.getEnterpriseAdminInfo({enuu : enUU}, {}).$promise;
+
+			return promise.then(function (data) {
+				return data.userTel;
+			}, function () {
+				return 0;
+			});
+		}
 		
 		function accessUnreadMessageCount(param) {
 			var promise = Chat.countUnReadSessionsWhenUserQuery(param, {}).$promise;
@@ -91,9 +110,10 @@ define([ 'common/query/chat', 'common/query/enterprise' ], function() {
 		this.visitWebChat = visitWebChat;
 		this.getParamsFromUserInfo = getParamsFromUserInfo;
 		this.accessUnreadMessageCount = accessUnreadMessageCount;
+		this.getAdminInfo = getAdminInfo;
 	}]);
 
-	module.controller('ChatContactCtrl', ['$rootScope', 'ChatBusinessLayer', 'toaster', function ($rootScope, ChatBusinessLayer, toaster) {
+	module.controller('ChatContactCtrl', ['$rootScope', 'ChatBusinessLayer', 'toaster','Enterprise', function ($rootScope, ChatBusinessLayer, toaster, Enterprise) {
 
 		var vm = this;
 		vm.param = {};
@@ -114,28 +134,65 @@ define([ 'common/query/chat', 'common/query/enterprise' ], function() {
 		 * @param userType	联系人用户类型
 		 */
 		function contactWithOther(phone, enUU, userType) {
-			console.log(phone, enUU, userType);
 			//获得窗口的垂直位置
 			var iTop = (window.screen.availHeight - 30 - 600) / 2;
 			//获得窗口的水平位置
 			var iLeft = (window.screen.availWidth - 10 - 1030) / 2;
-			var newTab = window.open('', '即时对话框', 'height=750, width=1030, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
-				chatInfoDto = {
-				userPhone: vm.param.phone,
-				enUU: vm.param.enUU,
-				userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
-				toPhone: phone,
-				otherEnUU: enUU,
-				otherUserType: userType
-			};
-			ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
-				//newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
-				newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
-			}, function (error) {
-				console.log(error);
-				newTab.close();
-				toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
-			});
+			if (!/^1\d{10}$/.test(phone)){
+				ChatBusinessLayer.getAdminInfo(enUU).then(function (userTel) {
+					phone = userTel;
+					if (!/^1\d{10}$/.test(phone)){
+						toaster.pop('warning', '该店铺暂无管理员电话号码!');
+						return;
+					}
+					console.log(phone, enUU, userType);
+					var newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
+						chatInfoDto = {
+							userPhone: vm.param.phone,
+							enUU: vm.param.enUU,
+							userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
+							toPhone: phone,
+							otherEnUU: enUU,
+							otherUserType: userType
+						};
+					ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
+						if (!gid || gid == ''){
+							newTab.close();
+							toaster.pop('warning', '您暂未开通聊天帐号!');
+							return;
+						}
+						//newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
+						newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
+					}, function (error) {
+						console.log(error);
+						newTab.close();
+						toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
+					});
+				});
+			}else {
+				var newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
+					chatInfoDto = {
+						userPhone: vm.param.phone,
+						enUU: vm.param.enUU,
+						userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
+						toPhone: phone,
+						otherEnUU: enUU,
+						otherUserType: userType
+					};
+				ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
+					if (!gid || gid == ''){
+						newTab.close();
+						toaster.pop('warning', '您暂未开通聊天帐号!');
+						return;
+					}
+					//newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
+					newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
+				}, function (error) {
+					console.log(error);
+					newTab.close();
+					toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
+				});
+			}
 		}
 
 	}]);

+ 4 - 0
src/main/webapp/resources/js/common/query/enterprise.js

@@ -149,6 +149,10 @@ define([ 'angular', 'ui-bootstrap', 'ngResource' ], function(angular) {
 				url : 'basic/enterprise/:enuu/info',
 				method : 'GET'
 			},
+            getEnterpriseAdminInfo : {
+                url : 'basic/enterprise/:enuu/admin',
+                method : 'GET'
+            },
 			getAllUsersByEnuu : {
 				url : 'basic/user/enterprise/info',
 				method : 'GET'