Commit b3ea9f0a by 杨浩

管理后台接口调整

parent 179a4240
......@@ -3,6 +3,9 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
......@@ -98,8 +101,7 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
private BigDecimal returnCount;
@Schema(description = "客户订单id")
private Long customerId;
@Schema(description = "客户订单id")
private Long customerOrderId;
......@@ -112,6 +114,32 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "发货状态")
private String deliveryStatus;
/* ------ 客户订单 ------ */
@Schema(description = "客户收货地址info")
private CustomerAddressInfo addressInfo;
@Schema(description = "预计配送开始时间")
@ExcelProperty("预计配送开始时间")
private LocalDateTime planDeliveryStartTime;
@Schema(description = "预计配送结束时间")
@ExcelProperty("预计配送结束时间")
private LocalDateTime planDeliveryEndTime;
@Schema(description = "客户订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("客户订单编号")
private String customerOrderCode;
@Schema(description = "客户id")
private Long customerId;
@Schema(description = "客户名称")
private String customerName;
@Schema(description = "配送模式")
private DeliveryMode deliveryMode;
@Data
public static class Item {
......@@ -152,20 +180,21 @@ public class ErpPurchaseOrderRespVO {
// ========== 关联字段 ==========
@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; // 该字段仅仅在“详情”和“编辑”时使用
@Schema(description = "客户订单id")
private Long customerId;
@Schema(description = "客户子订单id")
private Long customerOrderItemId;
@Schema(description = "签收数量")
private Integer signedQuantity;
@Schema(description = "签收总价,单位:分")
private Integer signedTotal;
}
......
......@@ -67,8 +67,8 @@ public class ErpPurchaseOrderSaveReqVO {
@Schema(description = "订单项编号", example = "11756")
private Long id;
@Schema(description = "客户订单id")
private Long customerOrderId;
@Schema(description = "客户订单id")
private Long customerOrderItemId;
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
@NotNull(message = "产品编号不能为空")
......
......@@ -11,6 +11,12 @@ import lombok.Data;
@Data
public class SupplierMonthOrderRespVO {
@Schema(description = "供应商id")
private Long supplierId;
@Schema(description = "供应商名称")
private String supplierName;
@Schema(description = "月份")
private String month;
......
......@@ -107,11 +107,19 @@ public class ErpCustomerController {
}));
}
@GetMapping("/list")
@Operation(summary = "获得客户列表", description = "只包含被开启的客户,主要用于前端的下拉选项")
public CommonResult<List<ErpCustomerRespVO>> getList() {
return success(BeanUtils.toBean(customerService.getCustomerListByStatus(CommonStatusEnum.ENABLE.getStatus()), ErpCustomerRespVO.class, item -> {
item.setWarehouseAreaIds(customerService.queryWarehouseAreaIdByCustomerId(item.getId()));
}));
}
@GetMapping("/simple-list")
@Operation(summary = "获得客户精简列表", description = "只包含被开启的客户,主要用于前端的下拉选项")
public CommonResult<List<ErpCustomerRespVO>> getCustomerSimpleList() {
List<ErpCustomerDO> list = customerService.getCustomerListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(convertList(list, customer -> new ErpCustomerRespVO().setId(customer.getId()).setName(customer.getName())));
return success(convertList(list, customer -> new ErpCustomerRespVO().setId(customer.getId()).setName(customer.getName()).setSystemDeptId(customer.getSystemDeptId())));
}
@GetMapping("/export-excel")
......
......@@ -5,6 +5,7 @@ import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
......@@ -89,12 +90,9 @@ public class ErpPurchaseOrderItemDO extends BaseDO {
*/
private BigDecimal returnCount;
/**
* 客户订单id
*/
private Long customerOrderId;
private Long customerOrderItemId;
}
\ No newline at end of file
......@@ -113,19 +113,23 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
default PageResult<SupplierMonthOrderRespVO> pageMonth(SupplierMonthOrderPageReqVO pageReqVO, Long supplierId) {
MPJQueryWrapper<ErpPurchaseOrderDO> wrapper = new MPJQueryWrapper<>();
wrapper.select("t.supplier_id");
wrapper.select("es.name as 'supplier_name'");
wrapper.select("DATE_FORMAT( t.create_time, '%Y-%m' ) AS 'month'");
wrapper.select("count( t.id ) AS 'orderCount'");
wrapper.select("SUM( t.total_price ) AS 'orderPrice'");
// TODO payablePrice 这个字段待定
wrapper.select("CASE WHEN SUM(CASE WHEN t.delivery_status='ARRIVAL' THEN 1 ELSE 0 END)> 0 THEN 0 ELSE 1 END AS 'status'");
wrapper.leftJoin("order_customer_order t1 on t.customer_order_id = t1.id");
wrapper.eq("t.supplier_id", supplierId);
wrapper.leftJoin("erp_supplier es on t.supplier_id = es.id");
wrapper.eq(CommonUtil.isNotEmpty(supplierId), "t.supplier_id", supplierId);
wrapper.in("t.delivery_status", CommonUtil.asList(ErpDeliveryStatus.RECONCILIATION.getStatus(),
ErpDeliveryStatus.ARRIVAL.getStatus()));
wrapper.in("t1.order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey()), CustomerOrderStatus.FINISH.getKey());
wrapper.eq(CommonUtil.isNotBlank(pageReqVO.getMonth()), "DATE_FORMAT(t.create_time, '%Y-%m') ", pageReqVO.getMonth());
wrapper.orderByDesc("t.id");
wrapper.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' ), t.supplier_id");
return this.selectJoinPage(pageReqVO, SupplierMonthOrderRespVO.class, wrapper);
}
......
......@@ -35,7 +35,7 @@ public interface ErpSaleOrderMapper extends BaseMapperX<ErpSaleOrderDO> {
.eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator())
.eqIfPresent(ErpSaleOrderDO::getDeliveryStaffId, reqVO.getDeliveryStaffId())
.betweenIfPresent(ErpSaleOrderDO::getAcceptTime, reqVO.getAcceptTime())
.eqIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatus().getType())
.eqIfPresent(ErpSaleOrderDO::getPickUpStatus, reqVO.getPickUpStatus())
.eqIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptId())
.inIfPresent(ErpSaleOrderDO::getCustomerDeptId, reqVO.getCustomerDeptIds())
.orderByDesc(ErpSaleOrderDO::getId);
......
......@@ -129,4 +129,6 @@ public interface ErpPurchaseOrderService {
* @param supplierId 当前供应商id
*/
void reconciliation(List<ErpPurchaseOrderDO> purchaseOrderList, Long supplierId);
Map<Long, ErpPurchaseOrderDO> getMap(List<Long> longs);
}
\ No newline at end of file
......@@ -106,10 +106,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
calculateTotalPrice(purchaseOrder, purchaseOrderItems);
purchaseOrderMapper.insert(purchaseOrder);
// 2.2 插入订单项
purchaseOrderItems.forEach(o -> {
o.setOrderId(purchaseOrder.getId());
o.setCustomerOrderId(purchaseOrder.getCustomerOrderId());
});
purchaseOrderItems.forEach(o -> o.setOrderId(purchaseOrder.getId()));
purchaseOrderItemMapper.insertBatch(purchaseOrderItems);
return purchaseOrder.getId();
}
......@@ -331,11 +328,14 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
public void delivery(List<Long> ids, Long supplierId, ErpDeliveryStatus oriStatus, ErpDeliveryStatus updateStatus, CustomerOrderStatus updateOrderStatus) {
List<ErpPurchaseOrderDO> orderList = purchaseOrderMapper.selectList(Wrappers.<ErpPurchaseOrderDO>lambdaQuery()
.in(ErpPurchaseOrderDO::getId, ids)
.eq(ErpPurchaseOrderDO::getSupplierId, supplierId));
.eq(CommonUtil.isNotEmpty(supplierId) ,ErpPurchaseOrderDO::getSupplierId, supplierId));
if (CommonUtil.isEmpty(orderList)) {
throw exception(PURCHASE_ORDER_NOT_EXISTS);
}
if (CommonUtil.isEmpty(supplierId)) {
supplierId = orderList.get(0).getSupplierId();
}
Set<Long> customerOrderSet = new HashSet<>();
for (ErpPurchaseOrderDO item : orderList) {
......@@ -373,7 +373,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
inSaveReqVO.setRemark(purchaseOrder.getRemark());
List<ErpPurchaseOrderItemDO> purchaseOrderItems = purchaseOrderItemMapper.selectListByOrderId(purchaseOrder.getId());
inSaveReqVO.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem ->
getItem(purchaseOrderItem, customerOrderApi.queryById(purchaseOrderItem.getCustomerOrderId()))));
getItem(purchaseOrderItem, customerOrderApi.queryById(purchaseOrder.getCustomerOrderId()))));
purchaseInService.createPurchaseIn(inSaveReqVO);
// 新增来料质检
......@@ -451,6 +451,15 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
purchaseOrderMapper.updateBatch(updateBatch);
}
@Override
public Map<Long, ErpPurchaseOrderDO> getMap(List<Long> ids) {
if (CommonUtil.isEmpty(ids)) {
return new HashMap<>(1);
}
List<ErpPurchaseOrderDO> erpPurchaseOrderDOS = purchaseOrderMapper.selectByIds(ids);
return CommonUtil.listConvertMap(erpPurchaseOrderDOS, ErpPurchaseOrderDO::getId);
}
@Async
@TransactionalEventListener(classes = PurchaseOrderSplitEvent.class, phase = TransactionPhase.AFTER_COMMIT)
public void orderSplit(PurchaseOrderSplitEvent event) {
......@@ -480,7 +489,8 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
purhcaseOrderItem.setProductUnit(customerOrderItem.getProductInfo().getUnitName());
purhcaseOrderItem.setProductPrice(customerOrderItem.getOrderItemPrice());
purhcaseOrderItem.setCount(customerOrderItem.getOrderItemQuantity());
purhcaseOrderItem.setCustomerOrderId(orderId);
purhcaseOrderItem.setCustomerOrderItemId(customerOrderItem.getId());
purhcaseOrderItem.setRemark(customerOrderItem.getCustomerRemark());
purchaseOrder.put(purhcaseOrderItem);
}
......
......@@ -37,6 +37,6 @@ public class CustomerRequirePageReqVO extends PageParam {
private LocalDateTime[] updateTime;
@Schema(description = "创建人")
private String creator;
private Long creator;
}
\ No newline at end of file
......@@ -73,7 +73,7 @@ public class AppCustomerRequireController {
@GetMapping("/page")
@Operation(summary = "获得客户需求分页")
public CommonResult<PageResult<CustomerRequireRespVO>> getCustomerRequirePage(@Valid CustomerRequirePageReqVO pageReqVO) {
pageReqVO.setCustomerId(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
pageReqVO.setCreator(SecurityFrameworkUtils.getLoginUserId());
PageResult<CustomerRequireDO> pageResult = customerRequireService.getCustomerRequirePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CustomerRequireRespVO.class));
}
......
......@@ -4,7 +4,10 @@ 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 java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author : yanghao
......@@ -18,4 +21,8 @@ public interface CustomerOrderApi {
List<CustomerOrderItemDTO> queryItemsByOrderId(Long customerOrderId);
void updateOrderStatus(Long customerOrderId, CustomerOrderStatus updateOrderStatus);
Map<Long, CustomerOrderDTO> getOrderMap(Collection<Long> orderIds);
List<CustomerOrderItemDTO> queryItemsByIds(Collection<Long> orderItems);
}
......@@ -67,4 +67,8 @@ public class CustomerOrderItemDTO {
* 订单备注
*/
private CustomerOrderRemark orderRemark;
/**
* 客户下单备注
*/
private String customerRemark;
}
package cn.iocoder.foodnexus.module.order.controller.admin.checktask;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerOrderScoreReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerOrderScoreRespVO;
import cn.iocoder.foodnexus.module.order.service.checktaskitems.CheckTaskItemsService;
......@@ -45,6 +51,15 @@ public class CheckTaskController {
@Autowired
private CheckTaskItemsService checkTaskItemsService;
@Autowired
private ErpSupplierApi supplierApi;
@Autowired
private ErpPurchaseOrderService purchaseOrderService;
@Autowired
private ErpCustomerApi customerApi;
@PostMapping("/create")
@Operation(summary = "创建来料质检")
@PreAuthorize("@ss.hasPermission('order:check-task:create')")
......@@ -86,6 +101,11 @@ public class CheckTaskController {
CheckTaskDO checkTask = checkTaskService.getCheckTask(id);
return success(BeanUtils.toBean(checkTask, CheckTaskRespVO.class, item -> {
item.setItems(BeanUtils.toBean(checkTaskItemsService.queryByCheckId(item.getId()), CheckTaskItemsRespVO.class));
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.setPurchaseOrderNo(purchaseOrderService.getPurchaseOrder(item.getPurchaseOrderId()).getNo());
}));
}
......@@ -94,7 +114,19 @@ public class CheckTaskController {
@PreAuthorize("@ss.hasPermission('order:check-task:query')")
public CommonResult<PageResult<CheckTaskRespVO>> getCheckTaskPage(@Valid CheckTaskPageReqVO pageReqVO) {
PageResult<CheckTaskDO> pageResult = checkTaskService.getCheckTaskPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CheckTaskRespVO.class));
Map<Long, String> supplierNameMap = supplierApi.queryNameMapByIds(CommonUtil.listConvertSet(pageResult.getList(), CheckTaskDO::getSupplierId));
Map<Long, String> productInfoMap = checkTaskItemsService.queryProductInfoByCheckId(CommonUtil.listConvertSet(pageResult.getList(), CheckTaskDO::getId));
Map<Long, ErpPurchaseOrderDO> purchaseOrderMap = purchaseOrderService.getMap(CommonUtil.listConvert(pageResult.getList(), CheckTaskDO::getPurchaseOrderId));
Map<Long, String> customerMap = customerApi.queryNameMapByIds(CommonUtil.listConvertSet((pageResult.getList()), CheckTaskDO::getCustomerId));
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(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder -> {
item.setPurchaseOrderNo(purchaseOrder.getNo());
});
}));
}
@GetMapping("score")
......
......@@ -65,4 +65,19 @@ public class CheckTaskRespVO {
@Schema(description = "质检子项(详情接口返回)")
private List<CheckTaskItemsRespVO> items;
@Schema(description = "供应商名称")
private String supplierName;
@Schema(description = "产品信息")
private String productNameInfo;
@Schema(description = "采购订单编号")
private String purchaseOrderNo;
@Schema(description = "客户名称")
private String customerName;
}
\ No newline at end of file
......@@ -81,4 +81,7 @@ public class CustomerOrderPageReqVO extends PageParam {
@Schema(description = "筛选待评价")
private Boolean filterToBeScore;
@Schema(description = "是否已评价")
private Boolean hasScore;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo;
import cn.iocoder.foodnexus.module.order.controller.admin.orderScore.vo.OrderScoreRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerOrderScoreRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* @author : yanghao
* create at: 2025/10/16 10:01
* @description: 客户 - 订单评价
*/
@Data
public class CustomerOrderScoreRespVO extends CustomerOrderRespVO {
@Schema(description = "评价指标项")
private List<orderScoreItems> orderScoreItems;
@Data
public static class orderScoreItems {
@Schema(description = "订单评价id")
private Long id;
@Schema(description = "评价指标id")
private Long scoreId;
@Schema(description = "评价指标名称")
private String scoreName;
@Schema(description = "得分")
private Integer score;
}
}
......@@ -85,5 +85,7 @@ public class CustomerOrderItemRespVO {
@Schema(description = "退货总价,单位:分")
private Integer returnsTotal;
@Schema(description = "客户下单备注")
private String customerRemark;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.admin.supplier;
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.object.BeanUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
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.SupplierMonthOrderDetailsRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
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/16 14:25
* @description: 管理后台 - 供应商 - 对账
*/
@Tag(name = "管理后台 - 供应商 - 对账")
@RestController
@RequestMapping("/operation/reconciliation")
@Validated
public class OperaSupplierPurchaseOrderController {
@Resource
private ErpPurchaseOrderService purchaseOrderService;
@Autowired
private CustomerOrderItemService customerOrderItemService;
@Autowired
private CustomerOrderService customerOrderService;
@GetMapping("/page-month")
@Operation(summary = "分页获取月度账单")
public CommonResult<PageResult<SupplierMonthOrderRespVO>> pageMonth(SupplierMonthOrderPageReqVO pageReqVO) {
return success(purchaseOrderService.pageMonth(pageReqVO, null));
}
@GetMapping("/page-by-month")
@Operation(summary = "月度账单明细")
public CommonResult<PageResult<SupplierMonthOrderDetailsRespVO>> listByMonth(SupplierMonthOrderPageReqVO pageReqVO) {
if (CommonUtil.isEmpty(pageReqVO.getMonth())) {
throw exception("月份不能为空");
}
ErpPurchaseOrderPageReqVO orderPageReqVo = new ErpPurchaseOrderPageReqVO();
orderPageReqVo.setPageSize(pageReqVO.getPageSize());
orderPageReqVo.setPageNo(pageReqVO.getPageNo());
// orderPageReqVo.setSupplierId(supplierApi.querySupplierIdByUserId(getLoginUserId()));
orderPageReqVo.setCreateMonth(pageReqVO.getMonth());
orderPageReqVo.setDeliveryStatus(CommonUtil.asList(ErpDeliveryStatus.ARRIVAL.getStatus(), ErpDeliveryStatus.RECONCILIATION.getStatus()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(orderPageReqVo);
return success(BeanUtils.toBean(pageResult, SupplierMonthOrderDetailsRespVO.class, this::transform));
}
private void transform(SupplierMonthOrderDetailsRespVO purchaseOrder) {
CustomerOrderDO customerOrder = customerOrderService.getCustomerOrder(purchaseOrder.getCustomerOrderId());
List<CustomerOrderItemDO> customerOrderItemDOS = customerOrderItemService.queryByOrderId(purchaseOrder.getCustomerOrderId(), purchaseOrder.getSupplierId());
purchaseOrder.setDeliveryMode(customerOrder.getDeliveryMode());
purchaseOrder.setPlanDeliveryStartTime(customerOrder.getPlanDeliveryStartTime());
purchaseOrder.setPlanDeliveryEndTime(customerOrder.getPlanDeliveryEndTime());
// TODO 待定
// purchaseOrder.setPayablePrice();
purchaseOrder.setSignedTotal(customerOrderItemDOS.stream().mapToInt(CustomerOrderItemDO::getSignedTotal).sum());
purchaseOrder.setReturnsTotal(customerOrderItemDOS.stream().mapToInt(CustomerOrderItemDO::getReturnsTotal).sum());
purchaseOrder.setSupplierName(customerOrderItemDOS.get(0).getSupplierName());
StringBuilder productNames = new StringBuilder();
for (CustomerOrderItemDO item : customerOrderItemDOS) {
productNames.append(item.getProductName()).append("(").append(item.getOrderItemQuantity()).append(")\n");
}
purchaseOrder.setProductNames(productNames.toString());
}
}
......@@ -88,7 +88,7 @@ public class CustomerAddressController {
@GetMapping("/page")
@Operation(summary = "获得客户 - 我的地址分页")
public CommonResult<PageResult<CustomerAddressRespVO>> getCustomerAddressPage(@Valid CustomerAddressPageReqVO pageReqVO) {
pageReqVO.setCustomerId(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
pageReqVO.setCreator(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
PageResult<CustomerAddressDO> pageResult = customerAddressService.getCustomerAddressPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CustomerAddressRespVO.class));
}
......
......@@ -50,4 +50,7 @@ public class CustomerAddressPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "创建者", hidden = true)
private Long creator;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.app.orderscore;
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.module.order.controller.admin.customerorder.vo.CustomerOrderPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderRespVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderScoreRespVO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService;
import cn.iocoder.foodnexus.module.order.service.orderScore.OrderScoreService;
import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth;
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 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/16 09:43
* @description: APP - 个人中心 - 我的评价
*/
@Tag(name = "APP - 个人中心 - 我的评价")
@RestController
@RequestMapping("/my/order-score")
@Validated
@AppSystemAuth(UserSystemEnum.CUSTOMER)
public class AppCustomerOrderScoreController {
@Autowired
private CustomerOrderService customerOrderService;
@Autowired
private CustomerOrderItemService customerOrderItemService;
@Autowired
private OrderScoreService orderScoreService;
@GetMapping("/page")
@Operation(summary = "获得客户总订单分页")
public CommonResult<PageResult<CustomerOrderScoreRespVO>> queryMyOrderScorePage(@Valid PageParam reqVO) {
CustomerOrderPageReqVO pageReqVO = new CustomerOrderPageReqVO();
pageReqVO.setPageNo(reqVO.getPageNo());
pageReqVO.setPageSize(reqVO.getPageSize());
pageReqVO.setCreator(getLoginUserId());
pageReqVO.setHasScore(Boolean.TRUE);
PageResult<CustomerOrderDO> pageResult = customerOrderService.getCustomerOrderPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CustomerOrderScoreRespVO.class, item -> {
item.setProductInfos(CommonUtil.listConvert(customerOrderItemService.queryByOrderId(item.getId()), CustomerOrderItemDO::getProductInfo));
item.setOrderScoreItems(BeanUtils.toBean(orderScoreService.listByOrderId(item.getId()), CustomerOrderScoreRespVO.orderScoreItems.class));
}));
}
@PostMapping("/delete-by-order-id")
@Operation(summary = "根据订单id删除评价")
@Parameter(name = "id", description = "订单id", required = true, example = "1024")
public CommonResult<Boolean> deleteByOrderId(@RequestParam("id") Long id) {
return success(orderScoreService.deleteByOrderId(id));
}
}
......@@ -101,4 +101,9 @@ public class CustomerOrderItemDO extends BaseDO {
* 退货总价,单位:分
*/
private Integer returnsTotal;
/**
* 客户下单备注
*/
private String customerRemark;
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ public interface CustomerAddressMapper extends BaseMapperX<CustomerAddressDO> {
.eqIfPresent(CustomerAddressDO::getAddress, reqVO.getAddress())
.eqIfPresent(CustomerAddressDO::getIsDefault, reqVO.getIsDefault())
.betweenIfPresent(CustomerAddressDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(CustomerAddressDO::getCreator, reqVO.getCreator())
.orderByDesc(CustomerAddressDO::getId));
}
......
......@@ -46,6 +46,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
.eqIfPresent(CustomerOrderDO::getOperCompany, reqVO.getOperCompany())
.betweenIfPresent(CustomerOrderDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(CustomerOrderDO::getCreator, reqVO.getCreator())
.eqIfPresent(CustomerOrderDO::getHasScore, reqVO.getHasScore())
.orderByDesc(CustomerOrderDO::getId);
if (CommonUtil.isNotBlank(reqVO.getCreateYearMonth())) {
String createMonth = reqVO.getCreateYearMonth().trim();
......
......@@ -302,6 +302,7 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
CheckTaskItemsSaveReqVO item = new CheckTaskItemsSaveReqVO();
ProductSpuDO productSpuDO = spuMap.get(purchaseOrderItem.getProductId());
item.setProductId(purchaseOrderItem.getProductId());
item.setProductName(productSpuDO.getName());
item.setCategoryId(productSpuDO.getCategoryId());
item.setCategoryName(productCategoryService.queryNameById(productSpuDO.getCategoryId()));
item.setPicUrl(productSpuDO.getPicUrl());
......
......@@ -61,5 +61,7 @@ public interface CheckTaskItemsService {
*/
PageResult<CheckTaskItemsDO> getCheckTaskItemsPage(CheckTaskItemsPageReqVO pageReqVO);
List<CheckTaskItemsDO> queryByCheckId(Long id);
List<CheckTaskItemsDO> queryByCheckId(Long checkId);
Map<Long, String> queryProductInfoByCheckId(Collection<Long> checkIds);
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.service.checktaskitems;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.CheckTaskItemsPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.CheckTaskItemsSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -74,4 +76,23 @@ public class CheckTaskItemsServiceImpl implements CheckTaskItemsService {
return checkTaskItemsMapper.selectList(CheckTaskItemsDO::getCheckTaskId, id);
}
@Override
public Map<Long, String> queryProductInfoByCheckId(Collection<Long> checkIds) {
Map<Long, String> resultMap = new HashMap<>();
if (CommonUtil.isEmpty(checkIds)) {
return resultMap;
}
List<CheckTaskItemsDO> checkTaskItemsDOS = checkTaskItemsMapper.selectList(Wrappers.<CheckTaskItemsDO>lambdaQuery()
.in(CheckTaskItemsDO::getCheckTaskId, checkIds));
if (CommonUtil.isEmpty(checkTaskItemsDOS)) {
return resultMap;
}
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() + ")"))));
return resultMap;
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderRecordApi;
import cn.iocoder.foodnexus.module.order.controller.admin.orderScore.vo.OrderScoreSaveReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.*;
import cn.iocoder.foodnexus.module.order.dal.dataobject.shoppingcart.ShoppingCartDO;
import cn.iocoder.foodnexus.module.order.dto.*;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderRemark;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO;
......@@ -35,6 +36,7 @@ import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.order.service.customeraddress.CustomerAddressService;
import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService;
import cn.iocoder.foodnexus.module.order.service.orderScore.OrderScoreService;
import cn.iocoder.foodnexus.module.order.service.shoppingcart.ShoppingCartService;
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;
......@@ -44,6 +46,7 @@ import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import cn.iocoder.foodnexus.module.system.util.GenCodeUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
......@@ -135,6 +138,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
private AdminUserService userService;
@Autowired
private ShoppingCartService shoppingCartService;
@Autowired
private GenCodeUtils genCodeUtils;
@Override
......@@ -244,6 +250,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
createOrder.setAddressInfo(BeanUtils.toBean(addressService.getCustomerAddress(createReqVO.getAddressId()), CustomerAddressInfo.class));
createOrder.setSupplierCount(supplierSet.size());
createOrder.setProductCount(procuctSet.size());
// 购物车信息
List<Long> productIds = CommonUtil.listConvert(createReqVO.getOrderItems(), AppCustomerOrderItemSaveReqVO::getProductId);
Map<Long, ShoppingCartDO> shoppingMap = shoppingCartService.getMap(loginUser.getId(), productIds);
// 子订单补全
AtomicReference<Integer> orderAmount = new AtomicReference<>(0);
List<CustomerOrderItemDO> collect = createReqVO.getOrderItems().stream().map(orderItem -> {
......@@ -254,6 +263,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
item.setProductName(item.getProductInfo().getName());
item.setSignedQuantity(0);
item.setSignedTotal(0);
if (shoppingMap.containsKey(orderItem.getProductId())) {
item.setCustomerRemark(shoppingMap.get(orderItem.getProductId()).getRemark());
}
orderAmount.updateAndGet(v -> v + item.getOrderItemTotal());
return item;
}).collect(Collectors.toList());
......@@ -263,6 +275,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
customerOrderId = this.createCustomerOrder(createOrder);
customerOrderItemService.createBatch(collect, customerOrderId);
// 删除购物车中的同样商品的信息
shoppingCartService.deleteByProductId(loginUser.getId(), productIds);
// 拆分采购订单
orderSplitPurchase(customerOrderId);
......@@ -580,14 +595,12 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
}
});
}
CustomerOrderDO updateScore = new CustomerOrderDO();
if (CommonUtil.isNotEmpty(reqVO.getOrderRemark())) {
reqVO.getOrderRemark().setOperTime(new Date());
customerOrderMapper.update(Wrappers.<CustomerOrderDO>lambdaUpdate()
.eq(CustomerOrderDO::getId, id)
.set(CustomerOrderDO::getOrderRemark, reqVO.getOrderRemark()));
updateScore.setOrderRemark(reqVO.getOrderRemark());
}
CustomerOrderDO updateScore = new CustomerOrderDO();
updateScore.setId(id);
updateScore.setHasScore(Boolean.TRUE);
customerOrderMapper.updateById(updateScore);
......@@ -741,4 +754,19 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
.set(CustomerOrderDO::getOrderStatus, updateOrderStatus)
.eq(CustomerOrderDO::getId, customerOrderId));
}
@Override
public Map<Long, CustomerOrderDTO> getOrderMap(Collection<Long> orderIds) {
List<CustomerOrderDO> customerOrders = customerOrderMapper.selectByIds(orderIds);
return CommonUtil.listConvertMap(BeanUtils.toBean(customerOrders, CustomerOrderDTO.class), CustomerOrderDTO::getId);
}
@Override
public List<CustomerOrderItemDTO> queryItemsByIds(Collection<Long> orderItems) {
if (CommonUtil.isEmpty(orderItems)) {
return Lists.newArrayList();
}
return BeanUtils.toBean(customerOrderItemMapper.selectByIds(orderItems), CustomerOrderItemDTO.class);
}
}
\ No newline at end of file
......@@ -64,4 +64,8 @@ public interface OrderScoreService {
boolean exists(Long orderId, Long scoreId);
PageResult<OrderScoreSupplierRespVO> supplierPage(OrderScoreSupplierPageReqVO pageReqVO);
List<OrderScoreDO> listByOrderId(Long orderId);
Boolean deleteByOrderId(Long orderId);
}
\ No newline at end of file
......@@ -181,6 +181,21 @@ public class OrderScoreServiceImpl implements OrderScoreService {
return null;
}
@Override
public List<OrderScoreDO> listByOrderId(Long id) {
return scoreMapper.selectList(OrderScoreDO::getOrderId, id);
}
@Override
public Boolean deleteByOrderId(Long orderId) {
if (!scoreMapper.exists(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId))) {
return Boolean.FALSE;
}
return scoreMapper.delete(Wrappers.<OrderScoreDO>lambdaQuery()
.eq(OrderScoreDO::getOrderId, orderId)) > 0;
}
public BigDecimal divideInts(int num1, int num2) {
// 处理除数为0的情况
if (num2 == 0) {
......
......@@ -60,4 +60,7 @@ public interface ShoppingCartService {
*/
PageResult<ShoppingCartDO> getShoppingCartPage(ShoppingCartPageReqVO pageReqVO);
Map<Long, ShoppingCartDO> getMap(Long creator, List<Long> productIds);
void deleteByProductId(Long creator, List<Long> productIds);
}
\ No newline at end of file
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.ShoppingCartSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -32,6 +34,17 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
@Override
public Long createShoppingCart(ShoppingCartSaveReqVO createReqVO) {
ShoppingCartDO cart = shoppingCartMapper.selectOne(Wrappers.<ShoppingCartDO>lambdaQuery()
.eq(ShoppingCartDO::getProductId, createReqVO.getProductId())
.last("LIMIT 1"));
if (CommonUtil.isNotEmpty(cart)) {
ShoppingCartDO updateCart = new ShoppingCartDO();
updateCart.setId(cart.getId());
updateCart.setRemark(createReqVO.getRemark());
updateCart.setOrderQuantity(cart.getOrderQuantity() + createReqVO.getOrderQuantity());
shoppingCartMapper.updateById(updateCart);
return cart.getId();
}
// 插入
ShoppingCartDO shoppingCart = BeanUtils.toBean(createReqVO, ShoppingCartDO.class);
shoppingCartMapper.insert(shoppingCart);
......@@ -80,4 +93,22 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
return shoppingCartMapper.selectPage(pageReqVO);
}
@Override
public Map<Long, ShoppingCartDO> getMap(Long creator, List<Long> productIds) {
List<ShoppingCartDO> shoppingCartDOS = shoppingCartMapper.selectList(Wrappers.<ShoppingCartDO>lambdaQuery()
.in(ShoppingCartDO::getProductId, productIds)
.eq(ShoppingCartDO::getCreator, creator));
return CommonUtil.listConvertMap(shoppingCartDOS, ShoppingCartDO::getProductId);
}
@Override
public void deleteByProductId(Long creator, List<Long> productIds) {
if (CommonUtil.isEmpty(productIds)) {
return;
}
shoppingCartMapper.delete(Wrappers.<ShoppingCartDO>lambdaQuery()
.in(ShoppingCartDO::getProductId, productIds)
.eq(ShoppingCartDO::getCreator, creator));
}
}
\ No newline at end of file
......@@ -40,6 +40,10 @@ public class ProductInfo implements Serializable {
*/
private Long categoryId;
/**
* 分类名称
*/
private String categoryName;
/**
* 商品封面图
*/
private String picUrl;
......
......@@ -19,4 +19,7 @@ public class DeptListReqVO {
@Schema(description = "用户体系", example = "1")
private String userSystem;
@Schema(description = "parentId")
private Long parentId;
}
......@@ -16,6 +16,7 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
return selectList(new LambdaQueryWrapperX<DeptDO>()
.likeIfPresent(DeptDO::getName, reqVO.getName())
.eqIfPresent(DeptDO::getStatus, reqVO.getStatus())
.eqIfPresent(DeptDO::getParentId, reqVO.getParentId())
.eqIfPresent(DeptDO::getUserSystem, reqVO.getUserSystem()));
}
......
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