Authored by 陈峰

commit

... ... @@ -158,3 +158,5 @@ nbproject/*
.scannerwork
package-lock.json
yoho-yohobuy-wap.tar.gz
other/files
\ No newline at end of file
... ...
... ... @@ -28,7 +28,8 @@ schedule.scheduleJob('0 59 23 * * *', () => {
clearTask();
});
// schedule.scheduleJob('0 0 */2 * * *', () => {
// logger.info('[process]task start priceTask');
// priceTask();
// });
schedule.scheduleJob('0 10 * * * *', () => {
logger.info('[process]task start priceTask');
priceTask();
});
priceTask();
... ...
const open = require("open");
const dayjs = require('dayjs');
const shelljs = require('shelljs')
const start = dayjs('2018-12-28 11:00:00');
const end = dayjs(dayjs().format('YYYY-MM-DD HH:00:00'));
const files = shelljs.ls('./other/files')
const download = (hour) => {
const startTime = start.add(hour, 'hour');
const endTime = start.add(hour + 1, 'hour');
if (endTime.diff(end, 'hour') > 0) {
return;
}
const url = `https://h5data.yoho.cn/rs/ufo/prod/size/download?startTime=${startTime.format('YYYYMMDD-HH')}&endTime=${endTime.format('YYYYMMDD-HH')}`;
const file = `${startTime.format('YYYYMMDD-HH')}_${endTime.format('YYYYMMDD-HH')}.xls`
if (!files.some(f => f === file)) {
console.log(file, url)
open(url)
return setTimeout(() => {
download(hour + 1);
}, 1000);
}
setTimeout(() => {
download(hour + 1);
}, 1);
}
download(0)
... ...
... ... @@ -18,6 +18,7 @@
"nedb-promise": "^2.0.1",
"node-lockup": "^1.0.3",
"node-schedule": "^1.3.0",
"open": "^0.0.5",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"winston": "^3.1.0",
... ...
... ... @@ -55,21 +55,27 @@ const task = async(id) => {
const productId = detail.productId;
const soldNum = detail.soldNum;
const sizes = sizeList.map(sizeItem => {
return {
size: sizeItem.size,
price: _.isEmpty(sizeItem.item) ? 0 : sizeItem.item.price,
soldNum: 0
};
});
const dest = await processBuys({
const articleNumber = detail.articleNumber;
// const sizes = sizeList.map(sizeItem => {
// return {
// size: sizeItem.size,
// price: _.isEmpty(sizeItem.item) ? 0 : sizeItem.item.price,
// soldNum: 0
// };
// });
// const dest = await processBuys({
// productId,
// soldNum,
// sizes
// });
return {
productId,
soldNum,
sizes
});
return dest;
articleNumber
};
}
};
... ... @@ -87,7 +93,7 @@ module.exports = async() => {
lockTask(id).then(async result => {
if (result) {
logger.info(`time:${now}; productId:${id}; soldNum:${result.soldNum}; sizeSoldNum:${_.sumBy(result.sizes, 'soldNum')}`);
logger.info(`time:${now}; productId:${id}; soldNum:${result.soldNum};`);
fw.write(`${JSON.stringify(result)}\n`);
}
... ...
const data = [
10000411
,10006053
,10006063
,10006303
,10006821
,10000157
,10001693
,10000339
,10000159
,10001309
,10001663
,10000567
,10000161
,10001223
,10000150
,10001247
,10000597
,10006201
,10000355
,10000631
,10000517
,10000785
,10000461
,10000130
,10000179
,10001017
,10000140
,10000104
,10006105
,10000341
,10000723
,10001207
,10001107
,10000136
,10000503
,10000148
,10000147
,10000189
,10000142
,10001293
,10006701
,10001335
,10000144
,10000835
,10000593
,10001895
,10000107
,10000471
,10000131
,10000115
,10001383
,10000463
,10000783
,10000449
,10000795
,10000787
,10005959
,10000163
,10000615
,10000129
,10000953
,10006589
,10000275
,10000451
,10000331
,10000345
,10000343
,10006111
,10002833
,10000455
,10005479
,10000118
,10000165
,10000419
,10000487
,10000141
,10002211
,10001949
,10001269
,10000591
,10000601
,10000515
,10000571
,10000769
,10006121
,10000114
,10001603
,10003345
,10004915
,10000117
,10000169
,10006113
,10004509
,10001919
,10000481
,10000143
,10006025
,10000789
,10004073
,10001595
,10000297
,10000421
,10000123
,10000641
,10000146
,10003251
,10005127
,10000120
,10000775
,10000771
,10002311
,10000423
,10000187
,10000145
,10001683
,10004981
,10000625
,10004405
,10005067
,10000133
,10000195
,10001027
,10006109
,10006573
,10000793
,10004317
,10006125
,10003445
,10004265
,10004865
,10003333
,10002341
,10003269
,10005079
,10000435
,10004579
,10004307
,10003947
,10000251
,10002143
,10004191
,10002263
,10001209
,10005565
,10000171
,10004955
,10000112
,10000513
,10000589
,10000437
,10000509
,10000599
,10002075
,10004931
,10002295
,10003211
,10000947
,10000128
,10005143
,10000125
,10004207
,10000479
,10003643
,10004953
,10000109
,10003803
,10001557
,10004793
,10000317
,10005889
,10001317
,10000459
,10002769
,10001787
,10000431
,10006083
,10000135
,10004603
,10005747
,10004315
,10004281
,10006217
,10000427
,10002239
,10002331
,10003909
,10003145
,10000305
,10001601
,10004043
,10000469
,10004053
,10004023
,10004855
,10000797
,10002017
,10000551
,10001363
,10006033
,10004555
,10004687
,10004093
,10000351
,10001011
,10004347
,10000629
,10000357
,10000663
,10003699
,10000683
,10000261
,10000561
,10003757
,10000287
,10000139
,10004939
,10004249
,10004895
,10000429
,10000499
,10000127
,10003147
,10000121
,10004131
,10003573
,10006035
,10000113
,10000353
,10000457
,10000233
,10001625
,10000151
,10001331
,10005461
,10004695
,10002417
,10000763
,10004133
,10004727
,10003191
,10000149
,10000105
,10004163
,10002945
,10004369
,10004655
,10004185
,10002125
,10005091
,10005839
,10004267
,10001995
,10004883
,10000116
,10003283
,10003887
,10002291
,10000869
,10000579
,10005919
,10002683
,10000283
,10004859
,10000173]
const task = require('./tasks/price-task')
const tempData = require('./data/skns.json');
console.log(data.length)
console.log(data.filter(item => {
if (tempData.find(a => a.yhId === item)) {
return false
}
return true
}).length)
\ No newline at end of file
task();
\ No newline at end of file
... ...
... ... @@ -858,6 +858,10 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"
open@^0.0.5:
version "0.0.5"
resolved "http://npm.yohops.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"
optionator@^0.8.2:
version "0.8.2"
resolved "http://npm.yohops.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
... ...