...
|
...
|
@@ -2,22 +2,24 @@ const {mysqlPool} = require('./mysql'); |
|
|
|
|
|
module.exports = async(data) => {
|
|
|
let dataId = 0;
|
|
|
const {productId, sizeId, price, time} = data;
|
|
|
const {productId, sizeId, price, time, highRate} = data;
|
|
|
|
|
|
try {
|
|
|
const updateRows = await mysqlPool.update('UPDATE `channel_sku_compare` SET `channel_price` = :channelPrice, `update_time` = :updateTime WHERE `product_id` = :productId AND `size_id` = :sizeId', {
|
|
|
const updateRows = await mysqlPool.update('UPDATE `channel_sku_compare` SET `channel_price` = :channelPrice, `update_time` = :updateTime, `high_rate` = :highRate WHERE `product_id` = :productId AND `size_id` = :sizeId', {
|
|
|
channelPrice: price,
|
|
|
updateTime: time,
|
|
|
productId,
|
|
|
sizeId
|
|
|
sizeId,
|
|
|
highRate: highRate || 0.05
|
|
|
});
|
|
|
|
|
|
if (!updateRows) {
|
|
|
const insertRow = await mysqlPool.insert('INSERT `channel_sku_compare` (`product_id`, `sku`, `size_id`,`channel_price`, `low_rate`, `high_rate`, `channel_average_price`, `update_time`, `status`) SELECT `product_id`,`id`,`size_id`, :channelPrice, 0.05, 0.05, 0.00, :updateTime, 0 FROM `storage` WHERE `product_id` = :productId AND `size_id` = :sizeId', {
|
|
|
const insertRow = await mysqlPool.insert('INSERT `channel_sku_compare` (`product_id`, `sku`, `size_id`,`channel_price`, `low_rate`, `high_rate`, `channel_average_price`, `update_time`, `status`) SELECT `product_id`,`id`,`size_id`, :channelPrice, 0.05, :highRate, 0.00, :updateTime, 0 FROM `storage` WHERE `product_id` = :productId AND `size_id` = :sizeId', {
|
|
|
channelPrice: price,
|
|
|
updateTime: time,
|
|
|
productId,
|
|
|
sizeId
|
|
|
sizeId,
|
|
|
highRate: highRate || 0.05
|
|
|
});
|
|
|
|
|
|
if (!insertRow) {
|
...
|
...
|
|