Pond.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\Method;
  4. use app\admin\model\method\Time;
  5. use app\admin\model\Order;
  6. use app\admin\model\Ordercode;
  7. use app\admin\model\Orderitem;
  8. use app\admin\model\Pingjia;
  9. use app\api\model\GoodsSku;
  10. use app\common\controller\Api;
  11. class Pond extends Api
  12. {
  13. protected $noNeedLogin = [];
  14. protected $noNeedRight = ['*'];
  15. public function order_list(){
  16. $order_model = new Order();
  17. $order_item_model= new Orderitem();
  18. $status=input('status',0);
  19. $stand_time = input('stand_time');
  20. $end_time = input('end_time');
  21. $phone = input('phone');
  22. $yutang_id = input('yutang_id');
  23. $type = input('type');
  24. $moshi = input('moshi');
  25. //订单状态:1=待支付,2=待核销,3=进行中,4=待评价,5=已完成,6=退款中,7=已退款,8=已取消
  26. switch ($status){
  27. case 0:
  28. $array = [0,1,2,3,4,5,6,7,8];
  29. break;
  30. case 1:
  31. $array = [1];
  32. break;
  33. case 2:
  34. $array = [2];
  35. break;
  36. case 3:
  37. $array = [3];
  38. break;
  39. case 4:
  40. $array = [4];
  41. break;
  42. case 5:
  43. $array = [6,7];
  44. break;
  45. case 6:
  46. $array = [8];
  47. break;
  48. }
  49. $where = [];
  50. if($stand_time&&$end_time) {
  51. $where['create_time'] = ['between', [strtotime($stand_time), strtotime($end_time)]];
  52. }
  53. if($yutang_id){
  54. $where['yutang_id'] = ['=', $yutang_id];
  55. }
  56. if($type){
  57. $where['type'] = ['=', $type];
  58. }
  59. if($moshi){
  60. $where['moshi'] = ['=', $moshi];
  61. }
  62. if($phone){
  63. $where['phone'] = ['=', $phone];
  64. }
  65. $list= $order_model->where('t_user_id',$this->auth->id)->whereIn('status',$array)->where($where)->order('id','desc')->paginate();
  66. foreach ($list as &$v){
  67. $v['item']=$order_item_model->where('order_id',$v['id'])->select();
  68. if($v['status']==3){
  69. $time=strtotime($v['end'])-strtotime(date( "H:i"));
  70. if($time<=1800) {
  71. $v['time'] = $time;
  72. }
  73. }
  74. }
  75. $this->success('我的订单列表',$list);
  76. }
  77. public function order_detail()
  78. {
  79. $order_id = input('order_id');
  80. $order_model = new Order();
  81. $order_item = new Orderitem();
  82. $order_code = new Ordercode();
  83. $pingjia_model = new Pingjia();
  84. $order_info = $order_model->where('id', $order_id)->find();
  85. if (empty($order_info)) {
  86. $this->error('订单信息有误');
  87. }
  88. if ($order_info['status']) {
  89. $order_info['time'] = $order_info['create_time'] + 30 * 60 - time();
  90. }
  91. $order_info['item'] = $order_item->where('order_id', $order_id)->select();
  92. $order_info['code'] = $order_code->where('order_id', $order_id)->select();
  93. $order_info['pingjia'] = $pingjia_model->where('user_id',$order_info['user_id'])->where('yutang_id',$order_info['yutang_id'])->find();
  94. $this->success('订单详情', $order_info);
  95. }
  96. public function method_log(){
  97. $type = input('type','1');
  98. $method_model = new Method();
  99. $list = $method_model->where('status',$type)->where('user_id',$this->auth->id)->paginate();
  100. $this->success('我的发布',$list);
  101. }
  102. public function write_log(){
  103. $method_id = input('method_id');
  104. $type = input('type','1');
  105. if($type==1){
  106. $where['ruchang_status']=['=',2];
  107. }
  108. if($type==2){
  109. $where['wucan_status']=['=',2];
  110. }
  111. if($type==3){
  112. $where['yajin_status']=['=',2];
  113. }
  114. $method_model = new Method();
  115. $item_model = new Time();
  116. $order_code_model = new Ordercode();
  117. $method_info = $method_model->where('id',$method_id)->find();
  118. $time_list = $item_model->where('m_id',$method_id)->select();
  119. foreach ($time_list as &$v){
  120. $v['show_image'] = $method_info['show_images'];
  121. $v['yutang_name'] = $method_info['yutang_name'];
  122. $v['moshi'] = $method_info['moshi'];
  123. $v['m_type'] = $method_info['type'];
  124. $v['date'] = date('Y-m-d');
  125. $v['count'] = $order_code_model->where('time_id',$v['id'])->where($where)->count();
  126. }
  127. $this->success('核销时间段',$time_list);
  128. }
  129. public function write_list(){
  130. $method_model = new Method();
  131. $item_model = new Time();
  132. $order_code_model = new Ordercode();
  133. $time_id = input('time_id');
  134. $type = input('type','1');
  135. if($type==1){
  136. $where['ruchang_status']=['=',2];
  137. }
  138. if($type==2){
  139. $where['wucan_status']=['=',2];
  140. }
  141. if($type==3){
  142. $where['yajin_status']=['=',2];
  143. }
  144. $time_info = $item_model->where('id',$time_id)->find();
  145. $time_info['desc'] = $method_model->alias('m')->join('yutang y','y.id=m.yutang_id')->where('m.id',$time_info['m_id'])->field('m.yutang_name,m.type,m.moshi,y.image')->find();
  146. $time_info['code'] = $order_code_model->where('time_id',$time_id)->where($where)->paginate();
  147. $this->success('已核销信息',$time_info);
  148. }
  149. public function wucna_tongzhi(){
  150. $user = $this->auth->getUser();
  151. $order_model = new Order();
  152. $mobiles = $order_model->where('t_user_id',$this->auth->id)->where('wucan_money','>',0)->where('status',3)->field('phone')->select();
  153. if(empty($mobiles)){
  154. $this->error('没有就餐人员');
  155. }
  156. if(count($mobiles)>$user->sms_number){
  157. $this->error('短信数量不足');
  158. }
  159. else{
  160. $user->sms_number -=count($mobiles);
  161. $user->save();
  162. }
  163. $sms= new Sms();
  164. $sms->wucna_tongzhi($mobiles,$this->auth->id);
  165. $this->success('午餐通知已发出');
  166. }
  167. }