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.
67 lines
1.6 KiB
67 lines
1.6 KiB
<?php
|
|
|
|
namespace app\model;
|
|
|
|
/**
|
|
* @property int id
|
|
* @property string trade_name
|
|
* @property string status
|
|
* @property string info
|
|
* @property string logo_link
|
|
* @property string keep_decimal
|
|
* @property string is_owner
|
|
* @property string sort
|
|
* @property string exchange_name
|
|
* @property string create_time
|
|
* @property string update_time
|
|
*/
|
|
class DigitalListModel extends BaseModel
|
|
{
|
|
|
|
protected $name = 'digital_list';
|
|
protected $pk = 'id';
|
|
|
|
public static function getMarketList($data,$type=0): array
|
|
{
|
|
$where=[];
|
|
if($type==0){
|
|
$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,exchange_name as code,logo_link,sort')->page($data['page'],$data['page_size'])->select();
|
|
if(empty($list)){
|
|
return [];
|
|
}
|
|
$list=$list->toArray();
|
|
|
|
foreach ($list as $key=>$val){
|
|
$list[$key]['code']=$val['name'].'-'.$val['code'];
|
|
}
|
|
|
|
return [
|
|
'total'=>$count,
|
|
'list'=>$list,
|
|
];
|
|
}
|
|
public static function existMarket($trade_name):bool
|
|
{
|
|
$id=self::where('trade_name',$trade_name)->value('id');
|
|
return $id >0;
|
|
}
|
|
|
|
|
|
}
|