Order.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use addons\epay\library\Service;
  6. /**
  7. * 订单
  8. */
  9. class order extends Api
  10. {
  11. protected $noNeedLogin = [''];
  12. protected $noNeedRight = ['*'];
  13. public function lists()
  14. {
  15. $active_status = input('active_status','all');
  16. $where = [
  17. 'order.user_id'=>$this->auth->id,
  18. ];
  19. $whereop = '(order.pay_type = 1 and order.status = 1) or (order.pay_type = 2)';
  20. if($active_status == 1){
  21. $where['active.activestarttime'] = ['gt',time()];
  22. $where['order.status'] = 1;
  23. }
  24. if($active_status == 2){
  25. $where['active.activestarttime'] = ['lt',time()];
  26. $where['active.activeendtime'] = ['gt',time()];
  27. $where['order.status'] = 1;
  28. }
  29. if($active_status == 3){
  30. $where['active.activeendtime'] = ['lt',time()];
  31. $where['order.status'] = 1;
  32. }
  33. if($active_status == 4){
  34. $where['order.pay_type'] = 2;
  35. $where['order.status'] = 0;
  36. }
  37. $list = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,active.images')
  38. ->join('active','order.active_id = active.id','LEFT')
  39. ->where($where)->where($whereop)->order('order.id desc')->autopage()->select();
  40. $list = list_domain_image($list,['images','offline_images']);
  41. if(!empty($list)){
  42. foreach($list as $key => &$item){
  43. //第一个图
  44. $item['image'] = isset($item['images'][0]) ? $item['images'][0] : '';
  45. //状态
  46. $status_text = '进行中';
  47. $status = 2;
  48. if(time() < $item['activestarttime']){
  49. $status_text = '报名中';
  50. $status = 1;
  51. }
  52. if(time() > $item['activeendtime']){
  53. $status_text = '已结束';
  54. $status = 3;
  55. }
  56. //是否能传图
  57. $item['can_upload'] = 0;
  58. if($item['pay_type'] == 2 && $item['status'] == 0){
  59. //收款码支付,待支付的
  60. $item['can_upload'] = 1;
  61. //待审核状态
  62. $status_text = '待审核';
  63. $status = 4;
  64. }
  65. $item['status_text'] = $status_text;
  66. $item['active_status'] = $status;
  67. }
  68. }
  69. $this->success(1,$list);
  70. }
  71. public function info(){
  72. $id = input('id',0);
  73. $info = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,us.realname,school.schoolname,grade.gradename,classes.classname')
  74. ->join('active','order.active_id = active.id','LEFT')
  75. ->join('user_student us','order.student_id = us.id','LEFT')
  76. ->join('school','us.school_id = school.id','LEFT')
  77. ->join('grade','us.grade_id = grade.id','LEFT')
  78. ->join('classes','us.classes_id = classes.id','LEFT')
  79. ->where('order.id',$id)->find();
  80. $info = info_domain_image($info,['offline_images']);
  81. $status_text = '进行中';
  82. $status = 2;
  83. if(time() < $info['activestarttime']){
  84. $status_text = '报名中';
  85. $status = 1;
  86. }
  87. if(time() > $info['activeendtime']){
  88. $status_text = '已结束';
  89. $status = 3;
  90. }
  91. //是否能传图
  92. $info['can_upload'] = 0;
  93. if($info['pay_type'] == 2 && $info['status'] == 0){
  94. //收款码支付,待支付的
  95. $info['can_upload'] = 1;
  96. //待审核状态
  97. $status_text = '待审核';
  98. $status = 4;
  99. }
  100. $info['status_text'] = $status_text;
  101. $info['active_status'] = $status;
  102. $this->success(1,$info);
  103. }
  104. public function order_upload(){
  105. $offline_images = input('offline_images','trim');
  106. $remark = input('remark','');
  107. $id = input('id',0);
  108. $data = [
  109. 'offline_images' => $offline_images,
  110. 'remark' => $remark,
  111. 'ispayimg' => 1,
  112. ];
  113. $info = Db::name('order')->where('id',$id)->update($data);
  114. $this->success('上传成功');
  115. }
  116. public function pay_qrcode(){
  117. $id = input('id',0,'intval');
  118. $info = Db::name('pay_qrcode')->where('is_show',1)->where('id != '.$id)->orderRaw('rand()')->find();
  119. $info = info_domain_image($info,['image']);
  120. $this->success(1,$info);
  121. }
  122. }