Search in sources :

Example 1 with PurchaseOrderItemVO

use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO in project shopzz by whoiszxl.

the class PurchaseInboundWmsStockUpdater method updateProductStock.

/**
 * 更新商品库存
 */
@Override
protected void updateProductStock() {
    // 1. 拿到采购入库单条目并进行遍历
    List<PurchaseOrderItemVO> items = purchaseOrderResponse.getItems();
    for (PurchaseOrderItemVO item : items) {
        // 2. 从数据库中通过sku_id拿到当前的条目库存
        WarehouseSkuStock warehouseProductStock = warehouseSkuStockService.getOrSaveBySkuId(item.getSkuId());
        // 3. 更新可用库存数量
        warehouseProductStock.setAvailableStockQuantity(warehouseProductStock.getAvailableStockQuantity() + item.getArrivalCount());
        warehouseSkuStockService.updateById(warehouseProductStock);
    }
}
Also used : PurchaseOrderItemVO(com.whoiszxl.cqrs.vo.PurchaseOrderItemVO) WarehouseSkuStock(com.whoiszxl.entity.WarehouseSkuStock)

Example 2 with PurchaseOrderItemVO

use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO 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 3 with PurchaseOrderItemVO

use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO 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 4 with PurchaseOrderItemVO

use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO 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

PurchaseOrderItemVO (com.whoiszxl.cqrs.vo.PurchaseOrderItemVO)4 PurchaseOrder (com.whoiszxl.entity.PurchaseOrder)3 PurchaseOrderItem (com.whoiszxl.entity.PurchaseOrderItem)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)1 PurchaseOrderResponse (com.whoiszxl.cqrs.response.PurchaseOrderResponse)1 WarehouseSkuStock (com.whoiszxl.entity.WarehouseSkuStock)1 Transactional (org.springframework.transaction.annotation.Transactional)1