文件
yjyf/server/application/admin/model/Invoice.php
MiAn fafddceaf2 feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包
- 新增后台控制器、视图及搜索字段配置
- 修复服务类目删除保护逻辑
- 优化后台登录页面文案及样式
- 新增前端角色切换逻辑及页面拦截
- 新增 SVG 图标及样式变量
- 修复接口权限及下拉框默认值问题
2026-11-11 17:02:35 +08:00

81 行
1.9 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class Invoice extends Model
{
// 表名
protected $name = 'invoice';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'type_text',
'title_type_text',
'status_text'
];
public function getTypeList()
{
return ['normal' => __('Ordinary'), 'special' => __('Special')];
}
public function getTitleTypeList()
{
return ['personal' => __('Personal'), 'enterprise' => __('Enterprise')];
}
public function getStatusList()
{
return [
'wait' => __('Wait'),
'issued' => __('Issued'),
'reject' => __('Reject'),
'cancel' => __('Cancel'),
];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ?: ($data['type'] ?? '');
$list = $this->getTypeList();
return $list[$value] ?? '';
}
public function getTitleTypeTextAttr($value, $data)
{
$value = $value ?: ($data['title_type'] ?? '');
if ($value === '' && !empty($data['tax_no'])) {
$value = 'enterprise';
}
$list = $this->getTitleTypeList();
return $list[$value] ?? __('Personal');
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
public function user()
{
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function merchant()
{
return $this->belongsTo('Merchant', 'merchant_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}