from(Shop::tableName()); $query->where(['ptStyle' => 2]); foreach ($query->batch(10) as $batch) { foreach ($batch as $shop) { $sjName = $shop['merchantName'] ?? ''; $shopName = $shop['shopName'] ?? ''; $name = $sjName . ' ' . $shopName; $where = ['ownShopId' => $shop['id']]; $ghsList = GhsClass::getAllByCondition($where, null, '*', null, true); if (!empty($ghsList)) { foreach ($ghsList as $ghs) { $ghsName = $ghs->name ?? ''; $ghsId = $ghs->id ?? 0; $totalDebtAmount = PurchaseOrderClass::sum(['ghsId' => $ghsId, 'status' => 4, 'debt' => PurchaseOrderClass::DEBT_YES], 'actPrice'); $totalDebtAmount = empty($totalDebtAmount) ? 0 : $totalDebtAmount; $ghsDebtAmount = $ghs->debtAmount ?? 0; if (floatval($totalDebtAmount) != floatval($ghsDebtAmount)) { noticeUtil::push("{$name}的供货商{$ghsName}({$ghsId})应付金额不一致。登记金额:{$ghsDebtAmount} 汇总金额:{$totalDebtAmount}", '15280215347'); } } } } } } }