fix: 共享单按骑行人设置,手动还车不续租,支持上游 A→B 切换
共享策略 - 预览:车主出卡,骑行人决定时长、轮次、提醒与保护卡策略 - 后端拦截共享车主的加轮、临时锁/开车与支付,普通订单不变 - 前端共享车主只保留还车按钮,不显示权限提示;骑行人沿用现有设置页 还车与续租 - auto_return_bike 默认 allow_renewal=False;仅 0 点定时器与过期巡检显式开启 - 页面按钮、邮件链接、共享还车均清理自动重试状态,剩余/临时加轮不再触发续租 - 官方小程序还车(上游订单消失)只做本地收尾,不重新开锁 - 续租拿不到原车位置时仍直接尝试下单开锁,失败再明确提示 上游 A→B - 网站开 A,官方小程序还 A 后又开 B:巡检保留 B,A 按已还车本地收尾 - 同一订单号不误关、不重复建单;无订单号记录保守跳过 测试:266 pytest + 45 node 全绿;tsc 与生产 bundle 检查通过
This commit is contained in:
+18
-1
@@ -707,6 +707,10 @@ let orderTempActionLoading: any = false;
|
||||
// static/js/map.js:2213-2260
|
||||
export async function tempLockCurrentOrder() {
|
||||
if (orderTempActionLoading || !isOrderActionEligible(S.currentOrder) || Number(S.currentOrder.status) !== 2) return;
|
||||
if (S.currentOrder.shared) {
|
||||
showToast("共享订单仅骑行人可临时锁车,车主只能还车");
|
||||
return;
|
||||
}
|
||||
// 先快照:等定位(最长 5 秒)期间 20 秒轮询可能把 currentOrder 置空,
|
||||
// 之后再读 currentOrder.order_id 会抛 TypeError 并被吞成「临时锁车失败」。
|
||||
const order = S.currentOrder;
|
||||
@@ -762,6 +766,10 @@ export async function tempLockCurrentOrder() {
|
||||
// static/js/map.js:2262-2300
|
||||
export async function tempUnlockCurrentOrder() {
|
||||
if (orderTempActionLoading || !isOrderActionEligible(S.currentOrder) || Number(S.currentOrder.status) !== 2) return;
|
||||
if (S.currentOrder.shared) {
|
||||
showToast("共享订单仅骑行人可临时开车,车主只能还车");
|
||||
return;
|
||||
}
|
||||
const button = document.getElementById("order-action-unlock");
|
||||
orderTempActionLoading = true;
|
||||
if (button) {
|
||||
@@ -1368,12 +1376,20 @@ export async function confirmAddRound() {
|
||||
// static/js/map.js:2946-2949
|
||||
export function addRoundForCurrent() {
|
||||
if (!S.activeRental || !S.authToken) { showToast("当前没有进行中的订单"); return; }
|
||||
if (S.currentOrder && S.currentOrder.shared) {
|
||||
showToast("共享订单仅骑行人可加轮,车主只能还车");
|
||||
return;
|
||||
}
|
||||
showAddRoundConfirm({ kind: "rental", value: S.activeRental.rental_id });
|
||||
}
|
||||
|
||||
// static/js/map.js:2950-2954
|
||||
export function addRoundFromBanner() {
|
||||
if (!S.currentOrder || !S.currentOrder.order_id) { showToast("当前没有进行中的订单"); return; }
|
||||
if (S.currentOrder.shared) {
|
||||
showToast("共享订单仅骑行人可加轮,车主只能还车");
|
||||
return;
|
||||
}
|
||||
showAddRoundConfirm({ kind: "order", value: S.currentOrder.order_id });
|
||||
}
|
||||
// 页面加载时检查订单状态和租车状态
|
||||
@@ -1853,7 +1869,8 @@ export function showRentalBar() {
|
||||
if (addBtn) {
|
||||
const realOrder = S.activeRental.source ? S.activeRental.source !== "reminder"
|
||||
: !!S.activeRental.order_id;
|
||||
addBtn.style.display = realOrder ? "inline-flex" : "none";
|
||||
const ownerShared = !!(S.currentOrder && S.currentOrder.shared);
|
||||
addBtn.style.display = (realOrder && !ownerShared) ? "inline-flex" : "none";
|
||||
}
|
||||
updateRentalFinalTime();
|
||||
updateRentalCountdown();
|
||||
|
||||
+32
-9
@@ -53,6 +53,7 @@ export function showOrderBanner(order) {
|
||||
const icon = document.getElementById("order-banner-icon");
|
||||
const text = document.getElementById("order-banner-text");
|
||||
const btn = document.getElementById("order-banner-btn");
|
||||
btn.onclick = handleOrderBannerClick;
|
||||
|
||||
banner.classList.remove("warning", "riding");
|
||||
|
||||
@@ -61,7 +62,9 @@ export function showOrderBanner(order) {
|
||||
banner.classList.add("warning");
|
||||
icon.innerHTML = '<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>';
|
||||
text.textContent = `待支付订单 #${order.code || order.order_id.slice(-6)}`;
|
||||
btn.textContent = "去支付";
|
||||
// 共享单的支付、时长与轮次由骑行人处理,车主只能还车。
|
||||
btn.textContent = order.shared ? "查看" : "去支付";
|
||||
if (order.shared) btn.onclick = showOrderActionsModal;
|
||||
hideOrderCountdown();
|
||||
const progress = document.getElementById("order-final-time");
|
||||
progress.textContent = "待支付 · 骑行已结束";
|
||||
@@ -125,7 +128,8 @@ export function fetchOrderCountdown(orderId) {
|
||||
}
|
||||
if (addBtn) {
|
||||
// 真实订单才可加轮; reminder 计时不显示
|
||||
const eligible = data.data.order_id && String(data.data.source) !== "reminder";
|
||||
const eligible = data.data.order_id && String(data.data.source) !== "reminder"
|
||||
&& !(S.currentOrder && S.currentOrder.shared);
|
||||
addBtn.style.display = eligible ? "inline-block" : "none";
|
||||
}
|
||||
showOrderCountdown();
|
||||
@@ -260,23 +264,29 @@ export function showOrderActionsModal() {
|
||||
const hint = document.getElementById("order-actions-hint");
|
||||
const code = S.currentOrder.code || S.currentOrder.order_id || "未知";
|
||||
const pending = Number(S.currentOrder.status) === 1;
|
||||
// order_status 只有当前登录车主会带 shared,因此这里可可靠地区分车主与骑行人。
|
||||
const ownerShared = !!S.currentOrder.shared;
|
||||
|
||||
meta.textContent = `车辆 #${code}`;
|
||||
status.textContent = pending ? "待支付订单" : "订单进行中";
|
||||
status.classList.toggle("warning", pending);
|
||||
status.textContent = ownerShared ? "" : (pending ? "待支付订单" : "订单进行中");
|
||||
status.style.display = ownerShared ? "none" : "";
|
||||
status.classList.toggle("warning", pending && !ownerShared);
|
||||
status.classList.toggle("riding", !pending);
|
||||
hint.textContent = pending
|
||||
hint.textContent = ownerShared ? "" : (pending
|
||||
? "当前订单尚未支付,请先完成支付后再使用车辆操作。"
|
||||
: "临时锁车不会结束订单,确认车辆停放安全后再操作。";
|
||||
: "临时锁车不会结束订单,确认车辆停放安全后再操作。");
|
||||
hint.style.display = ownerShared ? "none" : "";
|
||||
|
||||
// 待支付订单明确不展示临时锁车/临时开车。
|
||||
// 待支付订单不展示临时锁/开车;共享车主连寻车、支付也一并隐藏。
|
||||
["order-action-lock", "order-action-unlock"].forEach(id => {
|
||||
const button = document.getElementById(id);
|
||||
if (button) button.style.display = pending ? "none" : "flex";
|
||||
if (button) button.style.display = (pending || ownerShared) ? "none" : "flex";
|
||||
});
|
||||
const find = document.getElementById("order-action-find");
|
||||
const pay = document.getElementById("order-action-pay");
|
||||
const ret = document.getElementById("order-action-return");
|
||||
if (pay) pay.style.display = pending ? "flex" : "none";
|
||||
if (find) find.style.display = ownerShared ? "none" : "flex";
|
||||
if (pay) pay.style.display = (pending && !ownerShared) ? "flex" : "none";
|
||||
if (ret) ret.style.display = pending ? "none" : "flex";
|
||||
|
||||
modal.classList.add("show");
|
||||
@@ -297,6 +307,10 @@ export function closeOrderActionsModal() {
|
||||
// static/js/map.js:1943-1973
|
||||
export async function findCurrentOrderBike() {
|
||||
if (!isOrderActionEligible(S.currentOrder)) return;
|
||||
if (S.currentOrder.shared) {
|
||||
showToast("共享订单仅骑行人可寻车,车主只能还车");
|
||||
return;
|
||||
}
|
||||
const code = (S.currentOrder.code || "").toString().trim();
|
||||
if (!code) {
|
||||
showToast("该订单没有车牌信息");
|
||||
@@ -329,6 +343,10 @@ export async function findCurrentOrderBike() {
|
||||
|
||||
// static/js/map.js:1975-1978
|
||||
export function payCurrentOrderFromModal() {
|
||||
if (S.currentOrder && S.currentOrder.shared) {
|
||||
showToast("共享订单由骑行人处理支付,车主只能还车");
|
||||
return;
|
||||
}
|
||||
closeOrderActionsModal();
|
||||
tryCardPayOrRedirect();
|
||||
}
|
||||
@@ -348,6 +366,11 @@ export function handleOrderBannerClick() {
|
||||
}
|
||||
|
||||
if (Number(S.currentOrder.status) === 1) {
|
||||
// 共享单待支付也只能由骑行人处理,车主没有支付入口。
|
||||
if (S.currentOrder.shared) {
|
||||
showOrderActionsModal();
|
||||
return;
|
||||
}
|
||||
// 待支付 - 先检查是否有月卡/周卡
|
||||
tryCardPayOrRedirect();
|
||||
} else if (Number(S.currentOrder.status) === 2) {
|
||||
|
||||
Reference in New Issue
Block a user