|
@@ -8,6 +8,7 @@ const {logger} = require('../../libs/logger'); |
|
@@ -8,6 +8,7 @@ const {logger} = require('../../libs/logger'); |
8
|
const spiderSj = require('./spider/shenjian');
|
8
|
const spiderSj = require('./spider/shenjian');
|
9
|
const spiderDu = require('./spider/du');
|
9
|
const spiderDu = require('./spider/du');
|
10
|
const spiderUfo = require('./spider/ufo');
|
10
|
const spiderUfo = require('./spider/ufo');
|
|
|
11
|
+const {getSpecialSizeProducts, getSize} = require('../../utils');
|
11
|
|
12
|
|
12
|
const mergePrice = (prices, scales) => {
|
13
|
const mergePrice = (prices, scales) => {
|
13
|
let mp = 0;
|
14
|
let mp = 0;
|
|
@@ -89,7 +90,7 @@ const report = async(product, time) => { |
|
@@ -89,7 +90,7 @@ const report = async(product, time) => { |
89
|
return results.filter(r => r).length;
|
90
|
return results.filter(r => r).length;
|
90
|
};
|
91
|
};
|
91
|
|
92
|
|
92
|
-const task = async({product, now, sizeRelation}) => {
|
93
|
+const task = async({product, now, sizeRelation, isSpecialSize}) => {
|
93
|
try {
|
94
|
try {
|
94
|
const results = await Promise.all([
|
95
|
const results = await Promise.all([
|
95
|
spiderUfo(product.third.ufo),
|
96
|
spiderUfo(product.third.ufo),
|
|
@@ -102,7 +103,12 @@ const task = async({product, now, sizeRelation}) => { |
|
@@ -102,7 +103,12 @@ const task = async({product, now, sizeRelation}) => { |
102
|
du: _.get(results[2], 'skus', []),
|
103
|
du: _.get(results[2], 'skus', []),
|
103
|
});
|
104
|
});
|
104
|
const skus = _.map(Object.keys(skusGroups), size => {
|
105
|
const skus = _.map(Object.keys(skusGroups), size => {
|
105
|
- if (sizeRelation[size]) {
|
106
|
+ const find = getSize(size, sizeRelation, isSpecialSize);
|
|
|
107
|
+
|
|
|
108
|
+ if (isSpecialSize) {
|
|
|
109
|
+ console.log(`=================>price-day-task yhId: ${product.productId}, size: ${size} => ${find.relationSize || size}, ${find.sizeId}`);
|
|
|
110
|
+ }
|
|
|
111
|
+ if (find) {
|
106
|
const price = calcPrice(skusGroups[size]);
|
112
|
const price = calcPrice(skusGroups[size]);
|
107
|
|
113
|
|
108
|
logger.info(`[price-day-task] skusGroups: ${product.productId}, ${size} ${JSON.stringify(skusGroups[size])}, price: ${price}`);
|
114
|
logger.info(`[price-day-task] skusGroups: ${product.productId}, ${size} ${JSON.stringify(skusGroups[size])}, price: ${price}`);
|
|
@@ -111,7 +117,7 @@ const task = async({product, now, sizeRelation}) => { |
|
@@ -111,7 +117,7 @@ const task = async({product, now, sizeRelation}) => { |
111
|
return {
|
117
|
return {
|
112
|
size,
|
118
|
size,
|
113
|
price,
|
119
|
price,
|
114
|
- sizeId: _.get(sizeRelation[size], 'sizeId', 0)
|
120
|
+ sizeId: _.get(find, 'sizeId', 0)
|
115
|
};
|
121
|
};
|
116
|
}
|
122
|
}
|
117
|
}
|
123
|
}
|
|
@@ -139,6 +145,8 @@ module.exports = async() => { |
|
@@ -139,6 +145,8 @@ module.exports = async() => { |
139
|
logger.info(`[price-day-task] dayTask, exists createtime price: ${now}`);
|
145
|
logger.info(`[price-day-task] dayTask, exists createtime price: ${now}`);
|
140
|
return;
|
146
|
return;
|
141
|
}
|
147
|
}
|
|
|
148
|
+
|
|
|
149
|
+ const specialSizeProducts = await getSpecialSizeProducts();
|
142
|
const sizeData = await mysqlPool.query('select `size_name`,min(`id`) as id from `size` where `size_name` <> \'-\' group by `size_name`');
|
150
|
const sizeData = await mysqlPool.query('select `size_name`,min(`id`) as id from `size` where `size_name` <> \'-\' group by `size_name`');
|
143
|
const sizeRelation = {};
|
151
|
const sizeRelation = {};
|
144
|
|
152
|
|
|
@@ -153,7 +161,8 @@ module.exports = async() => { |
|
@@ -153,7 +161,8 @@ module.exports = async() => { |
153
|
let insertTotal = 0;
|
161
|
let insertTotal = 0;
|
154
|
|
162
|
|
155
|
products.forEach(async(product, inx) => {
|
163
|
products.forEach(async(product, inx) => {
|
156
|
- const inserted = await lockTask({product, now, sizeRelation});
|
164
|
+ const isSpecialSize = Boolean(specialSizeProducts[product.productId]);
|
|
|
165
|
+ const inserted = await lockTask({product, now, sizeRelation, isSpecialSize});
|
157
|
|
166
|
|
158
|
insertTotal += inserted;
|
167
|
insertTotal += inserted;
|
159
|
if (inx >= products.length - 1) {
|
168
|
if (inx >= products.length - 1) {
|