|
|
@@ -7,6 +7,7 @@ use bizGhs\ghs\classes\GhsClass;
|
|
|
use bizGhs\ghs\classes\GhsDebtRecordClass;
|
|
|
use bizGhs\order\classes\PurchaseOrderClass;
|
|
|
use common\components\dict;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
use yii\console\Controller;
|
|
|
use Yii;
|
|
|
@@ -14,6 +15,37 @@ use Yii;
|
|
|
class GhsController extends Controller
|
|
|
{
|
|
|
|
|
|
+ //供货商欠款跟踪 ssh 20240629 重要脚本
|
|
|
+ public function actionAdjustDebt()
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ $query = new \yii\db\Query();
|
|
|
+ $query->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');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function actionDebt()
|
|
|
{
|
|
|
ini_set('memory_limit', '2045M');
|