Эх сурвалжийг харах

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

hy 7 жил өмнө
parent
commit
b48f08af89
28 өөрчлөгдсөн 356 нэмэгдсэн , 60 устгасан
  1. 2 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java
  2. 2 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalanceMapper.java
  3. 5 11
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  4. 3 8
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  5. 21 15
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java
  6. 4 0
      applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml
  7. 4 0
      applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml
  8. 3 0
      applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml
  9. 3 0
      applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml
  10. 4 0
      applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml
  11. 3 0
      applications/money/money-server/src/main/resources/mapper/VerificationMapper.xml
  12. 42 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/CompanyRspDTO.java
  13. 5 0
      base-servers/account/account-server/pom.xml
  14. 2 1
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/AccountApplication.java
  15. 14 2
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountCenterController.java
  16. 45 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java
  17. 2 1
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/AccountCenterService.java
  18. 37 11
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountCenterServiceImpl.java
  19. 3 1
      base-servers/account/account-server/src/main/resources/application.yml
  20. 2 1
      base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml
  21. 35 0
      base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/service/CompanyServiceTest.java
  22. 10 0
      base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/api/SsoUserApi.java
  23. 22 0
      base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/api/SsoUserSpaceApi.java
  24. 19 0
      base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/dto/SsoCheckMobile.java
  25. 10 1
      base-servers/auth/sso-api/src/test/java/com/usoftchina/sso/test/SsoUserApiTest.java
  26. 30 0
      base-servers/auth/sso-api/src/test/java/com/usoftchina/sso/test/SsoUserSpaceApiTeest.java
  27. 11 1
      base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/AuthFilter.java
  28. 13 7
      frontend/saas-web/app/view/money/verification/FormPanel.js

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java

@@ -43,4 +43,6 @@ public interface PaybalanceMapper extends CommonBaseMapper<Paybalance> {
     Double selectThisamount(Integer id);
 
     void updateBankAmount(@Param("bk_thisamount") Double bk_thisamount, @Param("id") Integer id);
+
+    int checkStatus(@Param("id") Long id);
 }

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalanceMapper.java

@@ -50,4 +50,6 @@ public interface RecbalanceMapper extends CommonBaseMapper<Recbalance> {
     Customer selectCustomerByPrimaryKey(Integer bkId);
 
     int updateCustomerByPrimaryKeySelective(Customer record);
+
+    int checkStatus(@Param("id") Long id);
 }

+ 5 - 11
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -202,12 +202,8 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         paybalance.setPb_auditman(BaseContextHolder.getUserName());
         paybalance.setPb_auditdate(new Date());
         pay.setMain(paybalance);
-        Subledger subledger = this.changSubledgerUntil(paybalance);
-        if (subledger.getSl_code() == null){
-            subledgerMapper.insertSelective(subledger);
-        }else {
-            subledgerMapper.updateByPrimaryKeySelective(subledger);
-        }
+        this.changSubledgerUntil(paybalance);
+
         this.changBankUntil(pay);
         DocBaseDTO docBaseDTO = this.insert(pay);
         Long id = docBaseDTO.getId();
@@ -508,15 +504,13 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
 
 
     //插入中间表
-    public Subledger changSubledgerUntil(Paybalance paybalance){
+    public void changSubledgerUntil(Paybalance paybalance){
         Subledger subledger = new Subledger();
-//        BeanUtils.copyProperties(subledger, paybalance);
         subledger.setCompanyId(BaseContextHolder.getCompanyId());
         subledger.setSl_code(paybalance.getPb_code());
         subledger.setSl_kind(paybalance.getPb_kind());
         subledger.setSl_custid(0);
-//        subledger.setSl_vendid(paybalance.getPb_vendid());
-        subledger.setSl_vendid(1);
+        subledger.setSl_vendid(paybalance.getPb_vendid());
         subledger.setSl_date(paybalance.getPb_date());
         subledger.setSl_ym(DateUtils.getYm(paybalance.getPb_date()));
         if (paybalance.getPb_pdamount() == null){
@@ -546,7 +540,7 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         subledger.setSl_remark(subledger.getSl_remark());
         subledger.setSl_preamount(subledger.getSl_preamount());
 
-        return subledger;
+        subledgerMapper.insertSelective(subledger);
     }
 
     //插入bank中间表

+ 3 - 8
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -238,12 +238,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         recbalance.setRb_auditman(BaseContextHolder.getUserName());
         recbalance.setRb_auditdate(new Date());
         rec.setMain(recbalance);
-        Subledger subledger = this.changSubledgerUntil(recbalance);
-        if (subledger.getSl_code() == null){
-            subledgerMapper.insertSelective(subledger);
-        }else {
-            subledgerMapper.updateByPrimaryKeySelective(subledger);
-        }
+        this.changSubledgerUntil(recbalance);
         this.changBankUntil(rec);
         DocBaseDTO docBaseDTO = this.insert(rec);
         Long id = docBaseDTO.getId();
@@ -512,7 +507,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     }
 
     //插入中间表
-    public Subledger changSubledgerUntil(Recbalance recbalance){
+    public void changSubledgerUntil(Recbalance recbalance){
         Subledger subledger = new Subledger();
         subledger.setCompanyId(BaseContextHolder.getCompanyId());
         subledger.setSl_code(recbalance.getRb_code());
@@ -548,7 +543,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         subledger.setSl_remark(subledger.getSl_remark());
         subledger.setSl_preamount(subledger.getSl_preamount());
 
-        return subledger;
+        subledgerMapper.insertSelective(subledger);
     }
 
     //插入bank中间表

+ 21 - 15
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java

@@ -135,6 +135,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         if(id.longValue() > 0 ){
             String kind = verification.getVc_kind();
             verification.setVc_kind(transferKind(kind));
+            verification.setCompanyId(companyId);
+            verification.setUpdateTime(new Date());
+            verification.setUpdaterName(BaseContextHolder.getUserName());
+            verification.setUpdaterId(userId);
             verificationMapper.updateByPrimaryKey(verification);
             baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
             if (!("AUDITED".equals(verification.getVc_statuscode()))) {
@@ -166,6 +170,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
             Long vd_id = detail.getId();
             detail.setVd_vcid(id);
+            detail.setVd_id(Math.toIntExact(vd_id));
             detail.setCompanyId(companyId);
             detail.setVd_ym(numberYM);
             if (vd_id>0){
@@ -176,46 +181,47 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         }
         for (VerificationdetailDTO item : items2) {
             Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
+            Long vcd_id = detail.getId();
             detail.setVcd_vcid(id);
+            detail.setVcd_id(Math.toIntExact(vcd_id));
             detail.setVcd_ym(numberYM);
             detail.setCompanyId(companyId);
-            Long vcd_id = detail.getId();
             if(vcd_id>0){
                 verificationdetailMapper.updateByPrimaryKey(detail);
             }else{
                 verificationdetailMapper.insertSelective(detail);
             }
         }
-        updateCorrespondingData(formdata);
+        updateCorrespondingData(id);
         return baseDTO;
     }
 
-    private void updateCorrespondingData(VerificationFormDTO formdata) {
+    private void updateCorrespondingData(Long id) {
         //获取主表信息
-        VerificationDTO main = formdata.getMain();
+        Verification main = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
         //获取从表1
-        List<VerificationdetDTO> items1 = formdata.getItems1();
+        List<Verificationdet> items1 = verificationdetMapper.selectByFK(id);
         //获取从表2
-        List<VerificationdetailDTO> items2 = formdata.getItems2();
+        List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
 
         String type = main.getVc_kind();
         if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
                 type.equals("receivable_offset_payable")){
             Double total1 = new Double(0);
-            for(VerificationdetDTO det : items1){
+            for(Verificationdet det : items1){
                 Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
                 total1 += nowbalanceDet;
 
                 //单据金额
                 Double amount = det.getVd_amount();
                 //核销金额
-                if(amount>0 && nowbalanceDet<0){
+                if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
                     int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
                     String error = String.format(msg, det.getVd_slkind());
                     throw new BizException(code, error);
                 }
-                if(amount<0 && nowbalanceDet>0){
+                if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
                     int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
                     String error = String.format(msg, det.getVd_slkind());
@@ -223,20 +229,20 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                 }
             }
             Double total2 = new Double(0);
-            for(VerificationdetailDTO detail : items2){
+            for(Verificationdetail detail : items2){
                 Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
                 total2 += nowbalanceDet;
 
                 //单据金额
                 Double amount = detail.getVcd_amount();
                 //核销金额
-                if(amount>0 && nowbalanceDet<0){
+                if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
                     int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
                     String error = String.format(msg, detail.getVcd_slkind());
                     throw new BizException(code, error);
                 }
-                if(amount<0 && nowbalanceDet>0){
+                if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
                     int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
                     String error = String.format(msg, detail.getVcd_slkind());
@@ -247,10 +253,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                 throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
             }
         }else if(type.equals("receivable_to_receivable") || type.equals("payable_to_payable")){
-            for(VerificationdetDTO det : items1){
+            for(Verificationdet det : items1){
                 Double namount = det.getSl_namount()==null?new Double(0):det.getSl_namount();
                 Double nowbalance = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
-                if(namount<nowbalance){
+                if(namount.doubleValue()<nowbalance.doubleValue()){
                     throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
                 }
             }
@@ -403,7 +409,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
     public void deleteDetail1(Long id) {
         if (null != id) {
             Verificationdet verificationdet = verificationdetMapper.selectByPrimaryKey(Integer.valueOf(String.valueOf(id)));
-            Verification verification = verificationMapper.selectByPrimaryKey(verificationdet.getVd_vcid());
+            Verification verification = verificationMapper.selectByPrimaryKey(Math.toIntExact(verificationdet.getVd_vcid()));
             DocBaseDTO baseDTO = new DocBaseDTO();
             baseDTO.setId(id);
             baseDTO.setCode(verification.getVc_code());

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml

@@ -297,4 +297,8 @@
     from fundtransfer
     where ft_id = #{id,jdbcType=INTEGER}
   </select>
+
+  <select id="checkStatus" resultType="int">
+    select count(1) from fundtransfer where ifnull(ft_statuscode,'')='AUDITED' and ft_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml

@@ -375,4 +375,8 @@
     from othreceipts
     where or_id = #{id,jdbcType=INTEGER}
   </select>
+
+  <select id="checkStatus" resultType="int">
+    select count(1) from othreceipts where ifnull(or_statuscode,'')='AUDITED' and or_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 3 - 0
applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml

@@ -373,4 +373,7 @@
     from othspendings
     where os_id = #{id,jdbcType=INTEGER}
   </select>
+  <select id="checkStatus" resultType="int">
+    select count(1) from othspendings where ifnull(os_statuscode,'')='AUDITED' and os_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 3 - 0
applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml

@@ -767,4 +767,7 @@
     </set>
     where ve_id = #{id}
   </update>
+  <select id="checkStatus" resultType="int">
+    select count(1) from paybalance where ifnull(pb_statuscode,'')='AUDITED' and pb_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml

@@ -893,4 +893,8 @@
     </set>
     where cu_id = #{id}
   </update>
+
+  <select id="checkStatus" resultType="int">
+    select count(1) from recbalance where ifnull(rb_statuscode,0)='AUDITED' and rb_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 3 - 0
applications/money/money-server/src/main/resources/mapper/VerificationMapper.xml

@@ -648,4 +648,7 @@
   <select id="validateSetAcount" parameterType="long" resultType="java.lang.String">
     select count(1) from periodsdetail where pd_detno = #{detno} and IFNULL(pd_status,0)=0
   </select>
+  <select id="checkStatus" resultType="int">
+    select count(1) from Verification where ifnull(vc_statuscode,'')='AUDITED' and vc_id= #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 42 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/CompanyRspDTO.java

@@ -14,9 +14,39 @@ public class CompanyRspDTO implements Serializable {
      */
     private String businessCode;
     private String address;
+    /**
+     * 是否是默认企业
+     */
     private boolean default_;
+    /**
+     * 是否开通saas
+     */
     private boolean saas_;
     private String uu;
+    /**
+     * 是否有默认企业
+     */
+    private boolean hasDefaultCompany;
+    /**
+     * 默认企业ID
+     */
+    private Long defaultCompanyId;
+
+    public boolean isHasDefaultCompany() {
+        return hasDefaultCompany;
+    }
+
+    public void setHasDefaultCompany(boolean hasDefaultCompany) {
+        this.hasDefaultCompany = hasDefaultCompany;
+    }
+
+    public Long getDefaultCompanyId() {
+        return defaultCompanyId;
+    }
+
+    public void setDefaultCompanyId(Long defaultCompanyId) {
+        this.defaultCompanyId = defaultCompanyId;
+    }
 
     public String getUu() {
         return uu;
@@ -73,4 +103,16 @@ public class CompanyRspDTO implements Serializable {
     public void setDefault_(boolean default_) {
         this.default_ = default_;
     }
+
+    public CompanyRspDTO(String name, String businessCode, String address, boolean default_, boolean saas_, String uu) {
+        this.name = name;
+        this.businessCode = businessCode;
+        this.address = address;
+        this.default_ = default_;
+        this.saas_ = saas_;
+        this.uu = uu;
+    }
+
+    public CompanyRspDTO() {
+    }
 }

+ 5 - 0
base-servers/account/account-server/pom.xml

@@ -21,6 +21,11 @@
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>account-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>sso-api</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>file-api</artifactId>

+ 2 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/AccountApplication.java

@@ -14,7 +14,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
  */
 @SpringBootApplication
 @EnableEurekaClient
-@EnableFeignClients("com.usoftchina.saas")
+@EnableFeignClients({"com.usoftchina.sso",
+                     "com.usoftchina.saas"})
 @EnableTransactionManagement
 @MapperScan(basePackages = "com.usoftchina.saas.account.mapper")
 @EnableAuthClient

+ 14 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountCenterController.java

@@ -2,9 +2,9 @@ package com.usoftchina.saas.account.controller;
 
 import com.usoftchina.saas.account.dto.BindCompanyDTO;
 import com.usoftchina.saas.account.dto.CompanyAccountDTO;
-import com.usoftchina.saas.account.dto.CompanyListDTO;
 import com.usoftchina.saas.account.service.AccountCenterService;
 import com.usoftchina.saas.base.Result;
+import com.usoftchina.sso.api.SsoUserSpaceApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -14,6 +14,8 @@ public class AccountCenterController {
 
     @Autowired
     private AccountCenterService accountCenterService;
+    @Autowired
+    private SsoUserSpaceApi ssoUserSpaceApi;
 
     /**
      * 信息完善界面   保存接口
@@ -27,7 +29,7 @@ public class AccountCenterController {
 
     /**
      * 获取企业信息列表
-     * @param mobile      用户UU号
+     * @param mobile
      * @return
      */
     @GetMapping("/company/list")
@@ -46,4 +48,14 @@ public class AccountCenterController {
         return Result.success();
     }
 
+    /**
+     * 校验企业名称时候已在账户中心注册过
+     * @param spaceName
+     * @return
+     */
+    @GetMapping("/checkSpaceName")
+    public Result checkSpaceName(@RequestParam("spaceName") String spaceName){
+        return Result.success(ssoUserSpaceApi.checkSpaceName(spaceName));
+    }
+
 }

+ 45 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

@@ -17,6 +17,7 @@ import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
+import com.usoftchina.sso.api.SsoUserApi;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -41,6 +42,9 @@ public class AccountController {
     @Autowired
     private RoleService roleService;
 
+    @Autowired
+    private SsoUserApi ssoUserApi;
+
     /**
      * 注册
      *
@@ -104,6 +108,47 @@ public class AccountController {
         return Result.success();
     }
 
+    /**
+     * SAAS手动添加账户,并默认绑定当前公司
+     *
+     * @param accountCopyDTO
+     * @return
+     */
+    @PostMapping("/register/add")
+    @IgnoreAuth
+    public Result AddAccount(@RequestBody AccountCopyDTO accountCopyDTO) {
+        // 判断是否已注册
+        Account account = accountService.findByUsername(accountCopyDTO.getUsername());
+        if (null != account) {
+            return Result.error(ExceptionCode.USER_NAME_EXIST);
+        }
+        account = accountService.findByMobile(accountCopyDTO.getMobile());
+        if (null != account) {
+            return Result.error(ExceptionCode.USER_MOBILE_EXIST);
+        }
+        account = accountService.findByEmail(accountCopyDTO.getEmail());
+        if (null != account) {
+            return Result.error(ExceptionCode.USER_EMAIL_EXIST);
+        }
+
+        account = BeanMapper.map(accountCopyDTO, Account.class);
+        account.setEnabled(true);
+        accountService.save(account);
+        //绑定企业
+        accountService.bindCompany(account.getId(), BaseContextHolder.getCompanyId());
+        return Result.success();
+    }
+
+    /**
+     * 校验该手机号是否已在账户中心注册
+     * @param mobile
+     * @return
+     */
+    @GetMapping("/checkMobile")
+    public Result checkMobile(@RequestParam("mobile") String mobile){
+        return Result.success(ssoUserApi.checkMobile(mobile));
+    }
+
     /**
      * 修改
      *

+ 2 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/AccountCenterService.java

@@ -6,6 +6,7 @@ import com.usoftchina.saas.account.dto.CompanyRspDTO;
 import com.usoftchina.saas.base.Result;
 
 import java.util.List;
+import java.util.Map;
 
 public interface AccountCenterService {
 
@@ -21,7 +22,7 @@ public interface AccountCenterService {
      * @param mobile
      * @return
      */
-    List<CompanyRspDTO> getCompanyList(String mobile);
+    Map<String, Object> getCompanyList(String mobile);
 
     /**
      * 更新默认企业

+ 37 - 11
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountCenterServiceImpl.java

@@ -11,6 +11,9 @@ import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.exception.ExceptionCode;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.StringUtils;
+import com.usoftchina.sso.api.SsoUserApi;
+import com.usoftchina.sso.dto.SsoUserSpace;
+import com.usoftchina.sso.dto.SsoUserSpaceList;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -19,7 +22,9 @@ import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class AccountCenterServiceImpl implements AccountCenterService {
@@ -29,6 +34,8 @@ public class AccountCenterServiceImpl implements AccountCenterService {
     @Autowired
     private AccountService accountService;
     @Autowired
+    private SsoUserApi ssoUserApi;
+    @Autowired
     private AccountCompanyMapper accountCompanyMapper;
 
     private final String ACCOUNTCNETER_URL_DEV = "http://192.168.253.12:32323";
@@ -89,8 +96,11 @@ public class AccountCenterServiceImpl implements AccountCenterService {
     }
 
     @Override
-    public List<CompanyRspDTO> getCompanyList(String mobile) {
-        List<CompanyRspDTO> result = new ArrayList<CompanyRspDTO>();
+    public Map<String, Object> getCompanyList(String mobile) {
+        Map<String, Object> resultMap = new HashMap<String, Object>();
+        List<CompanyRspDTO> resultList = new ArrayList<CompanyRspDTO>();
+        resultMap.put("hasDefaultCompany", false);
+        resultMap.put("defaultCompanyId", -1);
         //1、获取本SAAS系统的企业信息
         List<CompanyRspDTO> companyRspDTOList = accountCompanyMapper.getCompanyListByAccountMobile(mobile);
         //如果只有一条记录,将该企业设置为默认企业
@@ -99,21 +109,37 @@ public class AccountCenterServiceImpl implements AccountCenterService {
             Long companyId = companyRspDTOList.get(0).getId();
             accountCompanyMapper.bindDefault(accountId, companyId);
         }
-        result.addAll(companyRspDTOList);
+        resultList.addAll(companyRspDTOList);
         //2、优软云返回的企业信息
-        //TODO 通过接口获取优软云的企业信息
+        SsoUserSpaceList ssoUserSpaceList = ssoUserApi.getUserSpacesByMobile(mobile);
+        List<SsoUserSpace> ssoUserSpaces = ssoUserSpaceList.getSpaces();
 
         //3、去重复
-        /*for (CompanyRspDTO companyRspDTO : companyRspDTOList){
-            for (CompanyBaseDTO companyBaseDTO : companyBaseDTOList){
-                if (companyRspDTO.getName().equals(companyBaseDTO.getName())){
-                    companyBaseDTOList.remove(companyRspDTO);
+        for (CompanyRspDTO companyRspDTO : companyRspDTOList) {
+            for (SsoUserSpace ssoUserSpace : ssoUserSpaces) {
+                if (companyRspDTO.getName().equals(ssoUserSpace.getSpaceName())){
+                    ssoUserSpaces.remove(ssoUserSpace);
                 }
             }
+            if (companyRspDTO.isDefault_()){
+                resultMap.put("hasDefaultCompany", true);
+                resultMap.put("defaultCompanyId", companyRspDTO.getId());
+            }
         }
-        List<CompanyRspDTO> companyBaseRspDTOList = BeanMapper.mapList(companyBaseDTOList, CompanyRspDTO.class);
-        result.addAll(companyBaseRspDTOList);*/
-        return result;
+        //构造返回数据
+        for (SsoUserSpace ssoUserSpace : ssoUserSpaces){
+            CompanyRspDTO companyRspDTO = new CompanyRspDTO(
+                    ssoUserSpace.getSpaceName(),
+                    ssoUserSpace.getBusinessCode(),
+                    ssoUserSpace.getRegAddress(),
+                    false,
+                    false,
+                    ssoUserSpace.getSpaceUU().toString()
+            );
+            resultList.add(companyRspDTO);
+        }
+        resultMap.put("spaces", resultList);
+        return resultMap;
     }
 
     @Override

+ 3 - 1
base-servers/account/account-server/src/main/resources/application.yml

@@ -80,4 +80,6 @@ mybatis:
   type-aliases-package: com.usoftchina.saas.account.po,com.usoftchina.saas.account.vo
   mapper-locations: classpath:mapper/*.xml
 auth:
-  public-key: auth/pub.key
+  public-key: auth/pub.key
+sso:
+  base-url: http://192.168.253.12:32323

+ 2 - 1
base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml

@@ -17,7 +17,8 @@
         SELECT cmp.id,cmp.name,cmp.uu,cmp.business_code businessCode,cmp.address,accmp.is_default default_,'1' saas_ from ac_company cmp
         left join ac_account_company accmp on accmp.company_id=cmp.id
         left join ac_account ac on ac.id = accmp.account_id
-        where ac.mobile = #{mobile};
+        where ac.mobile = #{mobile}
+        order by is_default desc
     </select>
     <update id="unBindDefault" >
         UPDATE AC_ACCOUNT_COMPANY SET IS_DEFAULT = 0 WHERE ACCOUNT_ID = #{accountId}

+ 35 - 0
base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/service/CompanyServiceTest.java

@@ -1,12 +1,24 @@
 package com.usoftchina.saas.account.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.usoftchina.saas.account.po.Company;
+import com.usoftchina.saas.utils.StringUtils;
+import com.usoftchina.saas.utils.http.HttpUtil;
 import org.junit.*;
 import org.junit.runner.RunWith;
 import org.junit.runners.MethodSorters;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author yingp
@@ -41,4 +53,27 @@ public class CompanyServiceTest {
         boolean removed = companyService.removeByPrimaryKey(company.getId());
         Assert.assertTrue(removed);
     }
+
+    @Test
+    public void testC_postToAccountCenter(){
+        String url = "/sso/userspace/register/admin";
+        RestTemplate restTemplate = new RestTemplate();
+        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
+        requestEntity.add("spaceName", "测试企业001");
+        requestEntity.add("businessCode", StringUtils.createBusinessCode());
+        requestEntity.add("userUU", "1000027260");
+        String result = restTemplate.postForObject("http://192.168.253.12:32323" + url, requestEntity, String.class);
+        System.out.println(result);
+    }
+
+    @Test
+    public void TestE_getCompanyByMobile() throws Exception {
+        String url = "http://10.1.51.83:8081/api/userspace/erp/info";
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("_by", "mobile");
+        map.put("mobile", "18702604854");
+        HttpUtil.Response response = HttpUtil.sendGetRequest(url, map, true, "b4uzn6vf1db06qmn");
+        JSONObject json = JSONObject.parseObject(response.getResponseText());
+        System.out.println(json.get("content"));
+    }
 }

+ 10 - 0
base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/api/SsoUserApi.java

@@ -2,6 +2,7 @@ package com.usoftchina.sso.api;
 
 import com.usoftchina.sso.auth.Signature;
 import com.usoftchina.sso.config.SsoFeignConfig;
+import com.usoftchina.sso.dto.SsoCheckMobile;
 import com.usoftchina.sso.dto.SsoResult;
 import com.usoftchina.sso.dto.SsoUser;
 import com.usoftchina.sso.dto.SsoUserSpaceList;
@@ -40,6 +41,9 @@ public interface SsoUserApi {
     @Deprecated
     SsoUserSpaceList getUserSpacesByMobile(@RequestParam("mobile") String mobile);
 
+    @GetMapping("/checkMobile")
+    SsoCheckMobile checkMobile(@RequestParam("mobile") String mobile);
+
     @Component
     class DefaultFallback implements SsoUserApi{
         @Override
@@ -51,5 +55,11 @@ public interface SsoUserApi {
         public SsoUserSpaceList getUserSpacesByMobile(String mobile) {
             return null;
         }
+
+        @Override
+        public SsoCheckMobile checkMobile(String mobile) {
+            return null;
+        }
+
     }
 }

+ 22 - 0
base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/api/SsoUserSpaceApi.java

@@ -1,8 +1,30 @@
 package com.usoftchina.sso.api;
 
+import com.usoftchina.sso.dto.SsoResult;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
 /**
  * @author yingp
  * @date 2018/11/23
  */
+@FeignClient(url = "${sso.base-url}", name = "sso-server", fallback = SsoUserApi.DefaultFallback.class)
+@RequestMapping("/api/userspace")
 public interface SsoUserSpaceApi {
+
+    @GetMapping("/checkSpaceName")
+    SsoResult checkSpaceName(@RequestParam("spacename") String spacename);
+
+    @Component
+    class DefaultFallback implements SsoUserSpaceApi{
+
+        @Override
+        public SsoResult checkSpaceName(String spaceName) {
+            return null;
+        }
+    }
+
 }

+ 19 - 0
base-servers/auth/sso-api/src/main/java/com/usoftchina/sso/dto/SsoCheckMobile.java

@@ -0,0 +1,19 @@
+package com.usoftchina.sso.dto;
+
+import java.io.Serializable;
+
+/**
+ * 校验手机号是否已经注册
+ */
+public class SsoCheckMobile implements Serializable {
+
+    private boolean hasRegister;
+
+    public boolean isHasRegister() {
+        return hasRegister;
+    }
+
+    public void setHasRegister(boolean hasRegister) {
+        this.hasRegister = hasRegister;
+    }
+}

+ 10 - 1
base-servers/auth/sso-api/src/test/java/com/usoftchina/sso/test/SsoUserApiTest.java

@@ -2,6 +2,7 @@ package com.usoftchina.sso.test;
 
 import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.sso.api.SsoUserApi;
+import com.usoftchina.sso.dto.SsoCheckMobile;
 import com.usoftchina.sso.dto.SsoResult;
 import com.usoftchina.sso.dto.SsoUser;
 import com.usoftchina.sso.dto.SsoUserSpaceList;
@@ -12,6 +13,7 @@ import org.junit.runners.MethodSorters;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.bind.annotation.RequestParam;
 
 /**
  * @author yingp
@@ -27,7 +29,7 @@ public class SsoUserApiTest {
 
     final static long userUU = 200040149;
 
-    final static String mobile = "13798490565";
+    final static String mobile = "18595633323";
 
     @Test
     public void testA_getUserByUu() {
@@ -44,4 +46,11 @@ public class SsoUserApiTest {
             list.getSpaces().forEach(space -> System.out.println(space.getSpaceName()));
         }
     }
+
+    @Test
+    public void testC_checkMobile(){
+        SsoCheckMobile checked = ssoUserApi.checkMobile(mobile);
+        System.out.println(checked);
+    }
+
 }

+ 30 - 0
base-servers/auth/sso-api/src/test/java/com/usoftchina/sso/test/SsoUserSpaceApiTeest.java

@@ -0,0 +1,30 @@
+package com.usoftchina.sso.test;
+
+import com.usoftchina.sso.api.SsoUserSpaceApi;
+import com.usoftchina.sso.dto.SsoResult;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author  chenw
+ * @date 2018/11/23
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class SsoUserSpaceApiTeest {
+
+    @Autowired
+    private SsoUserSpaceApi ssoUserSpaceApi;
+
+    @Test
+    public void testA_checkSpaceName(){
+        SsoResult result = ssoUserSpaceApi.checkSpaceName("测试公司08111550");
+        System.out.println(result);
+    }
+}

+ 11 - 1
base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/config/AuthFilter.java

@@ -12,6 +12,7 @@ import com.usoftchina.saas.exception.ExceptionCode;
 import com.usoftchina.saas.gateway.error.PermissionException;
 import com.usoftchina.saas.gateway.util.AntPathRequestMatcher;
 import com.usoftchina.saas.utils.CollectionUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cloud.gateway.filter.GatewayFilterChain;
@@ -74,11 +75,20 @@ public class AuthFilter implements GlobalFilter, Ordered {
     private void checkPermission(ServerHttpRequest request, JwtInfo jwt, AccountDTO accountDTO) {
         if (!accountDTO.isAdmin(jwt.getCompanyId())) {
             // 非管理账户,需要鉴权
+            ResourceCache.current().hdel();
             List<UrlResourceDTO> resources = ResourceCache.current().getUrlResources();
             if (!CollectionUtils.isEmpty(resources)) {
                 // 本次请求相关的资源
                 List<UrlResourceDTO> permissions = resources.parallelStream().filter(resource -> {
-                    AntPathRequestMatcher matcher = new AntPathRequestMatcher(resource.getUrl(), resource.getMethod());
+                    if (StringUtils.isEmpty(resource.getUrl())) {
+                        return false;
+                    }
+                    //处理删除、查询时 url变动无法匹配的问题
+                    String url = resource.getUrl();
+                    if (url.substring(url.length() - 1).equals("/")) {
+                        url += "*";
+                    }
+                    AntPathRequestMatcher matcher = new AntPathRequestMatcher(url, resource.getMethod());
                     return matcher.matches(request);
                 }).collect(Collectors.toList());
                 if (!CollectionUtils.isEmpty(permissions)) {

+ 13 - 7
frontend/saas-web/app/view/money/verification/FormPanel.js

@@ -324,6 +324,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '客户名称',
                 xtype: 'customerDbfindTrigger',
                 name: 'vc_custname',
+                allowBlank : false
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',
@@ -397,7 +398,8 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '客户名称',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_custname'
+                name: 'vc_custname',
+                allowBlank : false,
             }, {
                 xtype: 'hidden',
                 name: 'vc_vendid',
@@ -437,7 +439,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             main: [{
                 fieldLabel: '转出客户',
                 xtype: 'textfield',
-                name: 'vc_outcustid',
+                name: 'vc_custid',
                 hidden: true,
                 listeners: {
                     change: 'clearDetail0'
@@ -445,12 +447,13 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出客户编号',
                 xtype: 'textfield',
-                name: 'vc_outcustcode',
+                name: 'vc_custcode',
                 hidden: true
             }, {
                 fieldLabel: '转出客户',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_outcustname'
+                name: 'vc_custname',
+                allowBlank : false,
             }, {
                 fieldLabel: '转入客户id',
                 xtype: 'textfield',
@@ -465,6 +468,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转入客户',
                 xtype: 'customerDbfindTrigger',
                 name: 'vc_turncustname',
+                allowBlank : false,
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',
@@ -488,7 +492,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             main: [{
                 fieldLabel: '转出供应商',
                 xtype: 'textfield',
-                name: 'vc_outvendid',
+                name: 'vc_vendid',
                 hidden: true,
                 listeners: {
                     change: 'clearDetail0'
@@ -496,12 +500,13 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出供应商编号',
                 xtype: 'textfield',
-                name: 'vc_outvendcode',
+                name: 'vc_vendcode',
                 hidden: true
             }, {
                 fieldLabel: '转出供应商',
                 xtype: 'vendorDbfindTrigger',
-                name: 'vc_outvendname'
+                name: 'vc_vendname',
+                allowBlank : false,
             }, {
                 fieldLabel: '转入供应商id',
                 xtype: 'textfield',
@@ -516,6 +521,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转入供应商',
                 xtype: 'vendorDbfindTrigger',
                 name: 'vc_turnvendname',
+                allowBlank : false,
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',