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

fix:添加充值功能

geek 4 éve
szülő
commit
27c4e6c2fd

+ 37 - 33
application/api/controller/Order.php

@@ -25,6 +25,7 @@ use app\api\model\TurnStaffModel;
 use app\api\model\UserModel;
 use app\api\model\WriteOffModel;
 use app\common\service\OrderService;
+use app\common\service\ServerService;
 use app\common\until\Until;
 use think\App;
 use think\Db;
@@ -415,41 +416,44 @@ class Order extends BaseController {
             'orderId|订单id' => 'require',
         ];
         Until::check($rule, $input);
+        $ser = new ServerService();
+        $ser->startService($input['orderId']);
+        Until::output();
+    }
+
+    /**
+     * @OA\Post(path="/api/Order/clockStart",
+     *   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="clockCode", type="string", default="1"),
+     *           @OA\Property(description="工牌卡号", property="braceletCode", type="string", default="1"),
+     *           required={"clockCode","braceletCode"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function clockStart() {
+        $input = Until::getInput();
+        $rule = [
+            'clockCode|上钟器卡号' => 'require',
+            'braceletCode|手环卡号' => 'require',
+        ];
+        Until::check($rule, $input);
+        $staffInfo = ServerService::getStaffByCode($input['braceletCode']);
+        $roomInfo = ServerService::getRoomByCode($input['clockCode']);
         $allocateModel = new AllocateModel();
-        $model = new OrderModel();
-        $roomOrder = new OrderRoomModel();
-        $order = $model::where(['id' => $input['orderId']])->find();
-        if (empty($order)) {
-            throw new ApiException('无此订单');
-        }
-        if ($order['status'] != 2) {
-            throw new ApiException('订单必须是支付状态');
-        }
-        $rs = $allocateModel::where(['order_id' => (int)$input['orderId']])->find();
-        if (empty($rs)) {
-            throw new ApiException('该服务还没分配职员');
-        } else {
-            if ($rs['status'] == 3) {
-                throw new ApiException('该服务已完成');
-            }
-            if ($rs['status'] == 2) {
-                throw new ApiException('该服务正在进行');
-            }
-        }
-        $orderRoomRs = $roomOrder::where(['order_id' => $input['orderId']])->find();
-        if ($orderRoomRs === null) {
-            throw new ApiException('请分配房间');
-        }
-        if (!empty($this->adminId)) {
-            $opId = $this->adminId;
-            $opType = 'admin';
-        } else {
-            $opId = $this->userId;
-            $opType = 'xcx';
+        $info = $allocateModel::where(['staff_id' => $staffInfo['id'], 'store_id' => $roomInfo['store_id']])->order('id', 'desc')->find();
+        if (empty($info) || empty($info['order_id'])) {
+            throw new ApiException('无此服务');
         }
-        (new RoomModel())::where(['id' => $orderRoomRs['room_id']])->update(['room_server_status' => 2]);
-        $allocateModel::where(['id' => $rs['id']])->update(['status' => 2, 'start_id' => $opId, 'op_type' => $opType, 'server_start_time' => date('Y-m-d H:i:s')]);
-        (new StaffModel())::where(['id' => $rs['staff_id']])->update(['server_status' => 3]);
+        $ser = new ServerService();
+        $ser->startService($info['order_id']);
         Until::output();
     }
 

+ 6 - 5
application/api/controller/Server.php

@@ -9,6 +9,7 @@ namespace app\api\controller;
 
 use app\api\BaseController;
 use app\api\model\CallServiceModel;
+use app\common\service\ServerService;
 use app\common\until\Until;
 
 class Server extends BaseController {
@@ -22,22 +23,22 @@ class Server extends BaseController {
      *       mediaType="multipart/form-data",
      *         @OA\Schema(
      *           @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
-     *           @OA\Property(description="房间号", property="roomId", type="integer"),
-     *           @OA\Property(description="门店id", property="storeId", type="integer"),
-     *           required={"type","roomId","storeId"})
+     *           @OA\Property(description="钟code", property="blockCode", type="string"),
+     *           required={"type","blockCode"})
      *       )
      *     ),
      *   @OA\Response(response="200", description="请求成功")
      * )
      */
     public function callService() {
+        var_dump(1);
         $input = Until::getInput();
         $rule = [
             'type|服务类型' => 'require',
-            'roomId|房间号' => 'require',
-            'storeId|门店id' => 'require',
+            'blockCode|钟code' => 'require',
         ];
         Until::check($rule, $input);
+        ServerService::getRoomByCode($input['blockCode']);
         $model = new CallServiceModel();
         $callInfo = $model::where([
             'store_id'     => $input['storeId'],

+ 3 - 0
application/api/model/StaffModel.php

@@ -10,6 +10,9 @@ use app\common\until\Until;
 
 class StaffModel  extends BaseModel {
 
+
+    const NORMAL = 1;
+
     protected $table = 'staff';
 
     public function getStaffList() {

+ 79 - 0
application/common/service/ServerService.php

@@ -0,0 +1,79 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/23 15:11
+ */
+
+namespace app\common\service;
+
+
+use app\api\exception\ApiException;
+use app\api\model\AllocateModel;
+use app\api\model\OrderModel;
+use app\api\model\OrderRoomModel;
+use app\api\model\RoomModel;
+use app\api\model\StaffModel;
+use app\common\until\Until;
+use think\Model;
+
+class ServerService {
+
+    public function startService(int $orderId) {
+        $allocateModel = new AllocateModel();
+        $model = new OrderModel();
+        $roomOrder = new OrderRoomModel();
+        $order = $model::where(['id' =>$orderId])->find();
+        if (empty($order)) {
+            throw new ApiException('无此订单');
+        }
+        if ($order['status'] != 2) {
+            throw new ApiException('订单必须是支付状态');
+        }
+        $rs = $allocateModel::where(['order_id' => $orderId])->find();
+        if (empty($rs)) {
+            throw new ApiException('该服务还没分配职员');
+        } else {
+            if ($rs['status'] == 3) {
+                throw new ApiException('该服务已完成');
+            }
+            if ($rs['status'] == 2) {
+                throw new ApiException('该服务正在进行');
+            }
+        }
+        $orderRoomRs = $roomOrder::where(['order_id' =>$orderId])->find();
+        if ($orderRoomRs === null) {
+            throw new ApiException('请分配房间');
+        }
+        if (!empty($this->adminId)) {
+            $opId = $this->adminId;
+            $opType = 'admin';
+        } else {
+            $opId = Until::$userId;
+            $opType = 'xcx';
+        }
+        (new RoomModel())::where(['id' => $orderRoomRs['room_id']])->update(['room_server_status' => 2]);
+        $allocateModel::where(['id' => $rs['id']])->update(['status' => 2, 'start_id' => $opId, 'op_type' => $opType, 'server_start_time' => date('Y-m-d H:i:s')]);
+        (new StaffModel())::where(['id' => $rs['staff_id']])->update(['server_status' => 3]);
+    }
+
+    public static function getStaffByCode(string $braceletCode) {
+        $staffModel = new Staffmodel();
+        $staffInfo = $staffModel::where(['bracelet_code' => $braceletCode,'status' => Staffmodel::NORMAL])->find();
+        $staffInfo = Until::modelToArray($staffInfo);
+        if (empty($staffInfo)) {
+            throw new apiexception('无此职员');
+        }
+        return $staffInfo;
+    }
+
+    public static function getRoomByCode(string $roomCode) {
+        $model = new RoomModel();
+        $roomInfo = $model::where(['clock_code' => $roomCode,'status' => StaffModel::NORMAL])->find();
+        $roomInfo = Until::modelToArray($roomInfo);
+        if  (empty($roomInfo) || empty($roomInfo['store_id'])) {
+            throw new ApiException('无此门店');
+        }
+        return $roomInfo;
+    }
+
+}

+ 84 - 0
public/api.yaml

@@ -1022,6 +1022,39 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Order/clockStart:
+    post:
+      tags:
+        - 订单管理
+      summary: 上钟
+      operationId: 'app\api\controller\Order::clockStart'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - clockCode
+                - braceletCode
+              properties:
+                clockCode:
+                  description: 上钟器卡号(房间卡号)
+                  type: string
+                  default: '1'
+                braceletCode:
+                  description: 工牌卡号
+                  type: string
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
   /api/Order/serverComplete:
     post:
       tags:
@@ -1272,6 +1305,50 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Order/editOrder:
+    post:
+      tags:
+        - 订单管理
+      summary: 修改订单信息
+      operationId: 'app\api\controller\Order::editOrder'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - orderId
+              properties:
+                orderId:
+                  description: 订单id
+                  type: integer
+                  default: '1'
+                orderMoney:
+                  description: 订单金额
+                  type: string
+                  default: '13.26'
+                staffId:
+                  description: 技师
+                  type: string
+                  default: '13.26'
+                oldProductId:
+                  description: 旧服务项目id
+                  type: string
+                  default: '13.26'
+                newProductId:
+                  description: 新服务项目id
+                  type: string
+                  default: '13.26'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
   /api/Pay/index:
     get:
       tags:
@@ -1691,6 +1768,13 @@ paths:
           schema:
             type: ineger
             default: '1'
+        -
+          name: storeId
+          in: query
+          description: 门店id
+          schema:
+            type: ineger
+            default: '1'
       requestBody: {  }
       responses:
         '200':