2], null, '*', null, true); if (!empty($list)) { foreach ($list as $shop) { $sjName = $shop->merchantName ?? ''; $shopName = $shop->shopName ?? ''; $mainId = $shop->mainId ?? 0; $main = MainClass::getById($mainId, true); if (empty($main)) { continue; } $customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, '*', null, true); $ghsCustomDebt = 0; if (!empty($customList)) { foreach ($customList as $custom) { $debtAmount = $custom->debtAmount ?? 0; $ghsCustomDebt = bcadd($ghsCustomDebt, $debtAmount, 2); } } $hdCustomDebt = 0; $lsShopId = $shop->lsShopId ?? 0; $customList = \bizHd\custom\classes\CustomClass::getAllByCondition(['shopId' => $lsShopId], null, '*', null, true); if (!empty($customList)) { foreach ($customList as $custom) { $currentDebt = $custom->debtAmount ?? 0; $hdCustomDebt = bcadd($currentDebt, $hdCustomDebt, 2); } } $totalDebt = bcadd($ghsCustomDebt, $hdCustomDebt, 2); if (floatval($totalDebt) != floatval($main->debt)) { noticeUtil::push("{$sjName} {$shopName}的批零客户欠款总和跟main里的欠款不一致 总和欠款:{$totalDebt} main欠款:{$main->debt} mainId:{$mainId} | 批发:{$ghsCustomDebt} 零售:{$hdCustomDebt}", '15280215347'); } } } } public function actionHasGhs() { $query = new \yii\db\Query(); $query->from(Shop::tableName()); $query->where(['ptStyle' => 1]); foreach ($query->batch() as $shopList) { foreach ($shopList as $shop) { $shopId = $shop['id'] ?? 0; $where = ['ownShopId' => $shopId]; $count = GhsClass::getCount($where); if ($count == 0) { //无操作 } elseif ($count == 1) { $ghs = GhsClass::getByCondition($where, true); $ghsId = $ghs->id ?? 0; if (!empty($ghsId)) { ShopClass::updateById($shopId, ['uniGhsId' => $ghsId]); } } else { ShopClass::updateById($shopId, ['hasManyGhs' => 1]); } } } } public function actionOrder() { $query = new \yii\db\Query(); $query->from(Order::tableName()); $query->where(['>', 'id', 0]); foreach ($query->batch() as $orderList) { foreach ($orderList as $order) { $payTime = $order['payTime'] ?? ''; if (!empty($payTime) && $payTime != '0000-00-00 00:00:00') { $addTime = $order['addTime'] ?? ''; if ($payTime > $addTime) { echo "id:{$order['id']} {$payTime} {$addTime}\n"; OrderClass::updateById($order['id'], ['addTime' => $payTime]); $purchaseId = $order['purchaseId'] ?? 0; $cg = PurchaseClass::getById($purchaseId, true); if (!empty($cg)) { $cg->addTime = $payTime; $cg->save(); } } } } } } public function actionCustom() { $custom = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true); if (empty($custom)) { echo '空'; return false; } foreach ($custom as $item) { $shopId = $item->shopId ?? 0; $shop = ShopClass::getById($shopId, true); if ($shop->mainId != $item->mainId) { echo "客户id:{$item->id} {$shop->mainId} {$item->mainId}\n"; if (!empty($shop->mainId)) { $item->mainId = $shop->mainId; $item->save(); } } $ownShopId = $item->ownShopId ?? 0; $ownShop = ShopClass::getById($ownShopId, true); if ($ownShop->mainId != $item->ownMainId) { echo "客户own {$item->id} {$item->ownMainId} {$ownShop->mainId}\n"; if (!empty($ownShop->mainId)) { $item->ownMainId = $ownShop->mainId; $item->save(); } } } } public function actionGhs() { $ghs = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true); if (empty($ghs)) { echo '空'; return false; } foreach ($ghs as $item) { $shopId = $item->shopId ?? 0; $mainId = $item->mainId ?? 0; $shop = ShopClass::getById($shopId, true); if ($shop->mainId != $mainId) { echo "ghs {$item->id} {$mainId} {$shop->mainId} \n"; } $ownShopId = $item->ownShopId ?? 0; $ownMainId = $item->ownMainId ?? 0; $ownShop = ShopClass::getById($ownShopId, true); if ($ownShop->mainId != $ownMainId) { echo "ghs own {$item->id} {$ownMainId} {$ownShop->mainId} \n"; if (!empty($ownShop->mainId)) { $item->ownMainId = $ownShop->mainId; $item->save(); } } } } }