fix: 修复订单结算逻辑和商家档案重复问题

- 修复后台编辑订单状态为已完成时缺少结算分账逻辑
- 修复商家档案存在重复建档问题,添加唯一性校验
- 修复师傅核销码位数显示错误(6位改为4位)
- 重构后台支付订单详情页交互逻辑,优化复制和弹窗关闭功能
这个提交包含在:
2026-11-18 13:33:29 +08:00
父节点 19651c0899
当前提交 45a16c8bef
共有 15 个文件被更改,包括 1274 次插入 和 407 次删除

查看文件

@@ -519,7 +519,7 @@
<span class="po-item-k">关联订单号</span>
<span class="po-item-v">
{if !empty($order)}
<a href="order/detail/ids/{$order.id}" class="dialogit text-primary po-mono" data-title="订单 #{$order.order_no} 详情" style="font-weight:600;">
<a href="{:url('order/detail', ['ids' => $order['id']])}" class="dialogit text-primary po-mono" data-title="订单 #{$order.order_no} 详情" style="font-weight:600;">
{$order.order_no|htmlentities}
</a>
<button type="button" class="btn-copy js-copy-btn" data-text="{$order.order_no}" title="复制订单号">
@@ -668,25 +668,39 @@
<script>
(function () {
// 复制剪贴板辅助函数
function copyText(str, msg) {
if (!str || str === '-') return;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(str).then(function () {
if (window.Toastr) {
Toastr.success(msg || '已复制到剪贴板');
} else {
alert(msg || '已复制到剪贴板');
}
}).catch(function () {
fallbackCopy(str, msg);
});
function notifySuccess(msg) {
var t = window.Toastr || (parent && parent.Toastr);
if (t && typeof t.success === 'function') {
t.success(msg);
} else {
fallbackCopy(str, msg);
alert(msg);
}
}
function fallbackCopy(str, msg) {
function notifyError(msg) {
var l = window.Layer || (parent && parent.Layer);
if (l && typeof l.alert === 'function') {
l.alert(msg);
} else {
alert(msg);
}
}
function copyText(str, btnEl) {
if (!str || str === '-') return;
var done = function () {
notifySuccess('已复制:' + str);
if (btnEl) {
var oldHtml = btnEl.innerHTML;
btnEl.innerHTML = '<i class="fa fa-check text-success"></i> 已复制';
setTimeout(function () { btnEl.innerHTML = oldHtml; }, 1500);
}
};
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(str).then(done).catch(function () { fallbackCopy(str, done); });
} else {
fallbackCopy(str, done);
}
}
function fallbackCopy(str, cb) {
var ta = document.createElement('textarea');
ta.value = str;
ta.style.position = 'fixed';
@@ -694,92 +708,86 @@
document.body.appendChild(ta);
ta.select();
try {
var ok = document.execCommand('copy');
if (ok && window.Toastr) {
Toastr.success(msg || '已复制到剪贴板');
} else if (ok) {
alert(msg || '已复制到剪贴板');
}
if (document.execCommand('copy') && cb) cb();
} catch (e) {
if (window.Toastr) Toastr.error('复制失败,请手动选中文本');
notifyError('复制失败,请手动选中文本');
}
document.body.removeChild(ta);
}
// 绑定复制按钮
$(document).on('click', '.js-copy-btn', function (e) {
e.preventDefault();
var text = $(this).data('text');
copyText(text, '已复制:' + text);
});
// 弹窗关闭
$(document).on('click', '.js-modal-close', function () {
var index = parent.Layer.getFrameIndex(window.name);
if (index) {
parent.Layer.close(index);
} else {
window.close();
document.addEventListener('click', function (e) {
var copyBtn = e.target.closest ? e.target.closest('.js-copy-btn') : null;
if (copyBtn) {
e.preventDefault();
copyText(copyBtn.getAttribute('data-text'), copyBtn);
return;
}
});
// 弹窗内同步微信状态
$(document).on('click', '.js-action-sync', function () {
var id = $(this).data('id');
var $btn = $(this);
$btn.prop('disabled', true).find('i').addClass('fa-spin');
Fast.api.ajax({
url: 'pay_order/sync/ids/' + id,
data: {}
}, function (data, ret) {
$btn.prop('disabled', false).find('i').removeClass('fa-spin');
Toastr.success(ret.msg || '同步微信状态成功');
if (parent && parent.$ && parent.$('#table').length) {
parent.$('#table').bootstrapTable('refresh');
var closeBtn = e.target.closest ? e.target.closest('.js-modal-close') : null;
if (closeBtn) {
e.preventDefault();
if (parent && parent.Layer) {
var idx = parent.Layer.getFrameIndex(window.name);
if (idx) {
parent.Layer.close(idx);
return;
}
}
setTimeout(function () {
window.location.reload();
}, 800);
return false;
}, function (data, ret) {
$btn.prop('disabled', false).find('i').removeClass('fa-spin');
Layer.alert(ret.msg || '同步失败');
return false;
});
});
window.close();
return;
}
// 弹窗内重发退款
$(document).on('click', '.js-action-retry', function () {
var id = $(this).data('id');
var $btn = $(this);
Layer.confirm('确定对该笔流水重新发起微信原路退款吗?系统将自动退该笔剩余可退金额,并自动核对网关旧退款单。', {
title: '重发微信原路退款确认',
icon: 3
}, function (index) {
Layer.close(index);
$btn.prop('disabled', true).find('i').addClass('fa-spin');
Fast.api.ajax({
url: 'pay_order/retryrefund/ids/' + id,
data: {}
}, function (data, ret) {
$btn.prop('disabled', false).find('i').removeClass('fa-spin');
Toastr.success(ret.msg || '退款请求已发起');
var syncBtn = e.target.closest ? e.target.closest('.js-action-sync') : null;
if (syncBtn) {
e.preventDefault();
var id = syncBtn.getAttribute('data-id');
var FastApi = window.Fast || (parent && parent.Fast);
if (!FastApi) return;
syncBtn.disabled = true;
FastApi.api.ajax({ url: 'pay_order/sync/ids/' + id, data: {} }, function (data, ret) {
syncBtn.disabled = false;
notifySuccess((ret && ret.msg) || '同步微信状态成功');
if (parent && parent.$ && parent.$('#table').length) {
parent.$('#table').bootstrapTable('refresh');
}
setTimeout(function () {
window.location.reload();
}, 800);
setTimeout(function () { window.location.reload(); }, 800);
return false;
}, function (data, ret) {
$btn.prop('disabled', false).find('i').removeClass('fa-spin');
Layer.alert(ret.msg || '重退失败');
syncBtn.disabled = false;
notifyError((ret && ret.msg) || '同步失败');
return false;
});
});
return;
}
var retryBtn = e.target.closest ? e.target.closest('.js-action-retry') : null;
if (retryBtn) {
e.preventDefault();
var rid = retryBtn.getAttribute('data-id');
var FastApi2 = window.Fast || (parent && parent.Fast);
var LayerApi = window.Layer || (parent && parent.Layer);
if (!FastApi2 || !LayerApi) return;
LayerApi.confirm('确定对该笔流水重新发起微信原路退款吗?系统将自动退剩余可退金额。', {
title: '重发原路退款确认',
icon: 3
}, function (index) {
LayerApi.close(index);
retryBtn.disabled = true;
FastApi2.api.ajax({ url: 'pay_order/retryrefund/ids/' + rid, data: {} }, function (data, ret) {
retryBtn.disabled = false;
notifySuccess((ret && ret.msg) || '退款请求已发起');
if (parent && parent.$ && parent.$('#table').length) {
parent.$('#table').bootstrapTable('refresh');
}
setTimeout(function () { window.location.reload(); }, 800);
return false;
}, function (data, ret) {
retryBtn.disabled = false;
notifyError((ret && ret.msg) || '重退失败');
return false;
});
});
}
});
})();
</script>

查看文件

@@ -199,7 +199,7 @@
</div>
<!-- 表格 -->
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-detail="{:$auth->check('pay_order/detail')}"
data-operate-sync="{:$auth->check('pay_order/sync')}"
data-operate-retryrefund="{:$auth->check('pay_order/retryrefund')}"