Pārlūkot izejas kodu

订单,列表、详情

lizhen_gitee 11 mēneši atpakaļ
vecāks
revīzija
2dd0ec16ac

+ 87 - 5
application/api/controller/Wenzhen.php

@@ -163,10 +163,10 @@ class Wenzhen extends Api
 
     //订单列表
     public function order_list(){
-        $status = input('status',0);
+        $status = input('status','all');
 
-        $where = [];
-        if(!empty($status)){
+        $where = ['user_id'=>$this->auth->id];
+        if($status != 'all'){
             $where['order.status'] = $status;
 
             if($status == 30){
@@ -175,15 +175,97 @@ class Wenzhen extends Api
         }
 
         $field = [
-            'order.id','order.order_no','order.createtime','order.status',
+            'order.id','order.order_no','order.createtime','order.status','order.ordertype','order.accept_time',
             'doctor.avatar','doctor.nickname',
         ];
         $list = Db::name('wenzhen_order')->alias('order')
-            ->join('')
+            ->field($field)
+            ->join('doctor','order.doctor_id = doctor.id','LEFT')
+            ->order('order.id desc')
+            ->where($where)
+            ->autopage()->select();
+        $list = list_domain_image($list,['avatar']);
+
+        if(!empty($list)){
+            //订单类型
+            $ordertype_data = [
+                1 => ['name'=>'图文订单','name_en'=>'Visual Order'],
+                2 => ['name'=>'视频订单','name_en'=>'Video Order'],
+            ];
+
+            //状态备注
+            $status_data = $this->order_status_enum();
+
+            //循环处理
+            foreach($list as $key => $val){
+                //订单类型,辅助
+                $val['ordertype_data'] = $ordertype_data[$val['ordertype']];
+
+                //订单状态,辅助
+                $status_data_val = $status_data[$val['status']];
+
+                    //未支付订单N分钟后自动取消
+                    if($val['status'] == 0){
+                        $remain_time = $val['createtime'] + (config('site.nopay_order_autocancel_minute')*60) - time();
+                        if($remain_time > 0){
+                            $status_data_val['name'] .= ':'.Sec2Time($remain_time);
+                        }
+                    }
+
+                    //视频订单接诊后N分钟自动结束
+                    if($val['status'] == 20 && $val['ordertype'] == 2){
+                        $remain_time = $val['accept_time'] + (config('site.accept_videoorder_autofinish_minute')*60) - time();
+                        if($remain_time > 0){
+                            $status_data_val['name'] .= ':'.Sec2Time($remain_time);
+                        }
+                    }
+
+                $val['status_data'] = $status_data_val;
+
+                //
+                $list[$key] = $val;
+            }
+        }
 
+        $this->success(1,$list);
 
     }
 
+    //订单状态备注枚举
+    private function order_status_enum(){
+        $status_data = [
+            0 =>  [
+                'name'=>'等待支付时间',
+                'name_en'=>'Waiting time for payment'
+            ],
+            10 => [
+                'name'=>'等待医生接诊:已通知医生尽快接诊,超时自动取消订单并退款',
+                'name_en'=>'Waiting for the doctor. If not accepted within the specified time,the consultation will be automatically canceled, and a refund will be issued'
+            ],
+            20 => [
+                'name'=>'距离结束时间',
+                'name_en'=>'Time Remaining'
+            ],
+            30 => [
+                'name'=>'点击查看医生反馈结果',
+                'name_en'=>'Click to view the consultation results'
+            ],
+            90 => [
+                'name'=>'您的订单未及时支付,已失效',
+                'name_en'=>'Your order was not paid on time and has expired.'
+            ],
+            91 => [
+                'name'=>'您的订单已申请退款',
+                'name_en'=>'Your order has been requested for a refund'
+            ],
+            92 => [
+                'name'=>'您的订单已被退诊',
+                'name_en'=>'Your order has been returned for consultation'
+            ],
+        ];
+        return $status_data;
+    }
+
     //订单详情
     public function order_info(){
         $order_id = input('order_id',0);

+ 5 - 17
application/common.php

@@ -937,33 +937,21 @@ if(!function_exists('Sec2Time')) {
     function Sec2Time($time){
         if(is_numeric($time)){
             $value = array(
-                'years' => 0, 'days' => 0, 'hours' => 0,
                 'minutes' => 0, 'seconds' => 0,
             );
-            /*if($time >= 31556926){
-                $value['years'] = floor($time/31556926);
-                $time = ($time%31556926);
-            }*/
-            if($time >= 86400){
-                $value['days'] = floor($time/86400);
-                $time = ($time%86400);
-            }
-            if($time >= 3600){
-                $value['hours'] = floor($time/3600);
-                $time = ($time%3600);
-            }
+
             if($time >= 60){
                 $value['minutes'] = floor($time/60);
                 $time = ($time%60);
             }
+
             $value['seconds'] = floor($time);
-            //return (array) $value;
-            //$t=$value['years'] .'年'. $value['days'] .'天'.' '. $value['hours'] .'小时'. $value['minutes'] .'分'.$value['seconds'].'秒';
-            $t = $value['days'] .'天' . $value['hours'] .'小时'. $value['minutes'] .'分';
+
+            $t = $value['minutes'] .'分'.$value['seconds'].'秒';
             return $t;
 
         }else{
-            return '0';
+            return '0分钟';
         }
     }
 }

+ 4 - 0
application/extra/site.php

@@ -32,6 +32,7 @@ return array (
     'doctorandroid' => '医生安卓版本',
     'doctorios' => '医生IOS版本',
     'takecash' => '提现配置',
+    'wenzhen' => '问诊配置',
   ),
   'mail_type' => '1',
   'mail_smtp_host' => 'smtp.qq.com',
@@ -84,4 +85,7 @@ return array (
 1、选择本服务后,您可在咨询医生前提交初诊时的诊断结果,一段说明文字和6张图片以描述您的病情信息,为了保证咨询质量请务必填写真实信息。
 1、选择本服务后,您可在咨询医生前提交初诊时的诊断结果,一段说明文字和6张图片以描述您的病情信息,为了保证咨询质量请务必填写真实信息。
 1、选择本服务后,您可在咨询医生前提交初诊时的诊断结果,一段说明文字和6张图片以描述您的病情信息,为了保证咨询质量请务必填写真实信息。',
+  'nopay_order_autocancel_minute' => '10',
+  'accept_videoorder_autofinish_minute' => '10',
+  'payorder_noaccept_autocancel_minute' => '10',
 );

+ 8 - 3
application/index/controller/Plantask.php

@@ -8,13 +8,18 @@ use think\Cache;
 
 class Plantask extends Controller
 {
-    //超时未支付订单,自动取消
+    //未支付订单N分钟后自动取消
     public function auto_cancel_nopay_order(){
 
     }
 
-    //超时未接诊订单,自动取消,并退款
-    public function aoto_cancel_noaccept_order(){
+    //超预约时间N分钟后 未接诊订单 自动取消 并退款
+    public function auto_cancel_noaccept_order(){
+
+    }
+
+    //视频订单接诊后N分钟自动结束
+    public function auto_finish_accept_videoorder(){
 
     }