InitController.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. } else {
  61. $isOpen = 0;
  62. $merchant = xhMerchantService::getById($id);
  63. }
  64. //xhWxMenuService::applyInit($merchant);
  65. //模板消息
  66. $r = xhTMessageService::supplement($merchant, $isOpen);
  67. print_r($r);
  68. }
  69. //yii init/sub
  70. public function actionSub()
  71. {
  72. $name = 'redis_shi';
  73. $redisPubSub = \Yii::$app->redisPubSub;
  74. $redisPubSub->setOptReadTimeout(-1);
  75. $redisPubSub->subscribe($name, function ($instance, $channelName, $message) {
  76. $a = 123;
  77. });
  78. }
  79. public function actionPub()
  80. {
  81. $name = 'redis_shi';
  82. $time = 'nihao1123';
  83. $redisPubSub = \Yii::$app->redisPubSub;
  84. $redisPubSub->publish($name, $time);
  85. }
  86. public function actionBegin()
  87. {
  88. //先清除公众号里的模板消息!!!!!!!
  89. $num = 0;
  90. //清空数据
  91. $this->actionFlushAll();
  92. //国兰花尚
  93. if ($num == 0) {
  94. xhAdminService::updateById(1, ['mobile' => '18030142050', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => 'c80fd29375a3a91d3681d8445822248a', 'adminName' => '姜祖岚']);
  95. xhMerchantService::updateById(12358, [
  96. 'merchantName' => '国兰花尚',
  97. 'miniAppId' => 'wxe994a9f5fd036f69',
  98. 'miniAppSecret' => '53b646675251e940f56bd304c2dba480',
  99. 'wxAppId' => 'wx193341a4a80f6ea3',
  100. 'wxUserName' => 'gh_090c30df22e6',
  101. 'wxAliasName' => 'glhs520',
  102. 'openAppId' => 'wxe9211595a1d5a39f',
  103. 'wxToken' => 'wt01467284437',
  104. 'status' => 1,
  105. ]);
  106. xhMerchantExtendService::updateByMerchantId(12358, [
  107. 'wxAppId' => 'wx193341a4a80f6ea3',
  108. 'miniAppId' => 'wxe994a9f5fd036f69',
  109. 'wxPayMerchantId' => '1244548702',
  110. 'wxPayKey' => 'eez23jf739jsmm4309j10jnza3qw8dwm',
  111. 'webTitle' => '国兰花尚',
  112. 'webKeyword' => '国兰花尚',
  113. 'webDescription' => '国兰花尚',
  114. 'alipayAccount' => '18030142050',
  115. 'alipayAccountName' => '游俊涛',
  116. ]);
  117. }
  118. //花美灵
  119. if ($num == 1) {
  120. xhAdminService::updateById(1, ['mobile' => '15280215347', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => '6a348767a0b612172e5da7539de20cb5', 'adminName' => '石少华']);
  121. xhMerchantService::updateById(12358, [
  122. 'merchantName' => '花美灵',
  123. 'miniAppId' => 'wxe4675bab299a52f7',
  124. 'miniAppSecret' => '03dd4000a26af5c17fb86321b7d1ebf3',
  125. 'wxAppId' => 'wx84d95afcb7b594eb',
  126. 'wxUserName' => 'gh_090c30df22e6',
  127. 'wxAliasName' => 'glhs520',
  128. 'wxToken' => 'wt01467284437',
  129. 'openAppId' => 'wxb46e972ab18f27bb',
  130. 'status' => 1,
  131. ]);
  132. xhMerchantExtendService::updateByMerchantId(12358, [
  133. 'wxAppId' => 'wx84d95afcb7b594eb',
  134. 'miniAppId' => 'wxe4675bab299a52f7',
  135. 'wxPayMerchantId' => '1371367002',
  136. 'wxPayKey' => 'eoz23aG739jscv4309275jnza32wvdwm',
  137. 'webTitle' => '花美灵',
  138. 'webKeyword' => '花美灵',
  139. 'webDescription' => '花美灵',
  140. 'alipayAccount' => 'shishaohua8879@sina.com',
  141. 'alipayAccountName' => '石少华',
  142. ]);
  143. }
  144. //花卉宝
  145. if ($num == 2) {
  146. xhAdminService::updateById(1, ['mobile' => '15280215347', 'password' => '6a348767a0b612172e5da7539de20cb5', 'confirmPassword' => '6a348767a0b612172e5da7539de20cb5', 'adminName' => '石少华']);
  147. xhMerchantService::updateById(12358, [
  148. 'merchantName' => '花卉宝',
  149. 'miniAppId' => '',
  150. 'miniAppSecret' => '',
  151. 'wxAppId' => 'wx66dd83ff8744f7a8',
  152. 'wxUserName' => 'gh_a9105e0f02b9',
  153. 'wxAliasName' => 'ihuahuibao',
  154. 'wxToken' => 'wt01467284437',
  155. 'status' => 1,
  156. ]);
  157. xhMerchantExtendService::updateByMerchantId(12358, [
  158. 'wxAppId' => 'wx66dd83ff8744f7a8',
  159. 'miniAppId' => '',
  160. 'wxPayMerchantId' => '1442448402',
  161. 'wxPayKey' => 'xxe29ax639jvcv4m082a1jnza32svdd0',
  162. 'webTitle' => '花卉宝',
  163. 'webKeyword' => '花卉宝',
  164. 'webDescription' => '花卉宝',
  165. 'alipayAccount' => 'shishaohua8879@sina.com',
  166. 'alipayAccountName' => '石少华',
  167. ]);
  168. }
  169. }
  170. public function actionLast()
  171. {
  172. //拉取用户
  173. $this->actionPullUser();
  174. //生成模板消息
  175. //$this->actionTMSupplement();
  176. }
  177. public function actionFlushAll()
  178. {
  179. $sql = "TRUNCATE xhDrawCash;
  180. TRUNCATE xhInvite;
  181. TRUNCATE xhLuckyDrawActivity;
  182. TRUNCATE xhLuckyDrawAward;
  183. TRUNCATE xhLuckyDrawAwardCustomer;
  184. TRUNCATE xhLuckyDrawAwardParticipant;
  185. TRUNCATE xhMerchantCapital;
  186. TRUNCATE xhOrder;
  187. TRUNCATE xhOrderDayNum;
  188. TRUNCATE xhOrderGoods;
  189. TRUNCATE xhOrderMonthNum;
  190. TRUNCATE xhRecharge;
  191. TRUNCATE xhStatDealByDay;
  192. TRUNCATE xhStatInDay;
  193. TRUNCATE xhStatInMonth;
  194. TRUNCATE xhStatOutDay;
  195. TRUNCATE xhStatOutMonth;
  196. TRUNCATE xhStatUserByDay;
  197. TRUNCATE xhStatVisitByDay;
  198. TRUNCATE xhUnionUser;
  199. TRUNCATE xhUser;
  200. TRUNCATE xhUserAlipay;
  201. TRUNCATE xhUserAsset;
  202. TRUNCATE xhUserByDay;
  203. TRUNCATE xhUserByMonth;
  204. TRUNCATE xhUserCapital;
  205. TRUNCATE xhUserIntegral;
  206. TRUNCATE xhUserOldData;
  207. TRUNCATE xhUserByDay;";
  208. //清空用户
  209. $sql .= "TRUNCATE xhUser;TRUNCATE xhUserAsset;TRUNCATE xhUserCapital;TRUNCATE xhUserIntegral;";
  210. $sql .= "TRUNCATE xhUserIntegral;TRUNCATE xhUserAlipay;ALTER TABLE xhUser AUTO_INCREMENT=12536580;";
  211. //清空提现申请记录
  212. $sql .= "TRUNCATE xhDrawCash;";
  213. Yii::$app->db->createCommand($sql)->execute();
  214. //清空订单
  215. $sql = "TRUNCATE xhOrder;TRUNCATE xhOrderDayNum;TRUNCATE xhOrderGoods;TRUNCATE xhOrderMonthNum;";
  216. Yii::$app->db->createCommand($sql)->execute();
  217. //清空缓存
  218. Yii::$app->redis->executeCommand('FLUSHDB');
  219. }
  220. /**
  221. * 拉取微信用户 shish 2019.9.9
  222. */
  223. public function actionPullUser()
  224. {
  225. $merchantId = 12359;
  226. $return = UserService::syncWxAllUser($merchantId);
  227. $total = isset($return['data']['total']) ? $return['data']['total'] : 0;
  228. xhMerchantAssetService::updateByMerchantId($merchantId, ['totalFans' => $total]);
  229. }
  230. /**
  231. * 开放平台初始化
  232. * yii init/open hhb
  233. */
  234. public function actionOpen($myOption = 'hhb')
  235. {
  236. $hostname = isset($_SERVER['HOSTNAME']) ? $_SERVER['HOSTNAME'] : '';
  237. if ($hostname == 'iZ23b0wy8awZ') {
  238. util::stop("线上服务器不允许初始化\n");
  239. }
  240. echo "开始初始化…\n";
  241. xhInitService::clear($myOption);
  242. echo "初始化完成!\n";
  243. }
  244. }