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