开始多平台 多店铺整改

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
@@ -3,7 +3,10 @@ import { getDb } from '../db/client.js'
export function createMessageDelivery(input) {
const result = getDb().prepare(`
INSERT INTO message_deliveries (
provider,
platform,
shop_id,
shop_name,
channel,
order_id,
task_id,
@@ -21,9 +24,12 @@ export function createMessageDelivery(input) {
sent_at,
created_at,
updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
input.provider,
input.platform,
input.shopId,
input.shopName,
input.channel,
input.orderId,
input.taskId,
+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,
@@ -3,7 +3,10 @@ import { getDb } from '../db/client.js'
export function createWebhookEvent(input) {
const result = getDb().prepare(`
INSERT INTO webhook_events (
provider,
platform,
shop_id,
shop_name,
event_type,
event_key,
signature_valid,
@@ -14,9 +17,12 @@ export function createWebhookEvent(input) {
process_error,
related_order_id,
created_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
input.provider,
input.platform,
input.shopId,
input.shopName,
input.eventType,
input.eventKey,
input.signatureValid ? 1 : 0,
@@ -60,6 +66,7 @@ export function getWebhookEventById(eventId) {
export function listWebhookEvents({
page = 1,
pageSize = 20,
provider = '',
platform = '',
processed = '',
relatedOrderId = '',
@@ -70,6 +77,11 @@ export function listWebhookEvents({
const filters = []
const params = []
if (provider) {
filters.push('provider = ?')
params.push(provider)
}
if (platform) {
filters.push('platform = ?')
params.push(platform)