Bläddra i källkod

商家订单调整字段

zhangxiaobin 1 år sedan
förälder
incheckning
65cd6a9289

+ 10 - 5
application/api/controller/company/Coupon.php

@@ -112,14 +112,19 @@ class Coupon extends Apic
                 $check['action'] = $action;
             }
         }else{
+            $p = 'package';
+            $o = 'order';
             $map = [
-                'company_id' => $this->auth->company_id,
-                'check_code' => $id,
-                'ordertype'  => 3,
-                'status'     => 1, //1=待核销
+                $o.'.company_id' => $this->auth->company_id,
+                $o.'.check_code' => $id,
+                $o.'.ordertype'  => 3,
+                $o.'.status'     => 1, //1=待核销
             ];
-            $check = Db::name('order')->field('id,server_info as name,pay_fee as price')->where($map)->find();
+            $check = Db::name($o)->alias($o)->field($o.'.id,server_info as name,pay_fee as price,'.$p.'.title as `package_title`')
+                ->join($p,$p.'.id = '.$o.'.package_id','LEFT')
+                ->where($map)->find();
             if(!empty($check)){
+                $check['name'] = $check['package_title'];
                 $check['getfrom'] = '购买';
                 $check['action'] = $action;
             }

+ 23 - 16
application/api/controller/company/Order.php

@@ -37,27 +37,28 @@ class Order extends Apic
         $endtime = input('endtime',0);
         $servicetype_id = intval(input('servicetype_id',0));
         $status  = intval(input('status',0));
-
-        $order = 'order.id desc';
+        $o = 'order';
+        $p = 'package';
+        $order = $o.'.id desc';
 
         $where = [
-            'company_id' => $this->auth->company_id,
+            $o.'.company_id' => $this->auth->company_id,
         ];
         //员工
         if($this->auth->type == 2){
-            $where['staff_id'] = $this->auth->id;
+            $where[$o.'.staff_id'] = $this->auth->id;
         }//员工
 
         if($starttime || $endtime){
-            $where['createtime'] = ['between',$starttime,$endtime];
+            $where[$o.'.createtime'] = ['between',$starttime,$endtime];
         }
         if($servicetype_id){
-            $where['servicetype_id'] = $servicetype_id;
+            $where[$o.'.servicetype_id'] = $servicetype_id;
         }
         if($status){
-            $where['status'] = $status;  //状态:2=待处理,3=已核销(完成),4=已取消
+            $where[$o.'.status'] = $status;  //状态:2=待处理,3=已核销(完成),4=已取消
             if($status > 2){
-                $order = 'order.finish_time desc';
+                $order = $o.'.finish_time desc';
             }
 
         }
@@ -66,12 +67,15 @@ class Order extends Apic
         {
             $where['user_car_number|user_mobile'] = ['LIKE','%'.$keyword.'%'];
         }
-        $list = Db::name('order')->alias('order')
-            ->join('servicetype','order.servicetype_id = servicetype.id','LEFT')
-            ->field('order.id,orderno,ordertype,user_name,user_mobile,user_car_number,createtime,servicetype_id,server_info,server_time,status,finish_time,cancel_reason,hexiao_time,cancel_time,servicetype.title as servicetype_title,servicetype.baoyang_switch')->where($where)->order($order)->autopage()->select();
+        $list = Db::name('order')->alias($o)
+            ->join('servicetype',$o.'.servicetype_id = servicetype.id','LEFT')
+            ->join($p,$p.'.id = '.$o.'.package_id','LEFT')
+            ->field($o.'.id,orderno,ordertype,user_name,user_mobile,user_car_number,'.
+                $o.'.createtime,'.$o.'.servicetype_id,server_info,server_time,'.$o.'.status,finish_time,cancel_reason,hexiao_time,cancel_time,servicetype.title as servicetype_title,servicetype.baoyang_switch,'.$p.'.title as `package_title`')->where($where)->order($order)->autopage()->select();
 
         foreach($list as $key => &$val){
             $val['status_text'] = $this->status_text($val['status']);
+            $val['server_info'] = $val['package_title'];
         }
         $this->success(1,$list);
     }
@@ -80,14 +84,17 @@ class Order extends Apic
     //详情
     public function info(){
         $id = input('id',0);
-        $info = Db::name('order')->alias('order')
-            ->join('servicetype','order.servicetype_id = servicetype.id','LEFT')
-            ->field('order.*,servicetype.title as servicetype_title,servicetype.baoyang_switch')
-            ->where('order.id',$id)->find();
+        $o = 'order';
+        $p = 'package';
+        $info = Db::name('order')->alias($o)
+            ->join('servicetype',$o.'.servicetype_id = servicetype.id','LEFT')
+            ->join($p,$p.'.id = '.$o.'.package_id','LEFT')
+            ->field($o.'.*,servicetype.title as servicetype_title,servicetype.baoyang_switch,'.$p.'.title as package_title')
+            ->where($o.'.id',$id)->find();
         $info = info_domain_image($info,['server_images']);
         $info['status_text'] = $this->status_text($info['status']);
         $info['total_fee'] = bcadd($info['pay_fee'],$info['appen_fee'],2);
-
+        $info['server_info'] = $info['package_title'];
         $info['appen_list'] = Db::name('order_appen')->where('order_id',$id)->select();
 
         $this->success(1,$info);