Commit 0d551a440850fae4f61de062a56ef5411e1b43f5
1 parent
2d43c1f9
✨ ERP:初始化 payment 付款单的逻辑 30%
Showing
44 changed files
with
1063 additions
and
702 deletions
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java
| ... | ... | @@ -33,6 +33,7 @@ ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_00 |
| 33 | 33 | ErrorCode PURCHASE_IN_APPROVE_FAIL = new ErrorCode(1_030_102_003, "审核失败,只有未审核的入库单才能审核"); |
| 34 | 34 | ErrorCode PURCHASE_IN_NO_EXISTS = new ErrorCode(1_030_102_004, "生成入库单失败,请重新提交"); |
| 35 | 35 | ErrorCode PURCHASE_IN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_102_005, "采购入库单({})已审核,无法修改"); |
| 36 | + ErrorCode PURCHASE_IN_NOT_APPROVE = new ErrorCode(1_030_102_006, "采购入库单未审核,无法操作"); | |
| 36 | 37 | |
| 37 | 38 | // ========== ERP 采购退货(1-030-103-000) ========== |
| 38 | 39 | ErrorCode PURCHASE_RETURN_NOT_EXISTS = new ErrorCode(1_030_103_000, "采购退货单不存在"); |
| ... | ... | @@ -41,6 +42,7 @@ ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_00 |
| 41 | 42 | ErrorCode PURCHASE_RETURN_APPROVE_FAIL = new ErrorCode(1_030_103_003, "审核失败,只有未审核的退货单才能审核"); |
| 42 | 43 | ErrorCode PURCHASE_RETURN_NO_EXISTS = new ErrorCode(1_030_103_004, "生成退货单失败,请重新提交"); |
| 43 | 44 | ErrorCode PURCHASE_RETURN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_103_005, "采购退货单({})已审核,无法修改"); |
| 45 | + ErrorCode PURCHASE_RETURN_NOT_APPROVE = new ErrorCode(1_030_103_006, "采购退货单未审核,无法操作"); | |
| 44 | 46 | |
| 45 | 47 | // ========== ERP 客户(1-030-200-000)========== |
| 46 | 48 | ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_200_000, "客户不存在"); |
| ... | ... | @@ -137,4 +139,11 @@ ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_00 |
| 137 | 139 | ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_030_600_000, "结算账户不存在"); |
| 138 | 140 | ErrorCode ACCOUNT_NOT_ENABLE = new ErrorCode(1_030_600_001, "结算账户({})未启用"); |
| 139 | 141 | |
| 142 | + // ========== ERP 付款单 1-030-601-000 ========== | |
| 143 | + ErrorCode FINANCE_PAYMENT_NOT_EXISTS = new ErrorCode(1_030_601_000, "付款单不存在"); | |
| 144 | + ErrorCode FINANCE_PAYMENT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_601_001, "付款单({})已审核,无法删除"); | |
| 145 | + ErrorCode FINANCE_PAYMENT_PROCESS_FAIL = new ErrorCode(1_030_601_002, "反审核失败,只有已审核的付款单才能反审核"); | |
| 146 | + ErrorCode FINANCE_PAYMENT_APPROVE_FAIL = new ErrorCode(1_030_601_003, "审核失败,只有未审核的付款单才能审核"); | |
| 147 | + ErrorCode FINANCE_PAYMENT_NO_EXISTS = new ErrorCode(1_030_601_004, "生成付款单号失败,请重新提交"); | |
| 148 | + | |
| 140 | 149 | } | ... | ... |
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.enums.common; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.RequiredArgsConstructor; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * ERP 业务类型枚举 | |
| 11 | + * | |
| 12 | + * @author HUIHUI | |
| 13 | + */ | |
| 14 | +@RequiredArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum ErpBizTypeEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + PURCHASE_ORDER(10, "采购订单"), | |
| 19 | + PURCHASE_IN(11, "采购入库"), | |
| 20 | + PURCHASE_RETURN(12, "采购退货"), | |
| 21 | + | |
| 22 | + SALE_ORDER(20, "销售订单"), | |
| 23 | + SALE_OUT(21, "销售订单"), | |
| 24 | + SALE_RETURN(22, "销售退货"), | |
| 25 | + ; | |
| 26 | + | |
| 27 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpBizTypeEnum::getType).toArray(); | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 类型 | |
| 31 | + */ | |
| 32 | + private final Integer type; | |
| 33 | + /** | |
| 34 | + * 名称 | |
| 35 | + */ | |
| 36 | + private final String name; | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public int[] array() { | |
| 40 | + return ARRAYS; | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java
| ... | ... | @@ -7,9 +7,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | 9 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 10 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountPageReqVO; | |
| 11 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountRespVO; | |
| 12 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountSaveReqVO; | |
| 10 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountRespVO; | |
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; | |
| 13 | 13 | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| 14 | 14 | import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; |
| 15 | 15 | import io.swagger.v3.oas.annotations.Operation; | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.finance; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 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.collection.MapUtils; | |
| 8 | +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | |
| 9 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 10 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 11 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentRespVO; | |
| 14 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; | |
| 15 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; | |
| 16 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; | |
| 17 | +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; | |
| 18 | +import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService; | |
| 19 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; | |
| 20 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 21 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 22 | +import io.swagger.v3.oas.annotations.Operation; | |
| 23 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 24 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 25 | +import jakarta.annotation.Resource; | |
| 26 | +import jakarta.servlet.http.HttpServletResponse; | |
| 27 | +import jakarta.validation.Valid; | |
| 28 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 29 | +import org.springframework.validation.annotation.Validated; | |
| 30 | +import org.springframework.web.bind.annotation.*; | |
| 31 | + | |
| 32 | +import java.io.IOException; | |
| 33 | +import java.util.List; | |
| 34 | +import java.util.Map; | |
| 35 | +import java.util.stream.Stream; | |
| 36 | + | |
| 37 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 38 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 39 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 40 | + | |
| 41 | +@Tag(name = "管理后台 - ERP 付款单") | |
| 42 | +@RestController | |
| 43 | +@RequestMapping("/erp/finance-payment") | |
| 44 | +@Validated | |
| 45 | +public class ErpFinancePaymentController { | |
| 46 | + | |
| 47 | + @Resource | |
| 48 | + private ErpFinancePaymentService financePaymentService; | |
| 49 | + @Resource | |
| 50 | + private ErpSupplierService supplierService; | |
| 51 | + | |
| 52 | + @Resource | |
| 53 | + private AdminUserApi adminUserApi; | |
| 54 | + | |
| 55 | + @PostMapping("/create") | |
| 56 | + @Operation(summary = "创建付款单") | |
| 57 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:create')") | |
| 58 | + public CommonResult<Long> createFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO createReqVO) { | |
| 59 | + return success(financePaymentService.createFinancePayment(createReqVO)); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @PutMapping("/update") | |
| 63 | + @Operation(summary = "更新付款单") | |
| 64 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:update')") | |
| 65 | + public CommonResult<Boolean> updateFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO updateReqVO) { | |
| 66 | + financePaymentService.updateFinancePayment(updateReqVO); | |
| 67 | + return success(true); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @PutMapping("/update-status") | |
| 71 | + @Operation(summary = "更新付款单的状态") | |
| 72 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:update-status')") | |
| 73 | + public CommonResult<Boolean> updateFinancePaymentStatus(@RequestParam("id") Long id, | |
| 74 | + @RequestParam("status") Integer status) { | |
| 75 | + financePaymentService.updateFinancePaymentStatus(id, status); | |
| 76 | + return success(true); | |
| 77 | + } | |
| 78 | + | |
| 79 | + @DeleteMapping("/delete") | |
| 80 | + @Operation(summary = "删除付款单") | |
| 81 | + @Parameter(name = "ids", description = "编号数组", required = true) | |
| 82 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:delete')") | |
| 83 | + public CommonResult<Boolean> deleteFinancePayment(@RequestParam("ids") List<Long> ids) { | |
| 84 | + financePaymentService.deleteFinancePayment(ids); | |
| 85 | + return success(true); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @GetMapping("/get") | |
| 89 | + @Operation(summary = "获得付款单") | |
| 90 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 91 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") | |
| 92 | + public CommonResult<ErpFinancePaymentRespVO> getFinancePayment(@RequestParam("id") Long id) { | |
| 93 | + ErpFinancePaymentDO payment = financePaymentService.getFinancePayment(id); | |
| 94 | + if (payment == null) { | |
| 95 | + return success(null); | |
| 96 | + } | |
| 97 | + List<ErpFinancePaymentItemDO> paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentId(id); | |
| 98 | + return success(BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO -> | |
| 99 | + financePaymentVO.setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class)))); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @GetMapping("/page") | |
| 103 | + @Operation(summary = "获得付款单分页") | |
| 104 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") | |
| 105 | + public CommonResult<PageResult<ErpFinancePaymentRespVO>> getFinancePaymentPage(@Valid ErpFinancePaymentPageReqVO pageReqVO) { | |
| 106 | + PageResult<ErpFinancePaymentDO> pageResult = financePaymentService.getFinancePaymentPage(pageReqVO); | |
| 107 | + return success(buildFinancePaymentVOPageResult(pageResult)); | |
| 108 | + } | |
| 109 | + | |
| 110 | + @GetMapping("/export-excel") | |
| 111 | + @Operation(summary = "导出付款单 Excel") | |
| 112 | + @PreAuthorize("@ss.hasPermission('erp:finance-payment:export')") | |
| 113 | + @OperateLog(type = EXPORT) | |
| 114 | + public void exportFinancePaymentExcel(@Valid ErpFinancePaymentPageReqVO pageReqVO, | |
| 115 | + HttpServletResponse response) throws IOException { | |
| 116 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 117 | + List<ErpFinancePaymentRespVO> list = buildFinancePaymentVOPageResult(financePaymentService.getFinancePaymentPage(pageReqVO)).getList(); | |
| 118 | + // 导出 Excel | |
| 119 | + ExcelUtils.write(response, "付款单.xls", "数据", ErpFinancePaymentRespVO.class, list); | |
| 120 | + } | |
| 121 | + | |
| 122 | + private PageResult<ErpFinancePaymentRespVO> buildFinancePaymentVOPageResult(PageResult<ErpFinancePaymentDO> pageResult) { | |
| 123 | + if (CollUtil.isEmpty(pageResult.getList())) { | |
| 124 | + return PageResult.empty(pageResult.getTotal()); | |
| 125 | + } | |
| 126 | + // 1.1 付款项 | |
| 127 | + List<ErpFinancePaymentItemDO> paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentIds( | |
| 128 | + convertSet(pageResult.getList(), ErpFinancePaymentDO::getId)); | |
| 129 | + Map<Long, List<ErpFinancePaymentItemDO>> financePaymentItemMap = convertMultiMap(paymentItemList, ErpFinancePaymentItemDO::getPaymentId); | |
| 130 | + // 1.2 供应商信息 | |
| 131 | + Map<Long, ErpSupplierDO> supplierMap = supplierService.getSupplierMap( | |
| 132 | + convertSet(pageResult.getList(), ErpFinancePaymentDO::getSupplierId)); | |
| 133 | + // 1.3 管理员信息 | |
| 134 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), | |
| 135 | + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); | |
| 136 | + // 2. 开始拼接 | |
| 137 | + return BeanUtils.toBean(pageResult, ErpFinancePaymentRespVO.class, payment -> { | |
| 138 | + payment.setItems(BeanUtils.toBean(financePaymentItemMap.get(payment.getId()), ErpFinancePaymentRespVO.Item.class)); | |
| 139 | + MapUtils.findAndThen(supplierMap, payment.getSupplierId(), supplier -> payment.setSupplierName(supplier.getName())); | |
| 140 | + MapUtils.findAndThen(userMap, Long.parseLong(payment.getCreator()), user -> payment.setCreatorName(user.getNickname())); | |
| 141 | + MapUtils.findAndThen(userMap, payment.getFinanceUserId(), user -> payment.setFinanceUserName(user.getNickname())); | |
| 142 | + }); | |
| 143 | + } | |
| 144 | + | |
| 145 | +} | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/ErpAccountPageReqVO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/ErpAccountRespVO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/ErpAccountSaveReqVO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - ERP 付款单分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class ErpFinancePaymentPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "采购单编号", example = "XS001") | |
| 21 | + private String no; | |
| 22 | + | |
| 23 | + @Schema(description = "付款时间") | |
| 24 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 25 | + private LocalDateTime[] paymentTime; | |
| 26 | + | |
| 27 | + @Schema(description = "供应商编号", example = "1724") | |
| 28 | + private Long supplierId; | |
| 29 | + | |
| 30 | + @Schema(description = "创建者", example = "666") | |
| 31 | + private String creator; | |
| 32 | + | |
| 33 | + @Schema(description = "财务人员编号", example = "888") | |
| 34 | + private String financeUserId; | |
| 35 | + | |
| 36 | + @Schema(description = "结算账户编号", example = "31189") | |
| 37 | + private Long accountId; | |
| 38 | + | |
| 39 | + @Schema(description = "付款状态", example = "2") | |
| 40 | + private Integer status; | |
| 41 | + | |
| 42 | + @Schema(description = "备注", example = "你猜") | |
| 43 | + private String remark; | |
| 44 | + | |
| 45 | + @Schema(description = "业务编号", example = "123") | |
| 46 | + private String bizNo; | |
| 47 | + | |
| 48 | +} | |
| 0 | 49 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - ERP 付款单 Response VO") | |
| 13 | +@Data | |
| 14 | +public class ErpFinancePaymentRespVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "付款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") | |
| 20 | + private String no; | |
| 21 | + | |
| 22 | + @Schema(description = "付款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | + private Integer status; | |
| 24 | + | |
| 25 | + @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 26 | + private LocalDateTime paymentTime; | |
| 27 | + | |
| 28 | + @Schema(description = "财务人员编号", example = "19690") | |
| 29 | + private Long financeUserId; | |
| 30 | + @Schema(description = "财务人员名称", example = "张三") | |
| 31 | + private String financeUserName; | |
| 32 | + | |
| 33 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") | |
| 34 | + private Long supplierId; | |
| 35 | + @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小番茄公司") | |
| 36 | + private String supplierName; | |
| 37 | + | |
| 38 | + @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") | |
| 39 | + private Long accountId; | |
| 40 | + | |
| 41 | + @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "13832") | |
| 42 | + private BigDecimal totalPrice; | |
| 43 | + | |
| 44 | + @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") | |
| 45 | + private BigDecimal discountPrice; | |
| 46 | + | |
| 47 | + @Schema(description = "实际价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 48 | + private BigDecimal paymentPrice; | |
| 49 | + | |
| 50 | + @Schema(description = "备注", example = "你猜") | |
| 51 | + private String remark; | |
| 52 | + | |
| 53 | + @Schema(description = "创建人", example = "芋道") | |
| 54 | + private String creator; | |
| 55 | + @Schema(description = "创建人名称", example = "芋道") | |
| 56 | + private String creatorName; | |
| 57 | + | |
| 58 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 59 | + @ExcelProperty("创建时间") | |
| 60 | + private LocalDateTime createTime; | |
| 61 | + | |
| 62 | + @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 63 | + private List<Item> items; | |
| 64 | + | |
| 65 | + @Data | |
| 66 | + public static class Item { | |
| 67 | + | |
| 68 | + @Schema(description = "付款项编号", example = "11756") | |
| 69 | + private Long id; | |
| 70 | + | |
| 71 | + @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 72 | + private Integer bizType; | |
| 73 | + | |
| 74 | + @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") | |
| 75 | + private Long bizId; | |
| 76 | + | |
| 77 | + @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") | |
| 78 | + private String bizNo; | |
| 79 | + | |
| 80 | + @Schema(description = "应付欠款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 81 | + private BigDecimal totalPrice; | |
| 82 | + | |
| 83 | + @Schema(description = "已付欠款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 84 | + private BigDecimal paidPrice; | |
| 85 | + | |
| 86 | + @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 87 | + @NotNull(message = "本次付款不能为空") | |
| 88 | + private BigDecimal paymentPrice; | |
| 89 | + | |
| 90 | + @Schema(description = "备注", example = "随便") | |
| 91 | + private String remark; | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | +} | |
| 0 | 96 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.Valid; | |
| 5 | +import jakarta.validation.constraints.NotEmpty; | |
| 6 | +import jakarta.validation.constraints.NotNull; | |
| 7 | +import lombok.Data; | |
| 8 | + | |
| 9 | +import java.math.BigDecimal; | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +@Schema(description = "管理后台 - ERP 付款单新增/修改 Request VO") | |
| 14 | +@Data | |
| 15 | +public class ErpFinancePaymentSaveReqVO { | |
| 16 | + | |
| 17 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "付款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") | |
| 21 | + @NotEmpty(message = "付款单号不能为空") | |
| 22 | + private String no; | |
| 23 | + | |
| 24 | + @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 25 | + @NotNull(message = "付款时间不能为空") | |
| 26 | + private LocalDateTime paymentTime; | |
| 27 | + | |
| 28 | + @Schema(description = "财务人员编号", example = "19690") | |
| 29 | + private Long financeUserId; | |
| 30 | + | |
| 31 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") | |
| 32 | + @NotNull(message = "供应商编号不能为空") | |
| 33 | + private Long supplierId; | |
| 34 | + | |
| 35 | + @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") | |
| 36 | + @NotNull(message = "付款账户编号不能为空") | |
| 37 | + private Long accountId; | |
| 38 | + | |
| 39 | + @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") | |
| 40 | + @NotNull(message = "优惠金额不能为空") | |
| 41 | + private BigDecimal discountPrice; | |
| 42 | + | |
| 43 | + @Schema(description = "备注", example = "你猜") | |
| 44 | + private String remark; | |
| 45 | + | |
| 46 | + @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 47 | + @NotEmpty(message = "付款项列表不能为空") | |
| 48 | + @Valid | |
| 49 | + private List<Item> items; | |
| 50 | + | |
| 51 | + @Data | |
| 52 | + public static class Item { | |
| 53 | + | |
| 54 | + @Schema(description = "付款项编号", example = "11756") | |
| 55 | + private Long id; | |
| 56 | + | |
| 57 | + @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 58 | + @NotNull(message = "业务类型不能为空") | |
| 59 | + private Integer bizType; | |
| 60 | + | |
| 61 | + @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") | |
| 62 | + @NotNull(message = "业务编号不能为空") | |
| 63 | + private Long bizId; | |
| 64 | + | |
| 65 | + @Schema(description = "已付欠款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 66 | + @NotNull(message = "已付欠款不能为空") | |
| 67 | + private BigDecimal paidPrice; | |
| 68 | + | |
| 69 | + @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") | |
| 70 | + @NotNull(message = "本次付款不能为空") | |
| 71 | + private BigDecimal paymentPrice; | |
| 72 | + | |
| 73 | + @Schema(description = "备注", example = "随便") | |
| 74 | + private String remark; | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 78 | +} | |
| 0 | 79 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java
| ... | ... | @@ -138,7 +138,7 @@ public class ErpPurchaseInController { |
| 138 | 138 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 139 | 139 | return PageResult.empty(pageResult.getTotal()); |
| 140 | 140 | } |
| 141 | - // 1.1 出库项 | |
| 141 | + // 1.1 入库项 | |
| 142 | 142 | List<ErpPurchaseInItemDO> purchaseInItemList = purchaseInService.getPurchaseInItemListByInIds( |
| 143 | 143 | convertSet(pageResult.getList(), ErpPurchaseInDO::getId)); |
| 144 | 144 | Map<Long, List<ErpPurchaseInItemDO>> purchaseInItemMap = convertMultiMap(purchaseInItemList, ErpPurchaseInItemDO::getInId); |
| ... | ... | @@ -150,7 +150,7 @@ public class ErpPurchaseInController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpPurchaseInDO::getSupplierId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), purchaseIn -> Long.parseLong(purchaseIn.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpPurchaseInRespVO.class, purchaseIn -> { |
| 156 | 156 | purchaseIn.setItems(BeanUtils.toBean(purchaseInItemMap.get(purchaseIn.getId()), ErpPurchaseInRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java
| ... | ... | @@ -41,7 +41,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 41 | 41 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 42 | 42 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 43 | 43 | |
| 44 | - | |
| 45 | 44 | @Tag(name = "管理后台 - ERP 采购订单") |
| 46 | 45 | @RestController |
| 47 | 46 | @RequestMapping("/erp/purchase-order") |
| ... | ... | @@ -62,14 +61,14 @@ public class ErpPurchaseOrderController { |
| 62 | 61 | |
| 63 | 62 | @PostMapping("/create") |
| 64 | 63 | @Operation(summary = "创建采购订单") |
| 65 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:create')") | |
| 64 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:create')") | |
| 66 | 65 | public CommonResult<Long> createPurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO createReqVO) { |
| 67 | 66 | return success(purchaseOrderService.createPurchaseOrder(createReqVO)); |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | @PutMapping("/update") |
| 71 | 70 | @Operation(summary = "更新采购订单") |
| 72 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:update')") | |
| 71 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:update')") | |
| 73 | 72 | public CommonResult<Boolean> updatePurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO updateReqVO) { |
| 74 | 73 | purchaseOrderService.updatePurchaseOrder(updateReqVO); |
| 75 | 74 | return success(true); |
| ... | ... | @@ -77,7 +76,7 @@ public class ErpPurchaseOrderController { |
| 77 | 76 | |
| 78 | 77 | @PutMapping("/update-status") |
| 79 | 78 | @Operation(summary = "更新采购订单的状态") |
| 80 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:update-status')") | |
| 79 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:update-status')") | |
| 81 | 80 | public CommonResult<Boolean> updatePurchaseOrderStatus(@RequestParam("id") Long id, |
| 82 | 81 | @RequestParam("status") Integer status) { |
| 83 | 82 | purchaseOrderService.updatePurchaseOrderStatus(id, status); |
| ... | ... | @@ -87,7 +86,7 @@ public class ErpPurchaseOrderController { |
| 87 | 86 | @DeleteMapping("/delete") |
| 88 | 87 | @Operation(summary = "删除采购订单") |
| 89 | 88 | @Parameter(name = "ids", description = "编号数组", required = true) |
| 90 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:delete')") | |
| 89 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:delete')") | |
| 91 | 90 | public CommonResult<Boolean> deletePurchaseOrder(@RequestParam("ids") List<Long> ids) { |
| 92 | 91 | purchaseOrderService.deletePurchaseOrder(ids); |
| 93 | 92 | return success(true); |
| ... | ... | @@ -96,7 +95,7 @@ public class ErpPurchaseOrderController { |
| 96 | 95 | @GetMapping("/get") |
| 97 | 96 | @Operation(summary = "获得采购订单") |
| 98 | 97 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 99 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:query')") | |
| 98 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:query')") | |
| 100 | 99 | public CommonResult<ErpPurchaseOrderRespVO> getPurchaseOrder(@RequestParam("id") Long id) { |
| 101 | 100 | ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(id); |
| 102 | 101 | if (purchaseOrder == null) { |
| ... | ... | @@ -116,7 +115,7 @@ public class ErpPurchaseOrderController { |
| 116 | 115 | |
| 117 | 116 | @GetMapping("/page") |
| 118 | 117 | @Operation(summary = "获得采购订单分页") |
| 119 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:query')") | |
| 118 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:query')") | |
| 120 | 119 | public CommonResult<PageResult<ErpPurchaseOrderRespVO>> getPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) { |
| 121 | 120 | PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(pageReqVO); |
| 122 | 121 | return success(buildPurchaseOrderVOPageResult(pageResult)); |
| ... | ... | @@ -124,7 +123,7 @@ public class ErpPurchaseOrderController { |
| 124 | 123 | |
| 125 | 124 | @GetMapping("/export-excel") |
| 126 | 125 | @Operation(summary = "导出采购订单 Excel") |
| 127 | - @PreAuthorize("@ss.hasPermission('erp:purchase-out:export')") | |
| 126 | + @PreAuthorize("@ss.hasPermission('erp:purchase-create:export')") | |
| 128 | 127 | @OperateLog(type = EXPORT) |
| 129 | 128 | public void exportPurchaseOrderExcel(@Valid ErpPurchaseOrderPageReqVO pageReqVO, |
| 130 | 129 | HttpServletResponse response) throws IOException { |
| ... | ... | @@ -138,7 +137,7 @@ public class ErpPurchaseOrderController { |
| 138 | 137 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 139 | 138 | return PageResult.empty(pageResult.getTotal()); |
| 140 | 139 | } |
| 141 | - // 1.1 出库项 | |
| 140 | + // 1.1 订单项 | |
| 142 | 141 | List<ErpPurchaseOrderItemDO> purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderIds( |
| 143 | 142 | convertSet(pageResult.getList(), ErpPurchaseOrderDO::getId)); |
| 144 | 143 | Map<Long, List<ErpPurchaseOrderItemDO>> purchaseOrderItemMap = convertMultiMap(purchaseOrderItemList, ErpPurchaseOrderItemDO::getOrderId); |
| ... | ... | @@ -150,7 +149,7 @@ public class ErpPurchaseOrderController { |
| 150 | 149 | convertSet(pageResult.getList(), ErpPurchaseOrderDO::getSupplierId)); |
| 151 | 150 | // 1.4 管理员信息 |
| 152 | 151 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 152 | + convertSet(pageResult.getList(), purchaseOrder -> Long.parseLong(purchaseOrder.getCreator()))); | |
| 154 | 153 | // 2. 开始拼接 |
| 155 | 154 | return BeanUtils.toBean(pageResult, ErpPurchaseOrderRespVO.class, purchaseOrder -> { |
| 156 | 155 | purchaseOrder.setItems(BeanUtils.toBean(purchaseOrderItemMap.get(purchaseOrder.getId()), ErpPurchaseOrderRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java
| ... | ... | @@ -150,7 +150,7 @@ public class ErpPurchaseReturnController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpPurchaseReturnDO::getSupplierId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), purchaseReturn -> Long.parseLong(purchaseReturn.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpPurchaseReturnRespVO.class, purchaseReturn -> { |
| 156 | 156 | purchaseReturn.setItems(BeanUtils.toBean(purchaseReturnItemMap.get(purchaseReturn.getId()), ErpPurchaseReturnRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java
| ... | ... | @@ -138,7 +138,7 @@ public class ErpSaleOrderController { |
| 138 | 138 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 139 | 139 | return PageResult.empty(pageResult.getTotal()); |
| 140 | 140 | } |
| 141 | - // 1.1 出库项 | |
| 141 | + // 1.1 订单项 | |
| 142 | 142 | List<ErpSaleOrderItemDO> saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderIds( |
| 143 | 143 | convertSet(pageResult.getList(), ErpSaleOrderDO::getId)); |
| 144 | 144 | Map<Long, List<ErpSaleOrderItemDO>> saleOrderItemMap = convertMultiMap(saleOrderItemList, ErpSaleOrderItemDO::getOrderId); |
| ... | ... | @@ -150,7 +150,7 @@ public class ErpSaleOrderController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpSaleOrderDO::getCustomerId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), saleOrder -> Long.parseLong(saleOrder.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpSaleOrderRespVO.class, saleOrder -> { |
| 156 | 156 | saleOrder.setItems(BeanUtils.toBean(saleOrderItemMap.get(saleOrder.getId()), ErpSaleOrderRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java
| ... | ... | @@ -150,7 +150,7 @@ public class ErpSaleOutController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpSaleOutDO::getCustomerId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpSaleOutRespVO.class, saleOut -> { |
| 156 | 156 | saleOut.setItems(BeanUtils.toBean(saleOutItemMap.get(saleOut.getId()), ErpSaleOutRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java
| ... | ... | @@ -150,7 +150,7 @@ public class ErpSaleReturnController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> { |
| 156 | 156 | saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java
| ... | ... | @@ -126,7 +126,7 @@ public class ErpStockCheckController { |
| 126 | 126 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 127 | 127 | return PageResult.empty(pageResult.getTotal()); |
| 128 | 128 | } |
| 129 | - // 1.1 出库项 | |
| 129 | + // 1.1 盘点项 | |
| 130 | 130 | List<ErpStockCheckItemDO> stockCheckItemList = stockCheckService.getStockCheckItemListByCheckIds( |
| 131 | 131 | convertSet(pageResult.getList(), ErpStockCheckDO::getId)); |
| 132 | 132 | Map<Long, List<ErpStockCheckItemDO>> stockCheckItemMap = convertMultiMap(stockCheckItemList, ErpStockCheckItemDO::getCheckId); |
| ... | ... | @@ -135,7 +135,7 @@ public class ErpStockCheckController { |
| 135 | 135 | convertSet(stockCheckItemList, ErpStockCheckItemDO::getProductId)); |
| 136 | 136 | // 1.3 管理员信息 |
| 137 | 137 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 138 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 138 | + convertSet(pageResult.getList(), stockCheck -> Long.parseLong(stockCheck.getCreator()))); | |
| 139 | 139 | // 2. 开始拼接 |
| 140 | 140 | return BeanUtils.toBean(pageResult, ErpStockCheckRespVO.class, stockCheck -> { |
| 141 | 141 | stockCheck.setItems(BeanUtils.toBean(stockCheckItemMap.get(stockCheck.getId()), ErpStockCheckRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java
| ... | ... | @@ -150,7 +150,7 @@ public class ErpStockInController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpStockInDO::getSupplierId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), stockIn -> Long.parseLong(stockIn.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpStockInRespVO.class, stockIn -> { |
| 156 | 156 | stockIn.setItems(BeanUtils.toBean(stockInItemMap.get(stockIn.getId()), ErpStockInRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java
| ... | ... | @@ -134,7 +134,7 @@ public class ErpStockMoveController { |
| 134 | 134 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 135 | 135 | return PageResult.empty(pageResult.getTotal()); |
| 136 | 136 | } |
| 137 | - // 1.1 出库项 | |
| 137 | + // 1.1 调拨项 | |
| 138 | 138 | List<ErpStockMoveItemDO> stockMoveItemList = stockMoveService.getStockMoveItemListByMoveIds( |
| 139 | 139 | convertSet(pageResult.getList(), ErpStockMoveDO::getId)); |
| 140 | 140 | Map<Long, List<ErpStockMoveItemDO>> stockMoveItemMap = convertMultiMap(stockMoveItemList, ErpStockMoveItemDO::getMoveId); |
| ... | ... | @@ -144,7 +144,7 @@ public class ErpStockMoveController { |
| 144 | 144 | // 1.3 TODO 芋艿:搞仓库信息 |
| 145 | 145 | // 1.4 管理员信息 |
| 146 | 146 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 147 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 147 | + convertSet(pageResult.getList(), stockMove -> Long.parseLong(stockMove.getCreator()))); | |
| 148 | 148 | // 2. 开始拼接 |
| 149 | 149 | return BeanUtils.toBean(pageResult, ErpStockMoveRespVO.class, stockMove -> { |
| 150 | 150 | stockMove.setItems(BeanUtils.toBean(stockMoveItemMap.get(stockMove.getId()), ErpStockMoveRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java
| ... | ... | @@ -150,7 +150,7 @@ public class ErpStockOutController { |
| 150 | 150 | convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId)); |
| 151 | 151 | // 1.4 管理员信息 |
| 152 | 152 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 153 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 153 | + convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); | |
| 154 | 154 | // 2. 开始拼接 |
| 155 | 155 | return BeanUtils.toBean(pageResult, ErpStockOutRespVO.class, stockOut -> { |
| 156 | 156 | stockOut.setItems(BeanUtils.toBean(stockOutItemMap.get(stockOut.getId()), ErpStockOutRespVO.Item.class, | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java
| ... | ... | @@ -93,7 +93,7 @@ public class ErpStockRecordController { |
| 93 | 93 | Map<Long, ErpWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( |
| 94 | 94 | convertSet(pageResult.getList(), ErpStockRecordDO::getWarehouseId)); |
| 95 | 95 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 96 | - convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 96 | + convertSet(pageResult.getList(), record -> Long.parseLong(record.getCreator()))); | |
| 97 | 97 | return BeanUtils.toBean(pageResult, ErpStockRecordRespVO.class, stock -> { |
| 98 | 98 | MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) |
| 99 | 99 | .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.finance; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * ERP 付款单 DO | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("erp_finance_payment") | |
| 19 | +@KeySequence("erp_finance_payment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class ErpFinancePaymentDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + /** | |
| 34 | + * 付款单号 | |
| 35 | + */ | |
| 36 | + private String no; | |
| 37 | + /** | |
| 38 | + * 付款状态 | |
| 39 | + * | |
| 40 | + * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} | |
| 41 | + */ | |
| 42 | + private Integer status; | |
| 43 | + /** | |
| 44 | + * 付款时间 | |
| 45 | + */ | |
| 46 | + private LocalDateTime paymentTime; | |
| 47 | + /** | |
| 48 | + * 财务人员编号 | |
| 49 | + * | |
| 50 | + * 关联 AdminUserDO 的 id 字段 | |
| 51 | + */ | |
| 52 | + private Long financeUserId; | |
| 53 | + /** | |
| 54 | + * 供应商编号 | |
| 55 | + * | |
| 56 | + * 关联 {@link ErpSupplierDO#getId()} | |
| 57 | + */ | |
| 58 | + private Long supplierId; | |
| 59 | + /** | |
| 60 | + * 付款账户编号 | |
| 61 | + * | |
| 62 | + * 关联 {@link ErpAccountDO#getId()} | |
| 63 | + */ | |
| 64 | + private Long accountId; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 合计价格,单位:元 | |
| 68 | + */ | |
| 69 | + private BigDecimal totalPrice; | |
| 70 | + /** | |
| 71 | + * 优惠金额,单位:元 | |
| 72 | + */ | |
| 73 | + private BigDecimal discountPrice; | |
| 74 | + /** | |
| 75 | + * 实付金额,单位:分 | |
| 76 | + * | |
| 77 | + * paymentPrice = totalPrice - discountPrice | |
| 78 | + */ | |
| 79 | + private BigDecimal paymentPrice; | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * 备注 | |
| 83 | + */ | |
| 84 | + private String remark; | |
| 85 | + | |
| 86 | +} | |
| 0 | 87 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.finance; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * ERP 付款项 DO | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@TableName("erp_finance_payment_item") | |
| 18 | +@KeySequence("erp_finance_payment_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +@ToString(callSuper = true) | |
| 22 | +@Builder | |
| 23 | +@NoArgsConstructor | |
| 24 | +@AllArgsConstructor | |
| 25 | +public class ErpFinancePaymentItemDO extends BaseDO { | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 入库项编号 | |
| 29 | + */ | |
| 30 | + @TableId | |
| 31 | + private Long id; | |
| 32 | + /** | |
| 33 | + * 付款单编号 | |
| 34 | + * | |
| 35 | + * 关联 {@link ErpFinancePaymentDO#getId()} | |
| 36 | + */ | |
| 37 | + private Long paymentId; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 业务类型 | |
| 41 | + * | |
| 42 | + * 枚举 {@link cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum} 的采购入库、退货 | |
| 43 | + */ | |
| 44 | + private Integer bizType; | |
| 45 | + /** | |
| 46 | + * 业务编号 | |
| 47 | + * | |
| 48 | + * 例如说:{@link ErpPurchaseInDO#getId()} | |
| 49 | + */ | |
| 50 | + private Long bizId; | |
| 51 | + /** | |
| 52 | + * 业务单号 | |
| 53 | + * | |
| 54 | + * 例如说:{@link ErpPurchaseInDO#getNo()} | |
| 55 | + */ | |
| 56 | + private String bizNo; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 应付欠款,单位:分 | |
| 60 | + */ | |
| 61 | + private BigDecimal totalPrice; | |
| 62 | + /** | |
| 63 | + * 已付欠款,单位:分 | |
| 64 | + */ | |
| 65 | + private BigDecimal paidPrice; | |
| 66 | + /** | |
| 67 | + * 本次付款,单位:分 | |
| 68 | + */ | |
| 69 | + private BigDecimal paymentPrice; | |
| 70 | + /** | |
| 71 | + * 备注 | |
| 72 | + */ | |
| 73 | + private String remark; | |
| 74 | + | |
| 75 | +} | |
| 0 | 76 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.erp.dal.mysql.finance; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.finance; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | + | |
| 7 | +import java.util.Collection; | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * ERP 付款单项 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface ErpFinancePaymentItemMapper extends BaseMapperX<ErpFinancePaymentItemDO> { | |
| 17 | + | |
| 18 | + default List<ErpFinancePaymentItemDO> selectListByPaymentId(Long paymentId) { | |
| 19 | + return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentId); | |
| 20 | + } | |
| 21 | + | |
| 22 | + default List<ErpFinancePaymentItemDO> selectListByPaymentIds(Collection<Long> paymentIds) { | |
| 23 | + return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentIds); | |
| 24 | + } | |
| 25 | + | |
| 26 | + default int deleteByPaymentId(Long paymentId) { | |
| 27 | + return delete(ErpFinancePaymentItemDO::getPaymentId, paymentId); | |
| 28 | + } | |
| 29 | + | |
| 30 | +} | |
| 0 | 31 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.finance; | |
| 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.MPJLambdaWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; | |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; | |
| 9 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 10 | +import org.apache.ibatis.annotations.Mapper; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * ERP 付款单 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface ErpFinancePaymentMapper extends BaseMapperX<ErpFinancePaymentDO> { | |
| 19 | + | |
| 20 | + default PageResult<ErpFinancePaymentDO> selectPage(ErpFinancePaymentPageReqVO reqVO) { | |
| 21 | + MPJLambdaWrapperX<ErpFinancePaymentDO> query = new MPJLambdaWrapperX<ErpFinancePaymentDO>() | |
| 22 | + .likeIfPresent(ErpFinancePaymentDO::getNo, reqVO.getNo()) | |
| 23 | + .betweenIfPresent(ErpFinancePaymentDO::getPaymentTime, reqVO.getPaymentTime()) | |
| 24 | + .eqIfPresent(ErpFinancePaymentDO::getSupplierId, reqVO.getSupplierId()) | |
| 25 | + .eqIfPresent(ErpFinancePaymentDO::getCreator, reqVO.getCreator()) | |
| 26 | + .eqIfPresent(ErpFinancePaymentDO::getFinanceUserId, reqVO.getFinanceUserId()) | |
| 27 | + .eqIfPresent(ErpFinancePaymentDO::getAccountId, reqVO.getAccountId()) | |
| 28 | + .eqIfPresent(ErpFinancePaymentDO::getStatus, reqVO.getStatus()) | |
| 29 | + .likeIfPresent(ErpFinancePaymentDO::getRemark, reqVO.getRemark()) | |
| 30 | + .orderByDesc(ErpFinancePaymentDO::getId); | |
| 31 | + if (reqVO.getBizNo() != null) { | |
| 32 | + query.leftJoin(ErpFinancePaymentItemDO.class, ErpFinancePaymentItemDO::getPaymentId, ErpFinancePaymentDO::getId) | |
| 33 | + .eq(reqVO.getBizNo() != null, ErpFinancePaymentItemDO::getBizNo, reqVO.getBizNo()) | |
| 34 | + .groupBy(ErpFinancePaymentDO::getId); // 避免 1 对多查询,产生相同的 1 | |
| 35 | + } | |
| 36 | + return selectJoinPage(reqVO, ErpFinancePaymentDO.class, query); | |
| 37 | + } | |
| 38 | + | |
| 39 | + default int updateByIdAndStatus(Long id, Integer status, ErpFinancePaymentDO updateObj) { | |
| 40 | + return update(updateObj, new LambdaUpdateWrapper<ErpFinancePaymentDO>() | |
| 41 | + .eq(ErpFinancePaymentDO::getId, id).eq(ErpFinancePaymentDO::getStatus, status)); | |
| 42 | + } | |
| 43 | + | |
| 44 | + default ErpFinancePaymentDO selectByNo(String no) { | |
| 45 | + return selectOne(ErpFinancePaymentDO::getNo, no); | |
| 46 | + } | |
| 47 | + | |
| 48 | +} | |
| 0 | 49 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java
| ... | ... | @@ -64,6 +64,11 @@ public class ErpNoRedisDAO { |
| 64 | 64 | */ |
| 65 | 65 | public static final String PURCHASE_RETURN_NO_PREFIX = "CGTH"; |
| 66 | 66 | |
| 67 | + /** | |
| 68 | + * 付款单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} | |
| 69 | + */ | |
| 70 | + public static final String FINANCE_PAYMENT_NO_PREFIX = "FKD"; | |
| 71 | + | |
| 67 | 72 | @Resource |
| 68 | 73 | private StringRedisTemplate stringRedisTemplate; |
| 69 | 74 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.finance; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountPageReqVO; | |
| 5 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountSaveReqVO; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; | |
| 6 | 6 | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java
| ... | ... | @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.erp.service.finance; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| 9 | 9 | import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpAccountMapper; |
| 10 | 10 | import jakarta.annotation.Resource; | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.finance; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; | |
| 8 | +import jakarta.validation.Valid; | |
| 9 | + | |
| 10 | +import java.util.Collection; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * ERP 付款单 Service 接口 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +public interface ErpFinancePaymentService { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 创建付款单 | |
| 22 | + * | |
| 23 | + * @param createReqVO 创建信息 | |
| 24 | + * @return 编号 | |
| 25 | + */ | |
| 26 | + Long createFinancePayment(@Valid ErpFinancePaymentSaveReqVO createReqVO); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 更新付款单 | |
| 30 | + * | |
| 31 | + * @param updateReqVO 更新信息 | |
| 32 | + */ | |
| 33 | + void updateFinancePayment(@Valid ErpFinancePaymentSaveReqVO updateReqVO); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 更新付款单的状态 | |
| 37 | + * | |
| 38 | + * @param id 编号 | |
| 39 | + * @param status 状态 | |
| 40 | + */ | |
| 41 | + void updateFinancePaymentStatus(Long id, Integer status); | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 删除付款单 | |
| 45 | + * | |
| 46 | + * @param ids 编号数组 | |
| 47 | + */ | |
| 48 | + void deleteFinancePayment(List<Long> ids); | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 获得付款单 | |
| 52 | + * | |
| 53 | + * @param id 编号 | |
| 54 | + * @return 付款单 | |
| 55 | + */ | |
| 56 | + ErpFinancePaymentDO getFinancePayment(Long id); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 获得付款单分页 | |
| 60 | + * | |
| 61 | + * @param pageReqVO 分页查询 | |
| 62 | + * @return 付款单分页 | |
| 63 | + */ | |
| 64 | + PageResult<ErpFinancePaymentDO> getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO); | |
| 65 | + | |
| 66 | + // ==================== 付款单项 ==================== | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 获得付款单项列表 | |
| 70 | + * | |
| 71 | + * @param paymentId 付款单编号 | |
| 72 | + * @return 付款单项列表 | |
| 73 | + */ | |
| 74 | + List<ErpFinancePaymentItemDO> getFinancePaymentItemListByPaymentId(Long paymentId); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 获得付款单项 List | |
| 78 | + * | |
| 79 | + * @param paymentIds 付款单编号数组 | |
| 80 | + * @return 付款单项 List | |
| 81 | + */ | |
| 82 | + List<ErpFinancePaymentItemDO> getFinancePaymentItemListByPaymentIds(Collection<Long> paymentIds); | |
| 83 | + | |
| 84 | +} | |
| 0 | 85 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.finance; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.util.ObjectUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; | |
| 10 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; | |
| 11 | +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; | |
| 12 | +import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; | |
| 13 | +import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentItemMapper; | |
| 14 | +import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentMapper; | |
| 15 | +import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; | |
| 16 | +import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; | |
| 17 | +import cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum; | |
| 18 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInService; | |
| 19 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseReturnService; | |
| 20 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; | |
| 21 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 22 | +import jakarta.annotation.Resource; | |
| 23 | +import org.springframework.stereotype.Service; | |
| 24 | +import org.springframework.transaction.annotation.Transactional; | |
| 25 | +import org.springframework.validation.annotation.Validated; | |
| 26 | + | |
| 27 | +import java.math.BigDecimal; | |
| 28 | +import java.util.Collection; | |
| 29 | +import java.util.Collections; | |
| 30 | +import java.util.List; | |
| 31 | + | |
| 32 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 33 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 34 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 35 | + | |
| 36 | +// TODO 芋艿:记录操作日志 | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * ERP 付款单 Service 实现类 | |
| 40 | + * | |
| 41 | + * @author 芋道源码 | |
| 42 | + */ | |
| 43 | +@Service | |
| 44 | +@Validated | |
| 45 | +public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService { | |
| 46 | + | |
| 47 | + @Resource | |
| 48 | + private ErpFinancePaymentMapper financePaymentMapper; | |
| 49 | + @Resource | |
| 50 | + private ErpFinancePaymentItemMapper financePaymentItemMapper; | |
| 51 | + | |
| 52 | + @Resource | |
| 53 | + private ErpNoRedisDAO noRedisDAO; | |
| 54 | + | |
| 55 | + @Resource | |
| 56 | + private ErpSupplierService supplierService; | |
| 57 | + @Resource | |
| 58 | + private ErpAccountService accountService; | |
| 59 | + @Resource | |
| 60 | + private ErpPurchaseInService purchaseInService; | |
| 61 | + @Resource | |
| 62 | + private ErpPurchaseReturnService purchaseReturnService; | |
| 63 | + | |
| 64 | + @Resource | |
| 65 | + private AdminUserApi adminUserApi; | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + @Transactional(rollbackFor = Exception.class) | |
| 69 | + public Long createFinancePayment(ErpFinancePaymentSaveReqVO createReqVO) { | |
| 70 | + // 1.1 校验订单项的有效性 | |
| 71 | + List<ErpFinancePaymentItemDO> paymentItems = validateFinancePaymentItems(createReqVO.getItems()); | |
| 72 | + // 1.2 校验供应商 | |
| 73 | + supplierService.validateSupplier(createReqVO.getSupplierId()); | |
| 74 | + // 1.3 校验结算账户 | |
| 75 | + if (createReqVO.getAccountId() != null) { | |
| 76 | + accountService.validateAccount(createReqVO.getAccountId()); | |
| 77 | + } | |
| 78 | + // 1.4 校验财务人员 | |
| 79 | + if (createReqVO.getFinanceUserId() != null) { | |
| 80 | + adminUserApi.validateUser(createReqVO.getFinanceUserId()); | |
| 81 | + } | |
| 82 | + // 1.5 生成付款单号,并校验唯一性 | |
| 83 | + String no = noRedisDAO.generate(ErpNoRedisDAO.FINANCE_PAYMENT_NO_PREFIX); | |
| 84 | + if (financePaymentMapper.selectByNo(no) != null) { | |
| 85 | + throw exception(FINANCE_PAYMENT_NO_EXISTS); | |
| 86 | + } | |
| 87 | + | |
| 88 | + // 2.1 插入付款单 | |
| 89 | + ErpFinancePaymentDO payment = BeanUtils.toBean(createReqVO, ErpFinancePaymentDO.class, in -> in | |
| 90 | + .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); | |
| 91 | + calculateTotalPrice(payment, paymentItems); | |
| 92 | + financePaymentMapper.insert(payment); | |
| 93 | + // 2.2 插入付款单项 | |
| 94 | + paymentItems.forEach(o -> o.setPaymentId(payment.getId())); | |
| 95 | + financePaymentItemMapper.insertBatch(paymentItems); | |
| 96 | + return payment.getId(); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + @Transactional(rollbackFor = Exception.class) | |
| 101 | + public void updateFinancePayment(ErpFinancePaymentSaveReqVO updateReqVO) { | |
| 102 | + // 1.1 校验存在 | |
| 103 | + ErpFinancePaymentDO payment = validateFinancePaymentExists(updateReqVO.getId()); | |
| 104 | + if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { | |
| 105 | + throw exception(SALE_ORDER_UPDATE_FAIL_APPROVE, payment.getNo()); | |
| 106 | + } | |
| 107 | + // 1.2 校验供应商 | |
| 108 | + supplierService.validateSupplier(updateReqVO.getSupplierId()); | |
| 109 | + // 1.3 校验结算账户 | |
| 110 | + if (updateReqVO.getAccountId() != null) { | |
| 111 | + accountService.validateAccount(updateReqVO.getAccountId()); | |
| 112 | + } | |
| 113 | + // 1.4 校验财务人员 | |
| 114 | + if (updateReqVO.getFinanceUserId() != null) { | |
| 115 | + adminUserApi.validateUser(updateReqVO.getFinanceUserId()); | |
| 116 | + } | |
| 117 | + // 1.5 校验付款单项的有效性 | |
| 118 | + List<ErpFinancePaymentItemDO> paymentItems = validateFinancePaymentItems(updateReqVO.getItems()); | |
| 119 | + | |
| 120 | + // 2.1 更新付款单 | |
| 121 | + ErpFinancePaymentDO updateObj = BeanUtils.toBean(updateReqVO, ErpFinancePaymentDO.class); | |
| 122 | + calculateTotalPrice(updateObj, paymentItems); | |
| 123 | + financePaymentMapper.updateById(updateObj); | |
| 124 | + // 2.2 更新付款单项 | |
| 125 | + updateFinancePaymentItemList(updateReqVO.getId(), paymentItems); | |
| 126 | + } | |
| 127 | + | |
| 128 | + private void calculateTotalPrice(ErpFinancePaymentDO payment, List<ErpFinancePaymentItemDO> paymentItems) { | |
| 129 | + payment.setTotalPrice(getSumValue(paymentItems, ErpFinancePaymentItemDO::getPaymentPrice, BigDecimal::add, BigDecimal.ZERO)); | |
| 130 | + payment.setPaymentPrice(payment.getTotalPrice().subtract(payment.getDiscountPrice())); | |
| 131 | + } | |
| 132 | + | |
| 133 | + @Override | |
| 134 | + @Transactional(rollbackFor = Exception.class) | |
| 135 | + public void updateFinancePaymentStatus(Long id, Integer status) { | |
| 136 | + boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); | |
| 137 | + // 1.1 校验存在 | |
| 138 | + ErpFinancePaymentDO payment = validateFinancePaymentExists(id); | |
| 139 | + // 1.2 校验状态 | |
| 140 | + if (payment.getStatus().equals(status)) { | |
| 141 | + throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); | |
| 142 | + } | |
| 143 | + | |
| 144 | + // 2. 更新状态 | |
| 145 | + int updateCount = financePaymentMapper.updateByIdAndStatus(id, payment.getStatus(), | |
| 146 | + new ErpFinancePaymentDO().setStatus(status)); | |
| 147 | + if (updateCount == 0) { | |
| 148 | + throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + private List<ErpFinancePaymentItemDO> validateFinancePaymentItems(List<ErpFinancePaymentSaveReqVO.Item> list) { | |
| 153 | + return convertList(list, o -> BeanUtils.toBean(o, ErpFinancePaymentItemDO.class, item -> { | |
| 154 | + if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_IN.getType())) { | |
| 155 | + ErpPurchaseInDO purchaseIn = purchaseInService.validatePurchaseIn(item.getBizId()); | |
| 156 | + item.setTotalPrice(purchaseIn.getTotalPrice()).setBizNo(purchaseIn.getNo()); | |
| 157 | + } else if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_RETURN.getType())) { | |
| 158 | + ErpPurchaseReturnDO purchaseReturn = purchaseReturnService.validatePurchaseReturn(item.getBizId()); | |
| 159 | + item.setTotalPrice(purchaseReturn.getTotalPrice()).setBizNo(purchaseReturn.getNo()); | |
| 160 | + } else { | |
| 161 | + throw new IllegalArgumentException("业务类型不正确:" + item.getBizType()); | |
| 162 | + } | |
| 163 | + })); | |
| 164 | + } | |
| 165 | + | |
| 166 | + private void updateFinancePaymentItemList(Long id, List<ErpFinancePaymentItemDO> newList) { | |
| 167 | + // 第一步,对比新老数据,获得添加、修改、删除的列表 | |
| 168 | + List<ErpFinancePaymentItemDO> oldList = financePaymentItemMapper.selectListByPaymentId(id); | |
| 169 | + List<List<ErpFinancePaymentItemDO>> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 | |
| 170 | + (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); | |
| 171 | + | |
| 172 | + // 第二步,批量添加、修改、删除 | |
| 173 | + if (CollUtil.isNotEmpty(diffList.get(0))) { | |
| 174 | + diffList.get(0).forEach(o -> o.setPaymentId(id)); | |
| 175 | + financePaymentItemMapper.insertBatch(diffList.get(0)); | |
| 176 | + } | |
| 177 | + if (CollUtil.isNotEmpty(diffList.get(1))) { | |
| 178 | + financePaymentItemMapper.updateBatch(diffList.get(1)); | |
| 179 | + } | |
| 180 | + if (CollUtil.isNotEmpty(diffList.get(2))) { | |
| 181 | + financePaymentItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpFinancePaymentItemDO::getId)); | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + @Override | |
| 186 | + @Transactional(rollbackFor = Exception.class) | |
| 187 | + public void deleteFinancePayment(List<Long> ids) { | |
| 188 | + // 1. 校验不处于已审批 | |
| 189 | + List<ErpFinancePaymentDO> payments = financePaymentMapper.selectBatchIds(ids); | |
| 190 | + if (CollUtil.isEmpty(payments)) { | |
| 191 | + return; | |
| 192 | + } | |
| 193 | + payments.forEach(payment -> { | |
| 194 | + if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { | |
| 195 | + throw exception(SALE_ORDER_DELETE_FAIL_APPROVE, payment.getNo()); | |
| 196 | + } | |
| 197 | + }); | |
| 198 | + | |
| 199 | + // 2. 遍历删除,并记录操作日志 | |
| 200 | + payments.forEach(payment -> { | |
| 201 | + // 2.1 删除付款单 | |
| 202 | + financePaymentMapper.deleteById(payment.getId()); | |
| 203 | + // 2.2 删除付款单项 | |
| 204 | + financePaymentItemMapper.deleteByPaymentId(payment.getId()); | |
| 205 | + }); | |
| 206 | + } | |
| 207 | + | |
| 208 | + private ErpFinancePaymentDO validateFinancePaymentExists(Long id) { | |
| 209 | + ErpFinancePaymentDO payment = financePaymentMapper.selectById(id); | |
| 210 | + if (payment == null) { | |
| 211 | + throw exception(SALE_ORDER_NOT_EXISTS); | |
| 212 | + } | |
| 213 | + return payment; | |
| 214 | + } | |
| 215 | + | |
| 216 | + @Override | |
| 217 | + public ErpFinancePaymentDO getFinancePayment(Long id) { | |
| 218 | + return financePaymentMapper.selectById(id); | |
| 219 | + } | |
| 220 | + | |
| 221 | + @Override | |
| 222 | + public PageResult<ErpFinancePaymentDO> getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO) { | |
| 223 | + return financePaymentMapper.selectPage(pageReqVO); | |
| 224 | + } | |
| 225 | + | |
| 226 | + // ==================== 付款单项 ==================== | |
| 227 | + | |
| 228 | + @Override | |
| 229 | + public List<ErpFinancePaymentItemDO> getFinancePaymentItemListByPaymentId(Long paymentId) { | |
| 230 | + return financePaymentItemMapper.selectListByPaymentId(paymentId); | |
| 231 | + } | |
| 232 | + | |
| 233 | + @Override | |
| 234 | + public List<ErpFinancePaymentItemDO> getFinancePaymentItemListByPaymentIds(Collection<Long> paymentIds) { | |
| 235 | + if (CollUtil.isEmpty(paymentIds)) { | |
| 236 | + return Collections.emptyList(); | |
| 237 | + } | |
| 238 | + return financePaymentItemMapper.selectListByPaymentIds(paymentIds); | |
| 239 | + } | |
| 240 | + | |
| 241 | +} | |
| 0 | 242 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java
| ... | ... | @@ -56,6 +56,14 @@ public interface ErpPurchaseInService { |
| 56 | 56 | ErpPurchaseInDO getPurchaseIn(Long id); |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | + * 校验采购入库,已经审核通过 | |
| 60 | + * | |
| 61 | + * @param id 编号 | |
| 62 | + * @return 采购入库 | |
| 63 | + */ | |
| 64 | + ErpPurchaseInDO validatePurchaseIn(Long id); | |
| 65 | + | |
| 66 | + /** | |
| 59 | 67 | * 获得采购入库分页 |
| 60 | 68 | * |
| 61 | 69 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java
| ... | ... | @@ -78,7 +78,7 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { |
| 78 | 78 | List<ErpPurchaseInItemDO> purchaseInItems = validatePurchaseInItems(createReqVO.getItems()); |
| 79 | 79 | // 1.3 校验结算账户 |
| 80 | 80 | accountService.validateAccount(createReqVO.getAccountId()); |
| 81 | - // 1.4 生成调拨单号,并校验唯一性 | |
| 81 | + // 1.4 生成入库单号,并校验唯一性 | |
| 82 | 82 | String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_IN_NO_PREFIX); |
| 83 | 83 | if (purchaseInMapper.selectByNo(no) != null) { |
| 84 | 84 | throw exception(PURCHASE_IN_NO_EXISTS); |
| ... | ... | @@ -163,6 +163,7 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { |
| 163 | 163 | if (purchaseIn.getStatus().equals(status)) { |
| 164 | 164 | throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL); |
| 165 | 165 | } |
| 166 | + // TODO 芋艿:稍后加下校验 | |
| 166 | 167 | |
| 167 | 168 | // 2. 更新状态 |
| 168 | 169 | int updateCount = purchaseInMapper.updateByIdAndStatus(id, purchaseIn.getStatus(), |
| ... | ... | @@ -261,6 +262,15 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { |
| 261 | 262 | } |
| 262 | 263 | |
| 263 | 264 | @Override |
| 265 | + public ErpPurchaseInDO validatePurchaseIn(Long id) { | |
| 266 | + ErpPurchaseInDO purchaseIn = validatePurchaseInExists(id); | |
| 267 | + if (ObjectUtil.notEqual(purchaseIn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { | |
| 268 | + throw exception(PURCHASE_IN_NOT_APPROVE); | |
| 269 | + } | |
| 270 | + return purchaseIn; | |
| 271 | + } | |
| 272 | + | |
| 273 | + @Override | |
| 264 | 274 | public PageResult<ErpPurchaseInDO> getPurchaseInPage(ErpPurchaseInPageReqVO pageReqVO) { |
| 265 | 275 | return purchaseInMapper.selectPage(pageReqVO); |
| 266 | 276 | } | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java
| ... | ... | @@ -68,7 +68,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService { |
| 68 | 68 | if (createReqVO.getAccountId() != null) { |
| 69 | 69 | accountService.validateAccount(createReqVO.getAccountId()); |
| 70 | 70 | } |
| 71 | - // 1.4 生成调拨单号,并校验唯一性 | |
| 71 | + // 1.4 生成订单号,并校验唯一性 | |
| 72 | 72 | String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_ORDER_NO_PREFIX); |
| 73 | 73 | if (purchaseOrderMapper.selectByNo(no) != null) { |
| 74 | 74 | throw exception(PURCHASE_ORDER_NO_EXISTS); | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java
| ... | ... | @@ -56,6 +56,14 @@ public interface ErpPurchaseReturnService { |
| 56 | 56 | ErpPurchaseReturnDO getPurchaseReturn(Long id); |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | + * 校验采购退货,已经审核通过 | |
| 60 | + * | |
| 61 | + * @param id 编号 | |
| 62 | + * @return 采购退货 | |
| 63 | + */ | |
| 64 | + ErpPurchaseReturnDO validatePurchaseReturn(Long id); | |
| 65 | + | |
| 66 | + /** | |
| 59 | 67 | * 获得采购退货分页 |
| 60 | 68 | * |
| 61 | 69 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java
| ... | ... | @@ -74,7 +74,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { |
| 74 | 74 | List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems()); |
| 75 | 75 | // 1.3 校验结算账户 |
| 76 | 76 | accountService.validateAccount(createReqVO.getAccountId()); |
| 77 | - // 1.4 生成调拨单号,并校验唯一性 | |
| 77 | + // 1.4 生成退货单号,并校验唯一性 | |
| 78 | 78 | String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX); |
| 79 | 79 | if (purchaseReturnMapper.selectByNo(no) != null) { |
| 80 | 80 | throw exception(PURCHASE_RETURN_NO_EXISTS); |
| ... | ... | @@ -159,6 +159,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { |
| 159 | 159 | if (purchaseReturn.getStatus().equals(status)) { |
| 160 | 160 | throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL); |
| 161 | 161 | } |
| 162 | + // TODO 芋艿:稍后加下校验 | |
| 162 | 163 | |
| 163 | 164 | // 2. 更新状态 |
| 164 | 165 | int updateCount = purchaseReturnMapper.updateByIdAndStatus(id, purchaseReturn.getStatus(), |
| ... | ... | @@ -257,6 +258,15 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { |
| 257 | 258 | } |
| 258 | 259 | |
| 259 | 260 | @Override |
| 261 | + public ErpPurchaseReturnDO validatePurchaseReturn(Long id) { | |
| 262 | + ErpPurchaseReturnDO purchaseReturn = getPurchaseReturn(id); | |
| 263 | + if (ObjectUtil.notEqual(purchaseReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { | |
| 264 | + throw exception(PURCHASE_RETURN_NOT_APPROVE); | |
| 265 | + } | |
| 266 | + return purchaseReturn; | |
| 267 | + } | |
| 268 | + | |
| 269 | + @Override | |
| 260 | 270 | public PageResult<ErpPurchaseReturnDO> getPurchaseReturnPage(ErpPurchaseReturnPageReqVO pageReqVO) { |
| 261 | 271 | return purchaseReturnMapper.selectPage(pageReqVO); |
| 262 | 272 | } | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java
| ... | ... | @@ -76,7 +76,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { |
| 76 | 76 | if (createReqVO.getSaleUserId() != null) { |
| 77 | 77 | adminUserApi.validateUser(createReqVO.getSaleUserId()); |
| 78 | 78 | } |
| 79 | - // 1.5 生成调拨单号,并校验唯一性 | |
| 79 | + // 1.5 生成订单号,并校验唯一性 | |
| 80 | 80 | String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_ORDER_NO_PREFIX); |
| 81 | 81 | if (saleOrderMapper.selectByNo(no) != null) { |
| 82 | 82 | throw exception(SALE_ORDER_NO_EXISTS); | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java
| ... | ... | @@ -82,7 +82,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { |
| 82 | 82 | if (createReqVO.getSaleUserId() != null) { |
| 83 | 83 | adminUserApi.validateUser(createReqVO.getSaleUserId()); |
| 84 | 84 | } |
| 85 | - // 1.5 生成调拨单号,并校验唯一性 | |
| 85 | + // 1.5 生成出库单号,并校验唯一性 | |
| 86 | 86 | String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_OUT_NO_PREFIX); |
| 87 | 87 | if (saleOutMapper.selectByNo(no) != null) { |
| 88 | 88 | throw exception(SALE_OUT_NO_EXISTS); | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java
| ... | ... | @@ -82,7 +82,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { |
| 82 | 82 | if (createReqVO.getSaleUserId() != null) { |
| 83 | 83 | adminUserApi.validateUser(createReqVO.getSaleUserId()); |
| 84 | 84 | } |
| 85 | - // 1.5 生成调拨单号,并校验唯一性 | |
| 85 | + // 1.5 生成退货单号,并校验唯一性 | |
| 86 | 86 | String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_RETURN_NO_PREFIX); |
| 87 | 87 | if (saleReturnMapper.selectByNo(no) != null) { |
| 88 | 88 | throw exception(SALE_RETURN_NO_EXISTS); | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.erp.service.finance; | |
| 2 | - | |
| 3 | -import org.junit.jupiter.api.Disabled; | |
| 4 | -import org.junit.jupiter.api.Test; | |
| 5 | -import org.springframework.boot.test.mock.mockito.MockBean; | |
| 6 | - | |
| 7 | -import jakarta.annotation.Resource; | |
| 8 | - | |
| 9 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 10 | - | |
| 11 | -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.*; | |
| 12 | -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; | |
| 13 | -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpAccountMapper; | |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 16 | -import jakarta.annotation.Resource; | |
| 17 | -import org.springframework.context.annotation.Import; | |
| 18 | -import java.util.*; | |
| 19 | -import java.time.LocalDateTime; | |
| 20 | - | |
| 21 | -import static cn.hutool.core.util.RandomUtil.*; | |
| 22 | -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 23 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 24 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 25 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 26 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 27 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; | |
| 28 | -import static org.junit.jupiter.api.Assertions.*; | |
| 29 | -import static org.mockito.Mockito.*; | |
| 30 | - | |
| 31 | -/** | |
| 32 | - * {@link ErpAccountServiceImpl} 的单元测试类 | |
| 33 | - * | |
| 34 | - * @author 芋道源码 | |
| 35 | - */ | |
| 36 | -@Import(ErpAccountServiceImpl.class) | |
| 37 | -public class ErpAccountServiceImplTest extends BaseDbUnitTest { | |
| 38 | - | |
| 39 | - @Resource | |
| 40 | - private ErpAccountServiceImpl accountService; | |
| 41 | - | |
| 42 | - @Resource | |
| 43 | - private ErpAccountMapper accountMapper; | |
| 44 | - | |
| 45 | - @Test | |
| 46 | - public void testCreateAccount_success() { | |
| 47 | - // 准备参数 | |
| 48 | - ErpAccountSaveReqVO createReqVO = randomPojo(ErpAccountSaveReqVO.class).setId(null); | |
| 49 | - | |
| 50 | - // 调用 | |
| 51 | - Long accountId = accountService.createAccount(createReqVO); | |
| 52 | - // 断言 | |
| 53 | - assertNotNull(accountId); | |
| 54 | - // 校验记录的属性是否正确 | |
| 55 | - ErpAccountDO account = accountMapper.selectById(accountId); | |
| 56 | - assertPojoEquals(createReqVO, account, "id"); | |
| 57 | - } | |
| 58 | - | |
| 59 | - @Test | |
| 60 | - public void testUpdateAccount_success() { | |
| 61 | - // mock 数据 | |
| 62 | - ErpAccountDO dbAccount = randomPojo(ErpAccountDO.class); | |
| 63 | - accountMapper.insert(dbAccount);// @Sql: 先插入出一条存在的数据 | |
| 64 | - // 准备参数 | |
| 65 | - ErpAccountSaveReqVO updateReqVO = randomPojo(ErpAccountSaveReqVO.class, o -> { | |
| 66 | - o.setId(dbAccount.getId()); // 设置更新的 ID | |
| 67 | - }); | |
| 68 | - | |
| 69 | - // 调用 | |
| 70 | - accountService.updateAccount(updateReqVO); | |
| 71 | - // 校验是否更新正确 | |
| 72 | - ErpAccountDO account = accountMapper.selectById(updateReqVO.getId()); // 获取最新的 | |
| 73 | - assertPojoEquals(updateReqVO, account); | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Test | |
| 77 | - public void testUpdateAccount_notExists() { | |
| 78 | - // 准备参数 | |
| 79 | - ErpAccountSaveReqVO updateReqVO = randomPojo(ErpAccountSaveReqVO.class); | |
| 80 | - | |
| 81 | - // 调用, 并断言异常 | |
| 82 | - assertServiceException(() -> accountService.updateAccount(updateReqVO), ACCOUNT_NOT_EXISTS); | |
| 83 | - } | |
| 84 | - | |
| 85 | - @Test | |
| 86 | - public void testDeleteAccount_success() { | |
| 87 | - // mock 数据 | |
| 88 | - ErpAccountDO dbAccount = randomPojo(ErpAccountDO.class); | |
| 89 | - accountMapper.insert(dbAccount);// @Sql: 先插入出一条存在的数据 | |
| 90 | - // 准备参数 | |
| 91 | - Long id = dbAccount.getId(); | |
| 92 | - | |
| 93 | - // 调用 | |
| 94 | - accountService.deleteAccount(id); | |
| 95 | - // 校验数据不存在了 | |
| 96 | - assertNull(accountMapper.selectById(id)); | |
| 97 | - } | |
| 98 | - | |
| 99 | - @Test | |
| 100 | - public void testDeleteAccount_notExists() { | |
| 101 | - // 准备参数 | |
| 102 | - Long id = randomLongId(); | |
| 103 | - | |
| 104 | - // 调用, 并断言异常 | |
| 105 | - assertServiceException(() -> accountService.deleteAccount(id), ACCOUNT_NOT_EXISTS); | |
| 106 | - } | |
| 107 | - | |
| 108 | - @Test | |
| 109 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 110 | - public void testGetAccountPage() { | |
| 111 | - // mock 数据 | |
| 112 | - ErpAccountDO dbAccount = randomPojo(ErpAccountDO.class, o -> { // 等会查询到 | |
| 113 | - o.setNo(null); | |
| 114 | - o.setRemark(null); | |
| 115 | - o.setStatus(null); | |
| 116 | - o.setName(null); | |
| 117 | - }); | |
| 118 | - accountMapper.insert(dbAccount); | |
| 119 | - // 测试 no 不匹配 | |
| 120 | - accountMapper.insert(cloneIgnoreId(dbAccount, o -> o.setNo(null))); | |
| 121 | - // 测试 remark 不匹配 | |
| 122 | - accountMapper.insert(cloneIgnoreId(dbAccount, o -> o.setRemark(null))); | |
| 123 | - // 测试 status 不匹配 | |
| 124 | - accountMapper.insert(cloneIgnoreId(dbAccount, o -> o.setStatus(null))); | |
| 125 | - // 测试 name 不匹配 | |
| 126 | - accountMapper.insert(cloneIgnoreId(dbAccount, o -> o.setName(null))); | |
| 127 | - // 准备参数 | |
| 128 | - ErpAccountPageReqVO reqVO = new ErpAccountPageReqVO(); | |
| 129 | - reqVO.setNo(null); | |
| 130 | - reqVO.setRemark(null); | |
| 131 | - reqVO.setStatus(null); | |
| 132 | - reqVO.setName(null); | |
| 133 | - | |
| 134 | - // 调用 | |
| 135 | - PageResult<ErpAccountDO> pageResult = accountService.getAccountPage(reqVO); | |
| 136 | - // 断言 | |
| 137 | - assertEquals(1, pageResult.getTotal()); | |
| 138 | - assertEquals(1, pageResult.getList().size()); | |
| 139 | - assertPojoEquals(dbAccount, pageResult.getList().get(0)); | |
| 140 | - } | |
| 141 | - | |
| 142 | -} | |
| 143 | 0 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.erp.service.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; | |
| 4 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; | |
| 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.product.ErpProductUnitDO; | |
| 13 | -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; | |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 16 | -import org.springframework.context.annotation.Import; | |
| 17 | - | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 21 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 22 | -import static org.junit.jupiter.api.Assertions.*; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - * {@link ErpProductUnitServiceImpl} 的单元测试类 | |
| 26 | - * | |
| 27 | - * @author 芋道源码 | |
| 28 | - */ | |
| 29 | -@Import(ErpProductUnitServiceImpl.class) | |
| 30 | -public class ErpProductUnitServiceImplTest extends BaseDbUnitTest { | |
| 31 | - | |
| 32 | - @Resource | |
| 33 | - private ErpProductUnitServiceImpl productUnitService; | |
| 34 | - | |
| 35 | - @Resource | |
| 36 | - private ErpProductUnitMapper productUnitMapper; | |
| 37 | - | |
| 38 | - @Test | |
| 39 | - public void testCreateProductUnit_success() { | |
| 40 | - // 准备参数 | |
| 41 | - ErpProductUnitSaveReqVO createReqVO = randomPojo(ErpProductUnitSaveReqVO.class).setId(null); | |
| 42 | - | |
| 43 | - // 调用 | |
| 44 | - Long productUnitId = productUnitService.createProductUnit(createReqVO); | |
| 45 | - // 断言 | |
| 46 | - assertNotNull(productUnitId); | |
| 47 | - // 校验记录的属性是否正确 | |
| 48 | - ErpProductUnitDO productUnit = productUnitMapper.selectById(productUnitId); | |
| 49 | - assertPojoEquals(createReqVO, productUnit, "id"); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Test | |
| 53 | - public void testUpdateProductUnit_success() { | |
| 54 | - // mock 数据 | |
| 55 | - ErpProductUnitDO dbProductUnit = randomPojo(ErpProductUnitDO.class); | |
| 56 | - productUnitMapper.insert(dbProductUnit);// @Sql: 先插入出一条存在的数据 | |
| 57 | - // 准备参数 | |
| 58 | - ErpProductUnitSaveReqVO updateReqVO = randomPojo(ErpProductUnitSaveReqVO.class, o -> { | |
| 59 | - o.setId(dbProductUnit.getId()); // 设置更新的 ID | |
| 60 | - }); | |
| 61 | - | |
| 62 | - // 调用 | |
| 63 | - productUnitService.updateProductUnit(updateReqVO); | |
| 64 | - // 校验是否更新正确 | |
| 65 | - ErpProductUnitDO productUnit = productUnitMapper.selectById(updateReqVO.getId()); // 获取最新的 | |
| 66 | - assertPojoEquals(updateReqVO, productUnit); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Test | |
| 70 | - public void testUpdateProductUnit_notExists() { | |
| 71 | - // 准备参数 | |
| 72 | - ErpProductUnitSaveReqVO updateReqVO = randomPojo(ErpProductUnitSaveReqVO.class); | |
| 73 | - | |
| 74 | - // 调用, 并断言异常 | |
| 75 | - assertServiceException(() -> productUnitService.updateProductUnit(updateReqVO), PRODUCT_UNIT_NOT_EXISTS); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @Test | |
| 79 | - public void testDeleteProductUnit_success() { | |
| 80 | - // mock 数据 | |
| 81 | - ErpProductUnitDO dbProductUnit = randomPojo(ErpProductUnitDO.class); | |
| 82 | - productUnitMapper.insert(dbProductUnit);// @Sql: 先插入出一条存在的数据 | |
| 83 | - // 准备参数 | |
| 84 | - Long id = dbProductUnit.getId(); | |
| 85 | - | |
| 86 | - // 调用 | |
| 87 | - productUnitService.deleteProductUnit(id); | |
| 88 | - // 校验数据不存在了 | |
| 89 | - assertNull(productUnitMapper.selectById(id)); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @Test | |
| 93 | - public void testDeleteProductUnit_notExists() { | |
| 94 | - // 准备参数 | |
| 95 | - Long id = randomLongId(); | |
| 96 | - | |
| 97 | - // 调用, 并断言异常 | |
| 98 | - assertServiceException(() -> productUnitService.deleteProductUnit(id), PRODUCT_UNIT_NOT_EXISTS); | |
| 99 | - } | |
| 100 | - | |
| 101 | - @Test | |
| 102 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 103 | - public void testGetProductUnitPage() { | |
| 104 | - // mock 数据 | |
| 105 | - ErpProductUnitDO dbProductUnit = randomPojo(ErpProductUnitDO.class, o -> { // 等会查询到 | |
| 106 | - o.setName(null); | |
| 107 | - o.setStatus(null); | |
| 108 | - o.setCreateTime(null); | |
| 109 | - }); | |
| 110 | - productUnitMapper.insert(dbProductUnit); | |
| 111 | - // 测试 name 不匹配 | |
| 112 | - productUnitMapper.insert(cloneIgnoreId(dbProductUnit, o -> o.setName(null))); | |
| 113 | - // 测试 status 不匹配 | |
| 114 | - productUnitMapper.insert(cloneIgnoreId(dbProductUnit, o -> o.setStatus(null))); | |
| 115 | - // 测试 createTime 不匹配 | |
| 116 | - productUnitMapper.insert(cloneIgnoreId(dbProductUnit, o -> o.setCreateTime(null))); | |
| 117 | - // 准备参数 | |
| 118 | - ErpProductUnitPageReqVO reqVO = new ErpProductUnitPageReqVO(); | |
| 119 | - reqVO.setName(null); | |
| 120 | - reqVO.setStatus(null); | |
| 121 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 122 | - | |
| 123 | - // 调用 | |
| 124 | - PageResult<ErpProductUnitDO> pageResult = productUnitService.getProductUnitPage(reqVO); | |
| 125 | - // 断言 | |
| 126 | - assertEquals(1, pageResult.getTotal()); | |
| 127 | - assertEquals(1, pageResult.getList().size()); | |
| 128 | - assertPojoEquals(dbProductUnit, pageResult.getList().get(0)); | |
| 129 | - } | |
| 130 | - | |
| 131 | -} | |
| 132 | 0 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/product/ProductServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.erp.service.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 4 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; | |
| 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.product.ErpProductDO; | |
| 13 | -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; | |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 16 | -import org.springframework.context.annotation.Import; | |
| 17 | - | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 21 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 22 | -import static org.junit.jupiter.api.Assertions.*; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - * {@link ErpProductServiceImpl} 的单元测试类 | |
| 26 | - * | |
| 27 | - * @author 芋道源码 | |
| 28 | - */ | |
| 29 | -@Import(ErpProductServiceImpl.class) | |
| 30 | -public class ProductServiceImplTest extends BaseDbUnitTest { | |
| 31 | - | |
| 32 | - @Resource | |
| 33 | - private ErpProductServiceImpl productService; | |
| 34 | - | |
| 35 | - @Resource | |
| 36 | - private ErpProductMapper productMapper; | |
| 37 | - | |
| 38 | - @Test | |
| 39 | - public void testCreateProduct_success() { | |
| 40 | - // 准备参数 | |
| 41 | - ProductSaveReqVO createReqVO = randomPojo(ProductSaveReqVO.class).setId(null); | |
| 42 | - | |
| 43 | - // 调用 | |
| 44 | - Long productId = productService.createProduct(createReqVO); | |
| 45 | - // 断言 | |
| 46 | - assertNotNull(productId); | |
| 47 | - // 校验记录的属性是否正确 | |
| 48 | - ErpProductDO product = productMapper.selectById(productId); | |
| 49 | - assertPojoEquals(createReqVO, product, "id"); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Test | |
| 53 | - public void testUpdateProduct_success() { | |
| 54 | - // mock 数据 | |
| 55 | - ErpProductDO dbProduct = randomPojo(ErpProductDO.class); | |
| 56 | - productMapper.insert(dbProduct);// @Sql: 先插入出一条存在的数据 | |
| 57 | - // 准备参数 | |
| 58 | - ProductSaveReqVO updateReqVO = randomPojo(ProductSaveReqVO.class, o -> { | |
| 59 | - o.setId(dbProduct.getId()); // 设置更新的 ID | |
| 60 | - }); | |
| 61 | - | |
| 62 | - // 调用 | |
| 63 | - productService.updateProduct(updateReqVO); | |
| 64 | - // 校验是否更新正确 | |
| 65 | - ErpProductDO product = productMapper.selectById(updateReqVO.getId()); // 获取最新的 | |
| 66 | - assertPojoEquals(updateReqVO, product); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Test | |
| 70 | - public void testUpdateProduct_notExists() { | |
| 71 | - // 准备参数 | |
| 72 | - ProductSaveReqVO updateReqVO = randomPojo(ProductSaveReqVO.class); | |
| 73 | - | |
| 74 | - // 调用, 并断言异常 | |
| 75 | - assertServiceException(() -> productService.updateProduct(updateReqVO), PRODUCT_NOT_EXISTS); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @Test | |
| 79 | - public void testDeleteProduct_success() { | |
| 80 | - // mock 数据 | |
| 81 | - ErpProductDO dbProduct = randomPojo(ErpProductDO.class); | |
| 82 | - productMapper.insert(dbProduct);// @Sql: 先插入出一条存在的数据 | |
| 83 | - // 准备参数 | |
| 84 | - Long id = dbProduct.getId(); | |
| 85 | - | |
| 86 | - // 调用 | |
| 87 | - productService.deleteProduct(id); | |
| 88 | - // 校验数据不存在了 | |
| 89 | - assertNull(productMapper.selectById(id)); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @Test | |
| 93 | - public void testDeleteProduct_notExists() { | |
| 94 | - // 准备参数 | |
| 95 | - Long id = randomLongId(); | |
| 96 | - | |
| 97 | - // 调用, 并断言异常 | |
| 98 | - assertServiceException(() -> productService.deleteProduct(id), PRODUCT_NOT_EXISTS); | |
| 99 | - } | |
| 100 | - | |
| 101 | - @Test | |
| 102 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 103 | - public void testGetProductPage() { | |
| 104 | - // mock 数据 | |
| 105 | - ErpProductDO dbProduct = randomPojo(ErpProductDO.class, o -> { // 等会查询到 | |
| 106 | - o.setName(null); | |
| 107 | - o.setCategoryId(null); | |
| 108 | - o.setCreateTime(null); | |
| 109 | - }); | |
| 110 | - productMapper.insert(dbProduct); | |
| 111 | - // 测试 name 不匹配 | |
| 112 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setName(null))); | |
| 113 | - // 测试 categoryId 不匹配 | |
| 114 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCategoryId(null))); | |
| 115 | - // 测试 createTime 不匹配 | |
| 116 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCreateTime(null))); | |
| 117 | - // 准备参数 | |
| 118 | - ErpProductPageReqVO reqVO = new ErpProductPageReqVO(); | |
| 119 | - reqVO.setName(null); | |
| 120 | - reqVO.setCategoryId(null); | |
| 121 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 122 | - | |
| 123 | - // 调用 | |
| 124 | - PageResult<ErpProductDO> pageResult = productService.getProductVOPage(reqVO); | |
| 125 | - // 断言 | |
| 126 | - assertEquals(1, pageResult.getTotal()); | |
| 127 | - assertEquals(1, pageResult.getList().size()); | |
| 128 | - assertPojoEquals(dbProduct, pageResult.getList().get(0)); | |
| 129 | - } | |
| 130 | - | |
| 131 | -} | |
| 132 | 0 | \ 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 deleted
| 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 | -} | |
| 132 | 0 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.erp.service.stock; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; | |
| 4 | -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; | |
| 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.stock.ErpWarehouseDO; | |
| 13 | -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper; | |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 16 | -import org.springframework.context.annotation.Import; | |
| 17 | - | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 21 | -import static org.junit.jupiter.api.Assertions.*; | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * {@link ErpWarehouseServiceImpl} 的单元测试类 | |
| 25 | - * | |
| 26 | - * @author 芋道源码 | |
| 27 | - */ | |
| 28 | -@Import(ErpWarehouseServiceImpl.class) | |
| 29 | -public class ErpWarehouseServiceImplTest extends BaseDbUnitTest { | |
| 30 | - | |
| 31 | - @Resource | |
| 32 | - private ErpWarehouseServiceImpl warehouseService; | |
| 33 | - | |
| 34 | - @Resource | |
| 35 | - private ErpWarehouseMapper warehouseMapper; | |
| 36 | - | |
| 37 | - @Test | |
| 38 | - public void testCreateWarehouse_success() { | |
| 39 | - // 准备参数 | |
| 40 | - ErpWarehouseSaveReqVO createReqVO = randomPojo(ErpWarehouseSaveReqVO.class).setId(null); | |
| 41 | - | |
| 42 | - // 调用 | |
| 43 | - Long warehouseId = warehouseService.createWarehouse(createReqVO); | |
| 44 | - // 断言 | |
| 45 | - assertNotNull(warehouseId); | |
| 46 | - // 校验记录的属性是否正确 | |
| 47 | - ErpWarehouseDO warehouse = warehouseMapper.selectById(warehouseId); | |
| 48 | - assertPojoEquals(createReqVO, warehouse, "id"); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Test | |
| 52 | - public void testUpdateWarehouse_success() { | |
| 53 | - // mock 数据 | |
| 54 | - ErpWarehouseDO dbWarehouse = randomPojo(ErpWarehouseDO.class); | |
| 55 | - warehouseMapper.insert(dbWarehouse);// @Sql: 先插入出一条存在的数据 | |
| 56 | - // 准备参数 | |
| 57 | - ErpWarehouseSaveReqVO updateReqVO = randomPojo(ErpWarehouseSaveReqVO.class, o -> { | |
| 58 | - o.setId(dbWarehouse.getId()); // 设置更新的 ID | |
| 59 | - }); | |
| 60 | - | |
| 61 | - // 调用 | |
| 62 | - warehouseService.updateWarehouse(updateReqVO); | |
| 63 | - // 校验是否更新正确 | |
| 64 | - ErpWarehouseDO warehouse = warehouseMapper.selectById(updateReqVO.getId()); // 获取最新的 | |
| 65 | - assertPojoEquals(updateReqVO, warehouse); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void testUpdateWarehouse_notExists() { | |
| 70 | - // 准备参数 | |
| 71 | - ErpWarehouseSaveReqVO updateReqVO = randomPojo(ErpWarehouseSaveReqVO.class); | |
| 72 | - | |
| 73 | - // 调用, 并断言异常 | |
| 74 | - assertServiceException(() -> warehouseService.updateWarehouse(updateReqVO), WAREHOUSE_NOT_EXISTS); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Test | |
| 78 | - public void testDeleteWarehouse_success() { | |
| 79 | - // mock 数据 | |
| 80 | - ErpWarehouseDO dbWarehouse = randomPojo(ErpWarehouseDO.class); | |
| 81 | - warehouseMapper.insert(dbWarehouse);// @Sql: 先插入出一条存在的数据 | |
| 82 | - // 准备参数 | |
| 83 | - Long id = dbWarehouse.getId(); | |
| 84 | - | |
| 85 | - // 调用 | |
| 86 | - warehouseService.deleteWarehouse(id); | |
| 87 | - // 校验数据不存在了 | |
| 88 | - assertNull(warehouseMapper.selectById(id)); | |
| 89 | - } | |
| 90 | - | |
| 91 | - @Test | |
| 92 | - public void testDeleteWarehouse_notExists() { | |
| 93 | - // 准备参数 | |
| 94 | - Long id = randomLongId(); | |
| 95 | - | |
| 96 | - // 调用, 并断言异常 | |
| 97 | - assertServiceException(() -> warehouseService.deleteWarehouse(id), WAREHOUSE_NOT_EXISTS); | |
| 98 | - } | |
| 99 | - | |
| 100 | - @Test | |
| 101 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | - public void testGetWarehousePage() { | |
| 103 | - // mock 数据 | |
| 104 | - ErpWarehouseDO dbWarehouse = randomPojo(ErpWarehouseDO.class, o -> { // 等会查询到 | |
| 105 | - o.setName(null); | |
| 106 | - o.setStatus(null); | |
| 107 | - }); | |
| 108 | - warehouseMapper.insert(dbWarehouse); | |
| 109 | - // 测试 name 不匹配 | |
| 110 | - warehouseMapper.insert(cloneIgnoreId(dbWarehouse, o -> o.setName(null))); | |
| 111 | - // 测试 status 不匹配 | |
| 112 | - warehouseMapper.insert(cloneIgnoreId(dbWarehouse, o -> o.setStatus(null))); | |
| 113 | - // 准备参数 | |
| 114 | - ErpWarehousePageReqVO reqVO = new ErpWarehousePageReqVO(); | |
| 115 | - reqVO.setName(null); | |
| 116 | - reqVO.setStatus(null); | |
| 117 | - | |
| 118 | - // 调用 | |
| 119 | - PageResult<ErpWarehouseDO> pageResult = warehouseService.getWarehousePage(reqVO); | |
| 120 | - // 断言 | |
| 121 | - assertEquals(1, pageResult.getTotal()); | |
| 122 | - assertEquals(1, pageResult.getList().size()); | |
| 123 | - assertPojoEquals(dbWarehouse, pageResult.getList().get(0)); | |
| 124 | - } | |
| 125 | - | |
| 126 | -} | |
| 127 | 0 | \ No newline at end of file |