allocatr/application/admin/model/OrderLog.php
2025-03-03 13:55:34 +08:00

51 lines
1.0 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class OrderLog extends Model
{
// 表名
protected $name = 'order_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'order_status_text'
];
public function getOrderStatusList()
{
return ['10' => __('Order_status 10'), '20' => __('Order_status 20'), '30' => __('Order_status 30'), '40' => __('Order_status 40'), '50' => __('Order_status 50'), '-10' => __('Order_status -10'), '-20' => __('Order_status -20'), '-30' => __('Order_status -30')];
}
public function getOrderStatusTextAttr($value, $data)
{
$value = $value ?: ($data['order_status'] ?? '');
$list = $this->getOrderStatusList();
return $list[$value] ?? '';
}
}