<?php

namespace app\model;

/**
 * @property int $id
 * @property int $pre_stock_id
 * @property int $user_id
 * @property int $status
 * @property int $interest_type
 * @property int $order_no
 * @property int $amount
 * @property int $phase_count
 * @property int $stock_rate
 * @property int $stock_cycle_type
 * @property int $stock_cycle
 * @property int $fee
 * @property int $fee_rate
 * @property int $create_time
 * @property int $update_time
 */
class UserFundPreStockOrderModel extends BaseModel
{
    protected $name = 'user_fund_pre_stock_order';
    protected $pk = 'id';

    const STATUS_ONE = 1; // 已下单(待返息)
    const STATUS_TWO = 2; // 返息中(已返息N期)
    const STATUS_THREE = 3; // 已结束


    public static $statusEnList = [
        self::STATUS_ONE => 'Having',
        self::STATUS_TWO => 'Returning',
        self::STATUS_THREE => 'Over',
    ];

    public function getStatusEnTextAttr($value, $data)
    {
        $status = UserFundPreStockOrderModel::$statusEnList[$data['status']];
        return $status;
    }

    public function fund()
    {
        return $this->hasOne(PreFundStockModel::class, 'id', 'pre_stock_id');
    }

    public function interestArr()
    {
        return $this->hasMany(UserStockFundInterestReceiptModel::class, 'order_id','id');
    }
}