72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model\order;
|
|
|
|
use think\Model;
|
|
|
|
|
|
class RefundLog extends Model
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'order_refund_log';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'integer';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
protected $deleteTime = false;
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'status_text'
|
|
];
|
|
|
|
// 订单状态
|
|
const STATUS_INVALID = -2;
|
|
const STATUS_CANCEL = -1;
|
|
const STATUS_NOPAY = 0;
|
|
const STATUS_PAYED = 1;
|
|
const STATUS_FINISH = 2;
|
|
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['0' => __('Status 0'), '1' => __('Status 1'), '-1' => __('Status -1')];
|
|
}
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
|
$list = $this->getStatusList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo('app\admin\model\Order', 'order_no', 'order_no', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
// 获取退款单号
|
|
public static function getNo($user_id)
|
|
{
|
|
$rand = $user_id < 9999 ? mt_rand(100000, 99999999) : mt_rand(100, 99999);
|
|
$order_sn = date('Yhis') . $rand;
|
|
|
|
$id = str_pad($user_id, (24 - strlen($order_sn)), '0', STR_PAD_BOTH);
|
|
|
|
return 'R' . $order_sn . $id;
|
|
}
|
|
|
|
public function item()
|
|
{
|
|
return $this->belongsTo('app\admin\model\order\Item', 'order_item_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
}
|