Pārlūkot izejas kodu

fix():修改配置

geek 4 gadi atpakaļ
vecāks
revīzija
338fd77890

+ 73 - 8
application/api/controller/Room.php

@@ -26,8 +26,8 @@ class Room extends BaseController {
      *   @OA\Parameter(name="page", in="query", description="页码", @OA\Schema(type="ineger",default="1")),
      *   @OA\Parameter(name="pageSize", in="query", description="页尺寸", @OA\Schema(type="integer",default="10")),
      *   @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="integer",default="1")),
-     *   @OA\Parameter(name="date", in="query", description="服务开始时间", @OA\Schema(type="string",default="2021-04-09")),
-     *   @OA\Parameter(name="status", in="query", description="1正常(待使用) 2使用中 3空闲 999禁用", @OA\Schema(type="integer",default="1")),
+     *   @OA\Parameter(name="status", in="query", description="1正常 2禁用", @OA\Schema(type="integer",default="1")),
+     *   @OA\Parameter(name="serverStatus", in="query", description="1待使用 2使用中 3空闲", @OA\Schema(type="integer",default="1")),
      *   @OA\Parameter(name="name", in="query", description="名字或code", @OA\Schema(type="string",default="666")),
      *   @OA\RequestBody(
      *     ),
@@ -45,12 +45,12 @@ class Room extends BaseController {
             $where[] = ['r.store_id', '=', (int)$input['storeId']];
         }
         if (!empty($input['status'])) {
-            if ($input['status'] != 999) {
-                $where[] = ['r.status', '=', 1];
-                $where[] = ['r.room_server_status', '=', (int)$input['status']];
-            }else{
-                $where[] = ['r.status', '=', 2];
-            }
+            $where[] = ['r.status', '=', (int)$input['status']];
+        }
+
+        if (!empty($input['serverStatus'])) {
+            $where[] = ['r.status', '=', 1];
+            $where[] = ['r.room_server_status', '=', (int)$input['status']];
         }
 
         if (!empty($input['name'])) {
@@ -62,12 +62,77 @@ class Room extends BaseController {
         }
 
         $model->setWhere($where);
+
         $data = $model->getRoomList();
         Until::output($data);
     }
 
 
     /**
+     * @OA\Get(path="/api/Room/statusRoom",
+     *   tags={"房间管理"},
+     *   summary="房间状态列表",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="integer",default="1")),
+     *   @OA\RequestBody(
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function statusRoom() {
+        $input = Until::getInput();
+        $model = new RoomModel();
+        $where = [];
+        if (!empty($input['storeId'])) {
+            $where[] = ['r.store_id', '=', (int)$input['storeId']];
+        }
+        $where[] = ['sr.admin_id', '=', $this->adminId];
+        $where[] = ['r.status', '=', 1];
+        $model->setWhere($where);
+        $rs = $model->getStatusRoomList();
+        if (empty($rs)) {
+            Until::output([]);
+        }
+        $list = [];
+        foreach ($rs as $v) {
+            $productInfo = json_decode($v['product_snap'], true);
+//            var_dump($productInfo);
+            if (empty($v['server_end_time']) && !empty($v['server_start_time'])) {
+                $endTime = strtotime($v['server_start_time']) + ($productInfo['time'] * 60);
+                $startTime = strtotime($v['server_start_time']);
+                $time = $endTime - time();
+                $productList[$v['room_id']][] = [
+                    'productName'         => $productInfo['product_name'],
+                    'productId'           => $productInfo['id'],// time 倒计时
+                    'time'                => $v['asStatus'] == 2 ? (int)($time/60) : 0,
+                    'startTime'           => date('H:i',$startTime),
+                    'endTime'             => date('H:i',$endTime),
+                    'staffName'           => $v['staff_name'],
+                    'orderId'             => $v['order_id'],
+                    'name'                => $v['name'],
+                    'realName'            => $v['real_name'],
+                    'orderType'           => $v['order_type'],
+                    'staffId'            => $v['staff_id'],
+                    'serverStatus' => $v['asStatus'],
+                ];
+            }
+
+            $list[$v['room_id']] = [
+                'roomName'            => $v['room_name'],
+                'roomServerStatus'    => $v['room_server_status'],
+                'roomId'              => $v['room_id']
+            ];
+        }
+
+        $list = array_values($list);
+        foreach ($list as &$v) {
+            $v['productList'] = $productList[$v['roomId']] ?? [];
+        }
+        Until::output($list);
+    }
+
+
+    /**
      * @OA\Post(path="/api/room/save",
      *   tags={"房间管理"},
      *   summary="保存房间信息",

+ 37 - 8
application/api/controller/Staff.php

@@ -13,6 +13,7 @@ use app\api\model\BrandModel;
 use app\api\model\GroupModel;
 use app\api\model\StaffModel;
 use app\common\until\Until;
+use think\Model;
 
 class Staff extends BaseController {
 
@@ -56,17 +57,17 @@ class Staff extends BaseController {
         }
 
         if (!empty($input['storeId'])) {
-            $arr =  explode(',',$input['storeId']);
+            $arr = explode(',', $input['storeId']);
             $where[] = ['s.store_id', 'in', $arr];
         }
 
         if (!empty($input['groupId'])) {
-            $arr =  explode(',',$input['groupId']);
+            $arr = explode(',', $input['groupId']);
             $where[] = ['sto.group_id', 'in', $arr];
         }
 
         if ($this->isAdmin()) {
-            $where[] = ['gr.admin_id','=',$this->adminId];
+            $where[] = ['gr.admin_id', '=', $this->adminId];
         }
         $model->setWhere($where);
         $data = $model->getStaffList();
@@ -88,6 +89,7 @@ class Staff extends BaseController {
      *           @OA\Property(description="职员手机号", property="mobile", type="string", default="12367897654"),
      *           @OA\Property(description="入职日期", property="joinTime", type="string", default="2020-01-04"),
      *           @OA\Property(description="职称id", property="staffTitleId", type="integer", default="1"),
+     *           @OA\Property(description="性别", property="sex", type="integer", default="1男 2女"),
      *           @OA\Property(description="storeId", property="storeId", type="integer", default="1"),
      *           required={"name","code","mobile","joinTime","staffTitleId","storeId"})
      *       )
@@ -103,12 +105,13 @@ class Staff extends BaseController {
             'mobile|职员手机号'      => 'require',
             'joinTime|入职日期'     => 'require',
             'staffTitleId|职称id' => 'require',
-            'storeId|storeId'      => 'require',
+            'storeId|storeId'   => 'require',
+            'sex|性别'            => 'require|in:1,2',
         ];
         Until::check($rule, $input);
         $model = new StaffModel();
         if (!empty($input['id'])) {
-            $rs = $model::where([['staff_code','=',$input['code']],['id','<>',$input['id']]])->find();
+            $rs = $model::where([['staff_code', '=', $input['code']], ['id', '<>', $input['id']]])->find();
             if (!empty($rs)) {
                 throw new ApiException('工号不可重复');
             }
@@ -120,10 +123,11 @@ class Staff extends BaseController {
                 'join_time'      => $input['joinTime'],
                 'staff_title_id' => $input['staffTitleId'],
                 'store_id'       => $input['storeId'],
+                'sex'            => $input['sex'],
                 'status'         => $input['status'] ?? $model::NORMAL
             ]);
         } else {
-            $rs = $model::where([['staff_code','=',$input['code']]])->find();
+            $rs = $model::where([['staff_code', '=', $input['code']]])->find();
             if (!empty($rs)) {
                 throw new ApiException('工号不可重复');
             }
@@ -133,7 +137,8 @@ class Staff extends BaseController {
                 'mobile'         => $input['mobile'],
                 'join_time'      => $input['joinTime'],
                 'staff_title_id' => $input['staffTitleId'],
-                'store_id'       => $input['storeId']
+                'store_id'       => $input['storeId'],
+                'sex'            => $input['sex'],
             ]);
         }
         $where[] = ['s.id', '=', (int)$id];
@@ -173,7 +178,31 @@ class Staff extends BaseController {
      *   @OA\Response(response="200", description="请求成功")
      * )
      */
-    public function delete($id,$status) {
+    public function delete($id, $status) {
+        $model = new StaffModel();
+        $where[] = ['id', '=', (int)$id];
+        $data = ['status' => (int)$status];
+        $isSuccess = $model::where($where)->update($data);
+        Until::output(['isSuccess' => $isSuccess]);
+    }
+
+    /**
+     * @OA\GET(path="/api/Staff/turnStaffList",
+     *   tags={"职员管理"},
+     *   summary="获取排班职员列表",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="ineger",default="1")),
+     *   @OA\RequestBody(
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function turnStaffList($id, $status) {
+        $input = Until::getInput();
+        $rule = [
+            'storeId|storeId'   => 'require',
+        ];
+        Until::check($rule, $input);
         $model = new StaffModel();
         $where[] = ['id', '=', (int)$id];
         $data = ['status' => (int)$status];

+ 21 - 0
application/api/model/RoomModel.php

@@ -40,4 +40,25 @@ class RoomModel  extends BaseModel {
             ->find();
         return Until::modelToArray($select);
     }
+
+
+    public function getStatusRoomList() {
+        $rs = $this->alias('r')
+            ->field('r.room_server_status,r.room_name,or.*,
+            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,o.staff_id')
+            ->join('order_room or','r.id = or.room_id')
+            ->join('store store','store.id = r.store_id')
+            ->join('store_role sr','sr.store_id = store.id')
+            ->join('order o','o.id = or.order_id')
+            ->join('allocate_staff as','as.order_id = o.id and as.status <> 3','left')
+            ->join('staff s','s.id = o.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);
+    }
+
+
 }

+ 25 - 0
application/cron/Staff.php

@@ -0,0 +1,25 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/5/7 23:14
+ */
+
+namespace app\cron;
+
+
+use app\api\model\StoreModel;
+use think\db\Where;
+
+class Staff {
+
+    // php /public/index.php /cron/Staff/turnStaff
+    public function turnStaff() {
+        $yDate = date('Y-m-d H:i:s', strtotime('-1 day'));
+
+//        $storeModel = new StoreModel();
+//        $storeModel->alias('s')
+//            ->join('staff sta','sta.store_id = s.id')
+//            ->join('allocate_staff astf','astf.staff_id = sta.id')
+//            ->where([['server_start_time','','']])
+    }
+}

+ 58 - 6
public/api.yaml

@@ -1752,16 +1752,16 @@ paths:
             type: integer
             default: '1'
         -
-          name: date
+          name: status
           in: query
-          description: 服务开始时间
+          description: '1正常 2禁用'
           schema:
-            type: string
-            default: '2021-04-09'
+            type: integer
+            default: '1'
         -
-          name: status
+          name: serverStatus
           in: query
-          description: '1正常(待使用) 2使用中 3禁用 4空闲'
+          description: '1待使用 2使用中 3空闲'
           schema:
             type: integer
             default: '1'
@@ -1776,6 +1776,30 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Room/statusRoom:
+    get:
+      tags:
+        - 房间管理
+      summary: 房间状态列表
+      operationId: 'app\api\controller\Room::statusRoom'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: storeId
+          in: query
+          description: 门店id
+          schema:
+            type: integer
+            default: '1'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
   /api/room/save:
     post:
       tags:
@@ -2065,6 +2089,10 @@ paths:
                   description: 职称id
                   type: integer
                   default: '1'
+                sex:
+                  description: 性别
+                  type: integer
+                  default: '1男 2女'
                 storeId:
                   description: storeId
                   type: integer
@@ -2128,6 +2156,30 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Staff/turnStaffList:
+    get:
+      tags:
+        - 职员管理
+      summary: 获取排班职员列表
+      operationId: 'app\api\controller\Staff::turnStaffList'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: storeId
+          in: query
+          description: 门店id
+          schema:
+            type: ineger
+            default: '1'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
   /api/Store/index:
     get:
       tags: