开始多平台 多店铺整改
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user