开始多平台 多店铺整改

This commit is contained in:
yml
2026-04-08 22:21:11 +08:00
parent d5b10e3f7f
commit a2b09c89e8
40 changed files with 1750 additions and 685 deletions
+18 -4
View File
@@ -1,18 +1,21 @@
import { getDb } from '../db/client.js'
export function findOrderByPlatformOrderId(platform, platformOrderId) {
export function findOrderByPlatformOrderId({ provider = 'agiso', platform, shopId = '', platformOrderId }) {
return getDb().prepare(`
SELECT *
FROM orders
WHERE platform = ? AND platform_order_id = ?
WHERE provider = ? AND platform = ? AND shop_id = ? AND platform_order_id = ?
LIMIT 1
`).get(platform, platformOrderId) || null
`).get(provider, platform, shopId, platformOrderId) || null
}
export function createOrder(input) {
const result = getDb().prepare(`
INSERT INTO orders (
provider,
platform,
shop_id,
shop_name,
platform_order_id,
order_status,
pay_status,
@@ -25,9 +28,12 @@ export function createOrder(input) {
paid_at,
created_at,
updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
input.provider,
input.platform,
input.shopId,
input.shopName,
input.platformOrderId,
input.orderStatus,
input.payStatus,
@@ -49,6 +55,10 @@ export function updateOrder(orderId, input) {
getDb().prepare(`
UPDATE orders
SET
provider = ?,
platform = ?,
shop_id = ?,
shop_name = ?,
order_status = ?,
pay_status = ?,
buyer_id = ?,
@@ -61,6 +71,10 @@ export function updateOrder(orderId, input) {
updated_at = ?
WHERE id = ?
`).run(
input.provider,
input.platform,
input.shopId,
input.shopName,
input.orderStatus,
input.payStatus,
input.buyerId,