Browse Source

【BL_2018110014】【二维码分享加入输入已关闭账号的手机号,提交加入时报错】

chenw 7 years ago
parent
commit
ac75b12ddf

+ 8 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountCompanyMapper.java

@@ -81,4 +81,12 @@ public interface AccountCompanyMapper {
      * @return
      */
     int hasBind(@Param("accountId") Long accountId, @Param("companyId") Long companyId);
+
+    /**
+     * 账户公司以前绑定过,现在已解绑
+     * @param accountId
+     * @param companyId
+     * @return
+     */
+    int hasUnBindData(@Param("accountId") Long accountId, @Param("companyId") Long companyId);
 }

+ 6 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountServiceImpl.java

@@ -368,7 +368,12 @@ public class AccountServiceImpl implements AccountService {
 
         Account account = findByMobile(accountAddDTO.getMobile());
         //绑定企业
-        bindCompany(account.getId(), companyId);
+        int count = accountCompanyMapper.hasUnBindData(account.getId(), companyId);
+        if (count > 0) {
+            updateBindCompanyStatus(account.getId(), companyId, "1");
+        }else {
+            bindCompany(account.getId(), companyId);
+        }
         //绑定角色
         bindRoles(account.getId(), accountAddDTO.getRoleIds());
         //清除缓存

+ 3 - 0
base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml

@@ -42,4 +42,7 @@
     <select id="hasBind" resultType="int">
         SELECT COUNT(*) FROM AC_ACCOUNT_COMPANY WHERE ACCOUNT_ID = #{accountId} AND COMPANY_ID = #{companyId} AND STATUS = 1
     </select>
+    <select id="hasUnBindData" resultType="int">
+        SELECT COUNT(*) FROM AC_ACCOUNT_COMPANY WHERE ACCOUNT_ID = #{accountId} AND COMPANY_ID = #{companyId} AND STATUS = 0
+    </select>
 </mapper>