| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace console\controllers;
- use bizHd\user\services\UserService;
- use bizHd\wx\services\WxOpenService;
- use common\services\xhMerchantAssetService;
- use common\services\xhWxMenuService;
- use Yii;
- use yii\console\Controller;
- use common\services\xhTMessageService;
- use common\services\xhMerchantService;
- /**
- * 脚本
- */
- class InitController extends Controller
- {
- //微信菜单初始化 shish 20210526
- // yii init/menu-init
- public function actionMenuInit()
- {
- xhWxMenuService::menuInit();
- }
- //接入一个商家需要的操作 ssh 2019.9.7
- // yii init/join-one 12358 更新某个商家公众号
- // yii init/join-one 更新平台公众号
- public function actionJoinOne($id = 0)
- {
- //初始化微信菜单
- if ($id == 0) {
- $isOpen = 1;
- $merchant = WxOpenService::getWxInfo();
- $merchant['id'] = 0;
- } else {
- $isOpen = 0;
- $merchant = xhMerchantService::getById($id);
- }
- //xhWxMenuService::applyInit($merchant);
- //模板消息
- $r = xhTMessageService::supplement($merchant, $isOpen);
- print_r($r);
- }
- //yii init/sub
- public function actionSub()
- {
- $name = 'redis_shi';
- $redisPubSub = \Yii::$app->redisPubSub;
- $redisPubSub->setOptReadTimeout(-1);
- $redisPubSub->subscribe($name, function ($instance, $channelName, $message) {
- $a = 123;
- });
- }
- public function actionPub()
- {
- $name = 'redis_shi';
- $time = 'nihao1123';
- $redisPubSub = \Yii::$app->redisPubSub;
- $redisPubSub->publish($name, $time);
- }
- public function actionPullUser()
- {
- //拉取用户
- $this->actionPullUser();
- }
- // 拉取微信用户 ssh 2019.9.9
- public function actionPullUser2()
- {
- $sjId = 12359;
- $return = UserService::syncWxAllUser($sjId);
- $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
- xhMerchantAssetService::updateBySjId($sjId, ['totalFans' => $total]);
- }
- //更新用户名称
- public function actionUpdateName()
- {
- $sjId = 12362;
- UserService::syncWxAllUser($sjId);
- }
- //消息模板初始化 linqh ./yii init/t-message
- public function actionTMessage()
- {
- xhTMessageService::initTMessage();
- }
- }
|