|
|
@@ -3,18 +3,63 @@
|
|
|
namespace console\controllers;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
+use biz\shop\classes\MainClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use biz\shop\models\Shop;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\order\models\Order;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use common\components\noticeUtil;
|
|
|
use yii\console\Controller;
|
|
|
use Yii;
|
|
|
|
|
|
class ShopController extends Controller
|
|
|
{
|
|
|
|
|
|
+ //【有用的脚本】总欠款变动记录跟踪 ./yii shop/total-debt-check ssh 20220909
|
|
|
+ public function actionTotalDebtCheck()
|
|
|
+ {
|
|
|
+
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $list = ShopClass::getAllByCondition(['ptStyle' => 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里的欠款总合不一致", '15280215347');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function actionHasGhs()
|
|
|
{
|
|
|
$query = new \yii\db\Query();
|