123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- namespace app\api\controller;
- use app\admin\model\Method;
- use app\admin\model\method\Time;
- use app\admin\model\Order;
- use app\admin\model\Ordercode;
- use app\admin\model\Orderitem;
- use app\admin\model\Pingjia;
- use app\api\model\GoodsSku;
- use app\common\controller\Api;
- class Pond extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- public function order_list(){
- $order_model = new Order();
- $order_item_model= new Orderitem();
- $status=input('status',0);
- $stand_time = input('stand_time');
- $end_time = input('end_time');
- $phone = input('phone');
- $yutang_id = input('yutang_id');
- $type = input('type');
- $moshi = input('moshi');
- //订单状态:1=待支付,2=待核销,3=进行中,4=待评价,5=已完成,6=退款中,7=已退款,8=已取消
- switch ($status){
- case 0:
- $array = [0,1,2,3,4,5,6,7,8];
- break;
- case 1:
- $array = [1];
- break;
- case 2:
- $array = [2];
- break;
- case 3:
- $array = [3];
- break;
- case 4:
- $array = [4];
- break;
- case 5:
- $array = [6,7];
- break;
- case 6:
- $array = [8];
- break;
- }
- $where = [];
- if($stand_time&&$end_time) {
- $where['create_time'] = ['between', [strtotime($stand_time), strtotime($end_time)]];
- }
- if($yutang_id){
- $where['yutang_id'] = ['=', $yutang_id];
- }
- if($type){
- $where['type'] = ['=', $type];
- }
- if($moshi){
- $where['moshi'] = ['=', $moshi];
- }
- if($phone){
- $where['phone'] = ['=', $phone];
- }
- $list= $order_model->where('t_user_id',$this->auth->id)->whereIn('status',$array)->where($where)->order('id','desc')->paginate();
- foreach ($list as &$v){
- $v['item']=$order_item_model->where('order_id',$v['id'])->select();
- if($v['status']==3){
- $time=strtotime($v['end'])-strtotime(date( "H:i"));
- if($time<=1800) {
- $v['time'] = $time;
- }
- }
- }
- $this->success('我的订单列表',$list);
- }
- public function order_detail()
- {
- $order_id = input('order_id');
- $order_model = new Order();
- $order_item = new Orderitem();
- $order_code = new Ordercode();
- $pingjia_model = new Pingjia();
- $order_info = $order_model->where('id', $order_id)->find();
- if (empty($order_info)) {
- $this->error('订单信息有误');
- }
- if ($order_info['status']) {
- $order_info['time'] = $order_info['create_time'] + 30 * 60 - time();
- }
- $order_info['item'] = $order_item->where('order_id', $order_id)->select();
- $order_info['code'] = $order_code->where('order_id', $order_id)->select();
- $order_info['pingjia'] = $pingjia_model->where('user_id',$order_info['user_id'])->where('yutang_id',$order_info['yutang_id'])->find();
- $this->success('订单详情', $order_info);
- }
- public function method_log(){
- $type = input('type','1');
- $method_model = new Method();
- $list = $method_model->where('status',$type)->where('user_id',$this->auth->id)->paginate();
- $this->success('我的发布',$list);
- }
- public function write_log(){
- $method_id = input('method_id');
- $type = input('type','1');
- if($type==1){
- $where['ruchang_status']=['=',2];
- }
- if($type==2){
- $where['wucan_status']=['=',2];
- }
- if($type==3){
- $where['yajin_status']=['=',2];
- }
- $method_model = new Method();
- $item_model = new Time();
- $order_code_model = new Ordercode();
- $method_info = $method_model->where('id',$method_id)->find();
- $time_list = $item_model->where('m_id',$method_id)->select();
- foreach ($time_list as &$v){
- $v['show_image'] = $method_info['show_images'];
- $v['yutang_name'] = $method_info['yutang_name'];
- $v['moshi'] = $method_info['moshi'];
- $v['m_type'] = $method_info['type'];
- $v['date'] = date('Y-m-d');
- $v['count'] = $order_code_model->where('time_id',$v['id'])->where($where)->count();
- }
- $this->success('核销时间段',$time_list);
- }
- public function write_list(){
- $method_model = new Method();
- $item_model = new Time();
- $order_code_model = new Ordercode();
- $time_id = input('time_id');
- $type = input('type','1');
- if($type==1){
- $where['ruchang_status']=['=',2];
- }
- if($type==2){
- $where['wucan_status']=['=',2];
- }
- if($type==3){
- $where['yajin_status']=['=',2];
- }
- $time_info = $item_model->where('id',$time_id)->find();
- $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();
- $time_info['code'] = $order_code_model->where('time_id',$time_id)->where($where)->paginate();
- $this->success('已核销信息',$time_info);
- }
- public function wucna_tongzhi(){
- $user = $this->auth->getUser();
- $order_model = new Order();
- $mobiles = $order_model->where('t_user_id',$this->auth->id)->where('wucan_money','>',0)->where('status',3)->field('phone')->select();
- if(empty($mobiles)){
- $this->error('没有就餐人员');
- }
- if(count($mobiles)>$user->sms_number){
- $this->error('短信数量不足');
- }
- else{
- $user->sms_number -=count($mobiles);
- $user->save();
- }
- $sms= new Sms();
- $sms->wucna_tongzhi($mobiles,$this->auth->id);
- $this->success('午餐通知已发出');
- }
- }
|