调整除自动计算费用问题以外的问题

develop
vine_liutk 2023-06-26 11:27:18 +08:00
parent cd8bd7ddc2
commit 13576efcf9
10 changed files with 3279 additions and 3261 deletions

View File

@ -28,13 +28,13 @@ class ConstFlowController extends AdminController
$this->baseFilter()->body([ $this->baseFilter()->body([
amisMake()->TextControl('name', '名称')->size('md'), amisMake()->TextControl('name', '名称')->size('md'),
amisMake()->TextControl('card_no', '身份证')->size('md'), amisMake()->TextControl('card_no', '身份证')->size('md'),
amisMake()->TextControl('sn', '单据编号')->size('md'), amisMake()->TextControl('idsn', '单据编号')->size('md'),
amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'), amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'),
amis('submit')->label(__('admin.search'))->level('primary'), amis('submit')->label(__('admin.search'))->level('primary'),
])->actions([]) ])->actions([])
) )
->columns([ ->columns([
amisMake()->TableColumn('sn', '单据编号')->copyable(true), amisMake()->TableColumn('idsn', '单据编号')->copyable(true),
amisMake()->TableColumn('oldman.name', '客人'), amisMake()->TableColumn('oldman.name', '客人'),
amisMake()->TableColumn('const_type', '缴费类型')->type('mapping')->map(ConstFlow::typeMapLabel())->className('text-primary'), amisMake()->TableColumn('const_type', '缴费类型')->type('mapping')->map(ConstFlow::typeMapLabel())->className('text-primary'),
amisMake()->TableColumn('money', '金额'), amisMake()->TableColumn('money', '金额'),

View File

@ -337,7 +337,7 @@ class OldmenController extends AdminController
->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE]) ->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE])
->where('state', 0) ->where('state', 0)
->whereBetween('start_at', [$oldMan->live_in_at, $oldMan->avliable_at])//开始时间在用户这段时间内的清单 ->whereBetween('start_at', [$oldMan->live_in_at, $oldMan->avliable_at])//开始时间在用户这段时间内的清单
->get(); ->orderBy('created_at', 'desc')->limit(3)->get();//调整为最近3条
$tableList = []; $tableList = [];
foreach($flowList as $flow){ foreach($flowList as $flow){
$_feeInfo = $_bonusInfo = $_addInfo = $_delInfo = ''; $_feeInfo = $_bonusInfo = $_addInfo = $_delInfo = '';

View File

@ -17,6 +17,11 @@ class ConstFlowFilter extends ModelFilter
return $this->where('sn', $sn); return $this->where('sn', $sn);
} }
public function idsn($idsn){
$id = 0+$idsn;
return $this->where('id', $id);
}
/** /**
* 名称 * 名称
*/ */

View File

@ -26,7 +26,7 @@ class PrintController extends Controller
$flow->load(['oldman', 'adminuser']); $flow->load(['oldman', 'adminuser']);
$name = $flow->oldman->name; $name = $flow->oldman->name;
$time = $flow->created_at->format('Y-m-d H:i:s'); $time = $flow->created_at->format('Y-m-d H:i:s');
$sn = $flow->sn; $idsn = $flow->idsn;
$ukeys = explode(',', $request->input('ukeys', '')); $ukeys = explode(',', $request->input('ukeys', ''));
$i = 0; $i = 0;
foreach($rows as $item){ foreach($rows as $item){
@ -61,7 +61,7 @@ class PrintController extends Controller
$timeZone = substr($flow->start_at, 0, 10).'至'.substr($flow->end_at, 0, 10); $timeZone = substr($flow->start_at, 0, 10).'至'.substr($flow->end_at, 0, 10);
} }
return view('print-const', compact('name', 'time', 'sn', 'list', 'total', 'bigTotal', 'timeZone', 'adminName')); return view('print-const', compact('name', 'time', 'idsn', 'list', 'total', 'bigTotal', 'timeZone', 'adminName'));
} }

View File

@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use EloquentFilter\Filterable; use EloquentFilter\Filterable;
use Slowlyo\OwlAdmin\Models\AdminUser; use Slowlyo\OwlAdmin\Models\AdminUser;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Casts\Attribute;
class ConstFlow extends Model class ConstFlow extends Model
{ {
@ -34,6 +35,8 @@ class ConstFlow extends Model
]; ];
} }
protected $appends = ['idsn'];
protected $casts = [ protected $casts = [
'extends' => 'array', 'extends' => 'array',
]; ];
@ -53,6 +56,13 @@ class ConstFlow extends Model
}); });
} }
public function idsn():Attribute
{
return Attribute::make(
get: fn($value) => str_pad($this->id, 6, '0',STR_PAD_LEFT),
);
}
public function oldman(){ public function oldman(){
return $this->belongsTo(Oldmen::class, 'oldman_id'); return $this->belongsTo(Oldmen::class, 'oldman_id');
} }

View File

@ -22,6 +22,7 @@ class Oldmen extends Model
protected $casts = [ protected $casts = [
'birthday' => 'datetime:Y-m-d', 'birthday' => 'datetime:Y-m-d',
'bonds' => 'array',
]; ];
protected $appends = ['age']; protected $appends = ['age'];

View File

@ -23,17 +23,18 @@ class LiveExitService extends OldmenService
if($oldMan->live_in != Oldmen::STATUS_LIVE){ if($oldMan->live_in != Oldmen::STATUS_LIVE){
return $this->setError('客人状态异常,请刷新后重试!'); return $this->setError('客人状态异常,请刷新后重试!');
} }
$flowList = ConstFlow::where('oldman_id', $oldMan->id)
->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE])
->where('state', 0)
->whereBetween('start_at', [$oldMan->live_in_at, $oldMan->avliable_at])//开始时间在用户这段时间内的清单
->get();
$flowMoney = 0; $flowMoney = 0;
foreach($flowList as $flow){
$flowMoney = bcsub($flowMoney, $flow->money, 2); //取消计算历史费用
} // $flowList = ConstFlow::where('oldman_id', $oldMan->id)
// ->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE])
// ->where('state', 0)
// ->whereBetween('start_at', [$oldMan->live_in_at, $oldMan->avliable_at])//开始时间在用户这段时间内的清单
// ->get();
// foreach($flowList as $flow){
// $flowMoney = bcsub($flowMoney, $flow->money, 2);
// }
$flow = new ConstFlow(); $flow = new ConstFlow();
$flow->oldman_id = $oldMan->id; $flow->oldman_id = $oldMan->id;
@ -63,7 +64,7 @@ class LiveExitService extends OldmenService
'need_pay' => Oldmen::PAY_NORMAL, 'need_pay' => Oldmen::PAY_NORMAL,
'live_in_at' => null, 'live_in_at' => null,
'avliable_at' => null, 'avliable_at' => null,
'bonds' => 0,//保证金归零 'bonds' => [],//保证金归零
]); ]);
DB::commit(); DB::commit();
}catch(Throwable $th){ }catch(Throwable $th){

View File

@ -110,29 +110,30 @@ class OldmenService extends BaseService
switch($type){ switch($type){
case ConstFlow::TYPE_EXIT: case ConstFlow::TYPE_EXIT:
if($oldMan){ //取消缴费记录计算
if(isset($extends['live_in_at']) && $extends['avliable_at']){ // if($oldMan){
$startAt = $extends['live_in_at']; // if(isset($extends['live_in_at']) && $extends['avliable_at']){
$endAt = $extends['avliable_at']; // $startAt = $extends['live_in_at'];
}else{ // $endAt = $extends['avliable_at'];
$startAt = $oldMan->live_in_at; // }else{
$endAt = $oldMan->avliable_at; // $startAt = $oldMan->live_in_at;
} // $endAt = $oldMan->avliable_at;
// }
$flowList = ConstFlow::where('oldman_id', $oldMan->id) // $flowList = ConstFlow::where('oldman_id', $oldMan->id)
->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE]) // ->whereIn('const_type', [ConstFlow::TYPE_IN, ConstFlow::TYPE_CONTINUE])
->where('state', 0) // ->where('state', 0)
->whereBetween('start_at', [$startAt, $endAt])//开始时间在用户这段时间内的清单 // ->whereBetween('start_at', [$startAt, $endAt])//开始时间在用户这段时间内的清单
->get(); // ->get();
foreach($flowList as $flow){ // foreach($flowList as $flow){
$rows[] = [ // $rows[] = [
'ukey' => 'history_'.$flow->id, // 'ukey' => 'history_'.$flow->id,
'name' => '缴费记录', // 'name' => '缴费记录',
'fee_name' => ConstFlow::typeMap()[$flow->const_type].'【'.$flow->created_at->format('m-d H:i:s').'】', // 'fee_name' => ConstFlow::typeMap()[$flow->const_type].'【'.$flow->created_at->format('m-d H:i:s').'】',
'fee_value' => 0-$flow->money, // 'fee_value' => 0-$flow->money,
]; // ];
} // }
} // }
$addFee = Arr::get($extends, 'add_extends', []); $addFee = Arr::get($extends, 'add_extends', []);
if(!$addFee){ if(!$addFee){

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@
<p class="tag" style="font-size:20px;"> <p class="tag" style="font-size:20px;">
<span class="left">客户姓名 {{$name}}</span> <span class="left">客户姓名 {{$name}}</span>
<span class="middle">日期 {{$time}}</span> <span class="middle">日期 {{$time}}</span>
<span class="right">单据编号 {{$sn}}</span> <span class="right">单据编号 {{$idsn}}</span>
</p> </p>
<table class="print-table"> <table class="print-table">
<tr> <tr>