shish 11 месяцев назад
Родитель
Сommit
c745c2eaa6
1 измененных файлов с 36 добавлено и 0 удалено
  1. 36 0
      console/controllers/GhsInfoController.php

+ 36 - 0
console/controllers/GhsInfoController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace console\controllers;
+
+use bizHd\ghs\classes\GhsClass;
+use bizHd\ghs\models\Ghs;
+use bizHd\merchant\classes\ShopClass;
+use yii\console\Controller;
+use Yii;
+
+class GhsInfoController extends Controller
+{
+
+    public function actionMobile()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $query = new \yii\db\Query();
+        $query->from(Ghs::tableName());
+        $query->where(['mobile' => '']);
+        foreach ($query->batch(10) as $batch) {
+            foreach ($batch as $ghs) {
+                $ghsId = $ghs['id'];
+                $shopId = $ghs['shopId'];
+                $shop = ShopClass::getByCondition(['id' => $shopId], true, null, 'id,mobile');
+                if (!empty($shop)) {
+                    $mobile = $shop->mobile;
+                    if (!empty($mobile)) {
+                        GhsClass::updateById($ghsId, ['mobile' => $mobile]);
+                    }
+                }
+            }
+        }
+    }
+
+}