feat: audit diff, mock SMS 999888, env photos, proxy pay lock, mini-user UX
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1545,7 +1545,52 @@ export class TradeService {
|
||||
where: orderStatusLogWhere(orderId),
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
return serializeBigInt(mapOrderCompat({ ...order, statusLogs: mapStatusLogCompat(statusLogs) }));
|
||||
return serializeBigInt({
|
||||
...mapOrderCompat({ ...order, statusLogs: mapStatusLogCompat(statusLogs) }),
|
||||
proxyPayMethod: this.parseProxyPayMethod(order.channelSource),
|
||||
});
|
||||
}
|
||||
|
||||
private parseProxyPayMethod(channelSource: string | null | undefined): 'NATIVE' | 'JSAPI' | null {
|
||||
if (!channelSource) return null;
|
||||
const m = channelSource.match(/^PROXY_ONLINE:(NATIVE|JSAPI)$/);
|
||||
return m ? (m[1] as 'NATIVE' | 'JSAPI') : null;
|
||||
}
|
||||
|
||||
private proxyChannelWithMethod(method: 'NATIVE' | 'JSAPI'): string {
|
||||
return `PROXY_ONLINE:${method}`;
|
||||
}
|
||||
|
||||
/** 合伙人取消代下单支付(关闭待支付订单,可重新下单并选择其他支付方式) */
|
||||
async cancelPartnerProxyOrder(partnerAccountId: bigint, orderId: bigint) {
|
||||
const primary = await this.partnerCityService.resolvePrimaryAccount(partnerAccountId);
|
||||
const order = await this.prisma.order.findFirst({
|
||||
where: {
|
||||
id: orderId,
|
||||
orderType: 'PROXY',
|
||||
proxyPartnerAccountId: primary.id,
|
||||
},
|
||||
});
|
||||
if (!order) throw new NotFoundException('代下单不存在');
|
||||
if (order.status !== 'PENDING_PAY' || order.payStatus !== 'UNPAID') {
|
||||
throw new BadRequestException('仅待支付订单可取消');
|
||||
}
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.order.update({
|
||||
where: { id: orderId },
|
||||
data: { status: 'CANCELLED', cancelledAt: new Date() },
|
||||
});
|
||||
await tx.commonEvent.create({
|
||||
data: buildOrderStatusEvent({
|
||||
orderId,
|
||||
fromStatus: 'PENDING_PAY',
|
||||
toStatus: 'CANCELLED',
|
||||
operator: 'PARTNER_PROXY',
|
||||
remark: '合伙人取消代下单支付',
|
||||
}),
|
||||
});
|
||||
});
|
||||
return serializeBigInt({ id: orderId.toString(), status: 'CANCELLED' });
|
||||
}
|
||||
|
||||
/** HQ 代下单:商品/推广码选项(运营侧可看白名单测试酒) */
|
||||
@@ -1775,6 +1820,21 @@ export class TradeService {
|
||||
throw new BadRequestException('订单已超时未支付');
|
||||
}
|
||||
|
||||
const lockedMethod = this.parseProxyPayMethod(order.channelSource);
|
||||
if (lockedMethod && lockedMethod !== payMethod) {
|
||||
throw new BadRequestException(
|
||||
lockedMethod === 'JSAPI'
|
||||
? '该订单已发起微信代付,请先取消支付后重新下单'
|
||||
: '该订单已生成收款码,请先取消支付后重新下单',
|
||||
);
|
||||
}
|
||||
if (!lockedMethod) {
|
||||
await this.prisma.order.update({
|
||||
where: { id: orderId },
|
||||
data: { channelSource: this.proxyChannelWithMethod(payMethod) },
|
||||
});
|
||||
}
|
||||
|
||||
this.payRedeemAnomaly.onPayAttempt(Number(order.payAmount), {
|
||||
orderNo: order.orderNo,
|
||||
userId: order.userId,
|
||||
|
||||
Reference in New Issue
Block a user