TaskController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <?php
  2. namespace app\api\controller;
  3. use app\portal\model\UserModel;
  4. use app\user\model\PoolModel;
  5. use app\weixin\model\AccountLog;
  6. use app\weixin\model\Books;
  7. use app\weixin\model\Devices;
  8. use app\weixin\model\Member;
  9. use app\weixin\model\Message;
  10. use app\weixin\model\UserBalanceLog;
  11. use app\weixin\model\UserContactLog;
  12. use app\weixin\model\Wechat;
  13. use app\weixin\service\Award;
  14. use app\weixin\service\Export;
  15. use app\weixin\service\PRedis;
  16. use think\Controller;
  17. use think\Db;
  18. class TaskController extends Controller
  19. {
  20. /**
  21. * 订单超时处理
  22. * @throws \think\Exception
  23. * @throws \think\exception\PDOException
  24. */
  25. public function catchBook()
  26. {
  27. try {
  28. $key = input('key', '');
  29. $checkKey = config('task.key');
  30. if ($key != $checkKey) {
  31. showJson(1004, 2009, '', "\n");
  32. }
  33. $cancelTime = config('task.orderCancelTime');
  34. $cancelTime = $cancelTime ? $cancelTime * 60 : 30 * 60;
  35. // 未支付
  36. $cancelTime = date('Y-m-d H:i:s', time() - $cancelTime);
  37. $cancelCount = Books::where(['status' => 1])
  38. ->where('created_at', '<=', $cancelTime)
  39. ->count('id');
  40. Books::where(['status' => 1])
  41. ->where('created_at', '<=', $cancelTime)
  42. ->update(['status' => 4, 'remark' => '超时自动取消']);
  43. // 已取消的删除
  44. $deleteTime = date('Y-m-d H:i:s', time() - 3 * 24 * 3600);
  45. $deleteCount = Books::where(['status' => 4])
  46. ->where('created_at', '<=', $deleteTime)
  47. ->count('id');
  48. Books::where(['status' => 4])
  49. ->where('created_at', '<=', $deleteTime)
  50. ->delete();
  51. $msg = "报名订单自动取消已处理成功,累计取消{$cancelCount}个,删除{$deleteCount}个";
  52. return showJson(1005, $msg, '', "\n");
  53. } catch (\Exception $exception) {
  54. return showJson(1004, $exception->getMessage(), '', "\n");
  55. }
  56. }
  57. /**
  58. * 认识申请超时处理
  59. */
  60. public function cancelContact()
  61. {
  62. $key = input('key', '');
  63. $checkKey = config('task.contactKey');
  64. if ($key != $checkKey) {
  65. showJson(1004, 2009, '', "\n");
  66. }
  67. try {
  68. // 申请失效时间
  69. $siteInfo = cmf_get_site_info();
  70. $expire = isset($siteInfo['contact_time']) ? intval($siteInfo['contact_time']) : 0;
  71. $expire = $expire ? $expire : 1;
  72. $dataList = UserContactLog::where(['status' => 1])
  73. ->where('created_at', '<', date('Y-m-d H:i:s', time() - $expire * 24 * 3600))
  74. ->field('id,contact_uid')
  75. ->select();
  76. if (empty($dataList)) {
  77. showJson(1004, 1003, '', "\n");
  78. }
  79. $results = [];
  80. foreach ($dataList as $val) {
  81. $cid = isset($val['id']) ? intval($val['id']) : 0;
  82. $userId = isset($val['contact_uid']) ? intval($val['contact_uid']) : 0;
  83. if ($cid && $userId) {
  84. $res = Member::contactConfirm($userId, $cid, 4);
  85. if (is_array($res)) {
  86. $results[] = $res;
  87. }
  88. }
  89. }
  90. PRedis::set('tasks:contact:' . date('Ymd'), ['datalist' => $dataList, 'result' => $results], 3600);
  91. $msg = "认识申请记录超时处理结果,累计处理" . count($results) . "个";
  92. return showJson(1005, $msg, "\n");
  93. } catch (\Exception $exception) {
  94. return showJson(1004, $exception->getMessage(), '', "\n");
  95. }
  96. }
  97. /**
  98. * 批量推荐队列处理
  99. */
  100. public function catchMakeHearts()
  101. {
  102. set_time_limit(0);
  103. $key = input('key', '');
  104. $checkKey = config('task.heartKey');
  105. if ($key != $checkKey) {
  106. showJson(1004, 2009, '', "\n");
  107. }
  108. try {
  109. $userIds = [];
  110. $queenKey = "queens:hearts:" . date('Ymd');
  111. //echo $queenKey."<br>\n";
  112. for ($i = 0; $i < 500; $i++) {
  113. $userId = PRedis::lpop($queenKey);
  114. //echo $userId."\n";
  115. if ($userId) {
  116. $userIds[] = $userId;
  117. $url = url('/api/task/catchUserHeart', '', '', true);
  118. httpRequest($url, ['uid' => $userId], 'post', '', 2);
  119. }
  120. }
  121. $msg = "更新推荐数据结果,累计处理" . count($userIds) . "个会员数据更新";
  122. return showJson(1005, $msg, "\n");
  123. } catch (\Exception $exception) {
  124. return showJson(1004, $exception->getMessage(), '', "\n");
  125. }
  126. }
  127. /**
  128. * 清除过期签到爱心创建队列
  129. */
  130. public function clearSignHeart()
  131. {
  132. set_time_limit(0);
  133. $key = input('key', '');
  134. $checkKey = config('task.clearHeartKey');
  135. if ($key != $checkKey) {
  136. showJson(1004, 2009, '', "\n");
  137. }
  138. try {
  139. $month = date('Y-m-01', time() - 2 * 86400);
  140. $users = AccountLog::distinct(true)
  141. ->where(['type' => 12, 'status' => 2])
  142. ->where('created_at', '>=', $month)
  143. ->order('created_at', 'asc')
  144. ->column('user_id');
  145. $userIds = [];
  146. if ($users) {
  147. $queenKey = "queens:signs:".date('Ym');
  148. foreach ($users as $userId) {
  149. // 清除签到爱心
  150. if ($userId) {
  151. PRedis::rpush($queenKey, $userId);
  152. $userids[] = $userId;
  153. }
  154. }
  155. }
  156. $msg = "清除签到爱心数据创建队列,共" . count($users) . "个,累计处理" . count($userIds) . "个会员数据更新,SQL:".AccountLog::getLastSql();
  157. return showJson(1005, $msg, "\n");
  158. } catch (\Exception $exception) {
  159. return showJson(1004, $exception->getMessage(), '', "\n");
  160. }
  161. }
  162. /**
  163. * 清除爱心队列处理
  164. */
  165. public function catchClearSignHeart()
  166. {
  167. set_time_limit(0);
  168. $key = input('key', '');
  169. $checkKey = config('task.clearHeartKey');
  170. if ($key != $checkKey) {
  171. showJson(1004, 2009, '', "\n");
  172. }
  173. try {
  174. $userIds = [];
  175. $queenKey = "queens:signs:".date('Ym');
  176. for ($i = 0; $i < 800; $i++) {
  177. $userId = PRedis::lpop($queenKey);
  178. if ($userId) {
  179. $url = url('/api/task/clearSignHeartByUid', '', '', true);
  180. $result = httpRequest($url, ['uid' => $userId,'key'=> $checkKey], 'post', '', 5);
  181. PRedis::set("caches:signs:clear:{$userId}_result", json(['uid'=>$userId,'result'=>$result,'date'=>date('Y-m-d H:i:s')]), 30 * 24 * 3600);
  182. $code = isset($result['code'])? $result['code'] : '';
  183. if ($code=='success') {
  184. $userIds[] = $userId;
  185. }
  186. }
  187. }
  188. $msg = "清除签到爱心数据队列处理结果,累计处理" . count($userIds) . "个会员数据更新";
  189. return showJson(1005, $msg, "\n");
  190. } catch (\Exception $exception) {
  191. return showJson(1004, $exception->getMessage(), '', "\n");
  192. }
  193. }
  194. /**
  195. * 清除过期签到爱心
  196. */
  197. public function clearSignHeartByUid()
  198. {
  199. set_time_limit(0);
  200. $key = input('key', '');
  201. $userId = input('uid', 0);
  202. $checkKey = config('task.clearHeartKey');
  203. if ($key != $checkKey) {
  204. showJson(1004, 2009, '', "\n");
  205. }
  206. $result = \app\weixin\service\Member::clearSignRedHeart($userId);
  207. if($userId && $result){
  208. return showJson(1005, '清除成功:'.$userId, "\n");
  209. }else{
  210. return showJson(1004, "清除失败:{$userId}".($result<0? '_'.lang(abs($result)):''), "\n");
  211. }
  212. }
  213. /**
  214. * 处理怦然心动
  215. */
  216. public function catchUserHeart()
  217. {
  218. $uid = input('uid', 0);
  219. $dataList = Member::getHeartList($uid, '', true);
  220. showJson(1005, 1001, $dataList);
  221. }
  222. /**
  223. * 更新怦然心动推荐数据入队处理
  224. */
  225. public function makeHearts()
  226. {
  227. set_time_limit(0);
  228. $key = input('key', '');
  229. $checkKey = config('task.heartKey');
  230. if ($key != $checkKey) {
  231. showJson(1004, 2009, '', "\n");
  232. }
  233. try {
  234. // 查询需要推荐的用户
  235. $dataList = Member::alias('m')
  236. ->join('user_profile up', 'up.userid=m.id', 'left')
  237. ->field('m.openid,m.user_nickname,m.id,up.idcard_check,m.is_reg_profile')
  238. ->where(['m.user_status' => 1, 'm.user_type' => 2, 'up.idcard_check' => 2, 'm.is_reg_profile' => 1])
  239. ->where(function ($query) {
  240. return $query->where('m.heart_recommend_at', '<', date('Y-m-d 19:00:00'))
  241. ->whereOr('m.heart_recommend_at', 'exp', 'is null');
  242. })
  243. ->order('m.id')
  244. ->column('m.id');
  245. if (empty($dataList)) {
  246. showJson(1004, 1003, '', "\n");
  247. }
  248. $sql = Member::getLastSql();
  249. //echo $sql;
  250. // 处理数据更新
  251. $userids = [];
  252. $queenKey = "queens:hearts:" . date('Ymd');
  253. foreach ($dataList as $userId) {
  254. if ($userId && PRedis::rpush($queenKey, $userId)) {
  255. $userids[] = $userId;
  256. }
  257. }
  258. PRedis::expire($queenKey, 2 * 3600);
  259. PRedis::set('tasks:hearts:' . date('Ymd'), ['datalist' => $dataList, 'results' => $userids, 'time' => date('Y-m-d H:i:s'), 'sql' => $sql], 3600);
  260. $msg = "更新推荐数据入队结果,累计处理" . count($userids) . "个会员数据更新";
  261. return showJson(1005, $msg, "\n");
  262. } catch (\Exception $exception) {
  263. return showJson(1004, $exception->getMessage(), '', "\n");
  264. }
  265. }
  266. /**
  267. * 更新隐身
  268. * @throws \think\Exception
  269. * @throws \think\db\exception\DataNotFoundException
  270. * @throws \think\db\exception\ModelNotFoundException
  271. * @throws \think\exception\DbException
  272. * @throws \think\exception\PDOException
  273. */
  274. public function updateHeartStatus()
  275. {
  276. set_time_limit(0);
  277. $key = input('key', '');
  278. $checkKey = config('task.upHeartKey');
  279. if ($key != $checkKey) {
  280. showJson(1004, 2009, '', "\n");
  281. }
  282. $where = ['m.is_heart' => 1, 'm.is_reg_profile' => 1, 'm.user_status' => 1, 'm.user_type' => 2];
  283. $dataList = Member::alias('m')
  284. ->join('user_profile up', 'up.userid=m.id', 'left')
  285. ->where($where)
  286. ->where(function ($query) {
  287. $query->where(db()->raw("up.introduce is NULL or up.introduce = ''"))
  288. ->whereOr(db()->raw("up.family is NULL or up.family = ''"))
  289. ->whereOr(db()->raw("up.hobby is NULL or up.hobby = ''"))
  290. ->whereOr(db()->raw("up.purpose is NULL or up.purpose = ''"))
  291. ->whereOr(db()->raw("up.cause is NULL or up.cause = ''"))
  292. ->whereOr(db()->raw("up.expect is NULL or up.expect = ''"));
  293. })
  294. ->field('m.id,up.introduce,up.family,up.hobby,up.purpose,up.cause,up.expect')
  295. ->select()
  296. ->each(function ($profile, $k) {
  297. if (empty($profile) || (empty($profile['photolist']) || empty($profile['introduce']) || empty($profile['family']) || empty($profile['hobby']) || empty($profile['purpose']) || empty($profile['cause']) || empty($profile['expect']))) {
  298. Member::where(['id' => $profile['id']])->update(['is_heart' => 2, 'remark' => '系统检测自动设置隐身']);
  299. }
  300. });
  301. showJson(1005, 1001, $dataList);
  302. }
  303. /**
  304. * 活动报名分销收益结算
  305. * @throws \think\Exception
  306. * @throws \think\Exception\DbException
  307. * @throws \think\db\exception\DataNotFoundException
  308. * @throws \think\db\exception\ModelNotFoundException
  309. */
  310. public function catchBookMarket()
  311. {
  312. set_time_limit(0);
  313. $key = input('key', '');
  314. $checkKey = config('task.catchBookMarket');
  315. if ($key != $checkKey) {
  316. showJson(1004, 2009, '', "\n");
  317. }
  318. $catchIds = [];
  319. $catchList = [];
  320. $bookList = Books::alias('b')
  321. ->leftJoin('activity a', 'a.id=b.aid')
  322. ->leftJoin('user u', 'u.id=b.uid')
  323. ->where('a.endtime', '<=', time())
  324. // ->where('a.endtime', '>', time()-24*3600*3)
  325. ->where('u.parent_id', '>', 0)
  326. ->where(['a.is_top' => 0, 'a.status' => 1, 'b.status' => 3, 'b.is_market' => 2])
  327. ->field('b.id,b.uid,b.aid,b.money,u.parent_id,b.status')
  328. ->order('a.endtime desc, b.book_at asc,b.id asc')
  329. ->paginate(80)
  330. ->each(function ($item, $k) use (&$catchList, &$catchIds) {
  331. $userId = isset($item['uid']) ? intval($item['uid']) : 0;
  332. $aid = isset($item['aid']) ? $item['aid'] : 0;
  333. $money = isset($item['money']) ? floatval($item['money']) : 0;
  334. $inviteInfo = Member::getInviteInfo($userId);
  335. $inviteId = isset($inviteInfo['invite_id']) ? $inviteInfo['invite_id'] : 0;
  336. //$item['invite'] = $inviteInfo;
  337. PRedis::set('markets:activity:book_temp_' . $aid . ':' . $userId . '_' . $inviteId, ['info' => $item, 'inviteInfo' => $inviteInfo], 5 * 86400);
  338. if ($inviteInfo && $inviteId > 0 && $aid > 0 && $money > 0) {
  339. if (!UserBalanceLog::checkHasMarketBySource($inviteId, $userId, $aid, 9)) {
  340. $catchList[] = $item;
  341. PRedis::set('markets:activity:book_' . $aid . ':' . $userId . '_' . $inviteId, ['info' => $item, 'inviteInfo' => $inviteInfo], 7200);
  342. Award::marketAward($inviteId, $userId, 9, $money);
  343. $catchIds[] = $item['id'];
  344. }
  345. }
  346. });
  347. if ($catchIds) {
  348. Books::whereIn('id', $catchIds)->update(['is_market' => 1, 'remark' => '分销已结算']);
  349. }
  350. $bookList = $bookList ? $bookList->toArray() : [];
  351. showJson(1005, 1001, ['total' => $bookList['total'], 'bookList' => $bookList['data'], 'catchList' => $catchList]);
  352. }
  353. /**
  354. * 更新报表数据
  355. * @throws \think\Exception
  356. * @throws \think\exception\PDOException
  357. */
  358. public function updateExport()
  359. {
  360. set_time_limit(0);
  361. $key = input('key', '');
  362. $checkKey = config('task.updateExport');
  363. if ($key != $checkKey) {
  364. showJson(1004, 2009, '', "\n");
  365. }
  366. $result = Export::updateData();
  367. showJson(1005, 1001, ['ids' => $result, 'date' => date('Y-m-d H:i:s')]);
  368. }
  369. /**
  370. * 更新销售资源过期数据
  371. * @throws \think\Exception
  372. * @throws \think\exception\PDOException
  373. */
  374. public function salesExpired()
  375. {
  376. set_time_limit(0);
  377. $key = input('key', '');
  378. $checkKey = config('task.salesExpired');
  379. if ($key != $checkKey) {
  380. showJson(1004, 2009, '', "\n");
  381. }
  382. $cacheKey = "caches:sales:lock";
  383. if(date("H:i") >= '09:00' && date("H:i") <= '23:00' && PRedis::get($cacheKey)){
  384. showJson(1004, '非更新时间段', '', "\n");
  385. }
  386. PRedis::set($cacheKey, date('Y-m-d H:i:s'), rand(3600, 7200));
  387. $sql = '';
  388. $count = 0;
  389. $datas = [];
  390. $result = PoolModel::alias('p')
  391. ->where('p.expire_at', '>', date('Y-m-d H:i:s', time() - 10*86400))
  392. ->where(['p.type' => 0, 'p.status' => 1])
  393. ->whereNotIn('p.intention',[5])
  394. ->field('id,sale_uid,user_id,followup_num,follow_time,expire_at,intention')
  395. ->limit(1000)
  396. ->order('p.stop_time asc,p.expire_at asc')
  397. ->select()
  398. ->each(function ($item, $k) use (&$count, &$datas, &$sql) {
  399. if(empty($sql)){
  400. $sql = PoolModel::getLastSql();
  401. }
  402. $userId = isset($item['user_id']) ? $item['user_id'] : 0;
  403. $saleUid = isset($item['sale_uid']) ? $item['sale_uid'] : 0;
  404. $expireAt = isset($item['expire_at']) ? $item['expire_at'] : '';
  405. $followTime = isset($item['follow_time']) ? $item['follow_time'] : '';
  406. $followTime = $followTime && $followTime != '0000-00-00 00:00:00'? $followTime : '';
  407. $updateData = ['updated_at' => date('Y-m-d H:i:s'),'stop_time'=> date('Y-m-d H:i:s')];
  408. // 到期数据处理
  409. $state = false;
  410. if($expireAt && $expireAt <= date('Y-m-d H:i:s')){
  411. $updateData['status'] = 2;
  412. $data = [
  413. 'sale_uid' => 0,
  414. 'user_id' => $userId,
  415. 'type' => 2,
  416. 'followup_num' => 0,
  417. 'create_time' => date('Y-m-d H:i:s'),
  418. 'updated_at' => date('Y-m-d H:i:s'),
  419. 'expire_at' => 0,
  420. 'status' => 1,
  421. ];
  422. $info = PoolModel::checkData($userId, 3);
  423. $intention = isset($item['intention'])? $item['intention'] : 0;
  424. if(!in_array($intention, [5,8])){
  425. if(in_array($intention, [7])){
  426. $data['type'] = 8;
  427. }
  428. PRedis::set("caches:pools:task:update_{$userId}_".$info['id'],$info, 7 * 86400);
  429. if (empty($info)) {
  430. $datas[] = $data;
  431. } else{
  432. PoolModel::where(['id' => $info['id'], 'user_id' => $userId])->update($data);
  433. }
  434. }else{
  435. $updateData['type'] = 0;
  436. }
  437. // 到期未跟进
  438. if($item['followup_num'] <= 0 || ($followTime && $followTime <date('Y-m-d H:i:s'))){
  439. $updateData['agency'] = 3;
  440. $state = true;
  441. }
  442. }else if ($expireAt){
  443. // 今日坠海
  444. $time = strtotime($expireAt);
  445. $dayTime = strtotime(date('Y-m-d'));
  446. //
  447. if($followTime < date('Y-m-d', $dayTime+ 86400) && $followTime >= date('Y-m-d')){
  448. $updateData['agency'] = 1;
  449. $item['expire_text'] = '今日需跟进';
  450. $state = true;
  451. }else if($followTime < date('Y-m-d', $dayTime+ 2*86400) && $followTime >= date('Y-m-d', $dayTime + 86400)){
  452. $updateData['agency'] = 2;
  453. $item['expire_text'] = '明日需跟进';
  454. $state = true;
  455. }else if($followTime < date('Y-m-d')){
  456. $updateData['agency'] = 3;
  457. $item['expire_text'] = '到期未跟进';
  458. $state = true;
  459. }
  460. if($time >= time() && $time < $dayTime + 86400){
  461. $item['expire_text'] = '今天坠海';
  462. $updateData['agency'] = 4;
  463. $state = true;
  464. }else if($time>=$dayTime+86400 && $time < $dayTime + 2 * 86400){
  465. $item['expire_text'] = '明天坠海';
  466. $updateData['agency'] = 5;
  467. $state = true;
  468. }else if($time>=$dayTime+7*86400 && $time < $dayTime + 8 * 86400){
  469. $item['expire_text'] = '一礼拜后坠海';
  470. $updateData['agency'] = 6;
  471. $state = true;
  472. }else if ($time >= $dayTime + 8 * 86400){
  473. $item['expire_text'] = '超过7天';
  474. $updateData['agency'] = 7;
  475. $state = true;
  476. }
  477. }
  478. // 更新待办事项
  479. if($updateData && $state == true){
  480. $count++;
  481. PoolModel::where(['id' => $item['id']])->update($updateData);
  482. }
  483. });
  484. if ($datas) {
  485. PoolModel::insertAll($datas);
  486. }
  487. // 缓存
  488. PRedis::set("caches:sales:expired", ['count'=> $count,'datas'=> $datas,'result'=> $result, 'date'=> date('Y-m-d H:i:s')], 3*86400);
  489. showJson(1005, 1008, ['count' => $count,'sql'=> $sql, 'date' => date('Y-m-d H:i:s')]);
  490. }
  491. /**
  492. * 补发消息
  493. * @throws \think\db\exception\DataNotFoundException
  494. * @throws \think\db\exception\ModelNotFoundException
  495. * @throws \think\exception\DbException
  496. */
  497. public function sendMessage()
  498. {
  499. set_time_limit(0);
  500. $key = input('key', '');
  501. $checkKey = config('task.sendMessage');
  502. if ($key != $checkKey) {
  503. showJson(1004, 2009, '', "\n");
  504. }
  505. $cacheKey = "caches:taskMessage:lock";
  506. if((date("H:i") >= '03:00' && date('H:i') <= '05:00')){
  507. showJson(1004, '非处理时间段', '', "\n");
  508. }
  509. if(PRedis::get($cacheKey)){
  510. showJson(1004, '频繁请求', '', "\n");
  511. }
  512. PRedis::set($cacheKey, date('Y-m-d H:i:s'), rand(30, 60));
  513. $result = Wechat::taskSendMessage(300);
  514. PRedis::set("caches:messages:taskResult:".date('YmdHi'), $result, 7200);
  515. if(is_array($result)){
  516. showJson(1005, '处理成功', $result, "\n");
  517. }else{
  518. showJson(1004, $result? $result : '处理失败', "\n");
  519. }
  520. }
  521. /**
  522. * 异步公众号消息处理
  523. * @throws \think\Exception
  524. * @throws \think\exception\PDOException
  525. */
  526. public function sendSyncMsg()
  527. {
  528. try {
  529. $openid = input('openid', '');
  530. $params = input('params', []);
  531. if(empty($openid) || empty($params)){
  532. showJson(1004, 2009, '', "\n");
  533. }
  534. $result = Wechat::sendTplMsg($openid, $params);
  535. showJson(1005, '异步消息调用结果', $result, "\n");
  536. } catch (\Exception $exception) {
  537. showJson(1004, $exception->getMessage(), '', "\n");
  538. }
  539. }
  540. }