Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

hurx 1 mesiac pred
rodič
commit
ef49fd1190

+ 1 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierBankServiceImpl.java

@@ -75,7 +75,7 @@ public class SupplierBankServiceImpl  extends ServiceImpl<SupplierBankMapper, Su
     private LambdaQueryWrapper<SupplierBank> buildQueryWrapper(SupplierBankBo bo) {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<SupplierBank> lqw = Wrappers.lambdaQuery();
-        lqw.orderByAsc(SupplierBank::getId);
+        lqw.orderByDesc(SupplierBank::getId);
         lqw.eq(bo.getNum() != null, SupplierBank::getNum, bo.getNum());
         lqw.eq(StringUtils.isNotBlank(bo.getSupplierNo()), SupplierBank::getSupplierNo, bo.getSupplierNo());
         lqw.eq(bo.getSupplierId() != null, SupplierBank::getSupplierId, bo.getSupplierId());

+ 2 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierBusinessInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package org.dromara.customer.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -161,7 +162,7 @@ public class SupplierBusinessInfoServiceImpl  extends ServiceImpl<SupplierBusine
         // 2. 调用企查查接口
         CompanyInfoResponse response = QccUtils.getCompanyInfo(enterpriseName);
         if (response == null || response.getResult() == null) {
-            return null; // 或抛异常,根据业务需求
+            throw new ServiceException("未查到该企业信息");
         }
 
         // 3. 映射 QCC 数据到实体(注意:不设置 businessLicense)

+ 14 - 2
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierInfoServiceImpl.java

@@ -111,6 +111,20 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
      */
     @Override
     public Boolean insertByBo(SupplierInfoBo bo) {
+        // 1. 判断 businessName 是否已存在
+        LambdaQueryWrapper<SupplierInfo> checkWrapper = new LambdaQueryWrapper<>();
+        checkWrapper.eq(SupplierInfo::getBusinessName, bo.getBusinessName());
+        Long count = baseMapper.selectCount(checkWrapper);
+        if (count > 0) {
+            throw new ServiceException("该企业工商信息已存在,不能重复添加");
+        }
+        //2.判断enterpriseName 是否已存在
+        LambdaQueryWrapper<SupplierInfo> checkWrapper1 = new LambdaQueryWrapper<>();
+        checkWrapper1.eq(SupplierInfo::getEnterpriseName, bo.getEnterpriseName());
+        Long count1 = baseMapper.selectCount(checkWrapper1);
+        if (count1 > 0) {
+            throw new ServiceException("该企业名称已存在,不能重复添加");
+        }
         LambdaQueryWrapper<SupplierInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
         // 按supplier_no降序排序,取第一条(最大值)
         lambdaQueryWrapper.select(SupplierInfo::getSupplierNo)
@@ -123,8 +137,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
         add.setSupplierNo(supplierNo);
         add.setCooperative(0L);
         boolean flag = baseMapper.insert(add) > 0;
-
-
         if (flag) {
             bo.setId(add.getId());
             // 解析 otherCustomers JSON 并保存工商信息

+ 1 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplyAreaServiceImpl.java

@@ -411,6 +411,7 @@ public class SupplyAreaServiceImpl  extends ServiceImpl<SupplyAreaMapper, Supply
 
             // 2.3 批量插入正式库(MyBatis-Plus自带saveBatch,高效无冗余)
             try {
+                baseMapper.delete(new LambdaQueryWrapper<SupplyArea>().eq(SupplyArea::getSupplierId, supplierId));
                 boolean b = baseMapper.insertBatch(supplyAreaOfficialList);
                 return b;
             } catch (Exception e) {