diff --git a/app/common/repositories/system/financial/FinancialRepository.php b/app/common/repositories/system/financial/FinancialRepository.php index 554b6d5..90337d0 100644 --- a/app/common/repositories/system/financial/FinancialRepository.php +++ b/app/common/repositories/system/financial/FinancialRepository.php @@ -110,129 +110,105 @@ class FinancialRepository extends BaseRepository public function applyForm(int $merId) { $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); - $extract_minimum_line = systemConfig('extract_minimum_line') ?: 0; - $extract_minimum_num = systemConfig('extract_minimum_num'); + $extract_minimum_line = (float)systemConfig('extract_minimum_line') ?: 0; + $extract_minimum_num = (float)systemConfig('extract_minimum_num'); $_line = bcsub($merchant->mer_money,$extract_minimum_line,2); $_extract = ($_line < 0) ? 0 : $_line; $form = Elm::createForm(Route::buildUrl('merchantFinancialCreateSave')->build()); - $form->setRule([ - [ - 'type' => 'span', - 'title' => '商户名称:', - 'native' => false, - 'children' => ["$merchant->mer_name"] - ], - [ - 'type' => 'span', - 'title' => '商户ID:', - 'native' => false, - 'children' => ["$merId"] - ], -// [ -// 'type' => 'span', -// 'title' => '', -// 'children' => [] -// ], - [ - 'type' => 'span', - 'title' => '提示:', - 'native' => false, - 'children' => ['最低可提现额度:'.$extract_minimum_line.'元;最低提现金额:'.$extract_minimum_num.'元'] - ], - [ - 'type' => 'span', - 'title' => '商户余额:', - 'native' => false, - 'children' => ["$merchant->mer_money"] - ], - [ - 'type' => 'span', - 'native' => false, - 'title' => '商户可提现金额:', - 'children' => ["$_extract"] - ], + // 提示 + $tips = '最低可提现额度:'.$extract_minimum_line.'元;最低提现金额:'.$extract_minimum_num.'元'; + $setRule = [ + ['type' => 'span','title' => '商户名称:','native' => FALSE,'children' => ["$merchant->mer_name"]], + ['type' => 'span','title' => '商户ID:','native' => FALSE,'children' => ["$merId"]], + ['type' => 'span','title' => '提示:','native' => FALSE,'children' => ["$tips"]], + ['type' => 'span','title' => '商户余额:','native' => FALSE,'children' => ["$merchant->mer_money"]], + ['type' => 'span','native' => FALSE,'title' => '商户可提现金额:','children' => ["$_extract"]], + Elm::radio('financial_type', '转账类型:', $merchant->financial_type)->setOptions([ + ['value' => 1, 'label' => '银行卡'], + ['value' => 2, 'label' => '微信'], + ['value' => 3, 'label' => '支付宝'], + ])->control([ + [ + 'value' => 1, + 'rule'=> [ + [ + 'type' => 'span', + 'title' => '姓名:', + 'native' => false, + 'children' => [$merchant->financial_bank->name??'未填写'] + ], + [ + 'type' => 'span', + 'title' => '开户银行:', + 'native' => false, + 'children' => [$merchant->financial_bank->bank??'未填写'] + ], + [ + 'type' => 'span', + 'title' => '银行卡号:', + 'native' => false, + 'children' => [$merchant->financial_bank->bank_code??'未填写'] + ], + ] + ], + [ + 'value' => 2, + 'rule'=> [ + [ + 'type' => 'span', + 'title' => '姓名:', + 'native' => false, + 'children' => [$merchant->financial_wechat->name??'未填写'] + ], + [ + 'type' => 'span', + 'title' => '微信号:', + 'native' => false, + 'children' => [$merchant->financial_wechat->wechat??'未填写'] + ], + [ + 'type' => 'img', + 'title' => '收款二维码:', + 'native' => false, + 'attrs' => ['src' => $merchant->financial_wechat->wechat_code ?? ''], + 'style' => ['width' => '86px','height' => '48px'] + ], + ] + ], + [ + 'value' => 3, + 'rule'=> [ + [ + 'type' => 'span', + 'title' => '姓名:', + 'native' => false, + 'children' => [$merchant->financial_alipay->name??'未填写'] + ], + [ + 'type' => 'span', + 'title' => '支付宝账号:', + 'native' => false, + 'children' => [$merchant->financial_alipay->alipay??'未填写'] + ], + [ + 'type' => 'img', + 'title' => '收款二维码:', + 'native' => false, + 'attrs' => ['src' => $merchant->financial_alipay->alipay_code ?? ''], + 'style' => ['width' => '86px','height' => '48px'] + ], + ] + ], + ]), + Elm::number('extract_money', '申请金额:')->value($extract_minimum_num)->required(), + ]; + // 手续费 + $merchantWithdrawalFees = (float)systemConfig('merchant_withdrawal_fees'); + if($merchantWithdrawalFees > 0){ + $setRule[] = ['type' => 'span','title' => '提现手续费比例:','native' => FALSE,'children' => ["$merchantWithdrawalFees%"]]; + } - Elm::radio('financial_type', '转账类型:', $merchant->financial_type) - ->setOptions([ - ['value' => 1, 'label' => '银行卡'], - ['value' => 2, 'label' => '微信'], - ['value' => 3, 'label' => '支付宝'], - ])->control([ - [ - 'value' => 1, - 'rule'=> [ - [ - 'type' => 'span', - 'title' => '姓名:', - 'native' => false, - 'children' => [$merchant->financial_bank->name??'未填写'] - ], - [ - 'type' => 'span', - 'title' => '开户银行:', - 'native' => false, - 'children' => [$merchant->financial_bank->bank??'未填写'] - ], - [ - 'type' => 'span', - 'title' => '银行卡号:', - 'native' => false, - 'children' => [$merchant->financial_bank->bank_code??'未填写'] - ], - ] - ], - [ - 'value' => 2, - 'rule'=> [ - [ - 'type' => 'span', - 'title' => '姓名:', - 'native' => false, - 'children' => [$merchant->financial_wechat->name??'未填写'] - ], - [ - 'type' => 'span', - 'title' => '微信号:', - 'native' => false, - 'children' => [$merchant->financial_wechat->wechat??'未填写'] - ], - [ - 'type' => 'img', - 'title' => '收款二维码:', - 'native' => false, - 'attrs' => ['src' => $merchant->financial_wechat->wechat_code ?? ''], - 'style' => ['width' => '86px','height' => '48px'] - ], - ] - ], - [ - 'value' => 3, - 'rule'=> [ - [ - 'type' => 'span', - 'title' => '姓名:', - 'native' => false, - 'children' => [$merchant->financial_alipay->name??'未填写'] - ], - [ - 'type' => 'span', - 'title' => '支付宝账号:', - 'native' => false, - 'children' => [$merchant->financial_alipay->alipay??'未填写'] - ], - [ - 'type' => 'img', - 'title' => '收款二维码:', - 'native' => false, - 'attrs' => ['src' => $merchant->financial_alipay->alipay_code ?? ''], - 'style' => ['width' => '86px','height' => '48px'] - ], - ] - ], - - ]), - Elm::number('extract_money', '申请金额:')->value($extract_minimum_num)->required(), - ]); + $form->setRule($setRule); return $form->setTitle('申请转账'); } @@ -282,21 +258,35 @@ class FinancialRepository extends BaseRepository if($_line < $extract_minimum_num) throw new ValidateException('提现金额不足'); $_money = bcsub($merchant['mer_money'],$data['extract_money'],2); + // 手续费 + $realityMoney = (float)$data['extract_money'];// 实际获得金额 + $merchantWithdrawalFees = (float)systemConfig('merchant_withdrawal_fees'); + $withdrawalFeesMoney = 0; + if($merchantWithdrawalFees > 0){ + // 手续费金额 + $withdrawalFeesMoney = (float)sprintf("%.2f",$data['extract_money'] * $merchantWithdrawalFees / 100); + // 实际获得金额 + $realityMoney = (float)sprintf("%.2f",$realityMoney - $withdrawalFeesMoney); + } $sn = date('YmdHis'.$merId); $ret = [ - 'status' => 0, - 'mer_id' => $merId, - 'mer_money' => $_money, - 'financial_sn' => $sn, - 'extract_money' => $data['extract_money'], - 'financial_type' => $data['financial_type'], - 'financial_account' => json_encode($financial_account,JSON_UNESCAPED_UNICODE), - 'financial_status' => 0, - 'mer_admin_id' => $data['mer_admin_id'], - 'mark' => $datap['mark']??'', - 'refusal' => '', + 'status' => 0, + 'mer_id' => $merId, + 'mer_money' => $_money, + 'financial_sn' => $sn, + 'extract_money' => $data['extract_money'], + 'withdrawal_fees' => $merchantWithdrawalFees ?? 0, + 'withdrawal_fees_money' => $withdrawalFeesMoney ?? 0, + 'reality_money' => $realityMoney, + 'financial_type' => $data['financial_type'], + 'financial_account' => json_encode($financial_account,JSON_UNESCAPED_UNICODE), + 'financial_status' => 0, + 'mer_admin_id' => $data['mer_admin_id'], + 'mark' => $datap['mark'] ?? '', + 'refusal' => '', ]; + Db::transaction(function()use($merId,$ret,$data,$make){ $this->dao->create($ret); $make->subMoney($merId,(float)$data['extract_money']);