Order.php 4.0 KB

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