| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace console\controllers;
- use biz\merchant\services\MerchantService;
- use biz\user\services\UserService;
- use biz\wx\services\WxOpenService;
- use common\services\xhAdminService;
- use common\services\xhMerchantAssetService;
- use common\services\xhMerchantExtendService;
- use common\services\xhWxMenuService;
- use Yii;
- use yii\console\Controller;
- use common\components\util;
- use common\services\xhTMessageService;
- use common\services\xhMerchantService;
- use common\models\xhMerchant;
- use common\services\xhInitService;
- /**
- * 脚本
- */
- class InitController extends Controller
- {
-
- //开店初始化 shish 2020.2.8
- public function actionRabbit()
- {
- $data = ['merchantId' => 12362];
- $producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
- $msg = serialize($data);
- $producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
- }
-
- //二次初始化 shish 2020.1.19
- public function actionSecondInit($id = 0)
- {
- $merchant = xhMerchantService::getById($id);
- if (empty($merchant)) {
- echo "商家无效\n";
- }
- //初始化微信菜单
- xhWxMenuService::applyInit($merchant);
- }
-
- public function actionChangeDb()
- {
- echo 'ok';
- }
-
- //接入一个商家需要的操作 shish 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();
- }
- // 拉取微信用户 shish 2019.9.9
- public function actionPullUser2()
- {
- $merchantId = 12359;
- $return = UserService::syncWxAllUser($merchantId);
- $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
- xhMerchantAssetService::updateByMerchantId($merchantId, ['totalFans' => $total]);
- }
-
- }
|