diff --git a/db/schema_recharge_refund_menu.sql b/db/schema_recharge_refund_menu.sql index a77c2eb..30ee269 100644 --- a/db/schema_recharge_refund_menu.sql +++ b/db/schema_recharge_refund_menu.sql @@ -1,9 +1,12 @@ INSERT INTO `fa_auth_rule` (`type`,`pid`,`name`,`title`,`icon`,`condition`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`) -SELECT 'file',p.id,'recharge_refund','充值退款审核','fa fa-undo','','用户充值原路退款及审核',1,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),145,'normal' +SELECT 'file',p.id,'recharge_refund','充值退款记录','fa fa-undo','','用户充值原路退款记录',1,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),145,'normal' FROM `fa_auth_rule` p WHERE p.name='finance_manage' AND NOT EXISTS (SELECT 1 FROM (SELECT name FROM `fa_auth_rule`) x WHERE x.name='recharge_refund'); INSERT INTO `fa_auth_rule` (`type`,`pid`,`name`,`title`,`icon`,`condition`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`) SELECT 'file',p.id,permissions.name,permissions.title,'fa fa-circle-o','','',0,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),0,'normal' FROM `fa_auth_rule` p JOIN ( - SELECT 'recharge_refund/index' AS name,'查看' AS title UNION ALL SELECT 'recharge_refund/create','申请退款' UNION ALL SELECT 'recharge_refund/review','审核退款' UNION ALL SELECT 'recharge_refund/resolve','查询与重试' + SELECT 'recharge_refund/index' AS name,'查看' AS title UNION ALL SELECT 'recharge_refund/create','发起退款' UNION ALL SELECT 'recharge_refund/review','处理未提交退款' UNION ALL SELECT 'recharge_refund/resolve','查询与重试' ) permissions WHERE p.name='recharge_refund' AND NOT EXISTS (SELECT 1 FROM (SELECT name FROM `fa_auth_rule`) x WHERE x.name=permissions.name); +UPDATE `fa_auth_rule` SET `title`='充值退款记录', `remark`='用户充值原路退款记录', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund'; +UPDATE `fa_auth_rule` SET `title`='发起退款', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund/create'; +UPDATE `fa_auth_rule` SET `title`='处理未提交退款', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund/review'; diff --git a/server/application/admin/controller/RechargeRefund.php b/server/application/admin/controller/RechargeRefund.php index 0a3e130..58ec1ef 100644 --- a/server/application/admin/controller/RechargeRefund.php +++ b/server/application/admin/controller/RechargeRefund.php @@ -26,9 +26,11 @@ class RechargeRefund extends Backend if (!$pay) $this->error('充值订单不存在'); if ($this->request->isPost()) { $this->token(); - try { RechargeRefundService::create((int)$ids, $this->request->post('amount', ''), $this->request->post('reason', ''), $this->auth->id); } + try { $refund = RechargeRefundService::create((int)$ids, $this->request->post('amount', ''), $this->request->post('reason', ''), $this->auth->id); } catch (\Throwable $e) { $this->error($e->getMessage()); } - $this->success('退款申请已提交,余额已占用,等待审核'); + try { $result = RechargeRefundService::submit((int)$refund['id'], $this->auth->id); } + catch (\Throwable $e) { $this->error('退款记录已创建,余额保持占用;请到充值退款记录核实处理:' . $e->getMessage()); } + $this->success('退款已发起,当前状态:' . $result['status']); } $this->view->assign('pay', $pay); $this->view->assign('balance', Db::name('user')->where('id', (int)$pay['user_id'])->value('money')); @@ -45,15 +47,13 @@ class RechargeRefund extends Backend try { if ($action === 'reject') { RechargeRefundService::reject((int)$ids, $this->auth->id, $this->request->post('note', '')); - $this->success('已驳回并释放余额'); + $this->success('已取消并释放余额'); } if ($action !== 'approve') throw new \InvalidArgumentException('无效操作'); - RechargeRefundService::begin((int)$ids, $this->auth->id, $this->request->post('note', '')); + RechargeRefundService::submit((int)$ids, $this->auth->id); } catch (\think\exception\HttpResponseException $e) { throw $e; } - catch (\Throwable $e) { $this->error($e->getMessage()); } - try { RechargeRefundService::send((int)$ids); } - catch (\Throwable $e) { $this->error('申请已审核,微信结果待核实,余额保持占用:' . $e->getMessage()); } - $this->success('退款请求已处理,请查看退款状态'); + catch (\Throwable $e) { $this->error('处理未完成,请查看退款记录及余额占用状态:' . $e->getMessage()); } + $this->success('退款已发起,请查看退款状态'); } $this->view->assign('row', $row); return $this->view->fetch(); diff --git a/server/application/admin/view/pay_order/index.html b/server/application/admin/view/pay_order/index.html index e1fffc7..03d9cee 100644 --- a/server/application/admin/view/pay_order/index.html +++ b/server/application/admin/view/pay_order/index.html @@ -187,7 +187,7 @@
操作指引: - {if $rechargeOnly}可对已支付的充值订单申请原路退款,提交后占用余额,审核通过后向微信退款。{else /}展示全站微信支付与原路退款记录。充值退款请使用充值订单中的专用入口。{/if} + {if $rechargeOnly}可对已支付的充值订单发起原路退款,确认后占用余额并向微信提交退款。{else /}展示全站微信支付与原路退款记录。充值退款请使用充值订单中的专用入口。{/if}
diff --git a/server/application/admin/view/recharge_refund/create.html b/server/application/admin/view/recharge_refund/create.html index e44405e..609f9d0 100644 --- a/server/application/admin/view/recharge_refund/create.html +++ b/server/application/admin/view/recharge_refund/create.html @@ -4,5 +4,5 @@

¥{$pay.amount|htmlentities} / ¥{$pay.refund_amount|htmlentities},当前可用余额 ¥{$balance|htmlentities}

-

提交后将立即占用余额,审核通过后向微信发起退款。

+

确认后立即占用余额并向微信发起原路退款。

diff --git a/server/application/admin/view/recharge_refund/index.html b/server/application/admin/view/recharge_refund/index.html index 6ef1629..0aa6f91 100644 --- a/server/application/admin/view/recharge_refund/index.html +++ b/server/application/admin/view/recharge_refund/index.html @@ -1,11 +1,11 @@
-

充值退款申请

退款处理中、状态未知及异常时,余额保持占用;请核实微信状态。

+

充值退款记录

退款处理中、状态未知及异常时,余额保持占用;请核实微信状态。

-
-
+ +
申请单号充值支付单号用户金额状态申请原因 / 审核备注操作人 / 审核人 ID申请时间操作
{volist name="list" id="row"} {/volist} diff --git a/server/application/admin/view/recharge_refund/review.html b/server/application/admin/view/recharge_refund/review.html index 7bb2cc6..4c32c55 100644 --- a/server/application/admin/view/recharge_refund/review.html +++ b/server/application/admin/view/recharge_refund/review.html @@ -2,8 +2,8 @@ {:token()}

{$row.refund_no|htmlentities}

¥{$row.amount|htmlentities}

-

{$row.reason|htmlentities}

-
-
-
+

{$row.reason|htmlentities}

+
+
+
diff --git a/server/application/api/controller/Master.php b/server/application/api/controller/Master.php index 35a502f..ccd4dfa 100644 --- a/server/application/api/controller/Master.php +++ b/server/application/api/controller/Master.php @@ -3337,12 +3337,12 @@ class Master extends Base default: return [ [ - 'title' => '电子特种作业操作证示例', + 'title' => '特种作业操作证正面示例', 'url' => '/static/images/master/cert-sample-special-card.png', ], [ - 'title' => '纸质特种作业资格证示例', - 'url' => '/static/images/master/cert-sample-qualification.png', + 'title' => '特种作业操作证背面示例', + 'url' => '/static/images/master/cert-sample-special-card-back.png', ], ]; } diff --git a/server/application/common/library/PaymentService.php b/server/application/common/library/PaymentService.php index 5df3b85..eb63cc6 100644 --- a/server/application/common/library/PaymentService.php +++ b/server/application/common/library/PaymentService.php @@ -2579,7 +2579,7 @@ class PaymentService } Db::name('order')->where('id', $orderId)->update($quoteOrderUpdate); self::addOrderLog($orderId, OrderStatus::SCHEDULED, '买家选定师傅报价并使用余额支付差价 ¥' . number_format($payAmount, 2, '.', ''), 'user', $operatorUid); - self::sendMasterAndUserMessage($masterId, $operatorUid, '师傅已被选定', '客户已选定您的报价并完成支付,请及时预约上门'); + self::sendNotify('master', $masterId, '师傅已被选定', '客户已选定您的报价并完成支付,请及时预约上门', 'order', $orderId); } elseif ($scene === 'diff') { $newPayTotal = round((float)$lockedOrder['pay_amount'] + $payAmount, 2); $newTotalAmount = round((float)$lockedOrder['total_amount'] + $payAmount, 2); diff --git a/server/application/common/library/RechargeRefundService.php b/server/application/common/library/RechargeRefundService.php index 075e998..7bfce94 100644 --- a/server/application/common/library/RechargeRefundService.php +++ b/server/application/common/library/RechargeRefundService.php @@ -36,13 +36,19 @@ final class RechargeRefundService } catch (\Throwable $e) { Db::rollback(); throw $e; } } + public static function submit($refundId, $operatorId) + { + self::begin($refundId, $operatorId, ''); + return self::send($refundId); + } + public static function begin($refundId, $reviewerId, $note) { if ((int)$reviewerId <= 0 || mb_strlen(trim((string)$note)) > 255) throw new \InvalidArgumentException('审核信息不正确'); $changed = Db::name('recharge_refund')->where('id', (int)$refundId)->where('status', 'pending')->update([ 'status'=>'submitting', 'reviewer_id'=>(int)$reviewerId, 'audit_note'=>trim((string)$note), 'updatetime'=>time() ]); - if (!$changed) throw new \InvalidArgumentException('退款申请不在待审核状态'); + if (!$changed) throw new \InvalidArgumentException('退款记录不在待提交状态'); return Db::name('recharge_refund')->where('id', (int)$refundId)->find(); } @@ -125,18 +131,18 @@ final class RechargeRefundService public static function reject($refundId, $reviewerId, $note) { $note = trim((string)$note); - if ($note === '' || mb_strlen($note) > 255 || (int)$reviewerId <= 0) throw new \InvalidArgumentException('请填写驳回原因'); + if ($note === '' || mb_strlen($note) > 255 || (int)$reviewerId <= 0) throw new \InvalidArgumentException('请填写取消原因'); $initial = Db::name('recharge_refund')->where('id', (int)$refundId)->find(); if (!$initial) throw new \InvalidArgumentException('退款申请不存在'); Db::startTrans(); try { $user = Db::name('user')->where('id', (int)$initial['user_id'])->lock(true)->find(); $refund = Db::name('recharge_refund')->where('id', (int)$refundId)->lock(true)->find(); - if (!$user || !$refund || $refund['status'] !== 'pending') throw new \InvalidArgumentException('当前状态不允许驳回'); + if (!$user || !$refund || $refund['status'] !== 'pending') throw new \InvalidArgumentException('当前状态不允许取消'); $balance = number_format(((int)round((float)$user['money'] * 100) + (int)round((float)$refund['amount'] * 100)) / 100, 2, '.', ''); $now = time(); Db::name('user')->where('id', (int)$user['id'])->update(['money'=>$balance,'updatetime'=>$now]); - Db::name('wallet_log')->insert(['user_type'=>'user','user_id'=>(int)$user['id'],'type'=>'recharge_refund_release','amount'=>$refund['amount'],'balance'=>$balance,'order_id'=>0,'remark'=>'充值退款驳回释放余额(退款单 '.$refund['refund_no'].')','createtime'=>$now]); + Db::name('wallet_log')->insert(['user_type'=>'user','user_id'=>(int)$user['id'],'type'=>'recharge_refund_release','amount'=>$refund['amount'],'balance'=>$balance,'order_id'=>0,'remark'=>'充值退款取消释放余额(退款单 '.$refund['refund_no'].')','createtime'=>$now]); Db::name('recharge_refund')->where('id', (int)$refundId)->update(['status'=>'rejected','reviewer_id'=>(int)$reviewerId,'audit_note'=>$note,'updatetime'=>$now]); Db::commit(); } catch (\Throwable $e) { Db::rollback(); throw $e; } diff --git a/server/public/assets/js/backend/pay_order.js b/server/public/assets/js/backend/pay_order.js index cae1119..321aba9 100644 --- a/server/public/assets/js/backend/pay_order.js +++ b/server/public/assets/js/backend/pay_order.js @@ -67,8 +67,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons: [ { name: 'rechargerefund', - text: '申请退款', - title: '申请充值原路退款', + text: '退款', + title: '充值原路退款', classname: 'btn btn-xs btn-warning btn-dialog', url: 'recharge_refund/create', visible: function (row) { return row.scene === 'recharge' && row.status === 'paid' && Number(row.amount) > Number(row.refund_amount); } diff --git a/tests/quote_balance_message_guard.test.js b/tests/quote_balance_message_guard.test.js new file mode 100644 index 0000000..05192b8 --- /dev/null +++ b/tests/quote_balance_message_guard.test.js @@ -0,0 +1,8 @@ +const fs = require('fs'); +const assert = require('assert'); +const source = fs.readFileSync('server/application/common/library/PaymentService.php', 'utf8'); +const quoteSection = source.slice(source.indexOf("// 与微信支付路径(confirmOrderPay scene=quote)口径保持一致:"), source.indexOf("} elseif ($scene === 'diff')", source.indexOf("// 与微信支付路径(confirmOrderPay scene=quote)口径保持一致:"))); +assert(quoteSection.includes("self::sendNotify('master', $masterId, '师傅已被选定'"), '余额支付选定报价后应仅向师傅发送师傅视角通知'); +assert(!quoteSection.includes('self::sendMasterAndUserMessage('), '师傅视角通知不应发给买家'); +assert(quoteSection.includes("'order', $orderId"), '师傅通知应关联对应工单'); +console.log('余额支付报价通知归属检查通过'); diff --git a/tests/recharge_refund_gateway.php b/tests/recharge_refund_gateway.php index 93014e7..38325e4 100644 --- a/tests/recharge_refund_gateway.php +++ b/tests/recharge_refund_gateway.php @@ -20,14 +20,16 @@ namespace { \think\Db::name('user')->where('id',1)->update(['money'=>'50.00']); $id=\think\Db::name('pay_order')->insertGetId(['out_trade_no'=>'TEST'.bin2hex(random_bytes(10)), 'order_id'=>0,'order_no'=>'','user_id'=>1,'scene'=>'recharge','openid'=>'TEST','amount'=>'100.00','status'=>'paid']); $r=\app\common\library\RechargeRefundService::create($id,'20.00','客服退款',1); - \app\common\library\RechargeRefundService::begin($r['id'],1,'同意'); - try { \app\common\library\RechargeRefundService::send($r['id']); throw new \Exception('Expected timeout'); } + try { \app\common\library\RechargeRefundService::submit($r['id'],1); throw new \Exception('Expected timeout'); } catch (\RuntimeException $e) { if ($e->getMessage() !== 'TIMEOUT') throw $e; } $row=\think\Db::name('recharge_refund')->where('id',$r['id'])->find(); if ($row['status'] !== 'unknown' || (float)\think\Db::name('user')->where('id',1)->value('money') !== 30.0) throw new \Exception('Timeout failed to preserve reservation'); \app\common\library\RechargeRefundService::send($r['id']); $row=\think\Db::name('recharge_refund')->where('id',$r['id'])->find(); if ($row['status'] !== 'success' || (float)\think\Db::name('pay_order')->where('id',$id)->value('refund_amount') !== 20.0) throw new \Exception('Retry failed'); + $next = \app\common\library\RechargeRefundService::create($id,'10.00','客服退款',1); + $done = \app\common\library\RechargeRefundService::submit($next['id'],1); + if ($done['status'] !== 'success' || (float)\think\Db::name('pay_order')->where('id',$id)->value('refund_amount') !== 30.0) throw new \Exception('Direct submission failed'); echo "Recharge gateway timeout and retry passed\n"; } finally { \think\Db::rollback(); } } diff --git a/yjyf-app/pages/order/detail.vue b/yjyf-app/pages/order/detail.vue index eb4fd97..7b7d6ff 100644 --- a/yjyf-app/pages/order/detail.vue +++ b/yjyf-app/pages/order/detail.vue @@ -378,7 +378,14 @@ :placeholder="order ? '留空申请全额退款 ¥' + order.pay_amount : '留空申请全额退款'" /> - 提交后进入平台仲裁队列(1~2 个工作日),仲裁通过将按微信原路退回您的支付账户 + + + + 移除 + + {{ complaintUploading ? '上传中' : '添加图片' }} + + 可上传最多 3 张图片。平台核实后将通知处理结果。 取消 提交申请 @@ -446,6 +453,8 @@ const showComplaintModal = ref(false); const complaintReason = ref(''); const complaintAmount = ref(''); + const complaintImages = ref([]); + const complaintUploading = ref(false); const submittingComplaint = ref(false); const actionBusy = ref(false); const activeVideoUrl = ref(''); @@ -556,11 +565,33 @@ function openComplaintModal() { complaintReason.value = ''; complaintAmount.value = ''; + complaintImages.value = []; showComplaintModal.value = true; } + function chooseComplaintImages() { + if (complaintUploading.value) return; + uni.chooseImage({ count: 3 - complaintImages.value.length, sizeType: ['compressed'], success: async (res) => { + complaintUploading.value = true; + try { + for (const path of res.tempFilePaths) { + const uploaded = await api.upload(path, 'other'); + if (!uploaded || !uploaded.url) throw new Error('图片上传失败'); + complaintImages.value.push({ url: uploaded.url, preview: uploaded.fullurl || path }); + } + } catch (e) { + uni.showToast({ title: '图片上传失败,请重试', icon: 'none' }); + } finally { complaintUploading.value = false; } + } }); + } + + function previewComplaintImage(index) { + const urls = complaintImages.value.map(item => item.preview); + uni.previewImage({ current: urls[index], urls }); + } + async function submitComplaint() { - if (submittingComplaint.value) return; + if (submittingComplaint.value || complaintUploading.value) return; if (!complaintReason.value.trim() || complaintReason.value.trim().length < 10) { uni.showToast({ title: '请填写至少 10 个字的售后说明', icon: 'none' }); return; @@ -576,6 +607,7 @@ order_id: orderId, content: complaintReason.value.trim(), refund_expect: complaintAmount.value !== '' ? amountNum : 0, + images: complaintImages.value.map(item => item.url).join(','), }); showComplaintModal.value = false; uni.showToast({ title: '售后申请已提交', icon: 'success' }); @@ -1637,6 +1669,11 @@ } /* 售后退款申请表单 */ +.aftersale-images { display: flex; flex-wrap: wrap; gap: 16rpx; margin-top: 20rpx; } +.aftersale-image-item { display: flex; flex-direction: column; align-items: center; } +.aftersale-image { width: 128rpx; height: 128rpx; border-radius: $yjyf-radius-md; } +.aftersale-image-remove { color: $yjyf-danger; font-size: 24rpx; padding: 8rpx; } +.aftersale-image-add { width: 128rpx; height: 128rpx; display: flex; align-items: center; justify-content: center; color: $yjyf-text-secondary; border: 1rpx solid $yjyf-border-color; border-radius: $yjyf-radius-md; font-size: 24rpx; } .aftersale-amount-row { display: flex; align-items: center; diff --git a/yjyf-app/static/images/master/cert-sample-special-card-back.png b/yjyf-app/static/images/master/cert-sample-special-card-back.png new file mode 100644 index 0000000..115d589 Binary files /dev/null and b/yjyf-app/static/images/master/cert-sample-special-card-back.png differ diff --git a/yjyf-app/static/images/master/cert-sample-special-card.png b/yjyf-app/static/images/master/cert-sample-special-card.png new file mode 100644 index 0000000..4a4b28a Binary files /dev/null and b/yjyf-app/static/images/master/cert-sample-special-card.png differ
退款单号充值支付单号用户金额状态退款原因 / 处理备注操作人 / 处理人 ID创建时间操作
{$row.refund_no|htmlentities}{$row.out_trade_no|htmlentities}{$row.nickname|htmlentities} {$row.mobile|htmlentities}¥{$row.amount|htmlentities}{$row.status|htmlentities}{$row.reason|htmlentities}
{$row.audit_note|htmlentities}
{$row.error|htmlentities}
{$row.operator_id|htmlentities} / {$row.reviewer_id|htmlentities}{$row.createtime|date='Y-m-d H:i:s',###} - {if $row.status == 'pending' && $auth->check('recharge_refund/review')}审核{/if} + {if $row.status == 'pending' && $auth->check('recharge_refund/review')}处理{/if} {if in_array($row.status, ['submitting','unknown','processing','abnormal']) && $auth->check('recharge_refund/resolve')}处理{/if}