mirror of
https://github.com/34892002/edgeKey.git
synced 2026-07-01 02:24:23 +08:00
fix: 支付类型硬编码
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export type PaymentProviderCode = "BEPUSDT" | "EPAY";
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { PrismaClient } from "../../generated/prisma/client";
|
||||
import type { PaymentProvider } from "../payment/types";
|
||||
|
||||
export function findOrderRecord(prisma: PrismaClient, orderNo: string) {
|
||||
return prisma.order.findUnique({
|
||||
@@ -51,7 +52,7 @@ export function createOrderRecord(
|
||||
contactType: "EMAIL" | "QQ" | "TELEGRAM" | "OTHER";
|
||||
contactValue?: string | null;
|
||||
buyerNote?: string | null;
|
||||
paymentProvider: "BEPUSDT" | "EPAY";
|
||||
paymentProvider: PaymentProvider;
|
||||
paymentChannel?: string | null;
|
||||
},
|
||||
) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getContext } from "telefunc";
|
||||
import type { PaymentProvider } from "../payment/types";
|
||||
import type { PrismaClient } from "../../generated/prisma/client";
|
||||
import { conflictError, notFoundError } from "../../lib/app-error";
|
||||
import { validateOrderInput } from "../../lib/validators/order";
|
||||
@@ -38,7 +39,7 @@ function sleep(ms: number) {
|
||||
export async function createOrder(input: {
|
||||
productId: number;
|
||||
quantity: number;
|
||||
paymentProvider: "BEPUSDT" | "EPAY";
|
||||
paymentProvider: PaymentProvider;
|
||||
paymentChannel?: string;
|
||||
contactType: "EMAIL" | "QQ" | "TELEGRAM" | "OTHER";
|
||||
contactValue?: string;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { PaymentProvider } from "../payment/types";
|
||||
|
||||
export interface CreateOrderInput {
|
||||
productId: number;
|
||||
quantity: number;
|
||||
paymentProvider: "BEPUSDT" | "EPAY";
|
||||
paymentProvider: PaymentProvider;
|
||||
contactType: "EMAIL" | "QQ" | "TELEGRAM" | "OTHER";
|
||||
contactValue?: string;
|
||||
buyerNote?: string;
|
||||
|
||||
@@ -87,6 +87,7 @@ import { useData } from "vike-vue/useData";
|
||||
import { isEmail } from "../../../lib/validators/email";
|
||||
import { formatCents } from "../../../lib/utils/money";
|
||||
import { onCreateOrder } from "./createOrder.telefunc";
|
||||
import type { PaymentProvider } from "../../../modules/payment/types";
|
||||
import { saveLocalOrder } from "../../../lib/local-orders";
|
||||
import type { Data } from "./+data";
|
||||
|
||||
@@ -104,7 +105,7 @@ const form = reactive({
|
||||
quantity: product?.minBuy ?? 1,
|
||||
contactValue: "",
|
||||
buyerNote: "",
|
||||
paymentProvider: (paymentMethods[0]?.provider ?? "BEPUSDT") as "BEPUSDT" | "EPAY",
|
||||
paymentProvider: (paymentMethods[0]?.provider ?? "BEPUSDT") as PaymentProvider,
|
||||
paymentChannel: "alipay",
|
||||
});
|
||||
|
||||
@@ -132,7 +133,7 @@ async function handleCreateOrder() {
|
||||
productId: product.id,
|
||||
quantity: form.quantity,
|
||||
paymentProvider: form.paymentProvider,
|
||||
paymentChannel: form.paymentProvider === "EPAY" ? form.paymentChannel : undefined,
|
||||
paymentChannel: form.paymentProvider === "EPAY" ? form.paymentChannel : form.paymentProvider === "ALIPAY" ? "pc" : undefined,
|
||||
contactType: "EMAIL",
|
||||
contactValue: contactEmail,
|
||||
buyerNote: form.buyerNote,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getProductBySlug } from "../../../modules/catalog/service";
|
||||
import { listEnabledPaymentMethods } from "../../../modules/payment/service";
|
||||
|
||||
export type Data = ReturnType<typeof data>;
|
||||
export type Data = Awaited<ReturnType<typeof data>>;
|
||||
|
||||
export async function data(pageContext: {
|
||||
routeParams: { slug: string };
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { createOrder } from "../../../modules/order/service";
|
||||
import type { PaymentProvider } from "../../../modules/payment/types";
|
||||
|
||||
export async function onCreateOrder(input: {
|
||||
productId: number;
|
||||
quantity: number;
|
||||
paymentProvider: "BEPUSDT" | "EPAY";
|
||||
paymentProvider: PaymentProvider;
|
||||
paymentChannel?: string;
|
||||
contactType: "EMAIL";
|
||||
contactValue: string;
|
||||
|
||||
Reference in New Issue
Block a user