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