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.

121 lines
3.6 KiB

<?php
namespace app\model;
use think\Db;
/**
* @property int id
* @property int user_id
* @property int account_type
* @property int recharge_type
* @property int recharge_channel
* @property int recharge_num
* @property int status
* @property int order_no
* @property string country
* @property int currency_rate
* @property int total_amount
* @property string create_time
* @property string update_time
*/
class RechargeApplyModel extends BaseModel
{
protected $name = 'recharge_apply';
protected $pk = 'id';
// status 0处理中,0处理中 1充值成功 2充值失败
const STATUS_ZERO = 0;
const STATUS_ONE = 1;
const STATUS_TWO = 2;
public static $statusList = [
self::STATUS_ZERO => '处理中(待审核)',
self::STATUS_ONE => '充值成功',
self::STATUS_TWO => '充值失败',
];
public static function getUserRecharge(array $data)
{
$where['user_id']=$data['user_id'];
if($data['account_type']>0){
$where['account_type']=$data['account_type'];
}
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('account_type,market_amount as recharge_num,status,order_no,recharge_type,recharge_channel,service_fee,create_time')
->order('id desc')->page($data['page'],$data['page_size'])->select();
if(empty($list)){
return [];
}else{
return [
'total'=>$count,
'list'=>$list->toArray()
];
}
}
public static function getUserIsRecharge(array $data)
{
$count= self::where([
'user_id'=>$data['user_id'],
'status'=>1
])->count();
return $count > 0;
}
public static function getUserPayNum(array $data)
{
$count= self::where([
['user_id','in',$data],
['status','=',1]
])->count('DISTINCT user_id');
return $count;
}
public static function InsertUserRecharge(array $data)
{
$self = new self;
$self->user_id = $data['user_id'];
$self->account_type = $data['account_type'];
$self->recharge_type = $data['recharge_type'];
$self->recharge_channel = $data['recharge_channel'];
$self->recharge_num = $data['recharge_num'];
$self->status = 0;
$self->is_check = 0;
$self->country = $data['country'];
$self->order_no = $data['order_no'];
$self->currency_rate = $data['currency_rate'];
$self->market_amount = $data['market_amount'];
$self->service_fee = $data['service_fee'];
$self->total_amount = $data['total_amount'];
$self->is_online=$data['is_online'];
$self->file_id=$data['file_id'];
$self->create_time = date('Y-m-d H:i:s');
$self->update_time = date('Y-m-d H:i:s');
return $self->save();
}
public static function getOrderByNo(array $where)
{
$order_info=self::where($where)->find();
if($order_info){
return $order_info->toArray();
}else{
return [];
}
}
public static function AddUserRecharge(array $data)
{
$self = new self;
return $self->save($data);
}
public static function getOrderInfo($where)
{
$order_info=self::where($where)->find();
if($order_info){
return $order_info->toArray();
}else{
return [];
}
}
}