Commit 3c6ab397f9290372697b8cb40cc9fd19f1147d10
1 parent
d06a22da
✨ ERP:初始化销售出库 30%
Showing
20 changed files
with
1130 additions
and
16 deletions
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.controller.admin.finance; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -26,6 +27,7 @@ import java.io.IOException; |
| 26 | 27 | import java.util.List; |
| 27 | 28 | |
| 28 | 29 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 29 | 31 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 30 | 32 | |
| 31 | 33 | @Tag(name = "管理后台 - ERP 结算账户") |
| ... | ... | @@ -82,6 +84,14 @@ public class ErpAccountController { |
| 82 | 84 | return success(BeanUtils.toBean(account, ErpAccountRespVO.class)); |
| 83 | 85 | } |
| 84 | 86 | |
| 87 | + @GetMapping("/simple-list") | |
| 88 | + @Operation(summary = "获得结算账户精简列表", description = "只包含被开启的结算账户,主要用于前端的下拉选项") | |
| 89 | + public CommonResult<List<ErpAccountRespVO>> getWarehouseSimpleList() { | |
| 90 | + List<ErpAccountDO> list = accountService.getAccountListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 91 | + return success(convertList(list, account -> new ErpAccountRespVO().setId(account.getId()) | |
| 92 | + .setName(account.getName()).setDefaultStatus(account.getDefaultStatus()))); | |
| 93 | + } | |
| 94 | + | |
| 85 | 95 | @GetMapping("/page") |
| 86 | 96 | @Operation(summary = "获得结算账户分页") |
| 87 | 97 | @PreAuthorize("@ss.hasPermission('erp:account:query')") | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.http deleted
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale; | |
| 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.object.BeanUtils; | |
| 9 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 10 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutRespVO; | |
| 14 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; | |
| 15 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; | |
| 16 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; | |
| 17 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; | |
| 18 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | |
| 19 | +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | |
| 20 | +import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; | |
| 21 | +import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOutService; | |
| 22 | +import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; | |
| 23 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 24 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 25 | +import io.swagger.v3.oas.annotations.Operation; | |
| 26 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 27 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 28 | +import jakarta.annotation.Resource; | |
| 29 | +import jakarta.servlet.http.HttpServletResponse; | |
| 30 | +import jakarta.validation.Valid; | |
| 31 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 32 | +import org.springframework.validation.annotation.Validated; | |
| 33 | +import org.springframework.web.bind.annotation.*; | |
| 34 | + | |
| 35 | +import java.io.IOException; | |
| 36 | +import java.math.BigDecimal; | |
| 37 | +import java.util.List; | |
| 38 | +import java.util.Map; | |
| 39 | + | |
| 40 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 41 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; | |
| 42 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 43 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 44 | + | |
| 45 | +@Tag(name = "管理后台 - ERP 销售出库") | |
| 46 | +@RestController | |
| 47 | +@RequestMapping("/erp/sale-out") | |
| 48 | +@Validated | |
| 49 | +public class ErpSaleOutController { | |
| 50 | + | |
| 51 | + @Resource | |
| 52 | + private ErpSaleOutService saleOutService; | |
| 53 | + @Resource | |
| 54 | + private ErpStockService stockService; | |
| 55 | + @Resource | |
| 56 | + private ErpProductService productService; | |
| 57 | + @Resource | |
| 58 | + private ErpCustomerService customerService; | |
| 59 | + | |
| 60 | + @Resource | |
| 61 | + private AdminUserApi adminUserApi; | |
| 62 | + | |
| 63 | + @PostMapping("/create") | |
| 64 | + @Operation(summary = "创建销售出库") | |
| 65 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:create')") | |
| 66 | + public CommonResult<Long> createSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO createReqVO) { | |
| 67 | + return success(saleOutService.createSaleOut(createReqVO)); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @PutMapping("/update") | |
| 71 | + @Operation(summary = "更新销售出库") | |
| 72 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:update')") | |
| 73 | + public CommonResult<Boolean> updateSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO updateReqVO) { | |
| 74 | + saleOutService.updateSaleOut(updateReqVO); | |
| 75 | + return success(true); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @PutMapping("/update-status") | |
| 79 | + @Operation(summary = "更新销售出库的状态") | |
| 80 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')") | |
| 81 | + public CommonResult<Boolean> updateSaleOutStatus(@RequestParam("id") Long id, | |
| 82 | + @RequestParam("status") Integer status) { | |
| 83 | + saleOutService.updateSaleOutStatus(id, status); | |
| 84 | + return success(true); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @DeleteMapping("/delete") | |
| 88 | + @Operation(summary = "删除销售出库") | |
| 89 | + @Parameter(name = "ids", description = "编号数组", required = true) | |
| 90 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:delete')") | |
| 91 | + public CommonResult<Boolean> deleteSaleOut(@RequestParam("ids") List<Long> ids) { | |
| 92 | + saleOutService.deleteSaleOut(ids); | |
| 93 | + return success(true); | |
| 94 | + } | |
| 95 | + | |
| 96 | + @GetMapping("/get") | |
| 97 | + @Operation(summary = "获得销售出库") | |
| 98 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 99 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") | |
| 100 | + public CommonResult<ErpSaleOutRespVO> getSaleOut(@RequestParam("id") Long id) { | |
| 101 | + ErpSaleOutDO saleOut = saleOutService.getSaleOut(id); | |
| 102 | + if (saleOut == null) { | |
| 103 | + return success(null); | |
| 104 | + } | |
| 105 | + List<ErpSaleOutItemDO> saleOutItemList = saleOutService.getSaleOutItemListByOutId(id); | |
| 106 | + Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( | |
| 107 | + convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); | |
| 108 | + return success(BeanUtils.toBean(saleOut, ErpSaleOutRespVO.class, saleOutVO -> | |
| 109 | + saleOutVO.setItems(BeanUtils.toBean(saleOutItemList, ErpSaleOutRespVO.Item.class, item -> { | |
| 110 | + ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); | |
| 111 | + item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); | |
| 112 | + MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) | |
| 113 | + .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); | |
| 114 | + })))); | |
| 115 | + } | |
| 116 | + | |
| 117 | + @GetMapping("/page") | |
| 118 | + @Operation(summary = "获得销售出库分页") | |
| 119 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") | |
| 120 | + public CommonResult<PageResult<ErpSaleOutRespVO>> getSaleOutPage(@Valid ErpSaleOutPageReqVO pageReqVO) { | |
| 121 | + PageResult<ErpSaleOutDO> pageResult = saleOutService.getSaleOutPage(pageReqVO); | |
| 122 | + return success(buildSaleOutVOPageResult(pageResult)); | |
| 123 | + } | |
| 124 | + | |
| 125 | + @GetMapping("/export-excel") | |
| 126 | + @Operation(summary = "导出销售出库 Excel") | |
| 127 | + @PreAuthorize("@ss.hasPermission('erp:stock-out:export')") | |
| 128 | + @OperateLog(type = EXPORT) | |
| 129 | + public void exportSaleOutExcel(@Valid ErpSaleOutPageReqVO pageReqVO, | |
| 130 | + HttpServletResponse response) throws IOException { | |
| 131 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 132 | + List<ErpSaleOutRespVO> list = buildSaleOutVOPageResult(saleOutService.getSaleOutPage(pageReqVO)).getList(); | |
| 133 | + // 导出 Excel | |
| 134 | + ExcelUtils.write(response, "销售出库.xls", "数据", ErpSaleOutRespVO.class, list); | |
| 135 | + } | |
| 136 | + | |
| 137 | + private PageResult<ErpSaleOutRespVO> buildSaleOutVOPageResult(PageResult<ErpSaleOutDO> pageResult) { | |
| 138 | + if (CollUtil.isEmpty(pageResult.getList())) { | |
| 139 | + return PageResult.empty(pageResult.getTotal()); | |
| 140 | + } | |
| 141 | + // 1.1 出库项 | |
| 142 | + List<ErpSaleOutItemDO> saleOutItemList = saleOutService.getSaleOutItemListByOutIds( | |
| 143 | + convertSet(pageResult.getList(), ErpSaleOutDO::getId)); | |
| 144 | + Map<Long, List<ErpSaleOutItemDO>> saleOutItemMap = convertMultiMap(saleOutItemList, ErpSaleOutItemDO::getOutId); | |
| 145 | + // 1.2 商品信息 | |
| 146 | + Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( | |
| 147 | + convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); | |
| 148 | + // 1.3 客户信息 | |
| 149 | + Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap( | |
| 150 | + convertSet(pageResult.getList(), ErpSaleOutDO::getCustomerId)); | |
| 151 | + // 1.4 管理员信息 | |
| 152 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | |
| 153 | + convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 154 | + // 2. 开始拼接 | |
| 155 | + return BeanUtils.toBean(pageResult, ErpSaleOutRespVO.class, saleOut -> { | |
| 156 | + saleOut.setItems(BeanUtils.toBean(saleOutItemMap.get(saleOut.getId()), ErpSaleOutRespVO.Item.class, | |
| 157 | + item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) | |
| 158 | + .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); | |
| 159 | + saleOut.setProductNames(CollUtil.join(saleOut.getItems(), ",", ErpSaleOutRespVO.Item::getProductName)); | |
| 160 | + MapUtils.findAndThen(customerMap, saleOut.getCustomerId(), supplier -> saleOut.setCustomerName(supplier.getName())); | |
| 161 | + MapUtils.findAndThen(userMap, Long.parseLong(saleOut.getCreator()), user -> saleOut.setCreatorName(user.getNickname())); | |
| 162 | + }); | |
| 163 | + } | |
| 164 | + | |
| 165 | +} | |
| 0 | 166 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java
| ... | ... | @@ -64,7 +64,6 @@ public class ErpSaleOrderRespVO { |
| 64 | 64 | private BigDecimal discountPrice; |
| 65 | 65 | |
| 66 | 66 | @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") |
| 67 | - @NotNull(message = "定金金额,单位:元不能为空") | |
| 68 | 67 | private BigDecimal depositPrice; |
| 69 | 68 | |
| 70 | 69 | @Schema(description = "附件地址", example = "https://www.iocoder.cn") | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; | |
| 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 ErpSaleOutPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "销售单编号", example = "XS001") | |
| 21 | + private String no; | |
| 22 | + | |
| 23 | + @Schema(description = "客户编号", example = "1724") | |
| 24 | + private Long customerId; | |
| 25 | + | |
| 26 | + @Schema(description = "出库时间") | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + private LocalDateTime[] outTime; | |
| 29 | + | |
| 30 | + @Schema(description = "备注", example = "你猜") | |
| 31 | + private String remark; | |
| 32 | + | |
| 33 | + @Schema(description = "销售状态", example = "2") | |
| 34 | + private Integer status; | |
| 35 | + | |
| 36 | + @Schema(description = "创建者") | |
| 37 | + private String creator; | |
| 38 | + | |
| 39 | + @Schema(description = "产品编号", example = "1") | |
| 40 | + private Long productId; | |
| 41 | + | |
| 42 | + @Schema(description = "仓库编号", example = "1") | |
| 43 | + private Long warehouseId; | |
| 44 | + | |
| 45 | + @Schema(description = "结算账号编号", example = "1") | |
| 46 | + private Long accountId; | |
| 47 | + | |
| 48 | + @Schema(description = "是否欠款", example = "true") | |
| 49 | + private Boolean debtStatus; | |
| 50 | + | |
| 51 | + @Schema(description = "销售单号", example = "1") | |
| 52 | + private String orderNo; | |
| 53 | + | |
| 54 | +} | |
| 0 | 55 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 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 出库出库 Response VO") | |
| 14 | +@Data | |
| 15 | +@ExcelIgnoreUnannotated | |
| 16 | +public class ErpSaleOutRespVO { | |
| 17 | + | |
| 18 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 19 | + @ExcelProperty("编号") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "出库单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") | |
| 23 | + @ExcelProperty("出库单编号") | |
| 24 | + private String no; | |
| 25 | + | |
| 26 | + @Schema(description = "出库状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 27 | + @ExcelProperty("出库状态") | |
| 28 | + private Integer status; | |
| 29 | + | |
| 30 | + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") | |
| 31 | + private Long customerId; | |
| 32 | + @Schema(description = "客户名称", example = "芋道") | |
| 33 | + @ExcelProperty("客户名称") | |
| 34 | + private String customerName; | |
| 35 | + | |
| 36 | + @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") | |
| 37 | + @ExcelProperty("结算账户编号") | |
| 38 | + private Long accountId; | |
| 39 | + | |
| 40 | + @Schema(description = "出库员编号", example = "1888") | |
| 41 | + private Long saleUserId; | |
| 42 | + | |
| 43 | + @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 44 | + @ExcelProperty("出库时间") | |
| 45 | + private LocalDateTime outTime; | |
| 46 | + | |
| 47 | + @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 48 | + private Long orderId; | |
| 49 | + @Schema(description = "销售订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") | |
| 50 | + private Long orderNo; | |
| 51 | + | |
| 52 | + @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") | |
| 53 | + @ExcelProperty("合计数量") | |
| 54 | + private BigDecimal totalCount; | |
| 55 | + @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") | |
| 56 | + @ExcelProperty("最终合计价格") | |
| 57 | + private BigDecimal totalPrice; | |
| 58 | + | |
| 59 | + @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 60 | + private BigDecimal totalProductPrice; | |
| 61 | + | |
| 62 | + @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 63 | + private BigDecimal totalTaxPrice; | |
| 64 | + | |
| 65 | + @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") | |
| 66 | + private BigDecimal discountPercent; | |
| 67 | + | |
| 68 | + @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 69 | + private BigDecimal discountPrice; | |
| 70 | + | |
| 71 | + @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 72 | + private BigDecimal otherPrice; | |
| 73 | + | |
| 74 | + @Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 75 | + private BigDecimal payPrice; | |
| 76 | + @Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") | |
| 77 | + private BigDecimal debtPrice; | |
| 78 | + | |
| 79 | + | |
| 80 | + @Schema(description = "附件地址", example = "https://www.iocoder.cn") | |
| 81 | + @ExcelProperty("附件地址") | |
| 82 | + private String fileUrl; | |
| 83 | + | |
| 84 | + @Schema(description = "备注", example = "你猜") | |
| 85 | + @ExcelProperty("备注") | |
| 86 | + private String remark; | |
| 87 | + | |
| 88 | + @Schema(description = "审核人", example = "芋道") | |
| 89 | + private String creator; | |
| 90 | + @Schema(description = "审核人名称", example = "芋道") | |
| 91 | + private String creatorName; | |
| 92 | + | |
| 93 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 94 | + @ExcelProperty("创建时间") | |
| 95 | + private LocalDateTime createTime; | |
| 96 | + | |
| 97 | + @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 98 | + private List<Item> items; | |
| 99 | + | |
| 100 | + @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 101 | + @ExcelProperty("产品信息") | |
| 102 | + private String productNames; | |
| 103 | + | |
| 104 | + @Data | |
| 105 | + public static class Item { | |
| 106 | + | |
| 107 | + @Schema(description = "出库项编号", example = "11756") | |
| 108 | + private Long id; | |
| 109 | + | |
| 110 | + @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") | |
| 111 | + private Long orderItemId; | |
| 112 | + | |
| 113 | + @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 114 | + private Long warehouseId; | |
| 115 | + | |
| 116 | + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 117 | + private Long productId; | |
| 118 | + | |
| 119 | + @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 120 | + private Long productUnitId; | |
| 121 | + | |
| 122 | + @Schema(description = "产品单价", example = "100.00") | |
| 123 | + private BigDecimal productPrice; | |
| 124 | + | |
| 125 | + @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 126 | + @NotNull(message = "产品数量不能为空") | |
| 127 | + private BigDecimal count; | |
| 128 | + | |
| 129 | + @Schema(description = "税率,百分比", example = "99.88") | |
| 130 | + private BigDecimal taxPercent; | |
| 131 | + | |
| 132 | + @Schema(description = "税额,单位:元", example = "100.00") | |
| 133 | + private BigDecimal taxPrice; | |
| 134 | + | |
| 135 | + @Schema(description = "备注", example = "随便") | |
| 136 | + private String remark; | |
| 137 | + | |
| 138 | + // ========== 关联字段 ========== | |
| 139 | + | |
| 140 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") | |
| 141 | + private String productName; | |
| 142 | + @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") | |
| 143 | + private String productBarCode; | |
| 144 | + @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") | |
| 145 | + private String productUnitName; | |
| 146 | + | |
| 147 | + @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 148 | + private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 | |
| 149 | + | |
| 150 | + } | |
| 151 | + | |
| 152 | +} | |
| 0 | 153 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotNull; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.math.BigDecimal; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - ERP 销售出库新增/修改 Request VO") | |
| 12 | +@Data | |
| 13 | +public class ErpSaleOutSaveReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + @Schema(description = "结算账户编号", example = "31189") | |
| 19 | + private Long accountId; | |
| 20 | + | |
| 21 | + @Schema(description = "销售员编号", example = "1888") | |
| 22 | + private Long saleUserId; | |
| 23 | + | |
| 24 | + @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 25 | + @NotNull(message = "出库时间不能为空") | |
| 26 | + private LocalDateTime outTime; | |
| 27 | + | |
| 28 | + @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 29 | + @NotNull(message = "销售订单编号不能为空") | |
| 30 | + private Long orderId; | |
| 31 | + | |
| 32 | + @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") | |
| 33 | + private BigDecimal discountPercent; | |
| 34 | + | |
| 35 | + @Schema(description = "其它金额,单位:元", example = "7127") | |
| 36 | + private BigDecimal otherPrice; | |
| 37 | + | |
| 38 | + @Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 39 | + @NotNull(message = "本次收款不能为空") | |
| 40 | + private BigDecimal payPrice; | |
| 41 | + | |
| 42 | + @Schema(description = "附件地址", example = "https://www.iocoder.cn") | |
| 43 | + private String fileUrl; | |
| 44 | + | |
| 45 | + @Schema(description = "备注", example = "你猜") | |
| 46 | + private String remark; | |
| 47 | + | |
| 48 | + @Schema(description = "出库清单列表") | |
| 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 = "11756") | |
| 58 | + @NotNull(message = "销售订单项编号不能为空") | |
| 59 | + private Long orderItemId; | |
| 60 | + | |
| 61 | + @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 62 | + @NotNull(message = "仓库编号不能为空") | |
| 63 | + private Long warehouseId; | |
| 64 | + | |
| 65 | + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 66 | + @NotNull(message = "产品编号不能为空") | |
| 67 | + private Long productId; | |
| 68 | + | |
| 69 | + @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") | |
| 70 | + @NotNull(message = "产品单位单位不能为空") | |
| 71 | + private Long productUnitId; | |
| 72 | + | |
| 73 | + @Schema(description = "产品单价", example = "100.00") | |
| 74 | + private BigDecimal productPrice; | |
| 75 | + | |
| 76 | + @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 77 | + @NotNull(message = "产品数量不能为空") | |
| 78 | + private BigDecimal count; | |
| 79 | + | |
| 80 | + @Schema(description = "税率,百分比", example = "99.88") | |
| 81 | + private BigDecimal taxPercent; | |
| 82 | + | |
| 83 | + @Schema(description = "备注", example = "随便") | |
| 84 | + private String remark; | |
| 85 | + | |
| 86 | + } | |
| 87 | + | |
| 88 | +} | |
| 0 | 89 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java
| ... | ... | @@ -27,6 +27,7 @@ import java.io.IOException; |
| 27 | 27 | import java.util.List; |
| 28 | 28 | |
| 29 | 29 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 30 | 31 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 31 | 32 | |
| 32 | 33 | @Tag(name = "管理后台 - ERP 仓库") |
| ... | ... | @@ -95,7 +96,8 @@ public class ErpWarehouseController { |
| 95 | 96 | @Operation(summary = "获得仓库精简列表", description = "只包含被开启的仓库,主要用于前端的下拉选项") |
| 96 | 97 | public CommonResult<List<ErpWarehouseRespVO>> getWarehouseSimpleList() { |
| 97 | 98 | List<ErpWarehouseDO> list = warehouseService.getWarehouseListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 98 | - return success(BeanUtils.toBean(list, ErpWarehouseRespVO.class)); | |
| 99 | + return success(convertList(list, warehouse -> new ErpWarehouseRespVO().setId(warehouse.getId()) | |
| 100 | + .setName(warehouse.getName()).setDefaultStatus(warehouse.getDefaultStatus()))); | |
| 99 | 101 | } |
| 100 | 102 | |
| 101 | 103 | @GetMapping("/export-excel") | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.dal.dataobject.sale; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -30,7 +31,7 @@ public class ErpSaleOrderDO extends BaseDO { |
| 30 | 31 | @TableId |
| 31 | 32 | private Long id; |
| 32 | 33 | /** |
| 33 | - * 销售单编号 | |
| 34 | + * 销售订单号 | |
| 34 | 35 | */ |
| 35 | 36 | private String no; |
| 36 | 37 | /** |
| ... | ... | @@ -48,7 +49,7 @@ public class ErpSaleOrderDO extends BaseDO { |
| 48 | 49 | /** |
| 49 | 50 | * 结算账户编号 |
| 50 | 51 | * |
| 51 | - * TODO 芋艿:关联 | |
| 52 | + * 关联 {@link ErpAccountDO#getId()} | |
| 52 | 53 | */ |
| 53 | 54 | private Long accountId; |
| 54 | 55 | /** | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java
| ... | ... | @@ -10,7 +10,7 @@ import lombok.*; |
| 10 | 10 | import java.math.BigDecimal; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * ERP 销售订单明细 DO | |
| 13 | + * ERP 销售订单项 DO | |
| 14 | 14 | * |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| ... | ... | @@ -35,7 +35,6 @@ public class ErpSaleOrderItemDO extends BaseDO { |
| 35 | 35 | * 关联 {@link ErpSaleOrderDO#getId()} |
| 36 | 36 | */ |
| 37 | 37 | private Long orderId; |
| 38 | - | |
| 39 | 38 | /** |
| 40 | 39 | * 产品编号 |
| 41 | 40 | * | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; | |
| 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(value = "erp_sale_out") | |
| 19 | +@KeySequence("erp_sale_out_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 ErpSaleOutDO 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 | + * 关联 {@link ErpCustomerDO#getId()} | |
| 47 | + */ | |
| 48 | + private Long customerId; | |
| 49 | + /** | |
| 50 | + * 结算账户编号 | |
| 51 | + * | |
| 52 | + * 关联 {@link ErpAccountDO#getId()} | |
| 53 | + */ | |
| 54 | + private Long accountId; | |
| 55 | + /** | |
| 56 | + * 销售员编号 | |
| 57 | + * | |
| 58 | + * 关联 AdminUserDO 的 id 字段 | |
| 59 | + */ | |
| 60 | + private Long saleUserId; | |
| 61 | + /** | |
| 62 | + * 出库时间 | |
| 63 | + */ | |
| 64 | + private LocalDateTime outTime; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 销售订单编号 | |
| 68 | + * | |
| 69 | + * 关联 {@link ErpSaleOrderDO#getId()} | |
| 70 | + */ | |
| 71 | + private Long orderId; | |
| 72 | + /** | |
| 73 | + * 销售订单号 | |
| 74 | + * | |
| 75 | + * 冗余 {@link ErpSaleOrderDO#getNo()} | |
| 76 | + */ | |
| 77 | + private Long orderNo; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 合计数量 | |
| 81 | + */ | |
| 82 | + private BigDecimal totalCount; | |
| 83 | + /** | |
| 84 | + * 最终合计价格,单位:元 | |
| 85 | + * | |
| 86 | + * totalPrice = totalProductPrice + totalTaxPrice - discountPrice | |
| 87 | + */ | |
| 88 | + private BigDecimal totalPrice; | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 合计产品价格,单位:元 | |
| 92 | + */ | |
| 93 | + private BigDecimal totalProductPrice; | |
| 94 | + /** | |
| 95 | + * 合计税额,单位:元 | |
| 96 | + */ | |
| 97 | + private BigDecimal totalTaxPrice; | |
| 98 | + /** | |
| 99 | + * 优惠率,百分比 | |
| 100 | + */ | |
| 101 | + private BigDecimal discountPercent; | |
| 102 | + /** | |
| 103 | + * 优惠金额,单位:元 | |
| 104 | + * | |
| 105 | + * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent | |
| 106 | + */ | |
| 107 | + private BigDecimal discountPrice; | |
| 108 | + /** | |
| 109 | + * 其它金额,单位:元 | |
| 110 | + * | |
| 111 | + * 注意:它不算在 {@link #totalPrice} 中 | |
| 112 | + */ | |
| 113 | + private BigDecimal otherPrice; | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * 本次收款,单位:元 | |
| 117 | + * | |
| 118 | + * payPrice = totalPrice + otherPrice - debtPrice | |
| 119 | + */ | |
| 120 | + private BigDecimal payPrice; | |
| 121 | + /** | |
| 122 | + * 本次欠款,单位:元 | |
| 123 | + */ | |
| 124 | + private BigDecimal debtPrice; | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 附件地址 | |
| 128 | + */ | |
| 129 | + private String fileUrl; | |
| 130 | + /** | |
| 131 | + * 备注 | |
| 132 | + */ | |
| 133 | + private String remark; | |
| 134 | + | |
| 135 | +} | |
| 0 | 136 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 5 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; | |
| 7 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 10 | +import lombok.*; | |
| 11 | + | |
| 12 | +import java.math.BigDecimal; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * ERP 销售出库项 DO | |
| 16 | + * | |
| 17 | + * @author 芋道源码 | |
| 18 | + */ | |
| 19 | +@TableName("erp_sale_order_items") | |
| 20 | +@KeySequence("erp_sale_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 21 | +@Data | |
| 22 | +@EqualsAndHashCode(callSuper = true) | |
| 23 | +@ToString(callSuper = true) | |
| 24 | +@Builder | |
| 25 | +@NoArgsConstructor | |
| 26 | +@AllArgsConstructor | |
| 27 | +public class ErpSaleOutItemDO extends BaseDO { | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 编号 | |
| 31 | + */ | |
| 32 | + @TableId | |
| 33 | + private Long id; | |
| 34 | + /** | |
| 35 | + * 销售出库编号 | |
| 36 | + * | |
| 37 | + * 关联 {@link ErpStockOutDO##getId()} | |
| 38 | + */ | |
| 39 | + private Long outId; | |
| 40 | + /** | |
| 41 | + * 销售订单项编号 | |
| 42 | + * | |
| 43 | + * 关联 {@link ErpSaleOrderItemDO#getId()} | |
| 44 | + * 目的:方便更新关联的销售订单项的出库数量 | |
| 45 | + */ | |
| 46 | + private Long orderItemId; | |
| 47 | + /** | |
| 48 | + * 仓库编号 | |
| 49 | + * | |
| 50 | + * 关联 {@link ErpWarehouseDO#getId()} | |
| 51 | + */ | |
| 52 | + private Long warehouseId; | |
| 53 | + /** | |
| 54 | + * 产品编号 | |
| 55 | + * | |
| 56 | + * 关联 {@link ErpProductDO#getId()} | |
| 57 | + */ | |
| 58 | + private Long productId; | |
| 59 | + /** | |
| 60 | + * 产品单位单位 | |
| 61 | + * | |
| 62 | + * 冗余 {@link ErpProductDO#getUnitId()} | |
| 63 | + */ | |
| 64 | + private Long productUnitId; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 产品单位单价,单位:元 | |
| 68 | + */ | |
| 69 | + private BigDecimal productPrice; | |
| 70 | + /** | |
| 71 | + * 数量 | |
| 72 | + */ | |
| 73 | + private BigDecimal count; | |
| 74 | + /** | |
| 75 | + * 总价,单位:元 | |
| 76 | + * | |
| 77 | + * totalPrice = productPrice * count | |
| 78 | + */ | |
| 79 | + private BigDecimal totalPrice; | |
| 80 | + /** | |
| 81 | + * 税率,百分比 | |
| 82 | + */ | |
| 83 | + private BigDecimal taxPercent; | |
| 84 | + /** | |
| 85 | + * 税额,单位:元 | |
| 86 | + * | |
| 87 | + * taxPrice = totalPrice * taxPercent | |
| 88 | + */ | |
| 89 | + private BigDecimal taxPrice; | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * 备注 | |
| 93 | + */ | |
| 94 | + private String remark; | |
| 95 | + | |
| 96 | +} | |
| 0 | 97 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; | |
| 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 ErpSaleOutItemMapper extends BaseMapperX<ErpSaleOutItemDO> { | |
| 17 | + | |
| 18 | + default List<ErpSaleOutItemDO> selectListByOutId(Long orderId) { | |
| 19 | + return selectList(ErpSaleOutItemDO::getOutId, orderId); | |
| 20 | + } | |
| 21 | + | |
| 22 | + default List<ErpSaleOutItemDO> selectListByOutIds(Collection<Long> orderIds) { | |
| 23 | + return selectList(ErpSaleOutItemDO::getOutId, orderIds); | |
| 24 | + } | |
| 25 | + | |
| 26 | + default int deleteByOutId(Long orderId) { | |
| 27 | + return delete(ErpSaleOutItemDO::getOutId, orderId); | |
| 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/sale/ErpSaleOutMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.sale; | |
| 2 | + | |
| 3 | + | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; | |
| 9 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; | |
| 10 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 11 | +import org.apache.ibatis.annotations.Mapper; | |
| 12 | + | |
| 13 | +import java.math.BigDecimal; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * ERP 销售出库 Mapper | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@Mapper | |
| 21 | +public interface ErpSaleOutMapper extends BaseMapperX<ErpSaleOutDO> { | |
| 22 | + | |
| 23 | + default PageResult<ErpSaleOutDO> selectPage(ErpSaleOutPageReqVO reqVO) { | |
| 24 | + MPJLambdaWrapperX<ErpSaleOutDO> query = new MPJLambdaWrapperX<ErpSaleOutDO>() | |
| 25 | + .eqIfPresent(ErpSaleOutDO::getNo, reqVO.getNo()) | |
| 26 | + .eqIfPresent(ErpSaleOutDO::getCustomerId, reqVO.getCustomerId()) | |
| 27 | + .betweenIfPresent(ErpSaleOutDO::getOutTime, reqVO.getOutTime()) | |
| 28 | + .eqIfPresent(ErpSaleOutDO::getStatus, reqVO.getStatus()) | |
| 29 | + .likeIfPresent(ErpSaleOutDO::getRemark, reqVO.getRemark()) | |
| 30 | + .eqIfPresent(ErpSaleOutDO::getCreator, reqVO.getCreator()) | |
| 31 | + .eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId()) | |
| 32 | + .likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo()) | |
| 33 | + .orderByDesc(ErpSaleOutDO::getId); | |
| 34 | + query.gt(Boolean.TRUE.equals(reqVO.getDebtStatus()), ErpSaleOutDO::getDebtPrice, BigDecimal.ZERO); | |
| 35 | + if (reqVO.getWarehouseId() != null && reqVO.getProductId() != null) { | |
| 36 | + query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) | |
| 37 | + .eq(reqVO.getWarehouseId() != null, ErpSaleOutItemDO::getWarehouseId, reqVO.getWarehouseId()) | |
| 38 | + .eq(reqVO.getProductId() != null, ErpSaleOutItemDO::getProductId, reqVO.getProductId()) | |
| 39 | + .groupBy(ErpSaleOutDO::getId); // 避免 1 对多查询,产生相同的 1 | |
| 40 | + } | |
| 41 | + return selectJoinPage(reqVO, ErpSaleOutDO.class, query); | |
| 42 | + } | |
| 43 | + | |
| 44 | + default int updateByIdAndStatus(Long id, Integer status, ErpSaleOutDO updateObj) { | |
| 45 | + return update(updateObj, new LambdaUpdateWrapper<ErpSaleOutDO>() | |
| 46 | + .eq(ErpSaleOutDO::getId, id).eq(ErpSaleOutDO::getStatus, status)); | |
| 47 | + } | |
| 48 | + | |
| 49 | + default ErpSaleOutDO selectByNo(String no) { | |
| 50 | + return selectOne(ErpSaleOutDO::getNo, no); | |
| 51 | + } | |
| 52 | + | |
| 53 | +} | |
| 0 | 54 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java
| ... | ... | @@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.ErpAccountSaveReq |
| 6 | 6 | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 9 | 11 | /** |
| 10 | 12 | * ERP 结算账户 Service 接口 |
| 11 | 13 | * |
| ... | ... | @@ -60,6 +62,14 @@ public interface ErpAccountService { |
| 60 | 62 | ErpAccountDO validateAccount(Long id); |
| 61 | 63 | |
| 62 | 64 | /** |
| 65 | + * 获得指定状态的结算账户列表 | |
| 66 | + * | |
| 67 | + * @param status 状态 | |
| 68 | + * @return 结算账户 | |
| 69 | + */ | |
| 70 | + List<ErpAccountDO> getAccountListByStatus(Integer status); | |
| 71 | + | |
| 72 | + /** | |
| 63 | 73 | * 获得结算账户分页 |
| 64 | 74 | * |
| 65 | 75 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java
| ... | ... | @@ -11,6 +11,8 @@ import jakarta.annotation.Resource; |
| 11 | 11 | import org.springframework.stereotype.Service; |
| 12 | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | 13 | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 14 | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 15 | 17 | import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; |
| 16 | 18 | |
| ... | ... | @@ -92,6 +94,11 @@ public class ErpAccountServiceImpl implements ErpAccountService { |
| 92 | 94 | } |
| 93 | 95 | |
| 94 | 96 | @Override |
| 97 | + public List<ErpAccountDO> getAccountListByStatus(Integer status) { | |
| 98 | + return accountMapper.selectListByStatus(status); | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Override | |
| 95 | 102 | public PageResult<ErpAccountDO> getAccountPage(ErpAccountPageReqVO pageReqVO) { |
| 96 | 103 | return accountMapper.selectPage(pageReqVO); |
| 97 | 104 | } | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java
| ... | ... | @@ -222,16 +222,16 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { |
| 222 | 222 | // ==================== 订单项 ==================== |
| 223 | 223 | |
| 224 | 224 | @Override |
| 225 | - public List<ErpSaleOrderItemDO> getSaleOrderItemListByOrderId(Long moveId) { | |
| 226 | - return saleOrderItemMapper.selectListByOrderId(moveId); | |
| 225 | + public List<ErpSaleOrderItemDO> getSaleOrderItemListByOrderId(Long orderId) { | |
| 226 | + return saleOrderItemMapper.selectListByOrderId(orderId); | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | @Override |
| 230 | - public List<ErpSaleOrderItemDO> getSaleOrderItemListByOrderIds(Collection<Long> moveIds) { | |
| 231 | - if (CollUtil.isEmpty(moveIds)) { | |
| 230 | + public List<ErpSaleOrderItemDO> getSaleOrderItemListByOrderIds(Collection<Long> orderIds) { | |
| 231 | + if (CollUtil.isEmpty(orderIds)) { | |
| 232 | 232 | return Collections.emptyList(); |
| 233 | 233 | } |
| 234 | - return saleOrderItemMapper.selectListByOrderIds(moveIds); | |
| 234 | + return saleOrderItemMapper.selectListByOrderIds(orderIds); | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; | |
| 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 ErpSaleOutService { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 创建销售出库 | |
| 22 | + * | |
| 23 | + * @param createReqVO 创建信息 | |
| 24 | + * @return 编号 | |
| 25 | + */ | |
| 26 | + Long createSaleOut(@Valid ErpSaleOutSaveReqVO createReqVO); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 更新销售出库 | |
| 30 | + * | |
| 31 | + * @param updateReqVO 更新信息 | |
| 32 | + */ | |
| 33 | + void updateSaleOut(@Valid ErpSaleOutSaveReqVO updateReqVO); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 更新销售出库的状态 | |
| 37 | + * | |
| 38 | + * @param id 编号 | |
| 39 | + * @param status 状态 | |
| 40 | + */ | |
| 41 | + void updateSaleOutStatus(Long id, Integer status); | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 删除销售出库 | |
| 45 | + * | |
| 46 | + * @param ids 编号数组 | |
| 47 | + */ | |
| 48 | + void deleteSaleOut(List<Long> ids); | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 获得销售出库 | |
| 52 | + * | |
| 53 | + * @param id 编号 | |
| 54 | + * @return 销售出库 | |
| 55 | + */ | |
| 56 | + ErpSaleOutDO getSaleOut(Long id); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 获得销售出库分页 | |
| 60 | + * | |
| 61 | + * @param pageReqVO 分页查询 | |
| 62 | + * @return 销售出库分页 | |
| 63 | + */ | |
| 64 | + PageResult<ErpSaleOutDO> getSaleOutPage(ErpSaleOutPageReqVO pageReqVO); | |
| 65 | + | |
| 66 | + // ==================== 销售出库项 ==================== | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 获得销售出库项列表 | |
| 70 | + * | |
| 71 | + * @param outId 销售出库编号 | |
| 72 | + * @return 销售出库项列表 | |
| 73 | + */ | |
| 74 | + List<ErpSaleOutItemDO> getSaleOutItemListByOutId(Long outId); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 获得销售出库项 List | |
| 78 | + * | |
| 79 | + * @param outIds 销售出库编号数组 | |
| 80 | + * @return 销售出库项 List | |
| 81 | + */ | |
| 82 | + List<ErpSaleOutItemDO> getSaleOutItemListByOutIds(Collection<Long> outIds); | |
| 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/sale/ErpSaleOutServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.sale; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 10 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; | |
| 11 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; | |
| 12 | +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutItemMapper; | |
| 13 | +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutMapper; | |
| 14 | +import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; | |
| 15 | +import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; | |
| 16 | +import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; | |
| 17 | +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | |
| 18 | +import jakarta.annotation.Resource; | |
| 19 | +import org.springframework.stereotype.Service; | |
| 20 | +import org.springframework.transaction.annotation.Transactional; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | + | |
| 23 | +import java.math.BigDecimal; | |
| 24 | +import java.util.Collection; | |
| 25 | +import java.util.Collections; | |
| 26 | +import java.util.List; | |
| 27 | +import java.util.Map; | |
| 28 | + | |
| 29 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 31 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 32 | + | |
| 33 | +// TODO 芋艿:记录操作日志 | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * ERP 销售订单 Service 实现类 | |
| 37 | + * | |
| 38 | + * @author 芋道源码 | |
| 39 | + */ | |
| 40 | +@Service | |
| 41 | +@Validated | |
| 42 | +public class ErpSaleOutServiceImpl implements ErpSaleOutService { | |
| 43 | + | |
| 44 | + @Resource | |
| 45 | + private ErpSaleOutMapper saleOutMapper; | |
| 46 | + @Resource | |
| 47 | + private ErpSaleOutItemMapper saleOutItemMapper; | |
| 48 | + | |
| 49 | + @Resource | |
| 50 | + private ErpNoRedisDAO noRedisDAO; | |
| 51 | + | |
| 52 | + @Resource | |
| 53 | + private ErpProductService productService; | |
| 54 | + @Resource | |
| 55 | + private ErpCustomerService customerService; | |
| 56 | + @Resource | |
| 57 | + private ErpAccountService accountService; | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + @Transactional(rollbackFor = Exception.class) | |
| 61 | + public Long createSaleOut(ErpSaleOutSaveReqVO createReqVO) { | |
| 62 | + // 1.1 校验订单项的有效性 | |
| 63 | + List<ErpSaleOutItemDO> saleOutItems = validateSaleOutItems(createReqVO.getItems()); | |
| 64 | + // 1.2 校验客户 TODO 芋艿:需要在瞅瞅 | |
| 65 | +// customerService.validateCustomer(createReqVO.getCustomerId()); | |
| 66 | + // 1.3 校验结算账户 | |
| 67 | + accountService.validateAccount(createReqVO.getAccountId()); | |
| 68 | + // 1.4 生成调拨单号,并校验唯一性 | |
| 69 | + String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_ORDER_NO_PREFIX); | |
| 70 | + if (saleOutMapper.selectByNo(no) != null) { | |
| 71 | + throw exception(SALE_ORDER_NO_EXISTS); | |
| 72 | + } | |
| 73 | + | |
| 74 | + // 2.1 插入订单 | |
| 75 | + ErpSaleOutDO saleOut = BeanUtils.toBean(createReqVO, ErpSaleOutDO.class, in -> in | |
| 76 | + .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); | |
| 77 | + calculateTotalPrice(saleOut, saleOutItems); | |
| 78 | + saleOutMapper.insert(saleOut); | |
| 79 | + // 2.2 插入订单项 | |
| 80 | + saleOutItems.forEach(o -> o.setOutId(saleOut.getId())); | |
| 81 | + saleOutItemMapper.insertBatch(saleOutItems); | |
| 82 | + return saleOut.getId(); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + @Transactional(rollbackFor = Exception.class) | |
| 87 | + public void updateSaleOut(ErpSaleOutSaveReqVO updateReqVO) { | |
| 88 | + // 1.1 校验存在 | |
| 89 | + ErpSaleOutDO saleOut = validateSaleOutExists(updateReqVO.getId()); | |
| 90 | + if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { | |
| 91 | + throw exception(SALE_ORDER_UPDATE_FAIL_APPROVE, saleOut.getNo()); | |
| 92 | + } | |
| 93 | + // 1.2 校验客户 TODO 芋艿:需要在瞅瞅 | |
| 94 | +// customerService.validateCustomer(updateReqVO.getCustomerId()); | |
| 95 | + // 1.3 校验结算账户 | |
| 96 | + accountService.validateAccount(updateReqVO.getAccountId()); | |
| 97 | + // 1.4 校验订单项的有效性 | |
| 98 | + List<ErpSaleOutItemDO> saleOutItems = validateSaleOutItems(updateReqVO.getItems()); | |
| 99 | + | |
| 100 | + // 2.1 更新订单 | |
| 101 | + ErpSaleOutDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOutDO.class); | |
| 102 | + calculateTotalPrice(updateObj, saleOutItems); | |
| 103 | + saleOutMapper.updateById(updateObj); | |
| 104 | + // 2.2 更新订单项 | |
| 105 | + updateSaleOutItemList(updateReqVO.getId(), saleOutItems); | |
| 106 | + } | |
| 107 | + | |
| 108 | + private void calculateTotalPrice(ErpSaleOutDO saleOut, List<ErpSaleOutItemDO> saleOutItems) { | |
| 109 | + saleOut.setTotalCount(getSumValue(saleOutItems, ErpSaleOutItemDO::getCount, BigDecimal::add)); | |
| 110 | + saleOut.setTotalProductPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); | |
| 111 | + saleOut.setTotalTaxPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); | |
| 112 | + saleOut.setTotalPrice(saleOut.getTotalProductPrice().add(saleOut.getTotalTaxPrice())); | |
| 113 | + // 计算优惠价格 | |
| 114 | + if (saleOut.getDiscountPercent() == null) { | |
| 115 | + saleOut.setDiscountPercent(BigDecimal.ZERO); | |
| 116 | + } | |
| 117 | + saleOut.setDiscountPrice(MoneyUtils.priceMultiply(saleOut.getTotalPrice(), saleOut.getDiscountPercent())); | |
| 118 | + saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice())); | |
| 119 | + } | |
| 120 | + | |
| 121 | + @Override | |
| 122 | + @Transactional(rollbackFor = Exception.class) | |
| 123 | + public void updateSaleOutStatus(Long id, Integer status) { | |
| 124 | + boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); | |
| 125 | + // 1.1 校验存在 | |
| 126 | + ErpSaleOutDO saleOut = validateSaleOutExists(id); | |
| 127 | + // 1.2 校验状态 | |
| 128 | + if (saleOut.getStatus().equals(status)) { | |
| 129 | + throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); | |
| 130 | + } | |
| 131 | + // TODO @芋艿:需要校验是不是有入库、有退货 | |
| 132 | + | |
| 133 | + // 2. 更新状态 | |
| 134 | + int updateCount = saleOutMapper.updateByIdAndStatus(id, saleOut.getStatus(), | |
| 135 | + new ErpSaleOutDO().setStatus(status)); | |
| 136 | + if (updateCount == 0) { | |
| 137 | + throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + private List<ErpSaleOutItemDO> validateSaleOutItems(List<ErpSaleOutSaveReqVO.Item> list) { | |
| 142 | + // 1. 校验产品存在 | |
| 143 | + List<ErpProductDO> productList = productService.validProductList( | |
| 144 | + convertSet(list, ErpSaleOutSaveReqVO.Item::getProductId)); | |
| 145 | + Map<Long, ErpProductDO> productMap = convertMap(productList, ErpProductDO::getId); | |
| 146 | + // 2. 转化为 ErpSaleOutItemDO 列表 | |
| 147 | + return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOutItemDO.class, item -> { | |
| 148 | + item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); | |
| 149 | + item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); | |
| 150 | + if (item.getTotalPrice() == null) { | |
| 151 | + return; | |
| 152 | + } | |
| 153 | + item.setTaxPrice(MoneyUtils.priceMultiply(item.getTotalPrice(), item.getTaxPercent())); | |
| 154 | + item.setTotalPrice(item.getTotalPrice().add(item.getTaxPrice())); | |
| 155 | + })); | |
| 156 | + } | |
| 157 | + | |
| 158 | + private void updateSaleOutItemList(Long id, List<ErpSaleOutItemDO> newList) { | |
| 159 | + // 第一步,对比新老数据,获得添加、修改、删除的列表 | |
| 160 | + List<ErpSaleOutItemDO> oldList = saleOutItemMapper.selectListByOutId(id); | |
| 161 | + List<List<ErpSaleOutItemDO>> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 | |
| 162 | + (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); | |
| 163 | + | |
| 164 | + // 第二步,批量添加、修改、删除 | |
| 165 | + if (CollUtil.isNotEmpty(diffList.get(0))) { | |
| 166 | + diffList.get(0).forEach(o -> o.setOutId(id)); | |
| 167 | + saleOutItemMapper.insertBatch(diffList.get(0)); | |
| 168 | + } | |
| 169 | + if (CollUtil.isNotEmpty(diffList.get(1))) { | |
| 170 | + saleOutItemMapper.updateBatch(diffList.get(1)); | |
| 171 | + } | |
| 172 | + if (CollUtil.isNotEmpty(diffList.get(2))) { | |
| 173 | + saleOutItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleOutItemDO::getId)); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + @Override | |
| 178 | + @Transactional(rollbackFor = Exception.class) | |
| 179 | + public void deleteSaleOut(List<Long> ids) { | |
| 180 | + // 1. 校验不处于已审批 | |
| 181 | + List<ErpSaleOutDO> saleOuts = saleOutMapper.selectBatchIds(ids); | |
| 182 | + if (CollUtil.isEmpty(saleOuts)) { | |
| 183 | + return; | |
| 184 | + } | |
| 185 | + saleOuts.forEach(saleOut -> { | |
| 186 | + if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { | |
| 187 | + throw exception(SALE_ORDER_DELETE_FAIL_APPROVE, saleOut.getNo()); | |
| 188 | + } | |
| 189 | + }); | |
| 190 | + | |
| 191 | + // 2. 遍历删除,并记录操作日志 | |
| 192 | + saleOuts.forEach(saleOut -> { | |
| 193 | + // 2.1 删除订单 | |
| 194 | + saleOutMapper.deleteById(saleOut.getId()); | |
| 195 | + // 2.2 删除订单项 | |
| 196 | + saleOutItemMapper.deleteByOutId(saleOut.getId()); | |
| 197 | + }); | |
| 198 | + } | |
| 199 | + | |
| 200 | + private ErpSaleOutDO validateSaleOutExists(Long id) { | |
| 201 | + ErpSaleOutDO saleOut = saleOutMapper.selectById(id); | |
| 202 | + if (saleOut == null) { | |
| 203 | + throw exception(SALE_ORDER_NOT_EXISTS); | |
| 204 | + } | |
| 205 | + return saleOut; | |
| 206 | + } | |
| 207 | + | |
| 208 | + @Override | |
| 209 | + public ErpSaleOutDO getSaleOut(Long id) { | |
| 210 | + return saleOutMapper.selectById(id); | |
| 211 | + } | |
| 212 | + | |
| 213 | + @Override | |
| 214 | + public PageResult<ErpSaleOutDO> getSaleOutPage(ErpSaleOutPageReqVO pageReqVO) { | |
| 215 | + return saleOutMapper.selectPage(pageReqVO); | |
| 216 | + } | |
| 217 | + | |
| 218 | + // ==================== 订单项 ==================== | |
| 219 | + | |
| 220 | + @Override | |
| 221 | + public List<ErpSaleOutItemDO> getSaleOutItemListByOutId(Long outId) { | |
| 222 | + return saleOutItemMapper.selectListByOutId(outId); | |
| 223 | + } | |
| 224 | + | |
| 225 | + @Override | |
| 226 | + public List<ErpSaleOutItemDO> getSaleOutItemListByOutIds(Collection<Long> outIds) { | |
| 227 | + if (CollUtil.isEmpty(outIds)) { | |
| 228 | + return Collections.emptyList(); | |
| 229 | + } | |
| 230 | + return saleOutItemMapper.selectListByOutIds(outIds); | |
| 231 | + } | |
| 232 | + | |
| 233 | +} | |
| 0 | 234 | \ No newline at end of file | ... | ... |