Search in sources :

Example 6 with PurchaseOrderItem

use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.

the class PurchaseOrderServiceImpl method updatePurchaseOrder.

@Override
@Transactional
public void updatePurchaseOrder(PurchaseOrderSaveCommand purchaseOrderSaveCommand) {
    // 1. 更新采购订单
    PurchaseOrder purchaseOrder = dozerUtils.map(purchaseOrderSaveCommand, PurchaseOrder.class);
    purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
    this.updateById(purchaseOrder);
    // 2. 删除原来的订单商品详情
    purchaseOrderItemService.remove(new UpdateWrapper<PurchaseOrderItem>().eq("purchase_order_id", purchaseOrder.getId()));
    // 2. 新增订单商品详情
    List<PurchaseOrderItemVO> items = purchaseOrderSaveCommand.getItems();
    items.forEach(item -> item.setPurchaseOrderId(purchaseOrder.getId()));
    List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(items, PurchaseOrderItem::new);
    purchaseOrderItemService.saveBatch(purchaseOrderItems);
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.cqrs.vo.PurchaseOrderItemVO) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with PurchaseOrderItem

use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.

the class PurchaseOrderServiceImpl method savePurchaseOrder.

@Override
public void savePurchaseOrder(PurchaseOrderSaveCommand purchaseOrderSaveCommand) {
    PurchaseOrder purchaseOrder = dozerUtils.map(purchaseOrderSaveCommand, PurchaseOrder.class);
    // 1. 新增采购订单
    purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
    this.save(purchaseOrder);
    // 2. 批量新增采购订单中的商品详情
    List<PurchaseOrderItemVO> items = purchaseOrderSaveCommand.getItems();
    for (PurchaseOrderItemVO item : items) {
        item.setPurchaseOrderId(purchaseOrder.getId());
    }
    List<PurchaseOrderItem> purchaseOrderItems = dozerUtils.mapList(items, PurchaseOrderItem.class);
    purchaseOrderItemService.saveBatch(purchaseOrderItems);
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.cqrs.vo.PurchaseOrderItemVO) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder)

Example 8 with PurchaseOrderItem

use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.

the class PurchaseOrderServiceImpl method getPurchaseOrderById.

@Override
public PurchaseOrderResponse getPurchaseOrderById(Long id) {
    // 1. 查询采购订单
    PurchaseOrder purchaseOrder = this.getById(id);
    PurchaseOrderResponse purchaseOrderResponse = dozerUtils.map(purchaseOrder, PurchaseOrderResponse.class);
    // 2. 查询采购订单中的商品详情,将详情添加到采购订单对象中去
    List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.list(new LambdaQueryWrapper<PurchaseOrderItem>().eq(PurchaseOrderItem::getPurchaseOrderId, id));
    List<PurchaseOrderItemVO> purchaseOrderItemVOList = dozerUtils.mapList(purchaseOrderItemList, PurchaseOrderItemVO.class);
    purchaseOrderResponse.setItems(purchaseOrderItemVOList);
    return purchaseOrderResponse;
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.cqrs.vo.PurchaseOrderItemVO) PurchaseOrderResponse(com.whoiszxl.cqrs.response.PurchaseOrderResponse) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

PurchaseOrderItem (com.whoiszxl.entity.PurchaseOrderItem)8 PurchaseOrder (com.whoiszxl.entity.PurchaseOrder)7 PurchaseOrderItemVO (com.whoiszxl.cqrs.vo.PurchaseOrderItemVO)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Transactional (org.springframework.transaction.annotation.Transactional)3 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)2 PurchaseOrderItemVO (com.whoiszxl.entity.vo.PurchaseOrderItemVO)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 ReceiveProductCommand (com.whoiszxl.cqrs.command.ReceiveProductCommand)1 PurchaseOrderResponse (com.whoiszxl.cqrs.response.PurchaseOrderResponse)1 ProductAllocation (com.whoiszxl.entity.ProductAllocation)1 PurchaseInboundOnItem (com.whoiszxl.entity.PurchaseInboundOnItem)1 PurchaseInboundOnItemVO (com.whoiszxl.entity.vo.PurchaseInboundOnItemVO)1 ReceiveProductVO (com.whoiszxl.entity.vo.ReceiveProductVO)1