eprolo-cli 1.0.109 → 1.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +21 -16
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -254,13 +254,13 @@ async function insertProduct(arg) {
254
254
  title: variant.title,
255
255
  sku: variant.sku
256
256
  };
257
- if(variant.selectedOptions && variant.selectedOptions.length > 0){
258
- variant.selectedOptions.forEach((option, optionIndex) => {
259
- if (index == 0) {
260
- optionList.push({ name: option.name });
261
- }
262
- newInfo['option' + optionIndex] = option.name;
263
- })
257
+ if (variant.selectedOptions && variant.selectedOptions.length > 0) {
258
+ variant.selectedOptions.forEach((option, optionIndex) => {
259
+ if (index == 0) {
260
+ optionList.push({ name: option.name });
261
+ }
262
+ newInfo['option' + optionIndex] = option.name;
263
+ })
264
264
  }
265
265
  variantsList.push(newInfo);
266
266
  })
@@ -275,14 +275,14 @@ async function insertProduct(arg) {
275
275
  if (data.data.msg == "product_id exist") {
276
276
  const result = await postJsonWithRetry(BASE_URL + '/getproduct.html', { product_id: info.product_id }, config, "GET");
277
277
  if (result.data.code == 0) {
278
- console.log(JSON.stringify({
278
+ console.log({
279
279
  variantlist: result.data.data.variantlist.map((item) => {
280
280
  return {
281
281
  variantsid: item.id,
282
282
  sku: item.sku
283
283
  }
284
284
  })
285
- }, null, 2));
285
+ });
286
286
  process.exit(0);
287
287
  }
288
288
  } else {
@@ -290,14 +290,14 @@ async function insertProduct(arg) {
290
290
  process.exit(0);
291
291
  }
292
292
  }
293
- console.log(JSON.stringify({
293
+ console.log({
294
294
  variantlist: data.data.data.variantsList.map((item) => {
295
295
  return {
296
296
  variantsid: item.id,
297
297
  sku: item.sku
298
298
  }
299
299
  })
300
- }, null, 2));
300
+ });
301
301
  process.exit(0);
302
302
  }
303
303
  async function addOrder(arg) {
@@ -324,15 +324,20 @@ async function addOrder(arg) {
324
324
  }
325
325
  if (order.lineItems && order.lineItems.edges) {
326
326
  order.lineItems.edges.forEach((edge) => {
327
- orderItemlist.push({
328
- variantsid: getId(edge.node.variant.id),
329
- quantity: edge.node.quantity,
330
- })
327
+ console.log("-------666----------", order.lineItems.eproloSyncResult[edge.node.product.id].message);
328
+ let newOrderItemlist = { quantity: edge.node.quantity }
329
+ let messageResult = order.lineItems.eproloSyncResult[edge.node.product.id].message;
330
+ if (messageResult) {
331
+ let newMessage = JSON.parse(messageResult);
332
+ newOrderItemlist.variantsid = newMessage.variantlist.find((item) => item.sku == edge.node.sku).variantsid;
333
+ }
334
+ orderItemlist.push(newOrderItemlist)
331
335
  })
332
336
  newOrder.orderItemlist = orderItemlist;
333
337
  }
334
338
  console.log("-------222----------", newOrder);
335
- const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, newOrder, config, "POST");
339
+ // const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, newOrder, config, "POST");
340
+ const data = await postJsonWithRetry(BASE_URL + '/add_order.html', newOrder, config, "POST");
336
341
  console.log(JSON.stringify(data, null, 2));
337
342
  process.exit(0);
338
343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.109",
3
+ "version": "1.0.110",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"