InitController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace console\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use bizHd\custom\classes\CustomClass;
  5. use bizHd\custom\classes\HdClass;
  6. use common\components\stringUtil;
  7. use yii\console\Controller;
  8. class InitController extends Controller
  9. {
  10. // ./yii init/hd
  11. public function actionHd()
  12. {
  13. ini_set('memory_limit', '2045M');
  14. set_time_limit(0);
  15. $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  16. if (!empty($customList)) {
  17. foreach ($customList as $custom) {
  18. $hdId = $custom->hdId ?? 0;
  19. if (!empty($hdId)) {
  20. continue;
  21. }
  22. $shopId = $custom->shopId ?? 0;
  23. $shop = ShopClass::getById($shopId, true);
  24. if (empty($shop)) {
  25. echo "没有门店 \n";
  26. continue;
  27. }
  28. $userId = $custom->userId ?? 0;
  29. $shopName = $shop->shopName ?? '';
  30. $hdMobile = $shop->mobile ?? '';
  31. $sjId = $shop->sjId ?? 0;
  32. $sjName = $shop->merchantName ?? '';
  33. $hdName = $shop->default == 1 ? $sjName : $sjName . ' ' . $shopName;
  34. $hdPy = stringUtil::py($hdName);
  35. $customId = $custom->id ?? 0;
  36. $hdAvatar = $shop->avatar ?? '';
  37. $hdData = [
  38. 'shopId' => $shopId,
  39. 'userId' => $userId,
  40. 'name' => $hdName,
  41. 'sjId' => $sjId,
  42. 'customId' => $customId,
  43. 'avatar' => $hdAvatar,
  44. 'py' => $hdPy,
  45. 'mobile' => $hdMobile,
  46. 'province' => $shop->province ?? '',
  47. 'city' => $shop->city ?? '',
  48. 'dist' => $shop->dist ?? '',
  49. 'address' => $shop->address ?? '',
  50. 'floor' => $shop->floor ?? '',
  51. 'fullAddress' => $shop->fullAddress ?? '',
  52. 'showAddress' => $shop->showAddress ?? '',
  53. 'lat' => $shop->lat ?? '',
  54. 'long' => $shop->long ?? '',
  55. ];
  56. HdClass::addData($hdData);
  57. echo "OK\n";
  58. }
  59. }
  60. }
  61. }