|
|
|
@ -164,7 +164,7 @@ class User extends Model |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 扣减余额 |
|
|
|
* 扣减余额(消费) |
|
|
|
* @param $user_id |
|
|
|
* @param $balance |
|
|
|
* @return float|mixed |
|
|
|
@ -176,13 +176,12 @@ class User extends Model |
|
|
|
{ |
|
|
|
$user = self::find($user_id); |
|
|
|
$user->balance = round($user->balance - $balance,2); |
|
|
|
$user->withdrawal_balance = $user->balance; |
|
|
|
$user->save(); |
|
|
|
return $user->balance; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 增加余额 |
|
|
|
* 增加余额(充值、上分) |
|
|
|
* @param $user_id |
|
|
|
* @param $balance |
|
|
|
* @return float|mixed |
|
|
|
@ -194,11 +193,46 @@ class User extends Model |
|
|
|
{ |
|
|
|
$user = self::find($user_id); |
|
|
|
$user->balance = round($user->balance + $balance,2); |
|
|
|
$user->withdrawal_balance = $user->balance; |
|
|
|
$user->save(); |
|
|
|
return $user->balance; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 扣除可提余额 (提现、下分) |
|
|
|
* @param $user_id |
|
|
|
* @param $balance |
|
|
|
* @return float|mixed |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
* @author whj |
|
|
|
* @date 2023-08-30 17:31 |
|
|
|
*/ |
|
|
|
public static function decrWithdrawalBalance($user_id,$balance) |
|
|
|
{ |
|
|
|
$user = self::find($user_id); |
|
|
|
$user->withdrawal_balance = round($user->withdrawal_balance - $balance,2); |
|
|
|
$user->save(); |
|
|
|
return $user->withdrawal_balance; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 增加可提余额(中奖) |
|
|
|
* @param $user_id |
|
|
|
* @param $balance |
|
|
|
* @return float|mixed |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
public static function IncrWithdrawalBalance($user_id,$balance) |
|
|
|
{ |
|
|
|
$user = self::find($user_id); |
|
|
|
$user->withdrawal_balance = round($user->withdrawal_balance + $balance,2); |
|
|
|
$user->save(); |
|
|
|
return $user->withdrawal_balance; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成盐值 |
|
|
|
* @return string |
|
|
|
|