<?php

namespace app\admin\model\order;

use think\Model;


class Paylog extends Model
{

    

    

    // 表名
    protected $name = 'payment_logs';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'order_type_text',
        'pay_way_text',
        'status_text'
    ];
    

    
    public function getOrderTypeList()
    {
        return ['recharge' => __('Order_type recharge'), 'goods' => __('Order_type goods')];
    }

    public function getPayWayList()
    {
        return ['money' => __('Pay_way money'), 'weixin' => __('Pay_way weixin'), 'alipay' => __('Pay_way alipay')];
    }

    public function getStatusList()
    {
        return ['-2' => __('Status -2'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
    }


    public function getOrderTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['order_type']) ? $data['order_type'] : '');
        $list = $this->getOrderTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPayWayTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_way']) ? $data['pay_way'] : '');
        $list = $this->getPayWayList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function user(){
        return self::hasOne("app\admin\model\User",'id',"user_id");
    }



}
