InitController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace console\controllers;
  3. use bizHd\user\services\UserService;
  4. use bizHd\wx\services\WxOpenService;
  5. use common\services\xhMerchantAssetService;
  6. use common\services\xhWxMenuService;
  7. use Yii;
  8. use yii\console\Controller;
  9. use common\services\xhTMessageService;
  10. use common\services\xhMerchantService;
  11. /**
  12. * 脚本
  13. */
  14. class InitController extends Controller
  15. {
  16. //微信菜单初始化 shish 20210526
  17. // yii init/menu-init
  18. public function actionMenuInit()
  19. {
  20. xhWxMenuService::menuInit();
  21. }
  22. //接入一个商家需要的操作 ssh 2019.9.7
  23. // yii init/join-one 12358 更新某个商家公众号
  24. // yii init/join-one 更新平台公众号
  25. public function actionJoinOne($id = 0)
  26. {
  27. //初始化微信菜单
  28. if ($id == 0) {
  29. $isOpen = 1;
  30. $merchant = WxOpenService::getWxInfo();
  31. $merchant['id'] = 0;
  32. } else {
  33. $isOpen = 0;
  34. $merchant = xhMerchantService::getById($id);
  35. }
  36. //xhWxMenuService::applyInit($merchant);
  37. //模板消息
  38. $r = xhTMessageService::supplement($merchant, $isOpen);
  39. print_r($r);
  40. }
  41. //yii init/sub
  42. public function actionSub()
  43. {
  44. $name = 'redis_shi';
  45. $redisPubSub = \Yii::$app->redisPubSub;
  46. $redisPubSub->setOptReadTimeout(-1);
  47. $redisPubSub->subscribe($name, function ($instance, $channelName, $message) {
  48. $a = 123;
  49. });
  50. }
  51. public function actionPub()
  52. {
  53. $name = 'redis_shi';
  54. $time = 'nihao1123';
  55. $redisPubSub = \Yii::$app->redisPubSub;
  56. $redisPubSub->publish($name, $time);
  57. }
  58. public function actionPullUser()
  59. {
  60. //拉取用户
  61. $this->actionPullUser();
  62. }
  63. // 拉取微信用户 ssh 2019.9.9
  64. public function actionPullUser2()
  65. {
  66. $sjId = 12359;
  67. $return = UserService::syncWxAllUser($sjId);
  68. $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
  69. xhMerchantAssetService::updateBySjId($sjId, ['totalFans' => $total]);
  70. }
  71. //更新用户名称
  72. public function actionUpdateName()
  73. {
  74. $sjId = 12362;
  75. UserService::syncWxAllUser($sjId);
  76. }
  77. //消息模板初始化 linqh ./yii init/t-message
  78. public function actionTMessage()
  79. {
  80. xhTMessageService::initTMessage();
  81. }
  82. }