diff --git a/application/admin/controller/fc/Withdraw.php b/application/admin/controller/fc/Withdraw.php index cd27ad9..0fa9f11 100644 --- a/application/admin/controller/fc/Withdraw.php +++ b/application/admin/controller/fc/Withdraw.php @@ -281,6 +281,24 @@ class Withdraw extends Backend } } + // 单笔精准反馈文案 + if (count($withdraws) === 1) { + $row = $withdraws[0]; + if ($errors) { + $this->error('同步失败:' . $errors[0]); + } + $latest = Db::name('fc_withdraw')->where('id', $row['id'])->find(); + $transferStatus = (string)$latest['transfer_status']; + $stText = $transferStatus === 'WAIT_USER_CONFIRM' ? '待收款用户确认' : ($transferStatus === 'SUCCESS' ? '已转账成功' : ($transferStatus ?: '处理中')); + if ($latest['status'] === 'paid') { + $this->success('微信转账已完成,单据已更新为「已成功到账」'); + } elseif ($latest['status'] === 'failed') { + $this->error('微信转账已失败/已撤销:' . ($latest['fail_reason'] ?: '未知原因')); + } else { + $this->success('已同步微信最新状态:' . $stText . '(微信已受理,需收款人在微信完成确认方可到账)'); + } + } + $msg = '状态同步完成:'; if ($successCount > 0) { $msg .= $successCount . ' 笔已确认到账;'; @@ -297,4 +315,33 @@ class Withdraw extends Backend $this->success($msg); } + + /** + * 撤销「转账中」的微信转账提现单 + * + * @return void + */ + public function cancel() + { + $id = (int)$this->request->post('id', 0); + if ($id <= 0) { + $this->error('参数错误'); + } + + $withdraw = Db::name('fc_withdraw')->where('id', $id)->find(); + if (!$withdraw) { + $this->error('提现记录不存在'); + } + if ((string)$withdraw['status'] !== 'paying') { + $this->error('只有处于「转账中」的记录方可撤销(当前:' . $withdraw['status'] . ')'); + } + + try { + $state = \app\common\library\WxTransfer::cancel($id); + } catch (\Throwable $e) { + $this->error('撤销失败:' . $e->getMessage()); + } + + $this->success('转账已成功撤销,款项额度已自动退回用户可提现余额'); + } } diff --git a/application/admin/view/fc/withdraw/edit.html b/application/admin/view/fc/withdraw/edit.html index b5d28d7..9561bfe 100644 --- a/application/admin/view/fc/withdraw/edit.html +++ b/application/admin/view/fc/withdraw/edit.html @@ -216,6 +216,9 @@ + {/if} diff --git a/application/api/controller/Distribution.php b/application/api/controller/Distribution.php index 28eb200..25cd89d 100644 --- a/application/api/controller/Distribution.php +++ b/application/api/controller/Distribution.php @@ -376,6 +376,57 @@ class Distribution extends V1 $this->ok($list); } + /** + * D8 提现单详情 + * GET /api/v1/distribution/withdraw-detail 入参 {id|withdrawNo} + * + * @return void 输出提现流水单据详细信息JSON + */ + public function withdrawDetail() + { + $user = $this->auth(); + $id = (int)$this->input('id', 0); + $no = trim((string)$this->input('withdrawNo', '')); + + $query = Db::name('fc_withdraw')->where('user_id', $user['id']); + if ($id > 0) { + $query->where('id', $id); + } elseif ($no !== '') { + $query->where('withdraw_no', $no); + } else { + $this->fail('参数错误'); + } + + $row = $query->find(); + if (!$row) { + $this->fail('提现记录不存在'); + } + + $epay = (array)get_addon_config('epay'); + $wx = isset($epay['wechat']) && is_array($epay['wechat']) ? $epay['wechat'] : []; + $mchId = isset($wx['mch_id']) ? (string)$wx['mch_id'] : '1118898018'; + $appId = isset($wx['miniapp_id']) ? (string)$wx['miniapp_id'] : 'wxbfcb778f3019cff8'; + + $this->ok([ + 'id' => (int)$row['id'], + 'withdrawNo' => (string)$row['withdraw_no'], + 'amount' => round((float)$row['amount'], 2), + 'channel' => (string)$row['channel'], + 'status' => (string)$row['status'], + 'reason' => (string)$row['reason'], + 'outBillNo' => (string)$row['out_bill_no'], + 'transferStatus' => (string)$row['transfer_status'], + 'transferId' => (string)$row['transfer_id'], + 'packageInfo' => (string)$row['package_info'], + 'failReason' => (string)$row['fail_reason'], + 'createdAt' => $this->iso($row['createtime']), + 'payTime' => !empty($row['paytime']) ? $this->iso($row['paytime']) : '', + 'transferTime' => !empty($row['transfer_time']) ? $this->iso($row['transfer_time']) : '', + 'transferMchId' => $mchId, + 'transferAppId' => $appId, + ]); + } + /** * D7 手动输入邀请码补绑推荐人(老用户不支持自动补绑,仅支持通过手动填写邀请码完成补绑) * POST /api/v1/distribution/bind 入参 {inviteCode} diff --git a/application/route.php b/application/route.php index b650e19..306dced 100755 --- a/application/route.php +++ b/application/route.php @@ -103,6 +103,7 @@ return [ 'api/v1/distribution/poster' => 'api/Distribution/poster', 'api/v1/distribution/withdraw' => 'api/Distribution/withdraw', 'api/v1/distribution/withdraw-records' => 'api/Distribution/withdrawRecords', + 'api/v1/distribution/withdraw-detail' => 'api/Distribution/withdrawDetail', 'api/v1/distribution/bind' => 'api/Distribution/bind', /* =============== 六、用户端 · 消息中心(Module-MESSAGE) =============== */ diff --git a/public/assets/js/backend/fc/withdraw.js b/public/assets/js/backend/fc/withdraw.js index cb1f65b..a8cb6d7 100644 --- a/public/assets/js/backend/fc/withdraw.js +++ b/public/assets/js/backend/fc/withdraw.js @@ -174,6 +174,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu return true; }); } + }, + { + name: 'cancel', + text: '撤销', + title: '撤销微信转账', + classname: 'btn btn-xs btn-danger btn-click', + icon: 'fa fa-times-circle', + visible: function (row) { + return row.status === 'paying'; + }, + click: function (options, row) { + Layer.confirm('确认撤销提现单「' + row.withdraw_no + '」的微信转账?
撤销后微信转账单将失效,款项额度自动退回用户可提现余额。', { + title: '撤销转账单确认', + icon: 3, + btn: ['确认撤销', '取消'] + }, function (index) { + Layer.close(index); + var loadIdx = Layer.load(1); + Fast.api.ajax({ + url: 'fc/withdraw/cancel', + data: {id: row.id} + }, function (data, ret) { + Layer.close(loadIdx); + Toastr.success(ret.msg || '转账已撤销'); + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }, function () { + Layer.close(loadIdx); + return true; + }); + }); + } } ] } @@ -292,6 +324,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu return true; }); }); + + // 4. 撤销微信转账单 + $(document).on('click', '.btn-action-cancel', function () { + var id = $(this).data('id'); + var no = $(this).data('no'); + + Layer.confirm('确认撤销提现单「' + no + '」的微信转账?
撤销后微信转账单失效,款项额度将自动退回用户可提现余额。', { + title: '撤销转账单确认', + icon: 3, + btn: ['确认撤销', '取消'] + }, function (index) { + Layer.close(index); + var loadIdx = Layer.load(1); + Fast.api.ajax({ + url: 'fc/withdraw/cancel', + data: {id: id} + }, function (data, ret) { + Layer.close(loadIdx); + Toastr.success(ret.msg || '转账已撤销'); + setTimeout(function () { + Fast.api.close(); + parent.$("#table").bootstrapTable('refresh'); + }, 1200); + return false; + }, function () { + Layer.close(loadIdx); + return true; + }); + }); + }); }, api: { diff --git a/tools/deploy_withdraw_cancel.py b/tools/deploy_withdraw_cancel.py new file mode 100644 index 0000000..529e8f5 --- /dev/null +++ b/tools/deploy_withdraw_cancel.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +部署最新修改到线上服务器: +- application/admin/controller/fc/Withdraw.php +- application/admin/view/fc/withdraw/edit.html +- application/api/controller/Distribution.php +- application/route.php +- public/assets/js/backend/fc/withdraw.js +""" + +import os +import sys +import io +import paramiko + +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') + +HOST = "8.137.181.63" +PORT = 22 +USER = "root" +PASSWORD = "liyanxia@6688" +REMOTE_ROOT = "/www/wwwroot/fenleixinxi.gzyakj.com.cn" +LOCAL_ROOT = r"D:\Softwares\phpstudy_pro\WWW\fenleixinxi" + +SYNC_FILES = [ + "application/admin/controller/fc/Withdraw.php", + "application/admin/view/fc/withdraw/edit.html", + "application/api/controller/Distribution.php", + "application/route.php", + "public/assets/js/backend/fc/withdraw.js", +] + +def ssh_exec(client, cmd): + stdin, stdout, stderr = client.exec_command(cmd) + out = stdout.read().decode("utf-8", errors="replace").strip() + err = stderr.read().decode("utf-8", errors="replace").strip() + return out, err + +def main(): + print("=== [1/3] 连接线上服务器 ===") + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + client.connect(HOST, port=PORT, username=USER, password=PASSWORD, timeout=30) + print(f"✓ 成功连接 {HOST}") + + sftp = client.open_sftp() + print("✓ SFTP 通道已建立") + + print("\n=== [2/3] 上传最新修改文件 ===") + for rel_path in SYNC_FILES: + local_path = os.path.join(LOCAL_ROOT, rel_path.replace("/", "\\")) + remote_path = f"{REMOTE_ROOT}/{rel_path}" + + if not os.path.exists(local_path): + print(f" ✗ 本地文件缺失: {local_path}") + continue + + remote_dir = os.path.dirname(remote_path) + ssh_exec(client, f"mkdir -p '{remote_dir}'") + + sftp.put(local_path, remote_path) + ssh_exec(client, f"chown www:www '{remote_path}'") + file_size = os.path.getsize(local_path) + print(f" ✓ 已同步: {rel_path} ({file_size} 字节)") + + sftp.close() + + print("\n=== [3/3] 清理缓存与服务自检 ===") + ssh_exec(client, f"rm -rf {REMOTE_ROOT}/runtime/temp/* {REMOTE_ROOT}/runtime/cache/*") + print("✓ 线上 ThinkPHP 运行时缓存清理完成") + + # 服务健康自检 + check_urls = [ + ("API 信息流接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/feed"), + ("API 分类接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/categories"), + ("API 提现详情接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/distribution/withdraw-detail"), + ("后台登录页面", "https://fenleixinxi.gzyakj.com.cn/s.php/index/login"), + ] + for name, url in check_urls: + cmd = f"curl -s -o /dev/null -w '%{{http_code}}' -k '{url}'" + code, _ = ssh_exec(client, cmd) + print(f" {name}: HTTP {code}") + + client.close() + print("\n✓ 最新代码已全部部署至线上服务器!") + +if __name__ == "__main__": + main() diff --git a/uniapp/common/api/distribution.js b/uniapp/common/api/distribution.js index b53f6f5..2ce4f10 100644 --- a/uniapp/common/api/distribution.js +++ b/uniapp/common/api/distribution.js @@ -17,6 +17,8 @@ export const distributionApi = { withdraw: (payload) => post('/distribution/withdraw', payload, { silent: true }), /** 提现记录 */ withdrawRecords: () => get('/distribution/withdraw-records', {}, { silent: true }), + /** 提现单详情 */ + withdrawDetail: (params = {}) => get('/distribution/withdraw-detail', params, { silent: true }), /** 绑定分销推荐人(扫码自动补绑 / 手动填写邀请码绑定) */ bind: (payload = {}) => post('/distribution/bind', payload, { silent: true }), } diff --git a/uniapp/pages.json b/uniapp/pages.json index c22ae74..e83d454 100644 --- a/uniapp/pages.json +++ b/uniapp/pages.json @@ -165,6 +165,14 @@ "enablePullDownRefresh": true } }, + { + "path": "pages/distribution/withdraw-detail", + "style": { + "navigationBarTitleText": "提现详情", + "navigationStyle": "custom", + "backgroundColor": "#f2fef7" + } + }, { "path": "pages/admin/setting", "style": { diff --git a/uniapp/pages/distribution/index.vue b/uniapp/pages/distribution/index.vue index 0c5461c..0eb7f6b 100644 --- a/uniapp/pages/distribution/index.vue +++ b/uniapp/pages/distribution/index.vue @@ -329,7 +329,7 @@ - + 提现到微信零钱 @@ -343,9 +343,10 @@ -¥{{ money(w.amount) }} - - {{ w.transferStatus === 'WAIT_USER_CONFIRM' ? '去确认收款' : '转账中' }} + + {{ w.transferStatus === 'WAIT_USER_CONFIRM' ? (w.packageInfo ? '去确认收款' : '查看详情') : '转账中' }} + › @@ -358,6 +359,65 @@ + + + + + + 提现单详情 + + ✕ + + + + + + -¥ + {{ money(activeWithdrawItem.amount) }} + + + {{ statusText(activeWithdrawItem.status) }} + · {{ activeWithdrawItem.transferStatus === 'WAIT_USER_CONFIRM' ? '待确认' : '处理中' }} + + + + ⚠️ 该单据未获取到直接确认凭据。请联系管理员在后台点击「撤销」,撤销后额度将恢复,您可重新发起提现。 + + + + + 提现渠道 + 微信零钱(商家转账) + + + 提现单号 + + {{ activeWithdrawItem.withdrawNo }} + 复制 + + + + 申请时间 + {{ timeText(activeWithdrawItem.createdAt) }} + + + 失败说明 + {{ activeWithdrawItem.failReason }} + + + + + + + + @@ -611,6 +671,8 @@ export default { commissionStatus: '', minWithdraw: 50, showWithdraw: false, + showDetailModal: false, + activeWithdrawItem: null, showRuleModal: false, showBindModal: false, bindCodeInput: '', @@ -1569,9 +1631,26 @@ export default { * 拉起微信「确认收款」页(商家转账模式) * @param {Object} w 提现记录项 */ + /** + * 跳转到提现单详情页 + * @param {Object} w 提现记录项 + */ + goWithdrawDetail(w) { + if (!w) return + this.activeWithdrawItem = w + uni.navigateTo({ + url: `/pages/distribution/withdraw-detail?id=${w.id || 0}&no=${w.withdrawNo || ''}`, + fail: (err) => { + console.warn('[WithdrawDetail] 独立页面跳转失败,激活内置详情抽屉:', err) + this.showDetailModal = true + }, + }) + }, + confirmTransfer(w) { if (!w || !w.packageInfo) { - uni.showToast({ title: '转账处理中,请稍后刷新重试', icon: 'none' }) + // 未获取到确认 package 时直接引导跳转详情页查看排查指引 + this.goWithdrawDetail(w) return } // 优先使用微信原生 API(wx.requestMerchantTransfer 为微信基础库 3.3.0+ 商家转账确认专属 API) @@ -2343,6 +2422,96 @@ export default { font-size: 20rpx; font-weight: 700; } +.dist__detail-content { + padding: 20rpx 0 30rpx; + display: flex; + flex-direction: column; + align-items: center; +} +.dist__detail-hero { + display: flex; + align-items: baseline; + margin-top: 10rpx; + color: #1E293B; +} +.dist__detail-symbol { + font-size: 36rpx; + font-weight: 700; + margin-right: 4rpx; +} +.dist__detail-amount { + font-size: 64rpx; + font-weight: 800; +} +.dist__detail-status-tag { + margin-top: 12rpx; + padding: 6rpx 20rpx; + border-radius: 999rpx; + font-size: 24rpx; + font-weight: 600; +} +.dist__detail-warn { + margin-top: 24rpx; + padding: 16rpx 20rpx; + background: #FFF8EB; + border: 1rpx solid #FFE1A6; + border-radius: 12rpx; + width: 100%; + box-sizing: border-box; +} +.dist__detail-warn-text { + font-size: 24rpx; + color: #D97706; + line-height: 1.5; +} +.dist__detail-rows { + width: 100%; + margin-top: 30rpx; + background: #F8FAFC; + border-radius: 16rpx; + padding: 20rpx 24rpx; + box-sizing: border-box; + display: flex; + flex-direction: column; + gap: 16rpx; +} +.dist__detail-row { + display: flex; + justify-content: space-between; + align-items: center; + font-size: 26rpx; +} +.dist__detail-k { + color: #64748B; + flex-shrink: 0; +} +.dist__detail-v { + color: #1E293B; + font-weight: 500; + max-width: 420rpx; + text-align: right; +} +.dist__detail-v-wrap { + display: flex; + align-items: center; + gap: 8rpx; +} +.dist__detail-copy { + font-size: 22rpx; + color: #00A854; + background: #E8FAF0; + padding: 2rpx 10rpx; + border-radius: 6rpx; +} +.dist__record-arrow { + font-size: 32rpx; + color: #94A3B8; + margin-top: 4rpx; + line-height: 1; +} +.dist__record:active { + opacity: 0.85; +} /* ==================== 展开收起 ==================== */ .dist__more { diff --git a/uniapp/pages/distribution/withdraw-detail.vue b/uniapp/pages/distribution/withdraw-detail.vue new file mode 100644 index 0000000..54f4596 --- /dev/null +++ b/uniapp/pages/distribution/withdraw-detail.vue @@ -0,0 +1,708 @@ + + + + +