Commit 6e005f46d97596b7a59e757a5ea5d1f1ab303eab
1 parent
ebd92227
✨ ERP:【销售订单】初始化
Showing
12 changed files
with
721 additions
and
6 deletions
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.enums; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * ERP 错误码枚举类 |
| 5 | 7 | * <p> |
| ... | ... | @@ -7,5 +9,7 @@ package cn.iocoder.yudao.module.erp.enums; |
| 7 | 9 | */ |
| 8 | 10 | public interface ErrorCodeConstants { |
| 9 | 11 | |
| 12 | + // ========== 销售订单(1-030-000-000) ========== | |
| 13 | + ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_030_000_000, "销售订单不存在"); | |
| 10 | 14 | |
| 11 | 15 | } | ... | ... |
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/sale/ErpSaleOrderStatusEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.enums.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * ERP 销售订单的状态枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@AllArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum ErpSaleOrderStatusEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + AUDIT_NONE(0, "未审核"), | |
| 19 | + AUDIT_PASS(10, "已审核"), | |
| 20 | + SALE_PART(20, "部分销售"), | |
| 21 | + SALE_ALL(21, "完成销售"), | |
| 22 | + ; | |
| 23 | + | |
| 24 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpSaleOrderStatusEnum::getStatus).toArray(); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 状态 | |
| 28 | + */ | |
| 29 | + private final Integer status; | |
| 30 | + /** | |
| 31 | + * 状态名 | |
| 32 | + */ | |
| 33 | + private final String name; | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public int[] array() { | |
| 37 | + return ARRAYS; | |
| 38 | + } | |
| 39 | + | |
| 40 | +} | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.controller.admin.sale; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 8 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 9 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderRespVO; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; | |
| 13 | +import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 4 | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | |
| 19 | +import jakarta.validation.Valid; | |
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 5 | 21 | import org.springframework.validation.annotation.Validated; |
| 6 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 7 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | -import org.springframework.web.bind.annotation.RestController; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | + | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 9 | 26 | |
| 10 | 27 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 29 | + | |
| 11 | 30 | |
| 12 | 31 | @Tag(name = "管理后台 - ERP 销售订单") |
| 13 | 32 | @RestController |
| ... | ... | @@ -15,9 +34,67 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 15 | 34 | @Validated |
| 16 | 35 | public class ErpSaleOrderController { |
| 17 | 36 | |
| 18 | - @GetMapping("/demo") | |
| 19 | - public CommonResult<Boolean> demo() { | |
| 37 | + @Resource | |
| 38 | + private ErpSaleOrderService saleOrderService; | |
| 39 | + | |
| 40 | + // TODO 芋艿:待 review | |
| 41 | + @PostMapping("/create") | |
| 42 | + @Operation(summary = "创建ERP 销售订单") | |
| 43 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:create')") | |
| 44 | + public CommonResult<Long> createSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO createReqVO) { | |
| 45 | + return success(saleOrderService.createSaleOrder(createReqVO)); | |
| 46 | + } | |
| 47 | + | |
| 48 | + // TODO 芋艿:待 review | |
| 49 | + @PutMapping("/update") | |
| 50 | + @Operation(summary = "更新ERP 销售订单") | |
| 51 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:update')") | |
| 52 | + public CommonResult<Boolean> updateSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO updateReqVO) { | |
| 53 | + saleOrderService.updateSaleOrder(updateReqVO); | |
| 54 | + return success(true); | |
| 55 | + } | |
| 56 | + | |
| 57 | + // TODO 芋艿:待 review | |
| 58 | + @DeleteMapping("/delete") | |
| 59 | + @Operation(summary = "删除ERP 销售订单") | |
| 60 | + @Parameter(name = "id", description = "编号", required = true) | |
| 61 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:delete')") | |
| 62 | + public CommonResult<Boolean> deleteSaleOrder(@RequestParam("id") Long id) { | |
| 63 | + saleOrderService.deleteSaleOrder(id); | |
| 20 | 64 | return success(true); |
| 21 | 65 | } |
| 22 | 66 | |
| 23 | -} | |
| 67 | + // TODO 芋艿:待 review | |
| 68 | + @GetMapping("/get") | |
| 69 | + @Operation(summary = "获得ERP 销售订单") | |
| 70 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 71 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:query')") | |
| 72 | + public CommonResult<ErpSaleOrderRespVO> getSaleOrder(@RequestParam("id") Long id) { | |
| 73 | + ErpSaleOrderDO saleOrder = saleOrderService.getSaleOrder(id); | |
| 74 | + return success(BeanUtils.toBean(saleOrder, ErpSaleOrderRespVO.class)); | |
| 75 | + } | |
| 76 | + | |
| 77 | + // TODO 芋艿:待 review | |
| 78 | + @GetMapping("/page") | |
| 79 | + @Operation(summary = "获得ERP 销售订单分页") | |
| 80 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:query')") | |
| 81 | + public CommonResult<PageResult<ErpSaleOrderRespVO>> getSaleOrderPage(@Valid ErpSaleOrderPageReqVO pageReqVO) { | |
| 82 | + PageResult<ErpSaleOrderDO> pageResult = saleOrderService.getSaleOrderPage(pageReqVO); | |
| 83 | + return success(BeanUtils.toBean(pageResult, ErpSaleOrderRespVO.class)); | |
| 84 | + } | |
| 85 | + | |
| 86 | + // TODO 芋艿:待 review | |
| 87 | + @GetMapping("/export-excel") | |
| 88 | + @Operation(summary = "导出ERP 销售订单 Excel") | |
| 89 | + @PreAuthorize("@ss.hasPermission('erp:sale-order:export')") | |
| 90 | + @OperateLog(type = EXPORT) | |
| 91 | + public void exportSaleOrderExcel(@Valid ErpSaleOrderPageReqVO pageReqVO, | |
| 92 | + HttpServletResponse response) throws IOException { | |
| 93 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 94 | + List<ErpSaleOrderDO> list = saleOrderService.getSaleOrderPage(pageReqVO).getList(); | |
| 95 | + // 导出 Excel | |
| 96 | + ExcelUtils.write(response, "ERP 销售订单.xls", "数据", ErpSaleOrderRespVO.class, | |
| 97 | + BeanUtils.toBean(list, ErpSaleOrderRespVO.class)); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | |
| 24 | 101 | \ 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/ErpSaleOrderPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; | |
| 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 ErpSaleOrderPageReqVO 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[] orderTime; | |
| 29 | + | |
| 30 | + @Schema(description = "备注", example = "你猜") | |
| 31 | + private String description; | |
| 32 | + | |
| 33 | + @Schema(description = "销售状态", example = "2") | |
| 34 | + private Integer status; | |
| 35 | + | |
| 36 | + @Schema(description = "创建者") | |
| 37 | + private String creator; | |
| 38 | + | |
| 39 | +} | |
| 0 | 40 | \ 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
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; | |
| 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 lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +// TODO 芋艿:导出最后搞 | |
| 12 | +@Schema(description = "管理后台 - ERP 销售订单 Response VO") | |
| 13 | +@Data | |
| 14 | +@ExcelIgnoreUnannotated | |
| 15 | +public class ErpSaleOrderRespVO { | |
| 16 | + | |
| 17 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 18 | + @ExcelProperty("编号") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "销售单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") | |
| 22 | + @ExcelProperty("销售单编号") | |
| 23 | + private String no; | |
| 24 | + | |
| 25 | + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") | |
| 26 | + @ExcelProperty("客户编号") | |
| 27 | + private Long customerId; | |
| 28 | + | |
| 29 | + @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 30 | + @ExcelProperty("下单时间") | |
| 31 | + private LocalDateTime orderTime; | |
| 32 | + | |
| 33 | + // TODO 芋艿:example 后面 | |
| 34 | + @Schema(description = "销售员编号数组") | |
| 35 | + @ExcelProperty("销售员编号数组") | |
| 36 | + private String salePersonIds; | |
| 37 | + | |
| 38 | + @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "26094") | |
| 39 | + @ExcelProperty("合计价格,单位:元") | |
| 40 | + private BigDecimal totalPrice; | |
| 41 | + | |
| 42 | + @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") | |
| 43 | + @ExcelProperty("优惠率,百分比") | |
| 44 | + private BigDecimal discountPercent; | |
| 45 | + | |
| 46 | + @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "44.52") | |
| 47 | + @ExcelProperty("优惠金额,单位:元") | |
| 48 | + private BigDecimal discountPrice; | |
| 49 | + | |
| 50 | + @Schema(description = "支付金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "322.40") | |
| 51 | + @ExcelProperty("支付金额,单位:元") | |
| 52 | + private BigDecimal payPrice; | |
| 53 | + | |
| 54 | + @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "71.27") | |
| 55 | + @ExcelProperty("定金金额,单位:元") | |
| 56 | + private BigDecimal depositPrice; | |
| 57 | + | |
| 58 | + @Schema(description = "附件地址", example = "https://www.iocoder.cn") | |
| 59 | + @ExcelProperty("附件地址") | |
| 60 | + private String fileUrl; | |
| 61 | + | |
| 62 | + @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") | |
| 63 | + @ExcelProperty("结算账户编号") | |
| 64 | + private Long accountId; | |
| 65 | + | |
| 66 | + @Schema(description = "备注", example = "你猜") | |
| 67 | + @ExcelProperty("备注") | |
| 68 | + private String description; | |
| 69 | + | |
| 70 | + @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 71 | + @ExcelProperty("销售状态") | |
| 72 | + private Integer status; | |
| 73 | + | |
| 74 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 75 | + @ExcelProperty("创建时间") | |
| 76 | + private LocalDateTime createTime; | |
| 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/sale/vo/order/ErpSaleOrderSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSalesOrderItemDO; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 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 ErpSaleOrderSaveReqVO { | |
| 16 | + | |
| 17 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "销售单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") | |
| 21 | + @NotEmpty(message = "销售单编号不能为空") | |
| 22 | + private String no; | |
| 23 | + | |
| 24 | + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") | |
| 25 | + @NotNull(message = "客户编号不能为空") | |
| 26 | + private Long customerId; | |
| 27 | + | |
| 28 | + @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 29 | + @NotNull(message = "下单时间不能为空") | |
| 30 | + private LocalDateTime orderTime; | |
| 31 | + | |
| 32 | + @Schema(description = "销售员编号数组") | |
| 33 | + private String salePersonIds; | |
| 34 | + | |
| 35 | + @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "26094") | |
| 36 | + @NotNull(message = "合计价格,单位:元不能为空") | |
| 37 | + private BigDecimal totalPrice; | |
| 38 | + | |
| 39 | + @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") | |
| 40 | + @NotNull(message = "优惠率,百分比不能为空") | |
| 41 | + private BigDecimal discountPercent; | |
| 42 | + | |
| 43 | + @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "4452") | |
| 44 | + @NotNull(message = "优惠金额,单位:元不能为空") | |
| 45 | + private BigDecimal discountPrice; | |
| 46 | + | |
| 47 | + // TODO 芋艿:后面删除 | |
| 48 | +// @Schema(description = "支付金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "32240") | |
| 49 | +// @NotNull(message = "支付金额,单位:元不能为空") | |
| 50 | +// private BigDecimal payPrice; | |
| 51 | + | |
| 52 | + @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") | |
| 53 | + @NotNull(message = "定金金额,单位:元不能为空") | |
| 54 | + private BigDecimal depositPrice; | |
| 55 | + | |
| 56 | + @Schema(description = "附件地址", example = "https://www.iocoder.cn") | |
| 57 | + private String fileUrl; | |
| 58 | + | |
| 59 | + @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31189") | |
| 60 | + @NotNull(message = "结算账户编号不能为空") | |
| 61 | + private Long accountId; | |
| 62 | + | |
| 63 | + @Schema(description = "备注", example = "你猜") | |
| 64 | + private String description; | |
| 65 | + | |
| 66 | + // TODO 芋艿:后面删除 | |
| 67 | +// @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 68 | +// @NotNull(message = "销售状态不能为空") | |
| 69 | +// private Integer status; | |
| 70 | + | |
| 71 | + @Schema(description = "ERP 销售订单明细列表") | |
| 72 | + private List<ErpSalesOrderItemDO> salesOrderItems; | |
| 73 | + | |
| 74 | +} | |
| 0 | 75 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.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.framework.mybatis.core.type.LongListTypeHandler; | |
| 5 | +import cn.iocoder.yudao.module.erp.enums.sale.ErpSaleOrderStatusEnum; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 10 | +import lombok.*; | |
| 11 | + | |
| 12 | +import java.math.BigDecimal; | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * ERP 销售订单 DO | |
| 18 | + * | |
| 19 | + * @author 芋道源码 | |
| 20 | + */ | |
| 21 | +@TableName(value = "erp_sale_order", autoResultMap = true) | |
| 22 | +@KeySequence("erp_sale_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 23 | +@Data | |
| 24 | +@EqualsAndHashCode(callSuper = true) | |
| 25 | +@ToString(callSuper = true) | |
| 26 | +@Builder | |
| 27 | +@NoArgsConstructor | |
| 28 | +@AllArgsConstructor | |
| 29 | +public class ErpSaleOrderDO extends BaseDO { | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 编号 | |
| 33 | + */ | |
| 34 | + @TableId | |
| 35 | + private Long id; | |
| 36 | + /** | |
| 37 | + * 销售单编号 | |
| 38 | + */ | |
| 39 | + private String no; | |
| 40 | + /** | |
| 41 | + * 销售状态 | |
| 42 | + * | |
| 43 | + * 枚举 {@link ErpSaleOrderStatusEnum} | |
| 44 | + */ | |
| 45 | + private Integer status; | |
| 46 | + /** | |
| 47 | + * 客户编号 | |
| 48 | + * | |
| 49 | + * TODO 芋艿:关联 | |
| 50 | + */ | |
| 51 | + private Long customerId; | |
| 52 | + /** | |
| 53 | + * 结算账户编号 | |
| 54 | + * | |
| 55 | + * TODO 芋艿:关联 | |
| 56 | + */ | |
| 57 | + private Long accountId; | |
| 58 | + /** | |
| 59 | + * 销售员编号数组 | |
| 60 | + * | |
| 61 | + * TODO 芋艿:关联 | |
| 62 | + */ | |
| 63 | + @TableField(typeHandler = LongListTypeHandler.class) | |
| 64 | + private List<Long> salePersonIds; | |
| 65 | + /** | |
| 66 | + * 下单时间 | |
| 67 | + */ | |
| 68 | + private LocalDateTime orderTime; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 合计价格,单位:元 | |
| 72 | + */ | |
| 73 | + private BigDecimal totalPrice; | |
| 74 | + /** | |
| 75 | + * 优惠率,百分比 | |
| 76 | + */ | |
| 77 | + private BigDecimal discountPercent; | |
| 78 | + /** | |
| 79 | + * 优惠金额,单位:元 | |
| 80 | + */ | |
| 81 | + private BigDecimal discountPrice; | |
| 82 | + /** | |
| 83 | + * 支付金额,单位:元 | |
| 84 | + */ | |
| 85 | + private BigDecimal payPrice; | |
| 86 | + /** | |
| 87 | + * 定金金额,单位:元 | |
| 88 | + */ | |
| 89 | + private BigDecimal depositPrice; | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * 附件地址 | |
| 93 | + */ | |
| 94 | + private String fileUrl; | |
| 95 | + /** | |
| 96 | + * 备注 | |
| 97 | + */ | |
| 98 | + private String description; | |
| 99 | + | |
| 100 | +} | |
| 0 | 101 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSalesOrderItemDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.sale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +import java.math.BigDecimal; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * ERP 销售订单明细 DO | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@TableName("erp_sales_order_items") | |
| 17 | +@KeySequence("erp_sales_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +@Builder | |
| 22 | +@NoArgsConstructor | |
| 23 | +@AllArgsConstructor | |
| 24 | +public class ErpSalesOrderItemDO extends BaseDO { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 编号 | |
| 28 | + */ | |
| 29 | + @TableId | |
| 30 | + private Long id; | |
| 31 | + /** | |
| 32 | + * 销售订单编号 | |
| 33 | + * | |
| 34 | + * 关联 {@link ErpSaleOrderDO#getId()} | |
| 35 | + */ | |
| 36 | + private Long orderId; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 商品 SPU 编号 | |
| 40 | + * | |
| 41 | + * TODO 芋艿 关联 | |
| 42 | + */ | |
| 43 | + private Long productSpuId; | |
| 44 | + /** | |
| 45 | + * 商品 SKU 编号 | |
| 46 | + * | |
| 47 | + * TODO 芋艿 关联 | |
| 48 | + */ | |
| 49 | + private Long productSkuId; | |
| 50 | + /** | |
| 51 | + * 商品单位 | |
| 52 | + * | |
| 53 | + * TODO 芋艿 冗余 | |
| 54 | + */ | |
| 55 | + private String productUnit; | |
| 56 | + /** | |
| 57 | + * 商品单价 | |
| 58 | + * | |
| 59 | + * TODO 芋艿 冗余 | |
| 60 | + */ | |
| 61 | + private BigDecimal productPrice; | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 数量 | |
| 65 | + */ | |
| 66 | + private Integer count; | |
| 67 | + /** | |
| 68 | + * 总价 | |
| 69 | + */ | |
| 70 | + private BigDecimal totalPrice; | |
| 71 | + /** | |
| 72 | + * 备注 | |
| 73 | + */ | |
| 74 | + private String description; | |
| 75 | + /** | |
| 76 | + * 税率,百分比 | |
| 77 | + */ | |
| 78 | + private BigDecimal taxPercent; | |
| 79 | + /** | |
| 80 | + * 税额,单位:元 | |
| 81 | + */ | |
| 82 | + private BigDecimal taxPrice; | |
| 83 | + /** | |
| 84 | + * 支付金额,单位:元 | |
| 85 | + */ | |
| 86 | + private BigDecimal payPrice; | |
| 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/dal/mysql/sale/ErpSaleOrderMapper.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.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * ERP 销售订单 Mapper | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> { | |
| 18 | + | |
| 19 | + default PageResult<ErpSaleOrderDO> selectPage(ErpSaleOrderPageReqVO reqVO) { | |
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<ErpSaleOrderDO>() | |
| 21 | + .likeIfPresent(ErpSaleOrderDO::getNo, reqVO.getNo()) | |
| 22 | + .eqIfPresent(ErpSaleOrderDO::getCustomerId, reqVO.getCustomerId()) | |
| 23 | + .betweenIfPresent(ErpSaleOrderDO::getOrderTime, reqVO.getOrderTime()) | |
| 24 | + .eqIfPresent(ErpSaleOrderDO::getDescription, reqVO.getDescription()) | |
| 25 | + .eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus()) | |
| 26 | + .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) | |
| 27 | + .orderByDesc(ErpSaleOrderDO::getId)); | |
| 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/ErpSalesOrderItemMapper.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.ErpSalesOrderItemDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * ERP 销售订单明细 Mapper | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Mapper | |
| 15 | +public interface ErpSalesOrderItemMapper extends BaseMapperX<ErpSalesOrderItemDO> { | |
| 16 | + | |
| 17 | + default List<ErpSalesOrderItemDO> selectListById(Long id) { | |
| 18 | + return selectList(ErpSalesOrderItemDO::getId, id); | |
| 19 | + } | |
| 20 | + | |
| 21 | + default int deleteById(Long id) { | |
| 22 | + return delete(ErpSalesOrderItemDO::getId, id); | |
| 23 | + } | |
| 24 | + | |
| 25 | +} | |
| 0 | 26 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.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.order.ErpSaleOrderPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * ERP 销售订单 Service 接口 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +public interface ErpSaleOrderService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建ERP 销售订单 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createSaleOrder(@Valid ErpSaleOrderSaveReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新ERP 销售订单 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateSaleOrder(@Valid ErpSaleOrderSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除ERP 销售订单 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteSaleOrder(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得ERP 销售订单 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return ERP 销售订单 | |
| 43 | + */ | |
| 44 | + ErpSaleOrderDO getSaleOrder(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得ERP 销售订单分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页查询 | |
| 50 | + * @return ERP 销售订单分页 | |
| 51 | + */ | |
| 52 | + PageResult<ErpSaleOrderDO> getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO); | |
| 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/service/sale/ErpSaleOrderServiceImpl.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.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; | |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSalesOrderItemDO; | |
| 9 | +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderMapper; | |
| 10 | +import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSalesOrderItemMapper; | |
| 11 | +import jakarta.annotation.Resource; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.transaction.annotation.Transactional; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | + | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 19 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * ERP 销售订单 Service 实现类 | |
| 23 | + * | |
| 24 | + * @author 芋道源码 | |
| 25 | + */ | |
| 26 | +@Service | |
| 27 | +@Validated | |
| 28 | +public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private ErpSaleOrderMapper saleOrderMapper; | |
| 32 | + @Resource | |
| 33 | + private ErpSalesOrderItemMapper salesOrderItemMapper; | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + @Transactional(rollbackFor = Exception.class) | |
| 37 | + public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) { | |
| 38 | + // 插入 | |
| 39 | + ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class); | |
| 40 | + saleOrderMapper.insert(saleOrder); | |
| 41 | + | |
| 42 | + // 插入子表 | |
| 43 | + createSalesOrderItemsList(saleOrder.getId(), createReqVO.getSalesOrderItems()); | |
| 44 | + // 返回 | |
| 45 | + return saleOrder.getId(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + @Transactional(rollbackFor = Exception.class) | |
| 50 | + public void updateSaleOrder(ErpSaleOrderSaveReqVO updateReqVO) { | |
| 51 | + // 校验存在 | |
| 52 | + validateSaleOrderExists(updateReqVO.getId()); | |
| 53 | + // 更新 | |
| 54 | + ErpSaleOrderDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOrderDO.class); | |
| 55 | + saleOrderMapper.updateById(updateObj); | |
| 56 | + | |
| 57 | + // 更新子表 | |
| 58 | + updateSalesOrderItemsList(updateReqVO.getId(), updateReqVO.getSalesOrderItems()); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @Override | |
| 62 | + @Transactional(rollbackFor = Exception.class) | |
| 63 | + public void deleteSaleOrder(Long id) { | |
| 64 | + // 校验存在 | |
| 65 | + validateSaleOrderExists(id); | |
| 66 | + // 删除 | |
| 67 | + saleOrderMapper.deleteById(id); | |
| 68 | + | |
| 69 | + // 删除子表 | |
| 70 | + deleteSalesOrderItemsById(id); | |
| 71 | + } | |
| 72 | + | |
| 73 | + private void validateSaleOrderExists(Long id) { | |
| 74 | + if (saleOrderMapper.selectById(id) == null) { | |
| 75 | + throw exception(SALE_ORDER_NOT_EXISTS); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Override | |
| 80 | + public ErpSaleOrderDO getSaleOrder(Long id) { | |
| 81 | + return saleOrderMapper.selectById(id); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + public PageResult<ErpSaleOrderDO> getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO) { | |
| 86 | + return saleOrderMapper.selectPage(pageReqVO); | |
| 87 | + } | |
| 88 | + | |
| 89 | + // ==================== 子表(ERP 销售订单明细) ==================== | |
| 90 | + | |
| 91 | + private void createSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) { | |
| 92 | + list.forEach(o -> o.setId(id)); | |
| 93 | + salesOrderItemMapper.insertBatch(list); | |
| 94 | + } | |
| 95 | + | |
| 96 | + private void updateSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) { | |
| 97 | + deleteSalesOrderItemsById(id); | |
| 98 | + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 | |
| 99 | + createSalesOrderItemsList(id, list); | |
| 100 | + } | |
| 101 | + | |
| 102 | + private void deleteSalesOrderItemsById(Long id) { | |
| 103 | + salesOrderItemMapper.deleteById(id); | |
| 104 | + } | |
| 105 | + | |
| 106 | +} | |
| 0 | 107 | \ No newline at end of file | ... | ... |