操作步骤如下:
一、打开app/Http/Service/Client/ContractService.php 文件, 修改以下三处位置。
1.1 找到 reloadStatus 方法, 位于843行左右,替换:
public function reloadStatus(int $id, mixed $contract = null): void
{
$contract = $contract ?: $this->dao->get($id);
if ($contract->is_abnormal) {
$contract->contract_status = '3';
} else {
$status = '1';
$tz = config('app.timezone');
$now = Carbon::now($tz)->toDateString();
if ($contract->start_date && Carbon::parse($contract->start_date, $tz)->gt($now)) {
$status = '0';
}
if ($contract->end_date && Carbon::parse($contract->end_date, $tz)->lt($now)) {
$status = '2';
}
$contract->contract_status = $status;
}
$contract->save();
}
1.2 找到 updateContract 方法, 位于169行左右:
替换行:
$data['contract_status'] = $info->is_abnormal ? '3' : $this->getStatus($data);
1.3 找到 statusTimer 方法, 位于828行左右,替换:
public function statusTimer(): void
{
$now = Carbon::now(config('app.timezone'))->toDateString();
$this->dao->update(['start_date_gt' => $now, 'contract_status_lt' => '2'], ['contract_status' => '1']);
$this->dao->update(['end_date_lt' => $now, 'contract_status_lt' => '3'], ['contract_status' => '2']);
}
二、打开app/Http/Service/Client/ClientBillService.php 文件, 找到 contractPrice 方法,位于1113行左右,替换:
private function contractPrice(int $cid, $contract = null): bool
{
$contractService = app()->get(ContractService::class);
if (! $contract) {
$contract = $contractService->get($cid);
}
if (! $contract) {
throw $this->exception('合同信息获取异常');
}
$contract->received = max($this->dao->getSum(['cid' => $cid, 'types' => -1]), 0);
$paymentAmount = max($this->dao->getSum(['cid' => $cid, 'types' => 0]), 0);
$contract->surplus = max(bcsub((string) $contract->contract_price, (string) $paymentAmount, 2), 0);
return true;
}
三、打开app/Http/Model/Client/Contract.php 文件,新加方法:
/**
* end_date lt 作用域
* @param $query
* @param $value
* @return void
*/
public function scopeEndDateLt($query, $value): void
{
if ($value != '') {
$query->whereDate('end_date', '<', $value);
}
}
保存文件后并重启守护进程。
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}