Files
hospital-applets-api/app/Model/DoctorWithdrawal.php
T
2023-04-08 10:16:57 +08:00

113 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Collection;
use Hyperf\Database\Model\Relations\HasOne;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $withdrawal_id 主键id
* @property int $doctor_id 医生id
* @property int $bank_id 银行id
* @property string $account_name 银行卡姓名
* @property string $bank_card_code 银行卡号
* @property string $bank_card_code_four 银行卡号(后四位)
* @property string $applied_withdrawal_amount 提现金额
* @property string $actual_withdrawal_amount 实际提现金额
* @property string $income_tax 提现所得税金额
* @property int $examine_status 审核状态(1:审核中 2:审核通过 3:审核未通过)
* @property string $examine_fail_reason 审核失败原因
* @property string $examine_time 审核日期
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class DoctorWithdrawal extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_withdrawal';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['withdrawal_id', 'doctor_id', 'bank_id', 'account_name', 'bank_card_code', 'bank_card_code_four', 'applied_withdrawal_amount', 'actual_withdrawal_amount', 'income_tax', 'examine_status', 'examine_fail_reason', 'examine_time', 'created_at', 'updated_at'];
protected string $primaryKey = "withdrawal_id";
/**
* 关联银行表
*/
public function BasicBank(): HasOne
{
return $this->hasOne(BasicBank::class, 'bank_id', 'bank_id');
}
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getOne(array $params, array $fields = ['*']): object|null
{
return self::where($params)->first($fields);
}
/**
* 获取信息-多条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getList(array $params, array $fields = ['*']): object|null
{
return self::where($params)->get($fields);
}
/**
* 获取某一时间区间分页数据
* @param array $params
* @param array $created_at_params
* @param array $fields
* @param int|null $page
* @param int|null $per_page
* @return array
*/
public static function getDatePage(array $params,array $created_at_params, array $fields = ['*'], int $page = null, ?int $per_page = 10): array
{
$raw = self::with([
'BasicBank'
])
->where($params)
->whereBetween('created_at',$created_at_params)
->paginate($per_page, $fields, "page", $page);
$data = array();
$data['current_page'] = $raw->currentPage();// 当前页码
$data['total'] = $raw->total();//数据总数
$data['data'] = $raw->items();//数据
$data['per_page'] = $raw->perPage();//每页个数
$data['last_page'] = $raw->lastPage();//最后一页
return $data;
}
/**
* 新增
* @param array $data
* @return DoctorWithdrawal|\Hyperf\Database\Model\Model
*/
public static function addDoctorWithdrawal(array $data): \Hyperf\Database\Model\Model|DoctorWithdrawal
{
return self::create($data);
}
}