Commit 3f4e305f by 杨浩

销售订单退款

parent b3ea9f0a
...@@ -159,6 +159,9 @@ public class ErpPurchaseOrderRespVO { ...@@ -159,6 +159,9 @@ public class ErpPurchaseOrderRespVO {
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private Integer count;
@Schema(description = "总价,单位:分")
private Integer totalPrice;
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
...@@ -196,6 +199,15 @@ public class ErpPurchaseOrderRespVO { ...@@ -196,6 +199,15 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "签收总价,单位:分") @Schema(description = "签收总价,单位:分")
private Integer signedTotal; private Integer signedTotal;
@Schema(description = "质检结果(详情接口返回)")
private String checkResult;
@Schema(description = "退货数量")
private Integer returnsCount;
@Schema(description = "退货金额")
private Integer returnsTotal;
} }
} }
...@@ -72,7 +72,7 @@ public class ErpPurchaseReturnRespVO { ...@@ -72,7 +72,7 @@ public class ErpPurchaseReturnRespVO {
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private List<String> filesUrl;
@Schema(description = "备注", example = "你猜") @Schema(description = "备注", example = "你猜")
@ExcelProperty("备注") @ExcelProperty("备注")
...@@ -110,7 +110,7 @@ public class ErpPurchaseReturnRespVO { ...@@ -110,7 +110,7 @@ public class ErpPurchaseReturnRespVO {
private Long productId; private Long productId;
@Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
private Long productUnitId; private String productUnit;
@Schema(description = "产品单价", example = "100.00") @Schema(description = "产品单价", example = "100.00")
private BigDecimal productPrice; private BigDecimal productPrice;
......
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.returns; package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.returns;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
...@@ -26,18 +32,41 @@ public class ErpPurchaseReturnSaveReqVO { ...@@ -26,18 +32,41 @@ public class ErpPurchaseReturnSaveReqVO {
@NotNull(message = "采购订单编号不能为空") @NotNull(message = "采购订单编号不能为空")
private Long orderId; private Long orderId;
@Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88")
private BigDecimal discountPercent;
@Schema(description = "其它金额,单位:分", example = "7127")
private BigDecimal otherPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn") @Schema(description = "附件地址", example = "https://www.iocoder.cn")
private String fileUrl; private List<String> filesUrl;
@Schema(description = "备注", example = "你猜") @Schema(description = "备注", example = "你猜")
private String remark; private String remark;
@Schema(description = "供应商id")
private Long supplierId;
/**
* 枚举 {@link SaleOrderPickUpStatus}
*/
@Schema(description = "退货状态")
private String returnsStatus;
@Schema(description = "客户收货地址id")
private Long addressId;
@Schema(description = "客户收货地址info")
private CustomerAddressInfo addressInfo;
@Schema(description = "收获仓库id")
private Long warehouseId;
@Schema(description = "收获库区id")
private Long warehouseAreaId;
@Schema(description = "仓库信息")
private WarehouseInfo warehouseInfo;
/**
* DeliveryStaffDO
*/
private Long deliveryStaffId;
@Schema(description = "退货清单列表") @Schema(description = "退货清单列表")
private List<Item> items; private List<Item> items;
...@@ -61,21 +90,21 @@ public class ErpPurchaseReturnSaveReqVO { ...@@ -61,21 +90,21 @@ public class ErpPurchaseReturnSaveReqVO {
@Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
@NotNull(message = "产品单位单位不能为空") @NotNull(message = "产品单位单位不能为空")
private Long productUnitId; private String productUnit;
@Schema(description = "产品单价", example = "100.00") @Schema(description = "产品单价", example = "100.00")
private BigDecimal productPrice; private Integer productPrice;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private BigDecimal count; private Integer count;
@Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;
@Schema(description = "商品信息")
private ProductInfo productInfo;
} }
} }
\ No newline at end of file
...@@ -20,6 +20,7 @@ import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService; ...@@ -20,6 +20,7 @@ import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpCustomerService; import cn.iocoder.foodnexus.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleReturnService; import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleReturnService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockService; import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockService;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi; import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import cn.iocoder.foodnexus.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.foodnexus.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -36,6 +37,7 @@ import java.io.IOException; ...@@ -36,6 +37,7 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success; import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
...@@ -53,8 +55,6 @@ public class ErpSaleReturnController { ...@@ -53,8 +55,6 @@ public class ErpSaleReturnController {
@Resource @Resource
private ErpStockService stockService; private ErpStockService stockService;
@Resource @Resource
private ErpProductService productService;
@Resource
private ErpCustomerService customerService; private ErpCustomerService customerService;
@Resource @Resource
...@@ -76,7 +76,7 @@ public class ErpSaleReturnController { ...@@ -76,7 +76,7 @@ public class ErpSaleReturnController {
} }
@PutMapping("/update-status") @PutMapping("/update-status")
@Operation(summary = "更新销售退货的状态") @Operation(summary = "更新销售退货的状态(确认退货)")
@PreAuthorize("@ss.hasPermission('erp:sale-return:update-status')") @PreAuthorize("@ss.hasPermission('erp:sale-return:update-status')")
public CommonResult<Boolean> updateSaleReturnStatus(@RequestParam("id") Long id, public CommonResult<Boolean> updateSaleReturnStatus(@RequestParam("id") Long id,
@RequestParam("status") Integer status) { @RequestParam("status") Integer status) {
...@@ -103,14 +103,10 @@ public class ErpSaleReturnController { ...@@ -103,14 +103,10 @@ public class ErpSaleReturnController {
return success(null); return success(null);
} }
List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnId(id); List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnId(id);
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId));
return success(BeanUtils.toBean(saleReturn, ErpSaleReturnRespVO.class, saleReturnVO -> return success(BeanUtils.toBean(saleReturn, ErpSaleReturnRespVO.class, saleReturnVO ->
saleReturnVO.setItems(BeanUtils.toBean(saleReturnItemList, ErpSaleReturnRespVO.Item.class, item -> { saleReturnVO.setItems(BeanUtils.toBean(saleReturnItemList, ErpSaleReturnRespVO.Item.class, item -> {
ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId());
item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO);
MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()));
})))); }))));
} }
...@@ -142,9 +138,6 @@ public class ErpSaleReturnController { ...@@ -142,9 +138,6 @@ public class ErpSaleReturnController {
List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnIds( List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnIds(
convertSet(pageResult.getList(), ErpSaleReturnDO::getId)); convertSet(pageResult.getList(), ErpSaleReturnDO::getId));
Map<Long, List<ErpSaleReturnItemDO>> saleReturnItemMap = convertMultiMap(saleReturnItemList, ErpSaleReturnItemDO::getReturnId); Map<Long, List<ErpSaleReturnItemDO>> saleReturnItemMap = convertMultiMap(saleReturnItemList, ErpSaleReturnItemDO::getReturnId);
// 1.2 产品信息
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId));
// 1.3 客户信息 // 1.3 客户信息
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap( Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId)); convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId));
...@@ -153,10 +146,9 @@ public class ErpSaleReturnController { ...@@ -153,10 +146,9 @@ public class ErpSaleReturnController {
convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator()))); convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator())));
// 2. 开始拼接 // 2. 开始拼接
return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> { return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> {
saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class, saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class));
item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", item ->
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); Optional.ofNullable(item.getProductInfo()).map(ProductInfo::getName).orElse("")));
saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", ErpSaleReturnRespVO.Item::getProductName));
MapUtils.findAndThen(customerMap, saleReturn.getCustomerId(), supplier -> saleReturn.setCustomerName(supplier.getName())); MapUtils.findAndThen(customerMap, saleReturn.getCustomerId(), supplier -> saleReturn.setCustomerName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(saleReturn.getCreator()), user -> saleReturn.setCreatorName(user.getNickname())); MapUtils.findAndThen(userMap, Long.parseLong(saleReturn.getCreator()), user -> saleReturn.setCreatorName(user.getNickname()));
}); });
......
...@@ -12,8 +12,8 @@ import lombok.Data; ...@@ -12,8 +12,8 @@ import lombok.Data;
@Data @Data
public class DeliveryStatusCountRespVO { public class DeliveryStatusCountRespVO {
@Schema(description = "拣货状态") @Schema(description = "0-待接单 1-待配送 2-配送中")
private SaleOrderPickUpStatus pickUpStatus; private Integer type;
@Schema(description = "对应订单数") @Schema(description = "对应订单数")
private Long count; private Long count;
......
...@@ -91,6 +91,9 @@ public class ErpSaleOrderPageReqVO extends PageParam { ...@@ -91,6 +91,9 @@ public class ErpSaleOrderPageReqVO extends PageParam {
@Schema(description = "拣货状态") @Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "拣货状态list")
private List<String> pickUpStatusList;
@Schema(description = "接单时间段") @Schema(description = "接单时间段")
private LocalDateTime[] acceptTime; private LocalDateTime[] acceptTime;
......
...@@ -5,7 +5,9 @@ import cn.idev.excel.annotation.ExcelProperty; ...@@ -5,7 +5,9 @@ import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo; import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus; import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo; import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.dto.DeliveryStaffSimpleInfo;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode; import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
...@@ -109,6 +111,9 @@ public class ErpSaleOrderRespVO { ...@@ -109,6 +111,9 @@ public class ErpSaleOrderRespVO {
@Schema(description = "客户订单id") @Schema(description = "客户订单id")
private Long customerOrderId; private Long customerOrderId;
@Schema(description = "客户订单编号")
private String customerOrderCode;
@Schema(description = "配送模式") @Schema(description = "配送模式")
private DeliveryMode deliveryMode; private DeliveryMode deliveryMode;
...@@ -127,6 +132,12 @@ public class ErpSaleOrderRespVO { ...@@ -127,6 +132,12 @@ public class ErpSaleOrderRespVO {
@Schema(description = "配送人员") @Schema(description = "配送人员")
private Long deliveryStaffId; private Long deliveryStaffId;
@Schema(description = "退货配送人员")
private Long returnsDeliveryStaffId;
@Schema(description = "配送人员信息")
private DeliveryStaffSimpleInfo deliveryStaffInfo;
@Schema(description = "客户收货地址id") @Schema(description = "客户收货地址id")
private Long addressId; private Long addressId;
...@@ -154,12 +165,23 @@ public class ErpSaleOrderRespVO { ...@@ -154,12 +165,23 @@ public class ErpSaleOrderRespVO {
@Schema(description = "预计配送结束时间") @Schema(description = "预计配送结束时间")
private LocalDateTime planDeliveryEndTime; private LocalDateTime planDeliveryEndTime;
/* ---- 额外字段 ---- */
@Schema(description = "检获状态进度")
private String pickUpStatusDetails;
/* ---- 额外字段 END---- */
@Data @Data
public static class Item { public static class Item {
@Schema(description = "订单项编号", example = "11756") @Schema(description = "订单项编号", example = "11756")
private Long id; private Long id;
@Schema(description = "客户订单子项id")
private Long customerOrderItemId;
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
private Long productId; private Long productId;
...@@ -173,6 +195,9 @@ public class ErpSaleOrderRespVO { ...@@ -173,6 +195,9 @@ public class ErpSaleOrderRespVO {
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private Integer count;
@Schema(description = "总价")
private Integer totalPrice;
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
...@@ -194,12 +219,8 @@ public class ErpSaleOrderRespVO { ...@@ -194,12 +219,8 @@ public class ErpSaleOrderRespVO {
// ========== 关联字段 ========== // ========== 关联字段 ==========
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") @Schema(description = "商品信息")
private String productName; private ProductInfo productInfo;
@Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985")
private String productBarCode;
@Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒")
private String productUnitName;
@Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用
...@@ -208,9 +229,19 @@ public class ErpSaleOrderRespVO { ...@@ -208,9 +229,19 @@ public class ErpSaleOrderRespVO {
private Long purchaseOrderId; private Long purchaseOrderId;
@Schema(description = "供应商id") @Schema(description = "供应商id")
private Long supplierId; private Long supplierId;
@Schema(description = "拣货状态") @Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "供应商名称")
private String supplierName;
@Schema(description = "采购订单编号")
private String purchaseOrderNo;
@Schema(description = "检获时间")
private LocalDateTime pickUpTime;
} }
} }
...@@ -128,6 +128,9 @@ public class ErpSaleOrderSaveReqVO { ...@@ -128,6 +128,9 @@ public class ErpSaleOrderSaveReqVO {
@Schema(description = "拣货状态") @Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "采购订单id")
private Long purchaseOrderId;
} }
} }
\ No newline at end of file
...@@ -2,6 +2,11 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns; ...@@ -2,6 +2,11 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated; import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty; import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
...@@ -97,6 +102,37 @@ public class ErpSaleReturnRespVO { ...@@ -97,6 +102,37 @@ public class ErpSaleReturnRespVO {
@ExcelProperty("产品信息") @ExcelProperty("产品信息")
private String productNames; private String productNames;
@Schema(description = "退款状态")
private String returnsStatus;
@Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065")
private Long warehouseId;
@Schema(description = "收获库区id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26507")
private Long warehouseAreaId;
@Schema(description = "仓库信息")
private WarehouseInfo warehouseInfo;
@Schema(description = "配送人员")
private Long deliveryStaffId;
@Schema(description = "客户收货地址id")
private Long addressId;
@Schema(description = "客户收货地址info")
@TableField(typeHandler = JacksonTypeHandler.class)
private CustomerAddressInfo addressInfo;
@Schema(description = "配送时间(取货时间)")
private LocalDateTime deliveryTime;
@Schema(description = "接单时间")
private LocalDateTime acceptTime;
@Schema(description = "送达时间")
private LocalDateTime arrivalTime;
@Data @Data
public static class Item { public static class Item {
...@@ -118,6 +154,9 @@ public class ErpSaleReturnRespVO { ...@@ -118,6 +154,9 @@ public class ErpSaleReturnRespVO {
@Schema(description = "产品单价", example = "100.00") @Schema(description = "产品单价", example = "100.00")
private Integer productPrice; private Integer productPrice;
@Schema(description = "商品信息")
private ProductInfo productInfo;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private Integer count;
...@@ -131,15 +170,6 @@ public class ErpSaleReturnRespVO { ...@@ -131,15 +170,6 @@ public class ErpSaleReturnRespVO {
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;
// ========== 关联字段 ==========
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力")
private String productName;
@Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985")
private String productBarCode;
@Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒")
private String productUnitName;
@Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用
......
package cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns; package cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
...@@ -47,6 +52,25 @@ public class ErpSaleReturnSaveReqVO { ...@@ -47,6 +52,25 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "备注", example = "你猜") @Schema(description = "备注", example = "你猜")
private String remark; private String remark;
@Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065")
private Long warehouseId;
@Schema(description = "收获库区id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26507")
private Long warehouseAreaId;
@Schema(description = "仓库信息")
private WarehouseInfo warehouseInfo;
/*@Schema(description = "配送人员")
private Long deliveryStaffId;*/
@Schema(description = "客户收货地址id")
private Long addressId;
@Schema(description = "客户收货地址info")
@TableField(typeHandler = JacksonTypeHandler.class)
private CustomerAddressInfo addressInfo;
@Schema(description = "退货清单列表") @Schema(description = "退货清单列表")
private List<Item> items; private List<Item> items;
...@@ -78,6 +102,9 @@ public class ErpSaleReturnSaveReqVO { ...@@ -78,6 +102,9 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "产品单价", example = "100.00") @Schema(description = "产品单价", example = "100.00")
private Integer productPrice; private Integer productPrice;
@Schema(description = "商品信息")
private ProductInfo productInfo;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private Integer count;
......
...@@ -2,21 +2,27 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase; ...@@ -2,21 +2,27 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.finance.ErpAccountDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.finance.ErpAccountDO;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* ERP 采购退货 DO * ERP 采购退货 DO
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@TableName(value = "erp_purchase_return") @TableName(value = "erp_purchase_return", autoResultMap = true)
@KeySequence("erp_purchase_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @KeySequence("erp_purchase_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
...@@ -114,10 +120,57 @@ public class ErpPurchaseReturnDO extends BaseDO { ...@@ -114,10 +120,57 @@ public class ErpPurchaseReturnDO extends BaseDO {
/** /**
* 附件地址 * 附件地址
*/ */
private String fileUrl; @TableField(typeHandler = JacksonTypeHandler.class)
private List<String> filesUrl;
/** /**
* 备注 * 备注
*/ */
private String remark; private String remark;
/**
* 退货状态
* 枚举 {@link SaleOrderPickUpStatus}
*/
private String returnsStatus;
/**
* 客户收货地址id
*/
private Long addressId;
/**
* 客户收货地址info
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private CustomerAddressInfo addressInfo;
/**
* 收获仓库id
*/
private Long warehouseId;
/**
* 收获库区id
*/
private Long warehouseAreaId;
/**
* 仓库信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private WarehouseInfo warehouseInfo;
/**
* 配送人员
*
* DeliveryStaffDO
*/
private Long deliveryStaffId;
/**
* 客户订单id
*
* 关联 {@link // CustomerOrderDO#getId()}
*/
private Long customerOrderId;
} }
\ No newline at end of file
...@@ -3,9 +3,12 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase; ...@@ -3,9 +3,12 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -57,10 +60,8 @@ public class ErpPurchaseReturnItemDO extends BaseDO { ...@@ -57,10 +60,8 @@ public class ErpPurchaseReturnItemDO extends BaseDO {
private Long productId; private Long productId;
/** /**
* 产品单位单位 * 产品单位单位
*
* 冗余 {@link ErpProductDO#getUnitId()}
*/ */
private Long productUnitId; private String productUnit;
/** /**
* 产品单位单价,单位:分 * 产品单位单价,单位:分
...@@ -92,4 +93,9 @@ public class ErpPurchaseReturnItemDO extends BaseDO { ...@@ -92,4 +93,9 @@ public class ErpPurchaseReturnItemDO extends BaseDO {
*/ */
private String remark; private String remark;
/**
* 商品信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private ProductInfo productInfo;
} }
\ No newline at end of file
...@@ -169,6 +169,11 @@ public class ErpSaleOrderDO extends BaseDO { ...@@ -169,6 +169,11 @@ public class ErpSaleOrderDO extends BaseDO {
private Long deliveryStaffId; private Long deliveryStaffId;
/** /**
* 退货配送人员
*/
private Long returnsDeliveryStaffId;
/**
* 客户收货地址id * 客户收货地址id
*/ */
private Long addressId; private Long addressId;
......
...@@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
/** /**
* ERP 销售订单项 DO * ERP 销售订单项 DO
...@@ -109,4 +110,14 @@ public class ErpSaleOrderItemDO extends BaseDO { ...@@ -109,4 +110,14 @@ public class ErpSaleOrderItemDO extends BaseDO {
*/ */
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
/**
* 采购订单id
*/
private Long purchaseOrderId;
/**
* 检获时间
*/
private LocalDateTime pickUpTime;
} }
\ No newline at end of file
...@@ -2,7 +2,10 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.sale; ...@@ -2,7 +2,10 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.sale;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.finance.ErpAccountDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.finance.ErpAccountDO;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
...@@ -136,4 +139,59 @@ public class ErpSaleReturnDO extends BaseDO { ...@@ -136,4 +139,59 @@ public class ErpSaleReturnDO extends BaseDO {
*/ */
private String remark; private String remark;
/**
* 退货状态
* 枚举 {@link SaleOrderPickUpStatus}
*/
private String returnsStatus;
/**
* 客户收货地址id
*/
private Long addressId;
/**
* 客户收货地址info
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private CustomerAddressInfo addressInfo;
/**
* 收获仓库id
*/
private Long warehouseId;
/**
* 收获库区id
*/
private Long warehouseAreaId;
/**
* 仓库信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private WarehouseInfo warehouseInfo;
/**
* 配送人员
*
* DeliveryStaffDO
*/
private Long deliveryStaffId;
/**
* 接单时间
*/
private LocalDateTime acceptTime;
/**
* 配送时间(取货时间)
*/
private LocalDateTime deliveryTime;
/**
* 送达时间
*/
private LocalDateTime arrivalTime;
} }
\ No newline at end of file
...@@ -3,9 +3,12 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.sale; ...@@ -3,9 +3,12 @@ package cn.iocoder.foodnexus.module.erp.dal.dataobject.sale;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -15,7 +18,7 @@ import java.math.BigDecimal; ...@@ -15,7 +18,7 @@ import java.math.BigDecimal;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@TableName("erp_sale_return_items") @TableName(value = "erp_sale_return_items", autoResultMap = true)
@KeySequence("erp_sale_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @KeySequence("erp_sale_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
...@@ -99,4 +102,10 @@ public class ErpSaleReturnItemDO extends BaseDO { ...@@ -99,4 +102,10 @@ public class ErpSaleReturnItemDO extends BaseDO {
*/ */
private Long supplierId; private Long supplierId;
/**
* 商品信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private ProductInfo productInfo;
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.dal.mysql.sale; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.dal.mysql.sale;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.foodnexus.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.foodnexus.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.foodnexus.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryMyCountRespVO; import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryMyCountRespVO;
...@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -33,12 +35,19 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> { ...@@ -33,12 +35,19 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
.eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus()) .eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus())
.likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator())
.eqIfPresent(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId()) // .eqIfPresent(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId())
.betweenIfPresent(ErpSaleOrderDO::getAcceptTime, reqVO.getAcceptTime()) .betweenIfPresent(ErpSaleOrderDO::getAcceptTime, reqVO.getAcceptTime())
.eqIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatus()) .eqIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatus())
.inIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatusList())
.eqIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptId()) .eqIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptId())
.inIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptIds()) .inIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptIds())
.orderByDesc(ErpSaleOrderDO::getId); .orderByDesc(ErpSaleOrderDO::getId);
if (CommonUtil.isNotEmpty(reqVO.getDeliveryStaffId())) {
query.and(orQuery -> {
orQuery.eq(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId());
orQuery.or().eq(ErpSaleOrderDO::getReturnsDeliveryStaffId, reqVO.getDeliveryStaffId());
});
}
// 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 out_count 错误 // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 out_count 错误
if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_NONE)) { if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_NONE)) {
query.eq(ErpSaleOrderDO::getOutCount, 0); query.eq(ErpSaleOrderDO::getOutCount, 0);
...@@ -91,15 +100,15 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> { ...@@ -91,15 +100,15 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
return this.selectJoinOne(DeliveryMyCountRespVO.class, wrapper); return this.selectJoinOne(DeliveryMyCountRespVO.class, wrapper);
} }
default Long statusCount(String type, Long userId) { default Long statusCount(List<String> types, Long userId) {
return this.selectCount(Wrappers.<ErpSaleOrderDO>lambdaQuery() return this.selectCount(Wrappers.<ErpSaleOrderDO>lambdaQuery()
.eq(ErpSaleOrderDO::getDeliveryStaffId, userId) .eq(ErpSaleOrderDO::getDeliveryStaffId, userId)
.eq(ErpSaleOrderDO::getPickUpStatus, type)); .in(ErpSaleOrderDO::getPickUpStatus, types));
} }
default Long statusCount(String type, Set<Long> deptIds) { default Long statusCount(List<String> types, Set<Long> deptIds) {
return this.selectCount(Wrappers.<ErpSaleOrderDO>lambdaQuery() return this.selectCount(Wrappers.<ErpSaleOrderDO>lambdaQuery()
.in(ErpSaleOrderDO::getCustomerDeptId, deptIds) .in(ErpSaleOrderDO::getCustomerDeptId, deptIds)
.eq(ErpSaleOrderDO::getPickUpStatus, type)); .in(ErpSaleOrderDO::getPickUpStatus, types));
} }
} }
\ No newline at end of file
...@@ -2,7 +2,6 @@ package cn.iocoder.foodnexus.module.erp.enums; ...@@ -2,7 +2,6 @@ package cn.iocoder.foodnexus.module.erp.enums;
import cn.iocoder.foodnexus.framework.common.core.ArrayValuable; import cn.iocoder.foodnexus.framework.common.core.ArrayValuable;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -17,6 +16,8 @@ import java.util.Arrays; ...@@ -17,6 +16,8 @@ import java.util.Arrays;
@Getter @Getter
public enum SaleOrderPickUpStatus implements ArrayValuable<String> { public enum SaleOrderPickUpStatus implements ArrayValuable<String> {
CANCEL("CANCEL", "取消"),
TO_BE("TO_BE", "待拣"), TO_BE("TO_BE", "待拣"),
PICK_UP("PICK_UP", "待接单"), PICK_UP("PICK_UP", "待接单"),
...@@ -29,6 +30,24 @@ public enum SaleOrderPickUpStatus implements ArrayValuable<String> { ...@@ -29,6 +30,24 @@ public enum SaleOrderPickUpStatus implements ArrayValuable<String> {
SIGN("SIGN", "已签收"), SIGN("SIGN", "已签收"),
/* ----- 退款 ------ */
// 生成销售退货单
RETURNS_PROCESS("RETURNS_PROCESS", "退款 - 审核中"),
// 销售退货单申请通过
RETURNS_APPROVE("RETURNS_APPROVE", "退款 - 已审核"),
// 销售退货单根据供应商拆分为采购退货单
// 配送员接受采购退货单
RETURNS_STAFF_ACCEPT("RETURNS_STAFF_ACCEPT", "退款 - 配送员接单"),
// 配送员取件发货
RETURNS_STAFF_ALREADY("RETURNS_STAFF_ALREADY", "退款 - 配送员已取件"),
// 确认收获
RETURNS_FINISH("RETURNS_FINISH", "退款 - 退货完成"),
; ;
public static final String[] ARRAYS = Arrays.stream(values()).map(SaleOrderPickUpStatus::getType).toArray(String[]::new); public static final String[] ARRAYS = Arrays.stream(values()).map(SaleOrderPickUpStatus::getType).toArray(String[]::new);
......
...@@ -95,6 +95,8 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { ...@@ -95,6 +95,8 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
// 3. 更新采购订单的入库数量 // 3. 更新采购订单的入库数量
updatePurchaseOrderInCount(createReqVO.getOrderId()); updatePurchaseOrderInCount(createReqVO.getOrderId());
this.updatePurchaseInStatus(purchaseIn.getId(), ErpAuditStatus.APPROVE.getStatus());
return purchaseIn.getId(); return purchaseIn.getId();
} }
......
...@@ -20,6 +20,8 @@ import cn.iocoder.foodnexus.module.erp.service.finance.ErpAccountService; ...@@ -20,6 +20,8 @@ import cn.iocoder.foodnexus.module.erp.service.finance.ErpAccountService;
import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService; import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockRecordService; import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockRecordService;
import cn.iocoder.foodnexus.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; import cn.iocoder.foodnexus.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -56,13 +58,11 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { ...@@ -56,13 +58,11 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
private ErpNoRedisDAO noRedisDAO; private ErpNoRedisDAO noRedisDAO;
@Resource @Resource
private ErpProductService productService; private ProductSpuService productService;
@Resource @Resource
@Lazy // 延迟加载,避免循环依赖 @Lazy // 延迟加载,避免循环依赖
private ErpPurchaseOrderService purchaseOrderService; private ErpPurchaseOrderService purchaseOrderService;
@Resource @Resource
private ErpAccountService accountService;
@Resource
private ErpStockRecordService stockRecordService; private ErpStockRecordService stockRecordService;
@Override @Override
...@@ -73,7 +73,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { ...@@ -73,7 +73,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
// 1.2 校验退货项的有效性 // 1.2 校验退货项的有效性
List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems()); List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems());
// 1.3 校验结算账户 // 1.3 校验结算账户
accountService.validateAccount(createReqVO.getAccountId()); /*accountService.validateAccount(createReqVO.getAccountId());*/
// 1.4 生成退货单号,并校验唯一性 // 1.4 生成退货单号,并校验唯一性
String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX); String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX);
if (purchaseReturnMapper.selectByNo(no) != null) { if (purchaseReturnMapper.selectByNo(no) != null) {
...@@ -106,7 +106,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { ...@@ -106,7 +106,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
// 1.2 校验采购订单已审核 // 1.2 校验采购订单已审核
ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId()); ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId());
// 1.3 校验结算账户 // 1.3 校验结算账户
accountService.validateAccount(updateReqVO.getAccountId()); /*accountService.validateAccount(updateReqVO.getAccountId());*/
// 1.4 校验订单项的有效性 // 1.4 校验订单项的有效性
List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(updateReqVO.getItems()); List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(updateReqVO.getItems());
...@@ -197,12 +197,12 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { ...@@ -197,12 +197,12 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
private List<ErpPurchaseReturnItemDO> validatePurchaseReturnItems(List<ErpPurchaseReturnSaveReqVO.Item> list) { private List<ErpPurchaseReturnItemDO> validatePurchaseReturnItems(List<ErpPurchaseReturnSaveReqVO.Item> list) {
// 1. 校验产品存在 // 1. 校验产品存在
List<ErpProductDO> productList = productService.validProductList( List<ProductSpuDO> productList = productService.validProductList(
convertSet(list, ErpPurchaseReturnSaveReqVO.Item::getProductId)); convertSet(list, ErpPurchaseReturnSaveReqVO.Item::getProductId));
Map<Long, ErpProductDO> productMap = convertMap(productList, ErpProductDO::getId); Map<Long, ProductSpuDO> productMap = convertMap(productList, ProductSpuDO::getId);
// 2. 转化为 ErpPurchaseReturnItemDO 列表 // 2. 转化为 ErpPurchaseReturnItemDO 列表
return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseReturnItemDO.class, item -> { return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseReturnItemDO.class, item -> {
item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); item.setProductUnit(productMap.get(item.getProductId()).getUnitName());
item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount()));
if (item.getTotalPrice() == null) { if (item.getTotalPrice() == null) {
return; return;
......
...@@ -8,10 +8,12 @@ import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils; ...@@ -8,10 +8,12 @@ import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo; import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.*; import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.*;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOutDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOutDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOutItemDO;
import cn.iocoder.foodnexus.module.erp.dal.mysql.purchase.ErpPurchaseOrderMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderItemMapper; import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderItemMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderMapper; import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOutItemMapper; import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOutItemMapper;
...@@ -20,6 +22,7 @@ import cn.iocoder.foodnexus.module.erp.dal.redis.no.ErpNoRedisDAO; ...@@ -20,6 +22,7 @@ import cn.iocoder.foodnexus.module.erp.dal.redis.no.ErpNoRedisDAO;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus; import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.service.finance.ErpAccountService; import cn.iocoder.foodnexus.module.erp.service.finance.ErpAccountService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi; import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderRecordApi; import cn.iocoder.foodnexus.module.order.api.CustomerOrderRecordApi;
import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi; import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi;
...@@ -30,6 +33,7 @@ import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi; ...@@ -30,6 +33,7 @@ import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -90,6 +94,9 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -90,6 +94,9 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
@Autowired @Autowired
private ErpSaleOutItemMapper saleOutItemMapper; private ErpSaleOutItemMapper saleOutItemMapper;
@Autowired
private ErpPurchaseOrderMapper purchaseOrderMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) { public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) {
...@@ -113,7 +120,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -113,7 +120,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
// 2.1 插入订单 // 2.1 插入订单
ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class, in -> in ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class, in -> in
.setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); .setNo(no).setStatus(ErpAuditStatus.APPROVE.getStatus()));
calculateTotalPrice(saleOrder, saleOrderItems); calculateTotalPrice(saleOrder, saleOrderItems);
saleOrderMapper.insert(saleOrder); saleOrderMapper.insert(saleOrder);
// 2.2 插入订单项 // 2.2 插入订单项
...@@ -360,10 +367,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -360,10 +367,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
CustomerOrderDTO customerOrder = customerOrderApi.queryById(saleOrder.getCustomerOrderId()); CustomerOrderDTO customerOrder = customerOrderApi.queryById(saleOrder.getCustomerOrderId());
saleOrderItemMapper.update(Wrappers.<ErpSaleOrderItemDO>lambdaUpdate() saleOrderItemMapper.update(Wrappers.<ErpSaleOrderItemDO>lambdaUpdate()
.set(ErpSaleOrderItemDO::getPickUpTime, LocalDateTime.now())
.set(ErpSaleOrderItemDO::getPickUpStatus, SaleOrderPickUpStatus.PICK_UP.getType()) .set(ErpSaleOrderItemDO::getPickUpStatus, SaleOrderPickUpStatus.PICK_UP.getType())
.eq(ErpSaleOrderItemDO::getId, itemId)); .eq(ErpSaleOrderItemDO::getId, itemId));
Long allCount = saleOrderItemMapper.selectCount(ErpSaleOrderItemDO::getOrderId, saleOrder.getId()); Long allCount = saleOrderItemMapper.selectCount(ErpSaleOrderItemDO::getOrderId, saleOrder.getId());
Long pickUpCount = saleOrderItemMapper.selectCount(Wrappers.<ErpSaleOrderItemDO>lambdaQuery() Long pickUpCount = saleOrderItemMapper.selectCount(Wrappers.<ErpSaleOrderItemDO>lambdaQuery()
.eq(ErpSaleOrderItemDO::getOrderId, saleOrder.getId()) .eq(ErpSaleOrderItemDO::getOrderId, saleOrder.getId())
...@@ -606,6 +613,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -606,6 +613,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
item.setCount(orderItem.getOrderItemQuantity()); item.setCount(orderItem.getOrderItemQuantity());
item.setSupplierId(orderItem.getSupplierId()); item.setSupplierId(orderItem.getSupplierId());
item.setPickUpStatus(SaleOrderPickUpStatus.TO_BE); item.setPickUpStatus(SaleOrderPickUpStatus.TO_BE);
item.setPurchaseOrderId(Optional.ofNullable(purchaseOrderMapper.selectOne(Wrappers.<ErpPurchaseOrderDO>lambdaQuery()
.eq(ErpPurchaseOrderDO::getCustomerOrderId, order.getId())
.eq(ErpPurchaseOrderDO::getSupplierId, orderItem.getSupplierId())
.last("LIMIT 1"))).map(ErpPurchaseOrderDO::getId).orElse(null));
return item; return item;
})); }));
this.createSaleOrder(saveReqVO); this.createSaleOrder(saveReqVO);
...@@ -651,13 +662,24 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -651,13 +662,24 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
@Override @Override
public List<DeliveryStatusCountRespVO> statusCount(Long userId, Set<Long> deptIds) { public List<DeliveryStatusCountRespVO> statusCount(Long userId, Set<Long> deptIds) {
List<DeliveryStatusCountRespVO> result = new ArrayList<>(); List<DeliveryStatusCountRespVO> result = new ArrayList<>();
for (SaleOrderPickUpStatus status : SaleOrderPickUpStatus.values()) { for (int type = 0; type < 3;type ++) {
DeliveryStatusCountRespVO count = new DeliveryStatusCountRespVO(); DeliveryStatusCountRespVO count = new DeliveryStatusCountRespVO();
count.setPickUpStatus(status); count.setType(type);
if (status.equals(SaleOrderPickUpStatus.PICK_UP) && CommonUtil.isNotEmpty(deptIds)) { switch (type) {
count.setCount(saleOrderMapper.statusCount(status.getType(), deptIds)); case 0 :
} else { count.setCount(saleOrderMapper.statusCount(CommonUtil.asList(SaleOrderPickUpStatus.PICK_UP.getType(),
count.setCount(saleOrderMapper.statusCount(status.getType(), userId)); SaleOrderPickUpStatus.RETURNS_APPROVE.getType()), deptIds));
break;
case 1:
count.setCount(saleOrderMapper.statusCount(CommonUtil.asList(SaleOrderPickUpStatus.ACCEPT.getType(),
SaleOrderPickUpStatus.RETURNS_STAFF_ACCEPT.getType()
), userId));
break;
case 2:
count.setCount(saleOrderMapper.statusCount(CommonUtil.asList(SaleOrderPickUpStatus.ALREADY.getType(),
SaleOrderPickUpStatus.RETURNS_STAFF_ALREADY.getType()), userId));
break;
default:break;
} }
result.add(count); result.add(count);
} }
......
...@@ -106,6 +106,8 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { ...@@ -106,6 +106,8 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
// 3. 更新销售订单的出库数量 // 3. 更新销售订单的出库数量
updateSaleOrderOutCount(createReqVO.getOrderId()); updateSaleOrderOutCount(createReqVO.getOrderId());
this.updateSaleOutStatus(saleOut.getId(), ErpAuditStatus.APPROVE.getStatus());
return saleOut.getId(); return saleOut.getId();
} }
......
...@@ -104,4 +104,8 @@ public interface ErpSaleReturnService { ...@@ -104,4 +104,8 @@ public interface ErpSaleReturnService {
* @return * @return
*/ */
ErpSaleReturnDO queryByCustomerOrderId(Long id); ErpSaleReturnDO queryByCustomerOrderId(Long id);
void accept(Long id, Long deliveryStaffId);
void delivery(Long id, Long deliveryStaffId);
} }
\ No newline at end of file
...@@ -212,4 +212,14 @@ public class DeliveryStaffServiceImpl implements DeliveryStaffService, DeliveryS ...@@ -212,4 +212,14 @@ public class DeliveryStaffServiceImpl implements DeliveryStaffService, DeliveryS
public DeliveryStaffSimpleInfo querybyStaffId(Long staffId) { public DeliveryStaffSimpleInfo querybyStaffId(Long staffId) {
return BeanUtils.toBean(deliveryStaffMapper.selectById(staffId), DeliveryStaffSimpleInfo.class); return BeanUtils.toBean(deliveryStaffMapper.selectById(staffId), DeliveryStaffSimpleInfo.class);
} }
@Override
public Map<Long, DeliveryStaffSimpleInfo> getMap(Set<Long> ids) {
if (CommonUtil.isEmpty(ids)) {
return new HashMap<>();
}
List<DeliveryStaffDO> deliveryStaffDOS = deliveryStaffMapper.selectByIds(ids);
return CommonUtil.listConvertMap(deliveryStaffDOS, DeliveryStaffDO::getId, staff ->
new DeliveryStaffSimpleInfo(staff.getId(), staff.getName(), staff.getContact(), staff.getUserId()));
}
} }
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.api; package cn.iocoder.foodnexus.module.order.api;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/** /**
* @author : yanghao * @author : yanghao
* create at: 2025/9/30 14:17 * create at: 2025/9/30 14:17
...@@ -9,4 +13,6 @@ package cn.iocoder.foodnexus.module.order.api; ...@@ -9,4 +13,6 @@ package cn.iocoder.foodnexus.module.order.api;
public interface CheckTaskApi { public interface CheckTaskApi {
void createByPurchaseOrderId(Long purchaseOrderId); void createByPurchaseOrderId(Long purchaseOrderId);
Map<Long,String> getCheckResultMapByPurchaseOrderItemIds(Collection<Long> purchaseOrderItemIds);
} }
...@@ -2,6 +2,9 @@ package cn.iocoder.foodnexus.module.order.api; ...@@ -2,6 +2,9 @@ package cn.iocoder.foodnexus.module.order.api;
import cn.iocoder.foodnexus.module.order.dto.DeliveryStaffSimpleInfo; import cn.iocoder.foodnexus.module.order.dto.DeliveryStaffSimpleInfo;
import java.util.Map;
import java.util.Set;
/** /**
* @author : yanghao * @author : yanghao
* create at: 2025/9/25 15:54 * create at: 2025/9/25 15:54
...@@ -14,4 +17,6 @@ public interface DeliveryStaffApi { ...@@ -14,4 +17,6 @@ public interface DeliveryStaffApi {
Long queryStaffIdByUserId(Long loginUserId); Long queryStaffIdByUserId(Long loginUserId);
DeliveryStaffSimpleInfo querybyStaffId(Long staffId); DeliveryStaffSimpleInfo querybyStaffId(Long staffId);
Map<Long, DeliveryStaffSimpleInfo> getMap(Set<Long> longs);
} }
package cn.iocoder.foodnexus.module.order.dto; package cn.iocoder.foodnexus.module.order.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author : yanghao * @author : yanghao
...@@ -8,8 +10,12 @@ import lombok.Data; ...@@ -8,8 +10,12 @@ import lombok.Data;
* @description: * @description:
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class DeliveryStaffSimpleInfo { public class DeliveryStaffSimpleInfo {
private Long id; private Long id;
/** /**
* 姓名 * 姓名
......
...@@ -104,7 +104,7 @@ public class CheckTaskController { ...@@ -104,7 +104,7 @@ public class CheckTaskController {
item.setSupplierName(supplierApi.queryNameById(item.getSupplierId())); item.setSupplierName(supplierApi.queryNameById(item.getSupplierId()));
item.setCustomerName(customerApi.queryNameStrById(item.getCustomerId())); item.setCustomerName(customerApi.queryNameStrById(item.getCustomerId()));
Map<Long, String> itemMap = checkTaskItemsService.queryProductInfoByCheckId(CommonUtil.asList(item.getId())); Map<Long, String> itemMap = checkTaskItemsService.queryProductInfoByCheckId(CommonUtil.asList(item.getId()));
item.setProductNameInfo(itemMap.getOrDefault(item.getId(), "")); item.setProductNames(itemMap.getOrDefault(item.getId(), ""));
item.setPurchaseOrderNo(purchaseOrderService.getPurchaseOrder(item.getPurchaseOrderId()).getNo()); item.setPurchaseOrderNo(purchaseOrderService.getPurchaseOrder(item.getPurchaseOrderId()).getNo());
})); }));
} }
...@@ -122,7 +122,7 @@ public class CheckTaskController { ...@@ -122,7 +122,7 @@ public class CheckTaskController {
return success(BeanUtils.toBean(pageResult, CheckTaskRespVO.class, item -> { return success(BeanUtils.toBean(pageResult, CheckTaskRespVO.class, item -> {
MapUtils.findAndThen(supplierNameMap, item.getSupplierId(), item::setSupplierName); MapUtils.findAndThen(supplierNameMap, item.getSupplierId(), item::setSupplierName);
MapUtils.findAndThen(customerMap, item.getCustomerId(), item::setCustomerName); MapUtils.findAndThen(customerMap, item.getCustomerId(), item::setCustomerName);
MapUtils.findAndThen(productInfoMap, item.getId(), item::setProductNameInfo); MapUtils.findAndThen(productInfoMap, item.getId(), item::setProductNames);
MapUtils.findAndThen(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder -> { MapUtils.findAndThen(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder -> {
item.setPurchaseOrderNo(purchaseOrder.getNo()); item.setPurchaseOrderNo(purchaseOrder.getNo());
}); });
......
...@@ -22,6 +22,9 @@ public class CheckTaskItemsRespVO { ...@@ -22,6 +22,9 @@ public class CheckTaskItemsRespVO {
@ExcelProperty("来料质检id") @ExcelProperty("来料质检id")
private Long checkTaskId; private Long checkTaskId;
@Schema(description = "采购订单子id")
private Long purchaseOrderItemId;
@Schema(description = "商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30398") @Schema(description = "商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30398")
@ExcelProperty("商品id") @ExcelProperty("商品id")
private Long productId; private Long productId;
......
...@@ -23,6 +23,9 @@ public class CheckTaskItemsSaveReqVO { ...@@ -23,6 +23,9 @@ public class CheckTaskItemsSaveReqVO {
@Schema(description = "商品名称", example = "王五") @Schema(description = "商品名称", example = "王五")
private String productName; private String productName;
@Schema(description = "采购订单子id")
private Long purchaseOrderItemId;
@Schema(description = "商品分类", example = "20330") @Schema(description = "商品分类", example = "20330")
private Long categoryId; private Long categoryId;
......
...@@ -70,7 +70,7 @@ public class CheckTaskRespVO { ...@@ -70,7 +70,7 @@ public class CheckTaskRespVO {
private String supplierName; private String supplierName;
@Schema(description = "产品信息") @Schema(description = "产品信息")
private String productNameInfo; private String productNames;
@Schema(description = "采购订单编号") @Schema(description = "采购订单编号")
private String purchaseOrderNo; private String purchaseOrderNo;
......
...@@ -96,21 +96,33 @@ public class DeliverySaleOrderController { ...@@ -96,21 +96,33 @@ public class DeliverySaleOrderController {
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "接单大厅 - 查询配送单") @Operation(summary = "接单大厅 - 查询配送单")
@Parameter(name = "pickUpStatus", description = "拣货状态(字典类型:sale_order_pick_up_status)", required = true, example = "1024") @Parameter(name = "type", description = "0-待接单 1-待配送 2-配送中", required = true, example = "1024")
public CommonResult<PageResult<DeliverySaleOrderRespVO>> getSaleOrderPage(@Valid PageParam pageReq, public CommonResult<PageResult<DeliverySaleOrderRespVO>> getSaleOrderPage(@Valid PageParam pageReq,
@InEnum(value = SaleOrderPickUpStatus.class) @InEnum(value = SaleOrderPickUpStatus.class)
@RequestParam("pickUpStatus") @RequestParam("type")
String pickUpStatus) { Integer type) {
ErpSaleOrderPageReqVO pageReqVO = new ErpSaleOrderPageReqVO(); ErpSaleOrderPageReqVO pageReqVO = new ErpSaleOrderPageReqVO();
pageReqVO.setPageNo(pageReq.getPageNo()); pageReqVO.setPageNo(pageReq.getPageNo());
pageReqVO.setPageSize(pageReq.getPageSize()); pageReqVO.setPageSize(pageReq.getPageSize());
if (SaleOrderPickUpStatus.PICK_UP.getType().equals(pickUpStatus) || SaleOrderPickUpStatus.TO_BE.getType().equals(pickUpStatus) ) { if (type < 0 || type > 2) {
return success(new PageResult<>());
}
if (type == 0) {
List<DeptSimpleRespVO> deptSimpleRespVOS = deliveryStaffCustomerService.queryDeptListByStaffId(deliveryStaffApi.queryStaffIdByUserId(getLoginUserId())); List<DeptSimpleRespVO> deptSimpleRespVOS = deliveryStaffCustomerService.queryDeptListByStaffId(deliveryStaffApi.queryStaffIdByUserId(getLoginUserId()));
pageReqVO.setCustomerDeptIds(CommonUtil.listConvert(deptSimpleRespVOS, DeptSimpleRespVO::getId)); pageReqVO.setCustomerDeptIds(CommonUtil.listConvert(deptSimpleRespVOS, DeptSimpleRespVO::getId));
pageReqVO.setPickUpStatusList(CommonUtil.asList(SaleOrderPickUpStatus.PICK_UP.getType(),
SaleOrderPickUpStatus.RETURNS_APPROVE.getType()));
} else { } else {
pageReqVO.setDeliveryStaffId(deliveryStaffApi.queryStaffIdByUserId(getLoginUserId())); pageReqVO.setDeliveryStaffId(deliveryStaffApi.queryStaffIdByUserId(getLoginUserId()));
if (type == 1) {
pageReqVO.setPickUpStatusList(CommonUtil.asList(SaleOrderPickUpStatus.ACCEPT.getType(),
SaleOrderPickUpStatus.RETURNS_STAFF_ACCEPT.getType()));
}
if (type == 2) {
pageReqVO.setPickUpStatusList(CommonUtil.asList(SaleOrderPickUpStatus.ALREADY.getType(),
SaleOrderPickUpStatus.RETURNS_STAFF_ALREADY.getType()));
}
} }
pageReqVO.setPickUpStatus(SaleOrderPickUpStatus.getByType(pickUpStatus));
return success(BeanUtils.toBean(saleOrderService.getSaleOrderPage(pageReqVO), DeliverySaleOrderRespVO.class)); return success(BeanUtils.toBean(saleOrderService.getSaleOrderPage(pageReqVO), DeliverySaleOrderRespVO.class));
} }
......
package cn.iocoder.foodnexus.module.order.controller.app.delivery;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.common.validation.InEnum;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryMyCountRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryStatusCountRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleReturnDO;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleReturnService;
import cn.iocoder.foodnexus.module.operations.service.deliverystaffcustomer.DeliveryStaffCustomerService;
import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderRespVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo.CustomerOrderItemRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.delivery.vo.DeliveryOrderDetails;
import cn.iocoder.foodnexus.module.order.controller.app.delivery.vo.DeliverySaleOrderRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.delivery.vo.DeliverySaleReturnRespVO;
import cn.iocoder.foodnexus.module.order.dto.DeliveryOrderUpdateReqVO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService;
import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth;
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* @author : yanghao
* create at: 2025/10/14 17:56
* @description: 配送员 - 订单
*/
@Tag(name = "配送员 - 订单 - 退款")
@RestController
@RequestMapping("/delivery/sale-return")
@Validated
@AppSystemAuth(UserSystemEnum.DELIVERY)
public class DeliverySaleReturnController {
@Autowired
private DeliveryStaffApi deliveryStaffApi;
@Autowired
private ErpSaleReturnService saleReturnService;
@Autowired
private CustomerOrderService customerOrderService;
@Autowired
private CustomerOrderItemService customerOrderItemService;
@GetMapping("/get")
@Operation(summary = "退货单详情")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<DeliveryOrderDetails<DeliverySaleReturnRespVO>> getSaleOrder(@RequestParam("id") Long id) {
// ErpSaleOrderDO saleOrder = saleOrderService.getSaleOrder(id);
ErpSaleReturnDO saleReturn = saleReturnService.getSaleReturn(id);
if (saleReturn == null) {
return success(null);
}
DeliveryOrderDetails<DeliverySaleReturnRespVO> result = new DeliveryOrderDetails<>();
result.setDeliveryInfo(BeanUtils.toBean(saleReturn, DeliverySaleReturnRespVO.class));
result.setCustomerOrderInfo(BeanUtils.toBean(customerOrderService.getCustomerOrder(saleReturn.getCustomerOrderId()),
CustomerOrderRespVO.class, item ->
item.setOrderItems(BeanUtils.toBean(customerOrderItemService.queryByOrderId(item.getId()), CustomerOrderItemRespVO.class))));
return success(result);
}
@PostMapping("/accept")
@Operation(summary = "确认接单")
@Parameter(name = "id", description = "配送单id(deliveryInfo.id)", required = true)
public CommonResult<Boolean> accept(@RequestParam("id") Long id) {
saleReturnService.accept(id, deliveryStaffApi.queryStaffIdByUserId(getLoginUserId()));
return success(Boolean.TRUE);
}
// 退货订单
@PostMapping("/delivery")
@Operation(summary = "确认取货")
@Parameter(name = "id", description = "配送单id(deliveryInfo.id)", required = true)
public CommonResult<Boolean> delivery(@RequestParam("id") Long id) {
saleReturnService.delivery(id, deliveryStaffApi.queryStaffIdByUserId(getLoginUserId()));
return success(Boolean.TRUE);
}
// 订单到货 - 运营后台
/*@PostMapping("/arrival")
@Operation(summary = "订单到货")
public CommonResult<Boolean> arrival(@RequestBody @Valid DeliveryOrderUpdateReqVO reqVO) {
saleReturnService.arrival(reqVO, deliveryStaffApi.queryStaffIdByUserId(getLoginUserId()));
return success(Boolean.TRUE);
}*/
}
package cn.iocoder.foodnexus.module.order.controller.app.delivery.vo;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author : yanghao
* create at: 2025/10/14 18:16
* @description: 配送员 - 销售订单
*/
@Data
public class DeliverySaleReturnRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386")
@ExcelProperty("编号")
private Long id;
@Schema(description = "销售退货单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001")
@ExcelProperty("销售退货单号")
private String no;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724")
private Long customerId;
@Schema(description = "客户名称", example = "芋道")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("下单时间")
private LocalDateTime orderTime;
@Schema(description = "客户订单id")
private Long customerOrderId;
@Schema(description = "配送模式")
private DeliveryMode deliveryMode;
@Schema(description = "配送时间(取货时间)")
private LocalDateTime deliveryTime;
@Schema(description = "接单时间")
private LocalDateTime acceptTime;
@Schema(description = "送达时间")
private LocalDateTime arrivalTime;
@Schema(description = "客户收货地址id")
private Long addressId;
@Schema(description = "客户收货地址info")
@TableField(typeHandler = JacksonTypeHandler.class)
private CustomerAddressInfo addressInfo;
@Schema(description = "退货状态")
private String returnsStatus;
@Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065")
private Long warehouseId;
@Schema(description = "收获库区id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26507")
private Long warehouseAreaId;
@Schema(description = "仓库信息")
private WarehouseInfo warehouseInfo;
@Schema(description = "预计配送开始时间")
private LocalDateTime planDeliveryStartTime;
@Schema(description = "预计配送结束时间")
private LocalDateTime planDeliveryEndTime;
}
...@@ -52,6 +52,13 @@ public class ShoppingCartController { ...@@ -52,6 +52,13 @@ public class ShoppingCartController {
return success(shoppingCartService.createShoppingCart(createReqVO)); return success(shoppingCartService.createShoppingCart(createReqVO));
} }
@PostMapping("/create-batch")
@Operation(summary = "创建购物车(批量)")
public CommonResult<Boolean> createBatch(@Valid @RequestBody ShoppingCartSaveBatchReqVO createReqVO) {
shoppingCartService.createBatch(createReqVO);
return success(Boolean.TRUE);
}
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新购物车") @Operation(summary = "更新购物车")
public CommonResult<Boolean> updateShoppingCart(@Valid @RequestBody ShoppingCartSaveReqVO updateReqVO) { public CommonResult<Boolean> updateShoppingCart(@Valid @RequestBody ShoppingCartSaveReqVO updateReqVO) {
......
package cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.util.List;
/**
* @author : yanghao
* create at: 2025/10/18 10:14
* @description: 批量新增
*/
@Data
public class ShoppingCartSaveBatchReqVO {
@Schema(description = "购物车批量新增项")
@NotNull(message = "新增项不能为空")
@Size(min = 1, message = "新增项不能为空")
private List<ShoppingCartSaveReqVO> items;
}
...@@ -36,6 +36,10 @@ public class CheckTaskItemsDO extends BaseDO { ...@@ -36,6 +36,10 @@ public class CheckTaskItemsDO extends BaseDO {
*/ */
private Long productId; private Long productId;
/** /**
* 采购订单子id
*/
private Long purchaseOrderItemId;
/**
* 商品名称 * 商品名称
*/ */
private String productName; private String productName;
......
...@@ -278,6 +278,16 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi { ...@@ -278,6 +278,16 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
this.createCheckTask(this.transform(purchaseOrder, purchaseOrderItems)); this.createCheckTask(this.transform(purchaseOrder, purchaseOrderItems));
} }
@Override
public Map<Long, String> getCheckResultMapByPurchaseOrderItemIds(Collection<Long> purchaseOrderItemIds) {
if (CommonUtil.isEmpty(purchaseOrderItemIds)) {
return new HashMap<>(1);
}
List<CheckTaskItemsDO> checkTaskItemsDOS = checkTaskItemsMapper.selectList(Wrappers.<CheckTaskItemsDO>lambdaQuery()
.in(CheckTaskItemsDO::getPurchaseOrderItemId, purchaseOrderItemIds));
return CommonUtil.listConvertMap(checkTaskItemsDOS, CheckTaskItemsDO::getPurchaseOrderItemId, CheckTaskItemsDO::getCheckResult);
}
private CheckTaskSaveReqVO transform(ErpPurchaseOrderDO purchaseOrder, List<ErpPurchaseOrderItemDO> purchaseOrderItems) { private CheckTaskSaveReqVO transform(ErpPurchaseOrderDO purchaseOrder, List<ErpPurchaseOrderItemDO> purchaseOrderItems) {
CheckTaskSaveReqVO checkTask = new CheckTaskSaveReqVO(); CheckTaskSaveReqVO checkTask = new CheckTaskSaveReqVO();
if (CommonUtil.isEmpty(purchaseOrder)) { if (CommonUtil.isEmpty(purchaseOrder)) {
...@@ -301,6 +311,7 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi { ...@@ -301,6 +311,7 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
checkTask.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem -> { checkTask.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem -> {
CheckTaskItemsSaveReqVO item = new CheckTaskItemsSaveReqVO(); CheckTaskItemsSaveReqVO item = new CheckTaskItemsSaveReqVO();
ProductSpuDO productSpuDO = spuMap.get(purchaseOrderItem.getProductId()); ProductSpuDO productSpuDO = spuMap.get(purchaseOrderItem.getProductId());
item.setPurchaseOrderItemId(purchaseOrderItem.getId());
item.setProductId(purchaseOrderItem.getProductId()); item.setProductId(purchaseOrderItem.getProductId());
item.setProductName(productSpuDO.getName()); item.setProductName(productSpuDO.getName());
item.setCategoryId(productSpuDO.getCategoryId()); item.setCategoryId(productSpuDO.getCategoryId());
......
...@@ -90,7 +90,7 @@ public class CheckTaskItemsServiceImpl implements CheckTaskItemsService { ...@@ -90,7 +90,7 @@ public class CheckTaskItemsServiceImpl implements CheckTaskItemsService {
} }
Map<Long, List<CheckTaskItemsDO>> itemMap = CommonUtil.listConvertListMap(checkTaskItemsDOS, CheckTaskItemsDO::getCheckTaskId); Map<Long, List<CheckTaskItemsDO>> itemMap = CommonUtil.listConvertListMap(checkTaskItemsDOS, CheckTaskItemsDO::getCheckTaskId);
itemMap.forEach((checkId, list) -> resultMap.put(checkId, itemMap.forEach((checkId, list) -> resultMap.put(checkId,
String.join("\n", CommonUtil.listConvert(list, item -> item.getProductName() + "(" + item.getCheckCount() + ")")))); String.join("", CommonUtil.listConvert(list, item -> item.getProductName() + "(" + item.getCheckCount() + ")"))));
return resultMap; return resultMap;
} }
......
...@@ -14,6 +14,8 @@ import cn.iocoder.foodnexus.module.erp.api.service.ErpWarehouseApi; ...@@ -14,6 +14,8 @@ import cn.iocoder.foodnexus.module.erp.api.service.ErpWarehouseApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.customerwarehouse.CustomerWarehouseDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.customerwarehouse.CustomerWarehouseDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.*; import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.*;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderMapper;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.service.customerwarehouse.CustomerWarehouseService; import cn.iocoder.foodnexus.module.erp.service.customerwarehouse.CustomerWarehouseService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderServiceImpl; import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderServiceImpl;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService; import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService;
...@@ -40,7 +42,9 @@ import cn.iocoder.foodnexus.module.order.service.shoppingcart.ShoppingCartServic ...@@ -40,7 +42,9 @@ import cn.iocoder.foodnexus.module.order.service.shoppingcart.ShoppingCartServic
import cn.iocoder.foodnexus.module.product.api.InquireCustomerApi; import cn.iocoder.foodnexus.module.product.api.InquireCustomerApi;
import cn.iocoder.foodnexus.module.product.api.dto.CustomerVisibleProductRespDTO; import cn.iocoder.foodnexus.module.product.api.dto.CustomerVisibleProductRespDTO;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo; import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.foodnexus.module.product.service.category.ProductCategoryService;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService; import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService; import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
...@@ -117,6 +121,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -117,6 +121,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
private ProductSpuService productSpuService; private ProductSpuService productSpuService;
@Autowired @Autowired
private ProductCategoryService productCategoryService;
@Autowired
@Lazy @Lazy
private ErpSaleOutService saleOutService; private ErpSaleOutService saleOutService;
...@@ -129,6 +136,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -129,6 +136,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
private ErpSaleOrderService saleOrderService; private ErpSaleOrderService saleOrderService;
@Autowired @Autowired
private ErpSaleOrderMapper saleOrderMapper;
@Autowired
private ScoringWeightService scoringWeightService; private ScoringWeightService scoringWeightService;
@Autowired @Autowired
...@@ -259,7 +269,8 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -259,7 +269,8 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
CustomerOrderItemDO item = BeanUtils.toBean(orderItem, CustomerOrderItemDO.class); CustomerOrderItemDO item = BeanUtils.toBean(orderItem, CustomerOrderItemDO.class);
item.setCustomerId(customerId); item.setCustomerId(customerId);
item.setProductInfo(BeanUtils.toBean(productSpuService.getSpu(item.getProductId()), item.setProductInfo(BeanUtils.toBean(productSpuService.getSpu(item.getProductId()),
ProductInfo.class)); ProductInfo.class, product ->
product.setCategoryName(productCategoryService.queryNameById(product.getCategoryId()))));
item.setProductName(item.getProductInfo().getName()); item.setProductName(item.getProductInfo().getName());
item.setSignedQuantity(0); item.setSignedQuantity(0);
item.setSignedTotal(0); item.setSignedTotal(0);
...@@ -342,6 +353,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -342,6 +353,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
updateInfo.setOrderRemark(orderRemark); updateInfo.setOrderRemark(orderRemark);
customerOrderMapper.updateById(updateInfo); customerOrderMapper.updateById(updateInfo);
// 标记销售订单状态取消
saleOrderMapper.update(Wrappers.<ErpSaleOrderDO>lambdaUpdate()
.eq(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.CANCEL.getType())
.eq(ErpSaleOrderDO::getCustomerOrderId, customerOrder.getId()));
// 订单记录 // 订单记录
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent(); CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(CustomerOrderStatus.CANCEL); event.setOrderStatus(CustomerOrderStatus.CANCEL);
...@@ -500,6 +516,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -500,6 +516,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnSaveReqVO.setCustomerOrderId(customerOrder.getId()); returnSaveReqVO.setCustomerOrderId(customerOrder.getId());
returnSaveReqVO.setRemark(reqVO.getRemark()); returnSaveReqVO.setRemark(reqVO.getRemark());
returnSaveReqVO.setFilesUrl(reqVO.getRemarkFiles()); returnSaveReqVO.setFilesUrl(reqVO.getRemarkFiles());
returnSaveReqVO.setWarehouseId(saleOrderDO.getWarehouseId());
returnSaveReqVO.setWarehouseAreaId(saleOrderDO.getWarehouseAreaId());
returnSaveReqVO.setWarehouseInfo(saleOrderDO.getWarehouseInfo());
returnSaveReqVO.setAddressId(saleOrderDO.getAddressId());
returnSaveReqVO.setAddressInfo(saleOrderDO.getAddressInfo());
List<ErpSaleReturnSaveReqVO.Item> items = new ArrayList<>(reqVO.getOrderItems().size()); List<ErpSaleReturnSaveReqVO.Item> items = new ArrayList<>(reqVO.getOrderItems().size());
for (AppCustomerReturnOrderReqVO.ReturnItems item : reqVO.getOrderItems()) { for (AppCustomerReturnOrderReqVO.ReturnItems item : reqVO.getOrderItems()) {
CustomerOrderItemDO customerOrderItemDO = orderItemMap.get(item.getCustomerOrderItemId()); CustomerOrderItemDO customerOrderItemDO = orderItemMap.get(item.getCustomerOrderItemId());
...@@ -518,6 +539,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -518,6 +539,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnItem.setProductId(item.getProductId()); returnItem.setProductId(item.getProductId());
returnItem.setProductUnit(customerOrderItemDO.getProductInfo().getUnitName()); returnItem.setProductUnit(customerOrderItemDO.getProductInfo().getUnitName());
returnItem.setProductPrice(customerOrderItemDO.getOrderItemPrice()); returnItem.setProductPrice(customerOrderItemDO.getOrderItemPrice());
returnItem.setProductInfo(customerOrderItemDO.getProductInfo());
returnItem.setCount(item.getReturnCount()); returnItem.setCount(item.getReturnCount());
returnItem.setRemark(item.getRemark()); returnItem.setRemark(item.getRemark());
returnItem.setSupplierId(customerOrderItemDO.getSupplierId()); returnItem.setSupplierId(customerOrderItemDO.getSupplierId());
...@@ -757,6 +779,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -757,6 +779,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
@Override @Override
public Map<Long, CustomerOrderDTO> getOrderMap(Collection<Long> orderIds) { public Map<Long, CustomerOrderDTO> getOrderMap(Collection<Long> orderIds) {
if (CommonUtil.isEmpty(orderIds)) {
return new HashMap<>();
}
List<CustomerOrderDO> customerOrders = customerOrderMapper.selectByIds(orderIds); List<CustomerOrderDO> customerOrders = customerOrderMapper.selectByIds(orderIds);
return CommonUtil.listConvertMap(BeanUtils.toBean(customerOrders, CustomerOrderDTO.class), CustomerOrderDTO::getId); return CommonUtil.listConvertMap(BeanUtils.toBean(customerOrders, CustomerOrderDTO.class), CustomerOrderDTO::getId);
} }
......
...@@ -11,6 +11,8 @@ import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO; ...@@ -11,6 +11,8 @@ import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService; import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.scoringweight.ScoringWeightDO; import cn.iocoder.foodnexus.module.operations.dal.dataobject.scoringweight.ScoringWeightDO;
import cn.iocoder.foodnexus.module.operations.service.scoringweight.ScoringWeightService; import cn.iocoder.foodnexus.module.operations.service.scoringweight.ScoringWeightService;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.mysql.customerorder.CustomerOrderMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -56,6 +58,9 @@ public class OrderScoreServiceImpl implements OrderScoreService { ...@@ -56,6 +58,9 @@ public class OrderScoreServiceImpl implements OrderScoreService {
@Autowired @Autowired
private ScoringWeightService scoringWeightService; private ScoringWeightService scoringWeightService;
@Autowired
private CustomerOrderMapper customerOrderMapper;
@Override @Override
public Long createScore(OrderScoreSaveReqVO createReqVO) { public Long createScore(OrderScoreSaveReqVO createReqVO) {
// 插入 // 插入
...@@ -187,11 +192,15 @@ public class OrderScoreServiceImpl implements OrderScoreService { ...@@ -187,11 +192,15 @@ public class OrderScoreServiceImpl implements OrderScoreService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteByOrderId(Long orderId) { public Boolean deleteByOrderId(Long orderId) {
if (!scoreMapper.exists(Wrappers.<OrderScoreDO>lambdaQuery() if (!scoreMapper.exists(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId))) { .eq(OrderScoreDO::getOrderId, orderId))) {
return Boolean.FALSE; return Boolean.FALSE;
} }
customerOrderMapper.update(Wrappers.<CustomerOrderDO>lambdaUpdate()
.set(CustomerOrderDO::getHasScore, Boolean.FALSE)
.eq(CustomerOrderDO::getId, orderId));
return scoreMapper.delete(Wrappers.<OrderScoreDO>lambdaQuery() return scoreMapper.delete(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId)) > 0; .eq(OrderScoreDO::getOrderId, orderId)) > 0;
} }
......
...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart; ...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart;
import java.util.*; import java.util.*;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartPageReqVO; import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveBatchReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveReqVO; import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveReqVO;
import jakarta.validation.*; import jakarta.validation.*;
import cn.iocoder.foodnexus.module.order.dal.dataobject.shoppingcart.ShoppingCartDO; import cn.iocoder.foodnexus.module.order.dal.dataobject.shoppingcart.ShoppingCartDO;
...@@ -23,6 +24,8 @@ public interface ShoppingCartService { ...@@ -23,6 +24,8 @@ public interface ShoppingCartService {
*/ */
Long createShoppingCart(@Valid ShoppingCartSaveReqVO createReqVO); Long createShoppingCart(@Valid ShoppingCartSaveReqVO createReqVO);
void createBatch(@Valid ShoppingCartSaveBatchReqVO createReqVO);
/** /**
* 更新购物车 * 更新购物车
* *
......
...@@ -2,10 +2,12 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart; ...@@ -2,10 +2,12 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartPageReqVO; import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveBatchReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveReqVO; import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.*; import java.util.*;
...@@ -54,6 +56,14 @@ public class ShoppingCartServiceImpl implements ShoppingCartService { ...@@ -54,6 +56,14 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void createBatch(ShoppingCartSaveBatchReqVO createReqVO) {
for (ShoppingCartSaveReqVO item : createReqVO.getItems()) {
this.createShoppingCart(item);
}
}
@Override
public void updateShoppingCart(ShoppingCartSaveReqVO updateReqVO) { public void updateShoppingCart(ShoppingCartSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateShoppingCartExists(updateReqVO.getId()); validateShoppingCartExists(updateReqVO.getId());
......
...@@ -5,9 +5,7 @@ import cn.iocoder.foodnexus.module.product.controller.admin.category.vo.ProductC ...@@ -5,9 +5,7 @@ import cn.iocoder.foodnexus.module.product.controller.admin.category.vo.ProductC
import cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Optional;
/** /**
* 商品分类 Service 接口 * 商品分类 Service 接口
...@@ -98,4 +96,6 @@ public interface ProductCategoryService { ...@@ -98,4 +96,6 @@ public interface ProductCategoryService {
return Optional.ofNullable(this.getCategory(categoryId)) return Optional.ofNullable(this.getCategory(categoryId))
.map(ProductCategoryDO::getName).orElse(""); .map(ProductCategoryDO::getName).orElse("");
} }
Map<Long, String> getMap(Set<Long> productIds);
} }
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.product.service.category; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.product.service.category;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.enums.CommonStatusEnum; import cn.iocoder.foodnexus.framework.common.enums.CommonStatusEnum;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils; import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.module.product.controller.admin.category.vo.ProductCategoryListReqVO; import cn.iocoder.foodnexus.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
...@@ -14,10 +15,7 @@ import org.springframework.context.annotation.Lazy; ...@@ -14,10 +15,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; import static cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
...@@ -130,6 +128,14 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { ...@@ -130,6 +128,14 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
} }
@Override @Override
public Map<Long, String> getMap(Set<Long> ids) {
if (CommonUtil.isEmpty(ids)) {
return new HashMap<>(1);
}
return CommonUtil.listConvertMap(productCategoryMapper.selectList(ProductCategoryDO::getId, ids), ProductCategoryDO::getId, ProductCategoryDO::getName);
}
@Override
public ProductCategoryDO getCategory(Long id) { public ProductCategoryDO getCategory(Long id) {
return productCategoryMapper.selectById(id); return productCategoryMapper.selectById(id);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment