UserService.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: hp
  5. * Date: 2017/11/21
  6. * Time: 10:42
  7. */
  8. namespace App\Modules\User\Services;
  9. use App\Consts\QuickConst;
  10. use App\Modules\Book\Models\BookGiftsSend;
  11. use App\Modules\Book\Models\UserShelfBooks;
  12. use App\Modules\Subscribe\Models\BookOrder;
  13. use App\Modules\Subscribe\Models\ChapterOrder;
  14. use App\Modules\Subscribe\Services\ChapterOrderService;
  15. use App\Modules\User\Models\User;
  16. use App\Modules\User\Models\UserEnv;
  17. use DB;
  18. use App\Jobs\ActionTrigger;
  19. use App\Jobs\UserAddDeskJob;
  20. use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
  21. use App\Modules\Channel\Models\Channel;
  22. use App\Modules\Trade\Models\Order;
  23. use App\Modules\User\Models\QappUserAddDestop;
  24. use App\Modules\UserTask\Services\BaseTask;
  25. use App\Modules\UserTask\Services\UserTaskService;
  26. use Redis;
  27. class UserService
  28. {
  29. public static function setUserSendOrder(int $uid, int $send_order_id)
  30. {
  31. if (empty($uid) || empty($send_order_id)) {
  32. return false;
  33. }
  34. Redis::hmset('book_read:' . $uid,'send_order_id',$send_order_id,'soid_time',time());
  35. //return Redis::hset('book_read:' . $uid, 'send_order_id', $send_order_id);
  36. }
  37. public static function getUserSendOrderTime($uid)
  38. {
  39. $send_order_id_time = Redis::hGet('book_read:' . $uid, 'soid_time');
  40. $send_order_id_time = (int)($send_order_id_time);
  41. return $send_order_id_time;
  42. }
  43. public static function getUserSendOrder(int $uid)
  44. {
  45. $send_order_id = Redis::hGet('book_read:' . $uid, 'send_order_id');
  46. $send_order_id = (int)($send_order_id ? $send_order_id : 0);
  47. return $send_order_id;
  48. }
  49. public static function qappAddDesktop(int $uid, int $status)
  50. {
  51. myLog('incrAddDeskTop')->info('qappAddDesktop', compact('uid', 'status'));
  52. $log = QappUserAddDestop::where('uid', $uid)->orderBy('id', 'desc')->first();
  53. if (!$log) {
  54. //第一次加桌 没有任何记录,加桌状态为1
  55. if($status == 1){
  56. $job = new UserAddDeskJob($uid);
  57. $test = 'test';
  58. myLog('incrAddDeskTop')->info('qappAddDesktop', compact('uid', 'status','test'));
  59. dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
  60. }
  61. //第一次加桌 没有任何记录,加桌状态为0
  62. if($status == 0){
  63. QappUserAddDestop::create([
  64. 'uid' => $uid,
  65. 'status' => $status,
  66. ]);
  67. }
  68. }else{
  69. //如果有记录,但是都是0 没有1的记录
  70. $oneexists = QappUserAddDestop::where('uid', $uid)->where('status', 1)->exists();
  71. if(!$oneexists && $status == 1){
  72. $job = new UserAddDeskJob($uid);
  73. dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
  74. return false;
  75. }
  76. //有加桌记录 最近一次加桌状态和和此次状态是否相等
  77. if($log->status != $status){
  78. //不相等 插入记录
  79. QappUserAddDestop::create([
  80. 'uid' => $uid,
  81. 'status' => $status,
  82. ]);
  83. }
  84. //相等 不做处理
  85. return false;
  86. }
  87. // 加桌统计
  88. if (!$log && $status === 1) {
  89. QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_ADD_DESKTOP);
  90. UserTaskService::addUserTaskQueue($uid, BaseTask::add_desk, UserTaskService::add_trigger);
  91. }
  92. }
  93. /**
  94. * 创建用户
  95. * $params
  96. * 必穿参数 openid、unionid、distribution_channel_id
  97. * 可传 province、city、country、headimgurl、send_order_id、sex、register_ip
  98. */
  99. static function addUser($params)
  100. {
  101. return User::addUser($params);
  102. }
  103. static function getUserList($limit, $offset)
  104. {
  105. return User::getUserList($limit, $offset);
  106. }
  107. static function getUserByNickAndChannelId($distribution_channel_id, $nickname)
  108. {
  109. return User::getUserByNickAndChannelId($distribution_channel_id, $nickname);
  110. }
  111. /**
  112. * 获取用户信息列表
  113. * @param $pageSize 每页显示的条数
  114. */
  115. static function getPaginationList($pageSize = 20)
  116. {
  117. return User::getPaginationList($pageSize);
  118. }
  119. /**
  120. * 获取用户信息列表
  121. * @param $pageSize 每页显示的条数
  122. */
  123. static function getUsers($pageSize = 20, $careStatus)
  124. {
  125. return User::getPaginationList($pageSize, $careStatus);
  126. }
  127. /**
  128. * 根据id获取用户信息
  129. * @return user object
  130. */
  131. static function getById($id)
  132. {
  133. return User::getById($id);
  134. }
  135. /**
  136. * 根据id获取用户信息
  137. * @return user object
  138. */
  139. static function getUserDataById($id)
  140. {
  141. return User::getUserDataById($id);
  142. }
  143. /**
  144. * 根据id获取用户信息
  145. * @return user object
  146. */
  147. static function getUserDataDetailById($id)
  148. {
  149. return User::getUserDataDetailById($id);
  150. }
  151. /**
  152. * 根据id获取用户名称
  153. * @return string [用户昵称]
  154. */
  155. static function getNicknameById($id)
  156. {
  157. return User::getById($id)->nickname;
  158. }
  159. /**
  160. * 更新用户信息
  161. * @param int $id 用户ID
  162. * @param array $params 可传 province、city、country、headimgurl、sex
  163. * @return boolen
  164. */
  165. static function updateInfo($id, $params)
  166. {
  167. \Log::info('~~~~~~~~~~~~~~~~~====update User====~~~~~~~~~~~~~~~~' . "\n");
  168. \Log::info($id);
  169. \Log::info($params);
  170. return User::updateInfo($id, $params);
  171. }
  172. /**
  173. * 根据union和分销id获取用户信息
  174. * @param $union
  175. * @param $channel_id
  176. * @return mixed
  177. */
  178. static function getUserByUnionAndChannelId($openid, $channel_id)
  179. {
  180. return User::where('openid', $openid)->where('distribution_channel_id', $channel_id)->select('id', 'openid', 'unionid', 'balance', 'charge_balance', 'reward_balance')->first();
  181. }
  182. static function getUserByOpenidAndChannelId($openid, $channel_id)
  183. {
  184. return User::where('openid', $openid)->where('distribution_channel_id', $channel_id)->first();
  185. }
  186. /**
  187. * 用户余额充值
  188. * @param $uid
  189. * @param $fee
  190. * @return mixed
  191. */
  192. static function addBalance($uid, $fee, $charge, $given)
  193. {
  194. return User::addBalance($uid, $fee, $charge, $given);
  195. }
  196. /**
  197. * 查询推广注册用户总数
  198. * @param $send_order_id
  199. * @return mixed
  200. */
  201. static function getPromotionTotal($send_order_id)
  202. {
  203. return User::getPromotionTotal($send_order_id);
  204. }
  205. /**
  206. * 查询渠道某天注册用户总数
  207. * @param $channel_id
  208. * @param $date
  209. * @return mixed
  210. */
  211. static function getChannelDayTotal($channel_id, $date)
  212. {
  213. return User::getChannelDayTotal($channel_id, $date);
  214. }
  215. /**
  216. * 查询渠道注册用户总数
  217. * @param $channel_id
  218. * @return mixed
  219. */
  220. static function getChannelTotal($channel_id)
  221. {
  222. return User::getChannelTotal($channel_id);
  223. }
  224. /**
  225. * 查询渠道某段时间注册用户总数
  226. * @param $channel_id
  227. * @param $startDate
  228. * @param $endDate
  229. * @return mixed
  230. */
  231. static function getChannelDayToDayTotal($channel_id, $startDate = '', $endDate = '')
  232. {
  233. return User::getChannelDayToDayTotal($channel_id, $startDate, $endDate);
  234. }
  235. /**
  236. * 查询渠道某段时间注册用户总数
  237. * @param array $channelIds
  238. * @param $startDate
  239. * @param $endDate
  240. * @return mixed
  241. */
  242. static function getChannelsDayToDayTotal($channelIds, $startDate = '', $endDate = '')
  243. {
  244. return User::getChannelsDayToDayTotal($channelIds, $startDate, $endDate);
  245. }
  246. /**
  247. * 查询注册用户总数
  248. * @param $params
  249. */
  250. static function getTotalCount($params)
  251. {
  252. return User::getTotalCount($params);
  253. }
  254. /**
  255. * 查询渠道是否有登录
  256. * @param $channelId
  257. * @param $start_time
  258. * @param $end_time
  259. * @return int
  260. */
  261. static function judgeUserYesterdayLogin($channelId, $start_time, $end_time)
  262. {
  263. $user_behavior = DB::table('channel_operate_record')
  264. ->where([
  265. ['distribution_channel_id', '=', $channelId],
  266. ['created_at', '>=', $start_time],
  267. ['created_at', '<=', $end_time]
  268. ])
  269. ->first();
  270. if ($user_behavior) return 1;
  271. return 0;
  272. }
  273. /**
  274. * @param $date
  275. * @param $company_id
  276. * @return mixed
  277. */
  278. static function getCompanyDayTotal($date, $company_id)
  279. {
  280. $end_date = date('Y-m-d', strtotime($date) + 86400);
  281. $info = User::leftjoin('distribution_channels', 'distribution_channels.id', '=', 'users.distribution_channel_id')
  282. ->leftjoin('channel_users', 'channel_users.id', '=', 'distribution_channels.channel_user_id')
  283. ->where([
  284. ['users.created_at', '>=', $date],
  285. ['users.created_at', '<', $end_date],
  286. ['channel_users.company_id', '=', $company_id]
  287. ])
  288. ->groupBy('channel_users.company_id')
  289. ->select(DB::raw("count(users.id) as register_sum"))
  290. ->first();
  291. if ($info) return $info->register_sum;
  292. //\Log::info('getCompanyDayTotal error:' . $company_id);
  293. return $info;
  294. }
  295. static function getCompanyTotal($company_id)
  296. {
  297. $info = User::leftjoin('distribution_channels', 'distribution_channels.id', '=', 'users.distribution_channel_id')
  298. ->leftjoin('channel_users', 'channel_users.id', '=', 'distribution_channels.channel_user_id')
  299. ->where('channel_users.company_id', $company_id)
  300. ->groupBy('channel_users.company_id')
  301. ->select(DB::raw("count(users.id) as register_sum"))
  302. ->first();
  303. if ($info) return $info->register_sum;
  304. //\Log::error('getCompanyTotal error:' . $company_id);
  305. return $info;
  306. }
  307. static function transfromBalanceByUser($from_uid, $to_uid)
  308. {
  309. $add_balance_sql = "update users,(select * from users where id =" . $from_uid . ") as u2
  310. set users.balance = users.balance + u2.balance,
  311. users.reward_balance = users.reward_balance +u2.reward_balance,
  312. users.charge_balance = users.charge_balance +u2.charge_balance where users.id =" . $to_uid;
  313. $res = DB::update($add_balance_sql);
  314. return User::updateInfo($from_uid, ['balance' => 0, 'reward_balance' => 0, 'charge_balance' => 0]);
  315. }
  316. // 扔用户一些动作到队列,异步处理一些额外逻辑
  317. static function PushUserActionToQueue($action_type, $distribution_channel_id, $param)
  318. {
  319. try {
  320. // \Log::info('PushUserActionToQueue_param_start:'.$distribution_channel_id.' action_type:'.$action_type. ' param:'.json_encode($param));
  321. // 判断站点是否需要额外逻辑
  322. $distribution_self_define_config = DistributionSelfDefineConfig::getDistributionSelfDefineConfig($distribution_channel_id, 'action_call_ycsd');
  323. if (empty($distribution_self_define_config)) {
  324. // \Log::info('not_action_call_ycsd:'.$distribution_channel_id);
  325. return '';
  326. } else {
  327. \Log::info('PushUserActionToQueue_param:' . $distribution_channel_id . ' action_type:' . $action_type . ' param:' . json_encode($param));
  328. // 如果支付通道已经切换回去,则不推送了
  329. // $pay_merchant_id = env('YCSD_CALL_PAY_MERCHANT_ID');
  330. // 当前默认
  331. $pay_merchant_id = Redis::get('YCSD_CALL_PAY_MERCHANT_ID');
  332. $channel = Channel::getById($distribution_channel_id);
  333. $current_pay_merchant_id = isset($channel->pay_merchant_id) ? $channel->pay_merchant_id : '';
  334. \Log::info('action_call_ycsd:' . $distribution_channel_id . ' $pay_merchant_id:' . $pay_merchant_id . ' $current_pay_merchant_id:' . $current_pay_merchant_id);
  335. if ($current_pay_merchant_id != $pay_merchant_id) {
  336. // 判断订单是否是默认支付,放行,切换期间的bug
  337. if ($action_type == 'CallBackOrder') {
  338. $order = Order::getByTradeNo($distribution_channel_id, $param['order_sn']);
  339. if (isset($order->pay_merchant_id) && $order->pay_merchant_id == $pay_merchant_id) {
  340. \Log::info('action_call_ycsd_old_order_continue:' . $param['order_sn']);
  341. } else {
  342. \Log::info('action_call_ycsd_has_change_pay_return:' . $distribution_channel_id);
  343. return '';
  344. }
  345. } else {
  346. \Log::info('action_call_ycsd_has_change_pay_return:' . $distribution_channel_id);
  347. return '';
  348. }
  349. }
  350. \Log::info('action_call_ycsd:' . $distribution_channel_id);
  351. }
  352. $data = [];
  353. $data['send_time'] = date("Y-m-d H:i:s");
  354. $data['action_type'] = $action_type;
  355. if ($action_type == 'Register') {
  356. $data['openid'] = $param['openid'];
  357. $data['uid'] = $param['uid'];
  358. } elseif ($action_type == 'CreateOrder') {
  359. $data['orderSn'] = $param['order_sn'];
  360. $data['amount'] = $param['amount'];
  361. $data['openid'] = $param['openid'];
  362. $data['uid'] = $param['uid'];
  363. } elseif ($action_type == 'CallBackOrder') {
  364. $data['orderSn'] = $param['order_sn'];
  365. $data['openid'] = $param['openid'];
  366. }
  367. $send_data = array(
  368. 'send_time' => date("Y-m-d H:i:s"),
  369. 'data' => $data
  370. );
  371. \Log::info('PushUserActionToQueue_openid:' . $data['openid'] . ' action_type:' . $action_type);
  372. \Log::info('$send_data');
  373. \Log::info($send_data);
  374. $delay = 0;
  375. $job = (new ActionTrigger($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('action_trigger_list');
  376. dispatch($job);
  377. } catch (\Exception $e) {
  378. \Log::info('ept:' . $e->getMessage());
  379. }
  380. }
  381. public static function isCpcUser($uid)
  382. {
  383. //openid下所有强关超过三天的uid都无充值,对强关后的uid进行曝光
  384. //openid下有一个强关超过三天的uid,都无充值,对强关后的uid进行曝光
  385. $sql_format = "SELECT u.id,f.subscribe_time,(SELECT id from orders where uid = u.id and `status` = 'PAID' LIMIT 1)as oid FROM users u
  386. JOIN force_subscribe_users f on u.id = f.uid and f.is_subscribed= 1
  387. WHERE u.openid in (SELECT openid from users WHERE id = %s)";
  388. $result = DB::select(sprintf($sql_format, $uid));
  389. if (!$result) return false;
  390. $is_has_force_subscribe_three_days = false;
  391. foreach ($result as $item) {
  392. //有充值
  393. if ($item->oid) return false;
  394. //强关没超过超过三天
  395. //if(time()-strtotime($item->subscribe_time) < 86400*3) return false;
  396. if (time() - strtotime($item->subscribe_time) > 86400 * 3) $is_has_force_subscribe_three_days = true;
  397. }
  398. return $is_has_force_subscribe_three_days;
  399. }
  400. public static function recordUA($ua, $uid)
  401. {
  402. return UserEnv::recordUA($ua, $uid);
  403. }
  404. public static function transfer(int $from, int $to, int $distribution_channel_id)
  405. {
  406. $transfer_record = DB::table('crm_transfer')->where('from_uid', $from)->first();
  407. if ($transfer_record) {
  408. return;
  409. }
  410. $from_user = self::getById($from);
  411. $to_user = self::getById($to);
  412. if (!$from_user) return;
  413. if (!$to_user) return;
  414. //阅读记录迁移***************************************
  415. $record = Redis::hgetall('book_read:' . $from);
  416. $not_uid_key = ['last_read', 'sign_counts', 'sign_info', 'sign_day'];
  417. $data = [];
  418. foreach ($record as $k => $item) {
  419. if (is_numeric($k) || in_array($k, $not_uid_key)) {
  420. $data[$k] = $item;
  421. }
  422. }
  423. //\Log::info('read record is');
  424. //\Log::info($data);
  425. if ($data) Redis::hmset('book_read:' . $to, $data);
  426. //签到记录
  427. /*$user_sign_model = new UserSign();
  428. $user_sign_model->setCurrentTable(date('Ym'));
  429. $sign_record = $user_sign_model->where('uid',$from)->select('price','sign_time','day','created_at')->orderBy('sign_time','desc')->get();
  430. $temp = [];
  431. if($sign_record){
  432. foreach ($sign_record as $item){
  433. $temp[] = [
  434. 'uid'=>$to,
  435. 'price'=>$item->price,
  436. 'day'=>$item->day,
  437. 'sign_time'=>$item->sign_time,
  438. 'created_at'=>$item->created_at,
  439. 'updated_at'=>date('Y-m-d H:i:s'),
  440. ];
  441. }
  442. //\Log::info('user_sign is');
  443. //\Log::info($temp);
  444. DB::table('user_sign'.date('Ym'))->insert($temp);
  445. }*/
  446. //订阅记录(按本)
  447. $book_order = BookOrder::where('uid', $from)->where('bid', '>', 0)->get();
  448. if ($book_order) {
  449. $temp = [];
  450. foreach ($book_order as $book) {
  451. $temp[] = [
  452. 'distribution_channel_id' => $distribution_channel_id,
  453. 'bid' => $book->bid,
  454. 'book_name' => $book->book_name,
  455. 'uid' => $to,
  456. 'u' => $book->u,
  457. 'fee' => 0,
  458. 'created_at' => $book->created_at,
  459. 'updated_at' => date('Y-m-d H:i:s'),
  460. ];
  461. }
  462. //\Log::info('book_order is');
  463. //\Log::info($temp);
  464. DB::table('book_orders')->insert($temp);
  465. }
  466. //订阅记录(按章)
  467. $chapter_order_record = ChapterOrderService::getRecordByUid($from, '', '', true);
  468. if ($chapter_order_record) {
  469. $temp = [];
  470. $i = 1;
  471. $chapter_model = new ChapterOrder();
  472. $chapter_model->setCurrentTable($to);
  473. foreach ($chapter_order_record as $chapter_order) {
  474. $temp[] = [
  475. 'distribution_channel_id' => $distribution_channel_id,
  476. 'bid' => $chapter_order->bid,
  477. 'cid' => $chapter_order->cid,
  478. 'chapter_name' => $chapter_order->chapter_name,
  479. 'book_name' => $chapter_order->book_name,
  480. 'uid' => $to,
  481. 'send_order_id' => 0,
  482. 'fee' => 0,
  483. 'created_at' => $chapter_order->created_at,
  484. 'updated_at' => date('Y-m-d H:i:s')
  485. ];
  486. if ($i % 100 == 0) {
  487. $chapter_model->insert($temp);
  488. $temp = [];
  489. }
  490. $i++;
  491. }
  492. //\Log::info('chapter order is');
  493. //\Log::info($temp);
  494. $chapter_model->insert($temp);
  495. }
  496. //打赏记录
  497. $gift_result = BookGiftsSend::where('uid', $from)->get();
  498. if ($gift_result) {
  499. $tmp = [];
  500. foreach ($gift_result as $g) {
  501. $tmp[] = [
  502. 'uid' => $to,
  503. 'gift_id' => $g->gift_id,
  504. 'bid' => $g->bid,
  505. 'icon' => $g->icon,
  506. 'name_desc' => $g->name_desc,
  507. 'cost' => 0,
  508. 'cost_reward' => $g->cost_reward,
  509. 'cost_recharge' => $g->cost_recharge,
  510. 'created_at' => $g->created_at,
  511. 'updated_at' => date('Y-m-d H:i:s')
  512. ];
  513. }
  514. //\Log::info('book gift is');
  515. //\Log::info($temp);
  516. DB::table('book_gifts_send')->insert($tmp);
  517. }
  518. //书架
  519. $result = UserShelfBooks::where('uid', $from)->get();
  520. if ($result) {
  521. $tmp = [];
  522. foreach ($result as $s) {
  523. $tmp[] = [
  524. 'uid' => $to,
  525. 'distribution_channel_id' => $distribution_channel_id,
  526. 'bid' => $s->bid,
  527. 'created_at' => $s->created_at,
  528. 'updated_at' => date('Y-m-d H:i:s')
  529. ];
  530. }
  531. //\Log::info('user book shelf is');
  532. //\Log::info($temp);
  533. DB::table('user_shelf_books')->insert($tmp);
  534. }
  535. //包年
  536. $result = DB::table('year_orders')->where('uid', $from)->where('end_time', '>=', date('Y-m-d H:i:s'))->first();
  537. if ($result) {
  538. DB::table('year_orders')->insert([
  539. 'uid' => $to,
  540. 'begin_time' => $result->begin_time,
  541. 'end_time' => $result->end_time,
  542. 'distribution_channel_id' => $distribution_channel_id,
  543. 'send_order_id' => $result->send_order_id,
  544. 'fee' => $result->fee,
  545. 'created_at' => date('Y-m-d H:i:s'),
  546. 'updated_at' => $result->updated_at,
  547. ]);
  548. //\Log::info('year_orders is');
  549. //print_r($result);
  550. }
  551. //书币
  552. $to_user->balance += $from_user->balance;
  553. $to_user->reward_balance += $from_user->balance;
  554. $to_user->nickname = $from_user->nickname;
  555. $to_user->sex = $from_user->sex;
  556. $to_user->head_img = $from_user->head_img;
  557. $to_user->country = $from_user->country;
  558. $to_user->city = $from_user->city;
  559. $to_user->province = $from_user->province;
  560. $to_user->save();
  561. DB::table('crm_transfer')->insert([
  562. 'from_uid' => $from,
  563. 'to_uid' => $to,
  564. 'is_enable' => 1,
  565. 'created_at' => date('Y-m-d H:i:s'),
  566. 'updated_at' => date('Y-m-d H:i:s')
  567. ]);
  568. }
  569. public static function getUserByOpenid($openid)
  570. {
  571. return User::where('openid', $openid)->get();
  572. }
  573. }