小程序

This commit is contained in:
jianghanbo 2024-10-22 09:09:13 +08:00
parent 4930717e25
commit e50987ce21
2 changed files with 18 additions and 9 deletions

View File

@ -27,14 +27,13 @@ class SettingController extends base {
* 合同配置保存 * 合同配置保存
*/ */
public function saveContractSetting(Request $request) { public function saveContractSetting(Request $request) {
if (empty($request->get('domestic'))) { if (!empty($request->post('domestic'))) {
return $this->error('请上传境内合同');
}
if (empty($request->get('abroad'))) {
return $this->error('请上传境外合同');
}
Redis::set(self::SETTING_DOMESTIC, $request->get('domestic')); Redis::set(self::SETTING_DOMESTIC, $request->get('domestic'));
}
if (!empty($request->post('abroad'))) {
Redis::set(self::SETTING_ABROAD, $request->get('abroad')); Redis::set(self::SETTING_ABROAD, $request->get('abroad'));
}
return $this->success([]); return $this->success([]);
} }
} }

View File

@ -3,6 +3,7 @@ namespace app\api\controller;
use app\model\OrderBooks; use app\model\OrderBooks;
use app\model\Orders; use app\model\Orders;
use app\model\ProductSchedules;
use Respect\Validation\Validator; use Respect\Validation\Validator;
use support\Request; use support\Request;
@ -88,14 +89,23 @@ class OrderController extends base
$data['code_pic'] = json_encode($data['code_pic']); $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); $res = OrderBooks::create($data);
if (!empty($res)) { if (!empty($res)) {
$order->is_apply_appointment = 1; $order->is_apply_appointment = 1;
$order->save(); $order->save();
} }
// return $res;
// });
return $this->success($res); return $this->success($res);
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $this->error($exception->getMessage()); return $this->error($exception->getMessage());