From 3868becc632dd0524e86e0082da9490f6c8715b5 Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 19 Sep 2026 15:41:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(withdraw):=20=E5=90=8E=E5=8F=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8F=90=E7=8E=B0=E6=80=BB=E5=BC=80=E5=85=B3=E4=B8=8E?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=BF=87=E6=BB=A4=E5=B9=B6=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E9=92=B1=E5=8C=85=E4=B8=8E=E6=8F=90=E7=8E=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Index.php | 1 + addons/shopro/service/Withdraw.php | 211 ++++++++++- .../admin/controller/shopro/Config.php | 82 ++++- application/admin/model/shopro/Config.php | 16 + application/admin/model/shopro/Withdraw.php | 77 ++++ .../admin/view/shopro/config/index.html | 67 +++- .../admin/view/shopro/withdraw/index.html | 44 ++- public/assets/js/backend/shopro/config.js | 55 ++- .../verify_admin_withdraw_display_unit.js | 145 ++++++++ tests/partner/verify_drawer_rules_spec.js | 169 +++++++++ tests/partner/verify_madow_withdraw_spec.js | 328 ++++++++++++++++++ ...verify_withdraw_methods_visibility_spec.js | 178 ++++++++++ tests/partner/verify_withdraw_switch_spec.js | 205 +++++++++++ tests/verify_wallet_money_spec.js | 9 +- .../pay/components/account-type-select.vue | 115 ++++-- uniapp/pages/pay/withdraw.vue | 201 ++++++++++- uniapp/pages/user/wallet/money.vue | 85 ++--- 17 files changed, 1872 insertions(+), 116 deletions(-) create mode 100644 tests/partner/verify_admin_withdraw_display_unit.js create mode 100644 tests/partner/verify_drawer_rules_spec.js create mode 100644 tests/partner/verify_madow_withdraw_spec.js create mode 100644 tests/partner/verify_withdraw_methods_visibility_spec.js create mode 100644 tests/partner/verify_withdraw_switch_spec.js diff --git a/addons/shopro/controller/Index.php b/addons/shopro/controller/Index.php index 272c2cd..421c67c 100644 --- a/addons/shopro/controller/Index.php +++ b/addons/shopro/controller/Index.php @@ -69,6 +69,7 @@ class Index extends Common 'bind_mobile' => $platformConfig['bind_mobile'] ?? 0, 'payment' => $platformConfig['payment']['methods'], 'recharge_payment' => sheep_config('shop.recharge_withdraw.recharge.methods'), // 充值支持的支付方式 + 'withdraw_status' => (bool)(intval(sheep_config('shop.recharge_withdraw.withdraw.status', !empty(sheep_config('shop.recharge_withdraw.withdraw.methods', [])) ? 1 : 0)) && !empty(sheep_config('shop.recharge_withdraw.withdraw.methods', []))), 'share' => $platformConfig['share'], ], 'template' => $template, diff --git a/addons/shopro/service/Withdraw.php b/addons/shopro/service/Withdraw.php index 42ccd42..0302b0d 100755 --- a/addons/shopro/service/Withdraw.php +++ b/addons/shopro/service/Withdraw.php @@ -13,6 +13,10 @@ use app\admin\model\shopro\ThirdOauth; use addons\shopro\service\Wallet as WalletService; use addons\shopro\library\pay\PayService; use app\admin\model\shopro\user\User; +use addons\shopro\service\partner\PartnerConfig; +use addons\shopro\service\partner\RateService; +use addons\shopro\service\partner\PartnerRewardService; +use app\admin\model\shopro\commission\Agent as AgentModel; class Withdraw { @@ -33,6 +37,10 @@ class Withdraw // 提现规则 $config = sheep_config('shop.recharge_withdraw.withdraw'); + // 提现开关与是否允许提现综合状态 + $config['status'] = isset($config['status']) ? intval($config['status']) : (!empty($config['methods']) ? 1 : 0); + $config['is_withdraw_open'] = (bool)($config['status'] === 1 && !empty($config['methods'])); + $config['min_amount'] = $config['min_amount'] == 0 ? $config['min_amount'] : number_format(floatval($config['min_amount']), 2, '.', ''); $config['max_amount'] = $config['max_amount'] == 0 ? $config['max_amount'] : number_format(floatval($config['max_amount']), 2, '.', ''); $config['charge_rate_format'] = round(floatval($config['charge_rate']), 1); // 1 位小数 @@ -45,10 +53,15 @@ class Withdraw // 发起提现申请 public function apply($params) { - $type = $params['type']; + $walletType = $params['wallet_type'] ?? 'commission'; + $type = $params['type'] ?? ''; $money = $params['money'] ?? 0; $money = (string)$money; + if ($walletType === 'madow') { + return $this->applyMadow($params, $type, $money); + } + // 手续费 $charge = bcmul($money, (string)$this->config['charge_rate'], 2); @@ -83,6 +96,104 @@ class Withdraw return $withdraw; } + // 发起 dmepa 提现申请 + protected function applyMadow($params, $type, $money) + { + if (!PartnerConfig::isMadowWithdrawEnabled()) { + throw new ShoproException('dmepa提现功能暂未开启'); + } + + if ($type !== 'bank') { + throw new ShoproException('dmepa提现仅支持银行卡转账'); + } + + if (floatval($money) <= 0) { + throw new ShoproException('请输入正确的提现金额'); + } + + $minAmount = PartnerConfig::madowWithdrawMin(); + if ($minAmount > 0 && floatval($money) < $minAmount) { + throw new ShoproException('提现金额不能少于 ' . $minAmount . '元'); + } + + $rate = (new RateService())->currentRate(); + if ($rate <= 0) { + throw new ShoproException('当前dmepa暂无有效市值汇率,无法发起提现'); + } + + // 计算需扣除的 dmepa = 金额 / 汇率 + $rateStr = number_format($rate, 12, '.', ''); + $deductMadow = function_exists('bcdiv') ? bcdiv($money, $rateStr, 4) : number_format(floatval($money) / $rate, 4, '.', ''); + if (floatval($deductMadow) <= 0) { + throw new ShoproException('折算dmepa数量不足'); + } + + // 检查合伙人资产 + $agent = AgentModel::where('user_id', $this->user->id)->lock(true)->find(); + if (!$agent) { + throw new ShoproException('未找到您的合伙资产账户'); + } + + $currentMadow = strval($agent->madow ?? 0); + if (bccomp($currentMadow, $deductMadow, 4) < 0) { + throw new ShoproException('持仓dmepa不足,无法提现'); + } + + // 校验银行卡信息 + $withdrawInfo = $this->getAccountInfo($type, $params); + $rateClean = rtrim(rtrim(number_format((float)$rate, 12, '.', ''), '0'), '.'); + $moneyClean = number_format((float)$money, 2, '.', ''); + $withdrawInfo['提现资产'] = 'DMEPA'; + $withdrawInfo['扣除DMEPA'] = $deductMadow . ' DMEPA'; + $withdrawInfo['市值汇率'] = '1 DMEPA ≈ ' . $rateClean . ' 元'; + $withdrawInfo['换算市值'] = $moneyClean . ' 元'; + $withdrawInfo['wallet_type'] = 'madow'; + $withdrawInfo['madow_amount'] = $deductMadow; + $withdrawInfo['rate'] = $rate; + + // 扣减 dmepa + $agent->setDec('madow', $deductMadow); + + // 创建提现记录 + $withdraw = new WithdrawModel(); + $withdraw->user_id = $this->user->id; + $withdraw->amount = $money; + $withdraw->charge_fee = 0; + $withdraw->charge_rate = 0; + $withdraw->withdraw_sn = get_sn($this->user->id, 'W'); + $withdraw->withdraw_type = 'bank'; + $withdraw->withdraw_info = $withdrawInfo; + $withdraw->status = 0; + $withdraw->platform = request()->header('platform'); + $withdraw->save(); + + // 记录合伙人流水 + PartnerRewardService::write([ + 'order_id' => -$withdraw->id, + 'buyer_id' => $this->user->id, + 'user_id' => $this->user->id, + 'role' => 'partner', + 'reward_type' => 'madow_withdraw', + 'amount' => -$money, + 'madow' => -$deductMadow, + 'base_amount' => $money, + 'rate' => $rate, + 'ext' => [ + 'withdraw_sn' => $withdraw->withdraw_sn, + 'withdraw_id' => $withdraw->id, + 'deduct_madow' => $deductMadow, + 'cny_amount' => $money, + 'rate' => $rate, + ], + 'settle_date' => date('Y-m-d'), + 'status' => 1, + ]); + + $this->handleLog($withdraw, '用户发起dmepa提现申请(扣除 ' . $deductMadow . ' dmepa)', $this->user); + + return $withdraw; + } + // 继续提现 public function retry($params) @@ -256,6 +367,51 @@ class Withdraw $withdraw->status = -1; $withdraw->save(); + if (!$this->user && !empty($withdraw->user_id)) { + $this->user = User::get($withdraw->user_id); + } + $userId = $this->user ? $this->user->id : intval($withdraw->user_id); + + $info = $withdraw->withdraw_info; + if (is_string($info)) { + $info = json_decode($info, true) ?: []; + } + $isMadow = (isset($info['wallet_type']) && $info['wallet_type'] === 'madow') + || (isset($info['提现资产']) && strcasecmp($info['提现资产'], 'dmepa') === 0); + + if ($isMadow) { + $madowRefund = $info['madow_amount'] ?? ($info['扣除DMEPA'] ?? ($info['扣除dmepa'] ?? 0)); + if (is_string($madowRefund)) { + $madowRefund = trim(str_ireplace(['dmepa', ' '], '', $madowRefund)); + } + if (floatval($madowRefund) > 0) { + $agent = AgentModel::where('user_id', $userId)->lock(true)->find(); + if ($agent) { + $agent->setInc('madow', $madowRefund); + } + PartnerRewardService::write([ + 'order_id' => -$withdraw->id, + 'buyer_id' => $userId, + 'user_id' => $userId, + 'role' => 'partner', + 'reward_type' => 'madow_withdraw_refund', + 'amount' => $withdraw->amount, + 'madow' => $madowRefund, + 'base_amount' => $withdraw->amount, + 'rate' => $info['rate'] ?? 0, + 'ext' => [ + 'withdraw_sn' => $withdraw->withdraw_sn, + 'withdraw_id' => $withdraw->id, + 'refund_madow' => $madowRefund, + 'refuse_msg' => $refuse_msg, + ], + 'settle_date' => date('Y-m-d'), + 'status' => 1, + ]); + } + return $this->handleLog($withdraw, '拒绝:' . $refuse_msg . ',已退还扣除的 ' . $madowRefund . ' dmepa'); + } + // 退回用户佣金 WalletService::change($this->user, 'commission', bcadd($withdraw->charge_fee, $withdraw->amount, 2), 'withdraw_error', [ 'withdraw_id' => $withdraw->id, @@ -277,6 +433,51 @@ class Withdraw $withdraw->status = $status; $withdraw->save(); + if (!$this->user && !empty($withdraw->user_id)) { + $this->user = User::get($withdraw->user_id); + } + $userId = $this->user ? $this->user->id : intval($withdraw->user_id); + + $info = $withdraw->withdraw_info; + if (is_string($info)) { + $info = json_decode($info, true) ?: []; + } + $isMadow = (isset($info['wallet_type']) && $info['wallet_type'] === 'madow') + || (isset($info['提现资产']) && strcasecmp($info['提现资产'], 'dmepa') === 0); + + if ($isMadow) { + $madowRefund = $info['madow_amount'] ?? ($info['扣除DMEPA'] ?? ($info['扣除dmepa'] ?? 0)); + if (is_string($madowRefund)) { + $madowRefund = trim(str_ireplace(['dmepa', ' '], '', $madowRefund)); + } + if (floatval($madowRefund) > 0) { + $agent = AgentModel::where('user_id', $userId)->lock(true)->find(); + if ($agent) { + $agent->setInc('madow', $madowRefund); + } + PartnerRewardService::write([ + 'order_id' => -$withdraw->id, + 'buyer_id' => $userId, + 'user_id' => $userId, + 'role' => 'partner', + 'reward_type' => 'madow_withdraw_refund', + 'amount' => $withdraw->amount, + 'madow' => $madowRefund, + 'base_amount' => $withdraw->amount, + 'rate' => $info['rate'] ?? 0, + 'ext' => [ + 'withdraw_sn' => $withdraw->withdraw_sn, + 'withdraw_id' => $withdraw->id, + 'refund_madow' => $madowRefund, + 'fail_msg' => $refuse_msg, + ], + 'settle_date' => date('Y-m-d'), + 'status' => 1, + ]); + } + return $this->handleLog($withdraw, '提现失败,已退还 ' . $madowRefund . ' dmepa:' . $refuse_msg); + } + // 退回用户佣金 WalletService::change($this->user, 'commission', bcadd($withdraw->charge_fee, $withdraw->amount, 2), 'withdraw_error', [ 'withdraw_id' => $withdraw->id, @@ -412,6 +613,14 @@ class Withdraw // 提现条件检查 private function checkApply($type, $money, $charge) { + if (isset($this->config['status']) && intval($this->config['status']) === 0) { + throw new ShoproException('系统提现功能已关闭'); + } + + if (empty($this->config['methods'])) { + throw new ShoproException('暂未开启任何提现方式'); + } + if (!in_array($type, $this->config['methods'])) { throw new ShoproException('暂不支持该提现方式'); } diff --git a/application/admin/controller/shopro/Config.php b/application/admin/controller/shopro/Config.php index 8415e02..778d94b 100644 --- a/application/admin/controller/shopro/Config.php +++ b/application/admin/controller/shopro/Config.php @@ -195,21 +195,39 @@ class Config extends Common 'partner_mode', 'partner_enable', 'partner_count_type', 'partner_active_days', 'partner_chain_max_depth', 'partner_push3_amounts', 'partner_madow_mode', 'partner_show_madow_rate', - 'partner_madow_base_rate', 'partner_madow_step_orders', 'partner_voucher_times', - 'partner_voucher_days', 'partner_maker_bonus', 'partner_maker_peer_rate', + 'partner_madow_base_rate', 'partner_madow_step_orders', + 'partner_madow_rule_title', 'partner_madow_rules', + 'partner_madow_withdraw_enable', 'partner_madow_withdraw_min', + 'partner_voucher_times', 'partner_voucher_days', + 'partner_voucher_rule_title', 'partner_voucher_rules', + 'partner_maker_bonus', 'partner_maker_peer_rate', 'partner_maker_overtaken_rate', 'partner_team_total', 'partner_venue_split', 'partner_county_full', 'partner_venue_share_per_order', 'partner_county_share_per_order', 'partner_venue_peer_rate', 'partner_county_peer_rate', 'partner_role_name_taster', 'partner_role_name_maker', 'partner_role_name_venue', 'partner_role_name_county', 'partner_role_name_partner', ]; + $ruleDefaults = [ + 'partner_madow_rule_title' => '市值与增值规则', + 'partner_madow_rules' => [ + ['title' => 'dmepa获取与核算', 'desc' => '平台合伙人与创客达成考核或完成订单后,系统将于次日 00:30 起统一参与每日dmepa加权核算并自动分发。'], + ['title' => '市值动态增值', 'desc' => '市值随全平台订单增加而上浮增值。全网完成订单总量越多,dmepa单价所对应的市值越高,共享生态红利。'], + ['title' => '价值说明与权益', 'desc' => '市值仅作为平台数字生态资产价值参考展示,不可直接兑换现金提现。具体权益按平台股东与合伙人章程执行。'], + ], + 'partner_voucher_rule_title' => '兑换券释放与使用规则', + 'partner_voucher_rules' => [ + ['title' => '赠送与释放天数', 'desc' => '会员在平台完成符合条件的商城订单后,系统将按订单金额(默认 1.5 倍)生成兑换券计划,分 365 天按日线性释放。'], + ['title' => '每日自动到账', 'desc' => '系统将于次日 00:30 起统一执行日结核算,按期释放的兑换券将自动计入您的「可用兑换券」账户,无需手动领取。'], + ['title' => '全场购物直接抵扣', 'desc' => '可用兑换券可在平台商城下单结算时作为现金抵扣使用,尊享优惠抵扣权益。'], + ], + ]; if ('GET' === $this->request->method()) { $all = ShoproConfig::getConfigs('shop.commission', false) ?: []; $configs = []; foreach ($keys as $key) { $configs[$key] = $all[$key] ?? null; } - $defaults = [ + $defaults = array_merge([ 'partner_mode' => 1, 'partner_enable' => 1, 'partner_count_type' => 'order', @@ -218,6 +236,8 @@ class Config extends Common 'partner_push3_amounts' => [398, 400, 600], 'partner_madow_mode' => 'madow', 'partner_show_madow_rate' => 1, + 'partner_madow_withdraw_enable' => 1, + 'partner_madow_withdraw_min' => 1, 'partner_madow_base_rate' => '0.00000075', 'partner_madow_step_orders' => 1, 'partner_voucher_times' => 1.5, @@ -237,13 +257,23 @@ class Config extends Common 'partner_role_name_venue' => '酒道馆', 'partner_role_name_county' => '区县代理', 'partner_role_name_partner' => '合伙股东', - ]; + ], $ruleDefaults); foreach ($defaults as $key => $value) { if ($configs[$key] === null || $configs[$key] === '') { $configs[$key] = $value; } } $configs['partner_show_madow_rate'] = isset($configs['partner_show_madow_rate']) ? intval($configs['partner_show_madow_rate']) : 1; + $configs['partner_madow_withdraw_enable'] = isset($configs['partner_madow_withdraw_enable']) ? intval($configs['partner_madow_withdraw_enable']) : 1; + $configs['partner_madow_withdraw_min'] = isset($configs['partner_madow_withdraw_min']) ? floatval($configs['partner_madow_withdraw_min']) : 1.0; + foreach (['partner_madow_rules', 'partner_voucher_rules'] as $ruleKey) { + if (isset($configs[$ruleKey]) && is_string($configs[$ruleKey])) { + $decoded = json_decode($configs[$ruleKey], true); + if (is_array($decoded)) { + $configs[$ruleKey] = $decoded; + } + } + } } elseif ('POST' === $this->request->method()) { check_env('commission'); $params = $this->request->param(); @@ -256,6 +286,12 @@ class Config extends Common if (isset($save['partner_show_madow_rate'])) { $save['partner_show_madow_rate'] = intval($save['partner_show_madow_rate']); } + if (isset($save['partner_madow_withdraw_enable'])) { + $save['partner_madow_withdraw_enable'] = intval($save['partner_madow_withdraw_enable']); + } + if (isset($save['partner_madow_withdraw_min'])) { + $save['partner_madow_withdraw_min'] = max(0.0, floatval($save['partner_madow_withdraw_min'])); + } // 确保数据库存在 partner_show_madow_rate 配置行 $existConfig = ShoproConfig::where('code', 'shop.commission.partner_show_madow_rate')->find(); if (!$existConfig) { @@ -269,6 +305,29 @@ class Config extends Common 'weigh' => 86 ]); } + // 确保数据库存在规则条目等必要配置行 + $ensureConfigs = [ + 'shop.commission.partner_madow_withdraw_enable' => ['name' => '开启dmepa提现', 'desc' => '1=开启 0=关闭', 'type' => 'int', 'value' => '1', 'weigh' => 86], + 'shop.commission.partner_madow_withdraw_min' => ['name' => 'dmepa最低提现金额', 'desc' => 'dmepa最低提现金额(元)', 'type' => 'number', 'value' => '1', 'weigh' => 86], + 'shop.commission.partner_madow_rule_title' => ['name' => 'dmepa规则弹窗标题', 'desc' => '我的dmepa市值规则弹窗标题', 'type' => 'string', 'value' => '市值与增值规则', 'weigh' => 86], + 'shop.commission.partner_madow_rules' => ['name' => 'dmepa规则说明条目', 'desc' => '我的dmepa市值规则条目', 'type' => 'array', 'value' => json_encode($ruleDefaults['partner_madow_rules'], JSON_UNESCAPED_UNICODE), 'weigh' => 86], + 'shop.commission.partner_voucher_rule_title' => ['name' => '兑换券规则弹窗标题', 'desc' => '兑换券规则弹窗标题', 'type' => 'string', 'value' => '兑换券释放与使用规则', 'weigh' => 89], + 'shop.commission.partner_voucher_rules' => ['name' => '兑换券规则说明条目', 'desc' => '兑换券规则条目', 'type' => 'array', 'value' => json_encode($ruleDefaults['partner_voucher_rules'], JSON_UNESCAPED_UNICODE), 'weigh' => 89], + ]; + foreach ($ensureConfigs as $confCode => $confMeta) { + $existConfig = ShoproConfig::where('code', $confCode)->find(); + if (!$existConfig) { + ShoproConfig::create([ + 'code' => $confCode, + 'parent_code' => 'shop.commission', + 'name' => $confMeta['name'], + 'description' => $confMeta['desc'], + 'type' => $confMeta['type'], + 'value' => $confMeta['value'], + 'weigh' => $confMeta['weigh'], + ]); + } + } foreach (['partner_role_name_taster', 'partner_role_name_maker', 'partner_role_name_venue', 'partner_role_name_county', 'partner_role_name_partner'] as $roleKey) { if (isset($save[$roleKey])) { $save[$roleKey] = trim((string) $save[$roleKey]); @@ -346,6 +405,13 @@ class Config extends Common if ('GET' === $this->request->method()) { $configs = ShoproConfig::getConfigs('shop.recharge_withdraw', false); + if ($configs && isset($configs['withdraw'])) { + if (!isset($configs['withdraw']['status'])) { + $configs['withdraw']['status'] = !empty($configs['withdraw']['methods']) ? 1 : 0; + } else { + $configs['withdraw']['status'] = intval($configs['withdraw']['status']); + } + } } elseif ('POST' === $this->request->method()) { $params = $this->request->param(); if (!isset($params['recharge']['methods'])) { @@ -357,7 +423,15 @@ class Config extends Common if (!isset($params['withdraw']['methods'])) { $params['withdraw']['methods'] = []; } + if (!isset($params['withdraw']['status'])) { + $params['withdraw']['status'] = 0; + } else { + $params['withdraw']['status'] = intval($params['withdraw']['status']); + } $configs = ShoproConfig::setConfigs('shop.recharge_withdraw', $params); + if ($configs && isset($configs['withdraw'])) { + $configs['withdraw']['status'] = isset($configs['withdraw']['status']) ? intval($configs['withdraw']['status']) : (!empty($configs['withdraw']['methods']) ? 1 : 0); + } } $this->success('操作成功', null, $configs); } diff --git a/application/admin/model/shopro/Config.php b/application/admin/model/shopro/Config.php index 5209a45..82b2d34 100644 --- a/application/admin/model/shopro/Config.php +++ b/application/admin/model/shopro/Config.php @@ -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 + ]); + } } } diff --git a/application/admin/model/shopro/Withdraw.php b/application/admin/model/shopro/Withdraw.php index a7b831d..f9e4e0c 100644 --- a/application/admin/model/shopro/Withdraw.php +++ b/application/admin/model/shopro/Withdraw.php @@ -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, ['微信用户', '真实姓名'])) { diff --git a/application/admin/view/shopro/config/index.html b/application/admin/view/shopro/config/index.html index ec788ec..5da8c40 100644 --- a/application/admin/view/shopro/config/index.html +++ b/application/admin/view/shopro/config/index.html @@ -576,6 +576,21 @@ - + @@ -78,12 +93,21 @@ diff --git a/uniapp/pages/pay/withdraw.vue b/uniapp/pages/pay/withdraw.vue index 84a02f3..5ec6f39 100644 --- a/uniapp/pages/pay/withdraw.vue +++ b/uniapp/pages/pay/withdraw.vue @@ -1,5 +1,5 @@