feat(withdraw): 后台支持提现总开关与方式过滤并升级钱包与提现页面体验
这个提交包含在:
@@ -47,6 +47,9 @@ class Config extends Common
|
||||
}
|
||||
$config[self::getShortCode($row)] = $row->value;
|
||||
}
|
||||
if ($code === 'shop.recharge_withdraw.withdraw' && !isset($config['status'])) {
|
||||
$config['status'] = !empty($config['methods']) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
// 设置配置缓存
|
||||
cache("config:{$code}", $config);
|
||||
@@ -124,6 +127,19 @@ class Config extends Common
|
||||
$config->value = $value;
|
||||
$config->save();
|
||||
}
|
||||
} else {
|
||||
// 自动补齐缺失的提现开关配置项,确保热更新无缝落地
|
||||
if ($code === 'shop.recharge_withdraw.withdraw.status') {
|
||||
self::create([
|
||||
'code' => $code,
|
||||
'parent_code' => 'shop.recharge_withdraw.withdraw',
|
||||
'name' => '开启提现',
|
||||
'type' => 'boolean',
|
||||
'value' => (string)intval($value),
|
||||
'rule' => 'required',
|
||||
'weigh' => 50
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ class Withdraw extends Common
|
||||
'status_text',
|
||||
'charge_rate_format',
|
||||
'withdraw_info_hidden',
|
||||
'withdraw_info_display',
|
||||
'is_madow_withdraw',
|
||||
'withdraw_type_text',
|
||||
'wechat_transfer_state_text',
|
||||
];
|
||||
@@ -90,9 +92,84 @@ class Withdraw extends Common
|
||||
return bcmul((string)$value, '100', 1) . '%';
|
||||
}
|
||||
|
||||
public function getIsMadowWithdrawAttr($value, $data)
|
||||
{
|
||||
$info = $this->withdraw_info ?? ($data['withdraw_info'] ?? null);
|
||||
if (is_string($info)) {
|
||||
$info = json_decode($info, true) ?: [];
|
||||
}
|
||||
if (!is_array($info)) {
|
||||
return false;
|
||||
}
|
||||
return (isset($info['wallet_type']) && $info['wallet_type'] === 'madow')
|
||||
|| (isset($info['提现资产']) && strcasecmp($info['提现资产'], 'dmepa') === 0);
|
||||
}
|
||||
|
||||
public function getWithdrawInfoDisplayAttr($value, $data)
|
||||
{
|
||||
$info = $this->withdraw_info ?? ($data['withdraw_info'] ?? null);
|
||||
if (is_string($info)) {
|
||||
$info = json_decode($info, true) ?: [];
|
||||
}
|
||||
if (!is_array($info)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$display = [];
|
||||
$isMadow = (isset($info['wallet_type']) && $info['wallet_type'] === 'madow')
|
||||
|| (isset($info['提现资产']) && strcasecmp($info['提现资产'], 'dmepa') === 0);
|
||||
|
||||
if ($isMadow) {
|
||||
$display['提现资产'] = 'DMEPA';
|
||||
|
||||
// 扣除 DMEPA
|
||||
$madowAmount = $info['madow_amount'] ?? ($info['扣除DMEPA'] ?? ($info['扣除dmepa'] ?? null));
|
||||
if ($madowAmount !== null) {
|
||||
$madowClean = trim(str_ireplace(['dmepa', ' '], '', (string)$madowAmount));
|
||||
$display['扣除DMEPA'] = $madowClean . ' DMEPA';
|
||||
}
|
||||
|
||||
// 市值汇率
|
||||
$rate = $info['rate'] ?? ($info['市值汇率'] ?? ($info['折算汇率'] ?? null));
|
||||
if ($rate !== null) {
|
||||
if (is_numeric($rate)) {
|
||||
$rateClean = rtrim(rtrim(number_format((float)$rate, 12, '.', ''), '0'), '.');
|
||||
$display['市值汇率'] = '1 DMEPA ≈ ' . $rateClean . ' 元';
|
||||
} else {
|
||||
$rateStr = (string)$rate;
|
||||
$rateClean = trim(str_replace(['1 DMEPA ≈', '元/dmepa', '元/DMEPA', '元', ' '], '', $rateStr));
|
||||
$display['市值汇率'] = '1 DMEPA ≈ ' . $rateClean . ' 元';
|
||||
}
|
||||
}
|
||||
|
||||
// 换算市值
|
||||
$marketValue = $info['换算市值'] ?? ($data['amount'] ?? ($this->amount ?? null));
|
||||
if ($marketValue !== null) {
|
||||
$valClean = trim(str_replace(['元', ' '], '', (string)$marketValue));
|
||||
$display['换算市值'] = number_format((float)$valClean, 2, '.', '') . ' 元';
|
||||
}
|
||||
}
|
||||
|
||||
// 填充银行卡或其它常规账户信息,并过滤英文底层键
|
||||
$excludeKeys = ['wallet_type', 'madow_amount', 'rate', '提现资产', '扣除DMEPA', '扣除dmepa', '市值汇率', '折算汇率', '换算市值'];
|
||||
foreach ($info as $k => $v) {
|
||||
if (!in_array($k, $excludeKeys)) {
|
||||
$display[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
public function getWithdrawInfoHiddenAttr($value, $data)
|
||||
{
|
||||
$withdraw_info = $value ?: ($this->withdraw_info ?? null);
|
||||
if (is_string($withdraw_info)) {
|
||||
$withdraw_info = json_decode($withdraw_info, true) ?: [];
|
||||
}
|
||||
if (!is_array($withdraw_info)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($withdraw_info as $key => &$info) {
|
||||
if (in_array($key, ['微信用户', '真实姓名'])) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户