Advertapi.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class Advertapi extends Api
  6. {
  7. protected $noNeedLogin = ['*'];
  8. protected $noNeedRight = ['*'];
  9. public function __construct(){
  10. parent::__construct();
  11. $this->login();
  12. }
  13. public function login()
  14. {
  15. $account = input('mobile');
  16. $password = input('password');
  17. if (!$account || !$password) {
  18. $this->error('no login');
  19. }
  20. $ret = $this->auth->login($account, $password);
  21. if ($ret) {
  22. //$data = $this->userInfo('return');
  23. //$this->success(__('Logged in successful'), $data);
  24. } else {
  25. $this->error($this->auth->getError());
  26. }
  27. }
  28. public function index(){
  29. $type = input('type',1);
  30. $uid = $this->auth->id;
  31. $fields = [
  32. 'po.id,po.pay_no,po.status,po.money,po.payment_class,FROM_UNIXTIME(po.createtime) as createtime,user.mobile,user.id as user_id'
  33. ];
  34. if($type == 1){
  35. $result = Db::name('pay_order')->alias('po')->field($fields)->join('user','po.user_id = user.id','LEFT')->where('po.user_id',$uid)->order('po.id desc')->find();
  36. $this->success('success',$result);
  37. }else{
  38. $result = Db::name('pay_order')->alias('po')->field($fields)->join('user','po.user_id = user.id','LEFT')->where('po.user_id',$uid)->order('po.id desc')->autopage()->select();
  39. $this->success('success',$result);
  40. }
  41. }
  42. }