文件
yjyf/server/application/admin/model/Withdraw.php

79 行
1.6 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class Withdraw extends Model
{
// 表名
protected $name = 'withdraw';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'channel_text',
'status_text',
'transfer_state_text'
];
public function getChannelList()
{
return ['wechat' => __('Wechat'), 'bank' => __('Bank')];
}
public function getStatusList()
{
return ['wait' => __('Wait'), 'pass' => __('Pass'), 'reject' => __('Reject'), 'done' => __('Done')];
}
public function getChannelTextAttr($value, $data)
{
$value = $value ?: ($data['channel'] ?? '');
$list = $this->getChannelList();
return $list[$value] ?? '';
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
public function getTransferStateTextAttr($value, $data)
{
$state = $data['transfer_state'] ?? '';
if ($state === '' && ($data['channel'] ?? '') === 'bank') {
return '线下转账';
}
return \app\common\library\PaymentService::transferStateLabel($state);
}
public function master()
{
return $this->belongsTo('Master', 'master_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}