Commit 3f4e305f by 杨浩

销售订单退款

parent b3ea9f0a
......@@ -13,23 +13,22 @@ import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockService;
import cn.iocoder.foodnexus.module.order.api.CheckTaskApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
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.system.annotations.AppSystemAuth;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
......@@ -40,18 +39,13 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
......@@ -60,7 +54,6 @@ import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUt
@Tag(name = "管理后台 - ERP 采购订单")
@RestController
@RequestMapping("/erp/purchase-order")
@Validated
public class ErpPurchaseOrderController {
......@@ -68,8 +61,6 @@ public class ErpPurchaseOrderController {
private ErpPurchaseOrderService purchaseOrderService;
@Resource
private ErpSupplierService supplierService;
@Autowired
private ProductSpuService productService;
@Resource
private AdminUserApi adminUserApi;
......@@ -80,7 +71,13 @@ public class ErpPurchaseOrderController {
@Autowired
private ErpCustomerApi customerApi;
@GetMapping("/get")
@Autowired
private ErpSupplierApi supplierApi;
@Autowired
private CheckTaskApi checkTaskApi;
@GetMapping("/erp/purchase-order/get")
@Operation(summary = "获得采购订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:purchase-order:query')")
......@@ -92,7 +89,7 @@ public class ErpPurchaseOrderController {
return success(buildPurchaseOrderVOPageResult(CommonUtil.asList(purchaseOrder), true).get(0));
}
@GetMapping("/page")
@GetMapping("/erp/purchase-order/page")
@Operation(summary = "获得采购订单分页")
@PreAuthorize("@ss.hasPermission('erp:purchase-order:query')")
public CommonResult<PageResult<ErpPurchaseOrderRespVO>> getPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) {
......@@ -100,7 +97,7 @@ public class ErpPurchaseOrderController {
return success(new PageResult<>(buildPurchaseOrderVOPageResult(pageResult.getList(), false), pageResult.getTotal()));
}
@PostMapping("/arrival")
@PostMapping("/erp/purchase-order/arrival")
@Operation(summary = "到货")
@Parameter(name = "ids", description = "编号", required = true)
public CommonResult<Boolean> arrival(@RequestParam("ids") List<Long> ids) {
......@@ -109,7 +106,7 @@ public class ErpPurchaseOrderController {
return success(Boolean.TRUE);
}
@GetMapping("/export-excel")
@GetMapping("/erp/purchase-order/export-excel")
@Operation(summary = "导出采购订单 Excel")
@PreAuthorize("@ss.hasPermission('erp:purchase-order:export')")
@ApiAccessLog(operateType = EXPORT)
......@@ -121,6 +118,58 @@ public class ErpPurchaseOrderController {
ExcelUtils.write(response, "采购订单.xls", "数据", ErpPurchaseOrderRespVO.class, list);
}
/* ----- 供应商接口 ----- */
@GetMapping("/supplier/purchase-order/get")
@Operation(summary = "获得采购订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<ErpPurchaseOrderRespVO> supplierGetPurchaseOrder(@RequestParam("id") Long id) {
ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(id);
if (purchaseOrder == null) {
return success(null);
}
return success(buildPurchaseOrderVOPageResult(CommonUtil.asList(purchaseOrder), true).get(0));
}
@GetMapping("/supplier/purchase-order/page")
@Operation(summary = "获得采购订单分页")
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<PageResult<ErpPurchaseOrderRespVO>> supplierGetPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) {
pageReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(pageReqVO);
return success(new PageResult<>(buildPurchaseOrderVOPageResult(pageResult.getList(), false), pageResult.getTotal()));
}
@GetMapping("/supplier/purchase-ordercount")
@Operation(summary = "根据配送状态统计数量")
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<Map<String, Long>> supplierQueryCount(@Valid ErpPurchaseOrderPageReqVO pageReqVO) {
pageReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
return success(purchaseOrderService.queryCountByDeliveryStatus(pageReqVO));
}
@PostMapping("/supplier/purchase-order/accepting-orders")
@Operation(summary = "接单")
@Parameter(name = "ids", description = "编号", required = true)
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<Boolean> supplierAcceptingOrders(@RequestParam("ids") List<Long> ids) {
purchaseOrderService.delivery(ids, supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()),
ErpDeliveryStatus.MATCHED, ErpDeliveryStatus.NOT_YET, CustomerOrderStatus.SUPPLIER_ACCEPT_ORDER);
return success(Boolean.TRUE);
}
@PostMapping("/supplier/purchase-order/delivery")
@Operation(summary = "发货")
@Parameter(name = "ids", description = "编号", required = true)
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<Boolean> supplierPurchaseOrderDelivery(@RequestParam("ids") List<Long> ids) {
purchaseOrderService.delivery(ids, supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()),
ErpDeliveryStatus.NOT_YET, ErpDeliveryStatus.ALREADY, CustomerOrderStatus.SUPPLIER_SHIP);
return success(Boolean.TRUE);
}
private List<ErpPurchaseOrderRespVO> buildPurchaseOrderVOPageResult(List<ErpPurchaseOrderDO> list, boolean isDetails) {
if (CollUtil.isEmpty(list)) {
return new ArrayList<>();
......@@ -130,8 +179,9 @@ public class ErpPurchaseOrderController {
convertSet(list, ErpPurchaseOrderDO::getId));
Map<Long, List<ErpPurchaseOrderItemDO>> purchaseOrderItemMap = convertMultiMap(purchaseOrderItemList, ErpPurchaseOrderItemDO::getOrderId);
// 1.2 产品信息
Map<Long, ProductSpuDO> productMap = productService.getProductVOMap(
convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId));
// Set<Long> productIds = convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId);
// Map<Long, ProductSpuDO> productMap = productService.getProductVOMap(productIds);
// Map<Long, String> categoryMap = productCategoryService.getMap(CommonUtil.listConvertSet(productMap.values(), ProductSpuDO::getCategoryId));
// 1.3 供应商信息
Map<Long, ErpSupplierDO> supplierMap = supplierService.getSupplierMap(
convertSet(list, ErpPurchaseOrderDO::getSupplierId));
......@@ -141,27 +191,30 @@ public class ErpPurchaseOrderController {
Map<Long, CustomerOrderDTO> customerOrderMap = customerOrderApi.getOrderMap(
convertSet(list, ErpPurchaseOrderDO::getCustomerOrderId));
Map<Long, CustomerOrderItemDTO> customerOrderItemMap;
if (isDetails) {
Map<Long, String> checkResultMap;
List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(purchaseOrderItemList, ErpPurchaseOrderItemDO::getCustomerOrderItemId));
customerOrderItemMap = CommonUtil.listConvertMap(customerOrderItems, CustomerOrderItemDTO::getId);
if (isDetails) {
checkResultMap = checkTaskApi.getCheckResultMapByPurchaseOrderItemIds(CommonUtil.listConvertSet(purchaseOrderItemList,
ErpPurchaseOrderItemDO::getId));
// TODO 退款待定
} else {
customerOrderItemMap = new HashMap<>();
checkResultMap = new HashMap<>();
}
// 2. 开始拼接
return BeanUtils.toBean(list, ErpPurchaseOrderRespVO.class, purchaseOrder -> {
purchaseOrder.setItems(BeanUtils.toBean(purchaseOrderItemMap.get(purchaseOrder.getId()), ErpPurchaseOrderRespVO.Item.class,
item -> {
MapUtils.findAndThen(productMap, item.getProductId(), product -> {
item.setProductInfo(BeanUtils.toBean(product, ProductInfo.class));
});
if (isDetails) {
MapUtils.findAndThen(customerOrderItemMap, item.getCustomerOrderItemId(), customerOrderItem -> {
item.setSignedQuantity(customerOrderItem.getSignedQuantity());
item.setSignedTotal(customerOrderItem.getSignedTotal());
item.setProductInfo(customerOrderItem.getProductInfo());
});
}
}));
purchaseOrder.setProductNames(CollUtil.join(purchaseOrder.getItems(), ",", item -> item.getProductInfo().getName()));
if (isDetails) {
MapUtils.findAndThen(checkResultMap, item.getId(), item::setCheckResult);
}}));
purchaseOrder.setProductNames(CollUtil.join(purchaseOrder.getItems(), ",", item ->
Optional.ofNullable(item.getProductInfo()).map(ProductInfo::getName).orElse("")));
MapUtils.findAndThen(supplierMap, purchaseOrder.getSupplierId(), supplier -> purchaseOrder.setSupplierName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(purchaseOrder.getCreator()), user -> purchaseOrder.setCreatorName(user.getNickname()));
MapUtils.findAndThen(customerOrderMap, purchaseOrder.getCustomerOrderId(), customerOrder -> {
......@@ -172,6 +225,7 @@ public class ErpPurchaseOrderController {
purchaseOrder.setCustomerId(customerOrder.getCustomerId());
purchaseOrder.setCustomerName(customerApi.queryNameStrById(customerOrder.getCustomerId()));
purchaseOrder.setDeliveryMode(customerOrder.getDeliveryMode());
});
});
}
......
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockService;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import cn.iocoder.foodnexus.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertMultiMap;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertSet;
/**
* @author : yanghao
* create at: 2025/9/23 11:11
* @description: 采购订单
*/
@Tag(name = "供应商 - ERP 采购订单(仓库管理)")
@RestController
@RequestMapping("/supplier/purchase-order")
@Validated
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public class PurchaseOrderController {
@Resource
private ErpPurchaseOrderService purchaseOrderService;
@Resource
private ErpSupplierService supplierService;
@Resource
private AdminUserApi adminUserApi;
@Autowired
private ErpSupplierApi supplierApi;
@Autowired
private ProductSpuService productService;
@Autowired
private CustomerOrderApi customerOrderApi;
@Autowired
private ErpCustomerApi customerApi;
@GetMapping("/get")
@Operation(summary = "获得采购订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<ErpPurchaseOrderRespVO> getPurchaseOrder(@RequestParam("id") Long id) {
ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(id);
if (purchaseOrder == null) {
return success(null);
}
return success(buildPurchaseOrderVOPageResult(CommonUtil.asList(purchaseOrder), true).get(0));
}
@GetMapping("/page")
@Operation(summary = "获得采购订单分页")
public CommonResult<PageResult<ErpPurchaseOrderRespVO>> getPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) {
pageReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(pageReqVO);
return success(new PageResult<>(buildPurchaseOrderVOPageResult(pageResult.getList(), false), pageResult.getTotal()));
}
@GetMapping("count")
@Operation(summary = "根据配送状态统计数量")
public CommonResult<Map<String, Long>> queryCount(@Valid ErpPurchaseOrderPageReqVO pageReqVO) {
pageReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
return success(purchaseOrderService.queryCountByDeliveryStatus(pageReqVO));
}
@PostMapping("/accepting-orders")
@Operation(summary = "接单")
@Parameter(name = "ids", description = "编号", required = true)
public CommonResult<Boolean> acceptingOrders(@RequestParam("ids") List<Long> ids) {
purchaseOrderService.delivery(ids, supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()),
ErpDeliveryStatus.MATCHED, ErpDeliveryStatus.NOT_YET, CustomerOrderStatus.SUPPLIER_ACCEPT_ORDER);
return success(Boolean.TRUE);
}
@PostMapping("/delivery")
@Operation(summary = "发货")
@Parameter(name = "ids", description = "编号", required = true)
public CommonResult<Boolean> purchaseOrderDelivery(@RequestParam("ids") List<Long> ids) {
purchaseOrderService.delivery(ids, supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()),
ErpDeliveryStatus.NOT_YET, ErpDeliveryStatus.ALREADY, CustomerOrderStatus.SUPPLIER_SHIP);
return success(Boolean.TRUE);
}
private List<ErpPurchaseOrderRespVO> buildPurchaseOrderVOPageResult(List<ErpPurchaseOrderDO> list, boolean isDetails) {
if (CollUtil.isEmpty(list)) {
return new ArrayList<>();
}
// 1.1 订单项
List<ErpPurchaseOrderItemDO> purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderIds(
convertSet(list, ErpPurchaseOrderDO::getId));
Map<Long, List<ErpPurchaseOrderItemDO>> purchaseOrderItemMap = convertMultiMap(purchaseOrderItemList, ErpPurchaseOrderItemDO::getOrderId);
// 1.2 产品信息
Map<Long, ProductSpuDO> productMap = productService.getProductVOMap(
convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId));
// 1.3 供应商信息
Map<Long, ErpSupplierDO> supplierMap = supplierService.getSupplierMap(
convertSet(list, ErpPurchaseOrderDO::getSupplierId));
// 1.4 管理员信息
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(list, purchaseOrder -> Long.parseLong(purchaseOrder.getCreator())));
Map<Long, CustomerOrderDTO> customerOrderMap = customerOrderApi.getOrderMap(
convertSet(list, ErpPurchaseOrderDO::getCustomerOrderId));
Map<Long, CustomerOrderItemDTO> customerOrderItemMap;
if (isDetails) {
List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(purchaseOrderItemList, ErpPurchaseOrderItemDO::getCustomerOrderItemId));
customerOrderItemMap = CommonUtil.listConvertMap(customerOrderItems, CustomerOrderItemDTO::getId);
} else {
customerOrderItemMap = new HashMap<>();
}
// 2. 开始拼接
return BeanUtils.toBean(list, ErpPurchaseOrderRespVO.class, purchaseOrder -> {
purchaseOrder.setItems(BeanUtils.toBean(purchaseOrderItemMap.get(purchaseOrder.getId()), ErpPurchaseOrderRespVO.Item.class,
item -> {
MapUtils.findAndThen(productMap, item.getProductId(), product -> {
item.setProductInfo(BeanUtils.toBean(product, ProductInfo.class));
});
if (isDetails) {
MapUtils.findAndThen(customerOrderItemMap, item.getCustomerOrderItemId(), customerOrderItem -> {
item.setSignedQuantity(customerOrderItem.getSignedQuantity());
item.setSignedTotal(customerOrderItem.getSignedTotal());
});
}
}));
purchaseOrder.setProductNames(CollUtil.join(purchaseOrder.getItems(), ",", item -> item.getProductInfo().getName()));
MapUtils.findAndThen(supplierMap, purchaseOrder.getSupplierId(), supplier -> purchaseOrder.setSupplierName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(purchaseOrder.getCreator()), user -> purchaseOrder.setCreatorName(user.getNickname()));
MapUtils.findAndThen(customerOrderMap, purchaseOrder.getCustomerOrderId(), customerOrder -> {
purchaseOrder.setAddressInfo(customerOrder.getAddressInfo());
purchaseOrder.setPlanDeliveryStartTime(customerOrder.getPlanDeliveryStartTime());
purchaseOrder.setPlanDeliveryEndTime(customerOrder.getPlanDeliveryEndTime());
purchaseOrder.setCustomerOrderCode(customerOrder.getCode());
purchaseOrder.setCustomerId(customerOrder.getCustomerId());
purchaseOrder.setCustomerName(customerApi.queryNameStrById(customerOrder.getCustomerId()));
purchaseOrder.setDeliveryMode(customerOrder.getDeliveryMode());
});
});
}
}
......@@ -159,6 +159,9 @@ public class ErpPurchaseOrderRespVO {
@NotNull(message = "产品数量不能为空")
private Integer count;
@Schema(description = "总价,单位:分")
private Integer totalPrice;
@Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent;
......@@ -196,6 +199,15 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "签收总价,单位:分")
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 {
@Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址")
private String fileUrl;
private List<String> filesUrl;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
......@@ -110,7 +110,7 @@ public class ErpPurchaseReturnRespVO {
private Long productId;
@Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
private Long productUnitId;
private String productUnit;
@Schema(description = "产品单价", example = "100.00")
private BigDecimal productPrice;
......
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 jakarta.validation.constraints.NotNull;
import lombok.Data;
......@@ -26,18 +32,41 @@ public class ErpPurchaseReturnSaveReqVO {
@NotNull(message = "采购订单编号不能为空")
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")
private String fileUrl;
private List<String> filesUrl;
@Schema(description = "备注", example = "你猜")
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 = "退货清单列表")
private List<Item> items;
......@@ -61,21 +90,21 @@ public class ErpPurchaseReturnSaveReqVO {
@Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
@NotNull(message = "产品单位单位不能为空")
private Long productUnitId;
private String productUnit;
@Schema(description = "产品单价", example = "100.00")
private BigDecimal productPrice;
private Integer productPrice;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空")
private BigDecimal count;
@Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent;
private Integer count;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "商品信息")
private ProductInfo productInfo;
}
}
\ No newline at end of file
......@@ -5,20 +5,33 @@ import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
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.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.ErpSaleOrderRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
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.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.service.product.ErpProductService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockService;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO;
import cn.iocoder.foodnexus.module.order.dto.DeliveryStaffSimpleInfo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
......@@ -29,6 +42,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -37,6 +52,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
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.common.pojo.CommonResult.success;
......@@ -61,6 +77,18 @@ public class ErpSaleOrderController {
@Resource
private AdminUserApi adminUserApi;
@Autowired
private DeliveryStaffApi deliveryStaffApi;
@Autowired
private CustomerOrderApi customerOrderApi;
@Autowired
private ErpPurchaseOrderService purchaseOrderService;
@Autowired
private ErpSupplierApi supplierApi;
@PostMapping("/create")
@Operation(summary = "创建销售订单")
@PreAuthorize("@ss.hasPermission('erp:sale-out:create')")
......@@ -122,15 +150,26 @@ public class ErpSaleOrderController {
return success(null);
}
List<ErpSaleOrderItemDO> saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderId(id);
Map<Long, ProductSpuDO> productMap = productService.getProductVOMap(
convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId));
return success(BeanUtils.toBean(saleOrder, ErpSaleOrderRespVO.class, saleOrderVO ->
List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(saleOrderItemList, ErpSaleOrderItemDO::getCustomerOrderItemId));
Map<Long, CustomerOrderItemDTO> customerOrderItemMap = CommonUtil.listConvertMap(customerOrderItems, CustomerOrderItemDTO::getId);
Map<Long, ErpPurchaseOrderDO> purchaseOrderMap = purchaseOrderService.getMap(CommonUtil.listConvert(saleOrderItemList, ErpSaleOrderItemDO::getPurchaseOrderId));
Map<Long, String> supplierMap = supplierApi.queryNameMapByIds(CommonUtil.listConvertSet(saleOrderItemList, ErpSaleOrderItemDO::getSupplierId));
return success(BeanUtils.toBean(saleOrder, ErpSaleOrderRespVO.class, saleOrderVO -> {
saleOrderVO.setCustomerOrderCode(
Optional.ofNullable(customerOrderApi.queryById(saleOrderVO.getCustomerOrderId())).map(CustomerOrderDTO::getCode).orElse(""));
if (CommonUtil.isNotEmpty(saleOrderVO.getDeliveryStaffId())) {
saleOrderVO.setDeliveryStaffInfo(deliveryStaffApi.querybyStaffId(saleOrderVO.getDeliveryStaffId()));
}
saleOrderVO.setItems(BeanUtils.toBean(saleOrderItemList, ErpSaleOrderRespVO.Item.class, item -> {
MapUtils.findAndThen(supplierMap, item.getSupplierId(), item::setSupplierName);
MapUtils.findAndThen(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder ->
item.setPurchaseOrderNo(purchaseOrder.getNo()));
BigDecimal stockCount = stockService.getStockCount(item.getProductId());
item.setStockCount(stockCount != null ? stockCount : BigDecimal.ZERO);
MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductUnitName(product.getUnitName()));
}))));
MapUtils.findAndThen(customerOrderItemMap, item.getCustomerOrderItemId(), customerOrderItem ->
item.setProductInfo(customerOrderItem.getProductInfo()));
}));}
));
}
@GetMapping("/page")
......@@ -161,23 +200,46 @@ public class ErpSaleOrderController {
List<ErpSaleOrderItemDO> saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderIds(
convertSet(pageResult.getList(), ErpSaleOrderDO::getId));
Map<Long, List<ErpSaleOrderItemDO>> saleOrderItemMap = convertMultiMap(saleOrderItemList, ErpSaleOrderItemDO::getOrderId);
// 1.2 产品信息
Map<Long, ProductSpuDO> productMap = productService.getProductVOMap(
convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId));
// 1.3 客户信息
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
convertSet(pageResult.getList(), ErpSaleOrderDO::getCustomerId));
// 1.4 管理员信息
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(pageResult.getList(), saleOrder -> Long.parseLong(saleOrder.getCreator())));
// 配送人员
Map<Long, DeliveryStaffSimpleInfo> staffMap = deliveryStaffApi.getMap(CommonUtil.listConvertSet(pageResult.getList(), ErpSaleOrderDO::getDeliveryStaffId));
// 客户订单编号
Map<Long, CustomerOrderDTO> orderMap = customerOrderApi.getOrderMap(CommonUtil.listConvert(pageResult.getList(), ErpSaleOrderDO::getCustomerOrderId));
List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(saleOrderItemList, ErpSaleOrderItemDO::getCustomerOrderItemId));
Map<Long, CustomerOrderItemDTO> customerOrderItemMap = CommonUtil.listConvertMap(customerOrderItems, CustomerOrderItemDTO::getId);
Map<Long, ErpPurchaseOrderDO> purchaseOrderMap = purchaseOrderService.getMap(CommonUtil.listConvert(saleOrderItemList, ErpSaleOrderItemDO::getPurchaseOrderId));
Map<Long, String> supplierMap = supplierApi.queryNameMapByIds(CommonUtil.listConvertSet(saleOrderItemList, ErpSaleOrderItemDO::getSupplierId));
final String pickUpStatusDetails = "已到%s 已拣%s 共%s";
// 2. 开始拼接
return BeanUtils.toBean(pageResult, ErpSaleOrderRespVO.class, saleOrder -> {
saleOrder.setItems(BeanUtils.toBean(saleOrderItemMap.get(saleOrder.getId()), ErpSaleOrderRespVO.Item.class,
item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductUnitName(product.getUnitName()))));
saleOrder.setProductNames(CollUtil.join(saleOrder.getItems(), ",", ErpSaleOrderRespVO.Item::getProductName));
saleOrder.setItems(BeanUtils.toBean(saleOrderItemMap.get(saleOrder.getId()), ErpSaleOrderRespVO.Item.class, item -> {
MapUtils.findAndThen(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder ->
item.setPurchaseOrderNo(purchaseOrder.getNo()));
MapUtils.findAndThen(customerOrderItemMap, item.getCustomerOrderItemId(), customerOrderItem ->
item.setProductInfo(customerOrderItem.getProductInfo()));
MapUtils.findAndThen(supplierMap, item.getSupplierId(), item::setSupplierName);
}));
saleOrder.setProductNames(CollUtil.join(saleOrder.getItems(), ",", item ->
Optional.ofNullable(item.getProductInfo()).map(ProductInfo::getName).orElse("")));
MapUtils.findAndThen(customerMap, saleOrder.getCustomerId(), supplier -> saleOrder.setCustomerName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(saleOrder.getCreator()), user -> saleOrder.setCreatorName(user.getNickname()));
MapUtils.findAndThen(staffMap, saleOrder.getDeliveryStaffId(), saleOrder::setDeliveryStaffInfo);
MapUtils.findAndThen(orderMap, saleOrder.getCustomerOrderId(), order -> saleOrder.setCustomerOrderCode(order.getCode()));
saleOrder.setPickUpStatusDetails(String.format(pickUpStatusDetails,
Optional.ofNullable(saleOrder.getItems()).orElse(Lists.newArrayList()).stream().filter(item -> SaleOrderPickUpStatus.ARRIVAL.equals(item.getPickUpStatus())).count(),
Optional.ofNullable(saleOrder.getItems()).orElse(Lists.newArrayList()).stream().filter(item -> !SaleOrderPickUpStatus.TO_BE.equals(item.getPickUpStatus())).count(),
Optional.ofNullable(saleOrder.getItems()).orElse(Lists.newArrayList()).size()
));
});
}
......
......@@ -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.ErpSaleReturnService;
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.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
......@@ -36,6 +37,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
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.common.pojo.CommonResult.success;
......@@ -53,8 +55,6 @@ public class ErpSaleReturnController {
@Resource
private ErpStockService stockService;
@Resource
private ErpProductService productService;
@Resource
private ErpCustomerService customerService;
@Resource
......@@ -76,7 +76,7 @@ public class ErpSaleReturnController {
}
@PutMapping("/update-status")
@Operation(summary = "更新销售退货的状态")
@Operation(summary = "更新销售退货的状态(确认退货)")
@PreAuthorize("@ss.hasPermission('erp:sale-return:update-status')")
public CommonResult<Boolean> updateSaleReturnStatus(@RequestParam("id") Long id,
@RequestParam("status") Integer status) {
......@@ -103,14 +103,10 @@ public class ErpSaleReturnController {
return success(null);
}
List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnId(id);
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId));
return success(BeanUtils.toBean(saleReturn, ErpSaleReturnRespVO.class, saleReturnVO ->
saleReturnVO.setItems(BeanUtils.toBean(saleReturnItemList, ErpSaleReturnRespVO.Item.class, item -> {
ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId());
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 {
List<ErpSaleReturnItemDO> saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnIds(
convertSet(pageResult.getList(), ErpSaleReturnDO::getId));
Map<Long, List<ErpSaleReturnItemDO>> saleReturnItemMap = convertMultiMap(saleReturnItemList, ErpSaleReturnItemDO::getReturnId);
// 1.2 产品信息
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId));
// 1.3 客户信息
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId));
......@@ -153,10 +146,9 @@ public class ErpSaleReturnController {
convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator())));
// 2. 开始拼接
return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> {
saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class,
item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()))));
saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", ErpSaleReturnRespVO.Item::getProductName));
saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class));
saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", item ->
Optional.ofNullable(item.getProductInfo()).map(ProductInfo::getName).orElse("")));
MapUtils.findAndThen(customerMap, saleReturn.getCustomerId(), supplier -> saleReturn.setCustomerName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(saleReturn.getCreator()), user -> saleReturn.setCreatorName(user.getNickname()));
});
......
......@@ -12,8 +12,8 @@ import lombok.Data;
@Data
public class DeliveryStatusCountRespVO {
@Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "0-待接单 1-待配送 2-配送中")
private Integer type;
@Schema(description = "对应订单数")
private Long count;
......
......@@ -91,6 +91,9 @@ public class ErpSaleOrderPageReqVO extends PageParam {
@Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "拣货状态list")
private List<String> pickUpStatusList;
@Schema(description = "接单时间段")
private LocalDateTime[] acceptTime;
......
......@@ -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.enums.SaleOrderPickUpStatus;
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.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;
......@@ -109,6 +111,9 @@ public class ErpSaleOrderRespVO {
@Schema(description = "客户订单id")
private Long customerOrderId;
@Schema(description = "客户订单编号")
private String customerOrderCode;
@Schema(description = "配送模式")
private DeliveryMode deliveryMode;
......@@ -127,6 +132,12 @@ public class ErpSaleOrderRespVO {
@Schema(description = "配送人员")
private Long deliveryStaffId;
@Schema(description = "退货配送人员")
private Long returnsDeliveryStaffId;
@Schema(description = "配送人员信息")
private DeliveryStaffSimpleInfo deliveryStaffInfo;
@Schema(description = "客户收货地址id")
private Long addressId;
......@@ -154,12 +165,23 @@ public class ErpSaleOrderRespVO {
@Schema(description = "预计配送结束时间")
private LocalDateTime planDeliveryEndTime;
/* ---- 额外字段 ---- */
@Schema(description = "检获状态进度")
private String pickUpStatusDetails;
/* ---- 额外字段 END---- */
@Data
public static class Item {
@Schema(description = "订单项编号", example = "11756")
private Long id;
@Schema(description = "客户订单子项id")
private Long customerOrderItemId;
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
private Long productId;
......@@ -173,6 +195,9 @@ public class ErpSaleOrderRespVO {
@NotNull(message = "产品数量不能为空")
private Integer count;
@Schema(description = "总价")
private Integer totalPrice;
@Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent;
......@@ -194,12 +219,8 @@ public class ErpSaleOrderRespVO {
// ========== 关联字段 ==========
@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 = "商品信息")
private ProductInfo productInfo;
@Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用
......@@ -208,9 +229,19 @@ public class ErpSaleOrderRespVO {
private Long purchaseOrderId;
@Schema(description = "供应商id")
private Long supplierId;
@Schema(description = "拣货状态")
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 {
@Schema(description = "拣货状态")
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;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
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 jakarta.validation.constraints.NotNull;
import lombok.Data;
......@@ -97,6 +102,37 @@ public class ErpSaleReturnRespVO {
@ExcelProperty("产品信息")
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
public static class Item {
......@@ -118,6 +154,9 @@ public class ErpSaleReturnRespVO {
@Schema(description = "产品单价", example = "100.00")
private Integer productPrice;
@Schema(description = "商品信息")
private ProductInfo productInfo;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空")
private Integer count;
......@@ -131,15 +170,6 @@ public class ErpSaleReturnRespVO {
@Schema(description = "备注", example = "随便")
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")
private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用
......
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 jakarta.validation.constraints.NotNull;
import lombok.Data;
......@@ -47,6 +52,25 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "备注", example = "你猜")
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 = "退货清单列表")
private List<Item> items;
......@@ -78,6 +102,9 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "产品单价", example = "100.00")
private Integer productPrice;
@Schema(description = "商品信息")
private ProductInfo productInfo;
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空")
private Integer count;
......
......@@ -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.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.order.dto.CustomerAddressInfo;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* ERP 采购退货 DO
*
* @author 芋道源码
*/
@TableName(value = "erp_purchase_return")
@TableName(value = "erp_purchase_return", autoResultMap = true)
@KeySequence("erp_purchase_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
......@@ -114,10 +120,57 @@ public class ErpPurchaseReturnDO extends BaseDO {
/**
* 附件地址
*/
private String fileUrl;
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> filesUrl;
/**
* 备注
*/
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;
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.stock.ErpWarehouseDO;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.math.BigDecimal;
......@@ -57,10 +60,8 @@ public class ErpPurchaseReturnItemDO extends BaseDO {
private Long productId;
/**
* 产品单位单位
*
* 冗余 {@link ErpProductDO#getUnitId()}
*/
private Long productUnitId;
private String productUnit;
/**
* 产品单位单价,单位:分
......@@ -92,4 +93,9 @@ public class ErpPurchaseReturnItemDO extends BaseDO {
*/
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 {
private Long deliveryStaffId;
/**
* 退货配送人员
*/
private Long returnsDeliveryStaffId;
/**
* 客户收货地址id
*/
private Long addressId;
......
......@@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* ERP 销售订单项 DO
......@@ -109,4 +110,14 @@ public class ErpSaleOrderItemDO extends BaseDO {
*/
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;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
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.order.dto.CustomerAddressInfo;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
......@@ -136,4 +139,59 @@ public class ErpSaleReturnDO extends BaseDO {
*/
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;
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.stock.ErpWarehouseDO;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.math.BigDecimal;
......@@ -15,7 +18,7 @@ import java.math.BigDecimal;
*
* @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 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
......@@ -99,4 +102,10 @@ public class ErpSaleReturnItemDO extends BaseDO {
*/
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;
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.query.MPJLambdaWrapperX;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.order.DeliveryMyCountRespVO;
......@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.query.MPJQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Objects;
import java.util.Set;
......@@ -33,12 +35,19 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
.eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus())
.likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator())
.eqIfPresent(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId())
// .eqIfPresent(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId())
.betweenIfPresent(ErpSaleOrderDO::getAcceptTime, reqVO.getAcceptTime())
.eqIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatus())
.inIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatusList())
.eqIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptId())
.inIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptIds())
.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 错误
if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_NONE)) {
query.eq(ErpSaleOrderDO::getOutCount, 0);
......@@ -91,15 +100,15 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
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()
.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()
.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;
import cn.iocoder.foodnexus.framework.common.core.ArrayValuable;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
......@@ -17,6 +16,8 @@ import java.util.Arrays;
@Getter
public enum SaleOrderPickUpStatus implements ArrayValuable<String> {
CANCEL("CANCEL", "取消"),
TO_BE("TO_BE", "待拣"),
PICK_UP("PICK_UP", "待接单"),
......@@ -29,6 +30,24 @@ public enum SaleOrderPickUpStatus implements ArrayValuable<String> {
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);
......
......@@ -95,6 +95,8 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
// 3. 更新采购订单的入库数量
updatePurchaseOrderInCount(createReqVO.getOrderId());
this.updatePurchaseInStatus(purchaseIn.getId(), ErpAuditStatus.APPROVE.getStatus());
return purchaseIn.getId();
}
......
......@@ -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.stock.ErpStockRecordService;
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 org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
......@@ -56,13 +58,11 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
private ErpNoRedisDAO noRedisDAO;
@Resource
private ErpProductService productService;
private ProductSpuService productService;
@Resource
@Lazy // 延迟加载,避免循环依赖
private ErpPurchaseOrderService purchaseOrderService;
@Resource
private ErpAccountService accountService;
@Resource
private ErpStockRecordService stockRecordService;
@Override
......@@ -73,7 +73,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
// 1.2 校验退货项的有效性
List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems());
// 1.3 校验结算账户
accountService.validateAccount(createReqVO.getAccountId());
/*accountService.validateAccount(createReqVO.getAccountId());*/
// 1.4 生成退货单号,并校验唯一性
String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX);
if (purchaseReturnMapper.selectByNo(no) != null) {
......@@ -106,7 +106,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
// 1.2 校验采购订单已审核
ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId());
// 1.3 校验结算账户
accountService.validateAccount(updateReqVO.getAccountId());
/*accountService.validateAccount(updateReqVO.getAccountId());*/
// 1.4 校验订单项的有效性
List<ErpPurchaseReturnItemDO> purchaseReturnItems = validatePurchaseReturnItems(updateReqVO.getItems());
......@@ -197,12 +197,12 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
private List<ErpPurchaseReturnItemDO> validatePurchaseReturnItems(List<ErpPurchaseReturnSaveReqVO.Item> list) {
// 1. 校验产品存在
List<ErpProductDO> productList = productService.validProductList(
List<ProductSpuDO> productList = productService.validProductList(
convertSet(list, ErpPurchaseReturnSaveReqVO.Item::getProductId));
Map<Long, ErpProductDO> productMap = convertMap(productList, ErpProductDO::getId);
Map<Long, ProductSpuDO> productMap = convertMap(productList, ProductSpuDO::getId);
// 2. 转化为 ErpPurchaseReturnItemDO 列表
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()));
if (item.getTotalPrice() == null) {
return;
......
......@@ -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.controller.admin.sale.vo.order.*;
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.ErpSaleOrderItemDO;
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.mysql.purchase.ErpPurchaseOrderMapper;
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.ErpSaleOutItemMapper;
......@@ -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.enums.SaleOrderPickUpStatus;
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.CustomerOrderRecordApi;
import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi;
......@@ -30,6 +33,7 @@ import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -90,6 +94,9 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
@Autowired
private ErpSaleOutItemMapper saleOutItemMapper;
@Autowired
private ErpPurchaseOrderMapper purchaseOrderMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) {
......@@ -113,7 +120,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
// 2.1 插入订单
ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class, in -> in
.setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()));
.setNo(no).setStatus(ErpAuditStatus.APPROVE.getStatus()));
calculateTotalPrice(saleOrder, saleOrderItems);
saleOrderMapper.insert(saleOrder);
// 2.2 插入订单项
......@@ -360,10 +367,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
CustomerOrderDTO customerOrder = customerOrderApi.queryById(saleOrder.getCustomerOrderId());
saleOrderItemMapper.update(Wrappers.<ErpSaleOrderItemDO>lambdaUpdate()
.set(ErpSaleOrderItemDO::getPickUpTime, LocalDateTime.now())
.set(ErpSaleOrderItemDO::getPickUpStatus, SaleOrderPickUpStatus.PICK_UP.getType())
.eq(ErpSaleOrderItemDO::getId, itemId));
Long allCount = saleOrderItemMapper.selectCount(ErpSaleOrderItemDO::getOrderId, saleOrder.getId());
Long pickUpCount = saleOrderItemMapper.selectCount(Wrappers.<ErpSaleOrderItemDO>lambdaQuery()
.eq(ErpSaleOrderItemDO::getOrderId, saleOrder.getId())
......@@ -606,6 +613,10 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
item.setCount(orderItem.getOrderItemQuantity());
item.setSupplierId(orderItem.getSupplierId());
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;
}));
this.createSaleOrder(saveReqVO);
......@@ -651,13 +662,24 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
@Override
public List<DeliveryStatusCountRespVO> statusCount(Long userId, Set<Long> deptIds) {
List<DeliveryStatusCountRespVO> result = new ArrayList<>();
for (SaleOrderPickUpStatus status : SaleOrderPickUpStatus.values()) {
for (int type = 0; type < 3;type ++) {
DeliveryStatusCountRespVO count = new DeliveryStatusCountRespVO();
count.setPickUpStatus(status);
if (status.equals(SaleOrderPickUpStatus.PICK_UP) && CommonUtil.isNotEmpty(deptIds)) {
count.setCount(saleOrderMapper.statusCount(status.getType(), deptIds));
} else {
count.setCount(saleOrderMapper.statusCount(status.getType(), userId));
count.setType(type);
switch (type) {
case 0 :
count.setCount(saleOrderMapper.statusCount(CommonUtil.asList(SaleOrderPickUpStatus.PICK_UP.getType(),
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);
}
......
......@@ -106,6 +106,8 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
// 3. 更新销售订单的出库数量
updateSaleOrderOutCount(createReqVO.getOrderId());
this.updateSaleOutStatus(saleOut.getId(), ErpAuditStatus.APPROVE.getStatus());
return saleOut.getId();
}
......
......@@ -104,4 +104,8 @@ public interface ErpSaleReturnService {
* @return
*/
ErpSaleReturnDO queryByCustomerOrderId(Long id);
void accept(Long id, Long deliveryStaffId);
void delivery(Long id, Long deliveryStaffId);
}
\ No newline at end of file
......@@ -2,44 +2,52 @@ package cn.iocoder.foodnexus.module.erp.service.sale;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.foodnexus.framework.common.exception.ServiceException;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleOrderMapper;
import cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO;
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.dal.dataobject.sale.ErpSaleReturnItemDO;
import cn.iocoder.foodnexus.module.erp.dal.mysql.purchase.ErpPurchaseOrderItemMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.purchase.ErpPurchaseOrderMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleReturnItemMapper;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpSaleReturnMapper;
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.enums.stock.ErpStockRecordBizTypeEnum;
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.purchase.ErpPurchaseReturnService;
import cn.iocoder.foodnexus.module.erp.service.stock.ErpStockRecordService;
import cn.iocoder.foodnexus.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import cn.iocoder.foodnexus.module.product.api.ProductSpuApi;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.time.LocalDateTime;
import java.util.*;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.foodnexus.module.erp.enums.ErrorCodeConstants.*;
import static cn.iocoder.foodnexus.module.erp.enums.SaleOrderPickUpStatus.*;
import static cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService.SALE_ORDER_LOCK;
// TODO 芋艿:记录操作日志
......@@ -65,6 +73,8 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
@Resource
@Lazy // 延迟加载,避免循环依赖
private ErpSaleOrderService saleOrderService;
@Autowired
private ErpSaleOrderMapper saleOrderMapper;
@Resource
private ErpAccountService accountService;
@Resource
......@@ -73,6 +83,15 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
@Resource
private AdminUserApi adminUserApi;
@Autowired
private ErpPurchaseReturnService purchaseReturnService;
@Autowired
private ErpPurchaseOrderMapper purchaseOrderMapper;
@Autowired
private ErpPurchaseOrderItemMapper purchaseOrderItemMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createSaleReturn(ErpSaleReturnSaveReqVO createReqVO) {
......@@ -95,6 +114,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
// 2.1 插入退货
ErpSaleReturnDO saleReturn = BeanUtils.toBean(createReqVO, ErpSaleReturnDO.class, in -> in
.setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()))
.setReturnsStatus(SaleOrderPickUpStatus.RETURNS_PROCESS.getType())
.setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId());
calculateTotalPrice(saleReturn, saleReturnItems);
saleReturnMapper.insert(saleReturn);
......@@ -182,7 +202,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
// 2. 更新状态
int updateCount = saleReturnMapper.updateByIdAndStatus(id, saleReturn.getStatus(),
new ErpSaleReturnDO().setStatus(status));
new ErpSaleReturnDO().setStatus(status).setReturnsStatus(RETURNS_APPROVE.getType()));
if (updateCount == 0) {
throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL);
}
......@@ -197,6 +217,51 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
saleReturnItem.getProductId(), saleReturnItem.getWarehouseId(), BigDecimal.valueOf(count),
bizType, saleReturnItem.getReturnId(), saleReturnItem.getId(), saleReturn.getNo()));
});
// 将订单根据供应商拆分成采购退货单
Map<Long, List<ErpSaleReturnItemDO>> returnItemMap = CommonUtil.listConvertListMap(saleReturnItems, ErpSaleReturnItemDO::getSupplierId);
returnItemMap.forEach((supplierId, saleReturnsItems) -> {
List<ErpPurchaseReturnSaveReqVO.Item> purchaseReturnitems = new ArrayList<>();
ErpPurchaseReturnSaveReqVO purchaseReturnSave = new ErpPurchaseReturnSaveReqVO();
purchaseReturnSave.setReturnTime(saleReturn.getReturnTime());
purchaseReturnSave.setSupplierId(supplierId);
ErpPurchaseOrderDO purchaseOrder = purchaseOrderMapper.selectOne(Wrappers.<ErpPurchaseOrderDO>lambdaQuery()
.eq(ErpPurchaseOrderDO::getCustomerOrderId, saleReturn.getCustomerOrderId())
.eq(ErpPurchaseOrderDO::getSupplierId, supplierId)
.last("LIMIT 1"));
Optional.ofNullable(purchaseOrder).orElseThrow(() -> new ServiceException(PURCHASE_ORDER_NOT_EXISTS));
List<ErpPurchaseOrderItemDO> purchaseOrderItems = purchaseOrderItemMapper.selectListByOrderId(purchaseOrder.getId());
Optional.ofNullable(purchaseOrderItems).orElseThrow(() -> new ServiceException(PURCHASE_ORDER_NOT_EXISTS));
purchaseReturnSave.setOrderId(purchaseOrder.getId());
purchaseReturnSave.setFilesUrl(saleReturn.getFilesUrl());
purchaseReturnSave.setRemark(saleReturn.getRemark());
purchaseReturnSave.setReturnsStatus(RETURNS_APPROVE.getType());
purchaseReturnSave.setAddressId(saleReturn.getAddressId());
purchaseReturnSave.setAddressInfo(saleReturn.getAddressInfo());
purchaseReturnSave.setWarehouseId(saleReturn.getWarehouseId());
purchaseReturnSave.setWarehouseAreaId(saleReturn.getWarehouseAreaId());
purchaseReturnSave.setWarehouseInfo(saleReturn.getWarehouseInfo());
purchaseReturnSave.setDeliveryStaffId(saleReturn.getDeliveryStaffId());
Map<Long, ErpPurchaseOrderItemDO> purchaseOrderMap = CommonUtil.listConvertMap(purchaseOrderItems, ErpPurchaseOrderItemDO::getCustomerOrderItemId);
for (ErpSaleReturnItemDO saleReturnsItem : saleReturnsItems) {
ErpPurchaseReturnSaveReqVO.Item item = new ErpPurchaseReturnSaveReqVO.Item();
if (purchaseOrderMap.containsKey(saleReturnsItem.getCustomerOrderItemId())) {
throw exception(PURCHASE_ORDER_NOT_EXISTS);
}
item.setOrderItemId(purchaseOrderMap.get(saleReturnsItem.getCustomerOrderItemId()).getId());
item.setWarehouseId(saleReturnsItem.getWarehouseId());
item.setProductId(saleReturnsItem.getProductId());
item.setProductUnit(saleReturnsItem.getProductUnit());
item.setProductPrice(saleReturnsItem.getProductPrice());
item.setCount(saleReturnsItem.getCount());
item.setRemark(saleReturnsItem.getRemark());
item.setProductInfo(saleReturnsItem.getProductInfo());
purchaseReturnitems.add(item);
}
purchaseReturnSave.setItems(purchaseReturnitems);
purchaseReturnService.createPurchaseReturn(purchaseReturnSave);
});
}
@Override
......@@ -330,4 +395,65 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
.last("LIMIT 1"));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void accept(Long id, Long deliveryStaffId) {
ErpSaleReturnDO saleReturn = validateSaleReturn(id);
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleReturn.getOrderId());
if (!saleReturn.getReturnsStatus().equals(RETURNS_APPROVE.getType()) || !saleOrder.getPickUpStatus().equals(RETURNS_APPROVE)) {
throw exception(SALE_ORDER_PICKUP_STATUS_FAIL);
}
String key = String.format(SALE_ORDER_LOCK, saleOrder.getId());
RedisUtils.tryLockRds(key);
try {
// 更新退货单和销售订单的状态
saleOrderMapper.update(Wrappers.<ErpSaleOrderDO>lambdaUpdate()
.set(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.RETURNS_STAFF_ACCEPT.getType())
.set(ErpSaleOrderDO::getReturnsDeliveryStaffId, deliveryStaffId)
.eq(ErpSaleOrderDO::getId, saleOrder.getId()));
saleReturnMapper.update(Wrappers.<ErpSaleReturnDO>lambdaUpdate()
.set(ErpSaleReturnDO::getAcceptTime, LocalDateTime.now())
.set(ErpSaleReturnDO::getReturnsStatus, SaleOrderPickUpStatus.RETURNS_STAFF_ACCEPT.getType())
.set(ErpSaleReturnDO::getDeliveryStaffId, deliveryStaffId)
.eq(ErpSaleReturnDO::getId, saleReturn.getId()));
} finally {
RedisUtils.unLockRds(key);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delivery(Long id, Long deliveryStaffId) {
ErpSaleReturnDO saleReturn = validateSaleReturn(id);
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleReturn.getOrderId());
if (!saleReturn.getReturnsStatus().equals(RETURNS_STAFF_ACCEPT.getType()) || !saleOrder.getPickUpStatus().equals(RETURNS_STAFF_ACCEPT)) {
throw exception(SALE_ORDER_PICKUP_STATUS_FAIL);
}
String key = String.format(SALE_ORDER_LOCK, saleOrder.getId());
RedisUtils.tryLockRds(key);
try {
// 更新退货单和销售订单的状态
saleOrderMapper.update(Wrappers.<ErpSaleOrderDO>lambdaUpdate()
.set(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.RETURNS_STAFF_ALREADY.getType())
.set(ErpSaleOrderDO::getReturnsDeliveryStaffId, deliveryStaffId)
.eq(ErpSaleOrderDO::getId, saleOrder.getId()));
saleReturnMapper.update(Wrappers.<ErpSaleReturnDO>lambdaUpdate()
.set(ErpSaleReturnDO::getDeliveryTime, LocalDateTime.now())
.set(ErpSaleReturnDO::getReturnsStatus, SaleOrderPickUpStatus.RETURNS_STAFF_ALREADY.getType())
.set(ErpSaleReturnDO::getDeliveryStaffId, deliveryStaffId)
.eq(ErpSaleReturnDO::getId, saleReturn.getId()));
} finally {
RedisUtils.unLockRds(key);
}
}
}
......@@ -212,4 +212,14 @@ public class DeliveryStaffServiceImpl implements DeliveryStaffService, DeliveryS
public DeliveryStaffSimpleInfo querybyStaffId(Long staffId) {
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;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
* @author : yanghao
* create at: 2025/9/30 14:17
......@@ -9,4 +13,6 @@ package cn.iocoder.foodnexus.module.order.api;
public interface CheckTaskApi {
void createByPurchaseOrderId(Long purchaseOrderId);
Map<Long,String> getCheckResultMapByPurchaseOrderItemIds(Collection<Long> purchaseOrderItemIds);
}
......@@ -2,6 +2,9 @@ package cn.iocoder.foodnexus.module.order.api;
import cn.iocoder.foodnexus.module.order.dto.DeliveryStaffSimpleInfo;
import java.util.Map;
import java.util.Set;
/**
* @author : yanghao
* create at: 2025/9/25 15:54
......@@ -14,4 +17,6 @@ public interface DeliveryStaffApi {
Long queryStaffIdByUserId(Long loginUserId);
DeliveryStaffSimpleInfo querybyStaffId(Long staffId);
Map<Long, DeliveryStaffSimpleInfo> getMap(Set<Long> longs);
}
package cn.iocoder.foodnexus.module.order.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author : yanghao
......@@ -8,8 +10,12 @@ import lombok.Data;
* @description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DeliveryStaffSimpleInfo {
private Long id;
/**
* 姓名
......
......@@ -104,7 +104,7 @@ public class CheckTaskController {
item.setSupplierName(supplierApi.queryNameById(item.getSupplierId()));
item.setCustomerName(customerApi.queryNameStrById(item.getCustomerId()));
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());
}));
}
......@@ -122,7 +122,7 @@ public class CheckTaskController {
return success(BeanUtils.toBean(pageResult, CheckTaskRespVO.class, item -> {
MapUtils.findAndThen(supplierNameMap, item.getSupplierId(), item::setSupplierName);
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 -> {
item.setPurchaseOrderNo(purchaseOrder.getNo());
});
......
......@@ -22,6 +22,9 @@ public class CheckTaskItemsRespVO {
@ExcelProperty("来料质检id")
private Long checkTaskId;
@Schema(description = "采购订单子id")
private Long purchaseOrderItemId;
@Schema(description = "商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30398")
@ExcelProperty("商品id")
private Long productId;
......
......@@ -23,6 +23,9 @@ public class CheckTaskItemsSaveReqVO {
@Schema(description = "商品名称", example = "王五")
private String productName;
@Schema(description = "采购订单子id")
private Long purchaseOrderItemId;
@Schema(description = "商品分类", example = "20330")
private Long categoryId;
......
......@@ -70,7 +70,7 @@ public class CheckTaskRespVO {
private String supplierName;
@Schema(description = "产品信息")
private String productNameInfo;
private String productNames;
@Schema(description = "采购订单编号")
private String purchaseOrderNo;
......
......@@ -96,21 +96,33 @@ public class DeliverySaleOrderController {
@GetMapping("/page")
@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,
@InEnum(value = SaleOrderPickUpStatus.class)
@RequestParam("pickUpStatus")
String pickUpStatus) {
@RequestParam("type")
Integer type) {
ErpSaleOrderPageReqVO pageReqVO = new ErpSaleOrderPageReqVO();
pageReqVO.setPageNo(pageReq.getPageNo());
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()));
pageReqVO.setCustomerDeptIds(CommonUtil.listConvert(deptSimpleRespVOS, DeptSimpleRespVO::getId));
pageReqVO.setPickUpStatusList(CommonUtil.asList(SaleOrderPickUpStatus.PICK_UP.getType(),
SaleOrderPickUpStatus.RETURNS_APPROVE.getType()));
} else {
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));
}
......
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 {
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")
@Operation(summary = "更新购物车")
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 {
*/
private Long productId;
/**
* 采购订单子id
*/
private Long purchaseOrderItemId;
/**
* 商品名称
*/
private String productName;
......
......@@ -278,6 +278,16 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
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) {
CheckTaskSaveReqVO checkTask = new CheckTaskSaveReqVO();
if (CommonUtil.isEmpty(purchaseOrder)) {
......@@ -301,6 +311,7 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
checkTask.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem -> {
CheckTaskItemsSaveReqVO item = new CheckTaskItemsSaveReqVO();
ProductSpuDO productSpuDO = spuMap.get(purchaseOrderItem.getProductId());
item.setPurchaseOrderItemId(purchaseOrderItem.getId());
item.setProductId(purchaseOrderItem.getProductId());
item.setProductName(productSpuDO.getName());
item.setCategoryId(productSpuDO.getCategoryId());
......
......@@ -90,7 +90,7 @@ public class CheckTaskItemsServiceImpl implements CheckTaskItemsService {
}
Map<Long, List<CheckTaskItemsDO>> itemMap = CommonUtil.listConvertListMap(checkTaskItemsDOS, CheckTaskItemsDO::getCheckTaskId);
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;
}
......
......@@ -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.dal.dataobject.customerwarehouse.CustomerWarehouseDO;
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.purchase.ErpPurchaseOrderServiceImpl;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService;
......@@ -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.dto.CustomerVisibleProductRespDTO;
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.service.category.ProductCategoryService;
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.service.user.AdminUserService;
......@@ -117,6 +121,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
private ProductSpuService productSpuService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
@Lazy
private ErpSaleOutService saleOutService;
......@@ -129,6 +136,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
private ErpSaleOrderService saleOrderService;
@Autowired
private ErpSaleOrderMapper saleOrderMapper;
@Autowired
private ScoringWeightService scoringWeightService;
@Autowired
......@@ -259,7 +269,8 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
CustomerOrderItemDO item = BeanUtils.toBean(orderItem, CustomerOrderItemDO.class);
item.setCustomerId(customerId);
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.setSignedQuantity(0);
item.setSignedTotal(0);
......@@ -342,6 +353,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
updateInfo.setOrderRemark(orderRemark);
customerOrderMapper.updateById(updateInfo);
// 标记销售订单状态取消
saleOrderMapper.update(Wrappers.<ErpSaleOrderDO>lambdaUpdate()
.eq(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.CANCEL.getType())
.eq(ErpSaleOrderDO::getCustomerOrderId, customerOrder.getId()));
// 订单记录
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(CustomerOrderStatus.CANCEL);
......@@ -500,6 +516,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnSaveReqVO.setCustomerOrderId(customerOrder.getId());
returnSaveReqVO.setRemark(reqVO.getRemark());
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());
for (AppCustomerReturnOrderReqVO.ReturnItems item : reqVO.getOrderItems()) {
CustomerOrderItemDO customerOrderItemDO = orderItemMap.get(item.getCustomerOrderItemId());
......@@ -518,6 +539,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnItem.setProductId(item.getProductId());
returnItem.setProductUnit(customerOrderItemDO.getProductInfo().getUnitName());
returnItem.setProductPrice(customerOrderItemDO.getOrderItemPrice());
returnItem.setProductInfo(customerOrderItemDO.getProductInfo());
returnItem.setCount(item.getReturnCount());
returnItem.setRemark(item.getRemark());
returnItem.setSupplierId(customerOrderItemDO.getSupplierId());
......@@ -757,6 +779,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
@Override
public Map<Long, CustomerOrderDTO> getOrderMap(Collection<Long> orderIds) {
if (CommonUtil.isEmpty(orderIds)) {
return new HashMap<>();
}
List<CustomerOrderDO> customerOrders = customerOrderMapper.selectByIds(orderIds);
return CommonUtil.listConvertMap(BeanUtils.toBean(customerOrders, CustomerOrderDTO.class), CustomerOrderDTO::getId);
}
......
......@@ -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.operations.dal.dataobject.scoringweight.ScoringWeightDO;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -56,6 +58,9 @@ public class OrderScoreServiceImpl implements OrderScoreService {
@Autowired
private ScoringWeightService scoringWeightService;
@Autowired
private CustomerOrderMapper customerOrderMapper;
@Override
public Long createScore(OrderScoreSaveReqVO createReqVO) {
// 插入
......@@ -187,11 +192,15 @@ public class OrderScoreServiceImpl implements OrderScoreService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteByOrderId(Long orderId) {
if (!scoreMapper.exists(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId))) {
return Boolean.FALSE;
}
customerOrderMapper.update(Wrappers.<CustomerOrderDO>lambdaUpdate()
.set(CustomerOrderDO::getHasScore, Boolean.FALSE)
.eq(CustomerOrderDO::getId, orderId));
return scoreMapper.delete(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId)) > 0;
}
......
......@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart;
import java.util.*;
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 jakarta.validation.*;
import cn.iocoder.foodnexus.module.order.dal.dataobject.shoppingcart.ShoppingCartDO;
......@@ -23,6 +24,8 @@ public interface ShoppingCartService {
*/
Long createShoppingCart(@Valid ShoppingCartSaveReqVO createReqVO);
void createBatch(@Valid ShoppingCartSaveBatchReqVO createReqVO);
/**
* 更新购物车
*
......
......@@ -2,10 +2,12 @@ package cn.iocoder.foodnexus.module.order.service.shoppingcart;
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.ShoppingCartSaveBatchReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.shoppingcart.vo.ShoppingCartSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.*;
......@@ -54,6 +56,14 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createBatch(ShoppingCartSaveBatchReqVO createReqVO) {
for (ShoppingCartSaveReqVO item : createReqVO.getItems()) {
this.createShoppingCart(item);
}
}
@Override
public void updateShoppingCart(ShoppingCartSaveReqVO updateReqVO) {
// 校验存在
validateShoppingCartExists(updateReqVO.getId());
......
......@@ -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 jakarta.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.*;
/**
* 商品分类 Service 接口
......@@ -98,4 +96,6 @@ public interface ProductCategoryService {
return Optional.ofNullable(this.getCategory(categoryId))
.map(ProductCategoryDO::getName).orElse("");
}
Map<Long, String> getMap(Set<Long> productIds);
}
......@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.product.service.category;
import cn.hutool.core.collection.CollUtil;
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.object.BeanUtils;
import cn.iocoder.foodnexus.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
......@@ -14,10 +15,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
......@@ -130,6 +128,14 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
}
@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) {
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