兼容接入商品固定价格字段
This commit is contained in:
@@ -53,6 +53,7 @@ CREATE TABLE rental_listings (
|
||||
id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
||||
account_id BIGINT UNSIGNED NOT NULL,
|
||||
owner_id BIGINT UNSIGNED NOT NULL,
|
||||
price DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_hourly DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_daily DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_weekly DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
@@ -66,7 +67,8 @@ CREATE TABLE rental_listings (
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
KEY idx_rental_listings_account_id (account_id),
|
||||
KEY idx_rental_listings_owner_id (owner_id),
|
||||
KEY idx_rental_listings_filter (status, review_status, price_hourly)
|
||||
KEY idx_rental_listings_filter (status, review_status, price),
|
||||
KEY idx_rental_listings_legacy_filter (status, review_status, price_hourly)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE rental_orders (
|
||||
|
||||
@@ -15,6 +15,32 @@ PREPARE add_listing_in_transaction_stmt FROM @add_listing_in_transaction_sql;
|
||||
EXECUTE add_listing_in_transaction_stmt;
|
||||
DEALLOCATE PREPARE add_listing_in_transaction_stmt;
|
||||
|
||||
SET @listing_price_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'rental_listings'
|
||||
AND column_name = 'price'
|
||||
);
|
||||
|
||||
SET @add_listing_price_sql := IF(
|
||||
@listing_price_exists = 0,
|
||||
'ALTER TABLE rental_listings ADD COLUMN price DECIMAL(12,2) NOT NULL DEFAULT 0.00 AFTER owner_id',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE add_listing_price_stmt FROM @add_listing_price_sql;
|
||||
EXECUTE add_listing_price_stmt;
|
||||
DEALLOCATE PREPARE add_listing_price_stmt;
|
||||
|
||||
UPDATE rental_listings
|
||||
SET price = CASE
|
||||
WHEN price_daily > 0 THEN price_daily
|
||||
WHEN price_hourly > 0 THEN price_hourly * 24
|
||||
WHEN price_weekly > 0 THEN price_weekly / 7
|
||||
ELSE price
|
||||
END
|
||||
WHERE price <= 0;
|
||||
|
||||
INSERT INTO system_configs (`key`, `value`, description)
|
||||
VALUES ('order.pending_payment_timeout_minutes', '15', '订单待支付超时取消分钟数')
|
||||
ON DUPLICATE KEY UPDATE `key` = VALUES(`key`);
|
||||
|
||||
Reference in New Issue
Block a user