Search in sources :

Example 1 with PurchaseSettlementOrder

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

the class PurchaseSettlementOrderServiceImpl method getPurchaseSettlementOrderById.

@Override
public PurchaseSettlementOrderDTO getPurchaseSettlementOrderById(Long id) {
    // 1. 查询采购结算单
    PurchaseSettlementOrder purchaseSettlementOrder = this.getById(id);
    PurchaseSettlementOrderDTO purchaseSettlementOrderDTO = purchaseSettlementOrder.clone(PurchaseSettlementOrderDTO.class);
    // 2. 查询采购结算单条目
    QueryWrapper queryWrapper = new QueryWrapper<PurchaseSettlementOrderItem>();
    queryWrapper.eq("purchase_settlement_order_id", id);
    List<PurchaseSettlementOrderItem> itemList = purchaseSettlementOrderItemService.list(queryWrapper);
    List<PurchaseSettlementOrderItemDTO> purchaseSettlementOrderItemDTOS = BeanCopierUtils.copyListProperties(itemList, PurchaseSettlementOrderItemDTO::new);
    purchaseSettlementOrderDTO.setItems(purchaseSettlementOrderItemDTOS);
    return purchaseSettlementOrderDTO;
}
Also used : PurchaseSettlementOrderItem(com.whoiszxl.entity.PurchaseSettlementOrderItem) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) PurchaseSettlementOrderItemDTO(com.whoiszxl.dto.PurchaseSettlementOrderItemDTO) PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder) PurchaseSettlementOrderDTO(com.whoiszxl.dto.PurchaseSettlementOrderDTO)

Example 2 with PurchaseSettlementOrder

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

the class FinancePurchaseSettlementOrderController method submitOrderToApprove.

@PutMapping("/submit/approve/{id}")
@ApiOperation(value = "提交采购入库单的审核", notes = "提交采购入库单的审核", response = ResponseResult.class)
public ResponseResult submitOrderToApprove(@PathVariable("id") Long id) {
    // 对采购入库单的订单状态进行校验
    PurchaseSettlementOrder purchaseSettlementOrder = purchaseSettlementOrderService.getById(id);
    if (purchaseSettlementOrder == null || !purchaseSettlementOrder.getStatus().equals(PurchaseSettlementOrderStatusConstants.EDITING)) {
        return ResponseResult.buildError("采购结算单不存在或状态不为编辑中");
    }
    purchaseSettlementOrder.setStatus(PurchaseSettlementOrderStatusConstants.WAIT_FOR_APPROVE);
    boolean updateFlag = purchaseSettlementOrderService.updateById(purchaseSettlementOrder);
    return ResponseResult.buildByFlag(updateFlag);
}
Also used : PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with PurchaseSettlementOrder

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

the class FinancePurchaseSettlementOrderController method approve.

@PutMapping("/approve/{id}/{status}")
@ApiOperation(value = "审核采购结算单", notes = "审核采购结算单", response = ResponseResult.class)
public ResponseResult approve(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
    // 校验采购结算单状态
    PurchaseSettlementOrder purchaseSettlementOrder = purchaseSettlementOrderService.getById(id);
    if (purchaseSettlementOrder == null || !purchaseSettlementOrder.getStatus().equals(PurchaseSettlementOrderStatusConstants.WAIT_FOR_APPROVE)) {
        return ResponseResult.buildError("采购结算单不存在或状态不为待审核中");
    }
    // 进行审核状态更改
    purchaseSettlementOrderService.approve(id, status);
    return ResponseResult.buildSuccess();
}
Also used : PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with PurchaseSettlementOrder

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

the class PurchaseSettlementOrderServiceImpl method savePurchaseSettlementOrderAndItem.

@Override
public void savePurchaseSettlementOrderAndItem(PurchaseSettlementOrderDTO settlementOrderDTO) {
    // 1. 新增采购结算单
    settlementOrderDTO.setStatus(PurchaseSettlementOrderStatusConstants.EDITING);
    BigDecimal totalSettlementAmount = BigDecimal.ZERO;
    for (PurchaseSettlementOrderItemDTO item : settlementOrderDTO.getItems()) {
        totalSettlementAmount = totalSettlementAmount.add(item.getPurchasePrice().multiply(new BigDecimal(item.getArrivalCount())));
    }
    settlementOrderDTO.setTotalSettlementAmount(totalSettlementAmount);
    PurchaseSettlementOrder purchaseSettlementOrder = settlementOrderDTO.clone(PurchaseSettlementOrder.class);
    this.save(purchaseSettlementOrder);
    // 2. 新增采购结算条目单
    List<PurchaseSettlementOrderItem> settlementOrderItemList = BeanCopierUtils.copyListProperties(settlementOrderDTO.getItems(), PurchaseSettlementOrderItem::new);
    settlementOrderItemList.forEach(item -> item.setPurchaseSettlementOrderId(purchaseSettlementOrder.getId()));
    purchaseSettlementOrderItemService.saveBatch(settlementOrderItemList);
}
Also used : PurchaseSettlementOrderItem(com.whoiszxl.entity.PurchaseSettlementOrderItem) PurchaseSettlementOrderItemDTO(com.whoiszxl.dto.PurchaseSettlementOrderItemDTO) BigDecimal(java.math.BigDecimal) PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder)

Example 5 with PurchaseSettlementOrder

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

the class PurchaseSettlementOrderServiceImpl method updateStatus.

@Override
public void updateStatus(Long id, Integer status) {
    PurchaseSettlementOrder result = this.getById(id);
    if (result == null) {
        ExceptionCatcher.catchDatabaseFailEx();
    }
    result.setStatus(status);
    this.updateById(result);
}
Also used : PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder)

Aggregations

PurchaseSettlementOrder (com.whoiszxl.entity.PurchaseSettlementOrder)6 PurchaseSettlementOrderItemDTO (com.whoiszxl.dto.PurchaseSettlementOrderItemDTO)2 PurchaseSettlementOrderItem (com.whoiszxl.entity.PurchaseSettlementOrderItem)2 ApiOperation (io.swagger.annotations.ApiOperation)2 BigDecimal (java.math.BigDecimal)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PurchaseSettlementOrderDTO (com.whoiszxl.dto.PurchaseSettlementOrderDTO)1 PurchaseSupplier (com.whoiszxl.entity.PurchaseSupplier)1 Date (java.util.Date)1