<?php
namespace app\model;
/**
 * @property int id
 * @property int market_type
 * @property float buy_fee
 * @property float sale_fee
 * @property float purchase_fee
 * @property int pay_type
 * @property int min_buy_num
 * @property int min_sale_num
 * @property int max_entrust_num
 * @property int max_hold_num
 */
class FeeSettingModel extends BaseModel
{
    protected $name = 'fee_setting';
    protected $pk = 'id';

    public static $marketTypeList = [
        '1' => '现货',
        '2' => '合约',
        '3' => '美股',
        '4' => '印尼股票', // 5 马股 6 泰股
        '5' => '马股',
        '6' => '泰股',
        '7' => '印度股票',
        '8' => '秒合约',
        '9' => '新加坡股票',
        '10' => '基金',
        '11' => '印度期权',
        '12' => '港股',
        '14' => '英股'
    ];

    public static $payTypeList = [
        '0' => '固定费用',
        '1' => '按比例结算',
        '2' => '按张结算',
    ];

    public static function getTradeFeeById($market_type):array
    {
        if($market_type>0){
            $info = self::where('market_type', $market_type)->field('market_type,buy_fee,sale_fee,pay_type,min_buy_num,min_sale_num,purchase_fee')->find();
            if(empty($info)){
                return [];
            }
            return $info->toArray();
        }else{
            $info = self::where(1)->field('market_type,buy_fee,sale_fee,pay_type,min_buy_num,min_sale_num,purchase_fee')->select();
            if(empty($info)){
                return [];
            }
            return $info->toArray();
        }
    }



}