Search in sources :

Example 6 with PurchaseSettlementOrder

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

the class WeekSettlementHandler method execute.

@Override
public boolean execute() {
    // 1. 通过结算周期获取到所有的供应商
    List<PurchaseSupplier> supplierList = purchaseSupplierService.list(new LambdaQueryWrapper<PurchaseSupplier>().eq(PurchaseSupplier::getAccountPeriod, AccountPeriodConstants.WEEK));
    // 2. 遍历供应商,获取到这周的已审核的结算单
    for (PurchaseSupplier supplier : supplierList) {
        Date endTime = new Date();
        Date startTime = DateUtils.addDays(endTime, -7);
        LambdaQueryWrapper<PurchaseSettlementOrder> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(PurchaseSettlementOrder::getSupplierId, supplier.getId());
        queryWrapper.between(PurchaseSettlementOrder::getCreatedAt, startTime, endTime);
        List<PurchaseSettlementOrder> settlementOrderList = purchaseSettlementOrderService.list(queryWrapper);
        BigDecimal totalSettlementAmount = BigDecimal.ZERO;
        for (PurchaseSettlementOrder settlementOrder : settlementOrderList) {
            totalSettlementAmount = totalSettlementAmount.add(settlementOrder.getTotalSettlementAmount());
        }
        payForSupplier(supplier.getBankName(), supplier.getBankAccount(), supplier.getAccountHolder(), totalSettlementAmount);
        // 通过供应商ID更新采购单状态为已完成
        purchaseOrderService.updateFinishedBySupplierId(supplier.getId());
    }
    return true;
}
Also used : PurchaseSupplier(com.whoiszxl.entity.PurchaseSupplier) Date(java.util.Date) PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder) BigDecimal(java.math.BigDecimal) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

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