PushController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * 测试模块
  4. * @author wesmiler
  5. */
  6. namespace app\api\controller;
  7. use app\weixin\model\Member;
  8. use app\weixin\model\Message;
  9. class PushController extends BaseController
  10. {
  11. /**
  12. * 列表
  13. * @throws \think\exception\DbException
  14. */
  15. public function getList()
  16. {
  17. $params = input();
  18. $pageSize = input('pageSize', 12);
  19. //$this->userId = $this->userId == 102712? 100968 : $this->userId;
  20. $params['openid'] = Member::getField(['id'=> $this->userId],'openid');
  21. // $params['send_at'] = date('Y-m-d',time() - 7*86400);
  22. $dataList = Message::getList($params, $pageSize);
  23. showJson(1005, 1001, $dataList);
  24. }
  25. /**
  26. * 详情
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. * @throws \think\exception\DbException
  30. */
  31. public function getInfo()
  32. {
  33. $id = input('id');
  34. $info = Message::getInfo(['id' => $id],'',true);
  35. showJson(1005, 1001, $info? $info:['id'=>0]);
  36. }
  37. /**
  38. * 未读数据
  39. */
  40. public function getCount()
  41. {
  42. $openid = Member::getField(['id'=> $this->userId],'openid');
  43. $data = Message::where(['openid'=> $openid,'status'=>2,'is_read'=>2])
  44. // ->where('send_at','>',date('Y-m-d',time() - 7*86400))
  45. ->count();
  46. showJson(1005, 1001, $data>99? '99+': $data);
  47. // showJson(1005, 1001, $data>99? '99+': $data);
  48. }
  49. }
  50. ?>