取消提现手续费-附加一些功能测试
This commit is contained in:
@@ -214,8 +214,8 @@ class DivideAccountController extends BaseAdminController
|
||||
$CashAccount->saveOrFail();
|
||||
|
||||
// 计算手续费
|
||||
// $qianliuwu = bcdiv(0.65, 100, 4);
|
||||
// $shouxufei = bcadd(bcmul($post['apply_cash'], $qianliuwu, 2), 2, 3);
|
||||
$pQianliuwu = bcdiv(0.65, 100, 4);
|
||||
$pShouxufei = bcadd(bcmul($post['apply_cash'], $pQianliuwu, 2), 2, 3);
|
||||
// TODO 暂时不计算手续费
|
||||
$shouxufei = '0';
|
||||
|
||||
@@ -230,6 +230,16 @@ class DivideAccountController extends BaseAdminController
|
||||
$CashApply->apply_time = date('Y-m-d H:i:s', time());
|
||||
$CashApply->saveOrFail();
|
||||
|
||||
|
||||
// 记录代付的手续费
|
||||
$chargeCpr = new ChargeCashPayRecord();
|
||||
$chargeCpr->order_no = $order_no;
|
||||
$chargeCpr->store_id = 0;//诊所id
|
||||
$chargeCpr->charge_cash = $pShouxufei;//手续费
|
||||
$chargeCpr->type = 2;//用户类型1诊所2总部
|
||||
$chargeCpr->status = 1;
|
||||
$chargeCpr->saveOrFail();
|
||||
|
||||
// 记录操作日志
|
||||
$log = new Log();
|
||||
$log->admin_id = $user->uid;
|
||||
@@ -335,11 +345,15 @@ class DivideAccountController extends BaseAdminController
|
||||
throw new \yii\db\Exception('银行卡相关配置不能为空');
|
||||
}
|
||||
|
||||
$chargeCpr = $this->getChargeCashPayRecordStatusByOrderNo($CashApply->order_no);
|
||||
|
||||
if (empty($chargeCpr->charge_cash?? '')) {
|
||||
throw new \yii\db\Exception('手续费异常');
|
||||
}
|
||||
// 准备打款参数
|
||||
$param = [
|
||||
'order_no' => $CashApply->order_no, // 订单号
|
||||
'apply_cash' => bcadd($CashApply->true_cash, 1, 2), // 实际打款金额 1元是银联手续费
|
||||
'apply_cash' => bcadd($CashApply->true_cash, $chargeCpr->charge_cash, 2), // 实际打款金额 1元是银联手续费
|
||||
'bank_name' => $config->bank_name, // 银行名称
|
||||
'bank_account_type' => $config->bank_account_type, // 银行账户类型
|
||||
'bank_no' => $config->bank_no, // 银行账号
|
||||
@@ -415,7 +429,7 @@ class DivideAccountController extends BaseAdminController
|
||||
$CashApply->saveOrFail();
|
||||
|
||||
// 记录代付的手续费
|
||||
$this->updateChargeCashPayRecordStatusByOrderNo($CashApply->order_no, 2);
|
||||
$this->updateChargeCashPayRecordStatusByOrderNo($CashApply->order_no, 2, $param['apply_cash']);
|
||||
|
||||
// 记录日志
|
||||
$log = new Log();
|
||||
@@ -537,16 +551,44 @@ class DivideAccountController extends BaseAdminController
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function updateChargeCashPayRecordStatusByOrderNo($orderNo, $status)
|
||||
private function updateChargeCashPayRecordStatusByOrderNo($orderNo, $status, $chargeCash)
|
||||
{
|
||||
if (empty($orderNo) || empty($status)) throw new Exception('参数错误');
|
||||
// 记录代付的手续费
|
||||
$chargeCpr = ChargeCashPayRecord::find()->where([
|
||||
$chargeCpr = $this->getChargeCashPayRecordStatusByOrderNo($orderNo);
|
||||
$chargeCpr->status = $status;
|
||||
$chargeCpr->saveOrFail();
|
||||
if ($status == 2) {
|
||||
if (empty($chargeCash)) {
|
||||
throw new Exception('充值金额不能为空');
|
||||
}
|
||||
$account = CashAccount::find()->where([
|
||||
'user_id' => $chargeCpr->user_id,
|
||||
'user_type' => $chargeCpr->user_type
|
||||
])->one();
|
||||
// 将冻结金额和充值金额进行合并计算,并将结果赋值给可用金额
|
||||
$account->charge_cash = bcadd($account->frozen_cash, $chargeCpr->charge_cash, 2);
|
||||
|
||||
// 从冻结金额中减去充值金额,并将结果赋值回冻结金额
|
||||
$account->frozen_cash = bcsub($account->frozen_cash, $chargeCash, 2);
|
||||
// 减少账户可用余额
|
||||
$account->able_cash = bcsub($account->able_cash, $chargeCpr->charge_cash, 2);
|
||||
$account->saveOrFail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号获取代付记录
|
||||
*
|
||||
* @param $orderNo
|
||||
* @return array|\yii\db\ActiveRecord|null
|
||||
*/
|
||||
public function getChargeCashPayRecordStatusByOrderNo($orderNo)
|
||||
{
|
||||
return ChargeCashPayRecord::find()->where([
|
||||
'status' => 1,
|
||||
'order_no' => $orderNo
|
||||
])->one();
|
||||
$chargeCpr->status = $status;
|
||||
$chargeCpr->saveOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user