Explorar o código

fix():修改配置

geek %!s(int64=4) %!d(string=hai) anos
pai
achega
253bb80810

+ 63 - 14
application/api/controller/Room.php

@@ -209,7 +209,7 @@ class Room extends BaseController {
      *         @OA\Schema(
      *           @OA\Property(description="门店id", property="storeId", type="integer", default="1"),
      *           @OA\Property(description="日期(默认今天)", property="date", type="string", default="2021-04-29"),
-     *           @OA\Property(description="状态 1已开始 2已完成 3已开始和已完成", property="status", type="integer", default="1"),
+     *           @OA\Property(description="状态 1未开始 2服务中 3已完成(多个逗号分隔)", property="status", type="integer", default="1"),
      *           required={"storeId","status"})
      *       )
      *     ),
@@ -220,20 +220,16 @@ class Room extends BaseController {
         $input = Until::getInput();
         $rule = [
             'storeId|门店id' => 'require',
-            //            'date|日期' => 'require',
+            //'date|日期' => 'require',
             'status|状态'    => 'require',
         ];
         Until::check($rule, $input);
         $where = [];
-        if ($input['status'] == 3) {
-            $where[] = ['as.status', 'in', [2, 3]];
-        }
-        if ($input['status'] == 2) {
-            $where[] = ['as.status', '=', 2];
-        }
-        if ($input['status'] == 1) {
-            $where[] = ['as.status', '=', 1];
+        if (!empty($input['status'])) {
+            $statusArr = explode(',', $input['status']);
+            $where[] = ['as.status', 'in', $statusArr];
         }
+
         if (empty($input['date'])) {
             $input['date'] = date('Y-m-d');
         }
@@ -246,26 +242,79 @@ class Room extends BaseController {
         }
         $list = [];
         foreach ($rs as $v) {
-            $productInfo = json_decode($v['product_snap'],true);
+            if ($v['asStatus'] == 2){
+                $allocateOrderStatus = 3; //服务中
+            }elseif ($v['asStatus'] == 3) {
+                $allocateOrderStatus = 4; // 服务结束
+            }else {
+                $allocateOrderStatus = 2; //未开始
+            }
+            $productInfo = json_decode($v['product_snap'], true);
             if (empty($v['server_end_time'])) {
                 $endTime = strtotime($v['server_start_time']) + $productInfo['time'];
                 $time = $productInfo['time'];
             } else {
                 $endTime = strtotime($v['server_end_time']);
-                $time = (int)(($endTime - strtotime($v['server_start_time']))/60);
+                $time = (int)(($endTime - strtotime($v['server_start_time'])) / 60);
             }
             $list[$v['room_id']][] = [
                 'productName'         => $productInfo['product_name'],
                 'start'               => (int)((strtotime($v['server_start_time']) - strtotime($input['date'] . ' 08:00:00')) / 60),
                 'time'                => $time,
-                'allocateOrderStatus' => $v['asStatus'] == 2 ? 3 : 4,
+                'allocateOrderStatus' => $allocateOrderStatus,
                 'startTime'           => date('H:i', strtotime($v['server_start_time'])),
                 'endTime'             => date('H:i', $endTime),
-                'staffName'           => $v['staff_name']
+                'staffName'           => $v['staff_name'],
+                'orderId'             => $v['order_id'],
+                'name'                => $v['name'],
+                'realName'            => $v['real_name'],
+                'orderType'           => $v['order_type'],
             ];
         }
         Until::output($list);
     }
 
+    /**
+     * @OA\Post(path="/api/room/freeRoom",
+     *   tags={"房间管理"},
+     *   summary="还未分配房间",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="门店id", property="storeId", type="integer", default="1"),
+     *           @OA\Property(description="日期(默认今天)", property="date", type="string", default="2021-04-29"),
+     *           required={"storeId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function freeRoom() {
+        $input = Until::getInput();
+        $rule = [
+            'storeId|门店id' => 'require',
+            //'date|日期' => 'require',
+        ];
+        Until::check($rule, $input);
+        $where = [];
+        if (empty($input['date'])) {
+            $input['date'] = date('Y-m-d');
+        }
+        $where[] = ['o.status', '=', 2];
+        $where[] = ['or.id', '=', null];
+        $where[] = ['o.appointment_time', 'between', [$input['date'], date('Y-m-d', strtotime('+1 day', strtotime($input['date'])))]];
+        $model = new OrderRoomModel();
+        $model->setWhere($where);
+        $rs = $model->getfreeRoomList();
+        if (empty($rs)) {
+            Until::output([]);
+        }
+        $list = $rs;
+        $count = count($rs);
+        Until::output(['count' => $count, 'list' => $list]);
+    }
+
 
 }

+ 15 - 1
application/api/model/OrderRoomModel.php

@@ -16,12 +16,26 @@ class OrderRoomModel extends BaseModel {
     public function getRoomList() {
         $rs = $this->alias('or')
             ->field('or.*,
-            as.server_start_time,as.status as asStatus,as.server_end_time,s.staff_name,op.product_snap')
+            as.server_start_time,as.status as asStatus,as.server_end_time,s.staff_name,op.product_snap,
+            u.name,u.real_name,o.order_type')
             ->join('room r','r.id = or.room_id')
             ->join('order o','o.id = or.order_id')
             ->join('allocate_staff as','as.order_id = o.id')
             ->join('staff s','s.id = as.staff_id')
             ->join('order_product op','op.order_id = o.id')
+            ->join('user u','u.id = o.user_id','left')
+            ->where($this->getWhere())
+            ->select();
+        return Until::modelToArray($rs);
+    }
+
+    public function getfreeRoomList() {
+        $model = new OrderModel();
+        $rs = $model->alias('o')
+            ->field('o.id as orderId,o.staff_id')
+            ->join('order_room or','o.id = or.order_id','left')
+            ->join('allocate_staff as','as.order_id = o.id')
+            ->join('staff s','s.id = as.staff_id')
             ->where($this->getWhere())
             ->select();
         return Until::modelToArray($rs);

+ 6 - 1
application/common/service/OrderService.php

@@ -66,7 +66,12 @@ class OrderService {
                 'user_id'          => $userId,
                 'admin_id'         => Until::$adminId
             ]);
-            (new AllocateModel())->insertGetId(['order_id' => $orderId, 'staff_id' => $input['staffId'],'assign_admin_id' => Until::$adminId]);
+            (new AllocateModel())->insertGetId([
+                'order_id'          => $orderId,
+                'staff_id'          => $input['staffId'],
+                'assign_admin_id'   => Until::$adminId,
+                'server_start_time' => $input['appointmentTime'],
+            ]);
             $opModel = new OrderProductModel();
             $opModel->insert([
                 'order_id'        => $orderId,

+ 1 - 0
application/common/service/UserService.php

@@ -92,6 +92,7 @@ class UserService {
         if (empty($info)) {
             $userId = $userModel->insertGetId([
                 'name'          => $wxUsrInfo['nickName'] ?: '',
+                'real_name'     => $wxUsrInfo['nickName'] ?: '',
                 'avatar'        => $wxUsrInfo['avatarUrl'] ?: '',
                 'open_id'       => $openId,
                 'join_type'     => 1,

+ 38 - 1
public/api.yaml

@@ -1912,7 +1912,44 @@ paths:
                   type: string
                   default: '2021-04-29'
                 status:
-                  description: '状态 1已开始 2已完成 3已开始和已完成'
+                  description: '状态 1未开始 2服务中 3已完成(多个逗号分隔)'
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/room/freeRoom:
+    post:
+      tags:
+        - 房间管理
+      summary: 还未分配房间
+      operationId: 'app\api\controller\Room::freeRoom'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - storeId
+                - status
+              properties:
+                storeId:
+                  description: 门店id
+                  type: integer
+                  default: '1'
+                date:
+                  description: 日期(默认今天)
+                  type: string
+                  default: '2021-04-29'
+                status:
+                  description: '状态 1未开始 2服务中 3已完成(多个逗号分隔)'
                   type: integer
                   default: '1'
               type: object