InitController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace console\controllers;
  3. use biz\goods\services\GoodsService;
  4. use biz\goods\services\GoodsStyleService;
  5. use biz\merchant\services\MerchantService;
  6. use biz\user\services\UserService;
  7. use biz\wx\services\WxOpenService;
  8. use common\services\xhAdminService;
  9. use common\services\xhMerchantAssetService;
  10. use common\services\xhMerchantExtendService;
  11. use common\services\xhWxMenuService;
  12. use Yii;
  13. use yii\console\Controller;
  14. use common\components\util;
  15. use common\services\xhTMessageService;
  16. use common\services\xhMerchantService;
  17. use common\models\xhMerchant;
  18. use common\services\xhInitService;
  19. /**
  20. * 脚本
  21. */
  22. class InitController extends Controller
  23. {
  24. //开店初始化 shish 2020.2.8
  25. public function actionRabbit()
  26. {
  27. $data = ['merchantId' => 12362];
  28. $producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
  29. $msg = serialize($data);
  30. $producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
  31. }
  32. //二次初始化 shish 2020.1.19
  33. public function actionSecondInit($id = 0)
  34. {
  35. $merchant = xhMerchantService::getById($id);
  36. if (empty($merchant)) {
  37. echo "商家无效\n";
  38. }
  39. //初始化微信菜单
  40. xhWxMenuService::applyInit($merchant);
  41. }
  42. public function actionChangeDb()
  43. {
  44. echo 'ok';
  45. }
  46. //接入一个商家需要的操作 shish 2019.9.7
  47. // yii init/join-one 12358 更新某个商家公众号
  48. // yii init/join-one 更新平台公众号
  49. public function actionJoinOne($id = 0)
  50. {
  51. //初始化微信菜单
  52. if ($id == 0) {
  53. $isOpen = 1;
  54. $merchant = WxOpenService::getWxInfo();
  55. $merchant['id'] = 0;
  56. } else {
  57. $isOpen = 0;
  58. $merchant = xhMerchantService::getById($id);
  59. }
  60. //xhWxMenuService::applyInit($merchant);
  61. //模板消息
  62. $r = xhTMessageService::supplement($merchant, $isOpen);
  63. print_r($r);
  64. }
  65. //yii init/sub
  66. public function actionSub()
  67. {
  68. $name = 'redis_shi';
  69. $redisPubSub = \Yii::$app->redisPubSub;
  70. $redisPubSub->setOptReadTimeout(-1);
  71. $redisPubSub->subscribe($name, function ($instance, $channelName, $message) {
  72. $a = 123;
  73. });
  74. }
  75. public function actionPub()
  76. {
  77. $name = 'redis_shi';
  78. $time = 'nihao1123';
  79. $redisPubSub = \Yii::$app->redisPubSub;
  80. $redisPubSub->publish($name, $time);
  81. }
  82. public function actionPullUser()
  83. {
  84. //拉取用户
  85. $this->actionPullUser();
  86. }
  87. // 拉取微信用户 shish 2019.9.9
  88. public function actionPullUser2()
  89. {
  90. $merchantId = 12359;
  91. $return = UserService::syncWxAllUser($merchantId);
  92. $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
  93. xhMerchantAssetService::updateByMerchantId($merchantId, ['totalFans' => $total]);
  94. }
  95. //商品多款式 shish 2020.6.4
  96. public function actionUpdateGoods()
  97. {
  98. GoodsStyleService::updateGlhsGoods();
  99. }
  100. }