Authored by 陈峰

commit

@@ -158,3 +158,5 @@ nbproject/* @@ -158,3 +158,5 @@ nbproject/*
158 .scannerwork 158 .scannerwork
159 package-lock.json 159 package-lock.json
160 yoho-yohobuy-wap.tar.gz 160 yoho-yohobuy-wap.tar.gz
  161 +
  162 +other/files
@@ -28,7 +28,8 @@ schedule.scheduleJob('0 59 23 * * *', () => { @@ -28,7 +28,8 @@ schedule.scheduleJob('0 59 23 * * *', () => {
28 clearTask(); 28 clearTask();
29 }); 29 });
30 30
31 -// schedule.scheduleJob('0 0 */2 * * *', () => {  
32 -// logger.info('[process]task start priceTask');  
33 -// priceTask();  
34 -// }); 31 +schedule.scheduleJob('0 10 * * * *', () => {
  32 + logger.info('[process]task start priceTask');
  33 + priceTask();
  34 +});
  35 +priceTask();
  1 +const open = require("open");
  2 +const dayjs = require('dayjs');
  3 +const shelljs = require('shelljs')
  4 +
  5 +const start = dayjs('2018-12-28 11:00:00');
  6 +const end = dayjs(dayjs().format('YYYY-MM-DD HH:00:00'));
  7 +
  8 +const files = shelljs.ls('./other/files')
  9 +
  10 +
  11 +
  12 +const download = (hour) => {
  13 + const startTime = start.add(hour, 'hour');
  14 + const endTime = start.add(hour + 1, 'hour');
  15 +
  16 + if (endTime.diff(end, 'hour') > 0) {
  17 + return;
  18 + }
  19 + const url = `https://h5data.yoho.cn/rs/ufo/prod/size/download?startTime=${startTime.format('YYYYMMDD-HH')}&endTime=${endTime.format('YYYYMMDD-HH')}`;
  20 + const file = `${startTime.format('YYYYMMDD-HH')}_${endTime.format('YYYYMMDD-HH')}.xls`
  21 +
  22 + if (!files.some(f => f === file)) {
  23 + console.log(file, url)
  24 + open(url)
  25 +
  26 + return setTimeout(() => {
  27 + download(hour + 1);
  28 + }, 1000);
  29 +
  30 + }
  31 + setTimeout(() => {
  32 + download(hour + 1);
  33 + }, 1);
  34 +}
  35 +
  36 +download(0)
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 "nedb-promise": "^2.0.1", 18 "nedb-promise": "^2.0.1",
19 "node-lockup": "^1.0.3", 19 "node-lockup": "^1.0.3",
20 "node-schedule": "^1.3.0", 20 "node-schedule": "^1.3.0",
  21 + "open": "^0.0.5",
21 "request": "^2.88.0", 22 "request": "^2.88.0",
22 "request-promise": "^4.2.2", 23 "request-promise": "^4.2.2",
23 "winston": "^3.1.0", 24 "winston": "^3.1.0",
@@ -55,21 +55,27 @@ const task = async(id) => { @@ -55,21 +55,27 @@ const task = async(id) => {
55 55
56 const productId = detail.productId; 56 const productId = detail.productId;
57 const soldNum = detail.soldNum; 57 const soldNum = detail.soldNum;
58 - const sizes = sizeList.map(sizeItem => {  
59 - return {  
60 - size: sizeItem.size,  
61 - price: _.isEmpty(sizeItem.item) ? 0 : sizeItem.item.price,  
62 - soldNum: 0  
63 - };  
64 - }); 58 + const articleNumber = detail.articleNumber;
  59 +
  60 + // const sizes = sizeList.map(sizeItem => {
  61 + // return {
  62 + // size: sizeItem.size,
  63 + // price: _.isEmpty(sizeItem.item) ? 0 : sizeItem.item.price,
  64 + // soldNum: 0
  65 + // };
  66 + // });
  67 +
  68 + // const dest = await processBuys({
  69 + // productId,
  70 + // soldNum,
  71 + // sizes
  72 + // });
65 73
66 - const dest = await processBuys({ 74 + return {
67 productId, 75 productId,
68 soldNum, 76 soldNum,
69 - sizes  
70 - });  
71 -  
72 - return dest; 77 + articleNumber
  78 + };
73 } 79 }
74 }; 80 };
75 81
@@ -87,7 +93,7 @@ module.exports = async() => { @@ -87,7 +93,7 @@ module.exports = async() => {
87 lockTask(id).then(async result => { 93 lockTask(id).then(async result => {
88 if (result) { 94 if (result) {
89 95
90 - logger.info(`time:${now}; productId:${id}; soldNum:${result.soldNum}; sizeSoldNum:${_.sumBy(result.sizes, 'soldNum')}`); 96 + logger.info(`time:${now}; productId:${id}; soldNum:${result.soldNum};`);
91 97
92 fw.write(`${JSON.stringify(result)}\n`); 98 fw.write(`${JSON.stringify(result)}\n`);
93 } 99 }
1 -const data = [  
2 - 10000411  
3 - ,10006053  
4 - ,10006063  
5 - ,10006303  
6 - ,10006821  
7 - ,10000157  
8 - ,10001693  
9 - ,10000339  
10 - ,10000159  
11 - ,10001309  
12 - ,10001663  
13 - ,10000567  
14 - ,10000161  
15 - ,10001223  
16 - ,10000150  
17 - ,10001247  
18 - ,10000597  
19 - ,10006201  
20 - ,10000355  
21 - ,10000631  
22 - ,10000517  
23 - ,10000785  
24 - ,10000461  
25 - ,10000130  
26 - ,10000179  
27 - ,10001017  
28 - ,10000140  
29 - ,10000104  
30 - ,10006105  
31 - ,10000341  
32 - ,10000723  
33 - ,10001207  
34 - ,10001107  
35 - ,10000136  
36 - ,10000503  
37 - ,10000148  
38 - ,10000147  
39 - ,10000189  
40 - ,10000142  
41 - ,10001293  
42 - ,10006701  
43 - ,10001335  
44 - ,10000144  
45 - ,10000835  
46 - ,10000593  
47 - ,10001895  
48 - ,10000107  
49 - ,10000471  
50 - ,10000131  
51 - ,10000115  
52 - ,10001383  
53 - ,10000463  
54 - ,10000783  
55 - ,10000449  
56 - ,10000795  
57 - ,10000787  
58 - ,10005959  
59 - ,10000163  
60 - ,10000615  
61 - ,10000129  
62 - ,10000953  
63 - ,10006589  
64 - ,10000275  
65 - ,10000451  
66 - ,10000331  
67 - ,10000345  
68 - ,10000343  
69 - ,10006111  
70 - ,10002833  
71 - ,10000455  
72 - ,10005479  
73 - ,10000118  
74 - ,10000165  
75 - ,10000419  
76 - ,10000487  
77 - ,10000141  
78 - ,10002211  
79 - ,10001949  
80 - ,10001269  
81 - ,10000591  
82 - ,10000601  
83 - ,10000515  
84 - ,10000571  
85 - ,10000769  
86 - ,10006121  
87 - ,10000114  
88 - ,10001603  
89 - ,10003345  
90 - ,10004915  
91 - ,10000117  
92 - ,10000169  
93 - ,10006113  
94 - ,10004509  
95 - ,10001919  
96 - ,10000481  
97 - ,10000143  
98 - ,10006025  
99 - ,10000789  
100 - ,10004073  
101 - ,10001595  
102 - ,10000297  
103 - ,10000421  
104 - ,10000123  
105 - ,10000641  
106 - ,10000146  
107 - ,10003251  
108 - ,10005127  
109 - ,10000120  
110 - ,10000775  
111 - ,10000771  
112 - ,10002311  
113 - ,10000423  
114 - ,10000187  
115 - ,10000145  
116 - ,10001683  
117 - ,10004981  
118 - ,10000625  
119 - ,10004405  
120 - ,10005067  
121 - ,10000133  
122 - ,10000195  
123 - ,10001027  
124 - ,10006109  
125 - ,10006573  
126 - ,10000793  
127 - ,10004317  
128 - ,10006125  
129 - ,10003445  
130 - ,10004265  
131 - ,10004865  
132 - ,10003333  
133 - ,10002341  
134 - ,10003269  
135 - ,10005079  
136 - ,10000435  
137 - ,10004579  
138 - ,10004307  
139 - ,10003947  
140 - ,10000251  
141 - ,10002143  
142 - ,10004191  
143 - ,10002263  
144 - ,10001209  
145 - ,10005565  
146 - ,10000171  
147 - ,10004955  
148 - ,10000112  
149 - ,10000513  
150 - ,10000589  
151 - ,10000437  
152 - ,10000509  
153 - ,10000599  
154 - ,10002075  
155 - ,10004931  
156 - ,10002295  
157 - ,10003211  
158 - ,10000947  
159 - ,10000128  
160 - ,10005143  
161 - ,10000125  
162 - ,10004207  
163 - ,10000479  
164 - ,10003643  
165 - ,10004953  
166 - ,10000109  
167 - ,10003803  
168 - ,10001557  
169 - ,10004793  
170 - ,10000317  
171 - ,10005889  
172 - ,10001317  
173 - ,10000459  
174 - ,10002769  
175 - ,10001787  
176 - ,10000431  
177 - ,10006083  
178 - ,10000135  
179 - ,10004603  
180 - ,10005747  
181 - ,10004315  
182 - ,10004281  
183 - ,10006217  
184 - ,10000427  
185 - ,10002239  
186 - ,10002331  
187 - ,10003909  
188 - ,10003145  
189 - ,10000305  
190 - ,10001601  
191 - ,10004043  
192 - ,10000469  
193 - ,10004053  
194 - ,10004023  
195 - ,10004855  
196 - ,10000797  
197 - ,10002017  
198 - ,10000551  
199 - ,10001363  
200 - ,10006033  
201 - ,10004555  
202 - ,10004687  
203 - ,10004093  
204 - ,10000351  
205 - ,10001011  
206 - ,10004347 1 +const task = require('./tasks/price-task')
207 2
208 - ,10000629  
209 - ,10000357  
210 - ,10000663  
211 - ,10003699  
212 -  
213 - ,10000683  
214 -  
215 -  
216 - ,10000261  
217 - ,10000561  
218 -  
219 - ,10003757  
220 - ,10000287  
221 - ,10000139  
222 - ,10004939  
223 - ,10004249  
224 - ,10004895  
225 -  
226 - ,10000429  
227 - ,10000499  
228 - ,10000127  
229 - ,10003147  
230 - ,10000121  
231 - ,10004131  
232 - ,10003573  
233 - ,10006035  
234 -  
235 -  
236 - ,10000113  
237 - ,10000353  
238 - ,10000457  
239 - ,10000233  
240 - ,10001625  
241 - ,10000151  
242 - ,10001331  
243 - ,10005461  
244 - ,10004695  
245 -  
246 - ,10002417  
247 - ,10000763  
248 - ,10004133  
249 -  
250 -  
251 -  
252 - ,10004727  
253 - ,10003191  
254 - ,10000149  
255 - ,10000105  
256 -  
257 - ,10004163  
258 - ,10002945  
259 - ,10004369  
260 - ,10004655  
261 - ,10004185  
262 - ,10002125  
263 - ,10005091  
264 - ,10005839  
265 - ,10004267  
266 - ,10001995  
267 -  
268 - ,10004883  
269 - ,10000116  
270 - ,10003283  
271 - ,10003887  
272 - ,10002291  
273 - ,10000869  
274 - ,10000579  
275 - ,10005919  
276 -  
277 - ,10002683  
278 - ,10000283  
279 - ,10004859  
280 - ,10000173]  
281 -  
282 -  
283 -  
284 - const tempData = require('./data/skns.json');  
285 -  
286 -console.log(data.length)  
287 - console.log(data.filter(item => {  
288 - if (tempData.find(a => a.yhId === item)) {  
289 - return false  
290 - }  
291 - return true  
292 - }).length)  
  3 +task();
@@ -858,6 +858,10 @@ onetime@^2.0.0: @@ -858,6 +858,10 @@ onetime@^2.0.0:
858 dependencies: 858 dependencies:
859 mimic-fn "^1.0.0" 859 mimic-fn "^1.0.0"
860 860
  861 +open@^0.0.5:
  862 + version "0.0.5"
  863 + resolved "http://npm.yohops.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"
  864 +
861 optionator@^0.8.2: 865 optionator@^0.8.2:
862 version "0.8.2" 866 version "0.8.2"
863 resolved "http://npm.yohops.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" 867 resolved "http://npm.yohops.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"