|
|
@@ -4,6 +4,11 @@ namespace console\controllers;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizGhs\custom\models\Custom;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
+use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use common\components\noticeUtil;
|
|
|
+use common\components\util;
|
|
|
use yii\console\Controller;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -27,4 +32,66 @@ class CustomController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //欠款信息不一致跟踪 shish 20220307 ./yii custom/adjust-debt
|
|
|
+ public function actionAdjustDebt()
|
|
|
+ {
|
|
|
+ $query = new \yii\db\Query();
|
|
|
+
|
|
|
+ $query->from(Custom::tableName());
|
|
|
+
|
|
|
+ $query->orderBy('addTime ASC');
|
|
|
+
|
|
|
+ foreach ($query->batch(50) as $customList) {
|
|
|
+ if (!empty($customList)) {
|
|
|
+ foreach ($customList as $custom) {
|
|
|
+
|
|
|
+ $customId = $custom['id'] ?? 0;
|
|
|
+ $where = ['customId' => $customId, 'debt' => 1];
|
|
|
+ $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*');
|
|
|
+ if (empty($orderList)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $ghsOrderDebtAmount = 0;
|
|
|
+ foreach ($orderList as $order) {
|
|
|
+ $actPrice = $order['actPrice'] ?? 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;
|
|
|
+ foreach ($cgList as $cg) {
|
|
|
+ $actPrice = $cg['actPrice'] ?? 0;
|
|
|
+ $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
|
|
|
+ }
|
|
|
+ $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount);
|
|
|
+ $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount);
|
|
|
+
|
|
|
+ echo "供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
|
|
|
+
|
|
|
+ if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) {
|
|
|
+ noticeUtil::push("供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347');
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0;
|
|
|
+ $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0;
|
|
|
+
|
|
|
+ if ($customSaveDebtAmount != $ghsOrderDebtAmount) {
|
|
|
+ noticeUtil::push("客户 {$customId} 欠款总金额 和 订单总合 不一致", '15280215347');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) {
|
|
|
+ noticeUtil::push("欠供应商 {$ghsId} 金额 和 订单总合 不一致", '15280215347');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|