GhsInfoController.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace console\controllers;
  3. use bizHd\ghs\classes\GhsClass;
  4. use bizHd\ghs\models\Ghs;
  5. use bizHd\merchant\classes\ShopClass;
  6. use yii\console\Controller;
  7. use Yii;
  8. class GhsInfoController extends Controller
  9. {
  10. public function actionMobile()
  11. {
  12. ini_set('memory_limit', '2045M');
  13. set_time_limit(0);
  14. $query = new \yii\db\Query();
  15. $query->from(Ghs::tableName());
  16. $query->where(['mobile' => '']);
  17. foreach ($query->batch(10) as $batch) {
  18. foreach ($batch as $ghs) {
  19. $ghsId = $ghs['id'];
  20. $shopId = $ghs['shopId'];
  21. $shop = ShopClass::getByCondition(['id' => $shopId], true, null, 'id,mobile');
  22. if (!empty($shop)) {
  23. $mobile = $shop->mobile;
  24. if (!empty($mobile)) {
  25. GhsClass::updateById($ghsId, ['mobile' => $mobile]);
  26. echo $mobile . "\n";
  27. }
  28. }
  29. }
  30. }
  31. }
  32. }