Forráskód Böngészése

fix():修改配置

geek 4 éve
szülő
commit
73ef7e1c1e

+ 13 - 9
application/api/controller/Order.php

@@ -129,17 +129,21 @@ class Order extends BaseController {
             $product[$v['order_id']][] = $v;
         }
 
-        $statusFilter = [1 => '未支付', 2 => '已支付', 3 => '已关闭', 4 => '已删除'];
+        $statusFilter = [1 => '未支付', 2 => '已支付', 3 => '已关闭', 4 => '已删除', 5 => '已完成'];
 
         foreach ($data['list'] as &$one) {
-            if ($one['allocateStatus'] == 1) {
-                $one['allocateOrderStatus'] = 2; //分配职员完成 可开始服务
-            } elseif ($one['allocateStatus'] == 2) {
-                $one['allocateOrderStatus'] = 3; //服务中 可结束服务
-            } elseif ($one['allocateStatus'] == 3) {
-                $one['allocateOrderStatus'] = 3; //服务结束
-            } else {
-                $one['allocateOrderStatus'] = 1; //还没分配职员 可分配职员 不可开始服务
+            if($one['status'] == 2) {
+                if ($one['allocateStatus'] == 1 && ($one['write_off_status'] == 2 || $one['order_type'] == 2) && !empty($one['roomId'])) {
+                    $one['allocateOrderStatus'] = 2; // 可开始服务
+                } elseif ($one['allocateStatus'] == 2) {
+                    $one['allocateOrderStatus'] = 3; //服务中 可结束服务
+                }
+            }else {
+                $one['allocateOrderStatus'] = 1; //未支付
+            }
+
+            if ($one['allocateStatus'] == 3) {
+               $one['allocateOrderStatus'] = 4; //服务结束
             }
 
             $one['productList'] = $product[$one['id']] ?? [];

+ 202 - 0
application/api/controller/Room.php

@@ -0,0 +1,202 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2020/12/16 23:06
+ */
+
+namespace app\api\controller;
+
+
+use app\api\BaseController;
+use app\api\exception\ApiException;
+use app\api\model\DiscussModel;
+use app\api\model\GroupModel;
+use app\api\model\OrderRoomModel;
+use app\api\model\RoomModel;
+use app\common\until\Until;
+use think\Model;
+
+class Room extends BaseController {
+
+    /**
+     * @OA\Get(path="/api/Room/index",
+     *   tags={"房间管理"},
+     *   summary="房间列表",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @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="status", in="query", description="1正常 2禁用", @OA\Schema(type="integer",default="1")),
+     *   @OA\Parameter(name="name", in="query", description="名字或code", @OA\Schema(type="integer",default="666")),
+     *   @OA\RequestBody(
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function index() {
+        $input = Until::getInput();
+        $model = new RoomModel();
+        $model->setPage($input['page'] ?? 1);
+        $model->setPageSize($input['pageSize'] ?? 10);
+        $where = [];
+
+        if (!empty($input['storeId'])) {
+            $where[] = ['r.store_id', '=', (int)$input['storeId']];
+        }
+        if (!empty($input['status'])) {
+            $where[] = ['r.status', '=', (int)$input['status']];
+        }
+        if (!empty($input['name'])) {
+            $where[] = ['r.room_name|r.room_code', 'like', "%{$input['name']}%"];
+        }
+
+        if ($this->isAdmin()) {
+            $where[] = ['sr.admin_id', '=', $this->adminId];
+        }
+
+        $model->setWhere($where);
+        $data = $model->getRoomList();
+        Until::output($data);
+    }
+
+
+    /**
+     * @OA\Post(path="/api/room/save",
+     *   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="房间名称", property="roomName", type="integer", default="1"),
+     *           @OA\Property(description="房间代号", property="roomCode", type="integer", default="1"),
+     *           @OA\Property(description="门店id", property="storeId", type="integer", default="1"),
+     *           @OA\Property(description="状态", property="status", type="integer", default="1"),
+     *           @OA\Property(description="房间id", property="id", type="integer", default="1"),
+     *           required={"roomName","roomCode","storeId","status"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function save() {
+        $input = Until::getInput();
+        $rule = [
+            'roomName|房间名称' => 'require',
+            'roomCode|房间代号' => 'require',
+            'storeId|门店id'  => 'require',
+            'status|状态'     => 'require',
+//            'id|房间id'     => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new RoomModel();
+        if (!empty($input['id'])) {
+            $id = (int)$input['id'];
+            $rs = $model::where([['store_id', '=', $input['storeId']], ['room_name', '=', $input['roomName']], ['id', '<>', $id]])->find();
+            if ($rs !== null) {
+                throw new ApiException('名称不能重复');
+            }
+            $rs = $model::where([['store_id', '=', $input['storeId']], ['room_code', '=', $input['roomCode']], ['id', '<>', $id]])->find();
+            if ($rs !== null) {
+                throw new ApiException('code不能重复');
+            }
+            $model::where(['id' => $id])->update([
+                'room_name' => $input['roomName'],
+                'store_id'  => $input['storeId'],
+                'room_code' => $input['roomCode'],
+                'status'    => $input['status'] ?? 1,
+
+            ]);
+        } else {
+            $rs = $model::where([['store_id', '=', $input['storeId']], ['room_name', '=', $input['roomName']]])->find();
+            if ($rs !== null) {
+                throw new ApiException('名称不能重复');
+            }
+            $rs = $model::where([['store_id', '=', $input['storeId']], ['room_code', '=', $input['roomCode']]])->find();
+            if ($rs !== null) {
+                throw new ApiException('code不能重复');
+            }
+            $id = $model->insertGetId([
+                'room_name' => $input['roomName'],
+                'store_id'  => $input['storeId'],
+                'room_code' => $input['roomCode'],
+                'status'    => $input['status'] ?? 1,
+            ]);
+        }
+        $where[] = ['r.id', '=', (int)$id];
+        $model->setWhere($where);
+        $info = $model->getRoomInfo();
+        Until::output(['info' => $info]);
+    }
+
+    /**
+     * @OA\Post(path="/api/room/updateStatus",
+     *   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="id", type="integer", default="1"),
+     *           @OA\Property(description="状态", property="status", type="integer", default="1"),
+     *           required={"id","status"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function updateStatus() {
+        $input = Until::getInput();
+        $rule = [
+            'id|房间id'   => 'require',
+            'status|状态' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new RoomModel();
+        $model::where(['id' => $input['id']])->update(['status' => $input['status']]);
+        Until::output();
+    }
+
+
+    /**
+     * @OA\Post(path="/api/room/allocateRoom",
+     *   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="id", type="integer", default="1"),
+     *           @OA\Property(description="订单id", property="orderId", type="integer", default="1"),
+     *           required={"id","orderId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function allocateRoom() {
+        $input = Until::getInput();
+        $rule = [
+            'id|房间id'   => 'require',
+            'orderId|订单id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $data = [
+            'order_id' => $input['orderId'],
+            'room_id'  => $input['id']
+        ];
+        $model = new OrderRoomModel();
+        $rs = $model::where($data)->find();
+        if (empty($rs)) {
+            $model->insert($data);
+        }else {
+            $model::where(['order_id' => $input['orderId']])->update(['room_id' => $input['id']]);
+        }
+        Until::output();
+    }
+
+
+}

+ 2 - 1
application/api/model/OrderModel.php

@@ -39,7 +39,7 @@ class OrderModel  extends BaseModel {
             p.product_name,p.product_img,p.type as productType,
             u.name as userName,ad.name as writeOffName,u.real_name as realName,
             ad2.name as payAdminName,ad3.name as allocateAdminName,ad4.name as orderAdminName,
-            as.status as allocateStatus')
+            as.status as allocateStatus,or.id as roomId')
             ->join('store store', 'store.id = o.store_id','left')
             ->join('staff staff', 'staff.id = o.staff_id','left')
             ->join('product p', 'p.id = o.product_id','left')
@@ -52,6 +52,7 @@ class OrderModel  extends BaseModel {
             ->join('allocate_staff as','as.order_id = o.id','left')
             ->join('admin ad3','ad3.id = as.admin_id','left')
             ->join('admin ad4','ad4.id = o.admin_id','left')
+            ->join('order_room or','or.order_id = o.id','left')
             ->order('o.id desc');
         return $this->joinModelPageList($countModel, $selectModel);
 

+ 14 - 0
application/api/model/OrderRoomModel.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/4/26 14:45
+ */
+
+namespace app\api\model;
+
+
+class OrderRoomModel extends BaseModel {
+
+    protected $table = 'order_room';
+
+}

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

@@ -0,0 +1,43 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2020/12/5 19:52
+ */
+
+namespace app\api\model;
+
+use app\common\until\Until;
+use think\Db;
+
+class RoomModel  extends BaseModel {
+
+    protected $table = 'room';
+
+    public function getRoomList() {
+        $adminStore = 'left';
+        if (!empty(Until::$adminId)) {
+            $adminStore = 'INNER';
+        }
+
+        $count = $this->alias('r')
+            ->join('store store', 'store.id = r.store_id')
+            ->join('store_role sr','sr.store_id = store.id',$adminStore);
+
+
+        $select = $this->alias('r')
+            ->field('r.*,store.store_name')
+            ->join('store store','store.id = r.store_id')
+            ->join('store_role sr','sr.store_id = store.id',$adminStore)
+            ->order('r.id desc');
+        return $this->joinModelPageList($count, $select);
+    }
+
+    public function getRoomInfo() {
+        $select = $this->alias('r')
+            ->field('r.*,store.store_name')
+            ->join('store store','store.id = r.store_id')
+            ->where($this->getWhere())
+            ->find();
+        return Until::modelToArray($select);
+    }
+}

+ 165 - 0
public/api.yaml

@@ -1717,6 +1717,171 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Room/index:
+    get:
+      tags:
+        - 房间管理
+      summary: 房间列表
+      operationId: 'app\api\controller\Room::index'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: page
+          in: query
+          description: 页码
+          schema:
+            type: ineger
+            default: '1'
+        -
+          name: pageSize
+          in: query
+          description: 页尺寸
+          schema:
+            type: integer
+            default: '10'
+        -
+          name: storeId
+          in: query
+          description: 门店id
+          schema:
+            type: integer
+            default: '1'
+        -
+          name: status
+          in: query
+          description: '1正常 2禁用'
+          schema:
+            type: integer
+            default: '1'
+        -
+          name: name
+          in: query
+          description: 名字或code
+          schema:
+            type: integer
+            default: '666'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
+  /api/room/save:
+    post:
+      tags:
+        - 房间管理
+      summary: 保存房间信息
+      operationId: 'app\api\controller\Room::save'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - roomName
+                - roomCode
+                - storeId
+                - status
+              properties:
+                roomName:
+                  description: 房间名称
+                  type: integer
+                  default: '1'
+                roomCode:
+                  description: 房间代号
+                  type: integer
+                  default: '1'
+                storeId:
+                  description: 门店id
+                  type: integer
+                  default: '1'
+                status:
+                  description: 状态
+                  type: integer
+                  default: '1'
+                id:
+                  description: 房间id
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/room/updateStatus:
+    post:
+      tags:
+        - 房间管理
+      summary: 保存房间信息
+      operationId: 'app\api\controller\Room::updateStatus'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - id
+                - status
+              properties:
+                id:
+                  description: 房间id
+                  type: integer
+                  default: '1'
+                status:
+                  description: 状态
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/room/allocateRoom:
+    post:
+      tags:
+        - 房间管理
+      summary: 分配房间
+      operationId: 'app\api\controller\Room::allocateRoom'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - id
+                - orderId
+              properties:
+                id:
+                  description: 房间id
+                  type: integer
+                  default: '1'
+                orderId:
+                  description: 订单id
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
   /api/Staff/index:
     get:
       tags: