添加续住操作
parent
b1ddba164c
commit
828da9b5ac
|
|
@ -62,7 +62,6 @@ class LiveContinueController extends AdminController
|
|||
$feeKeys['add_extends'] = '${add_extends}';
|
||||
$feeKeys['del_extends'] = '${del_extends}';
|
||||
$feeKeys['continue_fee'] = '${continue_fee}';
|
||||
$feeKeys['bonds_fee'] = '${bonds_fee}';
|
||||
|
||||
$page = $this->basePage()->body([
|
||||
amisMake()->Card()->className('border-0')->body(
|
||||
|
|
@ -137,7 +136,7 @@ class LiveContinueController extends AdminController
|
|||
|
||||
amisMake()->GroupControl()->body([
|
||||
amisMake()->TextControl('start_at', '开始时间')->disabled(true),
|
||||
amisMake()->DateControl('end_at', '截至时间')->format('YYYY-MM-DD')->required(true),
|
||||
amisMake()->DateControl('end_at', '截至时间')->minDate('${start_at}')->value('${start_at}')->format('YYYY-MM-DD')->required(true),
|
||||
]),
|
||||
]),
|
||||
|
||||
|
|
@ -219,4 +218,23 @@ class LiveContinueController extends AdminController
|
|||
|
||||
return $this->response()->success($page);
|
||||
}
|
||||
|
||||
public function do(Request $request){
|
||||
$oldManId = $request->input('oldman_id');
|
||||
|
||||
$startDay = $request->input('start_at', null);
|
||||
$endDay = $request->input('end_at', null);
|
||||
|
||||
$liveFee = $request->input('continue_fee', []);
|
||||
$addFee = $request->input('add_extends', []);
|
||||
$delFee = $request->input('del_extends', []);
|
||||
|
||||
$res = $this->service->do($oldManId, $startDay, $endDay, [
|
||||
'live_fee' => $liveFee,
|
||||
'add_fee' => $addFee,
|
||||
'del_fee' => $delFee,
|
||||
], $request->input('change_lv', 0), $request->input('nurse_lv', 0));
|
||||
|
||||
return $this->autoResponse($res, '续住');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,8 +214,8 @@ class OldmenController extends AdminController
|
|||
$type = $request->input('type', 'live_fee');
|
||||
$dateRange = $request->input('live_in_date', null);
|
||||
//处理续住时间传递
|
||||
$startDay = $dateRange ? explode(',', $dateRange)[0].' 00:00:00' : null;
|
||||
$endDay = $dateRange ? explode(',', $dateRange)[1].' 23:59:59' : null;
|
||||
$startDay = $dateRange ? explode(',', $dateRange)[0].' 00:00:00' : $request->input('start_at', null);
|
||||
$endDay = $dateRange ? explode(',', $dateRange)[1].' 23:59:59' : $request->input('end_at', null);
|
||||
|
||||
if($startDay && $endDay){
|
||||
$diffYears = Carbon::parse($startDay)->diffInYears($endDay);
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@ Route::group([
|
|||
//字典表
|
||||
$router->resource('keywords', \App\Admin\Controllers\KeywordController::class);
|
||||
|
||||
//客人管理
|
||||
$router->resource('oldmen', \App\Admin\Controllers\OldmenController::class)->names('oldmen');
|
||||
|
||||
$router->get('feelist', '\App\Admin\Controllers\OldmenController@feelist');
|
||||
$router->get('live-fee-form', '\App\Admin\Controllers\OldmenController@liveSchemaForm');
|
||||
//客人-入住
|
||||
$router->get('live-in', '\App\Admin\Controllers\LiveInController@index');
|
||||
$router->get('live-in-do', '\App\Admin\Controllers\LiveInController@doForm');
|
||||
$router->post('live-in-do', '\App\Admin\Controllers\LiveInController@do');
|
||||
$router->get('feelist', '\App\Admin\Controllers\OldmenController@feelist');
|
||||
|
||||
$router->get('live-fee-form', '\App\Admin\Controllers\OldmenController@liveSchemaForm');
|
||||
|
||||
//客人-续住
|
||||
$router->get('live-continue', '\App\Admin\Controllers\LiveContinueController@index');
|
||||
$router->get('live-continue-do', '\App\Admin\Controllers\LiveContinueController@doForm');
|
||||
$router->post('live-continue-do', '\App\Admin\Controllers\LiveContinueController@do');
|
||||
|
||||
//费用设置
|
||||
$router->get('const-setting', '\App\Admin\Controllers\SettingController@settingFeeConfig');
|
||||
$router->post('const-setting', '\App\Admin\Controllers\SettingController@settingFeeConfigStore');
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\Oldmen;
|
||||
use App\Models\ConstFlow;
|
||||
use DB;
|
||||
use Throwable;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* @method Oldmen getModel()
|
||||
|
|
@ -25,4 +29,58 @@ class LiveContinueService extends OldmenService
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function do($oldManId, $startAt, $endAt, $feeArr = null, $changeLv = 0, $lv = 0){
|
||||
|
||||
$oldMan = $this->getDetail($oldManId);
|
||||
if($oldMan){
|
||||
//判断状态-是否是已经入住状态;未入住状态无法续住;
|
||||
if($oldMan->live_in != Oldmen::STATUS_LIVE){
|
||||
return $this->setError('客人状态异常,请刷新后重试!');
|
||||
}
|
||||
|
||||
//判断开始时间和用户截至时间是否相隔1秒;-todo
|
||||
if(Carbon::parse($oldMan->avliable_at)->diffInSeconds($startAt) != 1){
|
||||
return $this->setError('续住开始时间异常,请刷新重试!');
|
||||
}
|
||||
|
||||
$flow = new ConstFlow();
|
||||
$flow->oldman_id = $oldMan->id;
|
||||
$flow->const_type = ConstFlow::TYPE_CONTINUE;
|
||||
$flow->start_at = $startAt;
|
||||
$flow->end_at = $endAt;
|
||||
$flow->money = $this->totalFee($feeArr);
|
||||
$flow->extends = $feeArr;
|
||||
|
||||
//记录变更护理等级情况;
|
||||
if($changeLv && $lv != $oldMan->nurse_lv){
|
||||
$newLv = $lv;
|
||||
$flow->change_lv = $changeLv;
|
||||
$flow->new_lv = $lv;
|
||||
$flow->old_lv = $oldMan->nurse_lv;
|
||||
}else{
|
||||
$newLv = $oldMan->nurse_lv;
|
||||
}
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
//缴费生成流水;
|
||||
$flow->save();
|
||||
//更新客人信息状态;
|
||||
$oldMan->update([
|
||||
'live_in' => Oldmen::STATUS_LIVE,
|
||||
'avliable_at' => $endAt,
|
||||
'nurse_lv' => $newLv,
|
||||
]);
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->setError('系统错误,请刷新后重试');
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return $this->setError('未找到客人信息!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class LiveInService extends OldmenService
|
|||
'live_in' => Oldmen::STATUS_LIVE,
|
||||
'live_in_at' => $startAt,
|
||||
'avliable_at' => $endAt,
|
||||
'bonds' => $feeArr['bonds_fee'] ?? []
|
||||
'bonds' => $feeArr['bonds_fee'] ?? [] //记录保证金
|
||||
]);
|
||||
DB::commit();
|
||||
}catch(Throwable $th){
|
||||
|
|
|
|||
|
|
@ -75,11 +75,20 @@ class OldmenService extends BaseService
|
|||
if($feeArr){
|
||||
foreach($feeArr as $k => $item){
|
||||
switch($k){
|
||||
case 'del_fee':
|
||||
case 'add_fee':
|
||||
foreach($item as $value){
|
||||
$money = bcsub($money, $value, 2);
|
||||
if(isset($value['name'])){
|
||||
$money = bcadd($money, $value['fee'], 2);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'del_fee':
|
||||
foreach($item as $value){
|
||||
if(isset($value['name'])){
|
||||
$money = bcsub($money, $value['fee'], 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
foreach($item as $value){
|
||||
|
|
|
|||
Loading…
Reference in New Issue