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;
}
Aggregations