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.
56 lines
1.3 KiB
56 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MpBalance extends Model
|
|
{
|
|
protected $table = 'lanzu_mp_balance';
|
|
protected $dateFormat = 'U';
|
|
|
|
/**
|
|
* 获取可提现金额
|
|
* @param $uid
|
|
* @param $uType 0/1 普通用户/服务商
|
|
*/
|
|
public static function getBalance($uid,$uType=0)
|
|
{
|
|
$row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
|
|
if ($row){
|
|
return $row->balance;
|
|
}else{
|
|
return '0.00';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 扣减可提现金额
|
|
*/
|
|
public static function reduceBalance($uid,$uType,$reduceMoney)
|
|
{
|
|
$row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
|
|
if ($row){
|
|
$row->balance = $row->balance-$reduceMoney;
|
|
return $row->save();
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 回退审核未通过时的提现金额
|
|
*/
|
|
public static function returnBalance($uid,$uType,$returnMoney)
|
|
{
|
|
$row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
|
|
if ($row){
|
|
$row->balance = $row->balance+$returnMoney;
|
|
return $row->save();
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
}
|