Commit 7495bb05d19819c5e026750c118b65ee6d336021

Authored by YunaiV
1 parent 256d2435

✨ ERP:增加 ERP 客户的实现

Showing 20 changed files with 760 additions and 23 deletions
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java
@@ -13,8 +13,12 @@ public interface ErrorCodeConstants { @@ -13,8 +13,12 @@ public interface ErrorCodeConstants {
13 ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_030_100_000, "供应商不存在"); 13 ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_030_100_000, "供应商不存在");
14 ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_030_100_000, "供应商({})未启用"); 14 ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_030_100_000, "供应商({})未启用");
15 15
16 - // ========== ERP 销售订单(1-030-200-000) ==========  
17 - ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_200_000, "销售订单不存在"); 16 + // ========== ERP 客户(1-030-200-000)==========
  17 + ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_200_000, "客户不存在");
  18 + ErrorCode CUSTOMER_NOT_ENABLE = new ErrorCode(1_020_200_001, "客户({})未启用");
  19 +
  20 + // ========== ERP 销售订单(1-030-201-000) ==========
  21 + ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_201_000, "销售订单不存在");
18 22
19 // ========== ERP 仓库 1-030-400-000 ========== 23 // ========== ERP 仓库 1-030-400-000 ==========
20 ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); 24 ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在");
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java
@@ -10,7 +10,7 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; @@ -10,7 +10,7 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
10 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; 10 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
11 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO; 11 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO;
12 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; 12 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
13 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 13 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
14 import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; 14 import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService;
15 import io.swagger.v3.oas.annotations.Operation; 15 import io.swagger.v3.oas.annotations.Operation;
16 import io.swagger.v3.oas.annotations.Parameter; 16 import io.swagger.v3.oas.annotations.Parameter;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.controller.admin.sale;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  7 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  8 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  9 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  10 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO;
  11 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerRespVO;
  12 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO;
  13 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
  14 +import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
  15 +import io.swagger.v3.oas.annotations.Operation;
  16 +import io.swagger.v3.oas.annotations.Parameter;
  17 +import io.swagger.v3.oas.annotations.tags.Tag;
  18 +import jakarta.annotation.Resource;
  19 +import jakarta.servlet.http.HttpServletResponse;
  20 +import jakarta.validation.Valid;
  21 +import org.springframework.security.access.prepost.PreAuthorize;
  22 +import org.springframework.validation.annotation.Validated;
  23 +import org.springframework.web.bind.annotation.*;
  24 +
  25 +import java.io.IOException;
  26 +import java.util.List;
  27 +
  28 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  29 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
  30 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  31 +
  32 +@Tag(name = "管理后台 - ERP 客户")
  33 +@RestController
  34 +@RequestMapping("/erp/customer")
  35 +@Validated
  36 +public class ErpCustomerController {
  37 +
  38 + @Resource
  39 + private ErpCustomerService customerService;
  40 +
  41 + @PostMapping("/create")
  42 + @Operation(summary = "创建客户")
  43 + @PreAuthorize("@ss.hasPermission('erp:customer:create')")
  44 + public CommonResult<Long> createCustomer(@Valid @RequestBody ErpCustomerSaveReqVO createReqVO) {
  45 + return success(customerService.createCustomer(createReqVO));
  46 + }
  47 +
  48 + @PutMapping("/update")
  49 + @Operation(summary = "更新客户")
  50 + @PreAuthorize("@ss.hasPermission('erp:customer:update')")
  51 + public CommonResult<Boolean> updateCustomer(@Valid @RequestBody ErpCustomerSaveReqVO updateReqVO) {
  52 + customerService.updateCustomer(updateReqVO);
  53 + return success(true);
  54 + }
  55 +
  56 + @DeleteMapping("/delete")
  57 + @Operation(summary = "删除客户")
  58 + @Parameter(name = "id", description = "编号", required = true)
  59 + @PreAuthorize("@ss.hasPermission('erp:customer:delete')")
  60 + public CommonResult<Boolean> deleteCustomer(@RequestParam("id") Long id) {
  61 + customerService.deleteCustomer(id);
  62 + return success(true);
  63 + }
  64 +
  65 + @GetMapping("/get")
  66 + @Operation(summary = "获得客户")
  67 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  68 + @PreAuthorize("@ss.hasPermission('erp:customer:query')")
  69 + public CommonResult<ErpCustomerRespVO> getCustomer(@RequestParam("id") Long id) {
  70 + ErpCustomerDO customer = customerService.getCustomer(id);
  71 + return success(BeanUtils.toBean(customer, ErpCustomerRespVO.class));
  72 + }
  73 +
  74 + @GetMapping("/page")
  75 + @Operation(summary = "获得客户分页")
  76 + @PreAuthorize("@ss.hasPermission('erp:customer:query')")
  77 + public CommonResult<PageResult<ErpCustomerRespVO>> getCustomerPage(@Valid ErpCustomerPageReqVO pageReqVO) {
  78 + PageResult<ErpCustomerDO> pageResult = customerService.getCustomerPage(pageReqVO);
  79 + return success(BeanUtils.toBean(pageResult, ErpCustomerRespVO.class));
  80 + }
  81 +
  82 + @GetMapping("/simple-list")
  83 + @Operation(summary = "获得客户精简列表", description = "只包含被开启的客户,主要用于前端的下拉选项")
  84 + public CommonResult<List<ErpCustomerRespVO>> getCustomerSimpleList() {
  85 + List<ErpCustomerDO> list = customerService.getCustomerListByStatus(CommonStatusEnum.ENABLE.getStatus());
  86 + return success(convertList(list, customer -> new ErpCustomerRespVO().setId(customer.getId()).setName(customer.getName())));
  87 + }
  88 +
  89 + @GetMapping("/export-excel")
  90 + @Operation(summary = "导出客户 Excel")
  91 + @PreAuthorize("@ss.hasPermission('erp:customer:export')")
  92 + @OperateLog(type = EXPORT)
  93 + public void exportCustomerExcel(@Valid ErpCustomerPageReqVO pageReqVO,
  94 + HttpServletResponse response) throws IOException {
  95 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  96 + List<ErpCustomerDO> list = customerService.getCustomerPage(pageReqVO).getList();
  97 + // 导出 Excel
  98 + ExcelUtils.write(response, "客户.xls", "数据", ErpCustomerRespVO.class,
  99 + BeanUtils.toBean(list, ErpCustomerRespVO.class));
  100 + }
  101 +
  102 +}
0 \ No newline at end of file 103 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import java.math.BigDecimal;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +import java.time.LocalDateTime;
  10 +
  11 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  12 +
  13 +@Schema(description = "管理后台 - ERP 客户分页 Request VO")
  14 +@Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@ToString(callSuper = true)
  17 +public class ErpCustomerPageReqVO extends PageParam {
  18 +
  19 + @Schema(description = "客户名称", example = "张三")
  20 + private String name;
  21 +
  22 + @Schema(description = "手机号码", example = "15601691300")
  23 + private String mobile;
  24 +
  25 + @Schema(description = "联系电话", example = "15601691300")
  26 + private String telephone;
  27 +
  28 +}
0 \ No newline at end of file 29 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import java.util.*;
  7 +import java.math.BigDecimal;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +import java.time.LocalDateTime;
  10 +import com.alibaba.excel.annotation.*;
  11 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  12 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  13 +
  14 +@Schema(description = "管理后台 - ERP 客户 Response VO")
  15 +@Data
  16 +@ExcelIgnoreUnannotated
  17 +public class ErpCustomerRespVO {
  18 +
  19 + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520")
  20 + @ExcelProperty("客户编号")
  21 + private Long id;
  22 +
  23 + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
  24 + @ExcelProperty("客户名称")
  25 + private String name;
  26 +
  27 + @Schema(description = "联系人", example = "老王")
  28 + @ExcelProperty("联系人")
  29 + private String contact;
  30 +
  31 + @Schema(description = "手机号码", example = "15601691300")
  32 + @ExcelProperty("手机号码")
  33 + private String mobile;
  34 +
  35 + @Schema(description = "联系电话", example = "15601691300")
  36 + @ExcelProperty("联系电话")
  37 + private String telephone;
  38 +
  39 + @Schema(description = "电子邮箱", example = "7685323@qq.com")
  40 + @ExcelProperty("电子邮箱")
  41 + private String email;
  42 +
  43 + @Schema(description = "传真", example = "20 7123 4567")
  44 + @ExcelProperty("传真")
  45 + private String fax;
  46 +
  47 + @Schema(description = "备注", example = "你猜")
  48 + @ExcelProperty("备注")
  49 + private String remark;
  50 +
  51 + @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  52 + @ExcelProperty(value = "开启状态", converter = DictConvert.class)
  53 + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
  54 + private Integer status;
  55 +
  56 + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  57 + @ExcelProperty("排序")
  58 + private Integer sort;
  59 +
  60 + @Schema(description = "纳税人识别号", example = "91130803MA098BY05W")
  61 + @ExcelProperty("纳税人识别号")
  62 + private String taxNo;
  63 +
  64 + @Schema(description = "税率", example = "10")
  65 + @ExcelProperty("税率")
  66 + private BigDecimal taxPercent;
  67 +
  68 + @Schema(description = "开户行", example = "芋艿")
  69 + @ExcelProperty("开户行")
  70 + private String bankName;
  71 +
  72 + @Schema(description = "开户账号", example = "622908212277228617")
  73 + @ExcelProperty("开户账号")
  74 + private String bankAccount;
  75 +
  76 + @Schema(description = "开户地址", example = "兴业银行浦东支行")
  77 + @ExcelProperty("开户地址")
  78 + private String bankAddress;
  79 +
  80 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  81 + @ExcelProperty("创建时间")
  82 + private LocalDateTime createTime;
  83 +
  84 +}
0 \ No newline at end of file 85 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import jakarta.validation.constraints.*;
  7 +import java.math.BigDecimal;
  8 +
  9 +@Schema(description = "管理后台 - ERP 客户新增/修改 Request VO")
  10 +@Data
  11 +public class ErpCustomerSaveReqVO {
  12 +
  13 + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520")
  14 + private Long id;
  15 +
  16 + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
  17 + @NotEmpty(message = "客户名称不能为空")
  18 + private String name;
  19 +
  20 + @Schema(description = "联系人", example = "老王")
  21 + private String contact;
  22 +
  23 + @Schema(description = "手机号码", example = "15601691300")
  24 + private String mobile;
  25 +
  26 + @Schema(description = "联系电话", example = "15601691300")
  27 + private String telephone;
  28 +
  29 + @Schema(description = "电子邮箱", example = "7685323@qq.com")
  30 + private String email;
  31 +
  32 + @Schema(description = "传真", example = "20 7123 4567")
  33 + private String fax;
  34 +
  35 + @Schema(description = "备注", example = "你猜")
  36 + private String remark;
  37 +
  38 + @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  39 + @NotNull(message = "开启状态不能为空")
  40 + private Integer status;
  41 +
  42 + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  43 + @NotNull(message = "排序不能为空")
  44 + private Integer sort;
  45 +
  46 + @Schema(description = "纳税人识别号", example = "91130803MA098BY05W")
  47 + private String taxNo;
  48 +
  49 + @Schema(description = "税率", example = "10")
  50 + private BigDecimal taxPercent;
  51 +
  52 + @Schema(description = "开户行", example = "芋艿")
  53 + private String bankName;
  54 +
  55 + @Schema(description = "开户账号", example = "622908212277228617")
  56 + private String bankAccount;
  57 +
  58 + @Schema(description = "开户地址", example = "兴业银行浦东支行")
  59 + private String bankAddress;
  60 +
  61 +}
0 \ No newline at end of file 62 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java
@@ -15,7 +15,7 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveRe @@ -15,7 +15,7 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveRe
15 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; 15 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
16 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; 16 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO;
17 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; 17 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO;
18 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 18 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
19 import cn.iocoder.yudao.module.erp.service.product.ErpProductService; 19 import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
20 import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; 20 import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService;
21 import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; 21 import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService;
@@ -77,7 +77,7 @@ public class ErpStockInController { @@ -77,7 +77,7 @@ public class ErpStockInController {
77 77
78 @PutMapping("/update-status") 78 @PutMapping("/update-status")
79 @Operation(summary = "更新其它入库单的状态") 79 @Operation(summary = "更新其它入库单的状态")
80 - @PreAuthorize("@ss.hasPermission('erp:stock-in:update')") 80 + @PreAuthorize("@ss.hasPermission('erp:stock-in:update-status')")
81 public CommonResult<Boolean> updateStockInStatus(@RequestParam("id") Long id, 81 public CommonResult<Boolean> updateStockInStatus(@RequestParam("id") Long id,
82 @RequestParam("status") Integer status) { 82 @RequestParam("status") Integer status) {
83 stockInService.updateStockInStatus(id, status); 83 stockInService.updateStockInStatus(id, status);
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java
@@ -12,10 +12,12 @@ import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProduc @@ -12,10 +12,12 @@ import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProduc
12 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; 12 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
13 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO; 13 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO;
14 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; 14 import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
  15 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
15 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; 16 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
16 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; 17 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO;
17 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; 18 import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
18 import cn.iocoder.yudao.module.erp.service.product.ErpProductService; 19 import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
  20 +import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
19 import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService; 21 import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService;
20 import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; 22 import cn.iocoder.yudao.module.erp.service.stock.ErpStockService;
21 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 23 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@@ -52,8 +54,8 @@ public class ErpStockOutController { @@ -52,8 +54,8 @@ public class ErpStockOutController {
52 private ErpStockService stockService; 54 private ErpStockService stockService;
53 @Resource 55 @Resource
54 private ErpProductService productService; 56 private ErpProductService productService;
55 -// @Resource  
56 -// private ErpSupplierService supplierService; 57 + @Resource
  58 + private ErpCustomerService customerService;
57 59
58 @Resource 60 @Resource
59 private AdminUserApi adminUserApi; 61 private AdminUserApi adminUserApi;
@@ -75,7 +77,7 @@ public class ErpStockOutController { @@ -75,7 +77,7 @@ public class ErpStockOutController {
75 77
76 @PutMapping("/update-status") 78 @PutMapping("/update-status")
77 @Operation(summary = "更新其它出库单的状态") 79 @Operation(summary = "更新其它出库单的状态")
78 - @PreAuthorize("@ss.hasPermission('erp:stock-out:update')") 80 + @PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')")
79 public CommonResult<Boolean> updateStockOutStatus(@RequestParam("id") Long id, 81 public CommonResult<Boolean> updateStockOutStatus(@RequestParam("id") Long id,
80 @RequestParam("status") Integer status) { 82 @RequestParam("status") Integer status) {
81 stockOutService.updateStockOutStatus(id, status); 83 stockOutService.updateStockOutStatus(id, status);
@@ -143,9 +145,9 @@ public class ErpStockOutController { @@ -143,9 +145,9 @@ public class ErpStockOutController {
143 // 1.2 商品信息 145 // 1.2 商品信息
144 Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( 146 Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
145 convertSet(stockOutItemList, ErpStockOutItemDO::getProductId)); 147 convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
146 - // 1.3 客户信息 TODO  
147 -// Map<Long, ErpSupplierDO> supplierMap = supplierService.getSupplierMap(  
148 -// convertSet(pageResult.getList(), ErpStockOutDO::getSupplierId)); 148 + // 1.3 客户信息
  149 + Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
  150 + convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId));
149 // 1.4 管理员信息 151 // 1.4 管理员信息
150 Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( 152 Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
151 convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); 153 convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator())));
@@ -155,7 +157,7 @@ public class ErpStockOutController { @@ -155,7 +157,7 @@ public class ErpStockOutController {
155 item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) 157 item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
156 .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); 158 .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()))));
157 stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName)); 159 stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName));
158 -// MapUtils.findAndThen(supplierMap, stockOut.getSupplierId(), supplier -> stockOut.setSupplierName(supplier.getName())); 160 + MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName()));
159 MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname())); 161 MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname()));
160 }); 162 });
161 } 163 }
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/supplier/ErpSupplierDO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java
1 -package cn.iocoder.yudao.module.erp.dal.dataobject.supplier; 1 +package cn.iocoder.yudao.module.erp.dal.dataobject.purchase;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 import com.baomidou.mybatisplus.annotation.KeySequence; 4 import com.baomidou.mybatisplus.annotation.KeySequence;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.dal.dataobject.sale;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +import java.math.BigDecimal;
  10 +
  11 +/**
  12 + * ERP 客户 DO
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@TableName("erp_customer")
  17 +@KeySequence("erp_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  18 +@Data
  19 +@EqualsAndHashCode(callSuper = true)
  20 +@ToString(callSuper = true)
  21 +@Builder
  22 +@NoArgsConstructor
  23 +@AllArgsConstructor
  24 +public class ErpCustomerDO extends BaseDO {
  25 +
  26 + /**
  27 + * 客户编号
  28 + */
  29 + @TableId
  30 + private Long id;
  31 + /**
  32 + * 客户名称
  33 + */
  34 + private String name;
  35 + /**
  36 + * 联系人
  37 + */
  38 + private String contact;
  39 + /**
  40 + * 手机号码
  41 + */
  42 + private String mobile;
  43 + /**
  44 + * 联系电话
  45 + */
  46 + private String telephone;
  47 + /**
  48 + * 电子邮箱
  49 + */
  50 + private String email;
  51 + /**
  52 + * 传真
  53 + */
  54 + private String fax;
  55 + /**
  56 + * 备注
  57 + */
  58 + private String remark;
  59 + /**
  60 + * 开启状态
  61 + *
  62 + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
  63 + */
  64 + private Integer status;
  65 + /**
  66 + * 排序
  67 + */
  68 + private Integer sort;
  69 + /**
  70 + * 纳税人识别号
  71 + */
  72 + private String taxNo;
  73 + /**
  74 + * 税率
  75 + */
  76 + private BigDecimal taxPercent;
  77 + /**
  78 + * 开户行
  79 + */
  80 + private String bankName;
  81 + /**
  82 + * 开户账号
  83 + */
  84 + private String bankAccount;
  85 + /**
  86 + * 开户地址
  87 + */
  88 + private String bankAddress;
  89 +
  90 +}
0 \ No newline at end of file 91 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java
1 package cn.iocoder.yudao.module.erp.dal.dataobject.stock; 1 package cn.iocoder.yudao.module.erp.dal.dataobject.stock;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 4 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
5 import com.baomidou.mybatisplus.annotation.KeySequence; 5 import com.baomidou.mybatisplus.annotation.KeySequence;
6 import com.baomidou.mybatisplus.annotation.TableId; 6 import com.baomidou.mybatisplus.annotation.TableId;
7 import com.baomidou.mybatisplus.annotation.TableName; 7 import com.baomidou.mybatisplus.annotation.TableName;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
6 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; 6 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
7 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 7 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
8 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
9 9
10 import java.util.List; 10 import java.util.List;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.dal.mysql.sale;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO;
  7 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * ERP 客户 Mapper
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface ErpCustomerMapper extends BaseMapperX<ErpCustomerDO> {
  19 +
  20 + default PageResult<ErpCustomerDO> selectPage(ErpCustomerPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<ErpCustomerDO>()
  22 + .likeIfPresent(ErpCustomerDO::getName, reqVO.getName())
  23 + .eqIfPresent(ErpCustomerDO::getMobile, reqVO.getMobile())
  24 + .eqIfPresent(ErpCustomerDO::getTelephone, reqVO.getTelephone())
  25 + .orderByDesc(ErpCustomerDO::getId));
  26 + }
  27 +
  28 + default List<ErpCustomerDO> selectListByStatus(Integer status) {
  29 + return selectList(ErpCustomerDO::getStatus, status);
  30 + }
  31 +
  32 +}
0 \ No newline at end of file 33 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.erp.service.purchase; @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.erp.service.purchase;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; 4 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
5 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; 5 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
6 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 6 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
7 import jakarta.validation.Valid; 7 import jakarta.validation.Valid;
8 8
9 import java.util.Collection; 9 import java.util.Collection;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java
@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; 6 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
7 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; 7 import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
8 -import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; 8 +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO;
9 import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper; 9 import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper;
10 import jakarta.annotation.Resource; 10 import jakarta.annotation.Resource;
11 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.service.sale;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO;
  5 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO;
  6 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +import java.util.Collection;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  14 +
  15 +/**
  16 + * ERP 客户 Service 接口
  17 + *
  18 + * @author 芋道源码
  19 + */
  20 +public interface ErpCustomerService {
  21 +
  22 + /**
  23 + * 创建客户
  24 + *
  25 + * @param createReqVO 创建信息
  26 + * @return 编号
  27 + */
  28 + Long createCustomer(@Valid ErpCustomerSaveReqVO createReqVO);
  29 +
  30 + /**
  31 + * 更新客户
  32 + *
  33 + * @param updateReqVO 更新信息
  34 + */
  35 + void updateCustomer(@Valid ErpCustomerSaveReqVO updateReqVO);
  36 +
  37 + /**
  38 + * 删除客户
  39 + *
  40 + * @param id 编号
  41 + */
  42 + void deleteCustomer(Long id);
  43 +
  44 + /**
  45 + * 获得客户
  46 + *
  47 + * @param id 编号
  48 + * @return 客户
  49 + */
  50 + ErpCustomerDO getCustomer(Long id);
  51 +
  52 + /**
  53 + * 校验客户
  54 + *
  55 + * @param id 编号
  56 + * @return 客户
  57 + */
  58 + ErpCustomerDO validateCustomer(Long id);
  59 +
  60 + /**
  61 + * 获得客户列表
  62 + *
  63 + * @param ids 编号列表
  64 + * @return 客户列表
  65 + */
  66 + List<ErpCustomerDO> getCustomerList(Collection<Long> ids);
  67 +
  68 + /**
  69 + * 获得客户 Map
  70 + *
  71 + * @param ids 编号列表
  72 + * @return 客户 Map
  73 + */
  74 + default Map<Long, ErpCustomerDO> getCustomerMap(Collection<Long> ids) {
  75 + return convertMap(getCustomerList(ids), ErpCustomerDO::getId);
  76 + }
  77 +
  78 + /**
  79 + * 获得客户分页
  80 + *
  81 + * @param pageReqVO 分页查询
  82 + * @return 客户分页
  83 + */
  84 + PageResult<ErpCustomerDO> getCustomerPage(ErpCustomerPageReqVO pageReqVO);
  85 +
  86 + /**
  87 + * 获得指定状态的客户列表
  88 + *
  89 + * @param status 状态
  90 + * @return 客户列表
  91 + */
  92 + List<ErpCustomerDO> getCustomerListByStatus(Integer status);
  93 +
  94 +}
0 \ No newline at end of file 95 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.service.sale;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO;
  7 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO;
  8 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
  9 +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper;
  10 +import jakarta.annotation.Resource;
  11 +import org.springframework.stereotype.Service;
  12 +import org.springframework.validation.annotation.Validated;
  13 +
  14 +import java.util.Collection;
  15 +import java.util.List;
  16 +
  17 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  18 +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_ENABLE;
  19 +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
  20 +
  21 +/**
  22 + * ERP 客户 Service 实现类
  23 + *
  24 + * @author 芋道源码
  25 + */
  26 +@Service
  27 +@Validated
  28 +public class ErpCustomerServiceImpl implements ErpCustomerService {
  29 +
  30 + @Resource
  31 + private ErpCustomerMapper customerMapper;
  32 +
  33 + @Override
  34 + public Long createCustomer(ErpCustomerSaveReqVO createReqVO) {
  35 + // 插入
  36 + ErpCustomerDO customer = BeanUtils.toBean(createReqVO, ErpCustomerDO.class);
  37 + customerMapper.insert(customer);
  38 + // 返回
  39 + return customer.getId();
  40 + }
  41 +
  42 + @Override
  43 + public void updateCustomer(ErpCustomerSaveReqVO updateReqVO) {
  44 + // 校验存在
  45 + validateCustomerExists(updateReqVO.getId());
  46 + // 更新
  47 + ErpCustomerDO updateObj = BeanUtils.toBean(updateReqVO, ErpCustomerDO.class);
  48 + customerMapper.updateById(updateObj);
  49 + }
  50 +
  51 + @Override
  52 + public void deleteCustomer(Long id) {
  53 + // 校验存在
  54 + validateCustomerExists(id);
  55 + // 删除
  56 + customerMapper.deleteById(id);
  57 + }
  58 +
  59 + private void validateCustomerExists(Long id) {
  60 + if (customerMapper.selectById(id) == null) {
  61 + throw exception(CUSTOMER_NOT_EXISTS);
  62 + }
  63 + }
  64 +
  65 + @Override
  66 + public ErpCustomerDO getCustomer(Long id) {
  67 + return customerMapper.selectById(id);
  68 + }
  69 +
  70 + @Override
  71 + public ErpCustomerDO validateCustomer(Long id) {
  72 + ErpCustomerDO customer = customerMapper.selectById(id);
  73 + if (customer == null) {
  74 + throw exception(CUSTOMER_NOT_EXISTS);
  75 + }
  76 + if (CommonStatusEnum.isDisable(customer.getStatus())) {
  77 + throw exception(CUSTOMER_NOT_ENABLE, customer.getName());
  78 + }
  79 + return customer;
  80 + }
  81 +
  82 + @Override
  83 + public List<ErpCustomerDO> getCustomerList(Collection<Long> ids) {
  84 + return customerMapper.selectBatchIds(ids);
  85 + }
  86 +
  87 + @Override
  88 + public PageResult<ErpCustomerDO> getCustomerPage(ErpCustomerPageReqVO pageReqVO) {
  89 + return customerMapper.selectPage(pageReqVO);
  90 + }
  91 +
  92 + @Override
  93 + public List<ErpCustomerDO> getCustomerListByStatus(Integer status) {
  94 + return customerMapper.selectListByStatus(status);
  95 + }
  96 +
  97 +}
0 \ No newline at end of file 98 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java
@@ -15,7 +15,7 @@ import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; @@ -15,7 +15,7 @@ import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO;
15 import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; 15 import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
16 import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; 16 import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
17 import cn.iocoder.yudao.module.erp.service.product.ErpProductService; 17 import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
18 -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; 18 +import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
19 import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; 19 import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
20 import jakarta.annotation.Resource; 20 import jakarta.annotation.Resource;
21 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
@@ -56,7 +56,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService { @@ -56,7 +56,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
56 @Resource 56 @Resource
57 private ErpWarehouseService warehouseService; 57 private ErpWarehouseService warehouseService;
58 @Resource 58 @Resource
59 - private ErpSupplierService supplierService; 59 + private ErpCustomerService customerService;
60 @Resource 60 @Resource
61 private ErpStockRecordService stockRecordService; 61 private ErpStockRecordService stockRecordService;
62 62
@@ -65,8 +65,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService { @@ -65,8 +65,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
65 public Long createStockOut(ErpStockOutSaveReqVO createReqVO) { 65 public Long createStockOut(ErpStockOutSaveReqVO createReqVO) {
66 // 1.1 校验出库项的有效性 66 // 1.1 校验出库项的有效性
67 List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(createReqVO.getItems()); 67 List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(createReqVO.getItems());
68 - // 1.2 校验客户 TODO  
69 -// supplierService.validateSupplier(createReqVO.getSupplierId()); 68 + // 1.2 校验客户
  69 + customerService.validateCustomer(createReqVO.getCustomerId());
70 // 1.3 70 // 1.3
71 String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX); 71 String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX);
72 if (stockOutMapper.selectByNo(no) != null) { 72 if (stockOutMapper.selectByNo(no) != null) {
@@ -93,8 +93,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService { @@ -93,8 +93,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
93 if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) { 93 if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) {
94 throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo()); 94 throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo());
95 } 95 }
96 - // 1.2 校验客户 TODO  
97 -// supplierService.validateSupplier(updateReqVO.getSupplierId()); 96 + // 1.2 校验客户
  97 + customerService.validateCustomer(updateReqVO.getCustomerId());
98 // 1.3 校验出库项的有效性 98 // 1.3 校验出库项的有效性
99 List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(updateReqVO.getItems()); 99 List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(updateReqVO.getItems());
100 100
yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/sale/ErpCustomerMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
0 \ No newline at end of file 13 \ No newline at end of file
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.erp.service.sale;
  2 +
  3 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO;
  4 +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO;
  5 +import org.junit.jupiter.api.Disabled;
  6 +import org.junit.jupiter.api.Test;
  7 +
  8 +import jakarta.annotation.Resource;
  9 +
  10 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
  11 +
  12 +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
  13 +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper;
  14 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  15 +
  16 +import org.springframework.context.annotation.Import;
  17 +
  18 +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
  19 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
  20 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
  21 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
  22 +import static org.junit.jupiter.api.Assertions.*;
  23 +
  24 +/**
  25 + * {@link ErpCustomerServiceImpl} 的单元测试类
  26 + *
  27 + * @author 芋道源码
  28 + */
  29 +@Import(ErpCustomerServiceImpl.class)
  30 +public class ErpCustomerServiceImplTest extends BaseDbUnitTest {
  31 +
  32 + @Resource
  33 + private ErpCustomerServiceImpl customerService;
  34 +
  35 + @Resource
  36 + private ErpCustomerMapper customerMapper;
  37 +
  38 + @Test
  39 + public void testCreateCustomer_success() {
  40 + // 准备参数
  41 + ErpCustomerSaveReqVO createReqVO = randomPojo(ErpCustomerSaveReqVO.class).setId(null);
  42 +
  43 + // 调用
  44 + Long customerId = customerService.createCustomer(createReqVO);
  45 + // 断言
  46 + assertNotNull(customerId);
  47 + // 校验记录的属性是否正确
  48 + ErpCustomerDO customer = customerMapper.selectById(customerId);
  49 + assertPojoEquals(createReqVO, customer, "id");
  50 + }
  51 +
  52 + @Test
  53 + public void testUpdateCustomer_success() {
  54 + // mock 数据
  55 + ErpCustomerDO dbCustomer = randomPojo(ErpCustomerDO.class);
  56 + customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
  57 + // 准备参数
  58 + ErpCustomerSaveReqVO updateReqVO = randomPojo(ErpCustomerSaveReqVO.class, o -> {
  59 + o.setId(dbCustomer.getId()); // 设置更新的 ID
  60 + });
  61 +
  62 + // 调用
  63 + customerService.updateCustomer(updateReqVO);
  64 + // 校验是否更新正确
  65 + ErpCustomerDO customer = customerMapper.selectById(updateReqVO.getId()); // 获取最新的
  66 + assertPojoEquals(updateReqVO, customer);
  67 + }
  68 +
  69 + @Test
  70 + public void testUpdateCustomer_notExists() {
  71 + // 准备参数
  72 + ErpCustomerSaveReqVO updateReqVO = randomPojo(ErpCustomerSaveReqVO.class);
  73 +
  74 + // 调用, 并断言异常
  75 + assertServiceException(() -> customerService.updateCustomer(updateReqVO), CUSTOMER_NOT_EXISTS);
  76 + }
  77 +
  78 + @Test
  79 + public void testDeleteCustomer_success() {
  80 + // mock 数据
  81 + ErpCustomerDO dbCustomer = randomPojo(ErpCustomerDO.class);
  82 + customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
  83 + // 准备参数
  84 + Long id = dbCustomer.getId();
  85 +
  86 + // 调用
  87 + customerService.deleteCustomer(id);
  88 + // 校验数据不存在了
  89 + assertNull(customerMapper.selectById(id));
  90 + }
  91 +
  92 + @Test
  93 + public void testDeleteCustomer_notExists() {
  94 + // 准备参数
  95 + Long id = randomLongId();
  96 +
  97 + // 调用, 并断言异常
  98 + assertServiceException(() -> customerService.deleteCustomer(id), CUSTOMER_NOT_EXISTS);
  99 + }
  100 +
  101 + @Test
  102 + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
  103 + public void testGetCustomerPage() {
  104 + // mock 数据
  105 + ErpCustomerDO dbCustomer = randomPojo(ErpCustomerDO.class, o -> { // 等会查询到
  106 + o.setName(null);
  107 + o.setMobile(null);
  108 + o.setTelephone(null);
  109 + });
  110 + customerMapper.insert(dbCustomer);
  111 + // 测试 name 不匹配
  112 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null)));
  113 + // 测试 mobile 不匹配
  114 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null)));
  115 + // 测试 telephone 不匹配
  116 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null)));
  117 + // 准备参数
  118 + ErpCustomerPageReqVO reqVO = new ErpCustomerPageReqVO();
  119 + reqVO.setName(null);
  120 + reqVO.setMobile(null);
  121 + reqVO.setTelephone(null);
  122 +
  123 + // 调用
  124 + PageResult<ErpCustomerDO> pageResult = customerService.getCustomerPage(reqVO);
  125 + // 断言
  126 + assertEquals(1, pageResult.getTotal());
  127 + assertEquals(1, pageResult.getList().size());
  128 + assertPojoEquals(dbCustomer, pageResult.getList().get(0));
  129 + }
  130 +
  131 +}
0 \ No newline at end of file 132 \ No newline at end of file