bourse stock
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

<?php
namespace app\model;
/**
* @property int id
* @property string trade_name
* @property string status
* @property string is_owner
* @property string logo_link
* @property string face_value
* @property string info
* @property string sort
* @property string min_pry
* @property string max_pry
* @property string compel_num
* @property string keep_decimal
* @property string create_time
* @property string update_time
*/
class ForexListModel extends BaseModel
{
protected $name = 'forex_list';
protected $pk = 'id';
public static function getMarketList($data): array
{
$where=[
['status','=',1]
];
if(!empty($data['trade_name'])){
$where[]=[
'trade_name','like',strtoupper($data['trade_name']).'%'
];
}
if($data['page']<1){
$data['page']=1;
}
if($data['page_size']<1){
$data['page_size']=10;
}
$count=self::where($where)->count();
$list = self::where($where)->field('trade_name as name,trade_name as code')->page($data['page'],$data['page_size'])->select();
if(empty($list)){
return [];
}
return [
'total'=>$count,
'list'=>$list->toArray(),
];
}
public static function existMarket($trade_name):bool
{
$id=self::where('trade_name',$trade_name)->value('id');
return $id >0;
}
public static function getMarketFaceList($type=0)
{
$list=self::where('status',1)->field('face_value,trade_name as name,trade_name as code,sort,max_pry,min_pry')->select();
if(empty($list)){
return [];
}
$list=$list->toArray();
if($type==1){
foreach ($list as $val){
$face_list[$val['name']]=$val['face_value'];
}
}else{
$face_list=$list;
}
return $face_list;
}
}