Browse Source

Merge branch 'hurx'

hurx 1 month ago
parent
commit
dca0502f99
40 changed files with 792 additions and 210 deletions
  1. 2 1
      ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlatformDataScopeInterceptor.java
  2. 8 1
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/CustomerContactController.java
  3. 16 5
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/pc/CustomerRegisterController.java
  4. 7 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerContact.java
  5. 2 1
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerContract.java
  6. 5 5
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerDept.java
  7. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/EnterpriseScale.java
  8. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/IndustryCategory.java
  9. 3 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerContactBo.java
  10. 6 5
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerContractBo.java
  11. 6 5
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerDeptBo.java
  12. 10 5
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/EnterpriseScaleBo.java
  13. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/IndustryCategoryBo.java
  14. 101 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplierRegisterBo.java
  15. 6 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContactVo.java
  16. 2 1
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContractVo.java
  17. 7 6
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerDeptVo.java
  18. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/EnterpriseScaleVo.java
  19. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/IndustryCategoryVo.java
  20. 8 1
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerContactService.java
  21. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerInfoService.java
  22. 6 2
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ISupplierInfoService.java
  23. 85 10
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContactServiceImpl.java
  24. 0 1
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContractServiceImpl.java
  25. 14 3
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerDeptServiceImpl.java
  26. 120 37
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java
  27. 39 4
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInvoiceInfoServiceImpl.java
  28. 77 31
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerShippingAddressServiceImpl.java
  29. 1 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/EnterpriseScaleServiceImpl.java
  30. 10 9
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/IndustryCategoryServiceImpl.java
  31. 147 72
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierInfoServiceImpl.java
  32. 2 1
      ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java
  33. 15 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/pc/PcSysUserController.java
  34. 5 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysCompany.java
  35. 30 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ChangeUserPwdBo.java
  36. 5 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysCompanyBo.java
  37. 10 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysUserBo.java
  38. 5 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysCompanyVo.java
  39. 1 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysCompanyServiceImpl.java
  40. 1 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java

+ 2 - 1
ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlatformDataScopeInterceptor.java

@@ -97,7 +97,8 @@ public class PlatformDataScopeInterceptor implements Interceptor {
         "supply_area",
         "authorize_type_level",
         "order_return",
-        "order_return_item"
+        "order_return_item",
+        "customer_business_info"
 
 
         // 注意:前缀匹配需特殊处理(如 qrtz_),见 isIgnoreTable 方法

+ 8 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/CustomerContactController.java

@@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.customer.domain.bo.CustomerShippingAddressBo;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -62,7 +63,7 @@ public class CustomerContactController extends BaseController {
      */
     @GetMapping("/{id}")
     public R<CustomerContactVo> getInfo(@NotNull(message = "主键不能为空")
-                                     @PathVariable("id") Long id) {
+                                        @PathVariable("id") Long id) {
         return R.ok(customerContactService.queryById(id));
     }
 
@@ -97,4 +98,10 @@ public class CustomerContactController extends BaseController {
                           @PathVariable("ids") Long[] ids) {
         return toAjax(customerContactService.deleteWithValidByIds(List.of(ids), true));
     }
+
+    /*设置主联系人*/
+    @PutMapping("/changeIsPrimary")
+    public R<Void> changeIsPrimary(@RequestBody CustomerContactBo bo) {
+        return toAjax(customerContactService.changeIsPrimary(bo));
+    }
 }

+ 16 - 5
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/pc/CustomerRegisterController.java

@@ -8,6 +8,7 @@ package org.dromara.customer.controller.pc;
 import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.domain.R;
 import org.dromara.customer.domain.bo.CustomerRegisterBo;
+import org.dromara.customer.domain.bo.SupplierRegisterBo;
 import org.dromara.customer.service.ICustomerInfoService;
 import org.dromara.customer.service.ISupplierInfoService;
 import org.springframework.validation.annotation.Validated;
@@ -27,18 +28,28 @@ public class CustomerRegisterController {
     private final ISupplierInfoService supplierInfoService;
 
     /**
-    * 企业注册
-    * */
+     * 验证密码与验证码
+     */
+    @PostMapping("/validate")
+    public R<Void> verifyCodeAndPassword(@RequestBody CustomerRegisterBo bo) {
+        customerInfoService.verifyCodeAndPssword(bo);
+        return R.ok();
+    }
+
+    /**
+     * 企业注册
+     */
     @PostMapping("/registerCustomer")
     public R<Void> register(@RequestBody CustomerRegisterBo bo) {
         customerInfoService.register(bo);
         return R.ok();
     }
+
     /**
-    * 供应商注册
-    * */
+     * 供应商注册
+     */
     @PostMapping("/registerSupplier")
-    public R<Void> registerSupplier(@RequestBody CustomerRegisterBo bo) {
+    public R<Void> registerSupplier(@RequestBody SupplierRegisterBo bo) {
         supplierInfoService.register(bo);
         return R.ok();
     }

+ 7 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerContact.java

@@ -28,11 +28,18 @@ public class CustomerContact extends TenantEntity {
     @TableId(value = "id")
     private Long id;
 
+    /*系统用户id*/
+    private Long userId;
+
     /**
      * 所属客户ID
      */
     private Long customerId;
 
+
+    /*联系人编号*/
+    private String contactNo;
+
     /**
      * 联系人姓名
      */

+ 2 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerContract.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -56,7 +57,7 @@ public class CustomerContract extends TenantEntity {
     /**
      * 合同金额
      */
-    private String contractAmount;
+    private BigDecimal contractAmount;
 
     /**
      * 客服负责人

+ 5 - 5
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerDept.java

@@ -66,7 +66,7 @@ public class CustomerDept extends TenantEntity {
     /**
      * 部门负责人
      */
-    private String deptManage;
+    private Long deptManage;
 
     /**
      * 是否限制预算
@@ -79,18 +79,18 @@ public class CustomerDept extends TenantEntity {
     private String selectYear;
 
     /**
-     * 费用类型
+     * 分项费用
      */
-    private String expenseType;
+    private Long expenseTypeId;
 
     /**
      * 年度剩余预算
      */
-    private Long residueYearlyBudget;
+    private BigDecimal residueYearlyBudget;
 
     /**
      * 充值金额
      */
-    private Long recharge;
+    private BigDecimal recharge;
 
 }

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/EnterpriseScale.java

@@ -50,4 +50,9 @@ public class EnterpriseScale extends TenantEntity {
      */
     private String remark;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
 }

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/IndustryCategory.java

@@ -50,4 +50,9 @@ public class IndustryCategory extends TenantEntity {
      */
     private String remark;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
 }

+ 3 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerContactBo.java

@@ -32,6 +32,9 @@ public class CustomerContactBo extends BaseEntity {
      */
     private Long customerId;
 
+    /*联系人编号*/
+    private String contactNo;
+
     /**
      * 联系人姓名
      */

+ 6 - 5
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerContractBo.java

@@ -9,6 +9,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import jakarta.validation.constraints.*;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -56,8 +57,8 @@ public class CustomerContractBo extends BaseEntity {
     /**
      * 合同金额
      */
-    @NotBlank(message = "合同金额不能为空", groups = {AddGroup.class, EditGroup.class})
-    private String contractAmount;
+//    @NotBlank(message = "合同金额不能为空", groups = {AddGroup.class, EditGroup.class})
+    private BigDecimal contractAmount;
 
     /**
      * 客服负责人
@@ -72,19 +73,19 @@ public class CustomerContractBo extends BaseEntity {
     /**
      * 合同类型
      */
-    @NotBlank(message = "合同类型不能为空", groups = {AddGroup.class, EditGroup.class})
+//    @NotBlank(message = "合同类型不能为空", groups = {AddGroup.class, EditGroup.class})
     private String contractType;
 
     /**
      * 合同开始时间
      */
-    @NotNull(message = "合同开始时间不能为空", groups = {AddGroup.class, EditGroup.class})
+//    @NotNull(message = "合同开始时间不能为空", groups = {AddGroup.class, EditGroup.class})
     private Date startTime;
 
     /**
      * 合同结束时间
      */
-    @NotNull(message = "合同结束时间不能为空", groups = {AddGroup.class, EditGroup.class})
+//    @NotNull(message = "合同结束时间不能为空", groups = {AddGroup.class, EditGroup.class})
     private Date endTime;
 
     /**

+ 6 - 5
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerDeptBo.java

@@ -1,5 +1,6 @@
 package org.dromara.customer.domain.bo;
 
+import cn.idev.excel.annotation.ExcelProperty;
 import org.dromara.customer.domain.CustomerDept;
 import org.dromara.common.mybatis.core.domain.BaseEntity;
 import org.dromara.common.core.validate.AddGroup;
@@ -90,7 +91,7 @@ public class CustomerDeptBo extends BaseEntity {
     /**
      * 部门负责人
      */
-    private String deptManage;
+    private Long deptManage;
 
     /**
      * 是否限制预算
@@ -103,19 +104,19 @@ public class CustomerDeptBo extends BaseEntity {
     private String selectYear;
 
     /**
-     * 费用类型
+     * 分项费用
      */
-    private String expenseType;
+    private Long expenseTypeId;
 
     /**
      * 年度剩余预算
      */
-    private Long residueYearlyBudget;
+    private BigDecimal residueYearlyBudget;
 
     /**
      * 充值金额
      */
-    private Long recharge;
+    private BigDecimal recharge;
 
     /**
      * 状态(0正常 1停用)

+ 10 - 5
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/EnterpriseScaleBo.java

@@ -1,13 +1,13 @@
 package org.dromara.customer.domain.bo;
 
-import org.dromara.customer.domain.EnterpriseScale;
-import org.dromara.common.mybatis.core.domain.BaseEntity;
-import org.dromara.common.core.validate.AddGroup;
-import org.dromara.common.core.validate.EditGroup;
 import io.github.linpeilie.annotations.AutoMapper;
+import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import jakarta.validation.constraints.*;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.customer.domain.EnterpriseScale;
 
 /**
  * 企业规模业务对象 enterprise_scale
@@ -38,6 +38,11 @@ public class EnterpriseScaleBo extends BaseEntity {
      */
     private String status;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
     /**
      * 备注
      */

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/IndustryCategoryBo.java

@@ -43,4 +43,9 @@ public class IndustryCategoryBo extends BaseEntity {
      */
     private String remark;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
 }

+ 101 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplierRegisterBo.java

@@ -0,0 +1,101 @@
+package org.dromara.customer.domain.bo;
+
+import lombok.Data;
+import org.dromara.customer.domain.vo.SupplyAreaVo;
+
+import java.util.List;
+
+@Data
+public class SupplierRegisterBo {
+    /**
+     * 供应商名称
+     */
+    private String enterpriseName;
+    /**
+     * 姓名
+     */
+    private String purchaseName;
+    /**
+     * 手机号
+     */
+    private String purchasePhone;
+    /**
+     * 验证码
+     */
+    private String code;
+    /**
+     * 密码
+     */
+    private String password;
+    /**
+     * 确认密码
+     */
+    private String confirmPassword;
+
+    /**
+     * 人员规模
+     */
+    private Long membershipSize;
+
+    /**
+     * 固定电话
+     */
+    private String fixedPhone;
+
+    /**
+     * 传真
+     */
+    private String fax;
+
+    /**
+     * 网址
+     */
+    private String url;
+
+    /**
+     * 邮箱
+     */
+    private String mailbox;
+
+    /**
+     * 办公地址-省
+     */
+    private String officeProvince;
+
+    /**
+     * 办公地址-市
+     */
+    private String officeCity;
+
+    /**
+     * 办公地址-区/县
+     */
+    private String officeCounty;
+
+    /**
+     * 办公详细地址
+     */
+    private String officeAddress;
+
+    /**
+     * 统一社会信用代码
+     */
+    private String socialCreditCode;
+
+    /**
+     * 营业执照图片路径
+     */
+    private String businessLicense;
+
+    /**
+     * 年销售额
+     */
+    private Long yearSales;
+
+    /**
+     * 经营品类
+     */
+    private String operatingCategory;
+
+    List<SupplyAreaBo> supplyAreaList;
+}

+ 6 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContactVo.java

@@ -33,6 +33,12 @@ public class CustomerContactVo implements Serializable {
     @ExcelProperty(value = "联系人ID")
     private Long id;
 
+    /*联系人编号*/
+    private String contactNo;
+
+    /*系统用户id*/
+    private Long userId;
+
     /**
      * 所属客户ID
      */

+ 2 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContractVo.java

@@ -1,5 +1,6 @@
 package org.dromara.customer.domain.vo;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -66,7 +67,7 @@ public class CustomerContractVo implements Serializable {
      * 合同金额
      */
     @ExcelProperty(value = "合同金额")
-    private String contractAmount;
+    private BigDecimal contractAmount;
 
     /**
      * 客服负责人

+ 7 - 6
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerDeptVo.java

@@ -106,7 +106,7 @@ public class CustomerDeptVo implements Serializable {
      * 部门负责人
      */
     @ExcelProperty(value = "部门负责人")
-    private String deptManage;
+    private Long deptManage;
 
     /**
      * 是否限制预算
@@ -120,23 +120,24 @@ public class CustomerDeptVo implements Serializable {
     @ExcelProperty(value = "所选年份")
     private String selectYear;
 
+
     /**
-     * 费用类型
+     * 分项费用
      */
-    @ExcelProperty(value = "费用类型")
-    private String expenseType;
+    @ExcelProperty(value = "分项费用")
+    private Long expenseTypeId;
 
     /**
      * 年度剩余预算
      */
     @ExcelProperty(value = "年度剩余预算")
-    private Long residueYearlyBudget;
+    private BigDecimal residueYearlyBudget;
 
     /**
      * 充值金额
      */
     @ExcelProperty(value = "充值金额")
-    private Long recharge;
+    private BigDecimal recharge;
 
     /**
      * 状态(0正常 1停用)

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/EnterpriseScaleVo.java

@@ -54,4 +54,9 @@ public class EnterpriseScaleVo implements Serializable {
     @ExcelProperty(value = "备注")
     private String remark;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
 }

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/IndustryCategoryVo.java

@@ -54,4 +54,9 @@ public class IndustryCategoryVo implements Serializable {
     @ExcelProperty(value = "备注")
     private String remark;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
 }

+ 8 - 1
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerContactService.java

@@ -2,6 +2,7 @@ package org.dromara.customer.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.dromara.customer.domain.CustomerContact;
+import org.dromara.customer.domain.bo.CustomerShippingAddressBo;
 import org.dromara.customer.domain.vo.CustomerContactVo;
 import org.dromara.customer.domain.bo.CustomerContactBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -16,7 +17,7 @@ import java.util.List;
  * @author LionLi
  * @date 2025-12-11
  */
-public interface ICustomerContactService extends IService<CustomerContact>{
+public interface ICustomerContactService extends IService<CustomerContact> {
 
     /**
      * 查询客户联系人信息
@@ -59,6 +60,12 @@ public interface ICustomerContactService extends IService<CustomerContact>{
      */
     Boolean updateByBo(CustomerContactBo bo);
 
+    /**
+     * 设置主联系人
+     */
+    int changeIsPrimary(CustomerContactBo bo);
+
+
     /**
      * 校验并批量删除客户联系人信息信息
      *

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerInfoService.java

@@ -131,8 +131,13 @@ public interface ICustomerInfoService extends IService<CustomerInfo> {
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
+    /*验证密码与验证码*/
+    Boolean verifyCodeAndPssword(CustomerRegisterBo bo);
+
     /**
      * 客户注册
      */
     Boolean register(CustomerRegisterBo bo);
+
+
 }

+ 6 - 2
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ISupplierInfoService.java

@@ -7,6 +7,7 @@ import jakarta.validation.constraints.NotNull;
 import org.dromara.customer.domain.SupplierInfo;
 import org.dromara.customer.domain.bo.CustomerRegisterBo;
 import org.dromara.customer.domain.bo.SupplierAuthorizeBo;
+import org.dromara.customer.domain.bo.SupplierRegisterBo;
 import org.dromara.customer.domain.vo.SupplierInfoVo;
 import org.dromara.customer.domain.bo.SupplierInfoBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -24,7 +25,7 @@ import java.util.Set;
  * @author LionLi
  * @date 2026-01-09
  */
-public interface ISupplierInfoService extends IService<SupplierInfo>{
+public interface ISupplierInfoService extends IService<SupplierInfo> {
 
     /**
      * 查询供应商信息
@@ -42,6 +43,7 @@ public interface ISupplierInfoService extends IService<SupplierInfo>{
      * @return 供应商信息分页列表
      */
     TableDataInfo<SupplierInfoVo> queryPageList(SupplierInfoBo bo, PageQuery pageQuery);
+
     /**
      * 获取供应商信息列表
      *
@@ -54,6 +56,7 @@ public interface ISupplierInfoService extends IService<SupplierInfo>{
 
     /**
      * 获取供应商审核列表
+     *
      * @param bo
      * @param pageQuery
      * @return
@@ -109,9 +112,10 @@ public interface ISupplierInfoService extends IService<SupplierInfo>{
 
     /**
      * 注册供应商
+     *
      * @param bo
      */
-    Boolean register(CustomerRegisterBo bo);
+    Boolean register(SupplierRegisterBo bo);
 
     List<SupplierInfoVo> getNameList();
 }

+ 85 - 10
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContactServiceImpl.java

@@ -1,27 +1,38 @@
 package org.dromara.customer.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.common.core.enums.IsDefault;
+import org.dromara.common.core.enums.SysPlatformYesNo;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.dromara.system.api.RemoteDeptService;
-import org.springframework.stereotype.Service;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.SequenceUtils;
+import org.dromara.customer.domain.CustomerContact;
+import org.dromara.customer.domain.CustomerShippingAddress;
 import org.dromara.customer.domain.bo.CustomerContactBo;
+import org.dromara.customer.domain.bo.CustomerShippingAddressBo;
 import org.dromara.customer.domain.vo.CustomerContactVo;
-import org.dromara.customer.domain.CustomerContact;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
+import org.dromara.customer.domain.vo.CustomerShippingAddressVo;
 import org.dromara.customer.mapper.CustomerContactMapper;
+import org.dromara.customer.mapper.CustomerInfoMapper;
 import org.dromara.customer.service.ICustomerContactService;
+import org.dromara.system.api.RemoteDeptService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.time.Duration;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
 
 /**
  * 客户联系人信息Service业务层处理
@@ -34,11 +45,14 @@ import java.util.Collection;
 @Service
 public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMapper, CustomerContact> implements ICustomerContactService {
 
+    private static final String CONTACT_NO_KEY = "customer_contact:contact_no";
     @DubboReference
     private RemoteDeptService remoteDeptService;
 
     private final CustomerContactMapper baseMapper;
 
+    private final CustomerInfoMapper customerInfoMapper;
+
     /**
      * 查询客户联系人信息
      *
@@ -116,7 +130,32 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
      */
     @Override
     public Boolean insertByBo(CustomerContactBo bo) {
+        // 1. 获取并校验客户编号
+        String customerNo = null;
+        if (bo.getCustomerId() != null) {
+            CustomerInfoVo customerInfoVo = customerInfoMapper.selectVoById(bo.getCustomerId());
+
+            // 【关键修复】防御性编程:如果查不到客户信息,应直接抛错或返回失败,避免生成 "nullxxx" 数据
+            if (customerInfoVo == null) {
+                log.error("客户不存在,无法创建联系人 (ID: " + bo.getCustomerId() + ")");
+                throw new RuntimeException("客户不存在,无法创建联系人 (ID: " + bo.getCustomerId() + ")");
+            }
+
+            customerNo = customerInfoVo.getCustomerNo();
+
+            // 二次校验:防止 customerNo 本身为空
+            if (StringUtils.isBlank(customerNo)) {
+                log.error("客户编号为空,数据异常 (ID: " + bo.getCustomerId() + ")");
+                throw new RuntimeException("客户编号为空,数据异常 (ID: " + bo.getCustomerId() + ")");
+            }
+        }
+
+        // 2. 生成联系人编号
+        String seqId = SequenceUtils.nextPaddedIdStr(CONTACT_NO_KEY, Duration.ofDays(3650), 3);
+        String contactNo = customerNo + seqId;
+
         CustomerContact add = MapstructUtils.convert(bo, CustomerContact.class);
+        add.setContactNo(contactNo);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
@@ -138,6 +177,42 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
         return baseMapper.updateById(update) > 0;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int changeIsPrimary(CustomerContactBo bo) {
+        if (bo == null || bo.getId() == null) {
+            return 0;
+        }
+        CustomerContactVo contactVo = baseMapper.selectVoById(bo.getId());
+        if (SysPlatformYesNo.YES.getCode().equals(bo.getIsPrimary())) {
+            // 1. 清除该客户下所有主联系人
+            CustomerContact updateObj = new CustomerContact();
+            updateObj.setIsPrimary(SysPlatformYesNo.NO.getCode()); //
+
+            baseMapper.update(
+                updateObj,
+                new LambdaUpdateWrapper<CustomerContact>()
+                    .eq(CustomerContact::getCustomerId, contactVo.getCustomerId()) //
+                    .eq(CustomerContact::getIsPrimary, SysPlatformYesNo.YES.getCode())
+            );
+
+            // 2. 设置当前地址为默认
+            CustomerContact current = new CustomerContact();
+            current.setId(bo.getId());
+            current.setIsPrimary(SysPlatformYesNo.YES.getCode());
+            baseMapper.updateById(current);
+
+            return 1;
+        } else {
+            // 取消默认
+            CustomerContact current = new CustomerContact();
+            current.setId(bo.getId());
+            current.setIsPrimary(SysPlatformYesNo.NO.getCode());
+            baseMapper.updateById(current);
+            return 1;
+        }
+    }
+
     /**
      * 保存前的数据校验
      */

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

@@ -82,7 +82,6 @@ public class CustomerContractServiceImpl extends ServiceImpl<CustomerContractMap
         lqw.eq(bo.getCustomerId() != null, CustomerContract::getCustomerId, bo.getCustomerId());
         lqw.eq(StringUtils.isNotBlank(bo.getContractNo()), CustomerContract::getContractNo, bo.getContractNo());
         lqw.like(StringUtils.isNotBlank(bo.getContractName()), CustomerContract::getContractName, bo.getContractName());
-        lqw.eq(StringUtils.isNotBlank(bo.getContractAmount()), CustomerContract::getContractAmount, bo.getContractAmount());
         lqw.eq(StringUtils.isNotBlank(bo.getCustomerLeader()), CustomerContract::getCustomerLeader, bo.getCustomerLeader());
         lqw.eq(StringUtils.isNotBlank(bo.getProjectLeader()), CustomerContract::getProjectLeader, bo.getProjectLeader());
         lqw.eq(StringUtils.isNotBlank(bo.getContractType()), CustomerContract::getContractType, bo.getContractType());

+ 14 - 3
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerDeptServiceImpl.java

@@ -19,6 +19,7 @@ import org.dromara.customer.mapper.CustomerDeptMapper;
 import org.dromara.customer.mapper.CustomerShippingAddressMapper;
 import org.dromara.customer.service.ICustomerDeptService;
 import org.dromara.system.api.RemoteDeptService;
+import org.dromara.system.api.RemoteUserService;
 import org.dromara.system.api.domain.vo.RemoteDeptVo;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -41,6 +42,9 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
     @DubboReference
     private RemoteDeptService remoteDeptService;
 
+    @DubboReference
+    private RemoteUserService remoteUserService;
+
     private static final String DEPT_NO_KEY = "customer_dept:dept_no";
 
     private final CustomerDeptMapper baseMapper;
@@ -60,6 +64,7 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
         if (null != remoteDeptVo) {
             customerDeptVo.setDeptName(remoteDeptVo.getDeptName());
             customerDeptVo.setParentId(remoteDeptVo.getParentId());
+            customerDeptVo.setStatus(remoteDeptVo.getStatus());
         }
         return customerDeptVo;
     }
@@ -152,7 +157,7 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
         return customerDepts.stream()
             .map(cd -> deptMap.get(cd.getDeptId())) // 直接 get,null 表示不匹配
             .filter(Objects::nonNull) // 过滤掉 deptMap 中不存在的
-            .map(sys -> buildCustomerDeptTreeVo(sys, customerDeptsMap.get(sys.getDeptId()), addressVoMap)) // 假设你有 customerDepts 按 deptId 的 map
+            .map(sys -> buildCustomerDeptTreeVo(sys, customerDeptsMap.get(sys.getDeptId()), addressVoMap))
             .sorted(Comparator.comparing(
                 CustomerDeptTreeVo::getOrderNum,
                 Comparator.nullsLast(Comparator.naturalOrder())
@@ -198,7 +203,6 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
         lqw.eq(bo.getMonthLimit() != null, CustomerDept::getMonthLimit, bo.getMonthLimit());
         lqw.eq(bo.getMonthUsedBudget() != null, CustomerDept::getMonthUsedBudget, bo.getMonthUsedBudget());
         lqw.eq(StringUtils.isNotBlank(bo.getBindStatus()), CustomerDept::getBindStatus, bo.getBindStatus());
-        lqw.eq(StringUtils.isNotBlank(bo.getDeptManage()), CustomerDept::getDeptManage, bo.getDeptManage());
         lqw.eq(StringUtils.isNotBlank(bo.getIsLimit()), CustomerDept::getIsLimit, bo.getIsLimit());
         lqw.eq(StringUtils.isNotBlank(bo.getSelectYear()), CustomerDept::getSelectYear, bo.getSelectYear());
         lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerDept::getPlatformCode, bo.getPlatformCode());
@@ -219,6 +223,7 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
             RemoteDeptVo remoteDeptVo = new RemoteDeptVo();
             remoteDeptVo.setParentId(bo.getParentId());
             remoteDeptVo.setDeptName(bo.getDeptName());
+            remoteDeptVo.setStatus(bo.getStatus());
             remoteDeptVo.setPlatformCode(PlatformContext.getPlatform());
 
 
@@ -238,6 +243,12 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
             dept.setUsedBudget(bo.getUsedBudget());
             dept.setBindStatus(bo.getBindStatus());
             dept.setBindAddress(bo.getBindAddress());
+            dept.setIsLimit(bo.getIsLimit());
+            dept.setSelectYear(bo.getSelectYear());
+            dept.setExpenseTypeId(bo.getExpenseTypeId());
+            dept.setDeptManage(bo.getDeptManage());
+            dept.setRecharge(bo.getRecharge());
+            dept.setResidueYearlyBudget(bo.getResidueYearlyBudget());
 
             boolean success = baseMapper.insert(dept) > 0;
             if (!success) {
@@ -271,7 +282,7 @@ public class CustomerDeptServiceImpl extends ServiceImpl<CustomerDeptMapper, Cus
         // 更新远程部门字段
         remoteDeptVo.setDeptName(bo.getDeptName());
         remoteDeptVo.setParentId(bo.getParentId());
-
+        remoteDeptVo.setStatus(bo.getStatus());
         RemoteDeptVo updatedRemoteDept = remoteDeptService.updateDept(remoteDeptVo);
         if (updatedRemoteDept == null) {
             log.error("远程部门更新失败,deptId={}", deptId);

+ 120 - 37
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java

@@ -20,6 +20,7 @@ import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.common.redis.utils.SequenceUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.customer.domain.*;
 import org.dromara.customer.domain.bo.*;
@@ -35,6 +36,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -66,6 +68,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     @DubboReference
     private RemoteCreditLevelService remoteCreditLevelService;
 
+    private static final String CUSTOMER_NO_KEY = "customer_info:customer_no";
+    private static final String CONTACT_NO_KEY = "customer_contact:contact_no";
+
     private final CustomerInfoMapper baseMapper;
     private final CustomerBusinessInfoMapper customerBusinessInfoMapper;
     private final CustomerInvoiceInfoMapper customerInvoiceInfoMapper;
@@ -488,7 +493,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     private LambdaQueryWrapper<CustomerInfo> buildQueryWrapper(CustomerInfoBo bo) {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<CustomerInfo> lqw = Wrappers.lambdaQuery();
-        lqw.orderByAsc(CustomerInfo::getId);
+        lqw.orderByDesc(CustomerInfo::getId);
         lqw.eq(StringUtils.isNotBlank(bo.getCustomerNo()), CustomerInfo::getCustomerNo, bo.getCustomerNo());
         lqw.eq(bo.getBelongCompanyId() != null, CustomerInfo::getBelongCompanyId, bo.getBelongCompanyId());
         lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), CustomerInfo::getCompanyName, bo.getCompanyName());
@@ -557,7 +562,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
             /*新增客户时给每个客户创建自己的组织架构*/
             RemoteDeptVo remoteDeptVo = new RemoteDeptVo();
             remoteDeptVo.setParentId(100L);
-            remoteDeptVo.setDeptName(bo.getCustomerName());
+            remoteDeptVo.setDeptName(bo.getBusinessCustomerName());
             remoteDeptVo.setPlatformCode(platform);
             RemoteDeptVo deptVo = remoteDeptService.insertDept(remoteDeptVo);
 
@@ -604,27 +609,34 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
 
             // 联系人列表
             if (contactList != null && !contactList.isEmpty()) {
-                CustomerContactBo primaryContact = contactList.stream()
-                    .filter(contact -> contact.getIsPrimary().equals("0"))
-                    .findFirst()
-                    .orElse(null);
-                RemoteUserBo remoteUserBo = new RemoteUserBo();
-                remoteUserBo.setNickName(bo.getCustomerName());
-                if (null != primaryContact) {
-                    remoteUserBo.setUserName(primaryContact.getPhone());
-                } else {
-                    remoteUserBo.setUserName(contactList.get(0).getPhone());
-                }
-
-                String password = "123456";
-                remoteUserBo.setPassword(BCrypt.hashpw(password));
-                remoteUserBo.setUserSonType("3");
-                remoteUserBo.setTenantId(LoginHelper.getTenantId());
-                remoteUserService.addUser(remoteUserBo);
                 for (CustomerContactBo contactBo : contactList) {
+                    // 1. 准备创建系统用户的数据
+                    RemoteUserBo remoteUserBo = new RemoteUserBo();
+                    remoteUserBo.setNickName(contactBo.getContactName());
+                    remoteUserBo.setUserName(contactBo.getPhone());// 用手机号做账号
+                    String defaultPassword = "123456";
+                    remoteUserBo.setPassword(BCrypt.hashpw(defaultPassword));
+                    remoteUserBo.setUserSonType("3");
+                    remoteUserBo.setTenantId(LoginHelper.getTenantId());
+
+                    // 2. 调用远程服务创建用户
+                    Long userId = remoteUserService.addUser(remoteUserBo);
+
+                    if (userId == null) {
+                        throw new ServiceException("创建系统用户失败:" + userId);
+                    }
+
+                    // 3. 转换并填充业务联系人数据
                     CustomerContact contact = MapstructUtils.convert(contactBo, CustomerContact.class);
                     contact.setCustomerId(customerId);
-                    customerContactMapper.insert(contact);
+
+                    // 建立关联
+                    contact.setUserId(userId);
+
+                    // 4. 插入联系人表
+                    if (customerContactMapper.insert(contact) <= 0) {
+                        throw new ServiceException("保存联系人信息失败");
+                    }
                 }
             }
 
@@ -872,6 +884,22 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
         return baseMapper.deleteByIds(ids) > 0;
     }
 
+    @Override
+    public Boolean verifyCodeAndPssword(CustomerRegisterBo bo) {
+        //先校验验证码是否正确
+        String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
+        if (!code.equals(bo.getCode())) {
+            throw new ServiceException("验证码错误");
+
+        }
+
+        //校验密码与确认密码是否一致
+        if (!bo.getPassword().equals(bo.getConfirmPassword())) {
+            throw new ServiceException("密码与确认密码不一致");
+        }
+        return true;
+    }
+
     /**
      * 客户注册
      *
@@ -882,7 +910,10 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     public Boolean register(CustomerRegisterBo bo) {
         //先校验验证码是否正确
         String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
-        code = "123456";
+        if (code == null) {
+            throw new ServiceException("验证码已过期");
+        }
+
         if (!code.equals(bo.getCode())) {
             throw new ServiceException("验证码错误");
         }
@@ -893,9 +924,13 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
         }
 
         //查询数据库是否存在企业,已存在则提示客户已存在
-        CustomerInfo customerInfo = baseMapper.selectOne(new LambdaQueryWrapper<CustomerInfo>()
-            .eq(CustomerInfo::getCustomerName, bo.getCustomerName())
+        List<CustomerInfo> list = baseMapper.selectList(
+            new LambdaQueryWrapper<CustomerInfo>()
+                .eq(CustomerInfo::getCustomerName, bo.getCustomerName())
+                .last("LIMIT 1")
         );
+
+        CustomerInfo customerInfo = list.isEmpty() ? null : list.get(0);
         if (customerInfo != null) {
             throw new ServiceException("客户已存在");
         }
@@ -909,8 +944,10 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
         //构建客户信息实体
         CustomerInfo customerEntity = new CustomerInfo();
         customerEntity.setCustomerName(bo.getCustomerName());
+        customerEntity.setCustomerNo(SequenceUtils.nextPaddedIdStr(CUSTOMER_NO_KEY, Duration.ofDays(3650), 6));
         customerEntity.setBusinessCustomerName(companyInfo.getResult().getName());
         customerEntity.setShortName(companyInfo.getResult().getName());
+        customerEntity.setInvoiceTop(companyInfo.getResult().getName());
         customerEntity.setStatus("0"); // 正常状态
         customerEntity.setDelFlag("0"); // 未删除
 
@@ -921,27 +958,85 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
 
         Long customerId = customerEntity.getId();
 
+        String customerNo = customerEntity.getCustomerNo();
+
+        /*新增客户时给每个客户创建自己的组织架构*/
+        RemoteDeptVo remoteDeptVo = new RemoteDeptVo();
+        remoteDeptVo.setParentId(100L);
+        remoteDeptVo.setDeptName(companyInfo.getResult().getName());
+        RemoteDeptVo deptVo = remoteDeptService.insertDept(remoteDeptVo);
+
+        CustomerDept dept = new CustomerDept();
+        dept.setDeptId(deptVo.getDeptId());
+        dept.setCustomerId(customerId);
+        dept.setYearlyBudget(BigDecimal.ZERO);
+        dept.setMonthLimit(BigDecimal.ZERO);
+        dept.setUsedBudget(BigDecimal.ZERO);
+        dept.setBindStatus(IsDefault.No.getCode());
+
+        if (customerDeptMapper.insert(dept) <= 0) {
+            throw new ServiceException("客户部门新增失败");
+        }
+
         // 添加客户工商信息
         CustomerBusinessInfo businessInfo = new CustomerBusinessInfo();
         businessInfo.setCustomerId(customerId);
         businessInfo.setBusinessCustomerName(companyInfo.getResult().getName());
         businessInfo.setSocialCreditCode(companyInfo.getResult().getCreditCode());
         businessInfo.setLegalPersonName(companyInfo.getResult().getOperName());
-        businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
+//        businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
+
+        // 注册资本:拼接数值 + 单位(如 "101万元")
+        String regCap = companyInfo.getResult().getRegisteredCapital();
+        String regUnit = companyInfo.getResult().getRegisteredCapitalUnit();
+        businessInfo.setRegisteredCapital(
+            StringUtils.isNotBlank(regCap) && StringUtils.isNotBlank(regUnit)
+                ? regCap + regUnit
+                : regCap
+        );
+
+        // 实缴资本
+        String paidCap = companyInfo.getResult().getPaidUpCapital();
+        String paidUnit = companyInfo.getResult().getPaidUpCapitalUnit();
+        businessInfo.setPaidInCapital(
+            StringUtils.isNotBlank(paidCap) && StringUtils.isNotBlank(paidUnit)
+                ? paidCap + paidUnit
+                : paidCap
+        );
+
         businessInfo.setEstablishmentDate(DateUtils.parseDate((companyInfo.getResult().getStartDate())));
+        businessInfo.setRevocationDate(null);
         businessInfo.setRegistrationStatus(companyInfo.getResult().getStatus());
+        businessInfo.setRegistrationAuthority(companyInfo.getResult().getBelongOrg());
         businessInfo.setBusinessAddress(companyInfo.getResult().getAddress());
         businessInfo.setBussinessRange(companyInfo.getResult().getScope());
         businessInfo.setStatus("0");
-        businessInfo.setDelFlag("0");
 
         if (customerBusinessInfoMapper.insert(businessInfo) <= 0) {
             throw new ServiceException("客户工商信息新增失败");
         }
 
+        // 创建系统用户
+        RemoteUserBo remoteUserBo = new RemoteUserBo();
+        remoteUserBo.setDeptId(deptVo.getDeptId());
+        remoteUserBo.setUserName(bo.getPurchasePhone());
+        remoteUserBo.setNickName(bo.getCustomerName());
+        remoteUserBo.setPhonenumber(bo.getPurchasePhone());
+        remoteUserBo.setPassword(BCrypt.hashpw(bo.getPassword()));
+        remoteUserBo.setUserSonType("3"); // 商城用户
+        remoteUserBo.setTenantId(LoginHelper.getTenantId());
+        remoteUserBo.setStatus("0"); // 正常状态
+        Long userId = remoteUserService.addUser(remoteUserBo);
+
+
         // 添加客户联系人信息
         CustomerContact contact = new CustomerContact();
         contact.setCustomerId(customerId);
+        //  生成联系人编号
+        String seqId = SequenceUtils.nextPaddedIdStr(CONTACT_NO_KEY, Duration.ofDays(3650), 3);
+        String contactNo = customerNo + seqId;
+        contact.setContactNo(contactNo);
+        contact.setUserId(userId);
         contact.setContactName(bo.getPurchaseName());
         contact.setPhone(bo.getPurchasePhone());
         contact.setCustomLoginName(bo.getPurchasePhone());
@@ -953,18 +1048,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
             throw new ServiceException("客户联系人信息新增失败");
         }
 
-        // 创建系统用户
-        RemoteUserBo remoteUserBo = new RemoteUserBo();
-        remoteUserBo.setUserName(bo.getPurchasePhone());
-        remoteUserBo.setNickName(bo.getCustomerName());
-        remoteUserBo.setPhonenumber(bo.getPurchasePhone());
-        remoteUserBo.setPassword(BCrypt.hashpw(bo.getPassword()));
-        remoteUserBo.setUserSonType("3"); // 商城用户
-        remoteUserBo.setTenantId(LoginHelper.getTenantId());
-        remoteUserBo.setStatus("0"); // 正常状态
-
-        remoteUserService.addUser(remoteUserBo);
-
         log.info("客户注册成功,客户ID:{},客户名称:{}", customerId, bo.getCustomerName());
         return true;
     }

+ 39 - 4
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInvoiceInfoServiceImpl.java

@@ -1,6 +1,8 @@
 package org.dromara.customer.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.dromara.common.core.enums.SysPlatformYesNo;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -16,6 +18,7 @@ import org.dromara.customer.domain.vo.CustomerInvoiceInfoVo;
 import org.dromara.customer.domain.CustomerInvoiceInfo;
 import org.dromara.customer.mapper.CustomerInvoiceInfoMapper;
 import org.dromara.customer.service.ICustomerInvoiceInfoService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Map;
@@ -30,7 +33,7 @@ import java.util.Collection;
 @Slf4j
 @RequiredArgsConstructor
 @Service
-public class CustomerInvoiceInfoServiceImpl  extends ServiceImpl<CustomerInvoiceInfoMapper, CustomerInvoiceInfo> implements ICustomerInvoiceInfoService {
+public class CustomerInvoiceInfoServiceImpl extends ServiceImpl<CustomerInvoiceInfoMapper, CustomerInvoiceInfo> implements ICustomerInvoiceInfoService {
 
     private final CustomerInvoiceInfoMapper baseMapper;
 
@@ -41,7 +44,7 @@ public class CustomerInvoiceInfoServiceImpl  extends ServiceImpl<CustomerInvoice
      * @return 客户开票信息
      */
     @Override
-    public CustomerInvoiceInfoVo queryById(Long id){
+    public CustomerInvoiceInfoVo queryById(Long id) {
         return baseMapper.selectVoById(id);
     }
 
@@ -96,9 +99,22 @@ public class CustomerInvoiceInfoServiceImpl  extends ServiceImpl<CustomerInvoice
      * @return 是否新增成功
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean insertByBo(CustomerInvoiceInfoBo bo) {
         CustomerInvoiceInfo add = MapstructUtils.convert(bo, CustomerInvoiceInfo.class);
+
+        // 1. 如果设为“主账户”,先将该客户下其他所有“主账户”降级为“非主账户”
+        if (SysPlatformYesNo.YES.getCode().equals(bo.getIsPrimaryAccount())) {
+            baseMapper.update(null, new LambdaUpdateWrapper<CustomerInvoiceInfo>()
+                .eq(CustomerInvoiceInfo::getCustomerId, add.getCustomerId())
+                .eq(CustomerInvoiceInfo::getIsPrimaryAccount, SysPlatformYesNo.YES.getCode())
+                .set(CustomerInvoiceInfo::getIsPrimaryAccount, SysPlatformYesNo.NO.getCode()));
+        }
+
+        // 2. 业务校验
         validEntityBeforeSave(add);
+
+        // 3. 执行插入
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setId(add.getId());
@@ -113,16 +129,35 @@ public class CustomerInvoiceInfoServiceImpl  extends ServiceImpl<CustomerInvoice
      * @return 是否修改成功
      */
     @Override
+    @Transactional(rollbackFor = Exception.class) // 确保事务控制
     public Boolean updateByBo(CustomerInvoiceInfoBo bo) {
         CustomerInvoiceInfo update = MapstructUtils.convert(bo, CustomerInvoiceInfo.class);
+
+        // 防御性检查:确保 ID 存在
+        if (update.getId() == null) {
+            return false;
+        }
+
+        // 1. 如果设为“主账户”,先将该客户下其他所有“主账户”降级
+        if (SysPlatformYesNo.YES.getCode().equals(bo.getIsPrimaryAccount())) {
+            baseMapper.update(null, new LambdaUpdateWrapper<CustomerInvoiceInfo>()
+                .eq(CustomerInvoiceInfo::getCustomerId, update.getCustomerId())
+                .eq(CustomerInvoiceInfo::getIsPrimaryAccount, SysPlatformYesNo.YES.getCode())
+                .ne(CustomerInvoiceInfo::getId, update.getId()) // 排除自己
+                .set(CustomerInvoiceInfo::getIsPrimaryAccount, SysPlatformYesNo.NO.getCode()));
+        }
+
+        // 2. 业务校验
         validEntityBeforeSave(update);
+
+        // 3. 执行更新
         return baseMapper.updateById(update) > 0;
     }
 
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(CustomerInvoiceInfo entity){
+    private void validEntityBeforeSave(CustomerInvoiceInfo entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -135,7 +170,7 @@ public class CustomerInvoiceInfoServiceImpl  extends ServiceImpl<CustomerInvoice
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;

+ 77 - 31
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerShippingAddressServiceImpl.java

@@ -15,12 +15,15 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.SequenceUtils;
 import org.dromara.customer.domain.CustomerShippingAddress;
 import org.dromara.customer.domain.bo.CustomerShippingAddressBo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
 import org.dromara.customer.domain.vo.CustomerShippingAddressVo;
+import org.dromara.customer.mapper.CustomerInfoMapper;
 import org.dromara.customer.mapper.CustomerShippingAddressMapper;
 import org.dromara.customer.service.ICustomerShippingAddressService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.rmi.ServerException;
 import java.time.Duration;
 import java.util.Collection;
 import java.util.List;
@@ -41,6 +44,8 @@ public class CustomerShippingAddressServiceImpl extends ServiceImpl<CustomerShip
 
     private final CustomerShippingAddressMapper baseMapper;
 
+    private final CustomerInfoMapper customerInfoMapper;
+
     /**
      * 查询客户收货地址
      *
@@ -110,14 +115,49 @@ public class CustomerShippingAddressServiceImpl extends ServiceImpl<CustomerShip
      * @return 是否新增成功
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean insertByBo(CustomerShippingAddressBo bo) {
-        bo.setShippingAddressNo(SequenceUtils.nextPaddedIdStr(SHOPPING_ADDRESS_NO_KEY, Duration.ofDays(3650), 4));
+        // 1. 获取并校验客户编号
+        String customerNo = null;
+        if (bo.getCustomerId() != null) {
+            CustomerInfoVo customerInfoVo = customerInfoMapper.selectVoById(bo.getCustomerId());
+
+            // 【关键修复】防御性编程:如果查不到客户信息,应直接抛错或返回失败,避免生成 "nullxxx" 数据
+            if (customerInfoVo == null) {
+                log.error("客户不存在,无法创建收货地址 (ID: " + bo.getCustomerId() + ")");
+                throw new RuntimeException("客户不存在,无法创建收货地址 (ID: " + bo.getCustomerId() + ")");
+            }
+
+            customerNo = customerInfoVo.getCustomerNo();
+
+            // 二次校验:防止 customerNo 本身为空
+            if (StringUtils.isBlank(customerNo)) {
+                log.error("客户编号为空,数据异常 (ID: " + bo.getCustomerId() + ")");
+                throw new RuntimeException("客户编号为空,数据异常 (ID: " + bo.getCustomerId() + ")");
+            }
+        }
+
+        // 2. 生成收货地址编号
+        String seqId = SequenceUtils.nextPaddedIdStr(SHOPPING_ADDRESS_NO_KEY, Duration.ofDays(3650), 3);
+        String shippingAddressNo = customerNo + seqId;
+
+        // 3. 对象转换
         CustomerShippingAddress add = MapstructUtils.convert(bo, CustomerShippingAddress.class);
+
+        // 4. 设置生成的业务字段
+        add.setShippingAddressNo(shippingAddressNo);
+
+        // 5. 业务校验
         validEntityBeforeSave(add);
+
+        // 6. 执行插入
         boolean flag = baseMapper.insert(add) > 0;
+
+        // 7. 回填 ID
         if (flag) {
             bo.setId(add.getId());
         }
+
         return flag;
     }
 
@@ -137,36 +177,42 @@ public class CustomerShippingAddressServiceImpl extends ServiceImpl<CustomerShip
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int changeDefaultAddress(CustomerShippingAddressBo bo) {
-        if (bo == null || bo.getId() == null) {
-            return 0;
-        }
-        CustomerShippingAddressVo addressVo = baseMapper.selectVoById(bo.getId());
-        if (IsDefault.Yes.getCode().equals(bo.getDefaultAddress())) {
-            // 1. 清除该客户下所有默认地址
-            CustomerShippingAddress updateObj = new CustomerShippingAddress();
-            updateObj.setDefaultAddress(IsDefault.No.getCode()); //
-
-            baseMapper.update(
-                updateObj,
-                new LambdaUpdateWrapper<CustomerShippingAddress>()
-                    .eq(CustomerShippingAddress::getCustomerId, addressVo.getCustomerId()) //
-                    .eq(CustomerShippingAddress::getDefaultAddress, IsDefault.Yes.getCode())
-            );
-
-            // 2. 设置当前地址为默认
-            CustomerShippingAddress current = new CustomerShippingAddress();
-            current.setId(bo.getId());
-            current.setDefaultAddress(IsDefault.Yes.getCode());
-            baseMapper.updateById(current);
-
-            return 1;
-        } else {
-            // 取消默认
-            CustomerShippingAddress current = new CustomerShippingAddress();
-            current.setId(bo.getId());
-            current.setDefaultAddress(IsDefault.No.getCode());
-            baseMapper.updateById(current);
-            return 1;
+        try {
+            if (bo == null || bo.getId() == null) {
+                return 0;
+            }
+            CustomerShippingAddressVo addressVo = baseMapper.selectVoById(bo.getId());
+            log.info("修改默认地址:" + addressVo);
+            if (IsDefault.Yes.getCode().equals(bo.getDefaultAddress())) {
+                // 1. 清除该客户下所有默认地址
+                CustomerShippingAddress updateObj = new CustomerShippingAddress();
+                updateObj.setDefaultAddress(IsDefault.No.getCode()); //
+
+                baseMapper.update(
+                    updateObj,
+                    new LambdaUpdateWrapper<CustomerShippingAddress>()
+                        .eq(CustomerShippingAddress::getCustomerId, addressVo.getCustomerId()) //
+                        .eq(CustomerShippingAddress::getDefaultAddress, IsDefault.Yes.getCode())
+                );
+
+                // 2. 设置当前地址为默认
+                CustomerShippingAddress current = new CustomerShippingAddress();
+                current.setId(bo.getId());
+                current.setDefaultAddress(IsDefault.Yes.getCode());
+                baseMapper.updateById(current);
+
+                return 1;
+            } else {
+                // 取消默认
+                CustomerShippingAddress current = new CustomerShippingAddress();
+                current.setId(bo.getId());
+                current.setDefaultAddress(IsDefault.No.getCode());
+                baseMapper.updateById(current);
+                return 1;
+            }
+        } catch (Exception e) {
+            log.error("修改默认地址失败:" + e.getMessage(), e);
+            throw new RuntimeException(e);
         }
     }
 

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

@@ -83,6 +83,7 @@ public class EnterpriseScaleServiceImpl extends ServiceImpl<EnterpriseScaleMappe
         lqw.orderByAsc(EnterpriseScale::getId);
         lqw.like(StringUtils.isNotBlank(bo.getEnterpriseScaleName()), EnterpriseScale::getEnterpriseScaleName, bo.getEnterpriseScaleName());
         lqw.eq(StringUtils.isNotBlank(bo.getStatus()), EnterpriseScale::getStatus, bo.getStatus());
+        lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), EnterpriseScale::getDataSource, bo.getDataSource());
         lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), EnterpriseScale::getPlatformCode, bo.getPlatformCode());
         return lqw;
     }

+ 10 - 9
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/IndustryCategoryServiceImpl.java

@@ -1,27 +1,27 @@
 package org.dromara.customer.service.impl;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.dromara.common.core.utils.MapstructUtils;
-import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.SequenceUtils;
-import org.springframework.stereotype.Service;
+import org.dromara.customer.domain.IndustryCategory;
 import org.dromara.customer.domain.bo.IndustryCategoryBo;
 import org.dromara.customer.domain.vo.IndustryCategoryVo;
-import org.dromara.customer.domain.IndustryCategory;
 import org.dromara.customer.mapper.IndustryCategoryMapper;
 import org.dromara.customer.service.IIndustryCategoryService;
+import org.springframework.stereotype.Service;
 
 import java.time.Duration;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
 
 /**
  * 所属行业Service业务层处理
@@ -81,6 +81,7 @@ public class IndustryCategoryServiceImpl extends ServiceImpl<IndustryCategoryMap
         lqw.orderByAsc(IndustryCategory::getId);
         lqw.like(StringUtils.isNotBlank(bo.getIndustryCategoryName()), IndustryCategory::getIndustryCategoryName, bo.getIndustryCategoryName());
         lqw.eq(StringUtils.isNotBlank(bo.getStatus()), IndustryCategory::getStatus, bo.getStatus());
+        lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), IndustryCategory::getDataSource, bo.getDataSource());
         lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), IndustryCategory::getPlatformCode, bo.getPlatformCode());
         return lqw;
     }

+ 147 - 72
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierInfoServiceImpl.java

@@ -26,15 +26,10 @@ import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.customer.domain.*;
-import org.dromara.customer.domain.bo.CustomerRegisterBo;
-import org.dromara.customer.domain.bo.EnterpriseScaleBo;
-import org.dromara.customer.domain.bo.SupplierAuthorizeBo;
-import org.dromara.customer.domain.bo.SupplyAreaBo;
+import org.dromara.customer.domain.bo.*;
 import org.dromara.customer.domain.vo.*;
 import org.dromara.customer.enums.SupplierStatusEnum;
-import org.dromara.customer.mapper.SupplierAuthorizeMapper;
-import org.dromara.customer.mapper.SupplierBusinessInfoMapper;
-import org.dromara.customer.mapper.SupplierContactMapper;
+import org.dromara.customer.mapper.*;
 import org.dromara.customer.service.*;
 import org.dromara.customer.utils.qcc.QccUtils;
 import org.dromara.customer.utils.qcc.domain.CompanyInfoResponse;
@@ -48,10 +43,9 @@ import org.dromara.system.api.domain.bo.RemoteUserBo;
 import org.dromara.system.api.domain.vo.RemoteSupplierTypeVo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
-import org.dromara.customer.domain.bo.SupplierInfoBo;
 import org.dromara.customer.domain.vo.SupplierInfoVo;
 import org.dromara.customer.domain.SupplierInfo;
-import org.dromara.customer.mapper.SupplierInfoMapper;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.*;
@@ -66,7 +60,7 @@ import java.util.stream.Collectors;
 @Slf4j
 @RequiredArgsConstructor
 @Service
-public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
+public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
 
     private final SupplierInfoMapper baseMapper;
 
@@ -84,10 +78,11 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
     private final ObjectMapper objectMapper;
 
+    private final SupplyAreaMapper supplyAreaMapper;
+
     /**
-     *
      * 供应商联系人信息
-     * */
+     */
     private final SupplierContactMapper supplierContactMapper;
 
     @DubboReference
@@ -106,8 +101,6 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     private final RemoteSupplierTypeService remoteSupplierTypeService;
 
 
-
-
     /**
      * 新增供应商信息
      *
@@ -137,11 +130,12 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         }
         return flag;
     }
+
     /**
      * 从JSON字符串解析工商信息并保存
      *
      * @param otherCustomersJson JSON格式的工商信息
-     * @param supplierId 供应商ID
+     * @param supplierId         供应商ID
      */
     private void saveSupplierBusinessInfoFromJson(String otherCustomersJson, Long supplierId) {
         if (StringUtils.isBlank(otherCustomersJson)) {
@@ -172,7 +166,6 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     }
 
 
-
     /**
      * 修改供应商信息
      *
@@ -197,7 +190,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
             supplierInfoVo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
             //先copy到临时表
             SupplierInfoTemporary supplierInfoTemporary = new SupplierInfoTemporary();
-            BeanUtils.copyProperties(bo, supplierInfoTemporary,"id");
+            BeanUtils.copyProperties(bo, supplierInfoTemporary, "id");
             //修改待审核
             //ID一对一
             supplierInfoTemporary.setSupplierId(bo.getId());
@@ -229,7 +222,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         }
 
         //停用 ->正式供应商
-        if (supplierInfoVo.getSupplyStatus() ==SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
+        if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
             SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
             update.setCooperative(1L);
             return baseMapper.updateById(update) > 0;
@@ -262,7 +255,8 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
                 // 注意:泛型解析需要用 TypeReference 明确类型,否则会解析为 LinkedHashMap
                 TableDataInfo<SupplyAreaVo> areaTableData = objectMapper.readValue(
                     areaListJson,
-                    new TypeReference<TableDataInfo<SupplyAreaVo>>() {}
+                    new TypeReference<TableDataInfo<SupplyAreaVo>>() {
+                    }
                 );
                 // 2. 提取 SupplyAreaVo 列表(判空避免空指针)
                 List<SupplyAreaVo> supplyAreaVoList = areaTableData.getRows();
@@ -290,7 +284,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
                 // 5. 更新主表 SupplierInfo
                 supplierInfoVo.setSupplyStatus(SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode());
                 boolean updateMain = baseMapper.updateById(supplierInfoVo) > 0;
-                if (updateMain == false){
+                if (updateMain == false) {
                     throw new RuntimeException("更新供应商信息失败");
                 }
                 boolean remove = supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>().eq(SupplierInfoTemporary::getSupplierId, id));
@@ -356,16 +350,16 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         Long id = bo.getId();
         SupplierInfo supplierInfo = baseMapper.selectById(id);
         //如果是待审核和审核不通过 随便改
-        if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()){
+        if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
             SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
             return baseMapper.updateById(update) > 0;
         }
         //如果是启用状态,就变成待修改审核状态
-        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()){
+        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
             SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
-            if (supplierInfoTemporary == null){
+            if (supplierInfoTemporary == null) {
                 supplierInfoTemporary = new SupplierInfoTemporary();
-                BeanUtils.copyProperties(supplierInfo, supplierInfoTemporary,"id");
+                BeanUtils.copyProperties(supplierInfo, supplierInfoTemporary, "id");
                 supplierInfoTemporary.setSupplierId(id);
                 //通过传参在set临时表
                 //查询供应地址 存入  areaListJson  为了回显
@@ -377,57 +371,57 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
                 supplierInfoTemporary.setAreaListJson(areaListJson);
                 supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
                 boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
-                if (save == false){
+                if (save == false) {
                     throw new RuntimeException("保存供应商待审核数据失败");
                 }
 
             }
             //一共三个地方
-            boolean flag =false;
+            boolean flag = false;
             //1.简称
-            if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
+            if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
                 supplierInfoTemporary.setShortName(bo.getShortName());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
             //2.供货品牌
-            if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
+            if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
                 supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
             //3.供货类目
-            if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
+            if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
                 supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
 
             supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
-            boolean update =baseMapper.updateById(supplierInfo) > 0;
+            boolean update = baseMapper.updateById(supplierInfo) > 0;
             return update && flag;
         }
         //如果是待审核状态,依旧是待修改审核状态
-        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()){
+        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
             SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
             //一共三个地方
-            boolean flag =false;
+            boolean flag = false;
             //1.简称
-            if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
+            if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
                 supplierInfoTemporary.setShortName(bo.getShortName());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
             //2.供货品牌
-            if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
+            if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
                 supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
             //3.供货类目
-            if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
+            if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
                 supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
                 flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
             }
             return flag;
         }
         // 停用呢  不能修改了
-        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()){
+        if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()) {
             throw new RuntimeException("供应商已停用,不能修改");
         }
         return false;
@@ -458,11 +452,11 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     public SupplierInfoVo queryById(Long id) throws JsonProcessingException {
         SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
             .eq(SupplierInfo::getId, id));
-        SupplierInfoVo supplierInfoVo =new SupplierInfoVo();
+        SupplierInfoVo supplierInfoVo = new SupplierInfoVo();
         if (supplierInfoVo1.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
             SupplierInfoTemporaryVo supplierInfoTemporaryVo = supplierInfoTemporaryService.getVoOne(id);
             BeanUtils.copyProperties(supplierInfoTemporaryVo, supplierInfoVo);
-        }else {
+        } else {
             supplierInfoVo = baseMapper.selectVoById(id);
         }
         SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
@@ -478,7 +472,6 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     }
 
 
-
     /**
      * 分页查询供应商信息列表
      *
@@ -497,18 +490,18 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     public TableDataInfo<SupplierInfoVo> getSupplierInformation(SupplierInfoBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
         // 1. 基础分页查询
-        if (bo.getSupplyStatus() == null){
+        if (bo.getSupplyStatus() == null) {
             //正式供应商
             lqw.eq(SupplierInfo::getSupplyStatus, 1L);
-        }else {
-            lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
+        } else {
+            lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
         }
 
         // 2. 添加品牌条件
-        if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
-            if (StringUtils.isNotBlank(bo.getOperatingBrand())){
+        if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
+            if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
                 Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
-                if (productBrandIdByName != null){
+                if (productBrandIdByName != null) {
                     lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
                 }
             }
@@ -556,7 +549,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
     @Override
     public TableDataInfo<SupplierInfoVo> getSupplierApproveInformation(SupplierInfoBo bo, PageQuery pageQuery) {
-        if (bo.getSupplyStatus() == null){
+        if (bo.getSupplyStatus() == null) {
             // 步骤1:定义两个列表,存储主表(状态0)和临时表(状态4)的数据
             List<SupplierInfoVo> mainTableVoList = new ArrayList<>();
             List<SupplierInfoVo> tempTableVoList = new ArrayList<>();
@@ -664,13 +657,13 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
         // 1. 构建审批状态条件
         LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
+        lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
 
         // 2.添加品牌条件
-        if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
-            if (StringUtils.isNotBlank(bo.getOperatingBrand())){
+        if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
+            if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
                 Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
-                if (productBrandIdByName != null){
+                if (productBrandIdByName != null) {
                     lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
                 }
             }
@@ -813,9 +806,9 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         lqw.eq(StringUtils.isNotBlank(bo.getSupplierName()), SupplierInfo::getEnterpriseName, bo.getSupplierName());
 
         //可供应品牌
-        if (StringUtils.isNotBlank(bo.getSupplyBrand())){
+        if (StringUtils.isNotBlank(bo.getSupplyBrand())) {
             Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getSupplyBrand());
-            if (productBrandIdByName != null){
+            if (productBrandIdByName != null) {
                 lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
             }
         }
@@ -823,10 +816,10 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
             // 查询符合条件的供应商ID列表
             List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
-            if (supplierIds != null &&!supplierIds.isEmpty()) {
+            if (supplierIds != null && !supplierIds.isEmpty()) {
                 lqw.in(SupplierInfo::getId, supplierIds);
 
-            }else {
+            } else {
                 lqw.in(SupplierInfo::getId, -1L);
 
             }
@@ -836,9 +829,9 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         if (StringUtils.isNotBlank(bo.getBrandName())) {
             // 通过SupplierAuthorizeService查询符合条件的供应商ID
             List<Long> supplierIdsByBrand = commonSupplierAuthorizeMapper.getSupplierIdsByBrandName(bo.getBrandName());
-            if (supplierIdsByBrand!=null &&!supplierIdsByBrand.isEmpty()) {
+            if (supplierIdsByBrand != null && !supplierIdsByBrand.isEmpty()) {
                 lqw.in(SupplierInfo::getId, supplierIdsByBrand);
-            }else {
+            } else {
                 lqw.in(SupplierInfo::getId, -1L);
 
             }
@@ -889,7 +882,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     @Override
     public Long getSupplierStatus(Long id) {
         SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
-            .eq(SupplierInfo::getId,id));
+            .eq(SupplierInfo::getId, id));
 
         return supplierInfoVo1.getSupplyStatus();
     }
@@ -941,6 +934,7 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     }
 
     // ========== 3. 数据转换 - 映射构建方法 ==========
+
     /**
      * 构建品牌ID→名称映射表
      */
@@ -1421,7 +1415,6 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     }
 
 
-
     private SupplierInfoVo handleProcurementInfo(SupplierInfoVo records) {
 
         // 查询管理人员和采购人员
@@ -1565,7 +1558,6 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
     }*/
 
 
-
     /**
      * 处理采购员和产品经理信息和品牌和供应商类型
      */
@@ -1951,12 +1943,18 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
      * @param bo
      */
     @Override
-    public Boolean register(CustomerRegisterBo bo) {
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean register(SupplierRegisterBo bo) {
         //先校验验证码是否正确
         String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
-        code = "123456";
+
+        if (code == null) {
+            throw new ServiceException("验证码已过期");
+        }
+
         if (!code.equals(bo.getCode())) {
             throw new ServiceException("验证码错误");
+
         }
 
         //校验密码与确认密码是否一致
@@ -1966,23 +1964,47 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
         //查询数据库是否存在企业,已存在则提示客户已存在
         SupplierInfo one = baseMapper.selectOne(new LambdaQueryWrapper<SupplierInfo>()
-            .eq(SupplierInfo::getSupplierName, bo.getCustomerName())
+            .eq(SupplierInfo::getSupplierName, bo.getEnterpriseName())
         );
+
         if (one != null) {
-            throw new ServiceException("客户已存在");
+            throw new ServiceException("供应商已存在");
         }
 
         //查询企查查是否存在企业,如果企查查不存在则提示企业不存在
-        CompanyInfoResponse companyInfo = QccUtils.getCompanyInfo(bo.getCustomerName());
+        CompanyInfoResponse companyInfo = QccUtils.getCompanyInfo(bo.getEnterpriseName());
         if (companyInfo == null || companyInfo.getResult() == null) {
             throw new ServiceException("请检查企业名是否正确");
         }
 
         //构建客户信息实体
         SupplierInfo supplierInfo = new SupplierInfo();
-        supplierInfo.setSupplierName(bo.getCustomerName());
-        supplierInfo.setSupplierName(companyInfo.getResult().getName());
+        LambdaQueryWrapper<SupplierInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        // 按supplier_no降序排序,取第一条(最大值)
+        lambdaQueryWrapper.select(SupplierInfo::getSupplierNo)
+            .orderByDesc(SupplierInfo::getSupplierNo)
+            .last("LIMIT 1");
+        SupplierInfo maxSupplier = baseMapper.selectOne(lambdaQueryWrapper);
+        long l = Long.parseLong(maxSupplier.getSupplierNo()) + 1;
+        supplierInfo.setSupplierNo(String.valueOf(l));
+        // supplierInfo.setSupplierName(bo.getCustomerName()); //表中的该字段是表示 供应商联系人的名称
+        supplierInfo.setEnterpriseName(bo.getEnterpriseName());//表示供应商名称
+        supplierInfo.setBusinessName(companyInfo.getResult().getName());//表示供应商的工商名称
+        supplierInfo.setInvoiceHeader(companyInfo.getResult().getName());
         supplierInfo.setShortName(companyInfo.getResult().getName());
+        supplierInfo.setMembershipSize(bo.getMembershipSize());
+        supplierInfo.setFixedPhone(bo.getFixedPhone());
+        supplierInfo.setFax(bo.getFax());
+        supplierInfo.setUrl(bo.getUrl());
+        supplierInfo.setMailbox(bo.getMailbox());
+        supplierInfo.setOfficeProvince(bo.getOfficeProvince());
+        supplierInfo.setOfficeCity(bo.getOfficeCity());
+        supplierInfo.setOfficeCounty(bo.getOfficeCounty());
+        supplierInfo.setOfficeAddress(bo.getOfficeAddress());
+        supplierInfo.setSocialCreditCode(companyInfo.getResult().getCreditCode());
+        supplierInfo.setYearSales(bo.getYearSales());
+        supplierInfo.setOperatingCategory(bo.getOperatingCategory());
+        supplierInfo.setBusinessLicense(bo.getBusinessLicense());
 
         // 设置其他工商信息
         if (baseMapper.insert(supplierInfo) <= 0) {
@@ -1991,27 +2013,49 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
         Long supplierId = supplierInfo.getId();
 
+        String supplierNo = supplierInfo.getSupplierNo();
+
         // 添加客户工商信息
         SupplierBusinessInfo businessInfo = new SupplierBusinessInfo();
         businessInfo.setSupplierId(supplierId);
         businessInfo.setBusinessName(companyInfo.getResult().getName());
         businessInfo.setSocialCreditCode(companyInfo.getResult().getCreditCode());
         businessInfo.setLegalPersonName(companyInfo.getResult().getOperName());
-        businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
+//        businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
+        // 注册资本:拼接数值 + 单位(如 "101万元")
+        String regCap = companyInfo.getResult().getRegisteredCapital();
+        String regUnit = companyInfo.getResult().getRegisteredCapitalUnit();
+        businessInfo.setRegisteredCapital(
+            StringUtils.isNotBlank(regCap) && StringUtils.isNotBlank(regUnit)
+                ? regCap + regUnit
+                : regCap
+        );
+
+        // 实缴资本
+        String paidCap = companyInfo.getResult().getPaidUpCapital();
+        String paidUnit = companyInfo.getResult().getPaidUpCapitalUnit();
+        businessInfo.setPaidInCapital(
+            StringUtils.isNotBlank(paidCap) && StringUtils.isNotBlank(paidUnit)
+                ? paidCap + paidUnit
+                : paidCap
+        );
+
         businessInfo.setEstablishmentDate(DateUtils.parseDate((companyInfo.getResult().getStartDate())));
         businessInfo.setRegistrationStatus(companyInfo.getResult().getStatus());
+        businessInfo.setRegistrationAuthority(companyInfo.getResult().getBelongOrg());
         businessInfo.setBusinessAddress(companyInfo.getResult().getAddress());
         businessInfo.setBussinessRange(companyInfo.getResult().getScope());
         businessInfo.setStatus("0");
         businessInfo.setDelFlag("0");
 
         if (supplierBusinessInfoMapper.insert(businessInfo) <= 0) {
-            throw new ServiceException("客户工商信息新增失败");
+            throw new ServiceException("供应商工商信息新增失败");
         }
 
         // 添加客户联系人信息
         SupplierContact contact = new SupplierContact();
         contact.setSupplierId(supplierId);
+        contact.setSupplierNo(supplierNo);
         contact.setUserName(bo.getPurchaseName());
         contact.setPhone(bo.getPurchasePhone());
         contact.setPhone(bo.getPurchasePhone());
@@ -2021,13 +2065,44 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
         contact.setDelFlag("0");
 
         if (supplierContactMapper.insert(contact) <= 0) {
-            throw new ServiceException("客户联系人信息新增失败");
+            throw new ServiceException("供应商联系人信息新增失败");
+        }
+
+        List<SupplyAreaBo> supplyAreaList = bo.getSupplyAreaList();
+        if (supplyAreaList == null || supplyAreaList.isEmpty()) {
+            throw new ServiceException("供应商供应区域为空");
+        }
+
+        // 1. 内存中转换对象
+        List<SupplyArea> insertList = new ArrayList<>(supplyAreaList.size());
+        Set<String> uniqueCodes = new HashSet<>();
+        for (SupplyAreaBo area : supplyAreaList) {
+            if (!uniqueCodes.add(area.getAreaCode())) {
+                throw new ServiceException("供应区域代码 [" + area.getAreaCode() + "] 重复");
+            }
+            SupplyArea supplyArea = new SupplyArea();
+            supplyArea.setSupplierId(supplierId);
+            supplyArea.setSupplyNo(supplierNo);
+            supplyArea.setAreaCode(area.getAreaCode());
+            supplyArea.setAreaName(area.getAreaName());
+            supplyArea.setParentCode(area.getParentCode());
+            supplyArea.setLevel(area.getLevel());
+            supplyArea.setDelFlag("0");
+            supplyArea.setStatus("0");
+            insertList.add(supplyArea);
+        }
+
+        // 2. 执行批量插入
+        boolean b = supplyAreaMapper.insertBatch(insertList);
+
+        if (!b) {
+            throw new ServiceException("供应商供应区域信息批量新增失败");
         }
 
         // 创建系统用户
         RemoteUserBo remoteUserBo = new RemoteUserBo();
         remoteUserBo.setUserName(bo.getPurchasePhone());
-        remoteUserBo.setNickName(bo.getCustomerName());
+        remoteUserBo.setNickName(bo.getPurchaseName());
         remoteUserBo.setPhonenumber(bo.getPurchasePhone());
         remoteUserBo.setPassword(BCrypt.hashpw(bo.getPassword()));
         remoteUserBo.setUserSonType("3"); // 商城用户
@@ -2036,13 +2111,13 @@ public class SupplierInfoServiceImpl  extends ServiceImpl<SupplierInfoMapper, Su
 
         remoteUserService.addUser(remoteUserBo);
 
-        log.info("客户注册成功,客户ID:{},客户名称:{}", supplierId, bo.getCustomerName());
+        log.info("供应商注册成功,供应商ID:{},供应商名称:{}", supplierId, bo.getEnterpriseName());
         return true;
     }
 
     @Override
     public List<SupplierInfoVo> getNameList() {
-        List<SupplierInfoVo> supplierInfoVos = baseMapper.selectVoList(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getId, SupplierInfo::getEnterpriseName,SupplierInfo::getSupplierNo));
+        List<SupplierInfoVo> supplierInfoVos = baseMapper.selectVoList(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getId, SupplierInfo::getEnterpriseName, SupplierInfo::getSupplierNo));
         return supplierInfoVos;
     }
 }

+ 2 - 1
ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java

@@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.NotEmpty;
+
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
@@ -65,7 +66,7 @@ public class SysOssController extends BaseController {
      *
      * @param file 文件
      */
-    @SaCheckPermission("system:oss:upload")
+//    @SaCheckPermission("system:oss:upload")
     @Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
     @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     public R<SysOssUploadVo> upload(@RequestPart("file") MultipartFile file) {

+ 15 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/pc/PcSysUserController.java

@@ -2,9 +2,13 @@ package org.dromara.system.controller.pc;
 
 import cn.hutool.crypto.digest.BCrypt;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.constant.GlobalConstants;
 import org.dromara.common.core.domain.R;
+import org.dromara.common.core.exception.ServiceException;
+import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.web.core.BaseController;
+import org.dromara.system.domain.bo.ChangeUserPwdBo;
 import org.dromara.system.domain.bo.SysUserBo;
 import org.dromara.system.service.ISysUserService;
 import org.springframework.validation.annotation.Validated;
@@ -26,9 +30,19 @@ public class PcSysUserController extends BaseController {
      * 重置密码
      */
     @PutMapping("/changePwd")
-    public R<Void> changePwd(@RequestBody SysUserBo user) {
+    public R<Void> changePwd(@RequestBody ChangeUserPwdBo user) {
         Long userId = LoginHelper.getLoginUser().getUserId();
         user.setUserId(userId);
+        //先校验验证码是否正确
+        String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + user.getPhonenumber());
+        if (!code.equals(user.getCode())) {
+            throw new ServiceException("验证码错误");
+        }
+
+        //校验密码与确认密码是否一致
+        if (!user.getPassword().equals(user.getConfirmPassword())) {
+            throw new ServiceException("密码与确认密码不一致");
+        }
         sysUserService.checkUserAllowed(user.getUserId());
         sysUserService.checkUserDataScope(user.getUserId());
         user.setPassword(BCrypt.hashpw(user.getPassword()));

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysCompany.java

@@ -92,6 +92,11 @@ public class SysCompany extends TenantEntity {
      */
     private String status;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
     /**
      * 删除标志(0代表存在 2代表删除)
      */

+ 30 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ChangeUserPwdBo.java

@@ -0,0 +1,30 @@
+package org.dromara.system.domain.bo;
+
+import lombok.Data;
+
+@Data
+public class ChangeUserPwdBo {
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 手机号码
+     */
+    private String phonenumber;
+
+    /**
+     * 验证码
+     */
+    private String code;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /*确认密码*/
+    private String confirmPassword;
+}

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysCompanyBo.java

@@ -89,6 +89,11 @@ public class SysCompanyBo extends BaseEntity {
      */
     private String isShow;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
     /**
      * 状态(0正常 1停用)
      */

+ 10 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysUserBo.java

@@ -72,11 +72,19 @@ public class SysUserBo extends BaseEntity {
      */
     private String sex;
 
+    /**
+     * 验证码
+     */
+    private String code;
+
     /**
      * 密码
      */
     private String password;
 
+    /*确认密码*/
+    private String confirmPassword;
+
     /**
      * 帐号状态(0正常 1停用)
      */
@@ -88,8 +96,8 @@ public class SysUserBo extends BaseEntity {
     private String remark;
 
     /**
-    * 用户子类型 用户子类型(0=平台用户,1=供应商,2=伙伴商,3=商城用户)
-    * */
+     * 用户子类型 用户子类型(0=平台用户,1=供应商,2=伙伴商,3=商城用户)
+     */
     private String userSonType;
 
     /**

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysCompanyVo.java

@@ -112,6 +112,11 @@ public class SysCompanyVo implements Serializable {
     @ExcelDictFormat(readConverterExp = "0=正常,1=停用")
     private String status;
 
+    /**
+     * 数据源
+     */
+    private String dataSource;
+
     /**
      * 备注
      */

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysCompanyServiceImpl.java

@@ -89,6 +89,7 @@ public class SysCompanyServiceImpl extends ServiceImpl<SysCompanyMapper, SysComp
         lqw.eq(bo.getRegistrationDate() != null, SysCompany::getRegistrationDate, bo.getRegistrationDate());
         lqw.eq(StringUtils.isNotBlank(bo.getIsShow()), SysCompany::getIsShow, bo.getIsShow());
         lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysCompany::getStatus, bo.getStatus());
+        lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), SysCompany::getDataSource, bo.getDataSource());
         lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), SysCompany::getPlatformCode, bo.getPlatformCode());
         return lqw;
     }

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java

@@ -229,7 +229,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
                 SysDept::getParentId,
                 SysDept::getOrderNum,
                 SysDept::getStatus)
-            .eq(SysDept::getStatus, SystemConstants.NORMAL)
+//            .eq(SysDept::getStatus, SystemConstants.NORMAL)
             .in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds));
     }