xielq 5 лет назад
Родитель
Сommit
ca08dfcd67
100 измененных файлов с 14365 добавлено и 0 удалено
  1. 51 0
      account-common/pom.xml
  2. 57 0
      account-common/src/main/java/com/uas/account/AccountConfig.java
  3. 63 0
      account-common/src/main/java/com/uas/account/ResultWrap.java
  4. 328 0
      account-common/src/main/java/com/uas/account/entity/App.java
  5. 70 0
      account-common/src/main/java/com/uas/account/entity/AppCreateInfo.java
  6. 290 0
      account-common/src/main/java/com/uas/account/entity/PartnershipRecord.java
  7. 86 0
      account-common/src/main/java/com/uas/account/entity/RequsetStatus.java
  8. 282 0
      account-common/src/main/java/com/uas/account/entity/User.java
  9. 229 0
      account-common/src/main/java/com/uas/account/entity/UserDetail.java
  10. 83 0
      account-common/src/main/java/com/uas/account/entity/UserQuestion.java
  11. 136 0
      account-common/src/main/java/com/uas/account/entity/UserSpace.java
  12. 604 0
      account-common/src/main/java/com/uas/account/entity/UserSpaceDetail.java
  13. 46 0
      account-common/src/main/java/com/uas/account/entity/UserView.java
  14. 107 0
      account-common/src/main/java/com/uas/account/entity/UuzcUserDeatil.java
  15. 152 0
      account-common/src/main/java/com/uas/account/entity/UuzcUserSpaceDetail.java
  16. 19 0
      account-common/src/main/java/com/uas/account/exception/AccountException.java
  17. 91 0
      account-common/src/main/java/com/uas/account/support/Page.java
  18. 1061 0
      account-common/src/main/java/com/uas/account/util/AccountUtils.java
  19. 94 0
      account-common/src/main/java/com/uas/account/util/BeanUtil.java
  20. 62 0
      account-common/src/main/java/com/uas/account/util/FlexJsonUtil.java
  21. 122 0
      account-common/src/main/java/com/uas/account/web/AccountConfigurer.java
  22. 32 0
      account-common/src/test/java/com/uas/test/UserSpaceTest.java
  23. 344 0
      account-server/pom.xml
  24. 125 0
      account-server/src/main/java/com/uas/account/controller/AppManagerController.java
  25. 119 0
      account-server/src/main/java/com/uas/account/controller/AssetManagerController.java
  26. 12 0
      account-server/src/main/java/com/uas/account/controller/ChangeAdminDetailController.java
  27. 186 0
      account-server/src/main/java/com/uas/account/controller/GetAllPartnersInfoController.java
  28. 254 0
      account-server/src/main/java/com/uas/account/controller/PartnershipController.java
  29. 74 0
      account-server/src/main/java/com/uas/account/controller/SettingController.java
  30. 50 0
      account-server/src/main/java/com/uas/account/controller/SynchrodataToOldPlatController.java
  31. 1109 0
      account-server/src/main/java/com/uas/account/controller/UserManagerController.java
  32. 209 0
      account-server/src/main/java/com/uas/account/controller/UserSpaceController.java
  33. 689 0
      account-server/src/main/java/com/uas/account/controller/UserSpaceManagerController.java
  34. 15 0
      account-server/src/main/java/com/uas/account/core/Const.java
  35. 20 0
      account-server/src/main/java/com/uas/account/core/ICallable.java
  36. 37 0
      account-server/src/main/java/com/uas/account/core/ICallableAdapter.java
  37. 87 0
      account-server/src/main/java/com/uas/account/core/Logger.java
  38. 87 0
      account-server/src/main/java/com/uas/account/core/MergeTask.java
  39. 87 0
      account-server/src/main/java/com/uas/account/core/Page.java
  40. 65 0
      account-server/src/main/java/com/uas/account/core/Status.java
  41. 15 0
      account-server/src/main/java/com/uas/account/core/util/ArrayUtils.java
  42. 100 0
      account-server/src/main/java/com/uas/account/core/util/CaptchaUtil.java
  43. 69 0
      account-server/src/main/java/com/uas/account/core/util/ChineseUtils.java
  44. 30 0
      account-server/src/main/java/com/uas/account/core/util/ExecuteUtils.java
  45. 93 0
      account-server/src/main/java/com/uas/account/core/util/FastjsonUtils.java
  46. 298 0
      account-server/src/main/java/com/uas/account/core/util/HttpUtils.java
  47. 44 0
      account-server/src/main/java/com/uas/account/core/util/QRCodeUtil.java
  48. 34 0
      account-server/src/main/java/com/uas/account/core/util/StringUtil.java
  49. 59 0
      account-server/src/main/java/com/uas/account/dao/AppDao.java
  50. 116 0
      account-server/src/main/java/com/uas/account/dao/AppDaoImpl.java
  51. 22 0
      account-server/src/main/java/com/uas/account/dao/AssetDao.java
  52. 90 0
      account-server/src/main/java/com/uas/account/dao/AssetDaoImpl.java
  53. 18 0
      account-server/src/main/java/com/uas/account/dao/BaseDao.java
  54. 43 0
      account-server/src/main/java/com/uas/account/dao/ChangeAdminDao.java
  55. 146 0
      account-server/src/main/java/com/uas/account/dao/ChangeAdminDaoImpl.java
  56. 11 0
      account-server/src/main/java/com/uas/account/dao/LogDao.java
  57. 39 0
      account-server/src/main/java/com/uas/account/dao/LogDaoImpl.java
  58. 124 0
      account-server/src/main/java/com/uas/account/dao/PartnershipRecordDao.java
  59. 407 0
      account-server/src/main/java/com/uas/account/dao/PartnershipRecordDaoImpl.java
  60. 24 0
      account-server/src/main/java/com/uas/account/dao/PlatfromManageDao.java
  61. 93 0
      account-server/src/main/java/com/uas/account/dao/PlatfromManageDaoImpl.java
  62. 19 0
      account-server/src/main/java/com/uas/account/dao/SettingDao.java
  63. 59 0
      account-server/src/main/java/com/uas/account/dao/SettingDaoImpl.java
  64. 50 0
      account-server/src/main/java/com/uas/account/dao/SynchrodataToOldPlatDao.java
  65. 122 0
      account-server/src/main/java/com/uas/account/dao/SynchrodataToOldPlatDaoImpl.java
  66. 13 0
      account-server/src/main/java/com/uas/account/dao/TokenDao.java
  67. 64 0
      account-server/src/main/java/com/uas/account/dao/TokenDaoImpl.java
  68. 165 0
      account-server/src/main/java/com/uas/account/dao/UserDao.java
  69. 581 0
      account-server/src/main/java/com/uas/account/dao/UserDaoImpl.java
  70. 19 0
      account-server/src/main/java/com/uas/account/dao/UserQuestionDao.java
  71. 61 0
      account-server/src/main/java/com/uas/account/dao/UserQuestionDaoImpl.java
  72. 190 0
      account-server/src/main/java/com/uas/account/dao/UserSpaceDao.java
  73. 505 0
      account-server/src/main/java/com/uas/account/dao/UserSpaceDaoImpl.java
  74. 171 0
      account-server/src/main/java/com/uas/account/entity/Asset.java
  75. 279 0
      account-server/src/main/java/com/uas/account/entity/ChangeAdminDetail.java
  76. 35 0
      account-server/src/main/java/com/uas/account/entity/FileUrl.java
  77. 192 0
      account-server/src/main/java/com/uas/account/entity/InvitationRecord.java
  78. 152 0
      account-server/src/main/java/com/uas/account/entity/Log.java
  79. 54 0
      account-server/src/main/java/com/uas/account/entity/Setting.java
  80. 116 0
      account-server/src/main/java/com/uas/account/entity/Token.java
  81. 115 0
      account-server/src/main/java/com/uas/account/entity/UserFailed.java
  82. 37 0
      account-server/src/main/java/com/uas/account/entity/UserSpaceAndUserInfo.java
  83. 83 0
      account-server/src/main/java/com/uas/account/entity/UserSpaceDetailInfo.java
  84. 94 0
      account-server/src/main/java/com/uas/account/entity/UserSpaceFailed.java
  85. 23 0
      account-server/src/main/java/com/uas/account/exception/VisibleError.java
  86. 57 0
      account-server/src/main/java/com/uas/account/service/AppService.java
  87. 99 0
      account-server/src/main/java/com/uas/account/service/AppServiceImpl.java
  88. 21 0
      account-server/src/main/java/com/uas/account/service/AssetService.java
  89. 72 0
      account-server/src/main/java/com/uas/account/service/AssetServiceImpl.java
  90. 89 0
      account-server/src/main/java/com/uas/account/service/ChangeAdminService.java
  91. 326 0
      account-server/src/main/java/com/uas/account/service/ChangeAdminServiceImpl.java
  92. 239 0
      account-server/src/main/java/com/uas/account/service/PartnershipService.java
  93. 458 0
      account-server/src/main/java/com/uas/account/service/PartnershipServiceImpl.java
  94. 25 0
      account-server/src/main/java/com/uas/account/service/PlatformManageService.java
  95. 26 0
      account-server/src/main/java/com/uas/account/service/PlatformManageServiceImpl.java
  96. 19 0
      account-server/src/main/java/com/uas/account/service/SettingService.java
  97. 56 0
      account-server/src/main/java/com/uas/account/service/SettingServiceImpl.java
  98. 22 0
      account-server/src/main/java/com/uas/account/service/SynchrodataToOldPlatService.java
  99. 95 0
      account-server/src/main/java/com/uas/account/service/SynchrodataToOldPlatServiceImpl.java
  100. 53 0
      account-server/src/main/java/com/uas/account/service/SysDataToMallService.java

+ 51 - 0
account-common/pom.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.uas.account</groupId>
+		<artifactId>account-parent</artifactId>
+		<version>0.0.1-SNAPSHOT</version>
+	</parent>
+	<artifactId>account-common</artifactId>
+	<name>account-common</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.uas.account</groupId>
+			<artifactId>sso-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate-validator</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+	    <groupId>net.sf.flexjson</groupId>
+	    <artifactId>flexjson</artifactId>
+	    <version>2.1</version>
+</dependency>
+	</dependencies>
+</project>

+ 57 - 0
account-common/src/main/java/com/uas/account/AccountConfig.java

@@ -0,0 +1,57 @@
+package com.uas.account;
+
+import com.uas.sso.SSOConfig;
+
+/**
+ * 账户中心配置
+ * 
+ * @author yingp
+ * 
+ */
+public class AccountConfig extends SSOConfig {
+
+	public static final String ACCOUNT_CENTER = "sso";
+
+	/**
+	 * 无需绑定到任何企业的个人账号,默认绑定到-1
+	 */
+	public static final String DEFAULT_SPACE_ID = "-1";
+
+	/**
+	 * 账户中心的接口,App注册企业信息到账户中心
+	 * 
+	 * <pre>
+	 * 账户中心保存的资料有限,因此App里面也需要有自定义的企业信息表来存放业务字段;
+	 * App里面最好是在自己系统保存成功后,再调用账户中心的接口,即使出错也可回滚。
+	 * </pre>
+	 */
+	public static String getSpaceSaveUrl() {
+		return getInstance().getProperty("account.us.save.url");
+	}
+
+	/**
+	 * 账户中心的接口,App注册用户信息到账户中心
+	 * 
+	 * <pre>
+	 * 账户中心保存的资料有限,因此App里面也需要有自定义的用户信息表来存放业务字段;
+	 * App里面最好是在自己系统保存成功后,再调用账户中心的接口,即使出错也可回滚。
+	 * </pre>
+	 */
+	public static String getUserSaveUrl() {
+		return getInstance().getProperty("account.user.save.url");
+	}
+
+	/**
+	 * 账户中心的接口,供商务平台和ERP系统查询自己当期企业的合作伙伴
+	 */
+	public static String getEnPartnersUrl() {
+		return getInstance().getProperty("account.user.getPartners.url");
+	}
+
+	/**
+	 * 账户中心接口,跳转到企业圈
+	 */
+	public static String getContactPageUrl() {
+		return getInstance().getProperty("account.user.getContactPage.url");
+	}
+}

+ 63 - 0
account-common/src/main/java/com/uas/account/ResultWrap.java

@@ -0,0 +1,63 @@
+package com.uas.account;
+
+public class ResultWrap {
+
+	private Object content;
+
+	private Boolean success;
+
+	private Boolean error;
+
+	private Integer errCode;
+
+	private String errMsg;
+
+	public Boolean isSuccess() {
+		return null != success && success;
+	}
+
+	public Boolean isError() {
+		return null != error && error;
+	}
+
+	public Boolean getSuccess() {
+		return success;
+	}
+
+	public void setSuccess(Boolean success) {
+		this.success = success;
+	}
+
+	public Integer getErrCode() {
+		return errCode;
+	}
+
+	public void setErrCode(Integer errCode) {
+		this.errCode = errCode;
+	}
+
+	public String getErrMsg() {
+		return errMsg;
+	}
+
+	public void setErrMsg(String errMsg) {
+		this.errMsg = errMsg;
+	}
+
+	public Object getContent() {
+		return content;
+	}
+
+	public void setContent(Object content) {
+		this.content = content;
+	}
+
+	public Boolean getError() {
+		return error;
+	}
+
+	public void setError(Boolean error) {
+		this.error = error;
+	}
+
+}

+ 328 - 0
account-common/src/main/java/com/uas/account/entity/App.java

@@ -0,0 +1,328 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+/**
+ * 应用
+ * 
+ * @author yingp
+ *
+ */
+public class App implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public static final String COPY_ALL = "all";
+	public static final String COPY_APP_SPLIT = ",";
+	public static final String ENCRY_PARAM_PASSWORD = "$password";
+	public static final String ENCRY_PARAM_SALT = "$salt";
+
+	private String uid;
+
+	private String publicKey;
+
+	private String description;
+
+	private String userControl;
+
+	private String backSpaceUrl;
+
+	private String backUserUrl;
+
+	private String backUserPwdUrl;
+
+	private String backPartnerUrl;
+
+	private String loginUrl;
+
+	private String logoutUrl;
+
+	private String encryFormat;
+
+	private String copyApps;
+
+	private String scope;
+
+	private Integer defaultUse;
+
+	private int usCount;
+
+	private Integer dialectEnable;
+
+	private String homePage;
+
+	private Integer personalEnable;
+
+	private String backChangeAdminUrl;
+
+	/**
+	 * 唯一标识
+	 */
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	/**
+	 * 描述
+	 */
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	/**
+	 * App的企业注册接口(这个接口里面一定不要又调用账户中心注册企业接口)
+	 * 
+	 * <pre>
+	 * App1往账户中心注册账号时,指定了要同时注册到App2,此时账户中心会调用App2的这个接口;
+	 * </pre>
+	 * 
+	 */
+	public String getBackSpaceUrl() {
+		return backSpaceUrl;
+	}
+
+	public void setBackSpaceUrl(String backSpaceUrl) {
+		this.backSpaceUrl = backSpaceUrl;
+	}
+
+	/**
+	 * App的用户注册接口(这个接口里面一定不要又调用账户中心用户注册接口)
+	 * 
+	 * <pre>
+	 * App1往账户中心注册账号时,指定了要同时注册到App2,此时账户中心会调用App2的这个接口;
+	 * 需要注意的是,这个接口接收的用户信息,密码字段是<strong>已加密的</strong>
+	 * </pre>
+	 * 
+	 */
+	public String getBackUserUrl() {
+		return backUserUrl;
+	}
+
+	public void setBackUserUrl(String backUserUrl) {
+		this.backUserUrl = backUserUrl;
+	}
+
+	public String getBackUserPwdUrl() {
+		return backUserPwdUrl;
+	}
+
+	public void setBackUserPwdUrl(String backUserPwdUrl) {
+		this.backUserPwdUrl = backUserPwdUrl;
+	}
+
+	public String getBackPartnerUrl() {
+		return backPartnerUrl;
+	}
+
+	public void setBackPartnerUrl(String backPartnerUrl) {
+		this.backPartnerUrl = backPartnerUrl;
+	}
+
+	/**
+	 * 登录其他应用
+	 * @return
+	 */
+	public String getLoginUrl() {
+		return loginUrl;
+	}
+
+	public void setLoginUrl(String loginUrl) {
+		this.loginUrl = loginUrl;
+	}
+
+	/**
+	 * 登出其他应用
+	 * @return
+	 */
+	public String getLogoutUrl() {
+		return logoutUrl;
+	}
+
+	public void setLogoutUrl(String logoutUrl) {
+		this.logoutUrl = logoutUrl;
+	}
+
+	/**
+	 * 密码加密格式,每个应用的格式允许不一样
+	 */
+	public String getEncryFormat() {
+		return encryFormat;
+	}
+
+	public void setEncryFormat(String encryFormat) {
+		this.encryFormat = encryFormat;
+	}
+
+	@Override
+	public String toString() {
+		try {
+			return "uid=" + uid + "&description=" + description + "&backSpaceUrl="
+					+ URLEncoder.encode(backSpaceUrl, "UTF-8") + "&backUserUrl="
+					+ URLEncoder.encode(backUserUrl, "UTF-8") + "&backUserPwdUrl="
+					+ URLEncoder.encode(backUserPwdUrl, "UTF-8") + "&backPartnerUrl="
+					+ URLEncoder.encode(backChangeAdminUrl, "UTF-8") + "&backChangeAdminUrl="
+					+ URLEncoder.encode(backPartnerUrl, "UTF-8") + "&encryFormat=" + encryFormat + "&copyApps="
+					+ copyApps;
+		} catch (UnsupportedEncodingException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * 关联的应用
+	 * <p>
+	 * 在用户集、用户信息发生改变时,会同步到关联应用
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public String getCopyApps() {
+		return copyApps;
+	}
+
+	public void setCopyApps(String copyApps) {
+		this.copyApps = copyApps;
+	}
+
+	/**
+	 * 公钥
+	 * 
+	 * <pre>
+	 * 用于跨域验证;
+	 * 当App将私钥加密的密文传递到账户中心时,账户中心要用该App的公钥验证合法性
+	 * </pre>
+	 * 
+	 * @return
+	 */
+	public String getPublicKey() {
+		return publicKey;
+	}
+
+	public void setPublicKey(String publicKey) {
+		this.publicKey = publicKey;
+	}
+
+	/**
+	 * 绑定的UserSpace个数
+	 * 
+	 * @return
+	 */
+	public int getUsCount() {
+		return usCount;
+	}
+
+	public void setUsCount(int usCount) {
+		this.usCount = usCount;
+	}
+
+	/**
+	 * 某些应用没有独立企业及用户集,而是借用其他应用的;不为空时,登录该应用,将会使用{@code userControl}的企业及用户来验证<br>
+	 * 此时{@code backSpaceUrl}、{@code backUserUrl}、{@code encryFormat}和
+	 * {@code copyApps}不用填写
+	 * 
+	 * @return
+	 */
+	public String getUserControl() {
+		return userControl;
+	}
+
+	public void setUserControl(String userControl) {
+		this.userControl = userControl;
+	}
+
+	/**
+	 * 作用域,内网private,外网public,受限protected
+	 * 
+	 * @return
+	 */
+	public String getScope() {
+		return scope;
+	}
+
+	public void setScope(String scope) {
+		this.scope = scope;
+	}
+
+	/**
+	 * 默认注册
+	 * 
+	 * <pre>
+	 * 企业注册的时候,默认注册并开通该应用
+	 * </pre>
+	 * 
+	 * @return
+	 */
+	public Integer getDefaultUse() {
+		return defaultUse;
+	}
+
+	public void setDefaultUse(Integer defaultUse) {
+		this.defaultUse = defaultUse;
+	}
+
+	/**
+	 * 允许dialect方式(登录、修改等操作)
+	 * 
+	 * @return
+	 */
+	public Integer getDialectEnable() {
+		return dialectEnable;
+	}
+
+	public void setDialectEnable(Integer dialectEnable) {
+		this.dialectEnable = dialectEnable;
+	}
+
+	/**
+	 * 应用首页, 支持格式如:http://$domain/saas.ubtob.com <br>
+	 * 其中,{@code domain}表示企业注册域名
+	 * 
+	 * @return
+	 */
+	public String getHomePage() {
+		return homePage;
+	}
+
+	public void setHomePage(String homePage) {
+		this.homePage = homePage;
+	}
+
+	public Integer getPersonalEnable() {
+		return personalEnable;
+	}
+
+	/**
+	 * 是否允许个人注册
+	 * @param personalEnable
+	 */
+	public void setPersonalEnable(Integer personalEnable) {
+		this.personalEnable = personalEnable;
+	}
+
+
+	public String getBackChangeAdminUrl() {
+		return backChangeAdminUrl;
+	}
+
+	public void setBackChangeAdminUrl(String backChangeAdminUrl) {
+		this.backChangeAdminUrl = backChangeAdminUrl;
+	}
+
+	public enum Scope {
+		PRIVATE, PUBLIC, PROTECTED
+	}
+
+}

+ 70 - 0
account-common/src/main/java/com/uas/account/entity/AppCreateInfo.java

@@ -0,0 +1,70 @@
+package com.uas.account.entity;
+
+public class AppCreateInfo {
+
+	/**
+	 * 是否注册过优软云
+	 */
+	private boolean inCloud;
+
+	/**
+	 * 是否开立过账套
+	 */
+	private boolean hasCreate;
+
+	/**
+	 * 注册过优软云的营业执照号
+	 */
+	private String businessCode;
+
+	/**
+	 * 注册优软云的名称
+	 */
+	private String name;
+
+	/**
+	 * 返回uu号
+	 */
+	private String enuu;
+
+	public boolean isInCloud() {
+		return inCloud;
+	}
+
+	public void setInCloud(boolean inCloud) {
+		this.inCloud = inCloud;
+	}
+
+	public boolean isHasCreate() {
+		return hasCreate;
+	}
+
+	public void setHasCreate(boolean hasCreate) {
+		this.hasCreate = hasCreate;
+	}
+
+	public String getBusinessCode() {
+		return businessCode;
+	}
+
+	public void setBusinessCode(String businessCode) {
+		this.businessCode = businessCode;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(String enuu) {
+		this.enuu = enuu;
+	}
+
+}

+ 290 - 0
account-common/src/main/java/com/uas/account/entity/PartnershipRecord.java

@@ -0,0 +1,290 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 合作关系申请的记录
+ * 
+ * @author hejq
+ * @time 创建时间:2017年1月10日
+ */
+public class PartnershipRecord implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	private Long id;
+
+	/**
+	 * 应用
+	 */
+	private String appId;
+
+	/**
+	 * 申请时间
+	 */
+	private Date requestDate;
+
+	/**
+	 * 申请企业
+	 */
+	private String custName;
+
+	/**
+	 * 申请企业的code(统一用的营业执照号)
+	 */
+	private String custUID;
+
+	/**
+	 * 申请人的姓名
+	 */
+	private String custUserName;
+
+	/**
+	 * 申请人的标志(商务平台为个人UU号)
+	 */
+	private String custUserCode;
+
+	/**
+	 * 申请人的联系方式
+	 */
+	private String custUserTel;
+	
+	/**
+	 * 申请人的邮箱
+	 */
+	private String custUserEmail;
+
+	/**
+	 * 客户的企业名称
+	 */
+	private String vendName;
+
+	/**
+	 * 客户的标识(如UU号等)
+	 */
+	private String vendUID;
+
+	/**
+	 * 审核人姓名
+	 */
+	private String vendUserName;
+
+	/**
+	 * 审核人联系方式
+	 */
+	private String vendUserTel;
+
+	/**
+	 * 审核人邮箱
+	 */
+	private String vendUserEmail;
+
+	/**
+	 * 审核人标志(uu号等)
+	 */
+	private String vendUserCode;
+
+	/**
+	 * 审核时间
+	 */
+	private Date operateDate;
+
+	/**
+	 * 申请状态码
+	 */
+	private Integer statusCode;
+
+	/**
+	 * 申请状态
+	 */
+	private String status;
+
+	/**
+	 * 原因
+	 */
+	private String reason;
+
+	/**
+	 * 添加合作伙伴关系后方式
+	 */
+	private String method;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getAppId() {
+		return appId;
+	}
+
+	public void setAppId(String appId) {
+		this.appId = appId;
+	}
+
+	public Date getRequestDate() {
+		return requestDate;
+	}
+
+	public void setRequestDate(Date requestDate) {
+		this.requestDate = requestDate;
+	}
+
+	public String getCustName() {
+		return custName;
+	}
+
+	public void setCustName(String custName) {
+		this.custName = custName;
+	}
+
+	public String getCustUID() {
+		return custUID;
+	}
+
+	public void setCustUID(String custUID) {
+		this.custUID = custUID;
+	}
+
+	public String getCustUserName() {
+		return custUserName;
+	}
+
+	public void setCustUserName(String custUserName) {
+		this.custUserName = custUserName;
+	}
+
+	public String getCustUserCode() {
+		return custUserCode;
+	}
+
+	public void setCustUserCode(String custUserCode) {
+		this.custUserCode = custUserCode;
+	}
+
+	public String getCustUserTel() {
+		return custUserTel;
+	}
+
+	public void setCustUserTel(String custUserTel) {
+		this.custUserTel = custUserTel;
+	}
+
+	public String getCustUserEmail() {
+		return custUserEmail;
+	}
+
+	public void setCustUserEmail(String custUserEmail) {
+		this.custUserEmail = custUserEmail;
+	}
+
+	public String getVendName() {
+		return vendName;
+	}
+
+	public void setVendName(String vendName) {
+		this.vendName = vendName;
+	}
+
+	public String getVendUID() {
+		return vendUID;
+	}
+
+	public void setVendUID(String vendUID) {
+		this.vendUID = vendUID;
+	}
+
+	public String getVendUserName() {
+		return vendUserName;
+	}
+
+	public void setVendUserName(String vendUserName) {
+		this.vendUserName = vendUserName;
+	}
+
+	public String getVendUserTel() {
+		return vendUserTel;
+	}
+
+	public void setVendUserTel(String vendUserTel) {
+		this.vendUserTel = vendUserTel;
+	}
+
+	public String getVendUserEmail() {
+		return vendUserEmail;
+	}
+
+	public void setVendUserEmail(String vendUserEmail) {
+		this.vendUserEmail = vendUserEmail;
+	}
+
+	public String getVendUserCode() {
+		return vendUserCode;
+	}
+
+	public void setVendUserCode(String vendUserCode) {
+		this.vendUserCode = vendUserCode;
+	}
+
+	public Date getOperateDate() {
+		return operateDate;
+	}
+
+	public void setOperateDate(Date operateDate) {
+		this.operateDate = operateDate;
+	}
+
+	public Integer getStatusCode() {
+		return statusCode;
+	}
+
+	public void setStatusCode(Integer statusCode) {
+		this.statusCode = statusCode;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getReason() {
+		return reason;
+	}
+
+	public void setReason(String reason) {
+		this.reason = reason;
+	}
+
+	public String getMethod() {
+		return method;
+	}
+
+	public void setMethod(String method) {
+		this.method = method;
+	}
+
+	@Override
+	public String toString() {
+		return "PartnershipRecord [id=" + id + ", appId=" + appId + ", requestDate=" + requestDate + ", custName="
+				+ custName + ", custUID=" + custUID + ", custUserName=" + custUserName + ", custUserCode="
+				+ custUserCode + ", custUserTel=" + custUserTel + ", custUserEmail=" + custUserEmail + ", vendName="
+				+ vendName + ", vendUID=" + vendUID + ", vendUserName=" + vendUserName + ", vendUserTel=" + vendUserTel
+				+ ", vendUserEmail=" + vendUserEmail + ", vendUserCode=" + vendUserCode + ", operateDate=" + operateDate
+				+ ", statusCode=" + statusCode + ", status=" + status + ", reason=" + reason + ", method=" + method
+				+ "]";
+	}
+
+}

+ 86 - 0
account-common/src/main/java/com/uas/account/entity/RequsetStatus.java

@@ -0,0 +1,86 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+/**
+ * 通过当前分页的企业营业执照和当前登录企业的营业执照号查询申请状态
+ * 
+ * @author hejq
+ * @time 创建时间:2017年2月20日
+ */
+public class RequsetStatus implements Serializable {
+
+	/**
+	 * 序号
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 客户uid
+	 */
+	private String custUid;
+
+	/**
+	 * 供应商uid
+	 */
+	private String vendUid;
+
+	/**
+	 * 申请状态
+	 */
+	private Integer StatusCode;
+
+	/**
+	 * 方式(主动还是被动)<br>
+	 * 1: 主动发出 <br>
+	 * 0: 对方发出
+	 */
+	private Integer method;
+
+	/**
+	 * 是否需要操作(即他人发出请求且为待回复)<br>
+	 * 1: 需要 <br>
+	 * 0: 不需要
+	 */
+	private Integer needAgreed;
+
+	public String getCustUid() {
+		return custUid;
+	}
+
+	public void setCustUid(String custUid) {
+		this.custUid = custUid;
+	}
+
+	public String getVendUid() {
+		return vendUid;
+	}
+
+	public void setVendUid(String vendUid) {
+		this.vendUid = vendUid;
+	}
+
+	public Integer getStatusCode() {
+		return StatusCode;
+	}
+
+	public void setStatusCode(Integer statusCode) {
+		StatusCode = statusCode;
+	}
+
+	public Integer getMethod() {
+		return method;
+	}
+
+	public void setMethod(Integer method) {
+		this.method = method;
+	}
+
+	public Integer getNeedAgreed() {
+		return needAgreed;
+	}
+
+	public void setNeedAgreed(Integer needAgreed) {
+		this.needAgreed = needAgreed;
+	}
+}

+ 282 - 0
account-common/src/main/java/com/uas/account/entity/User.java

@@ -0,0 +1,282 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+import com.uas.sso.common.util.StringUtil;
+
+/**
+ * 用户
+ * 
+ * @author yingp
+ * 
+ */
+public class User implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private String appId;
+
+	private Long spaceId;
+
+	private String spaceUID;
+
+	private String spaceDialectUID;
+
+	private Long id;
+
+	private String uid;
+
+	private String secondUID;
+
+	private String dialectUID;
+
+	private String name;
+
+	private String password;
+
+	private String salt;
+
+	private Short hr;
+
+	private Short pwdSecLevel;
+
+	private Long lastLoginTime;
+
+	public User() {
+	}
+
+	public User(App app, UserSpace userSpace, UserSpaceDetail detail) {
+		this.setAppId(app.getUid());
+		this.setName(detail.getAdminName());
+		this.setUid(detail.getAdminTel());
+		this.setSecondUID(detail.getAdminEmail());
+		this.setSpaceId(userSpace.getId());
+		this.setSpaceUID(userSpace.getUid());
+		this.setSpaceDialectUID(userSpace.getDialectUID());
+	}
+
+	public User(App app, UserSpaceDetail detail) {
+		this.setAppId(app.getUid());
+		this.setName(detail.getAdminName());
+		this.setUid(detail.getAdminTel());
+		this.setSecondUID(detail.getAdminEmail());
+	}
+
+	public User(App app, UserSpace userSpace, UserDetail detail) {
+		this.setAppId(app.getUid());
+		this.setName(detail.getName());
+		this.setUid(detail.getMobile());
+		this.setSecondUID(detail.getEmail());
+		this.setSpaceId(userSpace.getId());
+		this.setSpaceUID(userSpace.getUid());
+		this.setSpaceDialectUID(userSpace.getDialectUID());
+	}
+
+	public User(App app, UserDetail detail) {
+		this.setAppId(app.getUid());
+		this.setName(detail.getName());
+		this.setUid(detail.getMobile());
+		this.setSecondUID(detail.getEmail());
+	}
+
+	/**
+	 * 属于哪个应用
+	 */
+	public String getAppId() {
+		return appId;
+	}
+
+	public void setAppId(String appId) {
+		this.appId = appId;
+	}
+
+	/**
+	 * 属于哪个用户集
+	 */
+	public Long getSpaceId() {
+		return spaceId;
+	}
+
+	public void setSpaceId(Long spaceId) {
+		this.spaceId = spaceId;
+	}
+
+	/**
+	 * ID
+	 */
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 全局唯一标识,例如手机号、身份证号,所有接入的业务系统都认可使用的同一个标识
+	 */
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	/**
+	 * 名称
+	 */
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * 属于哪个用户集
+	 * 
+	 * <pre>
+	 * 应用如果没保存账户中心的UserSpace.id也没关系,提供appId和UserSpace.UID即可
+	 * </pre>
+	 */
+	public String getSpaceUID() {
+		return spaceUID;
+	}
+
+	public void setSpaceUID(String spaceUID) {
+		this.spaceUID = spaceUID;
+	}
+
+	/**
+	 * 密码,新增、修改时请提交明文
+	 */
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	/**
+	 * 加密盐值,允许每个用户的不一样
+	 */
+	public String getSalt() {
+		return salt;
+	}
+
+	public void setSalt(String salt) {
+		this.salt = salt;
+	}
+
+	@Override
+	public String toString() {
+		return "&appId=" + StringUtil.nvl(appId, "") + "&spaceId=" + StringUtil.nvl(spaceId, "") + "&spaceUID="
+				+ StringUtil.nvl(spaceUID, "") + "&spaceDialectUID=" + StringUtil.nvl(spaceDialectUID, "") + "&id="
+				+ StringUtil.nvl(id, "") + "&uid=" + StringUtil.nvl(uid, "") + "&secondUID="
+				+ StringUtil.nvl(secondUID, "") + "&name=" + StringUtil.nvl(name, "") + "&password="
+				+ StringUtil.nvl(password, "") + "&salt=" + StringUtil.nvl(salt, "") + "&dialectUID="
+				+ StringUtil.nvl(dialectUID, "");
+	}
+
+	/**
+	 * 业务系统自己的,除UID(例如手机号)之外的,唯一标识字段(例如,user_uu) <br>
+	 * 因为业务系统可能历史原因,部分账号并没有UID(手机号)
+	 * <p>
+	 * 在业务系统没有保存ID,也不保证UID一定有数据的情况下使用
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public String getDialectUID() {
+		return dialectUID;
+	}
+
+	public void setDialectUID(String dialectUID) {
+		this.dialectUID = dialectUID;
+	}
+
+	/**
+	 * 业务系统自己的,除spaceUID之外的,唯一标识字段(例如,sec$userenterprise.en_uu) <br>
+	 * 因为业务系统可能历史原因,部分企业信息并没有UID,也就没有spaceUID
+	 * <p>
+	 * 在业务系统没有保存spaceId,也不保证spaceUID一定有数据的情况下使用
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public String getSpaceDialectUID() {
+		return spaceDialectUID;
+	}
+
+	public void setSpaceDialectUID(String spaceDialectUID) {
+		this.spaceDialectUID = spaceDialectUID;
+	}
+
+	/**
+	 * 除UID外的次要UID,比如邮箱名
+	 * 
+	 * @return
+	 */
+	public String getSecondUID() {
+		return secondUID;
+	}
+
+	public void setSecondUID(String secondUID) {
+		this.secondUID = secondUID;
+	}
+
+	/**
+	 * 密码安全等级(1、低,2、中,3、高)
+	 *
+	 * @return
+	 */
+	public Short getPwdSecLevel() {
+		return pwdSecLevel;
+	}
+
+	public void setPwdSecLevel(Short pwdSecLevel) {
+		this.pwdSecLevel = pwdSecLevel;
+	}
+
+	public Long getLastLoginTime() {
+		return lastLoginTime;
+	}
+
+	public void setLastLoginTime(Long lastLoginTime) {
+		this.lastLoginTime = lastLoginTime;
+	}
+
+	public UuzcUserDeatil covert() {
+		UuzcUserDeatil user = new UuzcUserDeatil();
+		user.setEmail(this.secondUID);
+		user.setMobile(this.uid);
+		user.setPassword(this.password);
+		user.setSalt(this.salt);
+		user.setUsername(this.name);
+		user.setUid(this.dialectUID);
+		return user;
+	}
+
+	/**
+	 * 设置是否是hr账号
+	 * 
+	 * <pre>
+	 * 1. 是
+	 * 
+	 * @return
+	 */
+	public Short getHr() {
+		return hr;
+	}
+
+	public void setHr(Short hr) {
+		this.hr = hr;
+	}
+
+}

+ 229 - 0
account-common/src/main/java/com/uas/account/entity/UserDetail.java

@@ -0,0 +1,229 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+/**
+ * 详细个人资料
+ * 
+ * @author yingp
+ *
+ */
+public class UserDetail implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private String mobile;
+	private String email;
+	private String name;
+	private String idCode;
+	private String sex;
+	private String avatar;
+	private Long birthday;
+	private Integer valid;
+	private String department;
+	private String job;
+
+	private String checkcode;
+	private String checkcodeToken;
+
+	/**
+	 * 优软众创注册时的同步信息:唯一标识
+	 */
+	private String uid;
+
+	/**
+	 * 优软众创注册时的同步信息:盐值
+	 */
+	private String salt;
+
+	/**
+	 * 设置数据来源
+	 */
+	private String source;
+
+	/**
+	 * 上次登录时间
+	 */
+	private Long lastLoginTime;
+
+	public UserDetail() {
+	}
+
+	public UserDetail(UserSpaceDetail detail) {
+		this.mobile = detail.getAdminTel();
+		this.email = detail.getAdminEmail();
+		this.name = detail.getAdminName();
+		this.job = "管理员";
+	}
+
+	/**
+	 * 手机号
+	 * 
+	 * @return
+	 */
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	/**
+	 * 邮箱
+	 * 
+	 * @return
+	 */
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	/**
+	 * 姓名
+	 * 
+	 * @return
+	 */
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * 身份证号
+	 * 
+	 * @return
+	 */
+	public String getIdCode() {
+		return idCode;
+	}
+
+	public void setIdCode(String idCode) {
+		this.idCode = idCode;
+	}
+
+	/**
+	 * 性别
+	 * 
+	 * @return
+	 */
+	public String getSex() {
+		return sex;
+	}
+
+	public void setSex(String sex) {
+		this.sex = sex;
+	}
+
+	/**
+	 * 头像
+	 * 
+	 * @return
+	 */
+	public String getAvatar() {
+		return avatar;
+	}
+
+	public void setAvatar(String avatar) {
+		this.avatar = avatar;
+	}
+
+	/**
+	 * 生日
+	 * 
+	 * @return
+	 */
+	public Long getBirthday() {
+		return birthday;
+	}
+
+	public void setBirthday(Long birthday) {
+		this.birthday = birthday;
+	}
+
+	/**
+	 * 是否已验证
+	 * 
+	 * @return
+	 */
+	public Integer getValid() {
+		return valid;
+	}
+
+	public void setValid(Integer valid) {
+		this.valid = valid;
+	}
+
+	public String getDepartment() {
+		return department;
+	}
+
+	public void setDepartment(String department) {
+		this.department = department;
+	}
+
+	public String getJob() {
+		return job;
+	}
+
+	public void setJob(String job) {
+		this.job = job;
+	}
+
+
+	public String getCheckcode() {
+		return checkcode;
+	}
+
+	public void setCheckcode(String checkcode) {
+		this.checkcode = checkcode;
+	}
+
+	public String getCheckcodeToken() {
+		return checkcodeToken;
+	}
+
+	public void setCheckcodeToken(String checkcodeToken) {
+		this.checkcodeToken = checkcodeToken;
+	}
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	public String getSalt() {
+		return salt;
+	}
+
+	public void setSalt(String salt) {
+		this.salt = salt;
+	}
+
+	public String getSource() {
+		return source;
+	}
+
+	public void setSource(String source) {
+		this.source = source;
+	}
+
+	public Long getLastLoginTime() {
+		return lastLoginTime;
+	}
+
+	public void setLastLoginTime(Long lastLoginTime) {
+		this.lastLoginTime = lastLoginTime;
+	}
+}

+ 83 - 0
account-common/src/main/java/com/uas/account/entity/UserQuestion.java

@@ -0,0 +1,83 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+/**
+ * 用户密保问题
+ * @author liusw
+ */
+public class UserQuestion implements Serializable {
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    public UserQuestion() {
+    }
+
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 密保用户的UU号
+     */
+    private Long userUU;
+
+
+    /**
+     * 密保问题
+     */
+    private String question;
+
+    /**
+     * 密保答案
+     */
+    private String answer;
+
+    /**
+     * 排序
+     */
+    private Short sort;
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getQuestion() {
+        return question;
+    }
+
+    public String getAnswer() {
+        return answer;
+    }
+
+    public Short getSort() {
+        return sort;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public void setQuestion(String question) {
+        this.question = question;
+    }
+
+    public void setAnswer(String answer) {
+        this.answer = answer;
+    }
+
+    public void setSort(Short sort) {
+        this.sort = sort;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+}

+ 136 - 0
account-common/src/main/java/com/uas/account/entity/UserSpace.java

@@ -0,0 +1,136 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+import com.uas.sso.common.util.StringUtil;
+
+/**
+ * <pre>
+ * App1					App2
+ * +					-
+ * +	+			-	-
+ * +		+	-		-
+ * +		-	+		-
+ * +	-			+	-
+ * UserSpace1		UserSpace2
+ * +					-
+ * + + +		   -   - 	
+ * +   +  +		-     -
+ * +     +   *	     -
+ * +	   *    +   -
+ * +	-	 +	   *
+ * +  -		   +  -	    +
+ * *		     *		    +
+ * User1		User2		User3
+ * </pre>
+ * 
+ * 用户集
+ * 
+ * @author yingp
+ * 
+ */
+public class UserSpace implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private String appId;
+
+	private Long id;
+
+	private String uid;
+
+	private String dialectUID;
+
+	private String name;
+
+	private Integer userCount;
+
+	public UserSpace() {
+	}
+
+	public UserSpace(App app, UserSpaceDetail detail) {
+		this.appId = app.getUid();
+		this.uid = detail.getBusinessCode();
+		this.name = detail.getName();
+		this.userCount = 0;
+	}
+
+	/**
+	 * 属于哪个应用
+	 */
+	public String getAppId() {
+		return appId;
+	}
+
+	public void setAppId(String appId) {
+		this.appId = appId;
+	}
+
+	/**
+	 * ID
+	 */
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 全局唯一标识,比如企业的商业登记证号、税务登记证号,所有接入的业务系统都认可使用的同一个标识
+	 */
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	/**
+	 * 名称
+	 */
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@Override
+	public String toString() {
+		return "appId=" + StringUtil.nvl(appId, "") + "&id=" + StringUtil.nvl(id, "") + "&uid=" + StringUtil.nvl(uid, "") + "&name="
+				+ StringUtil.nvl(name, "") + "&dialectUID=" + StringUtil.nvl(dialectUID, "");
+	}
+
+	/**
+	 * 业务系统自己的,除UID之外的,唯一标识字段(例如,en_uu) <br>
+	 * 因为业务系统可能历史原因,部分企业信息并没有UID
+	 * 
+	 * @return
+	 */
+	public String getDialectUID() {
+		return dialectUID;
+	}
+
+	public void setDialectUID(String dialectUID) {
+		this.dialectUID = dialectUID;
+	}
+
+	/**
+	 * 绑定的用户个数
+	 */
+	public Integer getUserCount() {
+		return userCount;
+	}
+
+	public void setUserCount(Integer userCount) {
+		this.userCount = userCount;
+	}
+
+}

+ 604 - 0
account-common/src/main/java/com/uas/account/entity/UserSpaceDetail.java

@@ -0,0 +1,604 @@
+package com.uas.account.entity;
+
+import org.hibernate.validator.constraints.Length;
+
+import java.io.Serializable;
+
+/**
+ * 详细企业资料
+ * 
+ * <pre>
+ * 应涵盖全部企业信息,满足所有应用需求
+ * </pre>
+ * 
+ * @author yingp
+ * 
+ */
+public class UserSpaceDetail implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private Long id;
+
+	private String name;
+
+//	@NotEmpty(message = "{us.shortName.null}")
+	private String shortName;
+
+	@Length(max = 50, message = "{us.businessCode.length.illegal}")
+	private String businessCode;
+
+	private String businessCodeImage;
+
+	private String address;
+	private String province;
+	private String city;
+	private String district;
+	private String street;
+	private String corporation;
+	private String fax;
+	private String tel;
+	private Long registerDate;
+	private String type;
+	private String url;
+	private String area;
+	private String industry;
+	private String domain;
+	private String inviteuid;
+	private String inviteUserCode;
+	private String method;
+
+//	@NotEmpty(message = "{us.admin.name.null}")
+	private String adminName;
+
+	private String adminTel;
+
+//	@NotEmpty(message = "{us.admin.email.null}")
+	private String adminEmail;
+
+	private Integer status;
+
+	private Integer approveStatus;
+
+	private String applyApps;
+
+	private String errMsg;
+
+	private String logoImage;
+
+	private String checkcode;
+
+	private String checkcodeToken;
+
+    private String contactMan;
+
+    private String contactTel;
+
+    private String contactEmail;
+
+    private String tags;
+
+    private String profession;
+
+    private Long uu;
+
+    /**
+	 * 注册全称
+	 * 
+	 * @return
+	 */
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * 简称
+	 *
+	 * @return
+	 */
+	public String getShortName() {
+		return shortName;
+	}
+
+	public void setShortName(String shortName) {
+		this.shortName = shortName;
+	}
+
+	/**
+	 * 注册号
+	 * 
+	 * @return
+	 */
+	public String getBusinessCode() {
+		return businessCode;
+	}
+
+	public void setBusinessCode(String businessCode) {
+		this.businessCode = businessCode;
+	}
+
+	/**
+	 * 注册地址
+	 * 
+	 * @return
+	 */
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	/**
+	 * 法人名
+	 * 
+	 * @return
+	 */
+	public String getCorporation() {
+		return corporation;
+	}
+
+	public void setCorporation(String corporation) {
+		this.corporation = corporation;
+	}
+
+	/**
+	 * 传真
+	 * 
+	 * @return
+	 */
+	public String getFax() {
+		return fax;
+	}
+
+	public void setFax(String fax) {
+		this.fax = fax;
+	}
+
+	/**
+	 * 注册(优软平台)的日期
+	 * 
+	 * @return
+	 */
+	public Long getRegisterDate() {
+		return registerDate;
+	}
+
+	public void setRegisterDate(Long registerDate) {
+		this.registerDate = registerDate;
+	}
+
+	/**
+	 * 企业类型
+	 * 
+	 * @return
+	 */
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	/**
+	 * 官网
+	 * 
+	 * @return
+	 */
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	/**
+	 * 区域
+	 * 
+	 * @return
+	 */
+	public String getArea() {
+		return area;
+	}
+
+	public void setArea(String area) {
+		this.area = area;
+	}
+
+	/**
+	 * 主营类型
+	 * 
+	 * @return
+	 */
+	public String getIndustry() {
+		return industry;
+	}
+
+	public void setIndustry(String industry) {
+		this.industry = industry;
+	}
+
+	/**
+	 * (优软平台分配的)二级域名
+	 * 
+	 * @return
+	 */
+	public String getDomain() {
+		return domain;
+	}
+
+	public void setDomain(String domain) {
+		this.domain = domain;
+	}
+
+	/**
+	 * 审核状态
+	 * 
+	 * @return
+	 */
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	/**
+	 * 企业联系电话
+	 * 
+	 * @return
+	 */
+	public String getTel() {
+		return tel;
+	}
+
+	public void setTel(String tel) {
+		this.tel = tel;
+	}
+
+	/**
+	 * 营业执照附件
+	 * 
+	 * @return
+	 */
+	public String getBusinessCodeImage() {
+		return businessCodeImage;
+	}
+
+	public void setBusinessCodeImage(String businessCodeImage) {
+		this.businessCodeImage = businessCodeImage;
+	}
+
+	/**
+	 * 管理员名
+	 *
+	 * @return
+	 */
+	public String getAdminName() {
+		return adminName;
+	}
+
+	public void setAdminName(String adminName) {
+		this.adminName = adminName;
+	}
+
+	/**
+	 * 管理员电话
+	 * 
+	 * @return
+	 */
+	public String getAdminTel() {
+		return adminTel;
+	}
+
+	public void setAdminTel(String adminTel) {
+		this.adminTel = adminTel;
+	}
+
+	/**
+	 * 管理员邮箱
+	 *
+	 * @return
+	 */
+	public String getAdminEmail() {
+		return adminEmail;
+	}
+
+	public void setAdminEmail(String adminEmail) {
+		this.adminEmail = adminEmail;
+	}
+
+	/**
+	 * 申请的应用
+	 * 
+	 * @return
+	 */
+	public String getApplyApps() {
+		return applyApps;
+	}
+
+	public void setApplyApps(String applyApps) {
+		this.applyApps = applyApps;
+	}
+
+	/**
+	 * 错误信息
+	 * 
+	 * @return
+	 */
+	public String getErrMsg() {
+		return errMsg;
+	}
+
+	public void setErrMsg(String errMsg) {
+		this.errMsg = errMsg;
+	}
+
+	/**
+	 * 省
+	 * 
+	 * @return
+	 */
+	public String getProvince() {
+		return province;
+	}
+
+	public void setProvince(String province) {
+		this.province = province;
+	}
+
+	/**
+	 * 市
+	 * 
+	 * @return
+	 */
+	public String getCity() {
+		return city;
+	}
+
+	public void setCity(String city) {
+		this.city = city;
+	}
+
+	/**
+	 * 区
+	 * 
+	 * @return
+	 */
+	public String getDistrict() {
+		return district;
+	}
+
+	public void setDistrict(String district) {
+		this.district = district;
+	}
+
+	/**
+	 * 街道
+	 * 
+	 * @return
+	 */
+	public String getStreet() {
+		return street;
+	}
+
+	public void setStreet(String street) {
+		this.street = street;
+	}
+
+	public UserSpace simple(App app) {
+		UserSpace userSpace = new UserSpace();
+		userSpace.setAppId(app.getUid());
+		userSpace.setDialectUID(this.businessCode);
+		userSpace.setName(this.name);
+		userSpace.setUserCount(0);
+		return userSpace;
+	}
+
+	/**
+	 * logo图标
+	 * 
+	 * @return
+	 */
+	public String getLogoImage() {
+		return logoImage;
+	}
+
+	public void setLogoImage(String logoImage) {
+		this.logoImage = logoImage;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 验证状态
+	 * @return
+	 */
+	public Integer getApproveStatus() {
+		return approveStatus;
+	}
+
+	public void setApproveStatus(Integer approveStatus) {
+		this.approveStatus = approveStatus;
+	}
+
+	public String getCheckcode() {
+		return checkcode;
+	}
+
+	/**
+	 * 注册时的验证码,用于后端验证验证码,不做保存
+	 * 
+	 * @param checkcode
+	 */
+	public void setCheckcode(String checkcode) {
+		this.checkcode = checkcode;
+	}
+
+	public String getCheckcodeToken() {
+		return checkcodeToken;
+	}
+
+	/**
+	 * 注册时的验证码的token,用于后端验证验证码,不做保存
+	 * 
+	 * @param checkcodeToken
+	 */
+	public void setCheckcodeToken(String checkcodeToken) {
+		this.checkcodeToken = checkcodeToken;
+	}
+
+	/**
+	 * 注册时,如果是别人邀请的链接注册,带出邀请企业信息
+	 * 
+	 * @return
+	 */
+	public String getInviteuid() {
+		return inviteuid;
+	}
+
+	public void setInviteuid(String inviteuid) {
+		this.inviteuid = inviteuid;
+	}
+
+	/**
+	 * 注册时,如果是别人邀请的链接注册,带出邀请人信息
+	 * 
+	 * @return
+	 */
+	public String getInviteUserCode() {
+		return inviteUserCode;
+	}
+
+	public void setInviteUserCode(String inviteUserCode) {
+		this.inviteUserCode = inviteUserCode;
+	}
+
+	/**
+	 * 邀请如果有方式为addVendor,需要同步到平台去自动添加供应商
+	 * 
+	 * @return
+	 */
+	public String getMethod() {
+		return method;
+	}
+
+	public void setMethod(String method) {
+		this.method = method;
+	}
+
+	/**
+	 * 联系人
+	 *
+	 * @return
+	 */
+	public String getContactMan() {
+		return contactMan;
+	}
+
+	public void setContactMan(String contactMan) {
+		this.contactMan = contactMan;
+	}
+
+    /**
+     * 联系人电话
+     *
+     * @return
+     */
+    public String getContactTel() {
+        return contactTel;
+    }
+
+    public void setContactTel(String contactTel) {
+        this.contactTel = contactTel;
+    }
+
+    /**
+     * 联系人邮箱
+     *
+     * @return
+     */
+    public String getContactEmail() {
+        return contactEmail;
+    }
+
+    public void setContactEmail(String contactEmail) {
+        this.contactEmail = contactEmail;
+    }
+
+	/**
+     * 标签
+     *
+     * @return
+     */
+	public String getTags() {
+		return tags;
+	}
+
+	public void setTags(String tags) {
+		this.tags = tags;
+	}
+
+	/**
+     * 行业
+     *
+     * @return
+     */
+    public String getProfession() {
+        return profession;
+    }
+
+    public void setProfession(String profession) {
+        this.profession = profession;
+    }
+
+	/**
+	 * 企业UU
+	 * @return
+	 */
+	public Long getUu() {
+		return uu;
+	}
+
+	public void setUu(Long uu) {
+		this.uu = uu;
+	}
+
+    /**
+     * 众创需要的企业的信息
+     *
+     * @return
+     */
+	public UuzcUserSpaceDetail covert() {
+        UuzcUserSpaceDetail detail = new UuzcUserSpaceDetail();
+        detail.setAdminEmail(this.adminEmail);
+        detail.setAdminName(this.adminName);
+        detail.setAdminTel(this.adminTel);
+        detail.setBusinessCode(this.businessCode);
+        detail.setContactEmail(this.contactEmail);
+        detail.setContactMan(this.contactMan);
+        detail.setContactTel(this.contactTel);
+        detail.setCorporation(this.corporation);
+        detail.setName(this.name);
+        detail.setTel(this.tel);
+        detail.setUrl(this.url);
+        return detail;
+    }
+}

+ 46 - 0
account-common/src/main/java/com/uas/account/entity/UserView.java

@@ -0,0 +1,46 @@
+package com.uas.account.entity;
+
+public class UserView extends User {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 用户集名称
+	 */
+	private String spaceName;
+
+	/**
+	 * 企业域名
+	 */
+	private String spaceDomain;
+
+	public String getSpaceName() {
+		return spaceName;
+	}
+
+	public void setSpaceName(String spaceName) {
+		this.spaceName = spaceName;
+	}
+
+	public String getSpaceDomain() {
+		return spaceDomain;
+	}
+
+	public void setSpaceDomain(String spaceDomain) {
+		this.spaceDomain = spaceDomain;
+	}
+
+    public UuzcUserDeatil covert() {
+		UuzcUserDeatil detail = new UuzcUserDeatil();
+		detail.setEmail(this.getSecondUID());
+		detail.setMobile(this.getUid());
+		detail.setPassword(this.getPassword());
+		detail.setSalt(this.getSalt());
+		detail.setUid(this.getDialectUID());
+		detail.setUsername(this.getName());
+		return detail;
+	}
+
+}

+ 107 - 0
account-common/src/main/java/com/uas/account/entity/UuzcUserDeatil.java

@@ -0,0 +1,107 @@
+package com.uas.account.entity;
+
+/**
+ * 优软众创用户信息格式
+ * 
+ * @author hejq
+ * @time 创建时间:2017年10月12日
+ */
+public class UuzcUserDeatil {
+
+	private String uid;
+
+	private String username;
+
+	private String password;
+
+	private String email;
+
+	private String mobile;
+
+	private String salt;
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	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 getSalt() {
+		return salt;
+	}
+
+	public void setSalt(String salt) {
+		this.salt = salt;
+	}
+
+	public UserDetail covert() {
+		UserDetail user = new UserDetail();
+		user.setEmail(this.email);
+		user.setMobile(this.mobile);
+		user.setName(this.username);
+		user.setUid(this.uid);
+		user.setSalt(this.salt);
+		return user;
+	}
+
+	public User covertUser() {
+		User user = new User();
+		user.setDialectUID(this.uid);
+		user.setUid(this.mobile);
+		user.setSecondUID(this.email);
+		user.setName(this.username);
+		user.setSalt(this.salt);
+		if (this.uid != null) {
+			user.setAppId("b2b");
+		} else {
+			user.setAppId("uuzc");
+		}
+		user.setPassword(this.password);
+		return user;
+	}
+
+	@Override
+	public String toString() {
+		return "uid='" + uid + '\'' +
+				", username='" + username + '\'' +
+				", password='" + password + '\'' +
+				", email='" + email + '\'' +
+				", mobile='" + mobile + '\'' +
+				", salt='" + salt + '\'' +
+				'}';
+	}
+}

+ 152 - 0
account-common/src/main/java/com/uas/account/entity/UuzcUserSpaceDetail.java

@@ -0,0 +1,152 @@
+package com.uas.account.entity;
+
+/**
+ * 优软众创企业信息需要的资料
+ *
+ * Created by hejq on 2017-11-09.
+ */
+public class UuzcUserSpaceDetail {
+
+    /**
+     * 企业名称
+     */
+    private String name;
+
+    /**
+     * 企业营业执照号
+     */
+    private String businessCode;
+
+    /**
+     * 法人名
+     */
+    private String corporation;
+
+    /**
+     * 企业电话
+     */
+    private String tel;
+
+    /**
+     * 企业官网
+     */
+    private String url;
+
+    /**
+     * 管理员姓名
+     */
+    private String adminName;
+
+    /**
+     * 管理员联系方式
+     */
+    private String adminTel;
+
+    /**
+     * 管理员邮箱
+     */
+    private String adminEmail;
+
+    /**
+     * 联系人
+     */
+    private String contactMan;
+
+    /**
+     * 联系人电话
+     */
+    private String contactTel;
+
+    /**
+     * 联系人邮箱
+     */
+    private String contactEmail;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getBusinessCode() {
+        return businessCode;
+    }
+
+    public void setBusinessCode(String businessCode) {
+        this.businessCode = businessCode;
+    }
+
+    public String getCorporation() {
+        return corporation;
+    }
+
+    public void setCorporation(String corporation) {
+        this.corporation = corporation;
+    }
+
+    public String getTel() {
+        return tel;
+    }
+
+    public void setTel(String tel) {
+        this.tel = tel;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getAdminName() {
+        return adminName;
+    }
+
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    public String getAdminTel() {
+        return adminTel;
+    }
+
+    public void setAdminTel(String adminTel) {
+        this.adminTel = adminTel;
+    }
+
+    public String getAdminEmail() {
+        return adminEmail;
+    }
+
+    public void setAdminEmail(String adminEmail) {
+        this.adminEmail = adminEmail;
+    }
+
+    public String getContactMan() {
+        return contactMan;
+    }
+
+    public void setContactMan(String contactMan) {
+        this.contactMan = contactMan;
+    }
+
+    public String getContactTel() {
+        return contactTel;
+    }
+
+    public void setContactTel(String contactTel) {
+        this.contactTel = contactTel;
+    }
+
+    public String getContactEmail() {
+        return contactEmail;
+    }
+
+    public void setContactEmail(String contactEmail) {
+        this.contactEmail = contactEmail;
+    }
+}

+ 19 - 0
account-common/src/main/java/com/uas/account/exception/AccountException.java

@@ -0,0 +1,19 @@
+package com.uas.account.exception;
+
+public class AccountException extends RuntimeException {
+
+	private static final long serialVersionUID = 1L;
+
+	public AccountException(String message) {
+		super(message);
+	}
+
+	public AccountException(Throwable throwable) {
+		super(throwable);
+	}
+
+	public AccountException(String message, Throwable throwable) {
+		super(message, throwable);
+	}
+
+}

+ 91 - 0
account-common/src/main/java/com/uas/account/support/Page.java

@@ -0,0 +1,91 @@
+package com.uas.account.support;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class Page<T> implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private int number;
+	private int size;
+	private int numberOfElements;
+	private List<T> content;
+	private boolean first;
+	private boolean last;
+	private long totalElements;
+
+	public Page() {
+
+	}
+
+	public Page(int pageNumber, int pageSize, List<T> content, int totalElements) {
+		this.number = pageNumber;
+		this.size = pageSize;
+		this.content = content;
+		this.numberOfElements = content == null || content.isEmpty() ? 0 : content.size();
+		this.totalElements = totalElements;
+		this.first = pageNumber == 1;
+		this.last = pageNumber >= (int) Math.floor((double) totalElements / pageSize);
+	}
+
+	public int getNumber() {
+		return number;
+	}
+
+	public void setNumber(int number) {
+		this.number = number;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public int getNumberOfElements() {
+		return numberOfElements;
+	}
+
+	public void setNumberOfElements(int numberOfElements) {
+		this.numberOfElements = numberOfElements;
+	}
+
+	public List<T> getContent() {
+		return content;
+	}
+
+	public void setContent(List<T> content) {
+		this.content = content;
+	}
+
+	public boolean isFirst() {
+		return first;
+	}
+
+	public void setFirst(boolean first) {
+		this.first = first;
+	}
+
+	public boolean isLast() {
+		return last;
+	}
+
+	public void setLast(boolean last) {
+		this.last = last;
+	}
+
+	public long getTotalElements() {
+		return totalElements;
+	}
+
+	public void setTotalElements(long totalElements) {
+		this.totalElements = totalElements;
+	}
+
+}

+ 1061 - 0
account-common/src/main/java/com/uas/account/util/AccountUtils.java

@@ -0,0 +1,1061 @@
+package com.uas.account.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.uas.account.AccountConfig;
+import com.uas.account.ResultWrap;
+import com.uas.account.entity.*;
+import com.uas.account.support.Page;
+import com.uas.sso.SSOHelper;
+import com.uas.sso.SSOToken;
+import com.uas.sso.common.util.HttpUtil;
+import com.uas.sso.common.util.HttpUtil.ResponseWrap;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 客户端使用,操作企业资料、用户资料
+ *
+ * @author yingp
+ *
+ */
+public class AccountUtils {
+
+	/**
+	 * 修改用户信息
+	 *
+	 * @param user
+	 * @param userDetail
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> saveUser(User user, UserDetail userDetail) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = new JSONObject();
+			if (userDetail != null) {
+				formData = JSON.parseObject(JSON.toJSONString(userDetail));
+			}
+			if (user != null) {
+				if (user.getUid() == null) {
+					user.setUid(userDetail.getMobile());
+				}
+				if (user.getSecondUID() == null) {
+					user.setSecondUID(userDetail.getEmail());
+				}
+				if (user.getAppId() != null && user.getDialectUID() != null) {
+					if (user.getAppId().equals("b2b") || user.getAppId().equals("mall")) {
+						user.setSalt(user.getDialectUID());
+					}
+				}
+				formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
+			}
+			ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (result.isError()) {
+					throw new Exception(result.getErrMsg());
+				} else {
+					return JSON.parseArray(JSON.toJSONString(result.getContent()), User.class);
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 修改用户信息
+	 *
+	 * @param dialectUID
+	 *            个人唯一标识
+	 * @param spaceDialectUID
+	 *            企业唯一标识
+	 * @param userDetail
+	 *            个人详细信息
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> saveUser(Object dialectUID, Object spaceDialectUID, UserDetail userDetail) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		return saveUser(user, userDetail);
+	}
+
+	/**
+	 * 保存与当前应用无关的用户信息,借用appId=sso
+	 *
+	 * @param uid
+	 * @param spaceUID
+	 * @param userDetail
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> saveCustUser(Object uid, Object spaceUID, UserDetail userDetail) throws Exception {
+		User user = new User();
+		user.setAppId(AccountConfig.ACCOUNT_CENTER);
+		user.setDialectUID(uid.toString());
+		user.setSpaceUID(spaceUID.toString());
+		return saveUser(user, userDetail);
+	}
+
+	/**
+	 * 添加用户信息
+	 *
+	 * @param dialectUID
+	 *            个人唯一标识
+	 * @param spaceDialectUID
+	 *            企业唯一标识
+	 * @param userDetail
+	 *            个人详细信息
+	 * @param noEncryPwd
+	 *            明文密码
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> addUser(Object dialectUID, Object spaceDialectUID, UserDetail userDetail, String noEncryPwd) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		user.setPassword(noEncryPwd);
+		return saveUser(user, userDetail);
+	}
+
+	public static List<UserSpace> saveUserSpace(UserSpace space, UserSpaceDetail spaceDetail) throws Exception {
+		String saveUrl = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = new JSONObject();
+			if (spaceDetail != null) {
+				formData = JSON.parseObject(JSON.toJSONString(spaceDetail));
+			}
+			if (space != null) {
+				if (space.getUid() == null) {
+					space.setUid(spaceDetail.getBusinessCode());
+				}
+				formData.putAll(JSON.parseObject(JSON.toJSONString(space)));
+			}
+			ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (result.isError()) {
+					throw new Exception(result.getErrMsg());
+				} else {
+					return JSON.parseArray(JSON.toJSONString(result.getContent()), UserSpace.class);
+				}
+			}
+		}
+		return null;
+	}
+
+	public static List<UserSpace> saveUserSpace(Object dialectUID, UserSpaceDetail spaceDetail) throws Exception {
+		UserSpace userSpace = new UserSpace();
+		userSpace.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		userSpace.setDialectUID(dialectUID.toString());
+		return saveUserSpace(userSpace, spaceDetail);
+	}
+
+	/**
+	 * 解除绑定的应用
+	 * 
+	 * @param userSpace
+	 * @throws Exception
+	 */
+	public static void unbindUserSpace(UserSpace userSpace) throws Exception {
+		String saveUrl = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(userSpace));
+			formData.put("_operate", "unbind");
+			ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+		}
+	}
+
+	/**
+	 * 解除绑定的应用
+	 * 
+	 * @param uid
+	 * @throws Exception
+	 */
+	public static void unbindUserSpace(String uid) throws Exception {
+		unbindUserSpace(SSOHelper.getSSOService().getConfig().getAppName(), uid);
+	}
+
+	/**
+	 * 解除绑定的应用
+	 * 
+	 * @param appId
+     * @param uid
+	 * @throws Exception
+	 */
+	public static void unbindUserSpace(String appId, String uid) throws Exception {
+		UserSpace userSpace = new UserSpace();
+		userSpace.setAppId(appId);
+		userSpace.setUid(uid);
+		unbindUserSpace(userSpace);
+	}
+
+	/**
+	 * 解除绑定的云账号
+	 *
+	 * @param user
+	 * @throws Exception
+	 */
+	public static void unbindUser(User user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			formData.put("_operate", "unbind");
+			ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+		}
+	}
+
+	/**
+	 * 解除绑定的云账号
+	 *
+	 * @param dialectUID
+     * @param spaceDialectUID
+	 * @throws Exception
+	 */
+	public static void unbindUser(Object dialectUID, Object spaceDialectUID) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		unbindUser(user);
+	}
+
+	/**
+	 * 校验密码
+	 *
+	 * @param user
+	 * @throws Exception
+	 */
+	public static boolean checkPassword(User user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			formData.put("_operate", "check");
+			ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+				else
+					return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * 校验密码
+	 *
+	 * @param dialectUID
+	 * @param spaceDialectUID
+	 * @param password
+	 * @throws Exception
+	 */
+	public static boolean checkPassword(Object dialectUID, Object spaceDialectUID, String password) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		user.setPassword(password);
+		return checkPassword(user);
+	}
+
+	/**
+	 * 校验密码
+	 *
+	 * <pre>
+	 * 全匹配模式
+	 * </pre>
+	 *
+	 * @param user
+	 * @throws Exception
+	 */
+	public static boolean fuzzyCheckPassword(User user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			formData.put("_operate", "fuzzyCheck");
+			ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+				else
+					return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * 校验密码
+	 *
+	 * <pre>
+	 * 全匹配模式
+	 * </pre>
+	 *
+	 * @param dialectUID
+	 * @param spaceDialectUID
+	 * @param password
+	 * @throws Exception
+	 */
+	public static boolean fuzzyCheckPassword(Object dialectUID, Object spaceDialectUID, String password) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		user.setPassword(password);
+		return fuzzyCheckPassword(user);
+	}
+
+	/**
+	 * 重置密码
+	 *
+	 * @param user
+	 * @throws Exception
+	 */
+	public static void resetPassword(User user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		saveUrl = saveUrl + "/resetPwd";
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			//formData.put("_operate", "reset");
+			ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+			}
+		}
+	}
+
+	/**
+	 * 重置密码
+	 *
+	 * @param dialectUID
+	 *            应用自己的用户唯一标识
+	 * @param spaceDialectUID
+	 *            企业唯一标识
+	 * @param noEncryPwd
+	 *            新密码(明文)
+	 * @throws Exception
+	 */
+	public static void resetPassword(Object dialectUID, Object spaceDialectUID, String noEncryPwd) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setDialectUID(dialectUID.toString());
+		if (spaceDialectUID != null) {
+			user.setSpaceDialectUID(spaceDialectUID.toString());
+		}
+		user.setPassword(noEncryPwd);
+		resetPassword(user);
+	}
+
+	/**
+	 * 重置密码
+	 *
+	 * @param mobile
+	 *            手机号
+	 * @param noEncryPwd
+	 *            新密码(明文)
+	 * @throws Exception
+	 */
+	public static void resetPassword(String mobile, String noEncryPwd) throws Exception {
+		User user = new User();
+		user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
+		user.setUid(mobile);
+		user.setPassword(noEncryPwd);
+		resetPassword(user);
+	}
+
+	/**
+	 * 获取校验码
+	 *
+	 * @param username
+	 *            手机号或邮箱地址
+	 * @return
+	 */
+	public static void sendValidCode(String username) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "getVcode").addAttribute("username", username));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+			}
+		}
+	}
+
+	/**
+	 * 验证校验码
+	 *
+	 * @param username
+	 *            手机号或邮箱地址
+	 * @param validCode
+	 *            校验码
+	 * @return
+	 */
+	public static boolean checkValidCode(String username, String validCode) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "checkVcode").addAttribute("username", username)
+					.addAttribute("validCode", validCode));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+				else
+					return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * 验证密码,返回绑定身份信息的token
+	 *
+	 * @return
+	 */
+	public static String getAccessToken(User user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			formData.put("_operate", "getToken");
+			ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+				else
+					return String.valueOf(result.getContent());
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 验证token,返回当前应用相关的身份信息
+	 *
+	 * @return
+	 */
+	public static UserView checkAccessToken(String token) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap res = HttpUtil.doGet(
+					saveUrl,
+					new ModelMap("_operate", "checkToken").addAttribute("token", token).addAttribute("appId",
+							SSOHelper.getSSOService().getConfig().getAppName()));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess())
+					throw new Exception(result.getErrMsg());
+				else
+					return JSON.parseObject(JSON.toJSONString(result.getContent()), UserView.class);
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 用token验证登录
+	 *
+	 * @param request
+	 * @param response
+	 * @param token
+	 * @throws Exception
+	 */
+	public static UserView loginByAccessToken(HttpServletRequest request, HttpServletResponse response, String token) throws Exception {
+		UserView user = checkAccessToken(token);
+		if (null != user) {
+			SSOToken st = new SSOToken(request, user.getUid());
+			st.setData(JSON.toJSONString(user));
+			SSOHelper.setSSOCookie(request, response, st, true);
+		}
+		return user;
+	}
+
+	/**
+	 * 传入当前登录的企业的营业执照号,查询发出的申请
+	 *
+	 * @param businessCode
+	 * @param statusCode
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 * @throws Exception
+	 */
+	public static Page<PartnershipRecord> getAllRequest(String businessCode, Integer statusCode, String keyword, int pageNumber,
+														int pageSize) throws Exception {
+		String getUrl = AccountConfig.getEnPartnersUrl();
+		if (!StringUtils.isEmpty(getUrl)) {
+			ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequest").addAttribute("businessCode", businessCode)
+					.addAttribute("statusCode", statusCode).addAttribute("businessCode", businessCode).addAttribute("keyword", keyword)
+					.addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			return JSONObject.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
+			});
+		}
+		return null;
+	}
+
+	/**
+	 * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用)
+	 * @param businessCode
+	 * @param statusCode
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param partnerUUs
+	 * @return
+	 */
+	public static Page<PartnershipRecord> getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs, int pageNumber, int pageSize) throws Exception {
+		String getUrl = AccountConfig.getEnPartnersUrl();
+		if (!StringUtils.isEmpty(getUrl)) {
+			ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequestFilterByPartnerUUs").addAttribute("businessCode", businessCode)
+					.addAttribute("statusCode", statusCode).addAttribute("keyword", keyword).addAttribute("partnerUUs", JSON.toJSON(partnerUUs))
+					.addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			return JSON.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
+			});
+		}
+		return null;
+	}
+
+	/**
+	 * 进入企业圈
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	public static String redirectContactPage() throws Exception {
+		String enterUrl = AccountConfig.getContactPageUrl();
+		return enterUrl;
+	}
+
+	/**
+	 * 通过关键词搜索企业信息
+	 *
+	 * @param keyword
+	 * @return
+	 * @throws Exception
+	 */
+	public static Page<UserSpaceDetail> getUserSpacesByKeyword(String keyword, int pageNumber, int pageSize) throws Exception {
+		String Url = AccountConfig.getEnPartnersUrl();
+		if (!StringUtils.isEmpty(Url)) {
+			ResponseWrap res = HttpUtil.doGet(Url,
+					new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", keyword).addAttribute("pageNumber", pageNumber)
+							.addAttribute("pageSize", pageSize));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			return JSON.parseObject(res.getContent(), new TypeReference<Page<UserSpaceDetail>>() {
+			});
+		}
+		return null;
+	}
+
+	/**
+	 * 通过手机号搜索用户账号信息
+	 *
+	 * @param uid
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> getUserInfoByUid(String uid) throws Exception {
+		String Url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(Url)) {
+			ResponseWrap res = HttpUtil.doGet(Url + "/userInfo",
+					new ModelMap("uid", uid));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			String resText = res.getContent();
+			JSONObject object = JSON.parseObject(resText);
+			String contentText = object.getString("content");
+			return JSON.parseArray(contentText, User.class);
+		}
+		return null;
+	}
+
+	/**
+	 * 通过营业执照号获取企业应用
+	 *
+	 * @param uid
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<UserSpace> getUserSpaceByUid(String uid) throws Exception {
+		String Url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(Url)) {
+			ResponseWrap res = HttpUtil.doGet(Url + "/" + uid);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			String resText = res.getContent();
+			JSONObject object = JSON.parseObject(resText);
+			String contentText = object.getString("content");
+			return JSON.parseArray(contentText, UserSpace.class);
+		}
+		return null;
+	}
+
+	/**
+	 * 新增一条合作关系记录
+	 *
+	 * @param record
+	 * @return
+	 * @throws Exception
+	 */
+	public static String addNewRecord(PartnershipRecord record) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
+			formData.put("_operate", "addPartner");
+			ResponseWrap res = HttpUtil.doPost(url, formData);
+			result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 同步供应商关系为合作关系记录
+	 *
+	 * @param record
+	 * @return
+	 * @throws Exception
+	 */
+	public static String synchronizeRecord(PartnershipRecord record) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
+			formData.put("_operate", "synchronizePartner");
+			ResponseWrap res = HttpUtil.doPost(url, formData);
+			result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 通过id和申请人的电话进行确认
+	 *
+	 * @param id
+	 * @param vendUserTel
+     * @param appId
+	 * @return
+	 * @throws Exception
+	 */
+	public static String acceptRequest(Long id, String vendUserTel, String appId) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(
+					url,
+					new ModelMap("_operate", "acceptRequest").addAttribute("id", id).addAttribute("vendUserTel", vendUserTel)
+							.addAttribute("appId", appId));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				result = res.getContent();
+			}
+		}
+		return result;
+	}
+
+	/**
+	 * 申请不通过,通过申请人的电话操作,并标出原因
+	 *
+	 * @param id
+	 * @param reason
+	 * @param vendUserTel
+     * @param appId
+	 * @return
+	 * @throws Exception
+	 */
+	public static String rejectRequest(Long id, String reason, String vendUserTel, String appId) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(
+					url,
+					new ModelMap("_operate", "rejectRequest").addAttribute("id", id).addAttribute("reason", reason)
+							.addAttribute("vendUserTel", vendUserTel).addAttribute("appId", appId));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				result = res.getContent();
+			}
+		}
+		return result;
+	}
+
+	/**
+	 * 通过当前企业号和企业列表中的企业号查询申请状态
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	public static RequsetStatus getStatusByCustUidAndVendUid(String custUid, String vendUid) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		RequsetStatus request = new RequsetStatus();
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus").addAttribute("custUid", custUid)
+					.addAttribute("vendUid", vendUid));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else {
+				request = JSON.parseObject(res.getContent(), RequsetStatus.class);
+			}
+		}
+		return request;
+	}
+
+	/**
+	 * 搜索词通过id返回数据
+	 * 
+	 * @param ids
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<UserSpaceDetail> findAll(String ids) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		List<UserSpaceDetail> details = new ArrayList<UserSpaceDetail>();
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "findAll").addAttribute("ids", ids));
+			if(!res.isSuccess())
+				throw new Exception(res.getContent());
+			else 
+				details = JSONObject.parseArray(res.getContent(), UserSpaceDetail.class);
+		}
+		return details;
+	}
+
+	/**
+	 * 通过企业营业执照查询收到的待处理的请求
+	 * 
+	 * @param businessCode
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getRequestTodo(String businessCode) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url,
+					new ModelMap("_operate", "getRequestTodo").addAttribute("businessCode", businessCode));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else
+				result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 其他应用发起邀请注册,同步数据
+	 * 
+	 * @param jsonStr
+	 * @throws Exception
+	 */
+	public static void synchroInvitation(String jsonStr) throws Exception {
+		String url = AccountConfig.getEnPartnersUrl();
+		if (!StringUtils.isEmpty(url)) {
+			HttpUtil.doPost(url, new ModelMap("_operate", "invitation").addAttribute("jsonStr", jsonStr));
+		}
+	}
+
+	/**
+	 * ERP、SAAS新开账套名称校验
+	 * 
+	 * @param name
+	 * @return
+	 * @throws Exception
+	 */
+	public static String validName(String name) throws Exception {
+		String result = null;
+		String url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
+					50);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else
+				result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * ERP、SAAS新开账套名称校验
+	 * 
+	 * @param businessCode
+	 * @return
+	 * @throws Exception
+	 */
+	public static String validBusinessCode(String businessCode) throws Exception {
+		String result = null;
+		String url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url,
+					new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else
+				result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 通过营业执照号查找 企业详细信息
+	 *
+	 * @param
+	 * @return
+	 * @throws Exception
+	 */
+	public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception {
+		String result = null;
+		String url = AccountConfig.getSpaceSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doGet(url,
+					new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50);
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else
+				result = res.getContent();
+		}
+		return JSON.parseObject(result,UserSpaceDetail.class);
+	}
+
+	/**
+	 * ERP、SAAS新开账套
+	 * 
+	 * @param userSpaceDetail
+	 * @param users
+	 * @throws Exception
+	 */
+	public static String applyApp(UserSpaceDetail userSpaceDetail, List<UserDetail> users) throws Exception {
+		String url = AccountConfig.getSpaceSaveUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
+							.addAttribute("detail", JSON.toJSON(userSpaceDetail))
+							.addAttribute("userInfos", JSON.toJSON(users)));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else 
+				result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 商城个人账号增加企业注册
+	 * 
+	 * @param userSpaceDetail
+	 * @throws Exception
+	 */
+	public static String applyAppForMall(UserSpaceDetail userSpaceDetail) throws Exception {
+		String url = AccountConfig.getSpaceSaveUrl();
+		String result = null;
+		if (!StringUtils.isEmpty(url)) {
+			ResponseWrap res = HttpUtil.doPost(url,
+					new ModelMap("_operate", "registForMall")
+					.addAttribute("detail", JSON.toJSON(userSpaceDetail)));
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+			else
+				result = res.getContent();
+		}
+		return result;
+	}
+
+	/**
+	 * 设置hr账号
+	 * 
+	 * @param user
+	 * @param detail
+	 * @return
+	 * @throws Exception
+	 */
+	public static String setHrAccount(User user, UuzcUserSpaceDetail detail) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		saveUrl = saveUrl + "/setHrAccount";
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = new JSONObject();
+			if (detail != null) {
+				formData = JSON.parseObject(JSON.toJSONString(detail));
+			}
+			if (null != user) {
+				formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
+			}
+			ResponseWrap response = HttpUtil.doPost(saveUrl, formData);
+			if (!response.isSuccess())
+				throw new Exception(response.getContent());
+			else {
+				return response.getContent();
+			}
+		}
+		return null;
+	}
+
+    /**
+     * 根据营业执照获取众创需要的企业资料
+     *
+     * @param businessCode
+     * @return
+     * @throws Exception
+     */
+    public static UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) throws Exception {
+        String saveUrl = AccountConfig.getUserSaveUrl();
+        if (!StringUtils.isEmpty(saveUrl)) {
+            ResponseWrap response = HttpUtil.doGet(saveUrl  + "/uuzcSpace" , new ModelMap("businessCode", businessCode));
+            if (!response.isSuccess())
+                throw new Exception(response.getContent());
+            else {
+                return JSONObject.parseObject(response.getContent(), UuzcUserSpaceDetail.class);
+            }
+        }
+        return null;
+    }
+
+	/**
+	 * 判断当前企业是否设置了hr
+	 * 
+	 * @param businessCode
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getHrAccount(String businessCode) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap response = HttpUtil.doGet(saveUrl  + "/hrcount" , new ModelMap("businessCode", businessCode));
+			if (!response.isSuccess())
+				throw new Exception(response.getContent());
+			else {
+				return response.getContent();
+			}
+		}
+		return null;
+	}
+
+    /**
+     * 获取当前企业的HR信息
+     *
+     * @param businessCode
+     * @return
+     * @throws Exception
+     */
+    public static User getHrInfo(String businessCode) throws Exception {
+        String saveUrl = AccountConfig.getUserSaveUrl();
+        if (!StringUtils.isEmpty(saveUrl)) {
+            ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrInfo" , new ModelMap("businessCode", businessCode));
+            if (!response.isSuccess())
+                throw new Exception(response.getContent());
+            else {
+                return JSONObject.parseObject(response.getContent(), User.class);
+            }
+        }
+        return null;
+    }
+
+	/**
+	 * 获取当前企业人员账号信息
+	 * 
+	 * @param businessCode
+	 * @return
+	 * @throws Exception
+	 */
+	public static List<User> getEmployees(String businessCode) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		saveUrl = saveUrl + "/employees";
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap response = HttpUtil.doPost(saveUrl, new ModelMap("businessCode", businessCode));
+			if (!response.isSuccess())
+				throw new Exception(response.getContent());
+			else {
+				return JSON.parseArray(response.getContent(), User.class);
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 保存用户密保问题
+	 * @param questions
+	 * @throws Exception
+	 */
+	public static void saveUserQuestions(List<UserQuestion> questions) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		saveUrl = saveUrl + "/save/question";
+		if (!StringUtils.isEmpty(saveUrl)) {
+			ResponseWrap res = HttpUtil.doPost(saveUrl, new ModelMap("question", questions));
+			if (!res.isSuccess()) {
+				throw new Exception(res.getContent());
+			}
+		}
+	}
+
+	/**
+	 * 保存用户密保问题
+	 * @param userQuestion
+	 * @throws Exception
+	 */
+	public static void saveUserQuestion(UserQuestion userQuestion) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		saveUrl = saveUrl + "/save/question";
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(userQuestion));
+			formData.put("_count", "one");
+			ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
+			if (!res.isSuccess()) {
+				throw new Exception(res.getContent());
+			}
+		}
+	}
+}

+ 94 - 0
account-common/src/main/java/com/uas/account/util/BeanUtil.java

@@ -0,0 +1,94 @@
+package com.uas.account.util;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
+
+public class BeanUtil extends BeanUtils {
+
+	/**
+	 * @param source
+	 * @param target
+	 * @param onlyNotNull
+	 *            只复制不为空的属性
+	 * @param ignoreProperties
+	 * @throws BeansException
+	 */
+	public static void copyProperties(Object source, Object target, boolean onlyNotNull, String... ignoreProperties) throws BeansException {
+		copyProperties(source, target, onlyNotNull, null, ignoreProperties);
+	}
+
+	/**
+	 * Copy the property values of the given source bean into the given target
+	 * bean.
+	 * <p>
+	 * Note: The source and target classes do not have to match or even be
+	 * derived from each other, as long as the properties match. Any bean
+	 * properties that the source bean exposes but the target bean does not will
+	 * silently be ignored.
+	 * 
+	 * @param source
+	 *            the source bean
+	 * @param target
+	 *            the target bean
+	 * @param editable
+	 *            the class (or interface) to restrict property setting to
+	 * @param ignoreProperties
+	 *            array of property names to ignore
+	 * @throws BeansException
+	 *             if the copying failed
+	 * @see BeanWrapper
+	 */
+	private static void copyProperties(Object source, Object target, boolean onlyNotNull, Class<?> editable, String... ignoreProperties)
+			throws BeansException {
+
+		Assert.notNull(source, "Source must not be null");
+		Assert.notNull(target, "Target must not be null");
+
+		Class<?> actualEditable = target.getClass();
+		if (editable != null) {
+			if (!editable.isInstance(target)) {
+				throw new IllegalArgumentException("Target class [" + target.getClass().getName() + "] not assignable to Editable class ["
+						+ editable.getName() + "]");
+			}
+			actualEditable = editable;
+		}
+		PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
+		List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null);
+
+		for (PropertyDescriptor targetPd : targetPds) {
+			Method writeMethod = targetPd.getWriteMethod();
+			if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
+				PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
+				if (sourcePd != null) {
+					Method readMethod = sourcePd.getReadMethod();
+					if (readMethod != null && ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], readMethod.getReturnType())) {
+						try {
+							if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
+								readMethod.setAccessible(true);
+							}
+							Object value = readMethod.invoke(source);
+							if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
+								writeMethod.setAccessible(true);
+							}
+							if ((onlyNotNull && null != value) || !onlyNotNull)
+								writeMethod.invoke(target, value);
+						} catch (Throwable ex) {
+							throw new FatalBeanException("Could not copy property '" + targetPd.getName() + "' from source to target", ex);
+						}
+					}
+				}
+			}
+		}
+	}
+
+}

+ 62 - 0
account-common/src/main/java/com/uas/account/util/FlexJsonUtil.java

@@ -0,0 +1,62 @@
+package com.uas.account.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import flexjson.JSONDeserializer;
+import flexjson.JSONSerializer;
+
+/**
+ * <h1>flexjson</h1><br>
+ * 1.序列化json字符串时较快,优于jackson<br>
+ * 2.但是数据量较大时,序列化有问题<br>
+ * 3.反序列化较慢
+ * 
+ * @author yingp
+ * 
+ */
+public class FlexJsonUtil {
+
+	public static <T> T fromJson(String json, Class<?> cls) {
+		return new JSONDeserializer<T>().use(null, cls).deserialize(json);
+	}
+
+	public static <K, V> Map<K, V> fromJson(String json) {
+		if (json != null) {
+			Map<K, V> map = new HashMap<K, V>();
+			return new JSONDeserializer<Map<K, V>>().use(null, map.getClass()).deserialize(json);
+		}
+		return null;
+	}
+
+	public String toJson() {
+		return new JSONSerializer().exclude("*.class").serialize(this);
+	}
+
+	public static String toJson(Object obj) {
+		if (obj == null)
+			return null;
+		return new JSONSerializer().exclude("*.class").serialize(obj);
+	}
+
+	public static String toJsonDeep(Object obj) {
+		if (obj == null)
+			return null;
+		return new JSONSerializer().exclude("*.class").deepSerialize(obj);
+	}
+
+	public static <T> String toJsonArray(Collection<?> collection) {
+		return new JSONSerializer().exclude("*.class").serialize(collection);
+	}
+
+	public static <T> String toJsonArrayDeep(Collection<?> collection) {
+		return new JSONSerializer().exclude("*.class").deepSerialize(collection);
+	}
+
+	public static <T> List<T> fromJsonArray(String json, Class<?> cls) {
+		return new JSONDeserializer<List<T>>().use(null, ArrayList.class).use("values", cls).deserialize(json);
+	}
+}

+ 122 - 0
account-common/src/main/java/com/uas/account/web/AccountConfigurer.java

@@ -0,0 +1,122 @@
+package com.uas.account.web;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import com.uas.account.AccountConfig;
+import com.uas.sso.web.SSOConfigurer;
+
+/**
+ * 账户中心配置
+ * 
+ * <pre>
+ * 包含sso配置和账户设置
+ * </pre>
+ * 
+ * @author yingp
+ *
+ */
+public class AccountConfigurer extends AccountConfig implements ApplicationContextAware {
+
+	/**
+	 * Parameter specifying the location of the account config file
+	 */
+	protected static final Logger logger = Logger.getLogger(SSOConfigurer.class.getName());
+	private static final String CONFIG_LOCATION_PARAM = "AccountConfigLocation";
+	private String configPath = "account.properties";
+	private ApplicationContext applicationContext;
+
+	public AccountConfigurer() {
+		/* 支持无参构造函数 */
+	}
+
+	public AccountConfigurer(String configPath) {
+		this.configPath = configPath;
+	}
+
+	/**
+	 * 
+	 * web.xml 启动监听, 初始化
+	 * 
+	 * @param servletContext
+	 * 
+	 */
+	public void init(ServletContext servletContext) {
+		setConfigPath(servletContext.getInitParameter(CONFIG_LOCATION_PARAM));
+		init();
+	}
+
+	/**
+	 * 
+	 * Spring bean 注入初始化
+	 * <p>
+	 * xml 配置方法:
+	 * 
+	 * <bean id="accountConfig" class="com.uas.sso.web.AccountConfigurer"
+	 * init-method="init"> <property name="configPath"
+	 * value="classpath:account.properties" /> </bean>
+	 * </p>
+	 * 
+	 */
+	public void init() {
+		Properties prop = null;
+
+		try {
+			File file = getApplicationContext().getResource(getConfigPath()).getFile();
+			prop = getInputStream(new FileInputStream(file));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		/**
+		 * 初始化
+		 */
+		if (prop != null) {
+			this.initProperties(prop);
+		} else {
+			logger.severe("Initializing is not available AccountConfigLocation on the classpath");
+		}
+	}
+
+	public void shutdown() {
+		logger.info("Uninstalling Account ");
+	}
+
+	private Properties getInputStream(InputStream in) {
+		Properties p = null;
+		try {
+			p = new Properties();
+			p.load(in);
+		} catch (Exception e) {
+			logger.severe(" account read config file error. \n" + e.toString());
+		}
+		return p;
+	}
+
+	public String getConfigPath() {
+		return configPath;
+	}
+
+	public void setConfigPath(String configPath) {
+		this.configPath = configPath;
+	}
+
+	@Override
+	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+		this.applicationContext = applicationContext;
+	}
+
+	public ApplicationContext getApplicationContext() {
+		return applicationContext;
+	}
+
+}

+ 32 - 0
account-common/src/test/java/com/uas/test/UserSpaceTest.java

@@ -0,0 +1,32 @@
+package com.uas.test;
+
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.support.Page;
+import com.uas.sso.common.util.HttpUtil;
+import com.uas.sso.common.util.HttpUtil.ResponseWrap;
+
+public class UserSpaceTest {
+
+	public static void main(String[] args) throws Exception {
+		String Url = "https://account.ubtob.com/api/partners";
+		if (!StringUtils.isEmpty(Url)) {
+			ResponseWrap res = HttpUtil.doGet(
+					Url,
+					new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", "优软").addAttribute("pageNumber", 1)
+							.addAttribute("pageSize", 50));
+			if (res.isSuccess()) {
+				Page<UserSpaceDetail> us = JSON.parseObject(res.getContent(), new TypeReference<Page<UserSpaceDetail>>() {
+				});
+				System.out.println("共找到:" + us.getTotalElements());
+				for (UserSpaceDetail u : us.getContent())
+					System.out.println(u.getName());
+			}
+		}
+	}
+
+}

+ 344 - 0
account-server/pom.xml

@@ -0,0 +1,344 @@
+<?xml version="1.0"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.uas.account</groupId>
+		<artifactId>account-parent</artifactId>
+		<version>0.0.1-SNAPSHOT</version>
+	</parent>
+	<artifactId>account-server</artifactId>
+	<packaging>war</packaging>
+	<name>account-server</name>
+	<url>http://maven.apache.org</url>
+	<dependencies>
+		<dependency>
+			<groupId>com.uas.account</groupId>
+			<artifactId>sso-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.uas.account</groupId>
+			<artifactId>account-common</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.shiro</groupId>
+			<artifactId>shiro-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-webmvc</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.mobile</groupId>
+			<artifactId>spring-mobile-device</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>jstl</groupId>
+			<artifactId>jstl</artifactId>
+		</dependency>
+		<!-- jdbc -->
+		<dependency>
+			<groupId>com.oracle</groupId>
+			<artifactId>ojdbc6</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jdbc</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-tx</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid</artifactId>
+		</dependency>
+		<!-- dubbo -->
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>dubbo</artifactId>
+			<exclusions>
+				<exclusion>
+					<groupId>javax.servlet</groupId>
+					<artifactId>javax.servlet-api</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>org.apache.httpcomponents</groupId>
+					<artifactId>httpcore</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.zookeeper</groupId>
+			<artifactId>zookeeper</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.github.sgroschupf</groupId>
+			<artifactId>zkclient</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.caucho</groupId>
+			<artifactId>hessian</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.uas.dfs</groupId>
+			<artifactId>dfs-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate-validator</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.data</groupId>
+			<artifactId>spring-data-redis</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.uas.message</groupId>
+			<artifactId>message-mail-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.uas.message</groupId>
+			<artifactId>message-sms-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.belerweb</groupId>
+			<artifactId>pinyin4j</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.google.zxing</groupId>
+			<artifactId>core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpmime</artifactId>
+			<version>4.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpcore</artifactId>
+			<version>4.4.5</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpclient</artifactId>
+			<version>4.4</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb.morphia</groupId>
+			<artifactId>morphia</artifactId>
+			<version>0.108</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+	<build>
+		<finalName>account</finalName>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.tomcat.maven</groupId>
+				<artifactId>tomcat7-maven-plugin</artifactId>
+				<version>2.2</version>
+				<configuration>
+					<port>8080</port>
+					<path>/</path>
+					<uriEncoding>utf-8</uriEncoding>
+				</configuration>
+			</plugin>
+			<!-- 在maven生命周期validate阶段生成timestamp -->
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>buildnumber-maven-plugin</artifactId>
+				<version>1.3</version>
+				<executions>
+					<execution>
+						<phase>validate</phase>
+						<goals>
+							<goal>create-timestamp</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<configuration>
+						<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
+						<items>
+							<item>timestamp</item>
+						</items>
+					</configuration>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.7</source>
+					<target>1.7</target>
+					<compilerArguments>
+						<verbose />
+						<bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>
+					</compilerArguments>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>com.samaxes.maven</groupId>
+				<artifactId>minify-maven-plugin</artifactId>
+				<version>1.7.4</version>
+				<!-- 静态文件压缩 -->
+				<executions>
+					<execution>
+						<id>default-minify</id>
+						<phase>prepare-package</phase>
+						<configuration>
+							<charset>UTF-8</charset>
+							<skipMerge>true</skipMerge>
+							<closureLanguage>ECMASCRIPT5</closureLanguage>
+							<closureAngularPass>true</closureAngularPass>
+							<nosuffix>true</nosuffix>
+							<webappTargetDir>${project.build.directory}/minify</webappTargetDir>
+							<cssSourceDir>assets</cssSourceDir>
+							<cssEngine>YUI</cssEngine>
+							<jsSourceDir>assets</jsSourceDir>
+							<jsEngine>CLOSURE</jsEngine>
+							<cssSourceIncludes>
+								<cssSourceInclude>css/**/*.css</cssSourceInclude>
+								<cssSourceInclude>data/**/*.json</cssSourceInclude>
+							</cssSourceIncludes>
+							<cssSourceExcludes>
+								<cssSourceExclude>css/**/*.min.css</cssSourceExclude>
+							</cssSourceExcludes>
+							<jsSourceIncludes>
+								<jsSourceInclude>js/**/*.js</jsSourceInclude>
+							</jsSourceIncludes>
+							<jsSourceExcludes>
+								<jsSourceExclude>js/**/*.min.js</jsSourceExclude>
+							</jsSourceExcludes>
+						</configuration>
+						<goals>
+							<goal>minify</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-resources-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>copy-resources</id>
+						<phase>prepare-package</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>${project.build.directory}/minify</outputDirectory>
+							<overwrite>false</overwrite>
+							<resources>
+								<resource>
+									<directory>${basedir}/src/main/webapp</directory>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>com.uas.plugins</groupId>
+				<artifactId>static-maven-plugin</artifactId>
+				<version>0.0.2-SNAPSHOT</version>
+				<!-- 静态资源分离 -->
+				<executions>
+					<execution>
+						<id>default-static</id>
+						<phase>prepare-package</phase>
+						<configuration>
+							<pathMatcher>static</pathMatcher>
+							<staticUrl>static</staticUrl>
+							<webappDir>${project.build.directory}/minify</webappDir>
+							<sourceDir>/</sourceDir>
+							<targetDir>${project.build.directory}/statics</targetDir>
+							<staticDir>/</staticDir>
+							<sourceIncludes>
+								<sourceInclude>assets/js/**/*.js</sourceInclude>
+								<sourceInclude>assets/data/**/*.json</sourceInclude>
+								<sourceInclude>WEB-INF/views/**/*.jsp</sourceInclude>
+							</sourceIncludes>
+							<!-- http://static.ubtob.com/css/index.css?_v=1450321871828 -->
+							<versionSuffix>
+								<suffix>?_v=${timestamp}</suffix>
+								<exclude>*/require.js,*.min.js,*.min.css</exclude>
+							</versionSuffix>
+						</configuration>
+						<goals>
+							<goal>static</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-war-plugin</artifactId>
+				<version>2.4</version>
+				<configuration>
+					<webResources>
+						<resource>
+							<directory>${project.build.directory}/statics</directory>
+						</resource>
+						<resource>
+							<directory>${project.build.directory}/minify</directory>
+						</resource>
+					</webResources>
+				</configuration>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.codehaus.mojo
+										</groupId>
+										<artifactId>
+											buildnumber-maven-plugin
+										</artifactId>
+										<versionRange>
+											[1.3,)
+										</versionRange>
+										<goals>
+											<goal>
+												create-timestamp
+											</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+</project>

+ 125 - 0
account-server/src/main/java/com/uas/account/controller/AppManagerController.java

@@ -0,0 +1,125 @@
+package com.uas.account.controller;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.uas.account.entity.App;
+import com.uas.account.service.AppService;
+import com.uas.account.web.BaseController;
+import com.uas.sso.common.encrypt.RSA;
+
+/**
+ * @author yingp
+ *
+ */
+@Controller
+public class AppManagerController extends BaseController {
+
+	@Autowired
+	private AppService appService;
+
+	/**
+	 * @return
+	 */
+	@RequestMapping(value = "/console/app", method = RequestMethod.GET)
+	public ModelAndView getPage(ModelMap model) {
+		return new ModelAndView("console/app", success(appService.findAllView()));
+	}
+
+	/**
+	 * 查找全部
+	 * 
+	 */
+	@RequestMapping(value = "/api/app/list", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findAll() {
+		return success(appService.findAllView());
+	}
+
+	/**
+	 * 查找全部可注册应用
+	 * 
+	 */
+	@RequestMapping(value = "/api/app/public", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findAllPublic() {
+		return success(appService.findAllPublicUseView());
+	}
+
+	/**
+	 * 查找
+	 * 
+	 * @param uid
+	 */
+	@RequestMapping(value = "/api/app/{uid}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findOne(@PathVariable("uid") String uid) {
+		return success(appService.findOne(uid));
+	}
+
+	/**
+	 * 更新
+	 * 
+	 * @param app
+	 */
+	@RequestMapping(value = "/api/app", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap save(App app) {
+		appService.save(app);
+		return success();
+	}
+
+	/**
+	 * 删除
+	 * 
+	 * @param uid
+	 */
+	@RequestMapping(value = "/api/app/{uid}", method = RequestMethod.DELETE)
+	@ResponseBody
+	public ModelMap delete(@PathVariable("uid") String uid) {
+		appService.delete(uid);
+		return success();
+	}
+
+	private static final String sessionPrivateKey = "privateKey";
+
+	/**
+	 * 获取密钥对
+	 * 
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "/api/secret/generate", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap generateKey() throws Exception {
+		Map<String, Object> keyMap = RSA.genKeyPair();
+		// 私钥走下载通道
+		request.getSession().setAttribute(sessionPrivateKey, RSA.getPrivateKey(keyMap));
+		return success(RSA.getPublicKey(keyMap));
+	}
+
+	/**
+	 * 下载私钥
+	 * 
+	 * @throws Exception
+	 */
+	@RequestMapping("/api/secret/private")
+	public ResponseEntity<byte[]> downloadKey() throws Exception {
+		Object privateKey = request.getSession().getAttribute(sessionPrivateKey);
+		if (privateKey != null) {
+			return outputStream("privateKey.txt", privateKey.toString().getBytes());
+		} else {
+			printJson(error("未找到密钥,请重新生成"));
+			return null;
+		}
+	}
+
+}

+ 119 - 0
account-server/src/main/java/com/uas/account/controller/AssetManagerController.java

@@ -0,0 +1,119 @@
+package com.uas.account.controller;
+
+import java.io.IOException;
+
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+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.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.Asset;
+import com.uas.account.service.AppService;
+import com.uas.account.service.AssetService;
+import com.uas.account.web.BaseController;
+import com.uas.dfs.service.FileClient;
+
+/**
+ * 资源
+ * 
+ * @author yingp
+ *
+ */
+@Controller
+public class AssetManagerController extends BaseController {
+
+	@Autowired
+	private AssetService assetService;
+	@Autowired
+	private AppService appService;
+	@Autowired
+	private FileClient fileClient;
+
+	/**
+	 * page
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/console/asset", method = RequestMethod.GET)
+	public ModelAndView getPage(ModelMap model) {
+		// 列出全部app以供筛选
+		return new ModelAndView("console/asset", success(appService.findAllView()));
+	}
+
+	/**
+	 * 资源新增、修改
+	 * 
+	 * @param asset
+	 * @return
+	 */
+	@RequestMapping(value = "/api/asset", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap save(Asset asset) {
+		if (asset.getAppId() == null)
+			return error("参数错误");
+		return success(assetService.save(asset));
+	}
+
+	/**
+	 * 资源查找
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/api/asset/{id}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findOne(@PathVariable("id") Long id) {
+		return success(assetService.findOne(id));
+	}
+
+	/**
+	 * 资源删除
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/api/asset/{id}", method = RequestMethod.DELETE)
+	@ResponseBody
+	public ModelMap delete(@PathVariable("id") Long id) {
+		Asset asset = assetService.findOne(id);
+		if (asset != null)
+			assetService.delete(asset);
+		return success();
+	}
+
+	/**
+	 * 按应用查找资源
+	 * 
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(value = "/api/asset/list", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<Asset> findAll(String appId, int pageNumber, int pageSize) {
+		return assetService.findAll(appId, pageNumber, pageSize);
+	}
+
+	/**
+	 * 资源背景图保存
+	 * 
+	 * @return
+	 * @throws IOException
+	 * @throws FileUploadException
+	 */
+	@RequestMapping(value = "/api/util/upload", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap uploadImage(@RequestBody MultipartFile file) throws IOException {
+		String url = fileClient.uploadImage(file.getBytes(), file.getSize(), FilenameUtils.getExtension(file.getOriginalFilename()), null);
+		return success(url);
+	}
+
+}

+ 12 - 0
account-server/src/main/java/com/uas/account/controller/ChangeAdminDetailController.java

@@ -0,0 +1,12 @@
+package com.uas.account.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import com.uas.account.web.BaseController;
+
+@Controller
+@RequestMapping("api/changeAdmin")
+public class ChangeAdminDetailController extends BaseController {
+
+}

+ 186 - 0
account-server/src/main/java/com/uas/account/controller/GetAllPartnersInfoController.java

@@ -0,0 +1,186 @@
+package com.uas.account.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.account.core.Page;
+import com.uas.account.entity.InvitationRecord;
+import com.uas.account.entity.PartnershipRecord;
+import com.uas.account.entity.RequsetStatus;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.service.PartnershipService;
+import com.uas.account.service.UserSpaceService;
+
+/**
+ * 为平台和ERP用户提供公共接口查询当前企业的合作伙伴
+ * 
+ * @author hejq
+ * @time 创建时间:2017年1月17日
+ */
+@Controller
+@RequestMapping(value = "/api/partners")
+public class GetAllPartnersInfoController {
+
+	@Autowired
+	private PartnershipService partnershipService;
+
+	@Autowired
+	private UserSpaceService userSpaceService;
+
+	/**
+	 * 查询发出的申请
+	 * 
+	 * @param businessCode
+	 * @param statusCode
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getAllRequest")
+	@ResponseBody
+	public Page<PartnershipRecord> getAllRequest(String businessCode, Integer statusCode, String keyword,
+			int pageNumber, int pageSize) {
+		return partnershipService.findBySpaceUidAndStatusCode(businessCode, statusCode, keyword, pageNumber, pageSize);
+	}
+
+	/**
+	 * 过滤掉已存在UU,查询发出的申请(UAS接口)
+	 *
+	 * @param businessCode
+	 * @param statusCode
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getAllRequestFilterByPartnerUUs")
+	@ResponseBody
+	public Page<PartnershipRecord> getAllRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, int pageNumber, int pageSize, String partnerUUs) {
+		List<Long> UUs = JSON.parseArray(partnerUUs, Long.class);
+		if (!CollectionUtils.isEmpty(UUs)) { // 存在需要过滤的UU时
+			return partnershipService.findBySpaceUidAndStatusCodeFilterByPartnerUUs(businessCode, statusCode, keyword, UUs, pageNumber, pageSize);
+		}
+		return partnershipService.findBySpaceUidAndStatusCode(businessCode, statusCode, keyword, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查询所有企业列表
+	 */
+	@RequestMapping(params = "_operate=getUserSpaces")
+	@ResponseBody
+	public Page<UserSpaceDetail> getUserSpaces(String keyword, int pageNumber, int pageSize) {
+		return userSpaceService.findByKeyword(keyword, pageNumber, pageSize);
+	}
+
+	/**
+	 * 从各应用新增一条合作关系
+	 * 
+	 * @param record
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=addPartner", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap addPartner(PartnershipRecord record) {
+		return partnershipService.addPartner(record);
+	}
+
+	/**
+	 * b2b因为单据产生新增一条合作关系
+	 *
+	 * @param record
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=synchronizePartner", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap synchronizePartner(PartnershipRecord record) {
+		return partnershipService.synchronizePartner(record);
+	}
+
+	/**
+	 * 拒绝申请
+	 * 
+	 * @param id
+	 * @param reason
+	 * @param vendUserTel
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=rejectRequest")
+	@ResponseBody
+	public ModelMap rejectRequest(Long id, String reason, String vendUserTel, String appId) {
+		return partnershipService.rejectRequest(id, reason, vendUserTel, appId);
+	}
+
+	/**
+	 * 通过申请
+	 * 
+	 * @param id
+	 * @param vendUserTel
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=acceptRequest")
+	@ResponseBody
+	public ModelMap acceptRequest(Long id, String vendUserTel, String appId) {
+		return partnershipService.acceptRequest(id, vendUserTel, appId);
+	}
+
+	/**
+	 * 通过营业执照号获取申请状态
+	 * 
+	 * @param custUid
+	 * @param vendUid
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getRequestStatus")
+	@ResponseBody
+	public RequsetStatus getRequestStatus(String custUid, String vendUid) {
+		return partnershipService.getRequestByCustUidAndVendUid(custUid, vendUid);
+	}
+
+	/**
+	 * 通过id查询企业信息(方便平台搜索调用)
+	 * 
+	 * @param ids
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=findAll")
+	@ResponseBody
+	public List<UserSpaceDetail> findAll(String ids) {
+		return userSpaceService.findAll(ids);
+	}
+
+	/**
+	 * 获取收到的待处理的请求的数量
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getRequestTodo")
+	@ResponseBody
+	public ModelMap getRequestTodo(String businessCode) {
+		return partnershipService.getRequestTodo(businessCode);
+	}
+	
+	/**
+	 * 邀请合作伙伴记录
+	 * 
+	 * @param formStore
+	 */
+	@RequestMapping(params = "_operate=invitation", method = RequestMethod.POST)
+	@ResponseBody
+	public void invite(String jsonStr) {
+		InvitationRecord record = JSONObject.parseObject(jsonStr, InvitationRecord.class);
+		partnershipService.invite(record);
+	}
+}

+ 254 - 0
account-server/src/main/java/com/uas/account/controller/PartnershipController.java

@@ -0,0 +1,254 @@
+package com.uas.account.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.PartnershipRecord;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.service.PartnershipService;
+import com.uas.account.service.UserSpaceService;
+import com.uas.account.support.SystemSession;
+import com.uas.account.web.BaseController;
+
+/**
+ * 合作关系操作记录的controller
+ * 
+ * @author hejq
+ * @time 创建时间:2017年1月11日
+ */
+@Controller
+@RequestMapping("/partnership")
+public class PartnershipController extends BaseController {
+
+	@Autowired
+	private PartnershipService partnershipService;
+	@Autowired
+	private UserSpaceService userSpaceService;
+
+	/**
+	 * 发送企业请求
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest")
+	@ResponseBody
+	public ModelMap SendRequest(Long id) {
+		partnershipService.sendRequestById(id);
+		return success();
+	}
+
+	/**
+	 * 查找发出的请求,待审批
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/list", params = "status=UNAUDIT", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllSendUNAUDIT(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		return partnershipService.findAllSendUnAudit(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查找发出的请求,已通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/list", params = "status=ENABLED", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllSendEnabled(String name, String businessCode, String custUserName,
+			int pageNumber,
+			int pageSize) {
+		return partnershipService.findAllSendEnable(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查找发出的请求,未通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/list", params = "status=UNAPPLY", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllSendUNAPPLY(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		return partnershipService.findAllSendUnApply(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 通过id查找发出请求的详情
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/detail/id/{id}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findSendDetailById(@PathVariable Long id) {
+		return success(partnershipService.findSendRequestById(id));
+	}
+
+	/**
+	 * 查找收到的请求,待审批
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/list", params = "status=UNAUDIT", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllReceivedUNAUDIT(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		return partnershipService.findAllReceivedUnAudit(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查找收到的请求,已通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/list", params = "status=ENABLED", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllReceivedEnabled(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		return partnershipService.findAllReceivedEnable(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查找收到的请求,未通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/list", params = "status=UNAPPLY", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<PartnershipRecord> findAllReceivedUNAPPLY(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		return partnershipService.findAllReceivedUnApply(name, businessCode, custUserName, pageNumber, pageSize);
+	}
+
+	/**
+	 * 通过id查找收到请求的详情
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/detail/id/{id}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findReceivedDetailById(@PathVariable Long id) {
+		return success(partnershipService.findReceivedRequestById(id));
+	}
+
+	/**
+	 * 审核通过
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/audit", params = "enable=1")
+	@ResponseBody
+	public ModelMap enableDetail(Long id) {
+		partnershipService.enable(id);
+		return success();
+	}
+
+	/**
+	 * 审批未通过
+	 * 
+	 * @param reason
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/audit", params = "enable=0")
+	@ResponseBody
+	public ModelMap disableDetail(String reason, Long id) {
+		partnershipService.disable(id, reason);
+		return success();
+	}
+	
+	/**
+	 * 再次申请
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/resend")
+	@ResponseBody
+	public ModelMap resendRequest(Long id) {
+		partnershipService.resendRequestById(id);
+		return success();
+	}
+
+	/**
+	 * 发出的请求统计
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/sendRequest/count", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap sendRequestCount() {
+		return success(partnershipService.getsendRequestCount());
+	}
+
+	/**
+	 * 收到的请求统计
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/receivedRequest/count", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap receivedRequestCount() {
+		return success(partnershipService.getreceivedRequestCount());
+	}
+
+	/**
+	 * 查询当前登录人信息
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/getCurrentUserInfo", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getCurrentUserInfo() {
+		User user = SystemSession.getUser();
+		ModelMap map = new ModelMap();
+		if (user == null) {
+			return error("暂未检测到当前用户信息,请通过商务平台或ERP系统进行登录");
+		} else {
+			List<UserSpace> space = userSpaceService.findByUID(user.getSpaceUID());
+			map.put("username", user.getName());
+			map.put("enName", space.get(0).getName());
+			map.put("enBusCode", space.get(0).getUid());
+		}
+
+		return success(map);
+	}
+}

+ 74 - 0
account-server/src/main/java/com/uas/account/controller/SettingController.java

@@ -0,0 +1,74 @@
+package com.uas.account.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.uas.account.entity.Setting;
+import com.uas.account.service.SettingService;
+import com.uas.account.web.BaseController;
+
+@Controller
+public class SettingController extends BaseController {
+
+	@Autowired
+	private SettingService settingService;
+
+	/**
+	 * @return
+	 */
+	@RequestMapping(value = "/console/setting", method = RequestMethod.GET)
+	public ModelAndView getPage(ModelMap model) {
+		return new ModelAndView("console/setting", success(settingService.findAll()));
+	}
+
+	/**
+	 * 查找全部
+	 * 
+	 */
+	@RequestMapping(value = "/api/setting/list", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findAll() {
+		return success(settingService.findAll());
+	}
+
+	/**
+	 * 查找
+	 * 
+	 * @param key
+	 */
+	@RequestMapping(value = "/api/setting", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findOne(String key) {
+		return success(settingService.findOne(key));
+	}
+
+	/**
+	 * 更新
+	 * 
+	 * @param app
+	 */
+	@RequestMapping(value = "/api/setting", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap save(Setting setting) {
+		settingService.save(setting);
+		return success();
+	}
+
+	/**
+	 * 删除
+	 * 
+	 * @param uid
+	 */
+	@RequestMapping(value = "/api/setting", method = RequestMethod.DELETE)
+	@ResponseBody
+	public ModelMap delete(String key) {
+		settingService.delete(key);
+		return success();
+	}
+
+}

+ 50 - 0
account-server/src/main/java/com/uas/account/controller/SynchrodataToOldPlatController.java

@@ -0,0 +1,50 @@
+package com.uas.account.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.uas.account.service.SynchrodataToOldPlatService;
+
+/**
+ * 同步企业人员信息到旧平台
+ * 
+ * @author hejq
+ * @time 创建时间:2017年4月13日
+ */
+@RequestMapping("/synchrodataToOldPlat")
+@Controller
+public class SynchrodataToOldPlatController {
+
+	@Autowired
+	private SynchrodataToOldPlatService synchrodataToOldPlatService;
+
+	/**
+	 * 同步数据和人员信息到旧平台
+	 * 
+	 * @param userId
+	 * @param enId
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.POST)
+	@ResponseBody
+	private ModelMap synchrodataToOldPlat(Long id) {
+		return synchrodataToOldPlatService.synchrodataToOldPlat(id);
+	}
+	
+	/**
+	 * 查询当前用户在当前企业的旧平台的密码信息
+	 * 
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+	@ResponseBody
+	private ModelMap findUserPasswordInOldPlat(Long id) {
+		return synchrodataToOldPlatService.findUserPasswordInOldPlat(id);
+	}
+
+}

+ 1109 - 0
account-server/src/main/java/com/uas/account/controller/UserManagerController.java

@@ -0,0 +1,1109 @@
+package com.uas.account.controller;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.org.apache.xml.internal.security.utils.Constants;
+import com.sun.tools.javac.code.Attribute;
+import com.uas.account.entity.*;
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+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.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.account.AccountConfig;
+import com.uas.account.core.Const;
+import com.uas.account.core.Page;
+import com.uas.account.core.util.StringUtil;
+import com.uas.account.exception.AccountException;
+import com.uas.account.exception.VisibleError;
+import com.uas.account.service.AppService;
+import com.uas.account.service.SettingService;
+import com.uas.account.service.SysDataToMallService;
+import com.uas.account.service.TokenService;
+import com.uas.account.service.UserQuestionService;
+import com.uas.account.service.UserService;
+import com.uas.account.service.UserSpaceService;
+import com.uas.account.support.SystemSession;
+import com.uas.account.web.BaseController;
+import com.uas.message.mail.service.MailService;
+import com.uas.message.sms.service.SmsService;
+import com.uas.sso.SSOHelper;
+import com.uas.sso.SSOToken;
+import com.uas.sso.common.encrypt.MD5;
+
+@Controller
+@RequestMapping("/api/user")
+public class UserManagerController extends BaseController {
+
+	@Autowired
+	private UserService userService;
+	@Autowired
+	private AppService appService;
+	@Autowired
+	private UserSpaceService userSpaceService;
+	@Autowired
+	private TokenService tokenService;
+	@Autowired
+	private MailService mailService;
+	@Autowired
+	private SmsService smsService;
+	@Autowired
+	private SettingService settingService;
+	@Autowired
+	private SysDataToMallService sysService;
+	@Autowired
+	private UserQuestionService userQuestionService;
+
+	private static final String UTF_8 = "UTF-8";
+
+	private static final String ERROR = "error";
+
+	/**
+	 * 按应用和所属企业查找用户
+	 *
+	 * @param appId
+	 * @param spaceId
+	 * @return
+	 */
+	@RequestMapping(value = "/list", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<User> findAll(String appId, String spaceId, int pageNumber, int pageSize) {
+		return userService.findAll(appId, spaceId, pageNumber, pageSize);
+	}
+
+	/**
+	 * 用户开通应用统计
+	 *
+	 * @return
+	 */
+	@RequestMapping(value = "/count", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap count() {
+		return success(userService.getUserAppCount());
+	}
+
+	/**
+	 * 查找用户详细信息
+	 *
+	 * @param mobile
+	 * @param email
+	 * @return
+	 */
+	@RequestMapping(value = "/detail", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findDetail(String mobile, String email) {
+		if (!StringUtils.isEmpty(mobile)) {
+			return success(userService.findOne(mobile));
+		}
+		List<UserDetail> details = userService.findByEmail(email);
+		return success(CollectionUtils.isEmpty(details) ? null : details.get(0));
+	}
+
+	/**
+	 * 查找用户详细信息
+	 *
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserDetail> findAllEnabledDetail(String name, String mobile, int pageNumber, int pageSize) {
+		return userService.findAllDetail(name, mobile, pageNumber, pageSize);
+	}
+
+	/**
+	 * 查找用户
+	 *
+	 * @param user
+	 * @return
+	 */
+	@RequestMapping(value = "/info", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findOne(User user) {
+		return success(userService.findOne(user.getAppId(), user.getSpaceUID(), user.getUid()));
+	}
+
+	/**
+	 * 查找用户所使用的全部应用和所属企业信息
+	 *
+	 * @param detail
+	 * @return
+	 */
+	@RequestMapping(value = "/all", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findUsers(UserDetail detail) {
+		if (!StringUtils.isEmpty(detail.getMobile()))
+			return success(userService.findViewByUID(detail.getMobile()));
+		else if (!StringUtils.isEmpty(detail.getEmail())) {
+			return success(userService.findViewBySecondUID(detail.getEmail()));
+		}
+		return error("个人信息不完善");
+	}
+
+	/**
+	 * 查找用户的所有帐号信息(ac$users)
+	 *
+	 * @param uid
+	 * @return
+	 */
+	@RequestMapping(value = "/userInfo", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findUserInfo(String uid) {
+		if (!StringUtils.isEmpty(uid)) {
+			return success(userService.findUserAppByUID(uid));
+		}
+		return error("个人信息不完善");
+	}
+
+	/**
+	 * 开通应用
+	 *
+	 * @return
+	 */
+	@RequestMapping("/applyApp")
+	@ResponseBody
+	public ModelMap applyApp(User user) {
+		userService.applyApp(user);
+		return success();
+	}
+
+	/**
+	 * 用户信息新增、修改
+	 *
+	 * @param user
+	 * @param userDetail
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap apiSave(User user, UserDetail userDetail) {
+		if (user == null || user.getAppId() == null)
+			throw new AccountException("参数错误");
+		return success(userService.save(user, userDetail));
+	}
+
+	/**
+	 * 控制台帮助用户重置密码
+	 *
+	 * @return
+	 */
+	@RequestMapping("resetPwd")
+	@ResponseBody
+	public ModelMap consoleResetPassword(User user) {
+		if (user == null || user.getPassword() == null) {
+			return error("参数错误");
+		}
+		user.setAppId(AccountConfig.ACCOUNT_CENTER);
+		userService.syncUserPassword(user, user.getPassword());
+		sysService.changepwd(user, user.getPassword());
+		return success();
+	}
+
+	/**
+	 * 用户绑定信息查询
+	 *
+	 * @param user
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap apiGet(User user) {
+		if (user == null)
+			throw new AccountException("参数错误");
+		return success(userService.findOne(user));
+	}
+
+	/**
+	 * 用户全部绑定信息查询
+	 *
+	 * @param user
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=all", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap apiGetAll(User user) {
+		if (user == null)
+			throw new AccountException("参数错误");
+		if (!StringUtils.isEmpty(user.getUid()))
+			return success(userService.findByUID(user.getUid()));
+		else if (!StringUtils.isEmpty(user.getSecondUID()))
+			return success(userService.findBySecondUID(user.getSecondUID()));
+		return error("未找到用户");
+	}
+
+	/**
+	 * 解除用户与企业绑定关系
+	 *
+	 * @param user
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=unbind", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap apiUnbind(User user) {
+		if (user == null || user.getAppId() == null)
+			throw new AccountException("参数错误");
+		userService.delete(user);
+		return success();
+	}
+
+	/**
+	 * 接口调用验证密码登录
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=check")
+	@ResponseBody
+	public ModelMap apiLogin(User user) {
+		if (null == user || null == user.getAppId() || null == user.getPassword()) {
+			return error("参数错误");
+		}
+		User oldOne = userService.findOne(user);
+		App app = appService.findOne(user.getAppId());
+		if (app != null) {
+			app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+		}
+		if (null != oldOne.getId()) {
+			// 允许应用在调用该接口前,已经将用户输入的明文加密为密文
+			String encryPwd = user.getPassword().length() >= 32 ? user.getPassword() : userService.getEncryPassword(app.getEncryFormat(),
+					user.getPassword(), user.getSalt());
+			if (encryPwd.equals(oldOne.getPassword())) {
+				return success();
+			}
+			return error("密码错误");
+		}
+		return error("未找到用户");
+	}
+
+	/**
+	 * 接口调用验证密码登录
+	 *
+	 * <pre>
+	 * 这个比较特殊,指定应用可能密码为空,需要借用其他应用的密码来校验
+	 * </pre>
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=fuzzyCheck")
+	@ResponseBody
+	public ModelMap apiFuzzyLogin(User user) {
+		if (null == user || null == user.getPassword()) {
+			return error("参数错误");
+		}
+		if (!StringUtils.isEmpty(user.getUid())) {
+			List<User> users = userService.findByUID(user.getUid());
+			if (users != null && users.size() == 0) {
+				return error("未找到用户");
+			}
+			for (User one : users) {
+				App app = appService.findOne(one.getAppId());
+				if (app != null) {
+					app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+				}
+				if (null != one.getId()) {
+					// 允许应用在调用该接口前,已经将用户输入的明文加密为密文
+					String encryPwd = user.getPassword().length() >= 32 ? user.getPassword() : userService.getEncryPassword(
+							app.getEncryFormat(), user.getPassword(), one.getSalt());
+					if (encryPwd.equals(one.getPassword())) {
+						if (!StringUtils.isEmpty(user.getAppId()) && !one.getAppId().equals(user.getAppId())) {
+							// 通过其他应用校验通过的,修改当前应用下绑定的密码
+							App userApp = appService.findOne(user.getAppId());
+							userService.changePassword(userApp, user, user.getPassword());
+						}
+						return success();
+					}
+				}
+			}
+			return error("密码错误");
+		}
+		return error("请填写手机号");
+	}
+
+	/**
+	 * 验证密码,返回绑定身份信息的token
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getToken")
+	@ResponseBody
+	public ModelMap apiGetToken(User user) {
+		ModelMap map = apiLogin(user);
+		if (isSuccess(map)) {
+			Token token = new Token(user);
+			tokenService.save(token);
+			return success(token.getId());
+		}
+		return map;
+	}
+
+	/**
+	 * 验证密码,返回绑定身份信息的token
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getAccessToken")
+	@ResponseBody
+	public ModelMap apiGetAccessToken(User user, Integer expires_in) {
+		ModelMap map = apiLogin(user);
+		if (isSuccess(map)) {
+			Token token = new Token(user, expires_in);
+			tokenService.save(token);
+			return success(token.getId());
+		}
+		return map;
+	}
+
+	/**
+	 * 验证token,返回其他身份信息
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=checkToken")
+	@ResponseBody
+	public ModelMap apiCheckAccessToken(String token, String appId) {
+		Token tk = tokenService.findOne(token);
+		if (null != tk) {
+			try {
+				User user = JSON.parseObject(JSON.toJSONString(tk.getBind()), User.class);
+				User currUser = null;
+				App app = appService.findOne(null == appId ? user.getAppId() : appId);
+				if (app != null) {
+					app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+				}
+
+				if (null != user.getSpaceUID()) {
+					UserSpace space = userSpaceService.findOne(app.getUid(), user.getSpaceUID());
+					if (null != space) {
+						currUser = userService.findOneView(app.getUid(), space.getId(), user.getUid());
+					}
+				}
+
+				if (null == currUser) {
+					currUser = new UserView();
+					currUser.setAppId(app.getUid());
+					currUser.setSecondUID(user.getSecondUID());
+					currUser.setSpaceUID(user.getSpaceUID());
+					currUser.setUid(user.getUid());
+					currUser = userService.findOne(currUser);
+				}
+
+				if (null != currUser.getId()) {
+					return success(currUser);
+				}
+				return error("未找到用户");
+			} finally {
+				tokenService.delete(token);
+			}
+		}
+		return error("验证信息已过期");
+	}
+
+	/**
+	 * ERP到账户中心的验证
+	 *
+	 * @param appId
+	 * @param access_token
+	 * @param redirect_page
+	 * @return
+	 */
+	@RequestMapping("/webpage")
+	public ModelAndView redirectPage(String appId, String access_token, String redirect_page) {
+		ModelMap data = apiCheckAccessToken(access_token, appId);
+		if (isSuccess(data)) {
+			User user = (User) getContent(data);
+			if (user != null) {
+				SystemSession.setUser(user);
+			}
+			SSOToken st = new SSOToken(request, user.getUid());
+			st.setData(JSON.toJSONString(user));
+			SSOHelper.setSSOCookie(request, response, st, true);
+			return new ModelAndView("redirect:/" + redirect_page);
+		} else {
+			return new ModelAndView("common/error", data);
+		}
+	}
+
+	/**
+	 * 接口调用修改密码
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=modify")
+	@ResponseBody
+	public ModelMap apiChangePassword(User user, String newPassword) {
+		if (null == user || null == user.getAppId() || null == user.getPassword() || null == newPassword) {
+			return error("参数错误");
+		}
+
+		User oldOne = userService.findOne(user);
+		App app = appService.findOne(user.getAppId());
+		if (app != null) {
+			app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+		}
+		if (null != oldOne.getId()) {
+			String encryPwd = user.getPassword().length() >= 32 ? user.getPassword() : userService.getEncryPassword(app.getEncryFormat(),
+					user.getPassword(), user.getSalt());
+			if (encryPwd.equals(oldOne.getPassword())) {
+				userService.changePassword(app, oldOne, newPassword);
+				sysService.changepwd(user, newPassword);
+				return success();
+			}
+			return error("密码错误");
+		}
+		return error("未找到用户");
+	}
+
+	/**
+	 * 接口调用重置密码
+	 *
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=reset")
+	@ResponseBody
+	public ModelMap apiResetPassword(User user) {
+		if (user == null || user.getAppId() == null || user.getPassword() == null) {
+			return error("参数错误");
+		}
+		App app = appService.findOne(user.getAppId());
+		if (app != null) {
+			app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+		}
+		user.setAppId(app.getUid());
+		User oldOne = userService.findOne(user);
+		if (oldOne.getId() != null) {
+			userService.changePassword(app, oldOne, user.getPassword());
+			sysService.changepwd(user, user.getPassword());
+		} else if (!StringUtils.isEmpty(user.getUid())) {
+			UserDetail userDetail = new UserDetail();
+			userDetail.setMobile(user.getUid());
+			userDetail.setEmail(user.getSecondUID());
+			userDetail.setName(user.getName());
+			userService.save(user, userDetail);
+			sysService.changepwd(user, user.getPassword());
+		}
+		return success();
+	}
+
+	/**
+	 * 接口调用获取验证码
+	 *
+	 * @param username
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=getVcode")
+	@ResponseBody
+	public ModelMap apiGetValidCode(@RequestParam(required = true) String username) {
+		return getValidCode(username);
+	}
+
+	/**
+	 * 接口调用校验验证码
+	 *
+	 * @param username
+	 * @param validCode
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=checkVcode")
+	@ResponseBody
+	public ModelMap apiCheckValidCode(@RequestParam(required = true) String username, @RequestParam(required = true) String validCode) {
+		String tokenId = "resetPwd:" + username;
+		Token token = tokenService.findOne(tokenId);
+		if (null == token) {
+			return error("验证码已过期,请重新获取");
+		}
+		if (!token.getBind().equals(MD5.toMD5(validCode))) {
+			return error("验证码错误");
+		}
+		tokenService.delete(tokenId);
+		return success();
+	}
+
+	/**
+	 * 用户操作获取验证码
+	 * 
+	 * @param username
+	 * @return
+	 */
+	@RequestMapping(value = "/vcode", params = "source=resetPwd", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getValidCode(@RequestParam String username) {
+		// 用户修改密码检测是否完成第一步
+		request.getSession().setAttribute("firstStep", false);
+
+		username = StringUtils.trimAllWhitespace(username);
+		String tokenId = "resetPwd:" + username;
+		Token oldOne = tokenService.findOne(tokenId);
+		if (null != oldOne) {
+			if (System.currentTimeMillis() - oldOne.getTime().getTime() < 60000) {
+				return error("403", "请不要频繁获取验证码");
+			} else {
+				// 这种情况可能短信发送后没及时收到
+				tokenService.delete(tokenId);
+			}
+		}
+		final String validCode = StringUtil.getRandomNumber(6);
+		Token token = new Token(tokenId, MD5.toMD5(validCode), 600);
+		tokenService.save(token);
+		UserDetail detail = null;
+		boolean isMobile = true;
+		if (username.matches(Const.REGEXP_EMAIL)) {
+			List<UserDetail> details = userService.findByEmail(username);
+			if (CollectionUtils.isEmpty(details)) {
+				return error("邮箱未注册");
+			}
+			if (details.size() > 1) {
+				// 一个邮箱绑定了多次的账号信息
+				return error("您的邮箱未激活,请使用手机号认证");
+			}
+			detail = details.get(0);
+			request.getSession().setAttribute("detail", detail);
+			isMobile = false;
+		} else if (username.matches(Const.REGEXP_MOBILE)) {
+			detail = userService.findOne(username);
+			if (null == detail) {
+				return error("手机号未注册");
+			}
+			request.getSession().setAttribute("detail", detail);
+		} else {
+			return error("手机号或邮箱地址不正确");
+		}
+		request.getSession().setAttribute("firstStep", true);
+
+		// 发送验证码
+		if (isMobile) {
+			// 短信
+			Setting smsTpl = settingService.findOne("templateForSendSmsAboutValidCode");
+			if (smsTpl != null) {
+				smsService.send(smsTpl.getValue(), username, new Object[] { validCode });
+			} else {
+				return error("系统错误");
+			}
+		} else {
+			// 邮件
+			Setting mailTpl = settingService.findOne("templateForSendMailAboutValidCode");
+			if (mailTpl != null) {
+				mailService.send(mailTpl.getValue(), username, new ModelMap("validCode", validCode).addAttribute("name", detail.getName()));
+			} else {
+				return error("系统错误");
+			}
+		}
+		return success();
+	}
+
+	/**
+	 * 用户操作校验验证码
+	 *
+	 * @param username
+	 * @param validCode
+	 * @return
+	 */
+	@RequestMapping(value = "/vcode", params = "source=resetPwd", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap checkValidCode(@RequestParam(required = true) String username, @RequestParam(required = true) String validCode) {
+		String tokenId = "resetPwd:" + username;
+		Token token = tokenService.findOne(tokenId);
+		if (null == token) {
+			return error("验证码已过期,请重新获取");
+		}
+		if (!token.getBind().equals(MD5.toMD5(validCode))) {
+			return error("验证码错误");
+		}
+		return success();
+	}
+
+	/**
+	 * 用户操作校验验证码
+	 *
+	 * @param username
+	 * @param validCode
+	 * @return
+	 */
+	@RequestMapping(value = "/vcode", params = "source=submitValidCheck", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap toAssistCheck(@RequestParam(required = true) String username, @RequestParam(required = true) String validCode) {
+		String tokenId = "resetPwd:" + username;
+		Token token = tokenService.findOne(tokenId);
+		if (null == token) {
+			return error("验证码已过期,请重新获取");
+		}
+		if (!token.getBind().equals(MD5.toMD5(validCode))) {
+			return error("验证码错误");
+		}
+		tokenService.delete(tokenId);
+		Token pageToken = new Token(username, 86400);
+		tokenService.save(pageToken);
+		return success(pageToken.getId());
+	}
+
+	/**
+	 * 用户操作重置密码
+	 *
+	 * @param pageToken
+	 * @param password
+	 * @return
+	 */
+	@RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap userResetPwd(@RequestParam(required = true) String pageToken, @RequestParam(required = true) String password) {
+		Token token = tokenService.findOne(pageToken);
+		if (null == token) {
+			return error("请刷新后重试");
+		}
+		String username = StringUtils.trimAllWhitespace(token.getBind().toString());
+		User user = null;
+		try {
+			Short level = checkPasswordLevel(password);
+			if (level == 1) {
+				return error("密码强度过低,请重新设置密码");
+			}
+		} catch (Exception e) {
+			return error(e.getMessage());
+		}
+		if (username.matches(Const.REGEXP_EMAIL)) {
+			List<User> users = userService.findBySecondUID(username);
+			if (!CollectionUtils.isEmpty(users)) {
+				user = users.get(0);
+			} else {
+				return error("邮箱地址错误");
+			}
+		} else if (username.matches(Const.REGEXP_MOBILE)) {
+			List<User> users = userService.findByUID(username);
+			if (!CollectionUtils.isEmpty(users)) {
+				user = users.get(0);
+			} else {
+				return error("手机号错误");
+			}
+		} else {
+			return error("请使用手机号或邮箱地址验证");
+		}
+		try {
+			boolean isPassCheck = (boolean) request.getSession().getAttribute("firstStep") &&
+					(boolean) request.getSession().getAttribute("answer1") && (boolean) request.getSession().getAttribute("answer2");
+			if (!isPassCheck) {
+				return error("请刷新后重试");
+			}
+		} catch (NullPointerException e) {
+			return error("请刷新后重试");
+		}
+
+		App app = appService.findOne(user.getAppId());
+		userService.changePassword(app, user, password);
+		user.setAppId(AccountConfig.ACCOUNT_CENTER);
+		syncUserPassword(user, password);
+		sysService.changepwd(user, password);
+		tokenService.delete(pageToken);
+		return success();
+	}
+
+	/**
+	 * 新开一个线程处理
+	 *
+	 * @param user
+	 * @param password
+	 */
+	private void syncUserPassword(final User user, final String password) {
+		new Thread(new Runnable() {
+			@Override
+			public void run() {
+				userService.syncUserPassword(user, password);
+			}
+		}).start();
+	}
+
+	/**
+	 * 控制台重置用户邮箱地址
+	 *
+	 * @param uid
+	 * @param secondUID
+	 * @return
+	 */
+	public ModelMap consoleResetEmail(@RequestParam(required = true) String uid, @RequestParam(required = true) String secondUID) {
+		if (!secondUID.matches(Const.REGEXP_EMAIL)) {
+			return error("邮箱地址格式错误");
+		}
+		userService.changeSecondUID(uid, secondUID);
+		return success();
+	}
+
+	/**
+	 * 企业信息库总数
+	 */
+	@RequestMapping(value = "/enterprise/count", method = RequestMethod.GET)
+	@ResponseBody
+	public Integer getEnterpriseCount() {
+		return userService.getEnterpriseCount();
+	}
+
+	/**
+	 * 优软云个人用户注册总数
+	 */
+	@RequestMapping(value = "/personalUser/count", method = RequestMethod.GET)
+	@ResponseBody
+	public Integer getPersonalUserCount() {
+		return userService.getPersonalUserCount();
+	}
+
+	/**
+	 * UU互联用户数
+	 */
+	@RequestMapping(value = "/uuUser/count", method = RequestMethod.GET)
+	@ResponseBody
+	public Integer getUuUserCount() {
+		return userService.getUuUserCount();
+	}
+
+	/**
+	 * 优软众创人员注册信息同步
+	 *
+	 * @param userDetail
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/sysUserdata/uuzc", method = RequestMethod.POST)
+	@ResponseBody
+	public UuzcUserDeatil sysUserdata(UuzcUserDeatil userDetail) throws UnsupportedEncodingException {
+		List<User> users = userService.findByUID(userDetail.getMobile());
+		String password = userDetail.getPassword();
+		// 转明码
+		String pwd = new String(Base64.decodeBase64(password.getBytes(UTF_8)), UTF_8);
+		userDetail.setPassword(pwd);
+		// 先判断账号是否已存在
+		if (!CollectionUtils.isEmpty(users)) {
+			User user = users.get(0);
+			return user.covert();
+		} else {
+			UserDetail detail = userDetail.covert();
+			detail = userService.save(detail);
+			return userService.initUserForUUzc(detail, userDetail.getPassword());
+		}
+	}
+
+	/**
+	 * 优软众创登录通知账户中心
+	 *
+	 * @param userDetail
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/login/fromuuzc", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap login(UuzcUserDeatil userDetail) throws UnsupportedEncodingException {
+		String password = userDetail.getPassword();
+		String pwd = new String(Base64.decodeBase64(password.getBytes(UTF_8)), UTF_8);
+		User user = userDetail.covertUser();
+		user.setPassword(pwd);
+		if (null == user || null == user.getAppId() || null == user.getPassword()) {
+			return error("参数错误");
+		}
+		User oldOne = userService.findByAppId(user);
+		App app = appService.findOne("b2b");
+		if (app != null) {
+			app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
+		}
+		if (null != oldOne.getId()) {
+			// // 允许应用在调用该接口前,已经将用户输入的明文加密为密文
+			// String encryPwd = user.getPassword().length() >= 32 ?
+			// user.getPassword()
+			// : userService.getEncryPassword(app.getEncryFormat(),
+			// user.getPassword(), user.getSalt());
+			// if (encryPwd.equals(oldOne.getPassword())) {
+			// return success("登录成功");
+			// }
+			// return error("密码错误");
+			List<UserView> userView = getUserByUserName(app, oldOne.getUid());
+			if (userView.size() > 0) {
+				return loginByUser(app, userView.get(0), pwd, user.getDialectUID());
+			}
+		}
+		return error("未找到用户");
+	}
+
+	private List<UserView> getUserByUserName(App app, String username) {
+		if (username.contains("@")) {
+			return userService.findByAppAndSecondUID(app.getUid(), username);
+		} else if (username.matches(Const.REGEXP_MOBILE)) {
+			return userService.findByAppAndUID(app.getUid(), username);
+		} else {
+			if (Const.NO == app.getDialectEnable()) {
+				throw new VisibleError("请使用手机号或邮箱地址登录" + app.getDescription());
+			}
+			return userService.findByAppAndDialectUID(app.getUid(), username);
+		}
+	}
+
+	private ModelMap loginByUser(App app, UserView user, String pass, String dialectuid) {
+		if (user == null) {
+			return error("您输入的账号或密码有误");
+		} else {
+			/*
+			 * 设置登录 Cookie 最后一个参数 true 时添加 cookie 同时销毁当前 JSESSIONID 创建信任的
+			 * JSESSIONID
+			 */
+			SSOToken st = new SSOToken(request, user.getUid());
+			st.setData(JSON.toJSONString(user));
+			SSOHelper.setSSOCookie(request, response, st, true);
+			return success();
+			// if (StringUtils.isEmpty((user.getPassword()))) {
+			// return error("100", "未设置密码");// 使用错误码100来判断
+			// } else if (!StringUtils.isEmpty(dialectuid)) {// 平台用户
+			// String encryPwd =
+			// userService.getEncryPassword(app.getEncryFormat(), pass,
+			// user.getSalt());
+			// if (encryPwd.equals(user.getPassword())) {
+			// UserSpaceDetail detail =
+			// userSpaceService.findByBusinessCode(user.getSpaceUID());
+			// if (detail != null)
+			// user.setSpaceDomain(detail.getDomain());
+			// /*
+			// * 设置登录 Cookie 最后一个参数 true 时添加 cookie 同时销毁当前 JSESSIONID
+			// * 创建信任的 JSESSIONID
+			// */
+			// SSOToken st = new SSOToken(request, user.getUid());
+			// st.setData(JSON.toJSONString(user));
+			// SSOHelper.setSSOCookie(request, response, st, true);
+			// return success();
+			// } else {
+			// return error("密码错误");
+			// }
+			// } else {// 众创用户
+				/*
+				 * 设置登录 Cookie 最后一个参数 true 时添加 cookie 同时销毁当前 JSESSIONID 创建信任的
+				 * JSESSIONID
+				 */
+			// }
+		}
+	}
+
+	/**
+	 * 优软众创更新用户信息
+	 *
+	 * @param detail
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(value = "/userInfo/fromuuzc", method = RequestMethod.POST)
+	@ResponseBody
+	public UuzcUserDeatil updateUserInfo(UuzcUserDeatil detail) throws UnsupportedEncodingException {
+		String password = detail.getPassword();
+		// 转明码
+		String pwd = new String(Base64.decodeBase64(password.getBytes(UTF_8)), UTF_8);
+		detail.setPassword(pwd);
+		User user = detail.covertUser();
+		UserDetail userDetail = detail.covert();
+		List<User> users = userService.save(user, userDetail);
+		return users.size() > 0 ? users.get(0).covert() : null;
+	}
+
+	/**
+	 * 设置当前企业的hr账号
+	 *
+	 * @param user
+	 * @param uuzcUserSpaceDetail
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "/setHrAccount", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap setHrAccount(User user, UuzcUserSpaceDetail uuzcUserSpaceDetail) throws Exception {
+		// 先判断当前企业是否已经存在hr账号
+		User hrInfo = userService.findHrInfo(uuzcUserSpaceDetail.getBusinessCode());
+		// 存在的话先将以前的权限去掉
+        if(null != hrInfo) {
+            if(hrInfo.getUid().equals(user.getUid())) {// 如果当前账号是hr账号,不用进行更改
+                return new ModelMap("msg", "success");
+            } else {
+                userService.updateHrInfo(hrInfo, false);
+            }
+        }
+        UserDetail detail = new UserDetail();
+        detail.setEmail(user.getSecondUID());
+        detail.setName(user.getName());
+        detail.setMobile(user.getUid());
+        user = userService.findOne("b2b", uuzcUserSpaceDetail.getBusinessCode(), user.getUid());
+        if (null == user) {
+            userService.save(detail);
+            userService.setHrAccount(detail, uuzcUserSpaceDetail);
+            user = userService.findOne("b2b", uuzcUserSpaceDetail.getBusinessCode(), detail.getMobile());
+            if (null != user) {
+                return new ModelMap("msg", "success");
+            } else {
+                return new ModelMap("msg", "setFailure");
+            }
+        } else {
+            userService.updateHrInfo(user, true);
+            return new ModelMap("msg", "success");
+        }
+	}
+
+	/**
+	 * 查询企业是否已开通hr账号
+	 *
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/hrcount", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getHrAccount(String businessCode) {
+		return new ModelMap("count", userService.findHrAccount(businessCode));
+	}
+
+    /**
+     * 获取当前企业hr的信息
+     *
+     * @param businessCode
+     * @return
+     */
+    @RequestMapping(value = "/hrInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public User getHrInfo(String businessCode) {
+        return userService.findHrInfo(businessCode);
+    }
+
+    /**
+     * 获取当前企业的信息
+     *
+     * @param businessCode
+     * @return
+     */
+    @RequestMapping(value = "/uuzcSpace", method = RequestMethod.GET)
+    @ResponseBody
+    public UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) {
+        UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+        return null != detail ? detail.covert() : null;
+    }
+
+	/**
+	 * 通过企业营业执照查询该企业的员工的信息
+	 *
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/employees", method = RequestMethod.POST)
+	@ResponseBody
+	public List<User> getEmployees(String businessCode) {
+		return userService.findByBusinessCode(businessCode);
+	}
+
+	@RequestMapping(value = "/checkTel", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap checkTel (@RequestParam String tel) {
+		UserDetail detail = userService.findOne(tel);
+		if (detail == null) {
+			return error("手机号未注册");
+		}
+		return success();
+	}
+
+	@RequestMapping(value = "/checkEmail", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap checkEmail (@RequestParam String email) {
+		if (email == null) {
+			return error("请输入邮箱");
+		}
+		List<UserDetail> details = userService.findByEmail(email);
+		if (CollectionUtils.isEmpty(details)) {
+			return error("邮箱未注册");
+		}
+		if (details.size() > 1) {
+			// 一个邮箱绑定了多次的账号信息
+			return error("您的邮箱未激活,请使用手机号认证");
+		}
+		request.getSession().setAttribute("fistStep", true);
+		return success();
+	}
+
+	/**
+	 * 获取用户密保问题
+	 * @param tel
+	 * @return
+	 */
+	@RequestMapping(value = "/encrypted/question", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getEncryptedQuestion (@RequestParam String tel) {
+		UserDetail detail = (UserDetail) request.getSession().getAttribute("detail");
+		if (detail == null) {
+			return error("请求超时,请返回第一步进行验证");
+		}
+		Long userUU = userService.findUserUUByMobile(detail.getMobile());
+		if (userUU == null) {
+			return error("用户无密保");
+		}
+		List<UserQuestion> userQuestions = userQuestionService.getEncryptedQuestion(userUU);
+		if (CollectionUtils.isEmpty(userQuestions)) {
+			userQuestions = userQuestionService.getDefaultQuestion(detail, 2);
+		}
+		List<Map<String, Object>> questions = new ArrayList<>();
+		Map<String, Object> question = null;
+		Map<Long, String> answers = new HashMap<>(userQuestions.size());
+		Map<Long, Short> sorts = new HashMap<>(userQuestions.size());
+		for (UserQuestion userQuestion : userQuestions) {
+			question = new HashMap<>(userQuestions.size());
+			question.put("id", userQuestion.getId());
+			question.put("question", userQuestion.getQuestion());
+			questions.add(question);
+			answers.put(userQuestion.getId(), userQuestion.getAnswer());
+			sorts.put(userQuestion.getId(), userQuestion.getSort());
+		}
+		request.getSession().setAttribute("answers", answers);
+		request.getSession().setAttribute("sorts", sorts);
+		return success(questions);
+	}
+
+	/**
+	 * 校验密保问题
+	 *
+	 * @param id
+	 * @param answer
+	 * @return
+	 */
+	@RequestMapping(value = "/check/question", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap checkEncryptedQuestion (@RequestParam Long id, @RequestParam String answer) {
+		Map<Long, String> answers = (Map<Long, String>) request.getSession().getAttribute("answers");
+		Map<Long, Short> sorts = (Map<Long, Short>) request.getSession().getAttribute("sorts");
+		if (id == null) {
+			return error("404", "请刷新重试");
+		}
+		if (answers == null) {
+			return error("404", "该手机号未设置密保");
+		}
+		if (!answers.containsKey(id)) {
+			return error("404", "非法操作");
+		}
+		if (!answers.get(id).equals(answer)) {
+			request.getSession().setAttribute("answer"+sorts.get(id), false);
+			return error("请输入正确的答案");
+		}
+		request.getSession().setAttribute("answer"+sorts.get(id), true);
+		boolean isOK;
+		try {
+			isOK = (boolean) request.getSession().getAttribute("answer1")
+					&& (boolean) request.getSession().getAttribute("answer2");
+		} catch (NullPointerException e) {
+			isOK = false;
+		}
+		return success("答案正确").addAttribute("isOk", isOK);
+	}
+
+	@RequestMapping(value = "/save/question", params = "_count=all", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap saveEncryptedQuestions (List<UserQuestion> questions) {
+		userQuestionService.save(questions);
+		return success();
+	}
+
+	@RequestMapping(value = "/save/question", params = "_count=one", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap saveEncryptedQuestion (UserQuestion userQuestion) {
+		userQuestionService.saveOne(userQuestion);
+		return success();
+	}
+}

+ 209 - 0
account-server/src/main/java/com/uas/account/controller/UserSpaceController.java

@@ -0,0 +1,209 @@
+package com.uas.account.controller;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+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.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.account.core.util.ChineseUtils;
+import com.uas.account.core.util.ExecuteUtils;
+import com.uas.account.core.util.StringUtil;
+import com.uas.account.entity.App;
+import com.uas.account.entity.Setting;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserDetail;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.entity.UserView;
+import com.uas.account.service.AppService;
+import com.uas.account.service.SettingService;
+import com.uas.account.service.UserService;
+import com.uas.account.service.UserSpaceService;
+import com.uas.account.viewmodel.ApplyAppView;
+import com.uas.account.web.BaseController;
+import com.uas.dfs.service.FileClient;
+import com.uas.message.mail.service.MailService;
+import com.uas.sso.SSOHelper;
+import com.uas.sso.SSOToken;
+
+/**
+ * 提供用户操作企业相关信息,need signin
+ * 
+ * @author yingp
+ * 
+ */
+@Controller
+@RequestMapping("/userspace")
+public class UserSpaceController extends BaseController {
+
+	@Autowired
+	private UserService userService;
+	@Autowired
+	private UserSpaceService userSpaceService;
+	@Autowired
+	private AppService appService;
+	@Autowired
+	private MailService mailService;
+	@Autowired
+	private SettingService settingService;
+	@Autowired
+	private FileClient fileClient;
+
+	/**
+	 * 用户申请为企业开通应用
+	 * 
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(value = "/applyApp", method = RequestMethod.GET)
+	public ModelAndView applyApp(String appId) {
+		SSOToken token = SSOHelper.attrToken(request);
+		UserView user = JSON.parseObject(token.getData(), UserView.class);
+
+		App app = appService.findOne(appId);
+		if (null == app) {
+			return new ModelAndView("common/error", error("404", "未找到您要开通的应用"));
+		}
+
+		if (StringUtils.isEmpty(user.getSpaceUID()) || StringUtils.isEmpty(user.getUid())) {
+			return new ModelAndView("common/error", error("您的账户信息未核实,无法开通" + app.getDescription()));
+		}
+
+		UserSpace oldUs = userSpaceService.findOne(appId, user.getSpaceUID());
+
+		if (null != oldUs) {
+			// 如果企业已经开通该应用
+			User oldUser = userService.findOne(appId, oldUs.getId(), user.getUid());
+			if (null != oldUser) {
+				// 直接重定向到该应用主页
+				if (!StringUtils.isEmpty(app.getHomePage())) {
+					return new ModelAndView("redirect:" + app.getHomePage().replace("$domain", user.getSpaceDomain()));
+				} else {
+					return new ModelAndView("common/error", error(String.format("%s 已开通%s,您可以直接访问", oldUs.getName(), app.getDescription())));
+				}
+			} else {
+				// 但是个人账号还未开通
+				return new ModelAndView("common/error", error(String.format("%s 已开通%s,请联系企业管理员开通您的个人账号", oldUs.getName(),
+						app.getDescription())));
+			}
+		}
+		UserSpaceDetail detail = userSpaceService.findByBusinessCode(user.getSpaceUID());
+		if (StringUtils.isEmpty(detail.getDomain())) {
+			detail.setDomain(generateDefaultDomain(detail));
+		}
+
+		// 开通应用的界面
+		return new ModelAndView("us/apply_" + appId, success(detail).addAttribute("user", user).addAttribute("appId", appId));
+	}
+
+	/**
+	 * 生成默认域名
+	 * 
+	 * @return
+	 */
+	private String generateDefaultDomain(UserSpaceDetail detail) {
+		String domain = null;
+		if (!StringUtils.isEmpty(detail.getUrl())) {
+			Pattern p = Pattern.compile("http(s)*://(.+\\.)*(.+)\\..+", Pattern.CASE_INSENSITIVE);
+			Matcher m = p.matcher(detail.getUrl());
+			if (m.find()) {
+				domain = m.group(3);
+			}
+		}
+		if (domain == null)
+			domain = StringUtil.substr(ChineseUtils.converterToFirstSpell(StringUtils.trimAllWhitespace(detail.getName())), 0, 16);
+		UserSpaceDetail oldOne = userSpaceService.findByDomain(domain);
+		if (oldOne != null) {
+			domain = StringUtil.substr(ChineseUtils.converterToSpell(StringUtils.trimAllWhitespace(detail.getName())), 0, 16);
+			oldOne = userSpaceService.findByDomain(domain);
+			if (oldOne != null)
+				domain = null;
+		}
+		return domain;
+	}
+
+	/**
+	 * 开通应用
+	 * 
+	 * @param businessCode
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(value = "/applyApp", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap applyApp(String businessCode, final String appId, final ApplyAppView view, @RequestBody MultipartFile file) {
+		final UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		if (detail == null) {
+			return error("您的企业注册资料已经失效,请重新注册");
+		}
+		detail.setDomain(view.getDomain());
+		if (null != file && !file.isEmpty()) {
+			try {
+				String path = fileClient.upload(file.getBytes(), file.getSize(), FilenameUtils.getExtension(file.getOriginalFilename()),
+						null);
+				if (path != null) {
+					detail.setLogoImage(path);
+					try {
+						userSpaceService.save(detail);
+					} catch (Exception e) {
+						fileClient.delete(path);
+						throw e;
+					}
+				} else {
+					return error("请检查您的企业LOGO图片");
+				}
+			} catch (IOException e) {
+				return error("请检查您的企业LOGO图片");
+			}
+		} else {
+			userSpaceService.save(detail);
+		}
+		// TODO 这里填写的用户,还要判断是否已开通默认应用
+		userSpaceService.applyApp(businessCode, appId, null, view.getUserDetails());
+		view.getUserDetails().add(new UserDetail(detail));
+		// 知会下企业用户
+		ExecuteUtils.asyncExecute(new Runnable() {
+
+			@Override
+			public void run() {
+				for (UserDetail user : view.getUserDetails()) {
+					if (!StringUtils.isEmpty(user.getEmail())) {
+						// 邮件
+						Setting mailTpl = settingService.findOne("templateForSendMailWhenRegisterFinished." + appId + "."
+								+ (!StringUtils.isEmpty(user.getDepartment()) ? user.getDepartment() : "管理员"));
+						if (mailTpl != null) {
+							ModelMap data = new ModelMap();
+							data.put("domain", detail.getDomain());
+							data.put("spaceName", detail.getName());
+							data.put("name", user.getName());
+							data.put("uid", user.getMobile());
+							data.put("job", user.getJob());
+							mailService.send(mailTpl.getValue(), user.getEmail(), data);
+						}
+					}
+				}
+			}
+		});
+		// 信息有变,修改sso信息
+		SSOToken token = SSOHelper.attrToken(request);
+		UserView user = JSON.parseObject(token.getData(), UserView.class);
+		user.setSpaceDomain(detail.getDomain());
+		token = new SSOToken(request, user.getUid());
+		token.setData(JSON.toJSONString(user));
+		SSOHelper.setSSOCookie(request, response, token, true);
+		return success();
+	}
+
+}

+ 689 - 0
account-server/src/main/java/com/uas/account/controller/UserSpaceManagerController.java

@@ -0,0 +1,689 @@
+package com.uas.account.controller;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.account.core.ICallable;
+import com.uas.account.core.Page;
+import com.uas.account.core.util.ExecuteUtils;
+import com.uas.account.dao.UserDao;
+import com.uas.account.entity.App;
+import com.uas.account.entity.AppCreateInfo;
+import com.uas.account.entity.Setting;
+import com.uas.account.entity.Token;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserDetail;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.entity.UserView;
+import com.uas.account.exception.AccountException;
+import com.uas.account.service.AppService;
+import com.uas.account.service.PlatformManageService;
+import com.uas.account.service.SettingService;
+import com.uas.account.service.SysDataToMallService;
+import com.uas.account.service.TokenService;
+import com.uas.account.service.UserService;
+import com.uas.account.service.UserSpaceService;
+import com.uas.account.viewmodel.ApplyAppView;
+import com.uas.account.viewmodel.UserSpaceDetailView;
+import com.uas.account.web.BaseController;
+import com.uas.message.mail.service.MailService;
+
+@Controller
+@RequestMapping("/api/userspace")
+public class UserSpaceManagerController extends BaseController {
+
+	@Autowired
+	private UserSpaceService userSpaceService;
+	@Autowired
+	private MailService mailService;
+	@Autowired
+	private SettingService settingService;
+	@Autowired
+	private TokenService tokenService;
+	@Autowired
+	private UserService userService;
+	@Autowired
+	private UserDao userDao;
+	@Autowired
+	private AppService appService;
+	@Autowired
+	private PlatformManageService platformManageService;
+	@Autowired
+	private SysDataToMallService sysDataToMallService;
+
+	/**
+	 * aapid 为 saas
+	 */
+	private final String saas = "saas";
+
+	/**
+	 * appid 为 uas
+	 */
+	private final String uas = "uas";
+
+	/**
+	 * appid 为 b2b
+	 */
+	private final String b2b = "b2b";
+
+	/**
+	 * appid 为 mall
+	 */
+	private final String mall = "mall";
+
+	/**
+	 * 企业信息新增、修改
+	 * 
+	 * @param userSpace
+	 * @param userSpaceDetail
+	 * @param apps
+	 *            绑定应用(为空表示开通全部默认应用)
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap save(UserSpace userSpace, UserSpaceDetail userSpaceDetail, String apps) {
+		if (userSpace == null || userSpace.getName() == null
+				|| (userSpace.getId() == null && (userSpace.getAppId() == null || userSpace.getUid() == null)))
+			return error("参数错误");
+		boolean isNew = userSpaceService.save(userSpace, userSpaceDetail,
+				null == apps ? null : new HashSet<String>(Arrays.asList(apps.split(","))));
+		if (isNew && !StringUtils.isEmpty(userSpaceDetail.getAdminEmail())) {
+			// 邮件通知
+			Setting mailTpl = settingService.findOne("templateForSendMailWhenRegisterFinished." + userSpace.getAppId() + ".管理员");
+			if (mailTpl != null) {
+				ModelMap data = new ModelMap();
+				data.put("domain", userSpaceDetail.getDomain());
+				data.put("spaceName", userSpaceDetail.getName());
+				data.put("name", userSpaceDetail.getAdminName());
+				data.put("uid", userSpaceDetail.getAdminTel());
+				data.put("job", "管理员");
+				mailService.send(mailTpl.getValue(), userSpaceDetail.getAdminEmail(), data);
+			}
+		}
+		return success(userSpaceService.findByUID(userSpace.getUid()));
+	}
+
+	/**
+	 * 取消企业开通的应用
+	 * 
+	 * @param userSpace
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=unbind", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap apiUnbind(UserSpace userSpace) {
+		if (userSpace == null || userSpace.getAppId() == null)
+			throw new AccountException("参数错误");
+		userSpaceService.delete(userSpace);
+		return success();
+	}
+
+	/**
+	 * 按应用查找企业
+	 * 
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(value = "/list", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpace> findAll(String appId, int pageNumber, int pageSize) {
+		return userSpaceService.findAll(appId, pageNumber, pageSize);
+	}
+
+	/**
+	 * 企业开通应用统计
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/count", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap count() {
+		return success(userSpaceService.getUserSpaceAppCount());
+	}
+
+	/**
+	 * 按UID查找企业所使用的全部应用
+	 * 
+	 * @param uid
+	 * @return
+	 */
+	@RequestMapping(value = "/{uid}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findOne(@PathVariable("uid") String uid) {
+		return success(userSpaceService.findByUID(uid));
+	}
+
+	/**
+	 * 按注册号查找企业详细信息
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/{businessCode}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findDetail(@PathVariable("businessCode") String businessCode) {
+		return success(userSpaceService.findByBusinessCode(businessCode));
+	}
+
+	/**
+	 * 按注册号查找企业详细信息
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/id/{id}", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap findDetailById(@PathVariable("id") Long id) {
+		return success(userSpaceService.findById(id));
+	}
+
+	/**
+	 * 查找所有企业的信息
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpaceDetailView> findAllDetail(String name, String businessCode, String address, int pageNumber, int pageSize) {
+		return userSpaceService.findAll(name, businessCode, address, pageNumber, pageSize);
+	}
+
+	/**
+	 * 按状态查找企业信息,已激活
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", params = "status=ENABLED", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpaceDetailView> findAllEnabledDetail(String name, String businessCode, int pageNumber, int pageSize) {
+		return userSpaceService.findAllEnable(name, businessCode, pageNumber, pageSize);
+	}
+
+	/**
+	 * 按状态查找企业信息,待审批
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", params = "status=UNAUDIT", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpaceDetailView> findAllUnAuditDetail(String name, String businessCode, int pageNumber, int pageSize) {
+		return userSpaceService.findAllUnAudit(name, businessCode, pageNumber, pageSize);
+	}
+
+	/**
+	 * 按状态查找企业信息,审批未通过
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", params = "status=UNAPPLY", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpaceDetailView> findAllUnApplyDetail(String name, String businessCode, int pageNumber, int pageSize) {
+		return userSpaceService.findAllUnApply(name, businessCode, pageNumber, pageSize);
+	}
+
+	/**
+	 * 按状态查找企业信息,未激活
+	 * 
+	 * @param appId
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/list", params = "status=UNACT", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<UserSpaceDetailView> findAllUnActiveDetail(String name, String businessCode, int pageNumber, int pageSize) {
+		return userSpaceService.findAllUnActive(name, businessCode, pageNumber, pageSize);
+	}
+
+	/**
+	 * 审批通过
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/audit", params = "enable=1")
+	@ResponseBody
+	public ModelMap enableDetail(String businessCode, Long id) {
+		userSpaceService.enable(businessCode);
+		UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		// 邮件
+		return sendEmail(detail.getAdminEmail(), businessCode);
+	}
+
+	/**
+	 * 审批未通过
+	 * 
+	 * @param reason
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/audit", params = "enable=0")
+	@ResponseBody
+	public ModelMap disableDetail(String reason, String businessCode, Long id) {
+		userSpaceService.disable(id, reason);
+		UserSpaceDetail detail = userSpaceService.findById(id);
+		// 邮件
+		Setting mailTpl = settingService.findOne("templateForSendMailAfterRegisterFailed");
+		if (mailTpl != null && detail.getAdminEmail() != null) {
+			ModelMap data = new ModelMap();
+			data.put("reason", reason);
+			data.put("content", detail);
+			mailService.send(mailTpl.getValue(), detail.getAdminEmail(), data);
+			return success();
+		}
+		return error("没有找到邮件模板,请设置后重新发送激活邮件");
+	}
+
+	/**
+	 * 重新发送激活邮件
+	 * 
+	 * @param email
+	 * @param businessCode
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/send")
+	@ResponseBody
+	public ModelMap sendEmail(String email, String businessCode) {
+		UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		// 邮件
+		Setting mailTpl = settingService.findOne("templateForSendMailAfterRegisterSuccess");
+		if (mailTpl != null && detail.getAdminEmail() != null) {
+			// 3 days
+			final Token token = new Token(detail.getBusinessCode(), 259200);
+
+			tokenService.save(token);
+			ModelMap data = new ModelMap();
+			data.put("token", token.getId());
+			data.put("content", detail);
+			mailService.send(mailTpl.getValue(), email, data);
+			return success();
+		}
+		return error("没有找到邮件模板,请设置后重新发送邮件");
+	}
+
+	/**
+	 * 修改管理员邮箱
+	 * 
+	 * @param email
+	 * @param businessCode
+	 * @param tel
+	 * @return
+	 */
+	@RequestMapping(value = "/detail/updateMail", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap updateEmail(String email, String businessCode, String tel) {
+		UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		UserDetail userdetail = userService.findOne(tel);
+		if (detail != null) {
+			detail.setAdminEmail(email);
+			userSpaceService.save(detail);
+		} else {
+			return error("暂未查询到企业相关信息,可能已被删除");
+		}
+
+		if (userdetail != null) {
+			userdetail.setEmail(email);
+			userDao.save(userdetail);
+		} else {
+			return error("暂未询到用户相关信息,可能已被删除");
+		}
+		return success("修改邮箱成功");
+	}
+
+	/**
+	 * 开通应用
+	 * 
+	 * @param businessCode
+	 * @param app
+	 * @return
+	 */
+	@RequestMapping(value = "/applyApp")
+	@ResponseBody
+	public ModelMap applyApp(String businessCode, final String app, final ApplyAppView view) {
+		final UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		userSpaceService.applyApp(businessCode, app, view.getPassword(), view.getUserDetails());
+		view.getUserDetails().add(new UserDetail(detail));
+		// 知会下企业用户
+		ExecuteUtils.asyncExecute(new Runnable() {
+
+			@Override
+			public void run() {
+				ExecuteUtils.execute(new ICallable<Void, UserDetail>() {
+
+					@Override
+					public Void call(UserDetail user) throws Exception {
+						// 邮件
+						Setting mailTpl = settingService.findOne("templateForSendMailWhenRegisterFinished." + app + "."
+								+ (!StringUtils.isEmpty(user.getDepartment()) ? user.getDepartment() : "管理员"));
+						if (mailTpl != null) {
+							ModelMap data = new ModelMap();
+							data.put("domain", detail.getDomain());
+							data.put("spaceName", detail.getName());
+							data.put("name", user.getName());
+							data.put("uid", user.getMobile());
+							data.put("job", user.getJob());
+							mailService.send(mailTpl.getValue(), user.getEmail(), data);
+						}
+						return null;
+					}
+
+				}, view.getUserDetails());
+			}
+		});
+		return success();
+	}
+
+	/**
+	 * 修改企业名称简称
+	 * 
+	 * @param id
+	 * @param renewName
+	 * @param renewShortName
+	 * @return
+	 */
+	@SuppressWarnings("unused")
+	@RequestMapping(value = "/renewUserSpace", method = RequestMethod.POST)
+	@ResponseBody
+	public ModelMap renewUserSpace(Long id, String renewName, String renewShortName, String renewAdress, String renewUid) {
+		UserSpaceDetail detail = userSpaceService.findById(id);
+		String businessCode = detail.getBusinessCode();
+		if (detail != null) {
+			if (renewName != null) {
+				detail.setName(renewName);
+			}
+			if (renewShortName != null) {
+				detail.setShortName(renewShortName);
+			}
+			if (renewAdress != null) {
+				detail.setAddress(renewAdress);
+			}
+			if (renewUid != null) {
+				detail.setBusinessCode(renewUid);
+			}
+			userSpaceService.save(detail);
+			//更新ac$userspace中的信息
+			UserSpace space = userSpaceService.findOne(b2b, businessCode);
+			if (space != null) {
+				Long enuu = Long.valueOf(space.getDialectUID());
+				detail.setUu(enuu);
+				space.setName(renewName);
+				space.setUid(renewUid);
+				try {
+					userSpaceService.update(space, space.getId());
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+			// 同步到平台更新企业信息
+			App app = appService.findOne(b2b);
+			try {
+				userSpaceService.callbacktoAppAfterUpdate(app, detail);
+
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			// 更新管理平台企业信息的数据
+			try {
+				platformManageService.updateEnterpriseInfoInManage(detail, businessCode);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			// 更新管理平台控制中心数据
+			try {
+				platformManageService.updateMasterInfoInManage(detail, businessCode);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			// 同步更新到商城
+			try {
+				sysDataToMallService.UserSpace(space, detail);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		} else {
+			return error("暂未查询到企业相关信息,请刷新后重试");
+		}
+		return success("企业名称修改成功");
+	}
+	
+	/**
+	 * 校验企业名称
+	 * 
+	 * @param name
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=validName", method = RequestMethod.GET)
+	@ResponseBody
+	public AppCreateInfo validName(String name) {
+		// 去掉可能存在的空格再进行检验
+		name = StringUtils.trimAllWhitespace(name);
+		AppCreateInfo info = new AppCreateInfo();
+		info.setHasCreate(false);
+		info.setInCloud(false);
+		if (!StringUtils.isEmpty(name)) {
+			UserSpaceDetail detail = userSpaceService.findByName(name);
+			if (null != detail) {
+				// 是否注册过saas
+				UserSpace userSpace = userSpaceService.findOne(saas, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setHasCreate(true);
+				}
+				// 是否注册过uas
+				userSpace = userSpaceService.findOne(uas, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setHasCreate(true);
+				}
+				// 是否注册过平台
+				userSpace = userSpaceService.findOne(b2b, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setInCloud(true);
+					info.setBusinessCode(userSpace.getUid());
+				}
+			}
+		}
+		return info;
+	}
+
+	/**
+	 * 校验企业营业执照
+	 * 
+	 * @param businessCode
+	 * @return
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(params = "_operate=validBusinessCode", method = RequestMethod.GET)
+	@ResponseBody
+	public AppCreateInfo validBusinessCode(String businessCode) throws UnsupportedEncodingException {
+		// 去掉可能存在的空格再进行检验
+		businessCode = StringUtils.trimAllWhitespace(businessCode);
+		AppCreateInfo info = new AppCreateInfo();
+		info.setHasCreate(false);
+		info.setInCloud(false);
+		if (!StringUtils.isEmpty(businessCode)) {
+			UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+			if (null != detail) {
+				// 是否注册过saas
+				UserSpace userSpace = userSpaceService.findOne(saas, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setHasCreate(true);
+				}
+				// 是否注册过uas
+				userSpace = userSpaceService.findOne(uas, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setHasCreate(true);
+				}
+				// 是否注册过平台
+				userSpace = userSpaceService.findOne(b2b, detail.getBusinessCode());
+				if (userSpace != null) {
+					info.setInCloud(true);
+					info.setName(userSpace.getName());
+				}
+			}
+		}
+		return info;
+	}
+
+	/**
+	 * 通过营业执照号查找 企业详细信息
+	 *
+	 * @param businessCode
+	 * @return
+	 * @throws UnsupportedEncodingException
+	 */
+	@RequestMapping(params = "_operate=findByBusinessCode", method = RequestMethod.GET)
+	@ResponseBody
+	public UserSpaceDetail findByBusinessCode(String businessCode) throws UnsupportedEncodingException {
+		return userSpaceService.findByBusinessCode(businessCode);
+	}
+	
+	/**
+	 * ERP、SAAS新开账套注册平台
+	 * 
+	 * @param userSpaceDetail
+	 * @param users
+	 */
+	@RequestMapping(params = "_operate=registerBranchAccount", method = RequestMethod.POST)
+	@ResponseBody
+	public AppCreateInfo applyApp(String detail, String userInfos) {
+		AppCreateInfo info = new AppCreateInfo();
+		List<UserDetail> users = JSON.parseArray(userInfos, UserDetail.class);
+		UserSpaceDetail userSpaceDetail = JSONObject.parseObject(detail, UserSpaceDetail.class);
+		userSpaceDetail.setRegisterDate(new Date().getTime());
+		userSpaceDetail = userSpaceService.save(userSpaceDetail);
+		String password = null;
+		User user = userService.findOne(uas, userSpaceDetail.getBusinessCode(), userSpaceDetail.getAdminTel());
+		if (user != null) {
+			password = user.getPassword();
+		} else {
+			user = userService.findOne(saas, userSpaceDetail.getBusinessCode(), userSpaceDetail.getAdminTel());
+			if (user != null) {
+				password = user.getPassword();
+			} else {
+				password = "111111";
+			}
+		}
+		userSpaceService.applyApp(userSpaceDetail.getBusinessCode(), b2b, password, users);
+		// 注册完后查询uu号等信息
+		UserSpace space = userSpaceService.findOne(b2b, userSpaceDetail.getBusinessCode());
+		if (null != space) {
+			info.setInCloud(true);
+			info.setEnuu(space.getDialectUID());
+		} else {
+			info.setInCloud(false);
+		}
+		return info;
+	}
+	
+	/**
+	 * 根据用户的手机号码查找对应的所属企业和企业地址
+	 * 
+	 * @param tel
+	 * @return
+	 */
+	@RequestMapping(value = "/userSpaceDetail", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getUserSpaceDetail(String tel) {
+		List<String> tels = Arrays.asList(tel.split(","));
+		return CollectionUtils.isEmpty(tels) ? new ModelMap("listdata", "请先输入电话号码")
+				: new ModelMap("listdata", userSpaceService.findByTel(tels));
+	}
+
+	/**
+	 * 根据用户的手机号查询企业信息和个人信息
+	 * 
+	 * @param tel
+	 * @return
+	 */
+	@RequestMapping(value = "/userInfos", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getUserInfos(String tel) {
+		List<String> tels = Arrays.asList(tel.split(","));
+		return CollectionUtils.isEmpty(tels) ? new ModelMap("listdata", "请先输入电话号码")
+				: new ModelMap("listdata", userSpaceService.findUserByTel(tels));
+	}
+
+	/**
+	 * 通过企业名称查询企业相关信息
+	 * 
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping(value = "/userSpaceDetail/keyword", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getUserSpaceDetailByKeyword(String keyword, Integer pageNumber) {
+		return StringUtils.isEmpty(keyword) ? new ModelMap("listdata", "请先输入企业名称")
+				: new ModelMap("listdata", userSpaceService.findByKeyword(keyword, pageNumber));
+	}
+
+	/**
+	 * 通过企业名称查询该企业的员工的信息
+	 * 
+	 * @param name
+	 * @param pageNumber
+	 * @return
+	 */
+	@RequestMapping(value = "/employees", method = RequestMethod.GET)
+	@ResponseBody
+	public ModelMap getEmployees(String name, Integer pageNumber) {
+		return StringUtils.isEmpty(name) ? new ModelMap("listdata", "请先输入企业名称")
+				: new ModelMap("listdata", userService.findByEnName(name, pageNumber));
+	}
+
+	/**
+	 * 商城个人用户重新注册企业相关
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	@RequestMapping(params = "_operate=registForMall", method = RequestMethod.POST)
+	@ResponseBody
+	public AppCreateInfo applyAppForMall(String detail) {
+		AppCreateInfo info = new AppCreateInfo();
+		UserSpaceDetail userSpaceDetail = JSONObject.parseObject(detail, UserSpaceDetail.class);
+		userSpaceDetail.setRegisterDate(new Date().getTime());
+		userSpaceDetail = userSpaceService.save(userSpaceDetail);
+		String password = null;
+		List<UserView> users = userService.findByAppAndUID(b2b, userSpaceDetail.getAdminTel());
+		if (!CollectionUtils.isEmpty(users)) {
+			password = users.get(0).getPassword();
+		} else {
+			password = "111111";
+		}
+		userSpaceService.applyApp(userSpaceDetail.getBusinessCode(), b2b, password, null);
+		userSpaceService.applyApp(userSpaceDetail.getBusinessCode(), mall, password, null);
+		// 注册完后查询uu号等信息
+		UserSpace space = userSpaceService.findOne(mall, userSpaceDetail.getBusinessCode());
+		if (null != space) {
+			info.setInCloud(true);
+			info.setEnuu(space.getDialectUID());
+		} else {
+			info.setInCloud(false);
+		}
+		return info;
+	}
+}

+ 15 - 0
account-server/src/main/java/com/uas/account/core/Const.java

@@ -0,0 +1,15 @@
+package com.uas.account.core;
+
+public class Const {
+
+	public static final int NO = 0;
+
+	public static final int YES = 1;
+
+	public static final String REGEXP_MOBILE = "^[1|8][3-8]\\d{9}$|^([6|9])\\d{7}$|^[0][9]\\d{8}$|^[6]([8|6])\\d{5}$|^(886|0)[9]\\d{8}$";
+
+	public static final String REGEXP_EMAIL = "^([\\w-])+(\\.\\w+)*@([\\w-])+((\\.\\w{2,3}){1,3})$";
+
+	public static final String SPACEID_PERSONAL_REGISTER = "1";
+
+}

+ 20 - 0
account-server/src/main/java/com/uas/account/core/ICallable.java

@@ -0,0 +1,20 @@
+package com.uas.account.core;
+
+import java.util.concurrent.Callable;
+
+/**
+ * 能传入参数执行的callable
+ * 
+ * @author yingp
+ * @see Callable
+ * 
+ * @param <V>
+ *            返回结果类型
+ * @param <T>
+ *            参数类型
+ */
+public abstract interface ICallable<V, T> {
+
+	public abstract V call(T param) throws Exception;
+
+}

+ 37 - 0
account-server/src/main/java/com/uas/account/core/ICallableAdapter.java

@@ -0,0 +1,37 @@
+package com.uas.account.core;
+
+import java.util.concurrent.Callable;
+
+/**
+ * 代理callable来执行
+ * 
+ * <pre>
+ * 涉及到一个callable对象调用不同参数循环执行的问题,不能直接在ICallable对象里面设置参数,需要代理执行
+ * </pre>
+ * 
+ * @see ICallable
+ * @see Callable
+ * 
+ * @author yingp
+ * 
+ * @param <V>
+ *            返回结果类型
+ * @param <T>
+ *            参数类型
+ */
+public final class ICallableAdapter<V, T> implements Callable<V> {
+
+	private final ICallable<V, T> task;
+	private final T param;
+
+	public ICallableAdapter(ICallable<V, T> task, T param) {
+		this.task = task;
+		this.param = param;
+	}
+
+	@Override
+	public V call() throws Exception {
+		return task.call(param);
+	}
+
+}

+ 87 - 0
account-server/src/main/java/com/uas/account/core/Logger.java

@@ -0,0 +1,87 @@
+package com.uas.account.core;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import com.uas.account.entity.Log;
+
+public class Logger {
+
+	private static List<Log> logs;
+
+	private static Logger instance;
+
+	public static Logger getLogger() {
+		if (instance == null) {
+			instance = new Logger();
+			logs = new LinkedList<Log>();
+		}
+		return instance;
+	}
+
+	public List<Log> getLogsAndClear() {
+		synchronized (logs) {
+			List<Log> copy = new LinkedList<Log>(logs);
+			logs = new LinkedList<Log>();
+			return copy;
+		}
+	}
+
+	public void info(String msg) {
+		info(null, null, msg, null);
+	}
+
+	public void info(String msg, Object detailMsg) {
+		info(null, null, msg, detailMsg);
+	}
+
+	public void info(String key, String msg, Object detailMsg) {
+		info(null, key, msg, detailMsg);
+	}
+
+	public void info(Class<?> cls, String key, String msg) {
+		info(null, key, msg, null);
+	}
+
+	public void info(Class<?> cls, String key, String msg, Object detailMsg) {
+		synchronized (logs) {
+			logs.add(Log.info(cls == null ? null : cls.getName(), key, msg, detailMsg));
+		}
+	}
+
+	public void warn(String msg) {
+		warn(null, null, msg, null);
+	}
+
+	public void warn(String msg, Object detailMsg) {
+		warn(null, null, msg, detailMsg);
+	}
+
+	public void warn(String key, String msg, Object detailMsg) {
+		warn(null, key, msg, detailMsg);
+	}
+
+	public void warn(Class<?> cls, String key, String msg, Object detailMsg) {
+		synchronized (logs) {
+			logs.add(Log.warn(cls == null ? null : cls.getName(), key, msg, detailMsg));
+		}
+	}
+
+	public void error(String msg) {
+		error(null, null, msg, null);
+	}
+
+	public void error(String msg, Object detailMsg) {
+		error(null, null, msg, detailMsg);
+	}
+
+	public void error(String key, String msg, Object detailMsg) {
+		error(null, key, msg, detailMsg);
+	}
+
+	public void error(Class<?> cls, String key, String msg, Object detailMsg) {
+		synchronized (logs) {
+			logs.add(Log.error(cls == null ? null : cls.getName(), key, msg, detailMsg));
+		}
+	}
+}

+ 87 - 0
account-server/src/main/java/com/uas/account/core/MergeTask.java

@@ -0,0 +1,87 @@
+package com.uas.account.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 任务聚合<br>
+ * 将多个分支任务并行处理,将任务处理的结果合并返回
+ * 
+ * @author yingp
+ *
+ * @param <V>
+ *            返回结果类型
+ * @param <T>
+ *            传递参数类型
+ */
+public class MergeTask<V, T> {
+
+	// 缓冲的线程池
+	private final ExecutorService threadPool;
+
+	private final CompletionService<V> service;
+
+	// 定义一个带参有返回的callable
+	private final ICallable<V, T> callable;
+
+	private int taskCount = 0;
+
+	public MergeTask(ICallable<V, T> callable) {
+		this.threadPool = Executors.newCachedThreadPool();
+		this.service = new ExecutorCompletionService<V>(threadPool);
+		this.callable = callable;
+	}
+
+	/**
+	 * 添加分支任务
+	 * 
+	 * @param param
+	 *            针对ICallable传递的参数
+	 * @return
+	 */
+	public MergeTask<V, T> join(T param) {
+		service.submit(new ICallableAdapter<V, T>(callable, param));
+		taskCount++;
+		return this;
+	}
+
+	/**
+	 * 获取聚合的结果,结果扔到List里面返回
+	 * 
+	 * @return
+	 */
+	public List<V> execute() {
+		threadPool.shutdown();
+		int finish = 0;
+		List<V> datas = new ArrayList<V>();
+		while (finish < taskCount) {
+			// 非阻塞方式
+			Future<V> future = service.poll();
+			if (future != null) {
+				try {
+					V result = future.get();
+					if (result != null) {
+						datas.add(result);
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				finish++;
+			}
+			if (finish < taskCount)
+				try {
+					// 等待50毫秒再进入下一次查找
+					TimeUnit.MILLISECONDS.sleep(50);
+				} catch (InterruptedException e) {
+				}
+		}
+		return datas;
+	}
+
+}

+ 87 - 0
account-server/src/main/java/com/uas/account/core/Page.java

@@ -0,0 +1,87 @@
+package com.uas.account.core;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class Page<T> implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private int number;
+	private int size;
+	private int numberOfElements;
+	private List<T> content;
+	private boolean first;
+	private boolean last;
+	private long totalElements;
+
+	public Page(int pageNumber, int pageSize, List<T> content, int totalElements) {
+		this.number = pageNumber;
+		this.size = pageSize;
+		this.content = content;
+		this.numberOfElements = content == null || content.isEmpty() ? 0 : content.size();
+		this.totalElements = totalElements;
+		this.first = pageNumber == 1;
+		this.last = pageNumber >= (int) Math.floor((double) totalElements / pageSize);
+	}
+
+	public int getNumber() {
+		return number;
+	}
+
+	public void setNumber(int number) {
+		this.number = number;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public int getNumberOfElements() {
+		return numberOfElements;
+	}
+
+	public void setNumberOfElements(int numberOfElements) {
+		this.numberOfElements = numberOfElements;
+	}
+
+	public List<T> getContent() {
+		return content;
+	}
+
+	public void setContent(List<T> content) {
+		this.content = content;
+	}
+
+	public boolean isFirst() {
+		return first;
+	}
+
+	public void setFirst(boolean first) {
+		this.first = first;
+	}
+
+	public boolean isLast() {
+		return last;
+	}
+
+	public void setLast(boolean last) {
+		this.last = last;
+	}
+
+	public long getTotalElements() {
+		return totalElements;
+	}
+
+	public void setTotalElements(long totalElements) {
+		this.totalElements = totalElements;
+	}
+
+}

+ 65 - 0
account-server/src/main/java/com/uas/account/core/Status.java

@@ -0,0 +1,65 @@
+package com.uas.account.core;
+
+public enum Status {
+
+	/**
+	 * {@code 310 未启用}
+	 */
+	UNAPPLY(310, "未启用"),
+	/**
+	 * {@code 311 申请中}
+	 */
+	UNAUDIT(311, "申请中"),
+	/**
+	 * {@code 312 未激活}
+	 */
+	UNACT(312, "未激活"),
+	/**
+	 * {@code 313 已激活}
+	 */
+	ENABLED(313, "已激活"),
+	/**
+	 * {@code 314 已禁用}
+	 */
+	DISABLED(314, "已禁用"),
+	/**
+	 * {@code 315 已注销,已取消}
+	 */
+	CANCELLED(315, "已注销"),
+	/**
+	 * {@code 400 信息资料还未验证}
+	 */
+	UNAPPROVED(400, "待验证"),
+	/**
+	 * {@code 401 信息资料已进行验证,但未通过审核}
+	 */
+	APPROVED_ERROR(401, "验证不通过"),
+	/**
+	 * {@code 402 信息资料已验证通过}
+	 */
+	APPROVED_SUCCESS(402, "已验证");
+
+	private Status(int value, String phrase) {
+		this.value = value;
+		this.phrase = phrase;
+	}
+
+	private final int value;
+
+	private final String phrase;
+
+	/**
+	 * @return 状态的整型编码
+	 */
+	public int value() {
+		return this.value;
+	}
+
+	/**
+	 * @return 状态的描述
+	 */
+	public String getPhrase() {
+		return this.phrase;
+	}
+
+}

+ 15 - 0
account-server/src/main/java/com/uas/account/core/util/ArrayUtils.java

@@ -0,0 +1,15 @@
+package com.uas.account.core.util;
+
+public class ArrayUtils {
+
+	public static boolean contains(String[] arr, String param) {
+		if (arr != null && param != null) {
+			for (String r : arr) {
+				if (param.equals(r))
+					return true;
+			}
+		}
+		return false;
+	}
+
+}

+ 100 - 0
account-server/src/main/java/com/uas/account/core/util/CaptchaUtil.java

@@ -0,0 +1,100 @@
+package com.uas.account.core.util;
+
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ *
+ * @author wangmh
+ * @date 2017/11/2
+ */
+public class CaptchaUtil {
+
+    private CaptchaUtil(){}
+
+    /**
+     * 随机字符字典
+     */
+    private static final char[] CHARS = { '2', '3', '4', '5', '6', '7', '8',
+            '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M',
+            'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
+
+    /**
+     * 随机数
+     */
+    private static Random random = new Random();
+
+    /**
+     * 获取6位随机数
+     */
+    private static String getRandomString()
+    {
+        StringBuffer buffer = new StringBuffer();
+        for(int i = 0; i < 4; i++)
+        {
+            buffer.append(CHARS[random.nextInt(CHARS.length)]);
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * 获取随机数颜色
+     */
+    private static Color getRandomColor()
+    {
+        return new Color(255,255,255);
+    }
+
+    /**
+     * 返回某颜色的反色
+     */
+    private static Color getReverseColor(Color c)
+    {
+        return new Color(255 - c.getRed(), 255 - c.getGreen(),
+                255 - c.getBlue());
+    }
+
+    public static void outputCaptcha(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException
+    {
+
+        response.setContentType("image/jpeg");
+
+        String randomString = getRandomString();
+        request.getSession(true).setAttribute("randomString", randomString);
+
+        int width = 100;
+        int height = 30;
+
+        Color color = getRandomColor();
+        Color reverse = getReverseColor(color);
+
+        BufferedImage bi = new BufferedImage(width, height,
+                BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = bi.createGraphics();
+        g.setFont(new Font(Font.SANS_SERIF, Font.ROMAN_BASELINE, 18));
+        g.setColor(color);
+        g.fillRect(0, 0, width, height);
+        g.setColor(reverse);
+        g.drawString(randomString, 18, 20);
+//        for (int i = 0, n = random.nextInt(100); i < n; i++)
+//        {
+//            g.drawRect(random.nextInt(width), random.nextInt(height), 1, 1);
+//        }
+
+        // 转成JPEG格式
+        ServletOutputStream out = response.getOutputStream();
+        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+        encoder.encode(bi);
+        out.flush();
+    }
+}

+ 69 - 0
account-server/src/main/java/com/uas/account/core/util/ChineseUtils.java

@@ -0,0 +1,69 @@
+package com.uas.account.core.util;
+
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+
+public class ChineseUtils {
+
+	/**
+	 * 汉字转换位汉语拼音首字母,英文字符不变
+	 * 
+	 * @param chinese
+	 *            汉字
+	 * @return 拼音
+	 */
+	public static String converterToFirstSpell(String chinese) {
+		String pinyinName = "";
+		char[] nameChar = chinese.toCharArray();
+		HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
+		defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+		defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+		for (int i = 0; i < nameChar.length; i++) {
+			if (nameChar[i] > 128) {
+				try {
+					pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0].charAt(0);
+				} catch (BadHanyuPinyinOutputFormatCombination e) {
+					e.printStackTrace();
+				} catch (ArrayIndexOutOfBoundsException e) {
+					// 特殊符号
+				}
+			} else {
+				pinyinName += nameChar[i];
+			}
+		}
+		return pinyinName;
+	}
+
+	/**
+	 * 汉字转换位汉语拼音,英文字符不变
+	 * 
+	 * @param chinese
+	 *            汉字
+	 * @return 拼音
+	 */
+	public static String converterToSpell(String chinese) {
+		String pinyinName = "";
+		char[] nameChar = chinese.toCharArray();
+		HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
+		defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+		defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+		for (int i = 0; i < nameChar.length; i++) {
+			if (nameChar[i] > 128) {
+				try {
+					pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0];
+				} catch (BadHanyuPinyinOutputFormatCombination e) {
+					e.printStackTrace();
+				} catch (ArrayIndexOutOfBoundsException e) {
+					// 特殊符号
+				}
+			} else {
+				pinyinName += nameChar[i];
+			}
+		}
+		return pinyinName;
+	}
+
+}

+ 30 - 0
account-server/src/main/java/com/uas/account/core/util/ExecuteUtils.java

@@ -0,0 +1,30 @@
+package com.uas.account.core.util;
+
+import java.util.Collection;
+import java.util.List;
+
+import com.uas.account.core.ICallable;
+import com.uas.account.core.MergeTask;
+
+public class ExecuteUtils {
+
+	public static void asyncExecute(Runnable runnable) {
+		new Thread(runnable).start();
+	}
+
+	/**
+	 * 多任务异步执行,结果以list返回
+	 * 
+	 * @param callable
+	 * @param arguments
+	 * @return
+	 */
+	public static <V, T> List<V> execute(ICallable<V, T> callable, Collection<T> arguments) {
+		MergeTask<V, T> task = new MergeTask<V, T>(callable);
+		for (T arg : arguments) {
+			task.join(arg);
+		}
+		return task.execute();
+	}
+
+}

+ 93 - 0
account-server/src/main/java/com/uas/account/core/util/FastjsonUtils.java

@@ -0,0 +1,93 @@
+package com.uas.account.core.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.parser.Feature;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @see JSON
+ *
+ */
+public class FastjsonUtils {
+
+	public static Feature DEFAULT_PARSER_FEATURE = Feature.DisableCircularReferenceDetect;
+	public static SerializerFeature DEFAULT_SERIAL_FEATURE = SerializerFeature.DisableCircularReferenceDetect;
+
+	/**
+	 * 把JSON文本parse为JSONObject或者JSONArray
+	 * 
+	 * @param text
+	 * @return
+	 */
+	public static Object parse(String text) {
+		return JSON.parse(text, DEFAULT_PARSER_FEATURE);
+	}
+
+	/**
+	 * 把JSON文本parse成JSONObject
+	 * 
+	 * @param text
+	 * @return
+	 */
+	public static final JSONObject parseObject(String text) {
+		return JSON.parseObject(text, DEFAULT_PARSER_FEATURE);
+	}
+
+	/**
+	 * 把JSON文本parse为JavaBean
+	 * 
+	 * @param text
+	 * @param clazz
+	 * @return
+	 */
+	public static final <T> T fromJson(String text, Class<T> clazz) {
+		return JSON.parseObject(text, clazz, DEFAULT_PARSER_FEATURE);
+	}
+
+	/**
+	 * 把JSON文本parse成JSONArray
+	 * 
+	 * @param text
+	 * @return
+	 */
+	public static final JSONArray fromJsonArray(String text) {
+		return JSON.parseArray(text);
+	}
+
+	/**
+	 * 把JSON文本parse成JavaBean集合
+	 * 
+	 * @param text
+	 * @param clazz
+	 * @return
+	 */
+	public static final <T> List<T> fromJsonArray(String text, Class<T> clazz) {
+		return JSON.parseArray(text, clazz);
+	}
+
+	/**
+	 * 将JavaBean序列化为JSON文本
+	 * 
+	 * @param object
+	 * @return
+	 */
+	public static final String toJson(Object object) {
+		return JSON.toJSONString(object, DEFAULT_SERIAL_FEATURE);
+	}
+
+	/**
+	 * 将JavaBean转换为JSONObject或者JSONArray。
+	 * 
+	 * @param javaObject
+	 * @return
+	 */
+	public static final Object toJSON(Object javaObject) {
+		return JSON.toJSON(javaObject);
+	}
+
+}

+ 298 - 0
account-server/src/main/java/com/uas/account/core/util/HttpUtils.java

@@ -0,0 +1,298 @@
+package com.uas.account.core.util;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.http.Consts;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.InputStreamBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.*;
+import java.util.Map.Entry;
+
+public class HttpUtils {
+
+	/**
+	 * 发起POST、PUT请求
+	 * 
+	 * @param params
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response get(String url, Map<String, Object> params) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = null;
+		CloseableHttpResponse response = null;
+		try {
+			StringBuilder buf = new StringBuilder(url);
+			if (params != null && !params.isEmpty()) {
+				if (url.indexOf("?") == -1)
+					buf.append("?");
+				else if (!url.endsWith("&"))
+					buf.append("&");
+				Set<Entry<String, Object>> entrys = params.entrySet();
+				for (Entry<String, Object> entry : entrys) {
+					buf.append(entry.getKey()).append("=").append(URLEncoder.encode(String.valueOf(entry.getValue()), "UTF-8")).append("&");
+				}
+			}
+			request = new HttpPost(buf.toString());
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * 发起POST、PUT请求
+	 *
+	 * @param datas
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response post(String url, Collection<?> datas) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = new HttpPost(url);
+		CloseableHttpResponse response = null;
+		try {
+			if (datas != null && !datas.isEmpty()) {
+				request.setEntity(new StringEntity(FastjsonUtils.toJson(datas), ContentType.create("text/plain", Consts.UTF_8)));
+			}
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * 发起POST、PUT请求
+	 *
+	 * @param params
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response post(String url, Map<String, String> params) throws Exception {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpEntityEnclosingRequestBase request = new HttpPost(url);
+		CloseableHttpResponse response = null;
+		try {
+			List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+			if (params != null && !params.isEmpty()) {
+				Set<Entry<String, String>> entrys = params.entrySet();
+				for (Entry<String, String> entry : entrys) {
+					nvps.add(new BasicNameValuePair(entry.getKey(), URLEncoder.encode(entry.getValue(), "UTF-8")));
+				}
+			}
+			request.setEntity(new UrlEncodedFormEntity(nvps));
+			response = httpClient.execute(request);
+			return Response.getResponse(response);
+		} finally {
+			request.releaseConnection();
+			try {
+				httpClient.close();
+			} catch (IOException e) {
+			}
+			if (response != null) {
+				try {
+					response.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	/**
+	 * http上传文件
+	 * 
+	 * @param url
+	 *            请求地址
+	 * @param filePath
+	 *            附件路径
+	 * @param params
+	 *            参数
+	 * @return
+	 * @throws Exception
+	 * @throws IOException
+	 * @throws IllegalStateException
+	 */
+	public static Response upload(String url, String filePath, Map<String, String> params) throws IllegalStateException, IOException,
+			Exception {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			HttpPost httpPost = new HttpPost(url);
+			FileBody fileBody = new FileBody(new File(filePath));
+			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+			builder.addPart("file", fileBody);
+			if (params != null) {
+				for (String paramKey : params.keySet()) {
+					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
+					builder.addPart(paramKey, body);
+				}
+			}
+			HttpEntity reqEntity = builder.build();
+			httpPost.setEntity(reqEntity);
+			response = httpClient.execute(httpPost);
+			return Response.getResponse(response);
+		} finally {
+			try {
+				if (response != null) {
+					response.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			try {
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * http上传文件
+	 *
+	 * @param url
+	 *            请求地址
+	 * @param multipartFile
+	 *            附件路径
+	 * @param params
+	 *            参数
+	 * @return
+	 * @throws Exception
+	 * @throws IOException
+	 * @throws IllegalStateException
+	 */
+	public static Response upload(String url, MultipartFile multipartFile, Map<String, String> params) throws IllegalStateException, IOException,
+			Exception {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			HttpPost httpPost = new HttpPost(url);
+			InputStreamBody streamBody = new InputStreamBody(multipartFile.getInputStream(),
+				multipartFile.getOriginalFilename());
+			MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+			builder.addPart("file", streamBody);
+			if (params != null) {
+				for (String paramKey : params.keySet()) {
+					StringBody body = new StringBody(params.get(paramKey), ContentType.create("text/plain", Consts.UTF_8));
+					builder.addPart(paramKey, body);
+				}
+			}
+			HttpEntity reqEntity = builder.build();
+			httpPost.setEntity(reqEntity);
+			response = httpClient.execute(httpPost);
+			return Response.getResponse(response);
+		} finally {
+			try {
+				if (response != null) {
+					response.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			try {
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 下载
+	 * 
+	 * @param url
+	 * @return
+	 * @throws ClientProtocolException
+	 * @throws IOException
+	 */
+	public static InputStream download(String url) throws ClientProtocolException, IOException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpGet httpGet = new HttpGet(url);
+		CloseableHttpResponse response = httpClient.execute(httpGet);
+		return response.getEntity().getContent();
+	}
+
+	public static class Response {
+		private int statusCode;
+		private String responseText;
+
+		public int getStatusCode() {
+			return statusCode;
+		}
+
+		public void setStatusCode(int statusCode) {
+			this.statusCode = statusCode;
+		}
+
+		public String getResponseText() {
+			return responseText;
+		}
+
+		public void setResponseText(String responseText) {
+			this.responseText = responseText;
+		}
+
+		public Response() {
+		}
+
+		public Response(HttpResponse response) throws IllegalStateException, IOException, Exception {
+			this.statusCode = response.getStatusLine().getStatusCode();
+			this.responseText = IOUtils.toString(response.getEntity().getContent());
+		}
+
+		public static Response getResponse(HttpResponse response) throws IllegalStateException, IOException, Exception {
+			if (response != null)
+				return new Response(response);
+			return null;
+		}
+	}
+}

+ 44 - 0
account-server/src/main/java/com/uas/account/core/util/QRCodeUtil.java

@@ -0,0 +1,44 @@
+package com.uas.account.core.util;
+
+import java.awt.image.BufferedImage;
+import java.io.OutputStream;
+import java.util.Hashtable;
+
+import javax.imageio.ImageIO;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+
+public class QRCodeUtil {
+
+	private static final String CHARSET = "utf-8";
+	private static final String FORMAT_NAME = "JPG";
+	// 二维码尺寸
+	private static final int QRCODE_SIZE = 129;
+
+	private static BufferedImage createImage(String content) throws Exception {
+		Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
+		hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+		hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
+		hints.put(EncodeHintType.MARGIN, 0);
+		BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
+		int width = bitMatrix.getWidth();
+		int height = bitMatrix.getHeight();
+		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+		for (int x = 0; x < width; x++) {
+			for (int y = 0; y < height; y++) {
+				image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
+			}
+		}
+		return image;
+	}
+
+	public static void encode(String content, OutputStream output) throws Exception {
+		BufferedImage image = createImage(content);
+		ImageIO.write(image, FORMAT_NAME, output);
+	}
+
+}

+ 34 - 0
account-server/src/main/java/com/uas/account/core/util/StringUtil.java

@@ -0,0 +1,34 @@
+package com.uas.account.core.util;
+
+import java.util.Random;
+import java.util.UUID;
+
+public class StringUtil {
+
+	/**
+	 * 产生唯一字符串
+	 * 
+	 * @return
+	 */
+	public static String uuid() {
+		return UUID.randomUUID().toString().replaceAll("\\-", "");
+	}
+
+	public static String substr(String str, int begin, int end) {
+		return str.substring(begin, Math.min(str.length(), end));
+	}
+
+	/**
+	 * 随机数字
+	 * 
+	 * @param len
+	 *            数字长度
+	 * @return
+	 */
+	public static String getRandomNumber(int len) {
+		int max = (int) Math.pow(10, len) - 1;
+		int min = (int) Math.pow(10, len - 1);
+		return String.valueOf(new Random().nextInt(max) % (max - min + 1) + min);
+	}
+
+}

+ 59 - 0
account-server/src/main/java/com/uas/account/dao/AppDao.java

@@ -0,0 +1,59 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import com.uas.account.entity.App;
+import com.uas.account.viewmodel.AppUseView;
+import com.uas.account.viewmodel.AppView;
+
+public interface AppDao {
+
+	App save(App app);
+
+	App findOne(String appId);
+
+	void delete(String appId);
+
+	/**
+	 * 返回应用的ID集合
+	 * 
+	 * @return
+	 */
+	List<String> findAllIDs();
+
+	/**
+	 * 返回指定企业已注册的应用的ID集合
+	 * 
+	 * @return
+	 */
+	List<String> findAllIDsBySpace(long spaceId);
+
+	/**
+	 * 返回指定用户已注册的应用的ID集合
+	 * 
+	 * @return
+	 */
+	List<String> findAllIDsByUser(long userId);
+
+	/**
+	 * 查找全部
+	 * 
+	 * @return
+	 */
+	List<App> findAll();
+
+	/**
+	 * 查找全部(简化视图1)
+	 * 
+	 * @return
+	 */
+	List<AppView> findAllView();
+
+	/**
+	 * 查找全部可注册应用(简化视图2)
+	 * 
+	 * @return
+	 */
+	List<AppUseView> findAllPublicUseView();
+
+}

+ 116 - 0
account-server/src/main/java/com/uas/account/dao/AppDaoImpl.java

@@ -0,0 +1,116 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Repository;
+
+import com.uas.account.entity.App;
+import com.uas.account.entity.App.Scope;
+import com.uas.account.viewmodel.AppUseView;
+import com.uas.account.viewmodel.AppView;
+
+@Repository
+public class AppDaoImpl extends BaseDao implements AppDao {
+
+	@Override
+	public App save(App app) {
+		int count = count("select count(1) from ac$apps where uid_=?", app.getUid());
+		if (count == 0) {
+			jdbcTemplate.update(
+					"insert into ac$apps(uid_,publicKey,description,backSpaceUrl,backUserUrl,backUserPwdUrl,loginUrl,logoutUrl,encryFormat,copyApps,userControl,usCount,scope_,defaultUse,dialectEnable,homePage,personalEnable,backChangeAdminUrl) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+					app.getUid(), app.getPublicKey(), app.getDescription(), app.getBackSpaceUrl(), app.getBackUserUrl(),
+					app.getBackUserPwdUrl(), app.getLoginUrl(), app.getLogoutUrl(), app.getEncryFormat(), app.getCopyApps(),
+					app.getUserControl(), app.getUsCount(), app.getScope(), app.getDefaultUse(), app.getDialectEnable(),
+					app.getHomePage(), app.getPersonalEnable(), app.getBackChangeAdminUrl());
+		} else {
+			jdbcTemplate.update(
+					"update ac$apps set description=?,publicKey=?,backSpaceUrl=?,backUserUrl=?,backUserPwdUrl=?,loginUrl=?,logoutUrl=?,encryFormat=?,copyApps=?,userControl=?,usCount=?,scope_=?,defaultUse=?,dialectEnable=?,homePage=?,personalEnable=?,backChangeAdminUrl=? where uid_=?",
+					app.getDescription(), app.getPublicKey(), app.getBackSpaceUrl(), app.getBackUserUrl(),
+					app.getBackUserPwdUrl(), app.getLoginUrl(), app.getLogoutUrl(), app.getEncryFormat(), app.getCopyApps(),
+					app.getUserControl(), app.getUsCount(), app.getScope(), app.getDefaultUse(), app.getDialectEnable(),
+					app.getHomePage(), app.getPersonalEnable(), app.getBackChangeAdminUrl(), app.getUid());
+		}
+		return app;
+	}
+
+	@Override
+	public App findOne(String appId) {
+		try {
+			return jdbcTemplate.queryForObject(
+					"select uid_ as \"UID\",publicKey,description,backSpaceUrl,backUserUrl,backUserPwdUrl,loginUrl,logoutUrl,encryFormat,copyApps,userControl,usCount,scope_ as \"SCOPE\",defaultUse,dialectEnable,homePage,personalEnable,backChangeAdminUrl,backpartnerurl from ac$apps where uid_=?",
+					new BeanPropertyRowMapper<App>(App.class), appId);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<String> findAllIDs() {
+		try {
+			return jdbcTemplate.queryForList("select distinct uid_ from ac$apps order by uid_", String.class);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<String> findAllIDsBySpace(long spaceId) {
+		try {
+			return jdbcTemplate.queryForList("select distinct appId from ac$userspaces where id=? order by appId",
+					String.class, spaceId);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<String> findAllIDsByUser(long userId) {
+		try {
+			return jdbcTemplate.queryForList("select distinct appId from ac$users where id=? order by appId",
+					String.class, userId);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<App> findAll() {
+		try {
+			return jdbcTemplate.query(
+					"select uid_ as \"UID\",publicKey,description,backSpaceUrl,backUserUrl,backUserPwdUrl,encryFormat,copyApps,userControl,usCount,scope_ as \"SCOPE\",defaultUse,dialectEnable,homePage,personalEnable,backChangeAdminUrl,loginUrl,logoutUrl from ac$apps order by uid_",
+					new BeanPropertyRowMapper<App>(App.class));
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<AppView> findAllView() {
+		try {
+			return jdbcTemplate.query("select uid_ as \"UID\",description,usCount from ac$apps order by uid_",
+					new BeanPropertyRowMapper<AppView>(AppView.class));
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void delete(String appId) {
+		jdbcTemplate.update("delete from ac$apps where uid_=?", appId);
+	}
+
+	@Override
+	public List<AppUseView> findAllPublicUseView() {
+		try {
+			return jdbcTemplate.query(
+					"select uid_ as \"UID\",description,defaultUse from ac$apps where (scope_=? or scope_=?) and userControl is null and backSpaceUrl is not null order by usCount,uid_",
+					new BeanPropertyRowMapper<AppUseView>(AppUseView.class), Scope.PUBLIC.name(),
+					Scope.PROTECTED.name());
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+}

+ 22 - 0
account-server/src/main/java/com/uas/account/dao/AssetDao.java

@@ -0,0 +1,22 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.Asset;
+
+public interface AssetDao {
+
+	Asset save(Asset asset);
+
+	Asset findOne(Long id);
+
+	int countByApp(String appId);
+
+	List<Asset> findByApp(String appId);
+
+	void delete(Asset asset);
+
+	Page<Asset> findAll(String appId, int pageNumber, int pageSize);
+
+}

+ 90 - 0
account-server/src/main/java/com/uas/account/dao/AssetDaoImpl.java

@@ -0,0 +1,90 @@
+package com.uas.account.dao;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Repository;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.account.core.Page;
+import com.uas.account.entity.Asset;
+
+@Repository
+public class AssetDaoImpl extends BaseDao implements AssetDao {
+
+	@Override
+	public Asset save(Asset asset) {
+		if (asset.getId() == null) {
+			asset.setId(generateId("ac$asset_seq"));
+			jdbcTemplate
+					.update("insert into ac$assets(id,appId,idx,url,background,imgLink,title,subTitle,color,reserveColor,btns) values (?,?,?,?,?,?,?,?,?,?,?)",
+							asset.getId(), asset.getAppId(), asset.getIdx(), asset.getUrl(), asset.getBackground(), asset.getImgLink(),
+							asset.getTitle(), asset.getSubTitle(), asset.getColor(), asset.getReserveColor(), asset.getBtns());
+		} else {
+			jdbcTemplate
+					.update("update ac$assets set appId=?,idx=?,url=?,background=?,imgLink=?,title=?,subTitle=?,color=?,reserveColor=?,btns=? where id=?",
+							asset.getAppId(), asset.getIdx(), asset.getUrl(), asset.getBackground(), asset.getImgLink(), asset.getTitle(),
+							asset.getSubTitle(), asset.getColor(), asset.getReserveColor(), asset.getBtns(), asset.getId());
+		}
+		return asset;
+	}
+
+	@Override
+	public List<Asset> findByApp(String appId) {
+		try {
+			return jdbcTemplate.query("select * from ac$assets where appId=? order by idx", new BeanPropertyRowMapper<Asset>(Asset.class),
+					appId);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void delete(Asset asset) {
+		jdbcTemplate.update("delete from ac$assets where id=?", asset.getId());
+		jdbcTemplate.update("update ac$assets set idx=idx-1 where idx>? and appId=?", asset.getIdx(), asset.getAppId());
+	}
+
+	@Override
+	public Page<Asset> findAll(String appId, int pageNumber, int pageSize) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$assets where 1=1");
+		StringBuffer querySql = new StringBuffer("select * from (select t.*,rownum r from (select * from ac$assets where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(appId)) {
+			countSql.append(" and appId=?");
+			querySql.append(" and appId=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = appId;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by appId,idx) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<Asset> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), new BeanPropertyRowMapper<Asset>(Asset.class), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<Asset>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public int countByApp(String appId) {
+		return count("select count(1) from ac$assets where appId=?", appId);
+	}
+
+	@Override
+	public Asset findOne(Long id) {
+		try {
+			return jdbcTemplate.queryForObject("select * from ac$assets where id=?", new BeanPropertyRowMapper<Asset>(Asset.class), id);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+}

+ 18 - 0
account-server/src/main/java/com/uas/account/dao/BaseDao.java

@@ -0,0 +1,18 @@
+package com.uas.account.dao;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+public class BaseDao {
+
+	@Autowired
+	protected JdbcTemplate jdbcTemplate;
+
+	protected int count(String sql, Object... args) {
+		return jdbcTemplate.queryForObject(!sql.startsWith("select") ? ("select count(1) " + sql) : sql, Integer.class, args);
+	}
+
+	protected Long generateId(String sequenceName) {
+		return jdbcTemplate.queryForObject("select " + sequenceName + ".nextval from dual", Long.class);
+	}
+}

+ 43 - 0
account-server/src/main/java/com/uas/account/dao/ChangeAdminDao.java

@@ -0,0 +1,43 @@
+package com.uas.account.dao;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.ChangeAdminDetail;
+
+public interface ChangeAdminDao {
+
+	/**
+	 * 存储更换管理员申请详细信息
+	 * 
+	 * @param changeAdminDetail
+	 * @return
+	 */
+	ChangeAdminDetail save(ChangeAdminDetail changeAdminDetail);
+
+	/**
+	 * 从ac$changeadmin表中取出所有信息
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAll(Integer pageNumber, Integer pageSize, String name, String businessCode);
+
+	/**
+	 * 按auditStatus分类查询信息
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param auditStatus
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAll(Integer pageNumber, Integer pageSize, Integer auditStatus, String name,
+			String businessCode, String userName);
+
+	/**
+	 * 通过businessCode查询详细信息
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	ChangeAdminDetail findByBusinessCode(String businessCode);
+}

+ 146 - 0
account-server/src/main/java/com/uas/account/dao/ChangeAdminDaoImpl.java

@@ -0,0 +1,146 @@
+package com.uas.account.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Repository;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.account.core.Page;
+import com.uas.account.entity.ChangeAdminDetail;
+
+@Repository
+public class ChangeAdminDaoImpl extends BaseDao implements ChangeAdminDao {
+
+	/**
+	 * 将数据存入mange中ac$changeadmin表中
+	 */
+	@Override
+	public ChangeAdminDetail save(ChangeAdminDetail changeAdminDetail) {
+		int count = count("from ac$changeadmin where ch_bussinesscode=?", changeAdminDetail.getBusinessCode());
+		changeAdminDetail.setId(generateId("AC$CHANGEADMIN_SEQ"));
+		if (count == 0) {
+			jdbcTemplate.update(
+					"insert into ac$changeadmin(ch_id,ch_enname,ch_bussinesscode,ch_bussinesscodeimg,ch_adminname,ch_admintel,ch_adminemail,ch_auditstatus,ch_date,ch_appid,ch_method) values (?,?,?,?,?,?,?,?,?,?,?)",
+					changeAdminDetail.getId(), changeAdminDetail.getEnName().trim(),
+					changeAdminDetail.getBusinessCode().trim(), changeAdminDetail.getBusinessCodeImage(),
+					changeAdminDetail.getAdminName().trim(), changeAdminDetail.getAdminTel().trim(),
+					changeAdminDetail.getAdminEmail().trim(), changeAdminDetail.getAuditStatus(),
+					changeAdminDetail.getEnDate(), changeAdminDetail.getAppId(), changeAdminDetail.getMethod());
+		} else {
+			jdbcTemplate.update(
+					"update ac$changeadmin set ch_enname=?,ch_bussinesscodeimg=?,ch_adminname=?,ch_admintel=?,ch_adminemail=?,ch_auditstatus=?,ch_auditresult=?,ch_date=?,ch_appid=?,ch_method=? where ch_bussinesscode=?",
+					changeAdminDetail.getEnName().trim(), changeAdminDetail.getBusinessCodeImage(),
+					changeAdminDetail.getAdminName().trim(), changeAdminDetail.getAdminTel().trim(),
+					changeAdminDetail.getAdminEmail().trim(), changeAdminDetail.getAuditStatus(),
+					changeAdminDetail.getAuditResult(), changeAdminDetail.getEnDate(), changeAdminDetail.getAppId(),
+					changeAdminDetail.getMethod(), changeAdminDetail.getBusinessCode().trim());
+		}
+		return changeAdminDetail;
+	}
+
+	private RowMapper<ChangeAdminDetail> getRowMapper() {
+		return new RowMapper<ChangeAdminDetail>() {
+			@Override
+			public ChangeAdminDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
+				ChangeAdminDetail detail = new ChangeAdminDetail();
+				detail.setAdminName(rs.getString("CH_ADMINNAME"));
+				detail.setAdminEmail(rs.getString("CH_ADMINEMAIL"));
+				detail.setAdminTel(rs.getString("CH_ADMINTEL"));
+				detail.setEnName(rs.getString("CH_ENNAME"));
+				detail.setBusinessCode(rs.getString("CH_BUSSINESSCODE"));
+				detail.setBusinessCodeImage(rs.getString("CH_BUSSINESSCODEIMG"));
+				detail.setAuditStatus(rs.getInt("CH_AUDITSTATUS"));
+				detail.setAuditResult(rs.getString("CH_AUDITRESULT"));
+				detail.setAppId(rs.getString("CH_APPID"));
+				Date date = rs.getDate("ch_date");
+				if (date != null)
+					detail.setEnDate(date);
+				detail.setMethod(rs.getString("ch_method"));
+				return detail;
+			}
+
+		};
+	}
+
+	/**
+	 * 查询ac$changeadmin所有信息
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAll(Integer pageNumber, Integer pageSize, String name, String businessCode) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$changeadmin where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select * from ac$changeadmin where 1=1");
+		Object[] args = new Object[] {};
+		int total = count(countSql.toString(), args);
+		querySql.append(" order by ch_id) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<ChangeAdminDetail> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), getRowMapper(), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<ChangeAdminDetail>(pageNumber, pageSize, content, total);
+	}
+
+	/**
+	 * 按auditStatus分类查找信息
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAll(Integer pageNumber, Integer pageSize, Integer auditStatus, String name,
+			String businessCode, String userName) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$changeadmin where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select * from ac$changeadmin where 1=1");
+		Object[] args = new Object[] {};
+		if (null != auditStatus) {
+			countSql.append(" and CH_AUDITSTATUS=?");
+			querySql.append(" and CH_AUDITSTATUS=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = auditStatus;
+		}
+		if (!StringUtils.isEmpty(businessCode)) {
+			countSql.append("and upper(ch_bussinesscode) = upper('").append(businessCode).append("')");
+			querySql.append("and upper(ch_bussinesscode) = upper('").append(businessCode).append("')");
+		}
+		if (!StringUtils.isEmpty(name)) {
+			countSql.append("and upper(ch_enname) like upper('%").append(name).append("%')");
+			querySql.append("and upper(ch_enname) like upper('%").append(name).append("%')");
+		}
+		if (!StringUtils.isEmpty(userName)) {
+			countSql.append("and upper(ch_adminname) = upper('").append(userName).append("')");
+			querySql.append("and upper(ch_adminname) = upper('").append(userName).append("')");
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by ch_id) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<ChangeAdminDetail> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), getRowMapper(), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<ChangeAdminDetail>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public ChangeAdminDetail findByBusinessCode(String businessCode) {
+		try {
+			return jdbcTemplate.queryForObject("select * from ac$changeadmin where ch_bussinessCode=?", getRowMapper(),
+					businessCode);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+}

+ 11 - 0
account-server/src/main/java/com/uas/account/dao/LogDao.java

@@ -0,0 +1,11 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import com.uas.account.entity.Log;
+
+public interface LogDao {
+
+	void save(List<Log> logs);
+
+}

+ 39 - 0
account-server/src/main/java/com/uas/account/dao/LogDaoImpl.java

@@ -0,0 +1,39 @@
+package com.uas.account.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.List;
+
+import org.springframework.jdbc.core.BatchPreparedStatementSetter;
+import org.springframework.stereotype.Repository;
+
+import com.uas.account.entity.Log;
+
+@Repository
+public class LogDaoImpl extends BaseDao implements LogDao {
+
+	@Override
+	public void save(final List<Log> logs) {
+		jdbcTemplate.batchUpdate("insert into ac$log(name,logDate,logLevel,msg,detailMsg,key) values (?,?,?,?,?,?)",
+				new BatchPreparedStatementSetter() {
+
+					@Override
+					public void setValues(PreparedStatement ps, int i) throws SQLException {
+						Log log = logs.get(i);
+						ps.setObject(1, log.getName());
+						ps.setObject(2, new Timestamp(log.getLogDate().getTime()));
+						ps.setObject(3, log.getLevel());
+						ps.setObject(4, log.getMsg());
+						ps.setObject(5, log.getDetailMsg());
+						ps.setObject(6, log.getKey());
+					}
+
+					@Override
+					public int getBatchSize() {
+						return logs.size();
+					}
+				});
+	}
+
+}

+ 124 - 0
account-server/src/main/java/com/uas/account/dao/PartnershipRecordDao.java

@@ -0,0 +1,124 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.InvitationRecord;
+import com.uas.account.entity.PartnershipRecord;
+
+
+public interface PartnershipRecordDao {
+
+	PartnershipRecord save(PartnershipRecord record);
+
+	/**
+	 * 分页查询所有已发出的申请
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param name
+	 * @param businessCode
+	 * @param status
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllSendView(int pageNumber, String businessCode, String custUserName, int pageSize,
+			String name, String custuid, String custusercode, Integer status);
+
+	/**
+	 * 分页查询所有已收到的申请
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param name
+	 * @param businessCode
+	 * @param status
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllReceivedView(int pageNumber, String businessCode, String custUserName, int pageSize,
+			String name, String venduid, Integer status);
+
+	/**
+	 * 通过id查找详情
+	 * 
+	 * @param id
+	 * @return
+	 */
+	PartnershipRecord findById(Long id);
+
+	/**
+	 * 通过申请企业的uid和客户的uid查询信息
+	 * 
+	 * @param custuid
+	 * @param venduid
+	 * @return
+	 */
+	PartnershipRecord findByCustUIDAndVendUID(String custuid, String venduid);
+
+	/**
+	 * 发出请求的数量
+	 * 
+	 * @return
+	 */
+	ModelMap getSendRequestCount(String custuid);
+
+	/**
+	 * 收到请求的数量
+	 * 
+	 * @return
+	 */
+	ModelMap getReceivedRequestCount(String venduid);
+
+	/**
+	 * 发出的总数(企业)
+	 * 
+	 * @param custusercode
+	 * @param custuid
+	 * @return
+	 */
+	int getAllSendCount(String custuid);
+
+	/**
+	 * 收到的总数(企业)
+	 * 
+	 * @param venduid
+	 * @return
+	 */
+	int getAllReceivedCount(String venduid);
+
+	/**
+	 * 通过营业执照和状态查询当前企业的列表
+	 * 
+	 * @param custuid
+	 * @param value
+	 * @return
+	 */
+	public Page<PartnershipRecord> findBySpaceUidAndStatusCode(String businessCode, Integer status, String keyword,
+			int pageNumber, int pageSize);
+
+	/**
+	 * 获取收到的待处理请求
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	int getRequestTodo(String businessCode);
+
+	Page<PartnershipRecord> findBySpaceUidAndStatusCodeFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword,  List<Long> partnerUUs, int pageNumber, int pageSize);
+
+	/**
+	 * 记录邀请注册记录
+	 * 
+	 * @param record
+	 */
+	void saveInvitation(InvitationRecord record);
+
+	/**
+	 * 通过当前注册企业名称查询邀请记录进行添加合作伙伴操作
+	 * 
+	 * @param vendname
+	 * @return
+	 */
+	List<InvitationRecord> findByVendname(String vendname);
+}

+ 407 - 0
account-server/src/main/java/com/uas/account/dao/PartnershipRecordDaoImpl.java

@@ -0,0 +1,407 @@
+package com.uas.account.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.ResultSetExtractor;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.stereotype.Repository;
+import org.springframework.ui.ModelMap;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.account.core.Page;
+import com.uas.account.entity.InvitationRecord;
+import com.uas.account.entity.PartnershipRecord;
+
+@Repository
+public class PartnershipRecordDaoImpl extends BaseDao implements PartnershipRecordDao {
+
+    @Override
+    public PartnershipRecord save(PartnershipRecord record) {
+        if (record.getId() == null && !StringUtils.isEmpty(record.getCustUID())) {
+            if (!StringUtils.isEmpty(record.getVendUID())) {
+                Long id = jdbcTemplate.queryForObject(
+                        "select min(id) from partnershiprecord where custuid=? and venduid=?", Long.class,
+                        record.getCustUID(), record.getVendUID());
+                record.setId(id);
+            }
+        }
+        if (record.getId() == null) {
+            record.setId(generateId("partnership_seq"));
+            jdbcTemplate.update(
+					"insert into partnershiprecord(id,appid,requestdate,custname,custuid,custusername,custusercode,custusertel,custuseremail,vendname,venduid,statuscode,status,method) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+                    record.getId(), record.getAppId(), record.getRequestDate(), record.getCustName(),
+                    record.getCustUID(), record.getCustUserName(), record.getCustUserCode(), record.getCustUserTel(),
+                    record.getCustUserEmail(), record.getVendName(), record.getVendUID(), record.getStatusCode(),
+					record.getStatus(), record.getMethod());
+        } else {
+            jdbcTemplate.update(
+					"update partnershiprecord set appid=?,requestdate=?,custusername=?,custusercode=?,custusertel=?,custuseremail=?,statuscode=?,status=?,vendusername=?,vendusertel=?,venduseremail=?,vendusercode=?,reason=?,method=? where id=?",
+                    record.getAppId(), record.getRequestDate(), record.getCustUserName(), record.getCustUserCode(),
+                    record.getCustUserTel(), record.getCustUserEmail(), record.getStatusCode(), record.getStatus(),
+                    record.getVendUserName(), record.getVendUserTel(), record.getVendUserEmail(),
+					record.getVendUserCode(), record.getReason(), record.getMethod(), record.getId());
+        }
+        return record;
+    }
+
+    @Override
+    public Page<PartnershipRecord> findAllSendView(int pageNumber, String businessCode, String custUserName,
+                                                   int pageSize, String name, String custuid, String custusercode, Integer status) {
+        StringBuffer countSql = new StringBuffer("select count(1) from partnershiprecord where 1=1");
+        StringBuffer querySql = new StringBuffer(
+                "select * from (select t.*,rownum r from (select * from partnershiprecord where 1=1");
+        Object[] args = new Object[]{};
+        if (null != custuid) {
+            countSql.append("and custuid=?");
+            querySql.append("and custuid=?");
+            args = Arrays.copyOf(args, args.length + 1);
+            args[args.length - 1] = custuid;
+        }
+        if (null != custusercode) {
+            countSql.append("and custusercode=?");
+            querySql.append("and custusercode=?");
+            args = Arrays.copyOf(args, args.length + 1);
+            args[args.length - 1] = custusercode;
+        }
+        if (null != status) {
+            countSql.append(" and statuscode=?");
+            querySql.append(" and statuscode=?");
+            args = Arrays.copyOf(args, args.length + 1);
+            args[args.length - 1] = status;
+        }
+        if (!StringUtils.isEmpty(name)) {
+            countSql.append(" and upper(vendname) like upper('%").append(name).append("%')");
+            querySql.append(" and upper(vendname) like upper('%").append(name).append("%')");
+        }
+        if (!StringUtils.isEmpty(custUserName)) {
+            countSql.append(" and custusername like '%").append(custUserName).append("%'");
+            querySql.append(" and custusername like '%").append(custUserName).append("%'");
+        }
+        if (!StringUtils.isEmpty(businessCode)) {
+            countSql.append(" and venduid = '").append(businessCode).append("'");
+            querySql.append(" and venduid = '").append(businessCode).append("'");
+        }
+        int total = count(countSql.toString(), args);
+
+        querySql.append(" order by id desc,vendname) t where rownum <= ?) where r >= ?");
+        args = Arrays.copyOf(args, args.length + 2);
+        args[args.length - 2] = pageNumber * pageSize;
+        args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+        List<PartnershipRecord> content = null;
+        try {
+            content = jdbcTemplate.query(querySql.toString(),
+                    new BeanPropertyRowMapper<PartnershipRecord>(PartnershipRecord.class), args);
+        } catch (EmptyResultDataAccessException e) {
+
+        }
+        return new Page<PartnershipRecord>(pageNumber, pageSize, content, total);
+    }
+
+    @Override
+    public Page<PartnershipRecord> findAllReceivedView(int pageNumber, String businessCode, String custUserName,
+                                                       int pageSize, String name, String venduid, Integer status) {
+        StringBuffer countSql = new StringBuffer("select count(1) from partnershiprecord where 1=1");
+        StringBuffer querySql = new StringBuffer(
+                "select * from (select t.*,rownum r from (select * from partnershiprecord where 1=1");
+        Object[] args = new Object[]{};
+        if (null != venduid) {
+            countSql.append("and venduid=?");
+            querySql.append("and venduid=?");
+            args = Arrays.copyOf(args, args.length + 1);
+            args[args.length - 1] = venduid;
+        }
+        if (null != status) {
+            countSql.append(" and statuscode=?");
+            querySql.append(" and statuscode=?");
+            args = Arrays.copyOf(args, args.length + 1);
+            args[args.length - 1] = status;
+        }
+        if (!StringUtils.isEmpty(name)) {
+            countSql.append(" and upper(custname) like upper('%").append(name).append("%')");
+            querySql.append(" and upper(custname) like upper('%").append(name).append("%')");
+        }
+        if (!StringUtils.isEmpty(custUserName)) {
+            countSql.append(" and custusername like '%").append(custUserName).append("%'");
+            querySql.append(" and custusername like '%").append(custUserName).append("%'");
+        }
+        if (!StringUtils.isEmpty(businessCode)) {
+            countSql.append(" and venduid = '").append(businessCode).append("'");
+            querySql.append(" and venduid = '").append(businessCode).append("'");
+        }
+        int total = count(countSql.toString(), args);
+
+        querySql.append(" order by id desc,vendname) t where rownum <= ?) where r >= ?");
+        args = Arrays.copyOf(args, args.length + 2);
+        args[args.length - 2] = pageNumber * pageSize;
+        args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+        List<PartnershipRecord> content = null;
+        try {
+            content = jdbcTemplate.query(querySql.toString(),
+                    new BeanPropertyRowMapper<PartnershipRecord>(PartnershipRecord.class), args);
+        } catch (EmptyResultDataAccessException e) {
+
+        }
+        return new Page<PartnershipRecord>(pageNumber, pageSize, content, total);
+    }
+
+    @Override
+    public PartnershipRecord findById(Long id) {
+        try {
+            return jdbcTemplate.queryForObject("select * from partnershiprecord where id=?", getRowMapper(), id);
+        } catch (EmptyResultDataAccessException e) {
+            return null;
+        }
+    }
+
+    private RowMapper<PartnershipRecord> getRowMapper() {
+        return new RowMapper<PartnershipRecord>() {
+
+            @Override
+            public PartnershipRecord mapRow(ResultSet rs, int rowNum) throws SQLException {
+                PartnershipRecord partner = new PartnershipRecord();
+                partner.setId(rs.getLong("id"));
+                partner.setAppId(rs.getString("appid"));
+                partner.setCustName(rs.getString("custname"));
+                partner.setCustUID(rs.getString("custuid"));
+                partner.setCustUserName(rs.getString("custusername"));
+                partner.setCustUserCode(rs.getString("custusercode"));
+                partner.setCustUserEmail(rs.getString("custuseremail"));
+                partner.setCustUserTel(rs.getString("custusertel"));
+                partner.setRequestDate(rs.getDate("requestdate"));
+                partner.setStatus(rs.getString("status"));
+                partner.setStatusCode(rs.getInt("statuscode"));
+                partner.setVendUID(rs.getString("venduid"));
+                partner.setVendName(rs.getString("vendname"));
+                partner.setVendUserCode(rs.getString("vendusercode"));
+                partner.setVendUserName(rs.getString("vendusername"));
+                partner.setOperateDate(rs.getDate("operatedate"));
+                partner.setReason(rs.getString("reason"));
+                partner.setVendUserTel(rs.getString("vendusertel"));
+                partner.setVendUserEmail(rs.getString("venduseremail"));
+                return partner;
+            }
+
+        };
+    }
+
+    @Override
+    public PartnershipRecord findByCustUIDAndVendUID(String custuid, String venduid) {
+        try {
+            return jdbcTemplate
+                    .queryForObject(
+                            "select * from partnershiprecord where custuid = '" + custuid + "' and venduid = '" + venduid + "'",
+                            new BeanPropertyRowMapper<PartnershipRecord>(PartnershipRecord.class));
+        } catch (EmptyResultDataAccessException e) {
+            return null;
+        }
+    }
+
+    @Override
+    public ModelMap getSendRequestCount(String custuid) {
+        return jdbcTemplate.query("select status,count(1) c from partnershiprecord where custuid = '" + custuid
+                        + "' group by status order by count(1) desc",
+                new ResultSetExtractor<ModelMap>() {
+
+                    @Override
+                    public ModelMap extractData(ResultSet rs) throws SQLException, DataAccessException {
+                        ModelMap map = new ModelMap();
+                        while (rs.next()) {
+                            map.put(rs.getString(1), rs.getInt(2));
+                        }
+                        return map;
+                    }
+
+                });
+    }
+
+    @Override
+    public ModelMap getReceivedRequestCount(String venduid) {
+        return jdbcTemplate.query("select status,count(1) c from partnershiprecord where venduid = '" + venduid
+                + "' group by status order by count(1) desc", new ResultSetExtractor<ModelMap>() {
+
+            @Override
+            public ModelMap extractData(ResultSet rs) throws SQLException, DataAccessException {
+                ModelMap map = new ModelMap();
+                while (rs.next()) {
+                    map.put(rs.getString(1), rs.getInt(2));
+                }
+                return map;
+            }
+
+        });
+    }
+
+    @Override
+    public int getAllSendCount(String custuid) {
+        return count("from partnershiprecord where custuid = ?", custuid);
+    }
+
+    @Override
+    public int getAllReceivedCount(String venduid) {
+        return count("from partnershiprecord where venduid = ?", venduid);
+    }
+
+    @Override
+    public Page<PartnershipRecord> findBySpaceUidAndStatusCode(String businessCode, Integer statusCode, String keyword,
+                                                               int pageNumber, int pageSize) {
+        StringBuffer countSql = new StringBuffer("select count(1) from v$partnershiprecord where 1=1");
+        StringBuffer querySql = new StringBuffer(
+                "select * from (select t.*,rownum r from (select * from v$partnershiprecord where 1=1");
+        Object[] args = new Object[]{};
+        if (!StringUtils.isEmpty(businessCode) && !StringUtils.isEmpty(keyword)) {
+            // ((custuid = '56749203' and (vendname like '%胜芳%' or venduid like '%123%')) or (venduid = '56749203' and (custname like '%胜芳%' or custuid like '%123%')))
+            querySql.append(" and ((venduid = '").append(businessCode).append("' and (custname like '%").append(keyword)
+                    .append("%' or custuid like '%").append(keyword).append("%' or custadminname like '%").append(keyword)
+                    .append("%' or custadmintel like '%").append(keyword).append("%' or custadminemail like '%").append(keyword)
+                    .append("%' or custprofession like '%").append(keyword).append("%' or custtags like '%").append(keyword)
+                    .append("%' or custuu like '%").append(keyword).append("%' or custaddress like '%").append(keyword)
+                    .append(" %')) or ((custuid = '").append(businessCode).append("' and (vendname like '%").append(keyword)
+                    .append("%' or venduid like '%").append(keyword).append("%' or vendadminname like '%").append(keyword)
+                    .append("%' or vendadmintel like '%").append(keyword).append("%' or vendadminemail like '%").append(keyword)
+                    .append("%' or vendprofession like '%").append(keyword).append("%' or vendtags like '%").append(keyword)
+                    .append("%' or venduu like '%").append(keyword).append("%' or vendaddress like '%").append(keyword).append("%'))))");
+
+            countSql.append(" and ((venduid = '").append(businessCode).append("' and (custname like '%").append(keyword)
+                    .append("%' or custuid like '%").append(keyword).append("%' or custadminname like '%").append(keyword)
+                    .append("%' or custadmintel like '%").append(keyword).append("%' or custadminemail like '%").append(keyword)
+                    .append("%' or custprofession like '%").append(keyword).append("%' or custtags like '%").append(keyword)
+                    .append("%' or custuu like '%").append(keyword).append("%' or custaddress like '%").append(keyword)
+                    .append(" %')) or ((custuid = '").append(businessCode).append("' and (vendname like '%").append(keyword)
+                    .append("%' or venduid like '%").append(keyword).append("%' or vendadminname like '%").append(keyword)
+                    .append("%' or vendadmintel like '%").append(keyword).append("%' or vendadminemail like '%").append(keyword)
+                    .append("%' or vendprofession like '%").append(keyword).append("%' or vendtags like '%").append(keyword)
+                    .append("%' or venduu like '%").append(keyword).append("%' or vendaddress like '%").append(keyword).append("%'))))");
+        }
+        if (!StringUtils.isEmpty(businessCode) && StringUtils.isEmpty(keyword)) {
+            querySql.append(" and (venduid = '").append(businessCode).append("' or custuid='").append(businessCode)
+                    .append("')");
+            countSql.append(" and (venduid = '").append(businessCode).append("' or custuid='").append(businessCode)
+                    .append("')");
+        }
+        if (statusCode != null) {
+            countSql.append(" and statusCode=").append(statusCode);
+            querySql.append(" and statusCode=").append(statusCode);
+        }
+        int total = count(countSql.toString(), args);
+        // 311申请中, 310 已拒绝, 313 已激活 需要按申请中、已激活、已拒绝排序,所以用replace将311替换成333再排序。
+        querySql.append(" order by translate(statuscode, 311, 333) desc,id desc,vendname) t where rownum <= ?) where r >= ?");
+        args = Arrays.copyOf(args, args.length + 2);
+        args[args.length - 2] = pageNumber * pageSize;
+        args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+        List<PartnershipRecord> content = null;
+        try {
+            content = jdbcTemplate.query(querySql.toString(),
+                    new BeanPropertyRowMapper<PartnershipRecord>(PartnershipRecord.class), args);
+        } catch (EmptyResultDataAccessException e) {
+
+        }
+        return new Page<PartnershipRecord>(pageNumber, pageSize, content, total);
+    }
+
+    @Override
+    public Page<PartnershipRecord> findBySpaceUidAndStatusCodeFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword,
+                                                                                 List<Long> partnerUUs, int pageNumber, int pageSize) {
+        StringBuffer countSql = new StringBuffer("select * from partnershiprecord where 1=1");
+        StringBuffer querySql = new StringBuffer(
+                "select * from (select t.*,rownum r from (select * from partnershiprecord where 1=1");
+        Object[] args = new Object[]{};
+        if (!StringUtils.isEmpty(businessCode) && !StringUtils.isEmpty(keyword)) {
+            // ((custuid = '56749203' and (vendname like '%胜芳%' or venduid like '%123%')) or (venduid = '56749203' and (custname like '%胜芳%' or custuid like '%123%')))
+            querySql.append(" and ((venduid = '").append(businessCode).append("' and (custname like '%").append(keyword)
+                    .append("%' or custuid like '%").append(keyword).append("%' or custusername like '%").append(keyword)
+                    .append("%' or vendusername like '%").append(keyword).append("%')) or (custuid='").append(businessCode)
+                    .append("' and (vendname like '%").append(keyword).append("%' or venduid like '%").append(keyword)
+                    .append("%' or custusername like '%").append(keyword).append("%' or vendusername like '%").append(keyword)
+                    .append("%')))");
+            countSql.append(" and ((venduid = '").append(businessCode).append("' and (custname like '%").append(keyword)
+                    .append("%' or custuid like '%").append(keyword).append("%' or custusername like '%").append(keyword)
+                    .append("%' or vendusername like '%").append(keyword).append("%')) or (custuid='").append(businessCode)
+                    .append("' and (vendname like '%").append(keyword).append("%' or venduid like '%").append(keyword)
+                    .append("%' or custusername like '%").append(keyword).append("%' or vendusername like '%").append(keyword)
+                    .append("%')))");
+        }
+        if (!StringUtils.isEmpty(businessCode) && StringUtils.isEmpty(keyword)) {
+            querySql.append(" and (venduid = '").append(businessCode).append("' or custuid='").append(businessCode)
+                    .append("')");
+            countSql.append(" and (venduid = '").append(businessCode).append("' or custuid='").append(businessCode)
+                    .append("')");
+        }
+        if (statusCode != null) {
+            countSql.append(" and statuscode=").append(statusCode);
+            querySql.append(" and statuscode=").append(statusCode);
+        }
+        MapSqlParameterSource parameters = new MapSqlParameterSource("dialectuids", partnerUUs);
+        // 不要直接拼SQL,防参数过多出错
+        NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
+        countSql.append(" and custuid not in (select uid_ from ac$userspaces where dialectuid in (:dialectuids))").append(" and venduid not in (select uid_ from ac$userspaces where dialectuid in (:dialectuids))");
+        querySql.append(" and custuid not in (select uid_ from ac$userspaces where dialectuid in (:dialectuids))").append(" and venduid not in (select uid_ from ac$userspaces where dialectuid in (:dialectuids))");
+        int total = namedParameterJdbcTemplate.query(countSql.toString(), parameters, getRowMapper()).size();
+        args = Arrays.copyOf(args, args.length + 2);
+        args[args.length - 2] = pageNumber * pageSize;
+        args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+        parameters.addValue("rowceil", pageNumber * pageSize);
+        parameters.addValue("rowfloor", (pageNumber - 1) * pageSize + 1);
+        // 311申请中, 310 已拒绝, 313 已激活 需要按申请中、已激活、已拒绝排序,所以用replace将311替换成333再排序。
+        querySql.append(" order by translate(statuscode, 311, 333) desc,id desc,vendname) t where rownum <= :rowceil) where r >= :rowfloor");
+        List<PartnershipRecord> content = null;
+        try {
+            content = namedParameterJdbcTemplate.query(querySql.toString(), parameters, getRowMapper());
+        } catch (EmptyResultDataAccessException e) {
+
+        }
+        return new Page<PartnershipRecord>(pageNumber, pageSize, content, total);
+    }
+
+    @Override
+    public int getRequestTodo(String businessCode) {
+        return count("from partnershiprecord where statuscode = 311 and venduid = ?", businessCode);
+    }
+
+    @Override
+    public void saveInvitation(InvitationRecord record) {
+        if (record.getEnuu() != null && record.getVendname() != null) {
+            Long id = jdbcTemplate.queryForObject(
+                    "select min(in_id) from invitationrecords where in_enuu=? and in_vendname=?", Long.class,
+                    record.getEnuu(), record.getVendname());
+            record.setId(id);
+        }
+        if (record.getId() == null) {
+            record.setId(generateId("invitationrecords_seq"));
+            jdbcTemplate.update(
+                    "insert into invitationrecords(in_id,in_enuu,in_businesscode,in_useruu,in_date,in_vendname,in_vendusername,in_vendusertel,in_venduseremail,in_count) values (?,?,?,?,?,?,?,?,?,?)",
+                    record.getId(), record.getEnuu(), record.getBussinesscode(), record.getUseruu(), new Date(),
+                    record.getVendname(), record.getVendusername(), record.getVendusertel(), record.getVenduseremail(),
+                    record.getCount());
+        } else {
+            jdbcTemplate.update(
+                    "update invitationrecords set in_enuu=?,in_businesscode=?,in_useruu=?,in_date=?,in_vendname=?,in_vendusername=?,in_vendusertel=?,in_venduseremail=?,in_count=? where in_id=?",
+                    record.getEnuu(), record.getBussinesscode(), record.getUseruu(), new Date(), record.getVendname(),
+                    record.getVendusername(), record.getVendusertel(), record.getVenduseremail(), record.getCount(),
+                    record.getId());
+        }
+    }
+
+    @Override
+    public List<InvitationRecord> findByVendname(String vendname) {
+        if (!StringUtils.isEmpty(vendname)) {
+            try {
+                return jdbcTemplate
+                        .query("select distinct(in_businesscode) bussinesscode,in_useruu useruu from invitationrecords where upper(in_vendname) = upper('"
+                                + vendname + "')", new BeanPropertyRowMapper<InvitationRecord>(InvitationRecord.class));
+            } catch (EmptyResultDataAccessException e) {
+                return null;
+            }
+        }
+        return null;
+    }
+
+}

+ 24 - 0
account-server/src/main/java/com/uas/account/dao/PlatfromManageDao.java

@@ -0,0 +1,24 @@
+package com.uas.account.dao;
+
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.entity.UserSpaceDetail;
+
+public interface PlatfromManageDao {
+
+	/**
+	 * 修改管理平台中的企业信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	public ModelMap updateEnterpriseInfoInManage(UserSpaceDetail detail, String businessCode);
+
+	/**
+	 * 修改管理平台控制中心的企业信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	public ModelMap updateMasterInfoInManage(UserSpaceDetail detail, String businessCode);
+}

+ 93 - 0
account-server/src/main/java/com/uas/account/dao/PlatfromManageDaoImpl.java

@@ -0,0 +1,93 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Repository;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+
+@Repository
+public class PlatfromManageDaoImpl extends BaseDao implements PlatfromManageDao {
+
+	@Override
+	public ModelMap updateEnterpriseInfoInManage(UserSpaceDetail detail, String businessCode) {
+		ModelMap map = new ModelMap();
+		String countSql = "select count(1) from enterprise where en_bussinesscode = '" + businessCode + "'";
+		Object[] args = new Object[] {};
+		Integer count = count(countSql, args);
+		if (count > 0) {
+			String updateSql = "update enterprise set en_name = '" + detail.getName() + "', en_address = '"
+					+ detail.getAddress() + "', en_bussinesscode ='"
+					+ detail.getBusinessCode() + "' where en_bussinesscode = '"
+					+ businessCode + "'";
+			jdbcTemplate.execute(updateSql);
+			countSql = "select count(1) from enterprise where en_name = '" + detail.getName() + "' and en_bussinesscode = '"
+                    + detail.getBusinessCode() + "'";
+			count = count(countSql, args);
+			if (count == 0) {
+				map.put("error", "管理平台企业信息更新失败");
+			}
+		} else {
+			map.put("error", "管理平台未找到相关企业信息,更新失败");
+		}
+		return map;
+	}
+
+	@Override
+	public ModelMap updateMasterInfoInManage(UserSpaceDetail detail, String businessCode) {
+		ModelMap map = new ModelMap();
+		String countSql = "select count(1) from masters where business_code = '" + businessCode + "'";
+		Object[] args = new Object[] {};
+		Integer count = count(countSql, args);
+		if (count > 0) {
+			String updateSql = "update masters set name = '" + detail.getName() + "',business_code = '"
+					+ detail.getBusinessCode() + "' where  business_code = '" + businessCode + "'";
+			jdbcTemplate.execute(updateSql);
+			countSql = "select count(1) from masters where name = '" + detail.getName() + "' and business_code = '"
+					+ detail.getBusinessCode() + "'";
+			count = count(countSql, args);
+			if (count == 0) {
+				map.put("error", "管理平台控制中心企业信息更新失败");
+			}
+		} else {
+			// 如果没找到,可以进行插入数据处理
+			Long id = generateId("masters_seq");
+			// 得到uu号等信息(目前只更新商务平台的信息)
+			UserSpace userSpace = getUserSpaceByUidAndAppId(detail.getBusinessCode(), "b2b");
+			jdbcTemplate.update(
+					"insert into masters(id,checked,name,platform,uu,business_code,env) values (?,?,?,?,?,?,?)", id, 1,
+					detail.getName(), "B2B", userSpace.getDialectUID(), detail.getBusinessCode(), "prod");
+			countSql = "select count(1) from masters where name = '" + detail.getName() + "' and business_code = '"
+					+ detail.getBusinessCode() + "'";
+			count = count(countSql, args);
+			if (count == 0) {
+				map.put("error", "管理平台控制中心企业信息更新失败");
+			}
+		}
+		return map;
+	}
+
+	/**
+	 * 通过营业执照号和应用查询注册后的信息
+	 * 
+	 * @param uid
+	 * @param appId
+	 * @return
+	 */
+	private UserSpace getUserSpaceByUidAndAppId(String uid, String appId) {
+		try {
+			List<UserSpace> spaces = jdbcTemplate.query(
+					"select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where appId=? and uid_=?",
+					new BeanPropertyRowMapper<UserSpace>(UserSpace.class), appId, uid);
+			return CollectionUtils.isEmpty(spaces) ? null : spaces.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+}

+ 19 - 0
account-server/src/main/java/com/uas/account/dao/SettingDao.java

@@ -0,0 +1,19 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import com.uas.account.entity.Setting;
+
+public interface SettingDao {
+
+	Setting save(Setting setting);
+
+	void save(List<Setting> settings);
+
+	Setting findOne(String key);
+
+	void delete(String key);
+
+	List<Setting> findAll();
+
+}

+ 59 - 0
account-server/src/main/java/com/uas/account/dao/SettingDaoImpl.java

@@ -0,0 +1,59 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Repository;
+
+import com.uas.account.entity.Setting;
+
+@Repository
+public class SettingDaoImpl extends BaseDao implements SettingDao {
+
+	@Override
+	public Setting save(Setting setting) {
+		int count = count("from ac$setting where key_=?", setting.getKey());
+		if (count == 0) {
+			jdbcTemplate.update("insert into ac$setting(description,key_,value_,deleteable) values (?,?,?,?)", setting.getDescription(),
+					setting.getKey(), setting.getValue(), setting.getDeleteable());
+		} else {
+			jdbcTemplate.update("update ac$setting set description=?,value_=?,deleteable=? where key_=?", setting.getDescription(),
+					setting.getValue(), setting.getDeleteable(), setting.getKey());
+		}
+		return setting;
+	}
+
+	@Override
+	public void save(List<Setting> settings) {
+		for (Setting setting : settings)
+			save(setting);
+	}
+
+	@Override
+	public Setting findOne(String key) {
+		try {
+			return jdbcTemplate.queryForObject(
+					"select description,key_ as \"KEY\",value_ as \"VALUE\",deleteable from ac$setting where key_=?",
+					new BeanPropertyRowMapper<Setting>(Setting.class), key);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void delete(String key) {
+		jdbcTemplate.update("delete from ac$setting where key_=?", key);
+	}
+
+	@Override
+	public List<Setting> findAll() {
+		try {
+			return jdbcTemplate.query("select description,key_ as \"KEY\",value_ as \"VALUE\",deleteable from ac$setting order by key_",
+					new BeanPropertyRowMapper<Setting>(Setting.class));
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+}

+ 50 - 0
account-server/src/main/java/com/uas/account/dao/SynchrodataToOldPlatDao.java

@@ -0,0 +1,50 @@
+package com.uas.account.dao;
+
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpaceDetail;
+
+public interface SynchrodataToOldPlatDao {
+
+	/**
+	 * 同步用户
+	 * 
+	 * @param user
+	 * @return
+	 */
+	public Long SynchUserToOldPlat(User user, String spaceName);
+
+	/**
+	 * 同步企业信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	public Long SyschUserSpaceToOldPlat(UserSpaceDetail detail, User user);
+
+	/**
+	 * 查询旧平台企业数量
+	 * 
+	 * @param bussinessCode
+	 * @param enuu
+	 * @return
+	 */
+	public Long findEnterpriseByEnuu(String enuu);
+
+	/**
+	 * 查询旧平台企业是否有这个人
+	 * 
+	 * @param useruu
+	 * @param enuu
+	 * @return
+	 */
+	public Long findUserByUserUUAndEnuu(String useruu, String enuu);
+
+	/**
+	 * 查询对应旧平台的人员的信息
+	 * 
+	 * @param useruu
+	 * @param enuu
+	 * @return
+	 */
+	public String getUserPassword(String useruu, String enuu);
+}

+ 122 - 0
account-server/src/main/java/com/uas/account/dao/SynchrodataToOldPlatDaoImpl.java

@@ -0,0 +1,122 @@
+package com.uas.account.dao;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.springframework.stereotype.Repository;
+
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpaceDetail;
+
+@Repository
+public class SynchrodataToOldPlatDaoImpl implements SynchrodataToOldPlatDao {
+
+	final static String userMethod = "user";
+	final static String userSpaceMethod = "userSpace";
+	final static String userPasswordMethod = "userPassword";
+
+	@Override
+	public Long SynchUserToOldPlat(User user, String spaceName) {
+		String userSpaceId = "select en_id from enterprise where en_uu = '" + user.getSpaceDialectUID()
+				+ "' and en_businesscode = '" + user.getSpaceUID() + "'";
+		String enId = ConnectionToOldPlat(userSpaceId, userSpaceMethod);
+		String sql = "insert into employees values (employees_seq.nextval,null,'111111', '" + user.getName()
+				+ "',null, " + user.getSpaceDialectUID() + ",'" + spaceName + "',null,null,null,'"
+				+ user.getUid() + "', '" + user.getSecondUID() + "',null,null,null,null," + user.getDialectUID()
+				+ ",'管理员',null,null,'" + enId + "')";
+		ConnectionToOldPlat(sql, null);
+		Long userId = findUserByUserUUAndEnuu(user.getDialectUID(), user.getSpaceDialectUID());
+		return userId;
+	}
+
+	@Override
+	public Long SyschUserSpaceToOldPlat(UserSpaceDetail detail, User user) {
+		String sql = "insert into enterprise values(enterprise_seq.nextval,'" + detail.getName() + "','"
+				+ detail.getShortName() + "','" + detail.getType() + "',1,null,'" + detail.getAddress() + "','"
+				+ detail.getAddress() + "','" + detail.getAdminTel() + "',null,'" + detail.getAdminName() + "','"
+				+ detail.getBusinessCode() + "',null,null,null,'" + user.getSpaceDialectUID() + "',null,'"
+				+ detail.getAdminEmail() + "',null,'" + detail.getAdminName() + "','" + detail.getAdminTel()
+				+ "',null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,'是',null,null,null,null,null)";
+		ConnectionToOldPlat(sql, null);
+		Long spaceId = findEnterpriseByEnuu(user.getSpaceDialectUID());
+		return spaceId;
+	}
+
+	@Override
+	public Long findEnterpriseByEnuu(String enuu) {
+		String userSpaceIdSql = "select en_id from enterprise where en_uu = '" + enuu + "'";
+		Long userSpaceId = 0L;
+		String spaceId = ConnectionToOldPlat(userSpaceIdSql, userSpaceMethod);
+		if (spaceId != null) {
+			userSpaceId = Long.valueOf(spaceId);
+		}
+		return userSpaceId;
+	}
+
+	@Override
+	public Long findUserByUserUUAndEnuu(String useruu, String enuu) {
+		String userIdSql = "select em_id from employees where en_uu = '" + enuu + "' and em_uu = '" + useruu + "'";
+		String id = ConnectionToOldPlat(userIdSql, userMethod);
+		Long userId = 0L;
+		if (id != null) {
+			userId = Long.valueOf(id);
+		}
+		return userId;
+	}
+
+	/**
+	 * 连接到旧平台数据库
+	 */
+	public String ConnectionToOldPlat(String sql, String method) {
+		String OperateResult = null;
+		Connection con = null;// 创建一个数据库连接
+		PreparedStatement pre = null;// 创建预编译语句对象,一般都是用这个而不用Statement
+		ResultSet result = null;// 创建一个结果集对象
+		try {
+			Class.forName("oracle.jdbc.driver.OracleDriver");// 加载Oracle驱动程序
+			String url = "jdbc:oracle:" + "thin:@10.10.100.88:1521:orcl";
+			String user = "dbusoft";// 用户名,系统默认的账户名
+			String password = "dbusoft";// 你安装时选设置的密码
+			con = DriverManager.getConnection(url, user, password);// 获取连接
+			pre = con.prepareStatement(sql);// 实例化预编译语句
+			result = pre.executeQuery();// 执行查询,注意括号中不需要再加参数
+			while (result.next())
+				// 当结果集不为空时
+				if (method != null) {
+					if (method.equals(userMethod)) {// employees表
+						OperateResult = result.getString("em_id");
+					} else if (method.equals(userSpaceMethod)) { // enterprise表
+						OperateResult = result.getString("en_id");
+					} else if (method.equals(userPasswordMethod)) {
+						OperateResult = result.getString("em_password");
+					}
+				}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 逐一将上面的几个对象关闭,因为不关闭的话会影响性能、并且占用资源
+				// 注意关闭的顺序,最后使用的最先关闭
+				if (result != null)
+					result.close();
+				if (pre != null)
+					pre.close();
+				if (con != null)
+					con.close();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		return OperateResult;
+	}
+
+	@Override
+	public String getUserPassword(String useruu, String enuu) {
+		String userIdSql = "select em_password from employees where en_uu = '" + enuu + "' and em_uu = '" + useruu
+				+ "'";
+		return ConnectionToOldPlat(userIdSql, userPasswordMethod);
+	}
+
+}

+ 13 - 0
account-server/src/main/java/com/uas/account/dao/TokenDao.java

@@ -0,0 +1,13 @@
+package com.uas.account.dao;
+
+import com.uas.account.entity.Token;
+
+public interface TokenDao {
+
+	void save(Token token);
+
+	Token findOne(String id);
+
+	void delete(String id);
+
+}

+ 64 - 0
account-server/src/main/java/com/uas/account/dao/TokenDaoImpl.java

@@ -0,0 +1,64 @@
+package com.uas.account.dao;
+
+import java.io.Serializable;
+
+import org.apache.shiro.dao.DataAccessException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.connection.RedisConnection;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Repository;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.account.entity.Token;
+
+@Repository
+public class TokenDaoImpl implements TokenDao {
+
+	@Autowired
+	private RedisTemplate<Serializable, Serializable> redisTemplate;
+
+	@Override
+	public void save(final Token token) {
+		redisTemplate.execute(new RedisCallback<Object>() {
+
+			@Override
+			public Object doInRedis(RedisConnection connection) throws DataAccessException {
+				byte[] key = redisTemplate.getStringSerializer().serialize("AccessToken.id." + token.getId());
+				byte[] value = redisTemplate.getStringSerializer().serialize(JSON.toJSONString(token));
+				connection.set(key, value);
+				connection.expire(key, token.getExpires_in());
+				return null;
+			}
+		});
+	}
+
+	@Override
+	public Token findOne(final String id) {
+		return redisTemplate.execute(new RedisCallback<Token>() {
+			@Override
+			public Token doInRedis(RedisConnection connection) throws DataAccessException {
+				byte[] key = redisTemplate.getStringSerializer().serialize("AccessToken.id." + id);
+				if (connection.exists(key)) {
+					String value = redisTemplate.getStringSerializer().deserialize(connection.get(key));
+					return JSON.parseObject(value, Token.class);
+				}
+				return null;
+			}
+		});
+	}
+
+	@Override
+	public void delete(final String id) {
+		redisTemplate.execute(new RedisCallback<Object>() {
+
+			@Override
+			public Object doInRedis(RedisConnection connection) throws DataAccessException {
+				byte[] key = redisTemplate.getStringSerializer().serialize("AccessToken.id." + id);
+				connection.del(key);
+				return null;
+			}
+		});
+	}
+
+}

+ 165 - 0
account-server/src/main/java/com/uas/account/dao/UserDao.java

@@ -0,0 +1,165 @@
+package com.uas.account.dao;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.*;
+import org.springframework.ui.ModelMap;
+
+import java.util.List;
+
+public interface UserDao {
+
+	/**
+	 * 保存、更新用户绑定关系
+	 *
+	 * @param user
+	 * @return
+	 */
+	User save(User user);
+
+	void delete(User user);
+
+	/**
+	 * 按应用、企业删除用户关系
+	 *
+	 * @param appId
+	 * @param spaceId
+	 */
+	void deleteByAppAndSpace(String appId, long spaceId);
+
+	UserDetail save(UserDetail userDetail);
+
+	User findOne(long id);
+
+	UserDetail findOne(String mobile);
+
+	List<UserDetail> findByEmail(String email);
+
+	User findOne(String appId, String spaceUID, String uid);
+
+	User findOne(String appId, Long spaceId, String uid);
+
+	User findDialectOne(String appId, Long spaceId, String dialectUID);
+
+	UserView findOneView(String appId, Long spaceId, String uid);
+
+	UserView findOneViewBySecondUID(String appId, Long spaceId, String secondUID);
+
+	UserView findOneViewByDialectUID(String appId, Long spaceId, String dialectUID);
+
+	List<User> findByUID(String uid);
+
+	List<User> findByDialectUID(String dialectUID);
+
+	List<User> findBySecondUID(String secondUID);
+
+	List<UserView> findViewByUID(String uid);
+
+	List<UserView> findViewBySecondUID(String secondUID);
+
+	List<UserView> findByAppAndUID(String appId, String uid);
+
+	List<UserView> findByAppAndSecondUID(String appId, String secondUID);
+
+	List<UserView> findByAppAndDialectUID(String appId, String dialectUID);
+
+	/**
+	 * 按SpaceID来更新其他Space字段
+	 *
+	 * @param spaceId
+	 * @param newAppId
+	 * @param newSpaceUID
+	 */
+	void updateUserSpace(long spaceId, String newAppId, String newSpaceUID);
+
+	Page<User> findAll(String appId, String spaceId, int pageNumber, int pageSize);
+
+	Page<UserDetail> findAllDetail(String name, String mobile, int pageNumber, int pageSize);
+
+	void saveFailed(UserFailed failed);
+
+	/**
+	 * @param appId
+	 *            应用
+	 * @param user
+	 *            用户
+	 * @param password
+	 *            密文密码
+	 */
+	void changePasswordByAppAndUser(String appId, User user, String password);
+
+	/**
+	 * @param user
+	 * @param secondUID
+	 */
+	void changeSecondUIDByUser(User user, String secondUID);
+
+	int getUserDetailCount();
+
+	/**
+	 * 用户开通app统计
+	 *
+	 * @return
+	 */
+	ModelMap getUserAppCount();
+
+	/**
+	 * 通过企业名称查询企业员工的信息
+	 *
+	 * @param name
+	 * @param pageNumber
+	 * @return
+	 */
+	List<UserSpaceDetailInfo> findByEnNameAndPageNumber(String name, Integer pageNumber);
+
+	/**
+	 * 通过企业营业执照查询企业员工的信息
+	 *
+	 * @param businessCode
+	 * @return
+	 */
+	List<User> findByBusinessCode(String businessCode);
+
+	Integer getEnterpriseCount();
+
+	Integer getPersonalUserCount();
+
+	Integer getUuUserCount();
+
+	/**
+	 * 锁定用户邮箱
+	 * @param email 需要锁定的邮箱
+	 */
+	void lockEmail(String email);
+
+	/**
+	 * 锁定用户手机号
+	 * @param tel 需要锁定的手机号
+	 */
+	void lockTel(String tel);
+
+	/**
+	 * 锁定用户UU号
+	 * @param uu 需要锁定的UU号
+	 */
+	void lockUU(String uu);
+
+	/**
+	 * 判断邮箱是否被锁定
+	 * @param email 需要判断的邮箱
+	 */
+	boolean isLockEmail(String email);
+
+	/**
+	 * 判断手机号是否被锁定
+	 * @param tel 需要判断的手机号
+	 */
+	boolean isLockTel(String tel);
+
+	/**
+	 * 判断手机号是否被锁定
+	 * @param uu 需要判断的uu号
+	 */
+	boolean isLockUU(String uu);
+
+    User findHrInfo(String businessCode);
+}

+ 581 - 0
account-server/src/main/java/com/uas/account/dao/UserDaoImpl.java

@@ -0,0 +1,581 @@
+package com.uas.account.dao;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.account.core.Page;
+import com.uas.account.entity.*;
+import org.springframework.dao.DataAccessException;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.ResultSetExtractor;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Repository;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@Repository
+public class UserDaoImpl extends BaseDao implements UserDao {
+
+	@Override
+	public User save(User user) {
+		if (user.getId() == null && !StringUtils.isEmpty(user.getUid())) {
+			Long id = null;
+			if (null == user.getSpaceId()) {
+				id = jdbcTemplate.queryForObject("select min(id) from ac$users where appId=? and uid_=?", Long.class,
+						user.getAppId(), user.getUid());
+			} else {
+				id = jdbcTemplate.queryForObject("select min(id) from ac$users where appId=? and uid_=? and spaceId=?",
+						Long.class, user.getAppId(), user.getUid(), user.getSpaceId());
+			}
+			user.setId(id);
+		}
+		if (user.getId() == null) {
+			user.setId(generateId("ac$user_seq"));
+			jdbcTemplate.update(
+					"insert into ac$users(id,appId,spaceId,spaceUID,spaceDialectUID,uid_,secondUID,dialectUID,name,password,salt,hr) values (?,?,?,?,?,?,?,?,?,?,?,?)",
+					user.getId(), user.getAppId(), user.getSpaceId(), user.getSpaceUID(), user.getSpaceDialectUID(),
+					user.getUid(), user.getSecondUID(), user.getDialectUID(), user.getName(), user.getPassword(),
+					user.getSalt(), user.getHr());
+		} else {
+			jdbcTemplate.update(
+					"update ac$users set appId=?,spaceId=?,spaceUID=?,spaceDialectUID=?,uid_=?,secondUID=?,dialectUID=?,name=?,password=?,salt=?,hr=? where id=?",
+					user.getAppId(), user.getSpaceId(), user.getSpaceUID(), user.getSpaceDialectUID(), user.getUid(),
+					user.getSecondUID(), user.getDialectUID(), user.getName(), user.getPassword(), user.getSalt(),
+					user.getHr(), user.getId());
+		}
+		return user;
+	}
+
+	@Override
+	public User findOne(String appId, Long spaceId, String uid) {
+		try {
+			List<User> users = null;
+			if (null == spaceId) {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where appId=? and spaceId is null and uid_=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, uid);
+			} else {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where appId=? and spaceId=? and uid_=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, spaceId, uid);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public User findDialectOne(String appId, Long spaceId, String dialectUID) {
+		try {
+			List<User> users = null;
+			if (null == spaceId) {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt from ac$users where appId=? and spaceId is null and dialectUID=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, dialectUID);
+			} else {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt from ac$users where appId=? and spaceId=? and dialectUID=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, spaceId, dialectUID);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserView findOneView(String appId, Long spaceId, String uid) {
+		try {
+			List<UserView> users = null;
+			if (null == spaceId) {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr from ac$users where  ac$users.appId=? and ac$users.spaceId is null and ac$users.uid_=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, uid);
+			} else {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$userspaces.name spaceName,ac$users.hr from ac$users,ac$userspaces where ac$users.spaceId=ac$userspaces.id and ac$users.appId=? and ac$users.spaceId=? and ac$users.uid_=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, spaceId, uid);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserView findOneViewBySecondUID(String appId, Long spaceId, String secondUID) {
+		try {
+			List<UserView> users = null;
+			if (null == spaceId) {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$userspaces.name spaceName from ac$users,ac$userspaces where ac$users.spaceId=ac$userspaces.id and ac$users.appId=? and ac$users.spaceId is null and ac$users.secondUID=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, secondUID);
+			} else {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$userspaces.name spaceName from ac$users,ac$userspaces where ac$users.spaceId=ac$userspaces.id and ac$users.appId=? and ac$users.spaceId=? and ac$users.secondUID=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, spaceId, secondUID);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserView findOneViewByDialectUID(String appId, Long spaceId, String dialectUID) {
+		try {
+			List<UserView> users = null;
+			if (null == spaceId) {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$userspaces.name spaceName,ac$users.hr from ac$users,ac$userspaces where ac$users.spaceId=ac$userspaces.id and ac$users.appId=? and ac$users.spaceId is null and ac$users.dialectUID=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, dialectUID);
+			} else {
+				users = jdbcTemplate.query(
+						"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$userspaces.name spaceName,ac$users.hr from ac$users,ac$userspaces where ac$users.spaceId=ac$userspaces.id and ac$users.appId=? and ac$users.spaceId=? and ac$users.dialectUID=?",
+						new BeanPropertyRowMapper<UserView>(UserView.class), appId, spaceId, dialectUID);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public User findOne(String appId, String spaceUID, String uid) {
+		try {
+			List<User> users = null;
+			if (null == spaceUID) {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where appId=? and spaceUID is null and uid_=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, uid);
+			} else {
+				users = jdbcTemplate.query(
+						"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where appId=? and spaceUID=? and uid_=?",
+						new BeanPropertyRowMapper<User>(User.class), appId, spaceUID, uid);
+			}
+			return CollectionUtils.isEmpty(users) ? null : users.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<User> findByUID(String uid) {
+		try {
+			return jdbcTemplate.query(
+					"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where uid_=? order by appId,spaceId",
+					new BeanPropertyRowMapper<User>(User.class), uid);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserView> findViewByUID(String uid) {
+		try {
+			return jdbcTemplate.query(
+					"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr,ac$userspaces.name spaceName from ac$users left join ac$userspaces on ac$users.spaceId=ac$userspaces.id where ac$users.uid_=? order by ac$users.spaceId,ac$users.appId",
+					new BeanPropertyRowMapper<UserView>(UserView.class), uid);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserView> findViewBySecondUID(String secondUID) {
+		try {
+			return jdbcTemplate.query(
+					"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr,ac$userspaces.name spaceName from ac$users left join ac$userspaces on ac$users.spaceId=ac$userspaces.id where ac$users.secondUID=? order by ac$users.spaceId,ac$users.appId",
+					new BeanPropertyRowMapper<UserView>(UserView.class), secondUID);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void updateUserSpace(long spaceId, String newAppId, String newSpaceUID) {
+		jdbcTemplate.update("update ac$users set appId=?,spaceUID=? where spaceId=?", newAppId, newSpaceUID, spaceId);
+	}
+
+	@Override
+	public User findOne(long id) {
+		try {
+			return jdbcTemplate.queryForObject(
+					"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where id=?",
+					new BeanPropertyRowMapper<User>(User.class), id);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public Page<User> findAll(String appId, String spaceId, int pageNumber, int pageSize) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$users where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(appId)) {
+			countSql.append(" and appId=?");
+			querySql.append(" and appId=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = appId;
+		}
+		if (!StringUtils.isEmpty(spaceId)) {
+			countSql.append(" and spaceId=?");
+			querySql.append(" and spaceId=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = spaceId;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by appId,spaceId,uid_) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<User> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), new BeanPropertyRowMapper<User>(User.class), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<User>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public List<UserView> findByAppAndUID(String appId, String uid) {
+		try {
+			return jdbcTemplate.query(
+					"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr,ac$userspaces.name spaceName from ac$users left join ac$userspaces on ac$users.spaceId=ac$userspaces.id where ac$users.appId=? and ac$users.uid_=? order by ac$users.spaceId",
+					new BeanPropertyRowMapper<UserView>(UserView.class), appId, uid);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserView> findByAppAndSecondUID(String appId, String secondUID) {
+		try {
+			return jdbcTemplate.query(
+					"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr,ac$userspaces.name spaceName from ac$users left join ac$userspaces on ac$users.spaceId=ac$userspaces.id where ac$users.appId=? and ac$users.secondUID=? order by ac$users.spaceId",
+					new BeanPropertyRowMapper<UserView>(UserView.class), appId, secondUID);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserView> findByAppAndDialectUID(String appId, String dialectUID) {
+		try {
+			return jdbcTemplate.query(
+					"select ac$users.id,ac$users.appId,ac$users.spaceId,ac$users.spaceUID,ac$users.spaceDialectUID,ac$users.uid_ as \"UID\",ac$users.secondUID,ac$users.dialectUID,ac$users.name,ac$users.password,ac$users.salt,ac$users.hr,ac$userspaces.name spaceName from ac$users left join ac$userspaces on ac$users.spaceId=ac$userspaces.id where ac$users.appId=? and ac$users.dialectUID=? order by ac$users.spaceId",
+					new BeanPropertyRowMapper<UserView>(UserView.class), appId, dialectUID);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void saveFailed(UserFailed failed) {
+		failed.setId(generateId("ac$user$fail_seq"));
+		jdbcTemplate.update(
+				"insert into ac$user$fail(id,callTime,errMsg,fromId,fromSpaceId,fromAppId,toSpaceId,toAppId) values (?,?,?,?,?,?,?,?)",
+				failed.getId(), failed.getCallTime(), failed.getErrMsg(), failed.getFromId(), failed.getFromSpaceId(),
+				failed.getFromAppId(), failed.getToSpaceId(), failed.getToAppId());
+	}
+
+	@Override
+	public List<User> findByDialectUID(String dialectUID) {
+		try {
+			return jdbcTemplate.query(
+					"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where dialectUID=? order by appId,spaceId",
+					new BeanPropertyRowMapper<User>(User.class), dialectUID);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<User> findBySecondUID(String secondUID) {
+		try {
+			return jdbcTemplate.query(
+					"select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where secondUID=? order by appId,spaceId",
+					new BeanPropertyRowMapper<User>(User.class), secondUID);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserDetail save(UserDetail userDetail) {
+		int count = count("from ac$user$detail where mobile=?", userDetail.getMobile());
+		if (count == 0) {
+			jdbcTemplate
+					.update("insert into ac$user$detail(mobile,email,name,sex,idCode,avatar,birthday,valid,department,job,lastLoginTime) values (?,?,?,?,?,?,?,?,?,?,?)",
+							userDetail.getMobile(), userDetail.getEmail(), userDetail.getName(), userDetail.getSex(),
+							userDetail.getIdCode(), userDetail.getAvatar(),
+							(userDetail.getBirthday() == null ? null : new Date(userDetail.getBirthday())), userDetail.getValid(),
+							userDetail.getDepartment(), userDetail.getJob(), (userDetail.getLastLoginTime()==null?null:new Date(userDetail.getLastLoginTime())));
+
+		} else {
+			jdbcTemplate
+					.update("update ac$user$detail set email=?,name=?,sex=?,idCode=?,avatar=?,birthday=?,valid=?,department=?,job=?,lastlogintime=? where mobile=?",
+							userDetail.getEmail(), userDetail.getName(), userDetail.getSex(), userDetail.getIdCode(),
+							userDetail.getAvatar(), (userDetail.getBirthday() == null ? null : new Date(userDetail.getBirthday())),
+							userDetail.getValid(), userDetail.getDepartment(), userDetail.getJob(), (userDetail.getLastLoginTime()==null?null:new Date(userDetail.getLastLoginTime())), userDetail.getMobile());
+		}
+		return userDetail;
+	}
+
+	private RowMapper<UserDetail> getRowMapper() {
+		return new RowMapper<UserDetail>() {
+
+			@Override
+			public UserDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
+				UserDetail detail = new UserDetail();
+				detail.setAvatar(rs.getString("avatar"));
+				Date birthday = rs.getDate("birthday");
+				if (birthday != null)
+					detail.setBirthday(birthday.getTime());
+				detail.setEmail(rs.getString("email"));
+				detail.setIdCode(rs.getString("idCode"));
+				detail.setMobile(rs.getString("mobile"));
+				detail.setName(rs.getString("name"));
+				detail.setSex(rs.getString("sex"));
+				detail.setValid(rs.getInt("valid"));
+				detail.setDepartment(rs.getString("department"));
+				detail.setJob(rs.getString("job"));
+				Date lastLoginTime = rs.getTimestamp("lastlogintime");
+				if (lastLoginTime != null) {
+					detail.setLastLoginTime(lastLoginTime.getTime());
+				}
+				return detail;
+			}
+
+		};
+	}
+
+	@Override
+	public UserDetail findOne(String mobile) {
+		try {
+			return jdbcTemplate.queryForObject("select * from ac$user$detail where mobile=?", getRowMapper(), mobile);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserDetail> findByEmail(String email) {
+		try {
+			return jdbcTemplate.query("select * from ac$user$detail where email=?", getRowMapper(), email);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void changePasswordByAppAndUser(String appId, User user, String password) {
+		if (!StringUtils.isEmpty(user.getUid()))
+			jdbcTemplate.update("update ac$users set password=? where appid=? and uid_=?", password, appId,
+					user.getUid());
+		else
+			jdbcTemplate.update("update ac$users set password=? where appid=? and dialectUID=?", password, appId,
+					user.getDialectUID());
+	}
+
+	@Override
+	public void delete(User user) {
+		jdbcTemplate.update("delete from ac$users where id=?", user.getId());
+	}
+
+	@Override
+	public void changeSecondUIDByUser(User user, String secondUID) {
+		if (!StringUtils.isEmpty(user.getUid()))
+			jdbcTemplate.update("update ac$users set secondUID=? where uid_=?", secondUID, user.getUid());
+		else
+			jdbcTemplate.update("update ac$users set secondUID=? where appId=? and dialectUID=?", secondUID,
+					user.getAppId(), user.getDialectUID());
+	}
+
+	@Override
+	public Page<UserDetail> findAllDetail(String name, String mobile, int pageNumber, int pageSize) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$user$detail where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select * from ac$user$detail where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(name)) {
+			countSql.append(" and name like '%").append(name).append("%'");
+			querySql.append(" and name like '%").append(name).append("%'");
+		}
+		if (!StringUtils.isEmpty(mobile)) {
+			countSql.append(" and mobile=?");
+			querySql.append(" and mobile=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = mobile;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by mobile) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserDetail> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), getRowMapper(), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserDetail>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public int getUserDetailCount() {
+		return count("from ac$user$detail");
+	}
+
+	@Override
+	public ModelMap getUserAppCount() {
+		return jdbcTemplate.query(
+				"select t2.description,count(1) c from (select distinct appId,uid_,secondUID from ac$users) t1,ac$apps t2 where t1.appId=t2.uid_ group by t2.description order by count(1) desc",
+				new ResultSetExtractor<ModelMap>() {
+
+					@Override
+					public ModelMap extractData(ResultSet rs) throws SQLException, DataAccessException {
+						ModelMap map = new ModelMap();
+						while (rs.next()) {
+							map.put(rs.getString(1), rs.getInt(2));
+						}
+						return map;
+					}
+
+				});
+	}
+
+	@Override
+	public void deleteByAppAndSpace(String appId, long spaceId) {
+		jdbcTemplate.update("delete from ac$users where appId=? and spaceId=?", appId, spaceId);
+	}
+
+	@Override
+	public List<UserSpaceDetailInfo> findByEnNameAndPageNumber(String name, Integer pageNumber) {
+		String sql = "select dialectuid imid,uid_ as \"usertel\",name username from ac$users where 1=1 and appid = 'im' and uid_ in (select a.uid_ from ac$users a left join ac$userspaces u on a.spaceid = u.id where u.appid = 'b2b' and upper(u.name) = upper('"
+				+ name + "'))";
+		List<UserSpaceDetailInfo> content = null;
+		try {
+			content = jdbcTemplate.query(sql,
+					new BeanPropertyRowMapper<UserSpaceDetailInfo>(UserSpaceDetailInfo.class));
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return content;
+	}
+
+	@Override
+	public List<User> findByBusinessCode(String businessCode) {
+		String sql = "select seconduid,uid_ as \"uid\",name,dialectuid from ac$users  where upper(spaceuid) = upper('"
+				+ businessCode + "') and appid = 'b2b'";
+		List<User> content = null;
+		try {
+			content = jdbcTemplate.query(sql, new BeanPropertyRowMapper<User>(User.class));
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return content;
+	}
+
+	@Override
+	public Integer getEnterpriseCount() {
+		try {
+			return jdbcTemplate.queryForObject("select count(*) SUM from ac$us$detail where 1=1", Integer.class);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	@Override
+	public Integer getPersonalUserCount() {
+		try {
+			return jdbcTemplate.queryForObject("select count(*) SUM from ac$user$detail where 1=1", Integer.class);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	@Override
+	public Integer getUuUserCount() {
+		try {
+			return jdbcTemplate.queryForObject("select count(*) SUM FROM ac$users where appid='im'", Integer.class);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	@Override
+	public void lockEmail(String email) {
+		int count = count("from ac$lock where username=? and type='email'", email);
+		if (count == 0) {
+			jdbcTemplate.update("insert into ac$lock(username, type) values (?, 'email')", email);
+		}
+	}
+
+	@Override
+	public void lockTel(String tel) {
+		int count = count("from ac$lock where username=? and type='tel'", tel);
+		if (count == 0) {
+			jdbcTemplate.update("insert into ac$lock(username, type) values (?, 'tel')", tel);
+		}
+	}
+
+	@Override
+	public void lockUU(String uu) {
+		int count = count("from ac$lock where username=? and type='uu'", uu);
+		if (count == 0) {
+			jdbcTemplate.update("insert into ac$lock(username, type) values (?, 'uu')", uu);
+		}
+	}
+
+	@Override
+	public boolean isLockEmail(String email) {
+		int count = count("from ac$lock where username=? and type='email'", email);
+		if (count > 0) {
+			return true;
+		}
+		return false;
+	}
+
+	@Override
+	public boolean isLockTel(String tel) {
+		int count = count("from ac$lock where username=? and type='tel'", tel);
+		if (count > 0) {
+			return true;
+		}
+		return false;
+	}
+
+	@Override
+	public boolean isLockUU(String uu) {
+		int count = count("from ac$lock where username=? and type='uu'", uu);
+		if (count > 0) {
+			return true;
+		}
+		return false;
+	}
+
+
+    @Override
+    public User findHrInfo(String businessCode) {
+	    List<User> content = null;
+        if(null != businessCode) {
+            content = jdbcTemplate.query("select id,appId,spaceId,spaceUID,spaceDialectUID,uid_ as \"UID\",secondUID,dialectUID,name,password,salt,hr from ac$users where appId = 'b2b' and spaceuid = '" + businessCode + "' and nvl(hr, 0) = 1",
+                    new BeanPropertyRowMapper<User>(User.class));
+            return content.size() > 0 ? content.get(0) : null;
+        }
+        return null;
+    }
+
+}

+ 19 - 0
account-server/src/main/java/com/uas/account/dao/UserQuestionDao.java

@@ -0,0 +1,19 @@
+package com.uas.account.dao;
+
+import com.uas.account.entity.UserQuestion;
+
+import java.util.List;
+
+/**
+ * Created by wangmh on 2017/10/31.
+ */
+public interface UserQuestionDao {
+
+    List<UserQuestion> getEncryptedQuestion(Long userUU);
+
+    boolean checkEncryptedQuestion();
+
+    void save(List<UserQuestion> questions);
+
+    void saveOne(UserQuestion question);
+}

+ 61 - 0
account-server/src/main/java/com/uas/account/dao/UserQuestionDaoImpl.java

@@ -0,0 +1,61 @@
+package com.uas.account.dao;
+
+import com.uas.account.entity.UserQuestion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by wangmh on 2017/10/31.
+ */
+@Repository
+public class UserQuestionDaoImpl extends BaseDao implements UserQuestionDao {
+
+    @Override
+    public List<UserQuestion> getEncryptedQuestion(Long userUU) {
+        if (userUU == null) {
+            return null;
+        }
+        List<UserQuestion> questions = jdbcTemplate.query("select id,userUU,question,answer,sort from ac$user$question where userUU=?",
+                new BeanPropertyRowMapper<UserQuestion>(UserQuestion.class), userUU);
+        return questions;
+    }
+
+    @Override
+    public boolean checkEncryptedQuestion() {
+        return false;
+    }
+
+    @Override
+    public void save(List<UserQuestion> questions) {
+        if (questions == null) {
+            return;
+        }
+        for (UserQuestion question : questions) {
+            int count = count("select id from ac$user$question where userUU=? and sort=?", question.getUserUU(), question.getSort());
+            if (count == 0) {
+                question.setId(generateId("ac$user$question_seq"));
+                jdbcTemplate.update("insert into ac$user$question(id, useruu, question, answer, sort) values (?,?,?,?,?)",
+                        question.getId(),question.getUserUU(),question.getQuestion(),question.getAnswer(),question.getSort());
+            } else {
+                jdbcTemplate.update("update ac$user$question set question=?,answer=?", question.getQuestion(), question.getAnswer());
+            }
+        }
+    }
+
+    @Override
+    public void saveOne(UserQuestion question) {
+        int count = count("select count(id) from ac$user$question where userUU=? and sort=?", question.getUserUU(), question.getSort());
+        if (count == 0) {
+            question.setId(generateId("ac$user$question_seq"));
+            jdbcTemplate.update("insert into ac$user$question(id, useruu, question, answer, sort) values (?,?,?,?,?)",
+                    question.getId(),question.getUserUU(),question.getQuestion(),question.getAnswer(),question.getSort());
+        } else {
+            jdbcTemplate.update("update ac$user$question set question=?,answer=? where useruu=? and sort=?",
+                    question.getQuestion(), question.getAnswer(), question.getUserUU(), question.getSort());
+        }
+    }
+}

+ 190 - 0
account-server/src/main/java/com/uas/account/dao/UserSpaceDao.java

@@ -0,0 +1,190 @@
+package com.uas.account.dao;
+
+import java.util.List;
+
+import com.uas.account.entity.*;
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.core.Page;
+import com.uas.account.viewmodel.UserSpaceDetailView;
+
+public interface UserSpaceDao {
+
+	UserSpace save(UserSpace userSpace);
+
+	UserSpace findOne(long id);
+
+	UserSpace findOne(String appId, String uid);
+
+	UserSpace findDialectOne(String appId, String dialectUID);
+
+	List<UserSpace> findByUID(String uid);
+
+	Page<UserSpace> findAll(String appId, int pageNumber, int pageSize);
+
+	UserSpaceFailed saveFailed(UserSpaceFailed failed);
+
+	/**
+	 * 保存详细企业信息
+	 * 
+	 * @param userSpaceDetail
+	 * @return
+	 */
+	UserSpaceDetail save(UserSpaceDetail userSpaceDetail);
+
+	/**
+	 * 删除
+	 * 
+	 * @param userSpaceDetail
+	 */
+	void delete(UserSpaceDetail userSpaceDetail);
+
+	/**
+	 * 删除
+	 * 
+	 * @param userSpace
+	 */
+	void delete(UserSpace userSpace);
+
+	/**
+	 * 查找企业详细信息
+	 * 
+	 * @param businessCode
+	 *            注册号
+	 * @return
+	 */
+	UserSpaceDetail findByBusinessCode(String businessCode);
+
+	/**
+	 * 查找企业详细信息
+	 * 
+	 * @param businessCode
+	 *            注册号
+	 * @return
+	 */
+	UserSpaceDetail findById(Long id);
+
+	/**
+	 * 查找企业详细信息
+	 * 
+	 * @param domain
+	 *            域名
+	 * @return
+	 */
+	UserSpaceDetail findByDomain(String domain);
+
+	/**
+	 * 查找企业详细信息
+	 * 
+	 * @param name
+	 *            全称
+	 * @return
+	 */
+	UserSpaceDetail findByName(String name);
+
+	/**
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param status
+	 *            状态
+	 * @return
+	 */
+	Page<UserSpaceDetail> findAll(int pageNumber, int pageSize, Integer status);
+
+	/**
+	 * 通过状态分类查找企业信息
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param name
+	 * @param businessCode
+	 * @param status
+	 * @return
+	 */
+	Page<UserSpaceDetailView> findAllView(int pageNumber, int pageSize, String name, String businessCode, Integer status);
+
+	/**
+	 * 查找所有企业信息,返回较多的信息
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @param name
+	 * @param businessCode
+	 * @return
+	 */
+	Page<UserSpaceDetailView> findAllView(int pageNumber, int pageSize, String name, String businessCode, String address);
+
+	int getUserSpaceDetailCount();
+
+	/**
+	 * 企业开通app统计
+	 * 
+	 * @return
+	 */
+	ModelMap getUserSpaceAppCount();
+
+	/**
+	 * 通过关键词查询企业信息
+	 * 
+	 * @param keyword
+	 * @return
+	 */
+	Page<UserSpaceDetail> findByKeyword(String keyword, int pageNumber, int pageSize);
+
+	/**
+	 * 通过id查询企业信息(方便平台搜索调用)
+	 * 
+	 * @param ids
+	 * @return
+	 */
+	List<UserSpaceDetail> findAll(List<Long> ids);
+
+	/**
+	 * uu互联接口,通过手机号查询企业地址和企业名称
+	 * 
+	 * @param tel
+	 * @return
+	 */
+	List<UserSpaceDetailInfo> findByTel(List<String> tels);
+
+	/**
+	 * uu互联接口,通过手机号查询企业信息和个人信息
+	 * 
+	 * @param tels
+	 * @return
+	 */
+	List<UserSpaceDetailInfo> findUserByTel(List<String> tels);
+
+	/**
+	 * uu互联接口,通过关键词查询企业相关信息
+	 * 
+	 * @param keyword
+	 * @param pageNumber
+	 * @return
+	 */
+	List<UserSpaceDetailInfo> findByKeyword(String keyword, Integer pageNumber);
+
+	/**
+	 * 更新ac$userspaces中的信息
+	 * 
+	 * @param space
+	 * @param id
+	 */
+	void update(UserSpace space, Long id);
+
+	/**
+	 * 查询企业是否已经存在hr账号
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	Integer findHrAccount(String businessCode);
+
+    /**
+     * 更新企业的hr账号信息
+     *
+     * @param hrInfo
+     * @param flag
+     */
+    void updateInfo(User hrInfo, boolean flag);
+}

+ 505 - 0
account-server/src/main/java/com/uas/account/dao/UserSpaceDaoImpl.java

@@ -0,0 +1,505 @@
+package com.uas.account.dao;
+
+import com.alibaba.druid.util.StringUtils;
+import com.uas.account.core.Page;
+import com.uas.account.core.Status;
+import com.uas.account.entity.*;
+import com.uas.account.viewmodel.UserSpaceDetailView;
+import org.springframework.dao.DataAccessException;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.ResultSetExtractor;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.stereotype.Repository;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@Repository
+public class UserSpaceDaoImpl extends BaseDao implements UserSpaceDao {
+
+	@Override
+	public UserSpace save(UserSpace userSpace) {
+		if (userSpace.getId() == null && !StringUtils.isEmpty(userSpace.getUid())) {
+			Long id = jdbcTemplate.queryForObject("select min(id) from ac$userspaces where appId=? and uid_=?", Long.class,
+					userSpace.getAppId(), userSpace.getUid());
+			userSpace.setId(id);
+		}
+		if (userSpace.getId() == null) {
+			userSpace.setId(generateId("ac$us_seq"));
+			jdbcTemplate.update("insert into ac$userspaces(id,appId,uid_,name,dialectUID,userCount) values (?,?,?,?,?,?)",
+					userSpace.getId(), userSpace.getAppId(), userSpace.getUid(), userSpace.getName(), userSpace.getDialectUID(),
+					userSpace.getUserCount());
+		} else {
+			jdbcTemplate.update("update ac$userspaces set appId=?,uid_=?,name=?,dialectUID=?,userCount=? where id=?", userSpace.getAppId(),
+					userSpace.getUid(), userSpace.getName(), userSpace.getDialectUID(), userSpace.getUserCount(), userSpace.getId());
+		}
+		return userSpace;
+	}
+
+	@Override
+	public UserSpace findOne(String appId, String uid) {
+		try {
+			List<UserSpace> spaces = jdbcTemplate.query(
+					"select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where appId=? and uid_=?",
+					new BeanPropertyRowMapper<UserSpace>(UserSpace.class), appId, uid);
+			return CollectionUtils.isEmpty(spaces) ? null : spaces.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserSpace findDialectOne(String appId, String dialectUID) {
+		try {
+			List<UserSpace> spaces = jdbcTemplate.query(
+					"select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where appId=? and dialectUID=?",
+					new BeanPropertyRowMapper<UserSpace>(UserSpace.class), appId, dialectUID);
+			return CollectionUtils.isEmpty(spaces) ? null : spaces.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public List<UserSpace> findByUID(String uid) {
+		try {
+			return jdbcTemplate.query(
+					"select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where uid_=? order by appId",
+					new BeanPropertyRowMapper<UserSpace>(UserSpace.class), uid);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserSpace findOne(long id) {
+		try {
+			return jdbcTemplate.queryForObject("select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where id=?",
+					new BeanPropertyRowMapper<UserSpace>(UserSpace.class), id);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public Page<UserSpace> findAll(String appId, int pageNumber, int pageSize) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$userspaces where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select appId,id,uid_ as \"UID\",dialectUID,name,userCount from ac$userspaces where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(appId)) {
+			countSql.append(" and appId=?");
+			querySql.append(" and appId=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = appId;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by appId,uid) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpace> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), new BeanPropertyRowMapper<UserSpace>(UserSpace.class), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserSpace>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public UserSpaceFailed saveFailed(UserSpaceFailed failed) {
+		failed.setId(generateId("ac$us$fail_seq"));
+		jdbcTemplate.update("insert into ac$us$fail(id,callTime,errMsg,fromId,fromAppId,toAppId) values (?,?,?,?,?,?)", failed.getId(),
+				failed.getCallTime(), failed.getErrMsg(), failed.getFromId(), failed.getFromAppId(), failed.getToAppId());
+		return failed;
+	}
+
+	@Override
+	public UserSpaceDetail save(UserSpaceDetail userSpaceDetail) {
+		int count = 0;
+		if (userSpaceDetail.getId() != null) {
+			count = count("from ac$us$detail where id=?", userSpaceDetail.getId());
+		} else {
+			count = count("from ac$us$detail where businessCode=?", userSpaceDetail.getBusinessCode());
+		}
+		if (count == 0) {
+			// 在这里设置ID,需要返回给后面用到
+			userSpaceDetail.setId(generateId("ac$us$detail_seq"));
+			jdbcTemplate
+					.update("insert into ac$us$detail(id,name,shortName,businessCode,address,corporation,fax,tel,registerDate,type,url,area,industry,domain,adminName,adminTel,adminEmail,status,approve_status,applyApps,businessCodeImage,province,city,district,street,logoImage,contactMan,contactTel,contactEmail,profession,tags) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+							userSpaceDetail.getId(), userSpaceDetail.getName(), userSpaceDetail.getShortName(),
+							userSpaceDetail.getBusinessCode(), userSpaceDetail.getAddress(), userSpaceDetail.getCorporation(),
+							userSpaceDetail.getFax(), userSpaceDetail.getTel(), new Date(userSpaceDetail.getRegisterDate()),
+							userSpaceDetail.getType(), userSpaceDetail.getUrl(), userSpaceDetail.getArea(), userSpaceDetail.getIndustry(),
+							userSpaceDetail.getDomain(), userSpaceDetail.getAdminName(), userSpaceDetail.getAdminTel(),
+							userSpaceDetail.getAdminEmail(), userSpaceDetail.getStatus(), userSpaceDetail.getApproveStatus(),
+							userSpaceDetail.getApplyApps(), userSpaceDetail.getBusinessCodeImage(), userSpaceDetail.getProvince(),
+							userSpaceDetail.getCity(), userSpaceDetail.getDistrict(), userSpaceDetail.getStreet(),
+							userSpaceDetail.getLogoImage(), userSpaceDetail.getContactMan(), userSpaceDetail.getContactTel(),
+                            userSpaceDetail.getContactEmail(), userSpaceDetail.getProfession(), userSpaceDetail.getTags());
+		} else {
+			jdbcTemplate
+					.update("update ac$us$detail set name=?,shortName=?,address=?,corporation=?,fax=?,tel=?,type=?,url=?,area=?,industry=?,domain=?,adminName=?,adminTel=?,adminEmail=?,status=?,approve_status=?,businessCodeImage=?,errMsg=?,province=?,city=?,district=?,street=?,logoImage=?,businessCode=?,contactMan=?,contactTel=?,contactEmail=?,profession=?,tags=? where id=?",
+							userSpaceDetail.getName(), userSpaceDetail.getShortName(), userSpaceDetail.getAddress(),
+							userSpaceDetail.getCorporation(), userSpaceDetail.getFax(), userSpaceDetail.getTel(),
+							userSpaceDetail.getType(), userSpaceDetail.getUrl(), userSpaceDetail.getArea(), userSpaceDetail.getIndustry(),
+							userSpaceDetail.getDomain(), userSpaceDetail.getAdminName(), userSpaceDetail.getAdminTel(),
+							userSpaceDetail.getAdminEmail(), userSpaceDetail.getStatus(), userSpaceDetail.getApproveStatus(),
+							userSpaceDetail.getBusinessCodeImage(), userSpaceDetail.getErrMsg(), userSpaceDetail.getProvince(),
+							userSpaceDetail.getCity(), userSpaceDetail.getDistrict(), userSpaceDetail.getStreet(),
+							userSpaceDetail.getLogoImage(), userSpaceDetail.getBusinessCode(), userSpaceDetail.getContactMan(),
+                            userSpaceDetail.getContactTel(), userSpaceDetail.getContactEmail(), userSpaceDetail.getProfession(),
+							userSpaceDetail.getTags(), userSpaceDetail.getId());
+		}
+		return userSpaceDetail;
+	}
+
+	@Override
+	public UserSpaceDetail findByBusinessCode(String businessCode) {
+		try {
+			List<UserSpaceDetail> list = jdbcTemplate
+					.query("select * from ac$us$detail where businessCode=?", getRowMapper(), businessCode);
+			return CollectionUtils.isEmpty(list) ? null : list.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserSpaceDetail findById(Long id) {
+		try {
+			return jdbcTemplate.queryForObject("select * from ac$us$detail where id=?", getRowMapper(), id);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public UserSpaceDetail findByDomain(String domain) {
+		try {
+			List<UserSpaceDetail> list = jdbcTemplate.query("select * from ac$us$detail where domain=? and businessCode is not null",
+					getRowMapper(), domain);
+			return CollectionUtils.isEmpty(list) ? null : list.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	private RowMapper<UserSpaceDetail> getRowMapper() {
+		return new RowMapper<UserSpaceDetail>() {
+
+			@Override
+			public UserSpaceDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
+				UserSpaceDetail detail = new UserSpaceDetail();
+				detail.setId(rs.getLong("id"));
+				detail.setAddress(rs.getString("address"));
+				detail.setAdminEmail(rs.getString("adminEmail"));
+				detail.setAdminName(rs.getString("adminName"));
+				detail.setAdminTel(rs.getString("adminTel"));
+				detail.setApplyApps(rs.getString("applyApps"));
+				detail.setArea(rs.getString("area"));
+				detail.setBusinessCode(rs.getString("businessCode"));
+				detail.setBusinessCodeImage(rs.getString("businessCodeImage"));
+				detail.setCity(rs.getString("city"));
+				detail.setCorporation(rs.getString("corporation"));
+				detail.setDistrict(rs.getString("district"));
+				detail.setDomain(rs.getString("domain"));
+				detail.setErrMsg(rs.getString("errMsg"));
+				detail.setFax(rs.getString("fax"));
+				detail.setIndustry(rs.getString("industry"));
+				detail.setName(rs.getString("name"));
+				detail.setProvince(rs.getString("province"));
+				Date registerDate = rs.getDate("registerDate");
+				if (registerDate != null)
+					detail.setRegisterDate(registerDate.getTime());
+				detail.setShortName(rs.getString("shortName"));
+				detail.setStatus(rs.getInt("status"));
+				detail.setStreet(rs.getString("street"));
+				detail.setTel(rs.getString("tel"));
+				detail.setType(rs.getString("type"));
+				detail.setUrl(rs.getString("url"));
+				detail.setContactMan(rs.getString("contactMan"));
+                detail.setContactEmail(rs.getString("contactEmail"));
+                detail.setContactTel(rs.getString("contactTel"));
+                detail.setProfession(rs.getString("profession"));
+                detail.setTags(rs.getString("tags"));
+				if (!StringUtils.isEmpty(rs.getString("uu"))) {
+					detail.setUu(Long.valueOf(rs.getString("uu")));
+				}
+				return detail;
+			}
+
+		};
+	}
+
+	@Override
+	public UserSpaceDetail findByName(String name) {
+		try {
+			List<UserSpaceDetail> list = jdbcTemplate.query("select * from ac$us$detail where name=? and businessCode is not null",
+					getRowMapper(), name);
+			return CollectionUtils.isEmpty(list) ? null : list.get(0);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	@Override
+	public Page<UserSpaceDetail> findAll(int pageNumber, int pageSize, Integer status) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$us$detail where 1=1");
+		StringBuffer querySql = new StringBuffer("select * from (select t.*,rownum r from (select * from ac$us$detail where 1=1");
+		Object[] args = new Object[] {};
+		if (null != status) {
+			countSql.append(" and status=?");
+			querySql.append(" and status=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = status;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by registerDate,name) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpaceDetail> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), getRowMapper(), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserSpaceDetail>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public void delete(UserSpaceDetail userSpaceDetail) {
+		jdbcTemplate.update("delete from ac$us$detail where businessCode=?", userSpaceDetail.getBusinessCode());
+	}
+
+	@Override
+	public void delete(UserSpace userSpace) {
+		jdbcTemplate.update("delete from ac$userspaces where id=?", userSpace.getId());
+	}
+
+	@Override
+	public Page<UserSpaceDetailView> findAllView(int pageNumber, int pageSize, String name, String businessCode, Integer status) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$us$detail where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select businessCode,name,registerDate,shortName,id from ac$us$detail where 1=1");
+		Object[] args = new Object[] {};
+		if (null != status) {
+			countSql.append(" and status=?");
+			querySql.append(" and status=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = status;
+		}
+		if (!StringUtils.isEmpty(name)) {
+			countSql.append(" and name like '%").append(name).append("%'");
+			querySql.append(" and name like '%").append(name).append("%'");
+		}
+		if (!StringUtils.isEmpty(businessCode)) {
+			countSql.append(" and businessCode=?");
+			querySql.append(" and businessCode=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = businessCode;
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by registerDate desc,name) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpaceDetailView> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), new BeanPropertyRowMapper<UserSpaceDetailView>(UserSpaceDetailView.class),
+					args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserSpaceDetailView>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public Page<UserSpaceDetailView> findAllView(int pageNumber, int pageSize, String name, String businessCode, String address) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$us$detail where 1=1");
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select businessCode,name,registerDate,shortName,id,status from ac$us$detail where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(name)) {
+			countSql.append(" and upper(name) like upper('%").append(name).append("%')");
+			querySql.append(" and upper(name) like upper('%").append(name).append("%')");
+		}
+		if (!StringUtils.isEmpty(businessCode)) {
+			countSql.append(" and businessCode=?");
+			querySql.append(" and businessCode=?");
+			args = Arrays.copyOf(args, args.length + 1);
+			args[args.length - 1] = businessCode;
+		}
+		if (!StringUtils.isEmpty(address)) {
+			countSql.append(" and address like '%").append(address).append("%'");
+			querySql.append(" and address like '%").append(address).append("%'");
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by registerDate desc,name) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpaceDetailView> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), new BeanPropertyRowMapper<UserSpaceDetailView>(UserSpaceDetailView.class),
+					args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserSpaceDetailView>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public int getUserSpaceDetailCount() {
+		return count("from ac$us$detail where status=?", Status.ENABLED.value());
+	}
+
+	@Override
+	public ModelMap getUserSpaceAppCount() {
+		return jdbcTemplate
+				.query("select ac$apps.description,count(1) c from ac$userspaces,ac$apps where ac$userspaces.appId=ac$apps.uid_ group by ac$apps.description order by count(1) desc",
+						new ResultSetExtractor<ModelMap>() {
+
+							@Override
+							public ModelMap extractData(ResultSet rs) throws SQLException, DataAccessException {
+								ModelMap map = new ModelMap();
+								while (rs.next()) {
+									map.put(rs.getString(1), rs.getInt(2));
+								}
+								return map;
+							}
+
+						});
+	}
+
+	@Override
+	public Page<UserSpaceDetail> findByKeyword(String keyword, int pageNumber, int pageSize) {
+		StringBuffer countSql = new StringBuffer("select count(1) from ac$us$detail where 1=1");
+		StringBuffer querySql = new StringBuffer("select * from (select t.*,rownum r from (select * from ac$us$detail where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(keyword)) {
+			querySql.append(" and upper(name) like upper('%").append(keyword).append("%') or upper(shortname) like upper('%")
+					.append(keyword).append("%') or upper(adminname) like upper('%").append(keyword).append("%')");
+			countSql.append(" and upper(name) like upper('%").append(keyword).append("%') or upper(shortname) like upper('%")
+					.append(keyword).append("%') or upper(adminname) like upper('%").append(keyword).append("%')");
+		}
+		int total = count(countSql.toString(), args);
+
+		querySql.append(" order by registerDate desc,name) t where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpaceDetail> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(), getRowMapper(), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return new Page<UserSpaceDetail>(pageNumber, pageSize, content, total);
+	}
+
+	@Override
+	public List<UserSpaceDetail> findAll(List<Long> ids) {
+		MapSqlParameterSource parameters = new MapSqlParameterSource("ids", ids);
+		// 不要直接拼SQL,防参数过多出错
+		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
+		return namedParameterJdbcTemplate.query("select * from v$ac$us$detail where id in (:ids)", parameters, getRowMapper());
+	}
+
+	@Override
+	public List<UserSpaceDetailInfo> findByTel(List<String> tels) {
+		MapSqlParameterSource parameters = new MapSqlParameterSource("tels", tels);
+		// 不要直接拼SQL,防参数过多出错
+		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
+		return namedParameterJdbcTemplate.query(
+				"select a.name company, a.address address,u.name username,u.uid_ usertel,u.dialectuid imid from ac$us$detail a left join ac$users u on a.admintel = u.uid_ where a.businesscode in (select distinct(spaceuid) from ac$users where uid_ in (:tels) and spaceuid is not null) and u.appid = 'im'",
+				parameters, new BeanPropertyRowMapper<UserSpaceDetailInfo>(UserSpaceDetailInfo.class));
+	}
+
+	@Override
+	public List<UserSpaceDetailInfo> findUserByTel(List<String> tels) {
+		List<UserSpaceDetailInfo> spaces = new ArrayList<>();
+		for (String tel : tels) {
+			String sql = "select a.name company, a.address address,u.name username,u.uid_ usertel,u.dialectuid imid from ac$us$detail a,ac$users u where a.businesscode = (select min(spaceuid) from ac$users a where a.uid_ = ? and a.spaceuid is not null group by (a.uid_)) and u.uid_ = ? and u.appid = 'im'";
+			List<UserSpaceDetailInfo> list = jdbcTemplate.query(sql,
+					new BeanPropertyRowMapper<UserSpaceDetailInfo>(UserSpaceDetailInfo.class), tel, tel);
+			UserSpaceDetailInfo space = CollectionUtils.isEmpty(list) ? null : list.get(0);
+			if (space == null) {
+				space = new UserSpaceDetailInfo();
+				space.setUsertel(tel);
+				space.setCompany(" ");
+				space.setAddress(" ");
+				space.setImid(" ");
+				space.setUsername(" ");
+			}
+			spaces.add(space);
+		}
+		return spaces;
+	}
+
+	@Override
+	public List<UserSpaceDetailInfo> findByKeyword(String keyword, Integer pageNumber) {
+		Integer pageSize = 30;// 设置默认大小30
+		if (pageNumber < 1) {
+			pageNumber = 1;
+		}
+		StringBuffer querySql = new StringBuffer(
+				"select * from (select t.*,rownum r from (select  a.name company, a.address address,u.name username,u.uid_ usertel,u.dialectuid imid from ac$us$detail a left join ac$users u on a.admintel = u.uid_ where 1=1");
+		Object[] args = new Object[] {};
+		if (!StringUtils.isEmpty(keyword)) {
+			querySql.append(" and upper(a.name) like upper('%").append(keyword).append("%')");
+		}
+		querySql.append("and u.appid = 'im') t  where rownum <= ?) where r >= ?");
+		args = Arrays.copyOf(args, args.length + 2);
+		args[args.length - 2] = pageNumber * pageSize;
+		args[args.length - 1] = (pageNumber - 1) * pageSize + 1;
+		List<UserSpaceDetailInfo> content = null;
+		try {
+			content = jdbcTemplate.query(querySql.toString(),
+					new BeanPropertyRowMapper<UserSpaceDetailInfo>(UserSpaceDetailInfo.class), args);
+		} catch (EmptyResultDataAccessException e) {
+
+		}
+		return content;
+	}
+
+	@Override
+	public void update(UserSpace space, Long id) {
+		if (id != null)
+			jdbcTemplate.update("update ac$userspaces set appId=?,uid_=?,name=?,dialectUID=?,userCount=? where id=?",
+					space.getAppId(), space.getUid(), space.getName(), space.getDialectUID(), space.getUserCount(), id);
+	}
+
+	@SuppressWarnings({ "deprecation" })
+	@Override
+	public Integer findHrAccount(String businessCode) {
+		Integer count = 0;
+		if (null != businessCode) {
+			String sql = "select count(1) from ac$users where spaceuid = '" + businessCode + "' and nvl(hr, 0) = 1";
+			count = jdbcTemplate.queryForInt(sql);
+		}
+		return count;
+	}
+
+    @Override
+    public void updateInfo(User hrInfo, boolean flag) {
+	    Integer status = flag ? 1 : 0;
+        jdbcTemplate.update("update ac$users set hr = " + status + "where spaceuid = '" + hrInfo.getSpaceUID() + "' and uid_ = '" + hrInfo.getUid() + "' and appid = 'b2b'");
+    }
+
+}

+ 171 - 0
account-server/src/main/java/com/uas/account/entity/Asset.java

@@ -0,0 +1,171 @@
+package com.uas.account.entity;
+
+/**
+ * 资源文件
+ * 
+ * @author yingp
+ *
+ */
+public class Asset {
+
+	private Long id;
+	private String appId;
+	private Integer idx;
+	private String url;
+	private String background;
+	private String imgLink;
+	private String color;
+	private String reserveColor;
+	private String title;
+	private String subTitle;
+	private String btns;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 所属app
+	 * 
+	 * @return
+	 */
+	public String getAppId() {
+		return appId;
+	}
+
+	public void setAppId(String appId) {
+		this.appId = appId;
+	}
+
+	/**
+	 * 序号
+	 * 
+	 * @return
+	 */
+	public Integer getIdx() {
+		return idx;
+	}
+
+	public void setIdx(Integer idx) {
+		this.idx = idx;
+	}
+
+	/**
+	 * 背景图片链接
+	 * 
+	 * @return
+	 */
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	/**
+	 * 背景颜色
+	 * 
+	 * @return
+	 */
+	public String getBackground() {
+		return background;
+	}
+
+	public void setBackground(String background) {
+		this.background = background;
+	}
+
+	/**
+	 * 点击背景图片跳转链接
+	 * 
+	 * @return
+	 */
+	public String getImgLink() {
+		return imgLink;
+	}
+
+	public void setImgLink(String imgLink) {
+		this.imgLink = imgLink;
+	}
+
+	/**
+	 * 主标题 <code>font-size: 24px</code>
+	 * 
+	 * @return
+	 */
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	/**
+	 * 副标题/描述 <code>font-size: 18px</code>
+	 * 
+	 * @return
+	 */
+	public String getSubTitle() {
+		return subTitle;
+	}
+
+	public void setSubTitle(String subTitle) {
+		this.subTitle = subTitle;
+	}
+
+	/**
+	 * 按钮,json格式
+	 * 
+	 * <pre>
+	 * [{
+	 * "text": "查看详情", 
+	 * "link": "http://www.example.com"
+	 * },{
+	 * "text": "立即购买", 
+	 * "link": "http://www.example.com"
+	 * }]
+	 * </pre>
+	 * 
+	 * @return
+	 */
+	public String getBtns() {
+		return btns;
+	}
+
+	public void setBtns(String btns) {
+		this.btns = btns;
+	}
+
+	/**
+	 * 文字颜色,包括标题、副标题、按钮的
+	 * 
+	 * @return
+	 */
+	public String getColor() {
+		return color;
+	}
+
+	public void setColor(String color) {
+		this.color = color;
+	}
+
+	/**
+	 * 相对文字颜色,focus、active时切换,包括标题、副标题、按钮的
+	 * 
+	 * @return
+	 */
+	public String getReserveColor() {
+		return reserveColor;
+	}
+
+	public void setReserveColor(String reserveColor) {
+		this.reserveColor = reserveColor;
+	}
+
+}

+ 279 - 0
account-server/src/main/java/com/uas/account/entity/ChangeAdminDetail.java

@@ -0,0 +1,279 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 更换管理员申请的详细信息
+ * 
+ * @author hejq
+ * @time 创建时间:2016年10月9日
+ */
+public class ChangeAdminDetail implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private Long id;
+	private String enName;
+	private Long enUu;
+	private String businessCodeImage;
+	private String businessCode;
+	private String adminName;
+	private String adminTel;
+	private String adminEmail;
+	private Long adminuu;
+	private String b2bUrl;
+	private Integer auditStatus;
+	private String auditResult;
+	private Short auditSendStatus;
+	private Integer dbStatus;
+	private Integer b2bStatus;
+	private Date enDate;
+	private String adminPassword;
+	private String appId;
+	private String method;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 企业名称
+	 */
+	public String getEnName() {
+		return enName;
+	}
+
+	public void setEnName(String enName) {
+		this.enName = enName;
+	}
+
+	/**
+	 * 企业UU
+	 * 
+	 * @return
+	 */
+	public Long getEnUu() {
+		return enUu;
+	}
+
+	public void setEnUu(Long enUu) {
+		this.enUu = enUu;
+	}
+
+	/**
+	 * 执照存储路径
+	 * 
+	 * @return
+	 */
+	public String getBusinessCodeImage() {
+		return businessCodeImage;
+	}
+
+	public void setBusinessCodeImage(String businessCodeImage) {
+		this.businessCodeImage = businessCodeImage;
+	}
+
+	/**
+	 * 企业执照号
+	 * 
+	 * @return
+	 */
+	public String getBusinessCode() {
+		return businessCode;
+	}
+
+	public void setBusinessCode(String businessCode) {
+		this.businessCode = businessCode;
+	}
+
+	/**
+	 * 管理员姓名
+	 * 
+	 * @return
+	 */
+	public String getAdminName() {
+		return adminName;
+	}
+
+	public void setAdminName(String adminName) {
+		this.adminName = adminName;
+	}
+
+	/**
+	 * 管理员手机
+	 * 
+	 * @return
+	 */
+	public String getAdminTel() {
+		return adminTel;
+	}
+
+	public void setAdminTel(String adminTel) {
+		this.adminTel = adminTel;
+	}
+
+	/**
+	 * 管理员邮箱
+	 * 
+	 * @return
+	 */
+	public String getAdminEmail() {
+		return adminEmail;
+	}
+
+	public void setAdminEmail(String adminEmail) {
+		this.adminEmail = adminEmail;
+	}
+
+	/**
+	 * 管理员uu
+	 * 
+	 * @return
+	 */
+	public Long getAdminuu() {
+		return adminuu;
+	}
+
+	public void setAdminuu(Long adminuu) {
+		this.adminuu = adminuu;
+	}
+
+	/**
+	 * 企业域名
+	 * 
+	 * @return
+	 */
+	public String getB2bUrl() {
+		return b2bUrl;
+	}
+
+	public void setB2bUrl(String b2bUrl) {
+		this.b2bUrl = b2bUrl;
+	}
+
+	/**
+	 * 申请审核状态
+	 * 
+	 * @return
+	 */
+	public Integer getAuditStatus() {
+		return auditStatus;
+	}
+
+	public void setAuditStatus(Integer auditStatus) {
+		this.auditStatus = auditStatus;
+	}
+
+	/**
+	 * 审核结果
+	 * 
+	 * @return
+	 */
+	public String getAuditResult() {
+		return auditResult;
+	}
+
+	public void setAuditResult(String auditResult) {
+		this.auditResult = auditResult;
+	}
+
+	/**
+	 * 资料上传状态
+	 * 
+	 * @return
+	 */
+	public Short getAuditSendStatus() {
+		return auditSendStatus;
+	}
+
+	public void setAuditSendStatus(Short auditSendStatus) {
+		this.auditSendStatus = auditSendStatus;
+	}
+
+	/**
+	 * 数据库账套情况
+	 * 
+	 * @return
+	 */
+	public Integer getDbStatus() {
+		return dbStatus;
+	}
+
+	public void setDbStatus(Integer dbStatus) {
+		this.dbStatus = dbStatus;
+	}
+
+	/**
+	 * 企业B2B状态 ( 申请中 未激活 已激活)
+	 * 
+	 * @return
+	 */
+	public Integer getB2bStatus() {
+		return b2bStatus;
+	}
+
+	public void setB2bStatus(Integer b2bStatus) {
+		this.b2bStatus = b2bStatus;
+	}
+
+	/**
+	 * 申请时间
+	 * 
+	 * @return
+	 */
+	public Date getEnDate() {
+		return enDate;
+	}
+
+	public void setEnDate(Date enDate) {
+		this.enDate = enDate;
+	}
+
+	/**
+	 * 管理员密码
+	 * 
+	 * @return
+	 */
+	public String getAdminPassword() {
+		return adminPassword;
+	}
+
+	public void setAdminPassword(String adminPassword) {
+		this.adminPassword = adminPassword;
+	}
+
+	/**
+	 * appId
+	 * 
+	 * @return
+	 */
+	public String getAppId() {
+		return appId;
+	}
+
+	public void setAppId(String appId) {
+		this.appId = appId;
+	}
+
+	/**
+	 * 更换的方法,删除或替换
+	 * 
+	 * @return
+	 */
+	public String getMethod() {
+		return method;
+	}
+
+	public void setMethod(String method) {
+		this.method = method;
+	}
+
+}

+ 35 - 0
account-server/src/main/java/com/uas/account/entity/FileUrl.java

@@ -0,0 +1,35 @@
+package com.uas.account.entity;
+
+/**
+ * 文件服务器的基本链接
+ *
+ * @author yuj 2017-10-12 14:53
+ */
+public class FileUrl {
+
+    /**
+     * 文件上传
+     */
+    public final static String FILE_UPLOAD = "http://10.10.100.200:9999/file/upload";
+
+
+    /**
+     * 文件下载
+     */
+    public final static String FILE_DOWNLOAD = "http://10.10.100.200:9999/file/download";
+
+    /**
+     * 文件删除
+     */
+    public final static String FILE_DELETE = "http://10.10.100.200:9999/file/delete";
+
+    /**
+     * 文件信息
+     */
+    public final static String FILE_INFO = "http://10.10.100.200:9999/file/info";
+
+    /**
+     * 文件额外属性
+     */
+    public final static String FILE_METADATA = "http://10.10.100.200:9999/file/metadata";
+}

+ 192 - 0
account-server/src/main/java/com/uas/account/entity/InvitationRecord.java

@@ -0,0 +1,192 @@
+package com.uas.account.entity;
+
+import java.util.Date;
+
+/**
+ * 合作伙伴邀请记录
+ * 
+ * @author hejq
+ * @time 创建时间:2017年7月28日
+ */
+public class InvitationRecord {
+
+	private Long id;
+	
+	/**
+	 * 邀请企业uu
+	 */
+	private Long enuu;
+	
+	/**
+	 * 邀请注册营业执照号
+	 */
+	private String bussinesscode;
+
+	/**
+	 * 用户uu
+	 */
+	private Long useruu;
+
+	/**
+	 * 最后一次邀请时间
+	 */
+	private Date date;
+
+	/**
+	 * 邀请的客户名称
+	 */
+	private String vendname;
+
+	/**
+	 * 邀请的用户名称
+	 */
+	private String vendusername;
+
+	/**
+	 * 邀请的用户的电话
+	 */
+	private String vendusertel;
+
+	/**
+	 * 邀请的用户的邮箱
+	 */
+	private String venduseremail;
+
+	/**
+	 * 可能出现重复邀请的情况,记录邀请次数
+	 */
+	private Integer count;
+
+	/**
+	 * 是否已激活
+	 */
+	private Short active;
+
+	/**
+	 * 相同名称企业的数量
+	 */
+	private Integer samecount;
+
+	/**
+	 * 企业uu(如果有相同名称的设置方便查询)
+	 */
+	private Long venduu;
+
+	/**
+	 * 邀请来源,如果设置了来源是ERP,需要自动添加为供应商
+	 */
+	private String source;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public String getBussinesscode() {
+		return bussinesscode;
+	}
+
+	public void setBussinesscode(String bussinesscode) {
+		this.bussinesscode = bussinesscode;
+	}
+
+	public Long getUseruu() {
+		return useruu;
+	}
+
+	public void setUseruu(Long useruu) {
+		this.useruu = useruu;
+	}
+
+	public Date getDate() {
+		return date;
+	}
+
+	public void setDate(Date date) {
+		this.date = date;
+	}
+
+	public String getVendname() {
+		return vendname;
+	}
+
+	public void setVendname(String vendname) {
+		this.vendname = vendname;
+	}
+
+	public String getVendusertel() {
+		return vendusertel;
+	}
+
+	public void setVendusertel(String vendusertel) {
+		this.vendusertel = vendusertel;
+	}
+
+	public String getVenduseremail() {
+		return venduseremail;
+	}
+
+	public void setVenduseremail(String venduseremail) {
+		this.venduseremail = venduseremail;
+	}
+
+	public Integer getCount() {
+		return count;
+	}
+
+	public void setCount(Integer count) {
+		this.count = count;
+	}
+
+	public String getVendusername() {
+		return vendusername;
+	}
+
+	public void setVendusername(String vendusername) {
+		this.vendusername = vendusername;
+	}
+
+	public Short getActive() {
+		return active;
+	}
+
+	public void setActive(Short active) {
+		this.active = active;
+	}
+
+	public Integer getSamecount() {
+		return samecount;
+	}
+
+	public void setSamecount(Integer samecount) {
+		this.samecount = samecount;
+	}
+
+	public Long getVenduu() {
+		return venduu;
+	}
+
+	public void setVenduu(Long venduu) {
+		this.venduu = venduu;
+	}
+
+	public String getSource() {
+		return source;
+	}
+
+	public void setSource(String source) {
+		this.source = source;
+	}
+
+}

+ 152 - 0
account-server/src/main/java/com/uas/account/entity/Log.java

@@ -0,0 +1,152 @@
+package com.uas.account.entity;
+
+import java.util.Date;
+
+/**
+ * 日志
+ * 
+ * @author yingp
+ * 
+ */
+public class Log {
+
+	public static final String defaultLogger = "sys";
+	private String name;
+	private Date logDate;
+	// logLevel
+	private String level;
+	private String msg;
+	private String detailMsg;
+	private String key;
+
+	public Log() {
+		this.logDate = new Date();
+		this.name = defaultLogger;
+	}
+
+	public Log(String name, String level, String key, String msg, Object detailMsg) {
+		this();
+		this.level = level;
+		this.msg = msg;
+		this.detailMsg = detailMsg != null ? detailMsg.toString() : null;
+		this.name = name == null ? defaultLogger : name;
+		this.key = key;
+	}
+
+	public static Log info(String msg) {
+		return info(msg, null);
+	}
+
+	public static Log info(String msg, Object detailMsg) {
+		return new Log(null, "INFO", null, msg, detailMsg);
+	}
+
+	public static Log info(String name, String msg, Object detailMsg) {
+		return new Log(name, "INFO", null, msg, detailMsg);
+	}
+
+	public static Log info(String name, String key, String msg, Object detailMsg) {
+		return new Log(name, "INFO", key, msg, detailMsg);
+	}
+
+	public static Log warn(String msg) {
+		return warn(msg, null);
+	}
+
+	public static Log warn(String msg, Object detailMsg) {
+		return new Log(null, "WARN", null, msg, detailMsg);
+	}
+
+	public static Log warn(String name, String msg, Object detailMsg) {
+		return new Log(name, "WARN", null, msg, detailMsg);
+	}
+
+	public static Log warn(String name, String key, String msg, Object detailMsg) {
+		return new Log(name, "WARN", key, msg, detailMsg);
+	}
+
+	public static Log error(String msg) {
+		return error(msg, null);
+	}
+
+	public static Log error(String msg, Object detailMsg) {
+		return new Log(null, "ERROR", null, msg, detailMsg);
+	}
+
+	public static Log error(String name, String msg, Object detailMsg) {
+		return new Log(name, "ERROR", null, msg, detailMsg);
+	}
+
+	public static Log error(String name, String key, String msg, Object detailMsg) {
+		return new Log(name, "ERROR", key, msg, detailMsg);
+	}
+
+	/**
+	 * 记录时间
+	 * 
+	 * @return
+	 */
+	public Date getLogDate() {
+		return logDate;
+	}
+
+	public void setLogDate(Date logDate) {
+		this.logDate = logDate;
+	}
+
+	/**
+	 * 错误级别:INFO、WARN、ERROR
+	 * 
+	 * @param level
+	 */
+	public String getLevel() {
+		return level;
+	}
+
+	public void setLevel(String level) {
+		this.level = level;
+	}
+
+	/**
+	 * 日志消息
+	 * 
+	 * @return
+	 */
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	/**
+	 * 详细情况
+	 * 
+	 * @return
+	 */
+	public String getDetailMsg() {
+		return detailMsg;
+	}
+
+	public void setDetailMsg(String detailMsg) {
+		this.detailMsg = detailMsg;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public void setKey(String key) {
+		this.key = key;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+}

+ 54 - 0
account-server/src/main/java/com/uas/account/entity/Setting.java

@@ -0,0 +1,54 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+
+public class Setting implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private String description;
+	private String key;
+	private String value;
+	private Integer deleteable;
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public void setKey(String key) {
+		this.key = key;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	/**
+	 * 是否允许删除
+	 * 
+	 * @return
+	 */
+	public Integer getDeleteable() {
+		return deleteable;
+	}
+
+	public void setDeleteable(Integer deleteable) {
+		this.deleteable = deleteable;
+	}
+
+}

+ 116 - 0
account-server/src/main/java/com/uas/account/entity/Token.java

@@ -0,0 +1,116 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.uas.account.core.util.StringUtil;
+
+public class Token implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private String id;
+
+	private Object bind;
+
+	private Date time;
+
+	private int expires_in;
+
+	private String tel;
+
+	private String email;
+
+	/**
+	 * 60秒过期
+	 */
+	public final static int default_expires_in = 60;
+
+	public Token() {
+	}
+
+	public Token(Object bindObject) {
+		this(bindObject, default_expires_in);
+	}
+
+	public Token(Object bindObject, int expires_in) {
+		this(StringUtil.uuid(), bindObject, expires_in);
+	}
+
+	public Token(String id, Object bindObject, int expires_in) {
+		this.id = id;
+		this.bind = bindObject;
+		this.time = new Date();
+		this.expires_in = expires_in;
+	}
+
+	public Date getTime() {
+		return time;
+	}
+
+	public void setTime(Date time) {
+		this.time = time;
+	}
+
+	public int getExpires_in() {
+		return expires_in;
+	}
+
+	public void setExpires_in(int expires_in) {
+		this.expires_in = expires_in;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Object getBind() {
+		return bind;
+	}
+
+	public void setBind(Object bind) {
+		this.bind = bind;
+	}
+
+	/**
+	 * 是否过期
+	 * 
+	 * @return
+	 */
+	public boolean isExpired() {
+		return System.currentTimeMillis() - this.time.getTime() > expires_in * 1000;
+	}
+
+	/**
+	 * 验证码绑定的手机号
+	 *
+	 * @return
+	 */
+	public String getTel() {
+		return tel;
+	}
+
+	public void setTel(String tel) {
+		this.tel = tel;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	/**
+	 * 验证码绑定的邮箱
+	 *
+	 * @return
+	 */
+	public void setEmail(String email) {
+		this.email = email;
+	}
+}

+ 115 - 0
account-server/src/main/java/com/uas/account/entity/UserFailed.java

@@ -0,0 +1,115 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.uas.account.AccountConfig;
+
+/**
+ * 调用业务系统的回调接口如果出错,会记录下来以便下次有机会再次同步过去
+ * 
+ * @author yingp
+ *
+ */
+public class UserFailed implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private Long id;
+	private Date callTime;
+	private String errMsg;
+	private Long fromId;
+	private Long fromSpaceId;
+	private String fromAppId;
+	private Long toSpaceId;
+	private String toAppId;
+
+	public UserFailed() {
+	}
+
+	public UserFailed(User to, Exception e) {
+		this.callTime = new Date();
+		this.errMsg = e.getMessage();
+		this.fromId = to.getId();
+		this.fromAppId = AccountConfig.ACCOUNT_CENTER;
+		this.toSpaceId = to.getSpaceId();
+		this.toAppId = to.getAppId();
+	}
+
+	public UserFailed(User from, User to, Exception e) {
+		this.callTime = new Date();
+		this.errMsg = e.getMessage();
+		this.fromId = from.getId();
+		this.fromSpaceId = from.getSpaceId();
+		this.fromAppId = from.getAppId();
+		this.toSpaceId = to.getSpaceId();
+		this.toAppId = to.getAppId();
+	}
+
+	public Date getCallTime() {
+		return callTime;
+	}
+
+	public void setCallTime(Date callTime) {
+		this.callTime = callTime;
+	}
+
+	public String getErrMsg() {
+		return errMsg;
+	}
+
+	public void setErrMsg(String errMsg) {
+		this.errMsg = errMsg;
+	}
+
+	public Long getFromId() {
+		return fromId;
+	}
+
+	public void setFromId(Long fromId) {
+		this.fromId = fromId;
+	}
+
+	public Long getFromSpaceId() {
+		return fromSpaceId;
+	}
+
+	public void setFromSpaceId(Long fromSpaceId) {
+		this.fromSpaceId = fromSpaceId;
+	}
+
+	public String getFromAppId() {
+		return fromAppId;
+	}
+
+	public void setFromAppId(String fromAppId) {
+		this.fromAppId = fromAppId;
+	}
+
+	public Long getToSpaceId() {
+		return toSpaceId;
+	}
+
+	public void setToSpaceId(Long toSpaceId) {
+		this.toSpaceId = toSpaceId;
+	}
+
+	public String getToAppId() {
+		return toAppId;
+	}
+
+	public void setToAppId(String toAppId) {
+		this.toAppId = toAppId;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+}

+ 37 - 0
account-server/src/main/java/com/uas/account/entity/UserSpaceAndUserInfo.java

@@ -0,0 +1,37 @@
+package com.uas.account.entity;
+
+/**
+ * 记录简单的用户和企业的信息
+ * 
+ * @author hejq
+ * @time 创建时间:2017年6月29日
+ */
+public class UserSpaceAndUserInfo {
+
+	/**
+	 * 企业注册后生产的编号
+	 */
+	String spaceDialectUID;
+
+	/**
+	 * 个人注册后生产的编号
+	 */
+	String userDialectUID;
+
+	public String getSpaceDialectUID() {
+		return spaceDialectUID;
+	}
+
+	public void setSpaceDialectUID(String spaceDialectUID) {
+		this.spaceDialectUID = spaceDialectUID;
+	}
+
+	public String getUserDialectUID() {
+		return userDialectUID;
+	}
+
+	public void setUserDialectUID(String userDialectUID) {
+		this.userDialectUID = userDialectUID;
+	}
+
+}

+ 83 - 0
account-server/src/main/java/com/uas/account/entity/UserSpaceDetailInfo.java

@@ -0,0 +1,83 @@
+package com.uas.account.entity;
+
+public class UserSpaceDetailInfo {
+
+	/**
+	 * 企业名称
+	 */
+	private String company;
+
+	/**
+	 * 地址
+	 */
+	private String address;
+
+	/**
+	 * 管理员姓名
+	 */
+	private String username;
+
+	/**
+	 * 管理员电话
+	 */
+	private String usertel;
+
+	/**
+	 * 管理员imid
+	 */
+	private String imid;
+
+	/**
+	 * 管理员邮箱
+	 */
+	private String email;
+
+	public String getCompany() {
+		return company;
+	}
+
+	public void setCompany(String company) {
+		this.company = company;
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getUsertel() {
+		return usertel;
+	}
+
+	public void setUsertel(String usertel) {
+		this.usertel = usertel;
+	}
+
+	public String getImid() {
+		return imid;
+	}
+
+	public void setImid(String imid) {
+		this.imid = imid;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+}

+ 94 - 0
account-server/src/main/java/com/uas/account/entity/UserSpaceFailed.java

@@ -0,0 +1,94 @@
+package com.uas.account.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.uas.account.AccountConfig;
+
+/**
+ * 调用业务系统的回调接口如果出错,会记录下来以便下次有机会再次同步过去
+ * 
+ * @author yingp
+ *
+ */
+public class UserSpaceFailed implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private Long id;
+	private Date callTime;
+	private String errMsg;
+	private Long fromId;
+	private String fromAppId;
+	private String toAppId;
+
+	public UserSpaceFailed() {
+	}
+
+	public UserSpaceFailed(UserSpace to, Exception e) {
+		this.callTime = new Date();
+		this.errMsg = e.getMessage();
+		this.fromId = to.getId();
+		this.fromAppId = AccountConfig.ACCOUNT_CENTER;
+		this.toAppId = to.getAppId();
+	}
+
+	public UserSpaceFailed(UserSpace from, UserSpace to, Exception e) {
+		this.callTime = new Date();
+		this.errMsg = e.getMessage();
+		this.fromId = from.getId();
+		this.fromAppId = from.getAppId();
+		this.toAppId = to.getAppId();
+	}
+
+	public Date getCallTime() {
+		return callTime;
+	}
+
+	public void setCallTime(Date callTime) {
+		this.callTime = callTime;
+	}
+
+	public String getErrMsg() {
+		return errMsg;
+	}
+
+	public void setErrMsg(String errMsg) {
+		this.errMsg = errMsg;
+	}
+
+	public Long getFromId() {
+		return fromId;
+	}
+
+	public void setFromId(Long fromId) {
+		this.fromId = fromId;
+	}
+
+	public String getFromAppId() {
+		return fromAppId;
+	}
+
+	public void setFromAppId(String fromAppId) {
+		this.fromAppId = fromAppId;
+	}
+
+	public String getToAppId() {
+		return toAppId;
+	}
+
+	public void setToAppId(String toAppId) {
+		this.toAppId = toAppId;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+}

+ 23 - 0
account-server/src/main/java/com/uas/account/exception/VisibleError.java

@@ -0,0 +1,23 @@
+package com.uas.account.exception;
+
+/**
+ * 可以直接显示给用户的错误信息
+ * 
+ * @author yingp
+ *
+ */
+public class VisibleError extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1438034231246046546L;
+
+	public VisibleError() {
+	}
+
+	public VisibleError(String errMsg) {
+		super(errMsg);
+	}
+
+}

+ 57 - 0
account-server/src/main/java/com/uas/account/service/AppService.java

@@ -0,0 +1,57 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import com.uas.account.entity.App;
+import com.uas.account.viewmodel.AppUseView;
+import com.uas.account.viewmodel.AppView;
+
+public interface AppService {
+
+	App save(App app);
+
+	App findOne(String uid);
+
+	/**
+	 * 返回应用的ID集合
+	 * 
+	 * @return
+	 */
+	List<String> findAllIDs();
+
+	/**
+	 * 返回指定用户已注册的应用的ID集合
+	 * 
+	 * @return
+	 */
+	List<String> findAllIDsByUser(long userId);
+
+	/**
+	 * 查找全部
+	 * 
+	 * @return
+	 */
+	List<App> findAll();
+
+	/**
+	 * 查找全部(简化视图1)
+	 * 
+	 * @return
+	 */
+	List<AppView> findAllView();
+
+	/**
+	 * 查找全部可注册应用(简化视图2)
+	 * 
+	 * @return
+	 */
+	List<AppUseView> findAllPublicUseView();
+
+	/**
+	 * 删除
+	 * 
+	 * @param uid
+	 */
+	void delete(String uid);
+
+}

+ 99 - 0
account-server/src/main/java/com/uas/account/service/AppServiceImpl.java

@@ -0,0 +1,99 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import com.uas.account.AccountConfig;
+import com.uas.account.core.Const;
+import com.uas.account.dao.AppDao;
+import com.uas.account.entity.App;
+import com.uas.account.entity.App.Scope;
+import com.uas.account.exception.VisibleError;
+import com.uas.account.viewmodel.AppUseView;
+import com.uas.account.viewmodel.AppView;
+
+@Service
+public class AppServiceImpl implements AppService {
+
+	@Autowired
+	private AppDao appDao;
+
+	@Override
+	@CacheEvict(value = "apps", key = "#app.uid")
+	public App save(App app) {
+		if (!StringUtils.isEmpty(app.getUserControl())) {
+			App control = appDao.findOne(app.getUserControl());
+			if (control == null) {
+				throw new VisibleError("应用" + app.getUserControl() + "不存在");
+			} else {
+				app.setBackSpaceUrl(null);
+				app.setBackUserUrl(null);
+				app.setCopyApps(null);
+				app.setEncryFormat(null);
+				app.setPublicKey(null);
+				app.setScope(control.getScope());
+				// no register
+				app.setDefaultUse(Const.NO);
+			}
+		}
+		if (app.getScope() == null) {
+			app.setScope(Scope.PRIVATE.name());
+		}
+		if (app.getDefaultUse() == null || AccountConfig.ACCOUNT_CENTER.equals(app.getUid())) {
+			app.setDefaultUse(Const.NO);
+		}
+		if (null == app.getDialectEnable()) {
+			app.setDialectEnable(Const.NO);
+		}
+		return appDao.save(app);
+	}
+
+	@Override
+	public List<String> findAllIDs() {
+		return appDao.findAllIDs();
+	}
+
+	@Override
+	public List<String> findAllIDsByUser(long userId) {
+		return appDao.findAllIDsByUser(userId);
+	}
+
+	@Override
+	@Cacheable(value = "apps")
+	public App findOne(String uid) {
+		return appDao.findOne(uid);
+	}
+
+	@Override
+	public List<App> findAll() {
+		return appDao.findAll();
+	}
+
+	@Override
+	@CacheEvict(value = "apps")
+	public void delete(String uid) {
+		App app = appDao.findOne(uid);
+		if (app != null) {
+			if (app.getUsCount() > 0) {
+				throw new VisibleError("该应用已被启用,无法删除!");
+			} else {
+				appDao.delete(uid);
+			}
+		}
+	}
+
+	@Override
+	public List<AppView> findAllView() {
+		return appDao.findAllView();
+	}
+
+	@Override
+	public List<AppUseView> findAllPublicUseView() {
+		return appDao.findAllPublicUseView();
+	}
+}

+ 21 - 0
account-server/src/main/java/com/uas/account/service/AssetService.java

@@ -0,0 +1,21 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.Asset;
+import com.uas.account.viewmodel.AssetView;
+
+public interface AssetService {
+
+	Asset save(Asset asset);
+
+	Asset findOne(Long id);
+
+	List<AssetView> findByApp(String appId);
+
+	void delete(Asset asset);
+
+	Page<Asset> findAll(String appId, int pageNumber, int pageSize);
+
+}

+ 72 - 0
account-server/src/main/java/com/uas/account/service/AssetServiceImpl.java

@@ -0,0 +1,72 @@
+package com.uas.account.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import com.uas.account.core.Page;
+import com.uas.account.dao.AssetDao;
+import com.uas.account.entity.Asset;
+import com.uas.account.viewmodel.AssetView;
+
+@Service
+public class AssetServiceImpl implements AssetService {
+
+	@Autowired
+	private AssetDao assetDao;
+
+	@Override
+	@CacheEvict(value = "assets", allEntries = true)
+	public Asset save(Asset asset) {
+		if (null == asset.getIdx() || asset.getIdx() <= 0) {
+			asset.setIdx(assetDao.countByApp(asset.getAppId()) + 1);
+		}
+		if (asset.getBackground() == null) {
+			asset.setBackground("transparent");
+		}
+		if (asset.getColor() == null) {
+			asset.setColor("inherit");
+		}
+		if (asset.getReserveColor() == null) {
+			asset.setReserveColor(asset.getColor());
+		}
+		return assetDao.save(asset);
+	}
+
+	@Override
+	@Cacheable(value = "assets", key = "'appId:'+#appId")
+	public List<AssetView> findByApp(String appId) {
+		List<Asset> assets = assetDao.findByApp(appId);
+		List<AssetView> assetViews = null;
+		if (assets != null) {
+			assetViews = new ArrayList<AssetView>();
+			for (Asset asset : assets) {
+				// convert to https
+				asset.setUrl(asset.getUrl().replace("http://", "https://"));
+				assetViews.add(new AssetView(asset));
+			}
+		}
+		return assetViews;
+	}
+
+	@Override
+	@CacheEvict(value = "assets", key = "'appId:'+#asset.appId")
+	public void delete(Asset asset) {
+		assetDao.delete(asset);
+	}
+
+	@Override
+	public Page<Asset> findAll(String appId, int pageNumber, int pageSize) {
+		return assetDao.findAll(appId, pageNumber, pageSize);
+	}
+
+	@Override
+	public Asset findOne(Long id) {
+		return assetDao.findOne(id);
+	}
+
+}

+ 89 - 0
account-server/src/main/java/com/uas/account/service/ChangeAdminService.java

@@ -0,0 +1,89 @@
+package com.uas.account.service;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.App;
+import com.uas.account.entity.ChangeAdminDetail;
+
+public interface ChangeAdminService {
+
+	/**
+	 * 存储相关信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	ChangeAdminDetail save(ChangeAdminDetail detail);
+
+	/**
+	 * 上传的相关信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	ChangeAdminDetail submit(ChangeAdminDetail detail);
+
+	/**
+	 * 查找所有 的申请更换管理员的信息
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAll(int pageNumber, int pageSize, String name, String businessCode, String userName);
+
+	/**
+	 * 查询审核通过
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAllEnable(int pageNumber, int pageSize, String name, String businessCode,
+			String userName);
+
+	/**
+	 * 查询待审核
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAllUnAudit(int pageNumber, int pageSize, String name, String businessCode,
+			String userName);
+
+	/**
+	 * 查询审核未通过
+	 * 
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<ChangeAdminDetail> findAllUnApply(int pageNumber, int pageSize, String name, String businessCode,
+			String userName);
+
+	/**
+	 * 审核通过
+	 * 
+	 * @param businessCode
+	 */
+	void enable(String businessCode);
+
+	/**
+	 * 审核未通过
+	 * 
+	 * @param businessCode
+	 * @param reason
+	 */
+	void disable(String businessCode, String reason);
+
+	/**
+	 * 通过businessCode查询详细信息
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	ChangeAdminDetail findByBusinessCode(String businessCode);
+
+	ChangeAdminDetail syncUserToApp(App app, ChangeAdminDetail detail) throws Exception;
+
+}

+ 326 - 0
account-server/src/main/java/com/uas/account/service/ChangeAdminServiceImpl.java

@@ -0,0 +1,326 @@
+package com.uas.account.service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import com.alibaba.dubbo.common.utils.CollectionUtils;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.account.core.Logger;
+import com.uas.account.core.Page;
+import com.uas.account.core.Status;
+import com.uas.account.dao.ChangeAdminDao;
+import com.uas.account.dao.UserDao;
+import com.uas.account.dao.UserSpaceDao;
+import com.uas.account.entity.App;
+import com.uas.account.entity.ChangeAdminDetail;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserDetail;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.entity.UserView;
+import com.uas.account.exception.VisibleError;
+import com.uas.account.util.AccountUtils;
+import com.uas.sso.common.util.HttpUtil;
+import com.uas.sso.common.util.HttpUtil.ResponseWrap;
+
+@Service
+@Transactional
+public class ChangeAdminServiceImpl implements ChangeAdminService {
+
+	@Autowired
+	private ChangeAdminDao changeAdminDao;
+
+	@Autowired
+	private UserSpaceService userSpaceService;
+
+	@Autowired
+	private UserSpaceDao userSpaceDao;
+
+	@Autowired
+	private UserDao userDao;
+
+	@Autowired
+	private AppService appService;
+
+	@Autowired
+	private UserService userService;
+
+	@Autowired
+	private SysDataToMallService sysService;
+
+	private Logger logger = Logger.getLogger();
+
+	private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
+
+	@Override
+	public ChangeAdminDetail save(ChangeAdminDetail detail) {
+		return changeAdminDao.save(detail);
+	}
+
+	@Override
+	@CacheEvict(value = "userspaces", allEntries = true)
+	public ChangeAdminDetail submit(ChangeAdminDetail detail) {
+		ChangeAdminDetail oldDetail = findByBusinessCode(detail.getBusinessCode());
+		if (oldDetail != null && oldDetail.getAuditStatus().equals(Status.UNAUDIT.value())) {
+			throw new VisibleError("请勿重复提交申请!");
+		}
+		UserSpace userSpace = userSpaceService.findOne("b2b", StringUtils.trimAllWhitespace(detail.getBusinessCode()));
+		if (userSpace == null) {
+			throw new VisibleError("暂未查询到与“" + detail.getEnName() + "”相关的企业信息,请检查输入的企业与营业执照是否匹配或先进行注册");
+		}
+		detail.setAuditStatus(Status.UNAUDIT.value());
+		detail.setEnDate(new Date());
+		detail.setBusinessCode(detail.getBusinessCode());
+		detail.setEnName(detail.getEnName());
+		detail.setAdminName(detail.getAdminName());
+		detail.setAdminTel(detail.getAdminTel());
+		detail.setAdminEmail(detail.getAdminEmail());
+		detail.setAppId(userSpace.getAppId());
+		detail.setMethod(detail.getMethod());
+		// 存储管理员信息
+		UserDetail userDetail = userService.findOne(detail.getAdminTel());
+		List<User> user = userService.findByUID(detail.getAdminTel());
+		if (CollectionUtils.isEmpty(user)) {
+			for (User users : user) {
+				users.setAppId(userSpace.getAppId());
+				users.setName(detail.getAdminName());
+				users.setUid(detail.getAdminTel());
+				users.setSecondUID(detail.getAdminEmail());
+				users.setSpaceUID(detail.getBusinessCode());
+				User userInfo = user.get(0);
+				userDao.save(userInfo);
+				if (userDetail == null) {
+					UserDetail userDetails = new UserDetail();
+					userDetails.setEmail(detail.getAdminEmail());
+					userDetails.setName(detail.getAdminName());
+					userDetails.setMobile(detail.getAdminTel());
+					logger.info("userDao", String.format("通过{Mobile, %s}存储管理员信息", userDetails.getMobile()));
+					userDao.save(userDetails);
+					// 传过去给b2b,生成UU号
+					App app = appService.findOne(detail.getAppId());
+					try {
+						userService.syncUserToApp(app, userInfo, userDetails);
+					} catch (Exception e) {
+						logger.error("更换管理员", String.format("传输数据出错", userDetails.getName(), userDetails.getMobile()));
+						e.printStackTrace();
+					}
+					userService.save(userInfo, userDetails);
+				}
+
+			}
+		}
+
+		logger.info(this.getClass(), detail.getBusinessCode(),
+				String.format("更换管理员申请信息存储,%s From: %s, To: sso", userSpace.getName(), userSpace.getAppId()),
+				userSpace);
+		return changeAdminDao.save(detail);
+	}
+
+	/**
+	 * 查询所有信息
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAll(int pageNumber, int pageSize, String name, String businessCode,
+			String userName) {
+		return changeAdminDao.findAll(pageNumber, pageSize, null, name, businessCode, userName);
+	}
+
+	/**
+	 * 审核通过
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAllEnable(int pageNumber, int pageSize, String name, String businessCode,
+			String userName) {
+		return changeAdminDao.findAll(pageNumber, pageSize, Status.ENABLED.value(), name, businessCode, userName);
+	}
+
+	/**
+	 * 待审核
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAllUnAudit(int pageNumber, int pageSize, String name, String businessCode,
+			String userName) {
+		return changeAdminDao.findAll(pageNumber, pageSize, Status.UNAUDIT.value(), name, businessCode, userName);
+	}
+
+	/**
+	 * 审核失败
+	 */
+	@Override
+	public Page<ChangeAdminDetail> findAllUnApply(int pageNumber, int pageSize, String name, String businessCode,
+			String userName) {
+		return changeAdminDao.findAll(pageNumber, pageSize, Status.UNAPPLY.value(), name, businessCode, userName);
+	}
+
+	/**
+	 * 更换管理员审核通过
+	 */
+	@Override
+	public void enable(String businessCode) {
+		UserSpaceDetail detail = userSpaceService.findByBusinessCode(businessCode);
+		ChangeAdminDetail chdetail = findByBusinessCode(businessCode);
+		UserDetail userdetail = userDao.findOne(chdetail.getAdminTel());
+		UserSpace userSpace = userSpaceService.findOne(chdetail.getAppId(), businessCode);
+		App app = appService.findOne(chdetail.getAppId());
+		if (userdetail == null) {
+			UserDetail userDetailInfo = new UserDetail();
+			userDetailInfo.setEmail(chdetail.getAdminEmail());
+			userDetailInfo.setName(chdetail.getAdminName());
+			userDetailInfo.setMobile(chdetail.getAdminTel());
+			userDetailInfo.setJob("管理员");
+			userDao.save(userDetailInfo);
+			User newUser = new User();
+			newUser.setAppId(chdetail.getAppId());
+			newUser.setName(chdetail.getAdminName());
+			newUser.setUid(chdetail.getAdminTel());
+			newUser.setSecondUID(chdetail.getAdminEmail());
+
+			// 同步到商务平台
+			try {
+				userService.syncUserToApp(app, newUser, userDetailInfo);
+			} catch (Exception error) {
+				throw new VisibleError(error.getMessage());
+			}
+			try {
+				AccountUtils.saveUser(chdetail.getAdminTel(), businessCode, userDetailInfo);
+			} catch (Exception e) {
+				throw new VisibleError("新增用户失败");
+			}
+
+			newUser.setSpaceId(userSpace.getId());
+			newUser.setSpaceUID(businessCode);
+			newUser.setSpaceDialectUID(userSpace.getDialectUID());
+			List<UserView> user = userService.findByAppAndUID(chdetail.getAppId(), chdetail.getAdminTel());
+			if (!CollectionUtils.isEmpty(user)) {
+				newUser.setPassword(user.get(0).getPassword());
+				newUser.setSalt(user.get(0).getSalt());
+				newUser.setDialectUID(user.get(0).getDialectUID());
+				chdetail.setAdminuu(Long.valueOf(newUser.getDialectUID()));
+			}
+			newUser = userDao.save(newUser);
+			try {
+				sysService.user(newUser);
+				logger.info("更换管理员", "同步用户" + newUser.getDialectUID() + "到商城,time:" + sdf.format(new Date()));
+			} catch (Exception e) {
+				logger.error("更换管理员", "同步用户" + newUser.getDialectUID() + "到商城失败,time" + sdf.format(new Date()));
+			}
+		} else if (userdetail != null) {
+			User userInfo = userDao.findOne(chdetail.getAppId(), businessCode, chdetail.getAdminTel());
+			if (userInfo == null) {
+				User userInfos = new User();
+				UserDetail userDetail = new UserDetail();
+				userInfos.setAppId(chdetail.getAppId());
+				userInfos.setName(chdetail.getAdminName());
+				userInfos.setUid(chdetail.getAdminTel());
+				userInfos.setSecondUID(chdetail.getAdminEmail());
+				userInfos.setSpaceId(userSpace.getId());
+				userInfos.setSpaceUID(businessCode);
+				userInfos.setSpaceDialectUID(userSpace.getDialectUID());
+				List<UserView> user = userService.findByAppAndUID(chdetail.getAppId(), chdetail.getAdminTel());
+				if (!CollectionUtils.isEmpty(user)) {
+					userInfos.setPassword(user.get(0).getPassword());
+					userInfos.setSalt(user.get(0).getSalt());
+					userInfos.setDialectUID(user.get(0).getDialectUID());
+					chdetail.setAdminuu(Long.valueOf(userInfos.getDialectUID()));
+				}
+				userInfos = userDao.save(userInfos);
+				try {
+					sysService.user(userInfos);
+					logger.info("更换管理员", "同步用户" + userInfos.getDialectUID() + "到商城,time:" + sdf.format(new Date()));
+				} catch (Exception e) {
+					logger.error("更换管理员", "同步用户" + userInfos.getDialectUID() + "到商城失败,time" + sdf.format(new Date()));
+				}
+				userDetail.setEmail(chdetail.getAdminEmail());
+				userDetail.setName(chdetail.getAdminName());
+				userDetail.setMobile(chdetail.getAdminTel());
+				userdetail.setJob("管理员");
+				// 同步到商务平台
+				try {
+					userService.syncUserToApp(app, userInfos, userDetail);
+				} catch (Exception error) {
+					throw new VisibleError(error.getMessage());
+				}
+				try {
+					AccountUtils.saveUser(chdetail.getAdminTel(), businessCode, userDetail);
+				} catch (Exception e) {
+					throw new VisibleError("新增用户失败");
+				}
+				userDao.save(userDetail);
+			}
+		}
+		if (detail != null) {
+			detail.setAdminName(chdetail.getAdminName());
+			detail.setAdminTel(chdetail.getAdminTel());
+			detail.setAdminEmail(chdetail.getAdminEmail());
+			detail.setBusinessCode(chdetail.getBusinessCode());
+			userSpaceDao.save(detail);
+		} else {
+			throw new VisibleError("找不到该企业资料");
+		}
+		chdetail.setAuditStatus(Status.ENABLED.value());
+		chdetail = changeAdminDao.save(chdetail);
+		try {
+			logger.info(this.getClass(), detail.getBusinessCode(),
+					String.format("更换管理员审核通操作,%s From: %s, To: b2b", userSpace.getName(), userSpace.getAppId()),
+					userSpace);
+			syncUserToApp(app, chdetail);
+			sysService.ChangeAdmin(chdetail);
+		} catch (Exception e) {
+			logger.error(this.getClass(), detail.getBusinessCode(),
+					String.format("更换管理员审核通操作,%s From: %s, To: b2b", userSpace.getName(), userSpace.getAppId()),
+					userSpace);
+			throw new VisibleError(e.getMessage());
+		}
+
+	}
+
+	/**
+	 * 更换管理员审核未通过
+	 */
+	@Override
+	public void disable(String businessCode, String reason) {
+		ChangeAdminDetail detail = findByBusinessCode(businessCode);
+		if (detail != null) {
+			detail.setAuditStatus(Status.UNAPPLY.value());
+			detail.setAuditResult(reason);
+			detail.setEnDate(new Date());
+			logger.info(this.getClass(), detail.getBusinessCode(),
+					String.format("更换管理员审核未通过操作,%s From: %s, to: sso", detail.getEnName(), detail.getAppId()), detail);
+			changeAdminDao.save(detail);
+		} else {
+			logger.error("更换管理员", String.format("根据{businessCode: %s}没有找到企业信息", businessCode));
+			throw new VisibleError("找不到该企业资料");
+		}
+	}
+
+	/**
+	 * 通过businessCode查询所有信息
+	 */
+	@Override
+	public ChangeAdminDetail findByBusinessCode(String businessCode) {
+		return changeAdminDao.findByBusinessCode(businessCode);
+	}
+
+	@Override
+	public ChangeAdminDetail syncUserToApp(App app, ChangeAdminDetail detail) throws Exception {
+		String url = app.getBackChangeAdminUrl();
+		detail.setEnDate(null); // 不需要传输时间,而且时间需要进行转换处理
+		if (!StringUtils.isEmpty(url)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(detail));
+			ResponseWrap res = HttpUtil.doPost(url, formData);// 5分钟超时
+			if (!res.isSuccess())
+				throw new Exception(res.getContent());
+		}
+		return null;
+	}
+
+
+}

+ 239 - 0
account-server/src/main/java/com/uas/account/service/PartnershipService.java

@@ -0,0 +1,239 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.core.Page;
+import com.uas.account.entity.InvitationRecord;
+import com.uas.account.entity.PartnershipRecord;
+import com.uas.account.entity.RequsetStatus;
+
+public interface PartnershipService {
+
+	/**
+	 * 通过id发送请求
+	 * 
+	 * @param id
+	 *            (id 是ac$us$detail中的id)
+	 */
+	void sendRequestById(Long id);
+
+	/**
+	 * 查询发出的申请<br>
+	 * 待审核
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllSendUnAudit(String name, String businessCode, String custUserName, int pageNumber,
+			int pageSize);
+
+	/**
+	 * 查询发出的申请<br>
+	 * 已通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllSendEnable(String name, String businessCode, String custUserName, int pageNumber,
+			int pageSize);
+
+	/**
+	 * 查询发出的申请<br>
+	 * 未通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllSendUnApply(String name, String businessCode, String custUserName, int pageNumber,
+			int pageSize);
+
+	/**
+	 * 查询收到的申请<br>
+	 * 待审核
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllReceivedUnAudit(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize);
+
+	/**
+	 * 查询收到的申请<br>
+	 * 已通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllReceivedEnable(String name, String businessCode, String custUserName, int pageNumber,
+			int pageSize);
+
+	/**
+	 * 查询收到的申请<br>
+	 * 未通过
+	 * 
+	 * @param name
+	 * @param businessCode
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findAllReceivedUnApply(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize);
+
+	/**
+	 * 发出的请求详情
+	 * 
+	 * @param id
+	 * @return
+	 */
+	PartnershipRecord findSendRequestById(Long id);
+
+	/**
+	 * 收到的请求的详情
+	 * 
+	 * @param id
+	 * @return
+	 */
+	PartnershipRecord findReceivedRequestById(Long id);
+
+	/**
+	 * 审核通过
+	 * 
+	 * @param id
+	 * @return
+	 */
+	void enable(Long id);
+
+	/**
+	 * 审核不通过
+	 * 
+	 * @param id
+	 * @param reason
+	 */
+	void disable(Long id, String reason);
+
+	/**
+	 * 再次申请
+	 * 
+	 * @param id
+	 */
+	void resendRequestById(Long id);
+
+	/**
+	 * 通过申请企业和客户的执照查询信息
+	 * 
+	 * @param custuid
+	 * @param venduid
+	 * @return
+	 */
+	PartnershipRecord findBycustUIDAndVendUID(String custuid, String venduid);
+
+	/**
+	 * 发出的请求统计
+	 * 
+	 * @return
+	 */
+	ModelMap getsendRequestCount();
+
+	/**
+	 * 收到的请求统计
+	 * 
+	 * @return
+	 */
+	ModelMap getreceivedRequestCount();
+
+	/**
+	 * 通过营业执照查询收到的申请
+	 * 
+	 * @param businessCode
+	 * @param status
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	public Page<PartnershipRecord> findBySpaceUidAndStatusCode(String businessCode, Integer status, String keyword,
+			int pageNumber, int pageSize);
+
+	/**
+	 * 通过营业执照查询收到的申请,过滤掉已存在合作关系的企业
+	 *
+	 * @param businessCode
+	 * @param status
+	 * @param keyword
+	 * @param pageNumber
+	 * @param pageSize
+	 * @return
+	 */
+	Page<PartnershipRecord> findBySpaceUidAndStatusCodeFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs, int pageNumber, int pageSize);
+
+	/**
+	 * 增加一条合作关系记录
+	 * 
+	 * @param record
+	 * @return
+	 */
+	public ModelMap addPartner(PartnershipRecord record);
+
+	ModelMap synchronizePartner(PartnershipRecord record);
+
+	/**
+	 * 同意请求
+	 * 
+	 * @param id
+	 * @param vendUid
+	 * @return
+	 */
+	public ModelMap acceptRequest(Long id, String vendUserTel, String appId);
+
+	/**
+	 * 拒绝请求
+	 * 
+	 * @param id
+	 * @param vendUid
+	 * @return
+	 */
+	public ModelMap rejectRequest(Long id, String vendUserTel, String reason, String appId);
+
+	/**
+	 * 通过当前企业号和企业列表中的企业号查询申请状态
+	 * 
+	 * @param custUid
+	 * @param vendUid
+	 * @return
+	 */
+	public RequsetStatus getRequestByCustUidAndVendUid(String custUid, String vendUid);
+
+	/**
+	 * 获取收到的待处理请求
+	 * 
+	 * @param businessCode
+	 * @return
+	 */
+	public ModelMap getRequestTodo(String businessCode);
+
+	/**
+	 * 保存邀请记录
+	 * 
+	 * @param record
+	 */
+	public void invite(InvitationRecord record);
+
+}

+ 458 - 0
account-server/src/main/java/com/uas/account/service/PartnershipServiceImpl.java

@@ -0,0 +1,458 @@
+package com.uas.account.service;
+
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+
+import com.uas.account.core.Const;
+import com.uas.account.core.Logger;
+import com.uas.account.core.Page;
+import com.uas.account.core.Status;
+import com.uas.account.dao.PartnershipRecordDao;
+import com.uas.account.dao.UserDao;
+import com.uas.account.dao.UserSpaceDao;
+import com.uas.account.entity.InvitationRecord;
+import com.uas.account.entity.PartnershipRecord;
+import com.uas.account.entity.RequsetStatus;
+import com.uas.account.entity.Setting;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+import com.uas.account.entity.UserView;
+import com.uas.account.exception.VisibleError;
+import com.uas.account.support.SystemSession;
+import com.uas.message.mail.service.MailService;
+import com.uas.message.sms.service.SmsService;
+
+@Service
+public class PartnershipServiceImpl implements PartnershipService {
+
+	@Autowired
+	private UserSpaceService userSpaceService;
+	@Autowired
+	private PartnershipRecordDao partnershipRecordDao;
+	@Autowired
+	private UserSpaceDao userSpaceDao;
+	@Autowired
+	private SettingService settingService;
+	@Autowired
+	private MailService mailService;
+	@Autowired
+	private SmsService smsService;
+	@Autowired
+	private UserDao userDao;
+
+	private Logger logger = Logger.getLogger();
+
+	@Override
+	public void sendRequestById(Long id) {
+		UserSpaceDetail detail = userSpaceService.findById(id);
+		User custuser = SystemSession.getUser();
+		if (custuser == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		UserSpaceDetail custEnter = userSpaceDao.findByBusinessCode(custuser.getSpaceUID());
+		if (custEnter.getBusinessCode().equals(detail.getBusinessCode())) {
+			throw new VisibleError("不能添加自己企业为合作伙伴");
+		}
+		PartnershipRecord oldSendRecord = partnershipRecordDao.findByCustUIDAndVendUID(custEnter.getBusinessCode(),
+				detail.getBusinessCode());
+		if (oldSendRecord != null) {
+			if (oldSendRecord.getStatusCode().equals(Status.UNAUDIT.value())) {
+				throw new VisibleError("对该企业的申请已经存在,请不要重复申请");
+			}
+
+			if (oldSendRecord.getStatusCode().equals(Status.ENABLED.value())) {
+				throw new VisibleError("该企业已经同意您的申请,请不要重复申请");
+			}
+		}
+		PartnershipRecord oldReceiveRecord = partnershipRecordDao.findByCustUIDAndVendUID(detail.getBusinessCode(),
+				custEnter.getBusinessCode());
+		if (oldReceiveRecord != null) {
+			if (!oldReceiveRecord.getStatusCode().equals(Status.UNAPPLY.value())) {
+				throw new VisibleError("该企业已经向您发出了申请,请注意查看您收到的申请记录");
+			}
+		}
+		UserSpace userSpace = userSpaceService.findOne("b2b", detail.getBusinessCode());
+		ModelMap data = new ModelMap();
+		data.put("vendorusername", detail.getAdminName());
+		data.put("vendorname", detail.getName());
+		data.put("custname", custEnter.getName());
+		if (null == userSpace) {// 未开通商务平台,提醒开通
+			Setting mailTplId = settingService.findOne("templateForSendEmailWhenAddPartner");
+			if (!StringUtils.isEmpty(mailTplId) && !StringUtils.isEmpty(detail.getAdminEmail())) {
+				mailService.send(mailTplId.getValue(), detail.getAdminEmail(), data);
+			}
+			Setting smsTplId = settingService.findOne("templateForSendSmsWhenAddPartner");
+			if (!StringUtils.isEmpty(smsTplId) && !StringUtils.isEmpty(detail.getAdminTel())) {
+				smsService.send(smsTplId.getValue(), detail.getAdminTel(),
+						new Object[] { detail.getAdminName(), detail.getName(), custEnter.getName() });
+			}
+		}
+		PartnershipRecord record = new PartnershipRecord();
+		record.setVendUID(detail.getBusinessCode());
+		record.setVendName(detail.getName());
+		record.setStatusCode(Status.UNAUDIT.value());
+		record.setStatus(Status.UNAUDIT.getPhrase());
+		record.setRequestDate(new Date());
+		record.setCustName(custEnter.getName());
+		record.setCustUID(custEnter.getBusinessCode());
+		record.setCustUserName(custuser.getName());
+		record.setCustUserCode(custuser.getDialectUID());
+		record.setCustUserTel(custuser.getUid());
+		record.setCustUserEmail(custuser.getSecondUID());
+		record.setAppId(custuser.getAppId());
+		logger.info(custuser.getDialectUID() + "向" + detail.getName() + "发出了建立合作关系的申请");
+		partnershipRecordDao.save(record);
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllSendUnAudit(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllSendView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(), null,
+				Status.UNAUDIT.value());
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllSendEnable(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllSendView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(), null,
+				Status.ENABLED.value());
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllSendUnApply(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllSendView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(), null,
+				Status.UNAPPLY.value());
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllReceivedUnAudit(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllReceivedView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(),
+				Status.UNAUDIT.value());
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllReceivedEnable(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllReceivedView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(), Status.ENABLED.value());
+	}
+
+	@Override
+	public Page<PartnershipRecord> findAllReceivedUnApply(String name, String businessCode, String custUserName,
+			int pageNumber, int pageSize) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findAllReceivedView(pageNumber, businessCode, custUserName, pageSize, name,
+				user.getSpaceUID(), Status.UNAPPLY.value());
+	}
+
+	@Override
+	public PartnershipRecord findSendRequestById(Long id) {
+		return partnershipRecordDao.findById(id);
+	}
+
+	@Override
+	public PartnershipRecord findReceivedRequestById(Long id) {
+		return partnershipRecordDao.findById(id);
+	}
+
+	@Override
+	public void enable(Long id) {
+		User user = SystemSession.getUser();
+		PartnershipRecord partner = partnershipRecordDao.findById(id);
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		if (partner == null) {
+			throw new VisibleError("未找到该企业信息");
+		}
+		if (partner != null && user != null) {
+			logger.info(user.getName() + "同意了" + partner.getCustName() + "的请求");
+			partner.setStatus(Status.ENABLED.getPhrase());
+			partner.setStatusCode(Status.ENABLED.value());
+			partner.setOperateDate(new Date());
+			partner.setVendUserCode(user.getDialectUID());
+			partner.setVendUserTel(user.getUid());
+			partner.setVendUserEmail(user.getSecondUID());
+			partner.setVendUserName(user.getName());
+			partner.setId(id);
+			partnershipRecordDao.save(partner);
+		}
+
+	}
+
+	@Override
+	public void disable(Long id, String reason) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当期用户信息,请先通过UAS系统或商务平台登录");
+		} else {
+			PartnershipRecord partner = partnershipRecordDao.findById(id);
+			logger.info(user.getName() + "拒绝了" + partner.getCustName() + "的请求");
+			partner.setStatus(Status.UNAPPLY.getPhrase());
+			partner.setStatusCode(Status.UNAPPLY.value());
+			partner.setReason(reason);
+			partner.setOperateDate(new Date());
+			partner.setVendUserCode(user.getDialectUID());
+			partner.setVendUserName(user.getName());
+			partner.setVendUserEmail(user.getSecondUID());
+			partner.setVendUserName(user.getName());
+			partner.setId(id);
+			partnershipRecordDao.save(partner);
+		}
+	}
+
+	@Override
+	public void resendRequestById(Long id) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当期用户信息,请先通过UAS系统或商务平台登录");
+		} else {
+			PartnershipRecord partner = partnershipRecordDao.findById(id);
+			logger.info(user.getDialectUID() + "向" + partner.getVendName() + "发出了建立合作关系的申请");
+			partner.setStatus(Status.UNAUDIT.getPhrase());
+			partner.setStatusCode(Status.UNAUDIT.value());
+			partner.setRequestDate(new Date());
+			partner.setCustUserCode(user.getDialectUID());
+			partner.setCustUserEmail(user.getSecondUID());
+			partner.setCustUserName(user.getName());
+			partner.setCustUserTel(user.getUid());
+			partnershipRecordDao.save(partner);
+		}
+	}
+
+	@Override
+	public PartnershipRecord findBycustUIDAndVendUID(String custuid, String venduid) {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		return partnershipRecordDao.findByCustUIDAndVendUID(custuid, venduid);
+	}
+
+	@Override
+	public ModelMap getsendRequestCount() {
+		User user = SystemSession.getUser();
+		if(user==null){
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		ModelMap map = new ModelMap("全部", partnershipRecordDao.getAllSendCount(user.getSpaceUID()));
+		map.addAllAttributes(partnershipRecordDao.getSendRequestCount(user.getSpaceUID()));
+		return map;
+	}
+
+	@Override
+	public ModelMap getreceivedRequestCount() {
+		User user = SystemSession.getUser();
+		if (user == null) {
+			throw new VisibleError("未检测到当前用户信息,请先通过UAS系统或商务平台登录");
+		}
+		ModelMap map = new ModelMap("全部", partnershipRecordDao.getAllReceivedCount(user.getSpaceUID()));
+		map.addAllAttributes(partnershipRecordDao.getReceivedRequestCount(user.getSpaceUID()));
+		return map;
+	}
+
+	@Override
+	public Page<PartnershipRecord> findBySpaceUidAndStatusCode(String businessCode, Integer statusCode, String keyword,
+															   int pageNumber, int pageSize) {
+		return partnershipRecordDao.findBySpaceUidAndStatusCode(businessCode, statusCode, keyword, pageNumber,
+				pageSize);
+	}
+
+	@Override
+	public Page<PartnershipRecord> findBySpaceUidAndStatusCodeFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs,
+															   int pageNumber, int pageSize) {
+		return partnershipRecordDao.findBySpaceUidAndStatusCodeFilterByPartnerUUs(businessCode, statusCode, keyword, partnerUUs, pageNumber,
+				pageSize);
+	}
+
+	@Override
+	public ModelMap addPartner(PartnershipRecord record) {
+		ModelMap map = new ModelMap();
+		PartnershipRecord oldSendRecord = partnershipRecordDao.findByCustUIDAndVendUID(record.getCustUID(),
+				record.getVendUID());
+		PartnershipRecord oldReceiveRecord = partnershipRecordDao.findByCustUIDAndVendUID(record.getVendUID(),
+				record.getCustUID());
+		if (oldSendRecord != null && !oldSendRecord.getStatusCode().equals(Status.UNAPPLY.value())) {
+			if (oldSendRecord.getStatusCode().equals(Status.UNAUDIT.value())) {
+				map.put("error", "对该企业的申请已发出,请耐心等待对方审核");
+			}
+			if (oldSendRecord.getStatusCode().equals(Status.ENABLED.value())) {
+				map.put("error", "您们已是合作伙伴,请不要重复申请");
+			}
+		}
+		if (oldReceiveRecord != null && !oldReceiveRecord.getStatusCode().equals(Status.UNAPPLY.value())) {
+			if (!oldReceiveRecord.getStatusCode().equals(Status.UNAPPLY.value())) {
+				map.put("error", "该企业已经向您发出了申请,请注意查看您收到的申请记录");
+			}
+			if (!oldReceiveRecord.getStatusCode().equals(Status.ENABLED.value())) {
+				map.put("error", "您们已是合作伙伴,请不要重复申请");
+			}
+		}
+		if ((oldSendRecord == null && oldReceiveRecord == null)
+				|| (oldSendRecord != null && oldSendRecord.getStatusCode().equals(Status.UNAPPLY.value()))
+				|| (oldReceiveRecord != null && !oldReceiveRecord.getStatusCode().equals(Status.UNAPPLY.value()))) {
+			UserSpace userSpace = userSpaceService.findOne("b2b", record.getVendUID());
+			UserSpaceDetail detail = userSpaceService.findByBusinessCode(record.getVendUID());
+			ModelMap data = new ModelMap();
+			data.put("vendorusername", detail.getAdminName());
+			data.put("vendorname", detail.getName());
+			data.put("custname", record.getCustName());
+			if (null == userSpace) {// 未开通商务平台,提醒开通
+				Setting mailTplId = settingService.findOne("templateForSendEmailWhenAddPartner");
+				if (!StringUtils.isEmpty(mailTplId) && !StringUtils.isEmpty(detail.getAdminEmail())) {
+					mailService.send(mailTplId.getValue(), detail.getAdminEmail(), data);
+				}
+				Setting smsTplId = settingService.findOne("templateForSendSmsWhenAddPartner");
+				if (!StringUtils.isEmpty(smsTplId) && !StringUtils.isEmpty(detail.getAdminTel())) {
+					smsService.send(smsTplId.getValue(), detail.getAdminTel(),
+							new Object[] { detail.getAdminName(), detail.getName(), record.getCustName() });
+				}
+			}
+			record.setStatusCode(Status.UNAUDIT.value());
+			record.setStatus(Status.UNAUDIT.getPhrase());
+			record.setRequestDate(new Date());
+			logger.info(record.getCustName() + "向" + detail.getName() + "发出了建立合作关系的申请");
+			partnershipRecordDao.save(record);
+			map.put("success", "申请发送成功");
+		}
+		return map;
+	}
+
+	@Override
+	public ModelMap synchronizePartner(PartnershipRecord record) {
+		ModelMap map = new ModelMap();
+		PartnershipRecord oldSendRecord = partnershipRecordDao.findByCustUIDAndVendUID(record.getCustUID(),
+				record.getVendUID());
+		PartnershipRecord oldReceiveRecord = partnershipRecordDao.findByCustUIDAndVendUID(record.getVendUID(),
+				record.getCustUID());
+		if (oldSendRecord != null && !oldSendRecord.getStatusCode().equals(Status.ENABLED.value())) {
+			oldSendRecord.setStatusCode(Status.ENABLED.value());
+			oldSendRecord.setStatus(Status.ENABLED.getPhrase());
+			oldSendRecord.setRequestDate(new Date());
+			oldSendRecord.setOperateDate(new Date());
+			partnershipRecordDao.save(oldSendRecord);
+		}
+		if (oldReceiveRecord != null && !oldReceiveRecord.getStatusCode().equals(Status.ENABLED.value())) {
+			oldReceiveRecord.setStatusCode(Status.ENABLED.value());
+			oldReceiveRecord.setStatus(Status.ENABLED.getPhrase());
+			oldReceiveRecord.setRequestDate(new Date());
+			oldReceiveRecord.setOperateDate(new Date());
+			partnershipRecordDao.save(oldReceiveRecord);
+		}
+		if (oldSendRecord == null && oldReceiveRecord == null) {
+			record.setStatusCode(Status.ENABLED.value());
+			record.setStatus(Status.ENABLED.getPhrase());
+			record.setRequestDate(new Date());
+			record.setOperateDate(new Date());
+			logger.info(record.getCustName() + "与" + record.getVendName() + "通过单据交易建立了合作关系");
+			partnershipRecordDao.save(record);
+			map.put("success", "建立合作关系成功");
+		}
+		return map;
+	}
+
+	@Override
+	public ModelMap acceptRequest(Long id, String vendUserTel, String appId) {
+		PartnershipRecord record = partnershipRecordDao.findById(id);
+		ModelMap map = new ModelMap();
+		List<UserView> user = userDao.findByAppAndUID(appId, vendUserTel);
+		record.setAppId(appId);
+		record.setOperateDate(new Date());
+		record.setVendUserName(user.get(0).getName());
+		record.setStatus(Status.ENABLED.getPhrase());
+		record.setStatusCode(Status.ENABLED.value());
+		partnershipRecordDao.save(record);
+		map.put("success", "审核成功");
+		return map;
+	}
+
+	@Override
+	public ModelMap rejectRequest(Long id, String reason, String vendUserTel, String appId) {
+		PartnershipRecord record = partnershipRecordDao.findById(id);
+		ModelMap map = new ModelMap();
+		List<UserView> user = userDao.findByAppAndUID(appId, vendUserTel);
+		record.setAppId(appId);
+		record.setOperateDate(new Date());
+		record.setVendUserName(user.get(0).getName());
+		record.setStatus(Status.UNAPPLY.getPhrase());
+		record.setStatusCode(Status.UNAPPLY.value());
+		record.setReason(reason);
+		partnershipRecordDao.save(record);
+		map.put("success", "审核成功");
+		return map;
+	}
+
+	@Override
+	public RequsetStatus getRequestByCustUidAndVendUid(String custUid, String vendUid) {
+		RequsetStatus request = new RequsetStatus();
+		PartnershipRecord receivedRequest = partnershipRecordDao.findByCustUIDAndVendUID(custUid, vendUid);
+		if (receivedRequest != null) {// 发出申请
+			request.setCustUid(custUid);
+			request.setVendUid(vendUid);
+			request.setStatusCode(receivedRequest.getStatusCode());
+			request.setMethod(Const.NO);
+			if (receivedRequest.getStatusCode() == 311) {
+				request.setNeedAgreed(Const.YES);
+			} else {
+				request.setNeedAgreed(Const.NO);
+			}
+		}
+		PartnershipRecord sendRequest = partnershipRecordDao.findByCustUIDAndVendUID(vendUid, custUid);
+		if (sendRequest != null) {// 收到申请
+			request.setCustUid(custUid);
+			request.setVendUid(vendUid);
+			request.setStatusCode(sendRequest.getStatusCode());
+			request.setMethod(Const.YES);
+			request.setNeedAgreed(Const.NO);
+		}
+		return request;
+	}
+
+	@Override
+	public ModelMap getRequestTodo(String businessCode) {
+		ModelMap map = new ModelMap();
+		map.put("todo", partnershipRecordDao.getRequestTodo(businessCode));
+		return map;
+	}
+
+	@Override
+	public void invite(InvitationRecord record) {
+		partnershipRecordDao.saveInvitation(record);
+	}
+
+}

+ 25 - 0
account-server/src/main/java/com/uas/account/service/PlatformManageService.java

@@ -0,0 +1,25 @@
+package com.uas.account.service;
+
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.entity.UserSpaceDetail;
+
+public interface PlatformManageService {
+
+	/**
+	 * 修改管理平台中的企业信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	public ModelMap updateEnterpriseInfoInManage(UserSpaceDetail detail, String businessCode);
+
+	/**
+	 * 修改管理平台控制中心的企业信息
+	 * 
+	 * @param detail
+	 * @return
+	 */
+	public ModelMap updateMasterInfoInManage(UserSpaceDetail detail, String businessCode);
+
+}

+ 26 - 0
account-server/src/main/java/com/uas/account/service/PlatformManageServiceImpl.java

@@ -0,0 +1,26 @@
+package com.uas.account.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.dao.PlatfromManageDao;
+import com.uas.account.entity.UserSpaceDetail;
+
+@Service
+public class PlatformManageServiceImpl implements PlatformManageService {
+
+	@Autowired
+	private PlatfromManageDao platfromManageDao;
+
+	@Override
+	public ModelMap updateEnterpriseInfoInManage(UserSpaceDetail detail, String businessCode) {
+		return platfromManageDao.updateEnterpriseInfoInManage(detail, businessCode);
+	}
+
+	@Override
+	public ModelMap updateMasterInfoInManage(UserSpaceDetail detail, String businessCode) {
+		return platfromManageDao.updateMasterInfoInManage(detail, businessCode);
+	}
+
+}

+ 19 - 0
account-server/src/main/java/com/uas/account/service/SettingService.java

@@ -0,0 +1,19 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import com.uas.account.entity.Setting;
+
+public interface SettingService {
+
+	Setting save(Setting setting);
+
+	void save(List<Setting> settings);
+
+	Setting findOne(String key);
+
+	void delete(String key);
+
+	List<Setting> findAll();
+
+}

+ 56 - 0
account-server/src/main/java/com/uas/account/service/SettingServiceImpl.java

@@ -0,0 +1,56 @@
+package com.uas.account.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import com.uas.account.core.Const;
+import com.uas.account.dao.SettingDao;
+import com.uas.account.entity.Setting;
+import com.uas.account.exception.VisibleError;
+
+@Service
+public class SettingServiceImpl implements SettingService {
+
+	@Autowired
+	private SettingDao settingDao;
+
+	@Override
+	@CacheEvict(value = "setting", key = "#setting.key")
+	public Setting save(Setting setting) {
+		return settingDao.save(setting);
+	}
+
+	@Override
+	@CacheEvict(value = "setting", allEntries = true)
+	public void save(List<Setting> settings) {
+		settingDao.save(settings);
+	}
+
+	@Override
+	@Cacheable(value = "setting")
+	public Setting findOne(String key) {
+		return settingDao.findOne(key);
+	}
+
+	@Override
+	@CacheEvict(value = "setting")
+	public void delete(String key) {
+		Setting setting = findOne(key);
+		if (setting != null) {
+			if (Const.NO == setting.getDeleteable()) {
+				throw new VisibleError("该设置不允许删除");
+			}
+			settingDao.delete(key);
+		}
+	}
+
+	@Override
+	public List<Setting> findAll() {
+		return settingDao.findAll();
+	}
+
+}

+ 22 - 0
account-server/src/main/java/com/uas/account/service/SynchrodataToOldPlatService.java

@@ -0,0 +1,22 @@
+package com.uas.account.service;
+
+import org.springframework.ui.ModelMap;
+
+public interface SynchrodataToOldPlatService {
+
+	/**
+	 * 同步数据到旧平台
+	 * 
+	 * @param user
+	 * @return
+	 */
+	public ModelMap synchrodataToOldPlat(Long id);
+
+	/**
+	 * 查询用户当前企业对应的旧平台密码
+	 * 
+	 * @param id
+	 * @return
+	 */
+	public ModelMap findUserPasswordInOldPlat(Long id);
+}

+ 95 - 0
account-server/src/main/java/com/uas/account/service/SynchrodataToOldPlatServiceImpl.java

@@ -0,0 +1,95 @@
+package com.uas.account.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+
+import com.uas.account.dao.SynchrodataToOldPlatDao;
+import com.uas.account.dao.UserDao;
+import com.uas.account.dao.UserSpaceDao;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpaceDetail;
+
+@Service
+public class SynchrodataToOldPlatServiceImpl implements SynchrodataToOldPlatService {
+
+	@Autowired
+	private UserSpaceDao userSpaceDao;
+
+	@Autowired
+	private SynchrodataToOldPlatDao synchrodataToOldPlatDao;
+
+	@Autowired
+	private UserDao userDao;
+
+	@Override
+	public ModelMap synchrodataToOldPlat(Long id) {
+		ModelMap map = new ModelMap();
+		User user = userDao.findOne(id);
+		if (user.getAppId().equals("b2b")) {
+			UserSpaceDetail detail = userSpaceDao.findByBusinessCode(user.getSpaceUID());
+			Long spaceCount = synchrodataToOldPlatDao.findEnterpriseByEnuu(user.getSpaceDialectUID());
+			// 先判断企业是否存在
+			if (spaceCount > 0) {
+				// 直接插入用户信息
+				Long userCount = synchrodataToOldPlatDao.findUserByUserUUAndEnuu(user.getDialectUID(),
+						user.getSpaceDialectUID());
+				if (userCount > 0) {
+					map.put("error", "该用户在旧平台已存在");
+				} else {
+					synchrodataToOldPlatDao.SynchUserToOldPlat(user, detail.getName());
+					userCount = synchrodataToOldPlatDao.findUserByUserUUAndEnuu(user.getDialectUID(),
+							user.getSpaceDialectUID());
+					if (userCount > 0) {
+						map.put("success", "用户添加成功");
+					}
+				}
+			} else {
+				// 先插入企业信息
+				synchrodataToOldPlatDao.SyschUserSpaceToOldPlat(detail, user);
+				spaceCount = synchrodataToOldPlatDao.findEnterpriseByEnuu(user.getSpaceDialectUID());
+				if (spaceCount > 0) {
+					synchrodataToOldPlatDao.SynchUserToOldPlat(user, detail.getName());
+					Long userCount = synchrodataToOldPlatDao.findUserByUserUUAndEnuu(user.getDialectUID(),
+							user.getSpaceDialectUID());
+					if (userCount > 0) {
+						map.put("error", "该用户在旧平台已存在");
+					} else {
+						userCount = synchrodataToOldPlatDao.findUserByUserUUAndEnuu(user.getDialectUID(),
+								user.getSpaceDialectUID());
+						if (userCount > 0) {
+							map.put("success", "用户添加成功");
+						}
+					}
+				}
+			}
+		} else {
+			map.put("error", "只有平台用户才能同步");
+		}
+		return map;
+	}
+
+	@Override
+	public ModelMap findUserPasswordInOldPlat(Long id) {
+		ModelMap map = new ModelMap();
+		User user = userDao.findOne(id);
+		if (user.getAppId().equals("b2b")) {
+			Long userCount = synchrodataToOldPlatDao.findUserByUserUUAndEnuu(user.getDialectUID(),
+					user.getSpaceDialectUID());
+			if (userCount > 0) {
+				String password = synchrodataToOldPlatDao.getUserPassword(user.getDialectUID(),
+						user.getSpaceDialectUID());
+				if (null != password) {
+					map.put("success", "enuu:" + user.getSpaceDialectUID() + ",useruu:" + user.getDialectUID()
+							+ ",password:" + password);
+				}
+			} else {
+				map.put("error", "暂未在旧平台企业中查询到相关人员信息,请先进行同步操作");
+			}
+		} else {
+			map.put("error", "只有平台用户才能查询");
+		}
+		return map;
+	}
+
+}

+ 53 - 0
account-server/src/main/java/com/uas/account/service/SysDataToMallService.java

@@ -0,0 +1,53 @@
+package com.uas.account.service;
+
+import com.uas.account.entity.ChangeAdminDetail;
+import com.uas.account.entity.User;
+import com.uas.account.entity.UserSpace;
+import com.uas.account.entity.UserSpaceDetail;
+
+/**
+ * 同步账户中心的数据到商城
+ * 
+ * @author hejq
+ * @time 创建时间:2017年10月20日
+ */
+public interface SysDataToMallService {
+
+	/**
+	 * 同步用户数据
+	 * 
+	 * @param user
+	 * @throws Exception
+	 */
+	void user(User user) throws Exception;
+
+	/**
+	 * 同步企业数据
+	 * 
+	 * @param userSpace
+	 * @param detail
+	 */
+	void UserSpace(UserSpace userSpace, UserSpaceDetail detail) throws Exception;
+
+	/**
+	 * 更换管理员
+	 * 
+	 * @param chdetail
+	 */
+	void ChangeAdmin(ChangeAdminDetail chdetail);
+
+	/**
+	 * 控制台更改密码同步到商城
+	 * 
+	 * @param user
+	 * @param password
+	 */
+	void changepwd(User user, String password);
+
+    /**
+     * 删除用户同步到商城
+     *
+     * @param user
+     */
+    void reMoveUser(User user);
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов