|
@@ -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();
|
|
|
}
|
|
|
|