将余额的减少写入到日志表中
This commit is contained in:
parent
da744d01c3
commit
9e289230dc
@ -99,7 +99,7 @@ class BillionsLogic extends Logic
|
||||
]);
|
||||
}
|
||||
|
||||
// 增加余额记录
|
||||
// 增加余额记录日志
|
||||
SubsidyWithdrawalRecord::insert([
|
||||
'subsidy_withdrawal_id' => $subsidy_id,
|
||||
'user_id' => $user_id,
|
||||
@ -107,6 +107,7 @@ class BillionsLogic extends Logic
|
||||
'type' => 1,
|
||||
'way' => 0,
|
||||
'money' => $billions->subsidy_price,
|
||||
'desc' => '+余额增加' . $billions->subsidy_price,
|
||||
'create_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
@ -149,67 +150,32 @@ class BillionsLogic extends Logic
|
||||
|
||||
public static function balanceapply($user_id, $post)
|
||||
{
|
||||
dump($post);
|
||||
die;
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 1.先记录到日志下
|
||||
// 1. 减少余额
|
||||
SubsidyWithdrawal::where(['user_id' => $user_id])->dec('total_amount', $post['money'])->update();
|
||||
|
||||
// 2.先记录到日志下
|
||||
$commission_money = $post['money'] * (BillionsLogic::COMMISSION / 100); // 需要扣除手续费的金额
|
||||
$take_money = $post['money'] - ($post['money'] * (BillionsLogic::COMMISSION / 100)); // 实际到手的金额
|
||||
SubsidyWithdrawalRecord::insert([
|
||||
'subsidy_withdrawal_id' => 0,
|
||||
'user_id' => $user_id,
|
||||
'billions_id' => 0,
|
||||
'type' => 2,
|
||||
'commission_money' => $commission_money,
|
||||
'commission' => BillionsLogic::COMMISSION . '%',
|
||||
'take_money' => $take_money,
|
||||
'way' => $post['type'],
|
||||
'money' => $post['money'],
|
||||
'desc' => '-余额提现总额减少¥' . $post['money'] . ';手续费%' . BillionsLogic::COMMISSION . ';扣除手续费%' . $commission_money . ';实际到手¥' . $take_money,
|
||||
'create_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
// 2. 减少余额
|
||||
|
||||
// 3. 开始提现
|
||||
//提现手续费
|
||||
$com = self::COMMISSION;
|
||||
// $poundage = 0;
|
||||
// if ($post['type'] != WithdrawEnum::TYPE_BALANCE) {
|
||||
// $poundage_config = ConfigServer::get('withdraw', 'balancepoundage', 0);
|
||||
// $poundage = $post['money'] * $poundage_config / 100;
|
||||
// }
|
||||
//
|
||||
// $data = [
|
||||
// 'sn' => createSn('withdraw_apply', 'sn'),
|
||||
// 'batch_no' => createSn('withdraw_apply', 'batch_no','SJZZ'),
|
||||
// 'user_id' => $user_id,
|
||||
// 'type' => $post['type'],
|
||||
// 'account' => $post['account'] ?? '',
|
||||
// 'real_name' => $post['real_name'] ?? '',
|
||||
// 'money' => $post['money'],
|
||||
// 'left_money' => $post['money'] - $poundage,
|
||||
// 'money_qr_code' => $post['money_qr_code'] ?? '',
|
||||
// 'remark' => $post['remark'] ?? '',
|
||||
// 'bank' => $post['bank'] ?? '',
|
||||
// 'subbank' => $post['subbank'] ?? '',
|
||||
// 'poundage' => $poundage,
|
||||
// 'status' => 1, // 待提现
|
||||
// 'create_time' => time(),
|
||||
// ];
|
||||
// $withdraw_id = BalanceWithdrawApply::insertGetId($data);
|
||||
//
|
||||
// //提交申请后,扣减用户的佣金
|
||||
// $user = User::find($user_id);
|
||||
// $user->user_money = ['dec', $post['money']];
|
||||
// $user->save();
|
||||
// //增加佣金变动记录
|
||||
// AccountLogLogic::AccountRecord(
|
||||
// $user_id,
|
||||
// $post['money'],
|
||||
// 2,
|
||||
// AccountLog::withdraw_dec_earnings,
|
||||
// '',
|
||||
// $withdraw_id,
|
||||
// $data['sn']
|
||||
// );
|
||||
|
||||
Db::commit();
|
||||
return $withdraw_id;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
throw new Exception($e->getMessage());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user