2], null, '*', null, true); if (!empty($list)) { foreach ($list as $c) { $ghsId = $c->ghsId ?? 0; $ghs = GhsClass::getById($ghsId, true); if (!empty($ghs)) { $ghs->black = 2; $ghs->save(); echo $ghs->name . " id:{$ghs->id} 已经黑了\n"; } } } } //欠款信息不一致跟踪 ssh 20220307 ./yii custom/adjust-debt public function actionAdjustDebt() { $shopList = ShopClass::getAllByCondition(['ptStyle' => 2], null, '*', null, true); if (empty($shopList)) { return false; } foreach ($shopList as $key => $shop) { $shopId = $shop->id ?? 0; // $shopName = $shop->shopName ?? ''; // $merchantName = $shop->merchantName ?? ''; // echo "{$merchantName}-{$shopName} \n\n\n\n"; $query = new \yii\db\Query(); $query->from(Custom::tableName()); $query->where(['ownShopId' => $shopId]); $query->orderBy('addTime ASC'); foreach ($query->batch(50) as $customList) { if (!empty($customList)) { foreach ($customList as $custom) { //$customName = $custom['name'] ?? ''; $customId = $custom['id'] ?? 0; $where = ['customId' => $customId, 'debt' => 1]; $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*'); $ghsOrderDebtAmount = 0; if (!empty($orderList)) { foreach ($orderList as $order) { $actPrice = $order['remainDebtPrice'] ?? 0; $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2); } } $ghsId = $custom['ghsId'] ?? 0; $ghs = \bizHd\ghs\classes\GhsClass::getById($ghsId); $where = ['ghsId' => $ghsId, 'debt' => PurchaseClass::DEBT_YES]; $cgList = PurchaseClass::getAllByCondition($where, 'addTime DESC', '*'); $hdCgOrderDebtAmount = 0; if (!empty($cgList)) { foreach ($cgList as $cg) { $actPrice = $cg['remainDebtPrice'] ?? 0; $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2); } } if ($ghsOrderDebtAmount < 0 || $hdCgOrderDebtAmount < 0) { noticeUtil::push("!!!!!!!供应商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount", '15280215347'); echo "@@@@@@@@@@@@@供应商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount \n"; } $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount); $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount); if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) { noticeUtil::push("!!!!!!!供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347'); echo "---------供应商 {$ghsId} 客户id {$customId} 二边 欠款单 总金额 不一致 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n"; continue; } $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0; $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0; if ($customSaveDebtAmount != $ghsOrderDebtAmount) { echo "*********客户 {$customId} 欠款 和 订单总额 不一致 $customSaveDebtAmount $ghsOrderDebtAmount \n"; noticeUtil::push("*********客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount ", '15280215347'); // echo "已更:".$hdCgOrderDebtAmount.' '.$ghsOrderDebtAmount."\n"; // \bizHd\ghs\classes\GhsClass::updateById($ghsId, ['debtAmount' => $hdCgOrderDebtAmount]); // CustomClass::updateById($customId, ['debtAmount' => $ghsOrderDebtAmount]); continue; } if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) { echo "#########欠供应商 {$ghsId} 和 订单总额 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount \n"; noticeUtil::push("#########欠供应商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount ", '15280215347'); // echo "已更:".$hdCgOrderDebtAmount.' '.$ghsOrderDebtAmount."\n"; // \bizHd\ghs\classes\GhsClass::updateById($ghsId, ['debtAmount' => $hdCgOrderDebtAmount]); // CustomClass::updateById($customId, ['debtAmount' => $ghsOrderDebtAmount]); continue; } } } } } } public function actionCreateCustomer() { $customerCachedKey = 'customers_list'; while ($count = Yii::$app->redis->executeCommand('LLEN', [$customerCachedKey])) { $customer = Yii::$app->redis->executeCommand('RPOP', [$customerCachedKey]); $customers[] = $customer; } if (!isset($customers)) { return; } foreach($customers as $customer) { $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); $customerInfo = explode('_', $customer); $post = []; // 组织表单数据 $shopName = $customerInfo[0]; $post['name'] = $shopName; if (empty($shopName)) { Yii::info('名称不能为空'); continue; } $mobile = $customerInfo[1]; $post['mobile'] = $mobile; if (stringUtil::isMobile($mobile) == false) { Yii::info('请填写正确手机号'); continue; } if (stringUtil::getWordNum($shopName) > 8) { Yii::info('名称不能超过8个汉字'); continue; } $has = SjClass::getByCondition(['name' => $shopName]); if (!empty($has)) { Yii::info('名称已经存在'); continue; } $has = ApplyClass::getByCondition(['mobile' => $mobile]); if (!empty($has)) { //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!! Yii::info('手机号已经申请过了(手机号开了零售店)'); continue; } $hasShop = ShopClass::getByCondition(['mobile' => $mobile]); if (!empty($hasShop)) { //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!! Yii::info('手机号已经被使用(手机号开了零售店)'); continue; } $adminName = $post['adminName'] ?? ''; $miniOpenId = $post['miniOpenId'] ?? ''; $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId]; $fromApp = dict::getDict('userSourceGetId', 'app', 'id'); $admin = AdminClass::replaceAdmin($adminInfo, $fromApp); $adminId = $admin['id'] ?? 0; $currentShopId = $admin['currentShopId'] ?? 0; if (!empty($currentShopId)) { util::fail('您已提交过申请,管理员ID:' . $adminId); } if (isset($admin['openShop']) && $admin['openShop'] == 2) { util::fail('审核中,无需重复申请'); } $post['adminId'] = $adminId; $post['adminName'] = $admin['name'] ?? ''; $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';// TODO $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';// TODO $post['from'] = ApplyClass::FROM_RETAIL; $post['style'] = SjClass::STYLE_RETAIL; //增加或更新申请 $respond = ApplyService::replaceRetail($post); $id = $respond['id'] ?? 0; if (empty($id)) { Yii::info('申请失败'); continue; } $passInfo = ApplyService::pass($id); //输出登录信息 $newShop = $passInfo['shop'] ?? []; $newMainId = $newShop->mainId ?? 0; $newShopId = $newShop->id ?? 0; $pfShopId = $newShop->pfShopId ?? 0; //前端用于判断是否注册 $admin['currentShopId'] = $newShopId; $adminId = $admin['id']; $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'mainId' => $newMainId], true); if (empty($shopAdmin)) { Yii::info('没有找到管理员'); continue; } //$shopAdmin->lastLogin = date("Y-m-d H:i:s"); //$shopAdmin->save(); //是否有切换门店的权限 $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin); $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND'); $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING'); if ($hdUpgrading == 1) { Yii::info('系统升级中,稍后再试'); continue; } $transaction->commit(); noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 被批发端手动注册", '15280215347'); echo "create customers success"; } } }