Order.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. }
  23. if($active_status == 2){
  24. $where['active.activestarttime'] = ['lt',time()];
  25. $where['active.activeendtime'] = ['gt',time()];
  26. }
  27. if($active_status == 3){
  28. $where['active.activeendtime'] = ['lt',time()];
  29. }
  30. if($active_status == 4){
  31. $where['order.pay_type'] = 2;
  32. $where['order.status'] = 0;
  33. }
  34. $list = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,active.images')
  35. ->join('active','order.active_id = active.id','LEFT')
  36. ->where($where)->where($whereop)->order('order.id desc')->autopage()->select();
  37. $list = list_domain_image($list,['images','offline_images']);
  38. if(!empty($list)){
  39. foreach($list as $key => &$item){
  40. //第一个图
  41. $item['image'] = isset($item['images'][0]) ? $item['images'][0] : '';
  42. //状态
  43. $status_text = '进行中';
  44. $status = 2;
  45. if(time() < $item['activestarttime']){
  46. $status_text = '报名中';
  47. $status = 1;
  48. }
  49. if(time() > $item['activeendtime']){
  50. $status_text = '已结束';
  51. $status = 3;
  52. }
  53. //是否能传图
  54. $item['can_upload'] = 0;
  55. if($item['pay_type'] == 2 && $item['status'] == 0){
  56. //收款码支付,待支付的
  57. $item['can_upload'] = 1;
  58. //待审核状态
  59. $status_text = '待审核';
  60. $status = 4;
  61. }
  62. $item['status_text'] = $status_text;
  63. $item['active_status'] = $status;
  64. }
  65. }
  66. $this->success(1,$list);
  67. }
  68. public function info(){
  69. $id = input('id',0);
  70. $info = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,us.realname,school.schoolname,grade.gradename,classes.classname')
  71. ->join('active','order.active_id = active.id','LEFT')
  72. ->join('user_student us','order.student_id = us.id','LEFT')
  73. ->join('school','us.school_id = school.id','LEFT')
  74. ->join('grade','us.grade_id = grade.id','LEFT')
  75. ->join('classes','us.classes_id = classes.id','LEFT')
  76. ->where('order.id',$id)->find();
  77. $info = info_domain_image($info,['offline_images']);
  78. $status_text = '进行中';
  79. $status = 2;
  80. if(time() < $info['activestarttime']){
  81. $status_text = '报名中';
  82. $status = 1;
  83. }
  84. if(time() > $info['activeendtime']){
  85. $status_text = '已结束';
  86. $status = 3;
  87. }
  88. //是否能传图
  89. $info['can_upload'] = 0;
  90. if($info['pay_type'] == 2 && $info['status'] == 0){
  91. //收款码支付,待支付的
  92. $info['can_upload'] = 1;
  93. //待审核状态
  94. $status_text = '待审核';
  95. $status = 4;
  96. }
  97. $info['status_text'] = $status_text;
  98. $info['active_status'] = $status;
  99. $this->success(1,$info);
  100. }
  101. public function order_upload(){
  102. $offline_images = input('offline_images','trim');
  103. $remark = input('remark','');
  104. $id = input('id',0);
  105. $data = [
  106. 'offline_images' => $offline_images,
  107. 'remark' => $remark,
  108. ];
  109. $info = Db::name('order')->where('id',$id)->update($data);
  110. $this->success('上传成功');
  111. }
  112. public function pay_qrcode(){
  113. $info = Db::name('pay_qrcode')->where('is_show',1)->orderRaw('rand()')->find();
  114. $info = info_domain_image($info,['image']);
  115. $this->success(1,$info);
  116. }
  117. }