yingzi 1 年間 前
コミット
90b0c32026
2 ファイル変更55 行追加23 行削除
  1. 55 22
      Controller/Shop/ApiShopProject.Class.php
  2. 0 1
      Model/Shop/MShopRostering.Class.php

+ 55 - 22
Controller/Shop/ApiShopProject.Class.php

@@ -309,34 +309,67 @@ class ApiShopProject extends BaseController
      * 员工可预约时间段
      * @return void
      */
-    public function choice_time()
+//    public function choice_time()
+//    {
+//        $time = $this->request->param('time');
+//        $uid = $this->request->param('uid');
+//
+//        $rostering = $this->objRostering->details([['time', 'like', '%'.$time.'%'], ['uid', '=', $uid]])->getData();
+//       
+//        $rostering['time_slot'] = json_decode($rostering['time_slot']);
+//        $rostering['clock'] = json_decode($rostering['clock']);
+//
+//
+//        $Stime = strtotime($time);
+//        $Etime = strtotime($time) + 86400;
+//        $where[] = ['uid', '=', $uid];
+//        $where[] = ['time', '>=', $Stime];
+//        $where[] = ['time', '<=', $Etime];
+//        $order = $this->objSub->select($where)->getData();
+//
+//        $rostering['reserved'] = [];
+//        if ($order){
+//            foreach ($order['data'] as $item)
+//            {
+//                $rostering['reserved'][] = date('H:i:s', $item['time']);
+//            }
+//        }
+//
+//        parent::sendOutput($rostering);
+//    }
+    
+     public function choice_time()
     {
         $time = $this->request->param('time');
         $uid = $this->request->param('uid');
-
-        $rostering = $this->objRostering->details([['time', 'like', '%'.$time.'%'], ['uid', '=', $uid]])->getData();
-        var_dump($rostering);
-       
-        $rostering['time_slot'] = json_decode($rostering['time_slot']);
-        $rostering['clock'] = json_decode($rostering['clock']);
-
-
-        $Stime = strtotime($time);
-        $Etime = strtotime($time) + 86400;
-        $where[] = ['uid', '=', $uid];
-        $where[] = ['time', '>=', $Stime];
-        $where[] = ['time', '<=', $Etime];
-        $order = $this->objSub->select($where)->getData();
-
-        $rostering['reserved'] = [];
-        if ($order){
-            foreach ($order['data'] as $item)
-            {
-                $rostering['reserved'][] = date('H:i:s', $item['time']);
+        
+        $rostering = $this->objRostering->details([['time', 'like', '%'.$time.'%'], ['uid', '=', $uid]]);
+        
+        if ($rostering->isSuccess()) {
+            $rostering = $rostering->getData();
+            $rostering['time_slot'] = json_decode($rostering['time_slot']);
+            $rostering['clock'] = json_decode($rostering['clock']);
+
+
+            $Stime = strtotime($time);
+            $Etime = strtotime($time) + 86400;
+            $where[] = ['uid', '=', $uid];
+            $where[] = ['time', '>=', $Stime];
+            $where[] = ['time', '<=', $Etime];
+            $rostering['reserved'] = [];
+            $order = $this->objSub->select($where)->getData();
+            if($order->isSuccess()){
+                $order = $order->getData();
+                foreach ($order['data'] as $item)
+                {
+                    $rostering['reserved'][] = date('H:i:s', $item['time']);
+                }
             }
+            parent::sendOutput($rostering);
+        } else {
+            parent::sendOutput($rostering->getData(), ErrorCode::$dberror);
         }
 
-        parent::sendOutput($rostering);
     }
 
 

+ 0 - 1
Model/Shop/MShopRostering.Class.php

@@ -142,7 +142,6 @@ class MShopRostering extends MBaseModel
             return ResultWrapper::success($where);
         }
         $dbResult = $this->obj->get($where);
-        var_dump($dbResult);
         if(empty($dbResult)){
             return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
         }