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.
70 lines
1.8 KiB
70 lines
1.8 KiB
2 months ago
|
<?php
|
||
|
|
||
|
namespace app\model;
|
||
|
|
||
|
/**
|
||
|
* @property int id
|
||
|
* @property int user_id
|
||
|
* @property string wallet_address
|
||
|
* @property string wallet_type
|
||
|
* @property string create_time
|
||
|
*/
|
||
|
class WalletListModel extends BaseModel
|
||
|
{
|
||
|
protected $name = 'wallet_list';
|
||
|
protected $pk = 'id';
|
||
|
|
||
|
public static function getUserWalletList(array $data)
|
||
|
{
|
||
|
$list=self::where($data)->field('wallet_address,wallet_type')->find();
|
||
|
if(empty($list)){
|
||
|
$wallet_info=self::where([
|
||
|
'user_id'=>0,
|
||
|
'wallet_type'=>$data['wallet_type']
|
||
|
])->order('id','asc')->find();
|
||
|
if($wallet_info){
|
||
|
$wallet_info=$wallet_info->toArray();
|
||
|
self::where('id',$wallet_info['id'])->update([
|
||
|
'user_id'=>$data['user_id']
|
||
|
]);
|
||
|
}
|
||
|
$list=$wallet_info;
|
||
|
}else{
|
||
|
$list=$list->toArray();
|
||
|
}
|
||
|
return $list;
|
||
|
}
|
||
|
public static function getUidByWallet(array $data)
|
||
|
{
|
||
|
$info=self::where($data)->find();
|
||
|
if(!empty($info)){
|
||
|
$wallet_info=$info->toArray();
|
||
|
return $wallet_info['user_id'];
|
||
|
}else{
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
public static function getUserWalletAddress(array $data)
|
||
|
{
|
||
|
$info=self::where($data)->find();
|
||
|
if(!empty($info)){
|
||
|
$wallet_info=$info->toArray();
|
||
|
return $wallet_info['wallet_address'];
|
||
|
}else{
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
public static function InsertUserWalletAddress(array $data)
|
||
|
{
|
||
|
$self = new self;
|
||
|
$self->user_id = $data['user_id'];
|
||
|
$self->wallet_address = $data['wallet_address'];
|
||
|
$self->wallet_type = $data['wallet_type'];
|
||
|
$self->create_time = date('Y-m-d H:i:s');
|
||
|
$self->save();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|