shawenguan hace 1 año
padre
commit
c3bf76e59d
Se han modificado 1 ficheros con 13 adiciones y 7 borrados
  1. 13 7
      Scripts/imoutai/imoutaiHelper.js

+ 13 - 7
Scripts/imoutai/imoutaiHelper.js

@@ -112,12 +112,20 @@ async function main() {
     ];
     for(let i=0; i < itemCodes.length;i++){
         const itemId = itemCodes[i];
-        lk.log(`#############${itemId}#############`);
-        let maxShopId = await getShopItem(sessionId,itemId,userData.token,userData.deviceId,province,city,iMT_Location.district||'',zeroTimeStamp);
-        if(!maxShopId || maxShopId == '0'){
+        lk.log(`#############[${itemId}]${iMT_Products[itemId]}#############`);
+        let maxShopData = await getShopItem(sessionId,itemId,userData.token,userData.deviceId,province,city,iMT_Location.district||'',zeroTimeStamp);
+        if(!maxShopData || maxShopData.shopId == '0'){
             continue;
         }
+        let maxShopId = maxShopData.shopId;
         lk.log(`maxShopId=${maxShopId}`);
+        const maxShopItemData = maxShopData.itemData;// const { count, itemId, inventory, ownerName } = maxShopItemData;
+        let maxShopMsg = `【${maxShopItemData.ownerName}】[${maxShopId}-${itemId}] ${getProductInfo(itemId, 'title')}  价格:${getProductInfo(itemId, 'price')}  库存:${maxShopItemData.inventory}`;
+        lk.log(maxShopMsg);
+        msgItems.push({
+            name: '申购产品',
+            value: maxShopMsg,
+        });
         let retMsg = await mtAdd(sessionId,itemId,maxShopId,userData.userId,userData.token,userData.deviceId);
         if (retMsg) {
             msgItems.push({
@@ -692,7 +700,7 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, d
                             if (jsonRetObj.code == 2000) {
                                 const rspData = jsonRetObj.data || {};
                                 let shops = rspData.shops || [];
-                                iMT_DynProducts = rspData.items;
+                                iMT_DynProducts = rspData.items || [];
                                 lk.log(`data=${JSON.stringify(rspData.items)}`);
                                 if(fliterRule == 0){
                                     shops = fliterShopByDistance(itemId, shops, iMT_Location.lat, iMT_Location.lng);
@@ -712,9 +720,7 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, d
                                         if (findIndex > -1) {
                                             lk.log(`shopInfo=${JSON.stringify(shopInfo)}`);
                                             lk.log(`skuData=${JSON.stringify(skuData)}`);
-                                            const { count, itemId, inventory, ownerName } = skuData.items[findIndex];
-                                            lk.log(`【${ownerName}】[${shopId}-${itemId}] ${getProductInfo(itemId, 'title')}  价格:${getProductInfo(itemId, 'price')}  库存:${inventory}`);
-                                            ret = shopId;
+                                            ret = {shopId: shopId, itemId:itemId, itemData: skuData.items[findIndex]};
                                             break;
                                         }
                                     }