ソースを参照

fix():修改配置

geek 4 年 前
コミット
e70917aa0b
共有4 個のファイルを変更した104 個の追加5 個の削除を含む
  1. 98 2
      application/api/controller/Order.php
  2. 2 2
      application/api/controller/Product.php
  3. 2 1
      application/api/model/OrderModel.php
  4. 2 0
      application/common/service/OrderService.php

+ 98 - 2
application/api/controller/Order.php

@@ -133,6 +133,20 @@ class Order extends BaseController {
 
         foreach ($data['list'] as &$one) {
 
+
+            if ($one['status'] == 2) {
+                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; //还没分配职员 可分配职员 不可开始服务
+                }
+
+            }
+
             $one['productList'] = $product[$one['id']] ?? [];
             $one['statusText'] = $statusFilter[$one['status']];
             if ($one['status'] === OrderModel::IS_PAY) {
@@ -252,7 +266,8 @@ class Order extends BaseController {
             'storeId|门店id'         => 'require',
             'appointmentTime|预约时间' => 'require',
             'num|数量'               => 'require',
-            'mobile|手机号'           => 'require'
+            'mobile|手机号'           => 'require',
+            'staffId|技师'           => 'require'
         ];
         Until::check($rule, $input);
         if (empty($input['endTime'])) {
@@ -341,7 +356,6 @@ class Order extends BaseController {
         ];
         Until::check($rule, $input);
         $model = new OrderModel();
-        $model::where(['id' => (int)$input['orderId']])->update(['staff_id' => (int)$input['staffId']]);
         $allocateModel = new AllocateModel();
         $rs = $allocateModel::where(['order_id' => (int)$input['orderId'], 'staff_id' => $input['staffId']])->find();
         if (empty($rs)) {
@@ -351,8 +365,90 @@ class Order extends BaseController {
                 'admin_id' => $this->adminId
             ]);
         } else {
+            if ($rs['status'] == 2) {
+                throw new ApiException('服务已开始,无法分配职员');
+            }elseif ($rs['status'] == 3) {
+                throw new ApiException('服务已结束,无法分配职员');
+            }
             $allocateModel::where(['id' => $rs['id']])->update(['staff_id' => $input['staffId']]);
         }
+        $model::where(['id' => (int)$input['orderId']])->update(['staff_id' => (int)$input['staffId']]);
+        Until::output();
+    }
+
+
+    /**
+     * @OA\Post(path="/api/Order/serverStart",
+     *   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="orderId", type="integer", default="1"),
+     *           required={"orderId","staffId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function serverStart() {
+        $input = Until::getInput();
+        $rule = [
+            'orderId|订单id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $allocateModel = new AllocateModel();
+        $rs = $allocateModel::where(['order_id' => (int)$input['orderId'], 'staff_id' => $input['staffId'],'status' => 2])->find();
+        if (empty($rs)) {
+            throw new ApiException('该服务还没分配职员');
+        } else {
+            if ($rs['status'] == 3) {
+                throw new ApiException('该服务已完成');
+            }
+            if ($rs['status'] == 2) {
+                throw new ApiException('该服务正在进行');
+            }
+        }
+        $allocateModel::where(['id' => $rs['id']])->update(['status' => 2]);
+        Until::output();
+    }
+
+    /**
+     * @OA\Post(path="/api/Order/serverComplete",
+     *   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="orderId", type="integer", default="1"),
+     *           required={"orderId","staffId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function serverComplete() {
+        $input = Until::getInput();
+        $rule = [
+            'orderId|订单id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new OrderModel();
+        $allocateModel = new AllocateModel();
+        $rs = $allocateModel::where(['order_id' => (int)$input['orderId'], 'staff_id' => $input['staffId'],'status' => 2])->find();
+        if (empty($rs)) {
+            throw new ApiException('该服务还没分配职员');
+        } else {
+            if ($rs['status'] == 3) {
+                throw new ApiException('该服务已完成');
+            }
+        }
+        $allocateModel::where(['id' => $rs['id']])->update(['status' => 3]);
+        $model::where(['id' => $input['orderId']])->update(['status' => 5]);
         Until::output();
     }
 

+ 2 - 2
application/api/controller/Product.php

@@ -90,7 +90,7 @@ class Product 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="type", in="query", description="1为洗浴 2为小食 3全部", @OA\Schema(type="integer",default="1")),
-     *   @OA\Property(description="0 异常 1正常", property="status", type="integer", default="1"),
+     *   @OA\Property(description="1 异常 2正常", property="status", type="integer", default="1"),
      *   @OA\RequestBody(
      *     ),
      *   @OA\Response(response="200", description="请求成功")
@@ -106,7 +106,7 @@ class Product extends BaseController {
             $where[] = ['status','=', 1];
         }else {
             if (!empty($input['status'])) {
-                $where[] = ['status', '=', $input['status']];
+                $where[] = ['status', '=', (int)$input['status'] - 1];
             }
         }
         if (!empty($input['type']) && $input['type'] == 2) {

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

@@ -38,7 +38,8 @@ class OrderModel  extends BaseModel {
             wo.write_off_status,wo.write_off_time,wo.admin_id as writeOffAdminId,wo.over_time as  writeOffOverTime,
             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')
+            ad2.name as payAdminName,ad3.name as allocateAdminName,ad4.name as orderAdminName,
+            as.status as allocateStatus')
             ->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')

+ 2 - 0
application/common/service/OrderService.php

@@ -9,6 +9,7 @@ namespace app\common\service;
 
 use app\api\controller\Order;
 use app\api\exception\ApiException;
+use app\api\model\AllocateModel;
 use app\api\model\CartModel;
 use app\api\model\OrderModel;
 use app\api\model\OrderProductModel;
@@ -65,6 +66,7 @@ class OrderService {
                 'user_id'          => $userId,
                 'admin_id'         => Until::$adminId
             ]);
+            (new AllocateModel())->insertGetId(['order_id' => $orderId, 'staff_id' => $input['staffId'],'admin_id' => Until::$adminId]);
             $opModel = new OrderProductModel();
             $opModel->insert([
                 'order_id'        => $orderId,