Browse Source

1.更新资金账户

heqinwei 7 years ago
parent
commit
bd442009f3

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java

@@ -38,4 +38,6 @@ public interface BankinformationMapper extends CommonBaseMapper<Bankinformation>
 
 
     int getBankNameSame(@Param("name") String name, @Param("companyId") Long company);
     int getBankNameSame(@Param("name") String name, @Param("companyId") Long company);
 
 
+    int getBankNameSameById(@Param("name") String name, @Param("id") Long id, @Param("companyId") Long company);
+
 }
 }

+ 10 - 5
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java

@@ -53,11 +53,6 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
     @Transactional
     @Transactional
     @Override
     @Override
     public boolean save(Bankinformation bankinformation){
     public boolean save(Bankinformation bankinformation){
-        //判断账户名称是否存在
-        if (bankinformationMapper.getBankNameSame(bankinformation.getBk_bankname(), BaseContextHolder.getCompanyId()) > 0){
-            throw new BizException(BIZ_SAME.getCode(),BIZ_SAME.getMessage());
-        }
-
         bankinformation.setCompanyId(BaseContextHolder.getCompanyId());
         bankinformation.setCompanyId(BaseContextHolder.getCompanyId());
         bankinformation.setBk_income(new Double(0));
         bankinformation.setBk_income(new Double(0));
         bankinformation.setBk_spending(new Double(0));
         bankinformation.setBk_spending(new Double(0));
@@ -108,6 +103,16 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
                 }
                 }
             }
             }
 
 
+
+            //判断账户名称是否存在
+            if (bankinformationMapper.getBankNameSame(bankinformation.getBk_bankname(), BaseContextHolder.getCompanyId()) > 1){
+                throw new BizException(BIZ_SAME.getCode(),BIZ_SAME.getMessage());
+            }else if (bankinformationMapper.getBankNameSame(bankinformation.getBk_bankname(), BaseContextHolder.getCompanyId()) == 1){
+                if (bankinformationMapper.getBankNameSameById(bankinformation.getBk_bankname(), docBaseDTO.getId(),
+                        BaseContextHolder.getCompanyId()) == 1){
+                    throw new BizException(BIZ_SAME.getCode(),BIZ_SAME.getMessage());
+                }
+            }
 //            Long id = bankinformationMapper.selectBankId(bankinformation.getBk_bankcode(), BaseContextHolder.getCompanyId());
 //            Long id = bankinformationMapper.selectBankId(bankinformation.getBk_bankcode(), BaseContextHolder.getCompanyId());
             if (bktion > 0){
             if (bktion > 0){
                     bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
                     bankinformationMapper.updateByPrimaryKeySelective(bankinformation);

+ 4 - 0
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -370,4 +370,8 @@
   <select id="getBankNameSame" resultType="int">
   <select id="getBankNameSame" resultType="int">
     select count(*) from bankinformation where bk_bankname = #{name} and companyId =#{companyId}
     select count(*) from bankinformation where bk_bankname = #{name} and companyId =#{companyId}
   </select>
   </select>
+
+  <select id="getBankNameSameById" resultType="int">
+    select count(*) from bankinformation where bk_bankname = #{name} and bk_id != #{id} and companyId =#{companyId}
+  </select>
 </mapper>
 </mapper>