InitController.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?php
  2. namespace console\controllers;
  3. use biz\merchant\services\MerchantService;
  4. use biz\user\services\UserService;
  5. use biz\wx\services\WxOpenService;
  6. use common\services\xhAdminService;
  7. use common\services\xhMerchantAssetService;
  8. use common\services\xhMerchantExtendService;
  9. use common\services\xhWxMenuService;
  10. use Yii;
  11. use yii\console\Controller;
  12. use common\components\util;
  13. use common\services\xhTMessageService;
  14. use common\services\xhMerchantService;
  15. use common\models\xhMerchant;
  16. use common\services\xhInitService;
  17. /**
  18. * 脚本
  19. */
  20. class InitController extends Controller
  21. {
  22. //开店初始化 shish 2020.2.8
  23. public function actionRabbit()
  24. {
  25. $data = ['merchantId' => 12362];
  26. $producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
  27. $msg = serialize($data);
  28. $producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
  29. }
  30. //哪些东西开店时需要初始化!!!!!
  31. public function actionFirstInit()
  32. {
  33. //CouponAsset优惠券资产
  34. //初始化微信菜单
  35. //模板消息
  36. }
  37. //二次初始化 shish 2020.1.19
  38. public function actionSecondInit($id = 0)
  39. {
  40. $merchant = xhMerchantService::getById($id);
  41. if (empty($merchant)) {
  42. echo "商家无效\n";
  43. }
  44. //初始化微信菜单
  45. xhWxMenuService::applyInit($merchant);
  46. }
  47. public function actionChangeDb()
  48. {
  49. echo 'ok';
  50. }
  51. //接入一个商家需要的操作 shish 2019.9.7
  52. // yii init/join-one 12358 更新某个商家公众号
  53. // yii init/join-one 更新平台公众号
  54. public function actionJoinOne($id = 0)
  55. {
  56. //初始化微信菜单
  57. if ($id == 0) {
  58. $isOpen = 1;
  59. $merchant = WxOpenService::getWxInfo();
  60. $merchant['id'] = 0;
  61. } else {
  62. $isOpen = 0;
  63. $merchant = xhMerchantService::getById($id);
  64. }
  65. //xhWxMenuService::applyInit($merchant);
  66. //模板消息
  67. $r = xhTMessageService::supplement($merchant, $isOpen);
  68. print_r($r);
  69. }
  70. //yii init/sub
  71. public function actionSub()
  72. {
  73. $name = 'redis_shi';
  74. $redisPubSub = \Yii::$app->redisPubSub;
  75. $redisPubSub->setOptReadTimeout(-1);
  76. $redisPubSub->subscribe($name, function ($instance, $channelName, $message) {
  77. $a = 123;
  78. });
  79. }
  80. public function actionPub()
  81. {
  82. $name = 'redis_shi';
  83. $time = 'nihao1123';
  84. $redisPubSub = \Yii::$app->redisPubSub;
  85. $redisPubSub->publish($name, $time);
  86. }
  87. public function actionBegin()
  88. {
  89. //先清除公众号里的模板消息!!!!!!!
  90. $num = 0;
  91. //清空数据
  92. $this->actionFlushAll();
  93. //国兰花尚
  94. if ($num == 0) {
  95. xhAdminService::updateById(1, ['mobile' => '18030142050', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => 'c80fd29375a3a91d3681d8445822248a', 'adminName' => '姜祖岚']);
  96. xhMerchantService::updateById(12358, [
  97. 'merchantName' => '国兰花尚',
  98. 'miniAppId' => 'wxe994a9f5fd036f69',
  99. 'miniAppSecret' => '53b646675251e940f56bd304c2dba480',
  100. 'wxAppId' => 'wx193341a4a80f6ea3',
  101. 'wxUserName' => 'gh_090c30df22e6',
  102. 'wxAliasName' => 'glhs520',
  103. 'openAppId' => 'wxe9211595a1d5a39f',
  104. 'wxToken' => 'wt01467284437',
  105. 'status' => 1,
  106. ]);
  107. xhMerchantExtendService::updateByMerchantId(12358, [
  108. 'wxAppId' => 'wx193341a4a80f6ea3',
  109. 'miniAppId' => 'wxe994a9f5fd036f69',
  110. 'wxPayMerchantId' => '1244548702',
  111. 'wxPayKey' => 'eez23jf739jsmm4309j10jnza3qw8dwm',
  112. 'webTitle' => '国兰花尚',
  113. 'webKeyword' => '国兰花尚',
  114. 'webDescription' => '国兰花尚',
  115. 'alipayAccount' => '18030142050',
  116. 'alipayAccountName' => '游俊涛',
  117. ]);
  118. }
  119. //花美灵
  120. if ($num == 1) {
  121. xhAdminService::updateById(1, ['mobile' => '15280215347', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => '6a348767a0b612172e5da7539de20cb5', 'adminName' => '石少华']);
  122. xhMerchantService::updateById(12358, [
  123. 'merchantName' => '花美灵',
  124. 'miniAppId' => 'wxe4675bab299a52f7',
  125. 'miniAppSecret' => '03dd4000a26af5c17fb86321b7d1ebf3',
  126. 'wxAppId' => 'wx84d95afcb7b594eb',
  127. 'wxUserName' => 'gh_090c30df22e6',
  128. 'wxAliasName' => 'glhs520',
  129. 'wxToken' => 'wt01467284437',
  130. 'openAppId' => 'wxb46e972ab18f27bb',
  131. 'status' => 1,
  132. ]);
  133. xhMerchantExtendService::updateByMerchantId(12358, [
  134. 'wxAppId' => 'wx84d95afcb7b594eb',
  135. 'miniAppId' => 'wxe4675bab299a52f7',
  136. 'wxPayMerchantId' => '1371367002',
  137. 'wxPayKey' => 'eoz23aG739jscv4309275jnza32wvdwm',
  138. 'webTitle' => '花美灵',
  139. 'webKeyword' => '花美灵',
  140. 'webDescription' => '花美灵',
  141. 'alipayAccount' => 'shishaohua8879@sina.com',
  142. 'alipayAccountName' => '石少华',
  143. ]);
  144. }
  145. //花卉宝
  146. if ($num == 2) {
  147. xhAdminService::updateById(1, ['mobile' => '15280215347', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => '6a348767a0b612172e5da7539de20cb5', 'adminName' => '石少华']);
  148. xhMerchantService::updateById(12358, [
  149. 'merchantName' => '花卉宝',
  150. 'miniAppId' => '',
  151. 'miniAppSecret' => '',
  152. 'wxAppId' => 'wx66dd83ff8744f7a8',
  153. 'wxUserName' => 'gh_a9105e0f02b9',
  154. 'wxAliasName' => 'ihuahuibao',
  155. 'wxToken' => 'wt01467284437',
  156. 'status' => 1,
  157. ]);
  158. xhMerchantExtendService::updateByMerchantId(12358, [
  159. 'wxAppId' => 'wx66dd83ff8744f7a8',
  160. 'miniAppId' => '',
  161. 'wxPayMerchantId' => '1442448402',
  162. 'wxPayKey' => 'xxe29ax639jvcv4m082a1jnza32svdd0',
  163. 'webTitle' => '花卉宝',
  164. 'webKeyword' => '花卉宝',
  165. 'webDescription' => '花卉宝',
  166. 'alipayAccount' => 'shishaohua8879@sina.com',
  167. 'alipayAccountName' => '石少华',
  168. ]);
  169. }
  170. }
  171. public function actionLast()
  172. {
  173. //拉取用户
  174. $this->actionPullUser();
  175. //生成模板消息
  176. //$this->actionTMSupplement();
  177. }
  178. public function actionFlushAll()
  179. {
  180. $sql = "TRUNCATE xhDrawCash;
  181. TRUNCATE xhInvite;
  182. TRUNCATE xhLuckyDrawActivity;
  183. TRUNCATE xhLuckyDrawAward;
  184. TRUNCATE xhLuckyDrawAwardCustomer;
  185. TRUNCATE xhLuckyDrawAwardParticipant;
  186. TRUNCATE xhMerchantCapital;
  187. TRUNCATE xhOrder;
  188. TRUNCATE xhOrderDayNum;
  189. TRUNCATE xhOrderGoods;
  190. TRUNCATE xhOrderMonthNum;
  191. TRUNCATE xhRecharge;
  192. TRUNCATE xhStatDealByDay;
  193. TRUNCATE xhStatInDay;
  194. TRUNCATE xhStatInMonth;
  195. TRUNCATE xhStatOutDay;
  196. TRUNCATE xhStatOutMonth;
  197. TRUNCATE xhStatUserByDay;
  198. TRUNCATE xhStatVisitByDay;
  199. TRUNCATE xhUnionUser;
  200. TRUNCATE xhUser;
  201. TRUNCATE xhUserAlipay;
  202. TRUNCATE xhUserAsset;
  203. TRUNCATE xhUserByDay;
  204. TRUNCATE xhUserByMonth;
  205. TRUNCATE xhUserCapital;
  206. TRUNCATE xhUserIntegral;
  207. TRUNCATE xhUserOldData;
  208. TRUNCATE xhUserByDay;";
  209. //清空用户
  210. $sql .= "TRUNCATE xhUser;TRUNCATE xhUserAsset;TRUNCATE xhUserCapital;TRUNCATE xhUserIntegral;";
  211. $sql .= "TRUNCATE xhUserIntegral;TRUNCATE xhUserAlipay;ALTER TABLE xhUser AUTO_INCREMENT=12536580;";
  212. //清空提现申请记录
  213. $sql .= "TRUNCATE xhDrawCash;";
  214. Yii::$app->db->createCommand($sql)->execute();
  215. //清空订单
  216. $sql = "TRUNCATE xhOrder;TRUNCATE xhOrderDayNum;TRUNCATE xhOrderGoods;TRUNCATE xhOrderMonthNum;";
  217. Yii::$app->db->createCommand($sql)->execute();
  218. //清空缓存
  219. Yii::$app->redis->executeCommand('FLUSHDB');
  220. }
  221. /**
  222. * 拉取微信用户 shish 2019.9.9
  223. */
  224. public function actionPullUser()
  225. {
  226. $merchantId = 12359;
  227. $return = UserService::syncWxAllUser($merchantId);
  228. $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
  229. xhMerchantAssetService::updateByMerchantId($merchantId, ['totalFans' => $total]);
  230. }
  231. /**
  232. * 开放平台初始化
  233. * yii init/open hhb
  234. */
  235. public function actionOpen($myOption = 'hhb')
  236. {
  237. $hostname = isset($_SERVER['HOSTNAME']) ? $_SERVER['HOSTNAME'] : '';
  238. if ($hostname == 'iZ23b0wy8awZ') {
  239. util::stop("线上服务器不允许初始化\n");
  240. }
  241. echo "开始初始化…\n";
  242. xhInitService::clear($myOption);
  243. echo "初始化完成!\n";
  244. }
  245. }