diff --git a/service/app/admin/controller/SettingController.php b/service/app/admin/controller/SettingController.php index 23c77649..f21f256e 100644 --- a/service/app/admin/controller/SettingController.php +++ b/service/app/admin/controller/SettingController.php @@ -27,14 +27,13 @@ class SettingController extends base { * 合同配置保存 */ public function saveContractSetting(Request $request) { - if (empty($request->get('domestic'))) { - return $this->error('请上传境内合同'); + if (!empty($request->post('domestic'))) { + Redis::set(self::SETTING_DOMESTIC, $request->get('domestic')); } - if (empty($request->get('abroad'))) { - return $this->error('请上传境外合同'); + if (!empty($request->post('abroad'))) { + Redis::set(self::SETTING_ABROAD, $request->get('abroad')); } - Redis::set(self::SETTING_DOMESTIC, $request->get('domestic')); - Redis::set(self::SETTING_ABROAD, $request->get('abroad')); + return $this->success([]); } } \ No newline at end of file diff --git a/service/app/api/controller/OrderController.php b/service/app/api/controller/OrderController.php index 5ea0ee9a..10fe8c3c 100644 --- a/service/app/api/controller/OrderController.php +++ b/service/app/api/controller/OrderController.php @@ -3,6 +3,7 @@ namespace app\api\controller; use app\model\OrderBooks; use app\model\Orders; +use app\model\ProductSchedules; use Respect\Validation\Validator; use support\Request; @@ -88,14 +89,23 @@ class OrderController extends base $data['code_pic'] = json_encode($data['code_pic']); } // 检查排期 - // $res = DB::transaction(function ($data) { + $schedules = ProductSchedules::where(['date' => $data['travel_date'], 'third_product_id' => $order->product_id])->find(); + if (!empty($schedules) && $schedules->num > 0) { + // 已预约人数 + $booksNum = OrderBooks::join('orders', 'orders.id=order_books.order_id') + ->where(['order_books.travel_date' => $data['travel_date'], 'orders.product_id' => $order->product_id]) + ->sum('order_books.num'); + + if (($schedules->num-$booksNum) < $data['num']) { + return $this->error('当前日期预约已满,请选择其他日期'); + } + } + $res = OrderBooks::create($data); if (!empty($res)) { $order->is_apply_appointment = 1; $order->save(); } - // return $res; - // }); return $this->success($res); } catch (\Exception $exception) { return $this->error($exception->getMessage());