|
@@ -112,12 +112,20 @@ async function main() {
|
|
|
];
|
|
];
|
|
|
for(let i=0; i < itemCodes.length;i++){
|
|
for(let i=0; i < itemCodes.length;i++){
|
|
|
const itemId = itemCodes[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;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ let maxShopId = maxShopData.shopId;
|
|
|
lk.log(`maxShopId=${maxShopId}`);
|
|
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);
|
|
let retMsg = await mtAdd(sessionId,itemId,maxShopId,userData.userId,userData.token,userData.deviceId);
|
|
|
if (retMsg) {
|
|
if (retMsg) {
|
|
|
msgItems.push({
|
|
msgItems.push({
|
|
@@ -692,7 +700,7 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, d
|
|
|
if (jsonRetObj.code == 2000) {
|
|
if (jsonRetObj.code == 2000) {
|
|
|
const rspData = jsonRetObj.data || {};
|
|
const rspData = jsonRetObj.data || {};
|
|
|
let shops = rspData.shops || [];
|
|
let shops = rspData.shops || [];
|
|
|
- iMT_DynProducts = rspData.items;
|
|
|
|
|
|
|
+ iMT_DynProducts = rspData.items || [];
|
|
|
lk.log(`data=${JSON.stringify(rspData.items)}`);
|
|
lk.log(`data=${JSON.stringify(rspData.items)}`);
|
|
|
if(fliterRule == 0){
|
|
if(fliterRule == 0){
|
|
|
shops = fliterShopByDistance(itemId, shops, iMT_Location.lat, iMT_Location.lng);
|
|
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) {
|
|
if (findIndex > -1) {
|
|
|
lk.log(`shopInfo=${JSON.stringify(shopInfo)}`);
|
|
lk.log(`shopInfo=${JSON.stringify(shopInfo)}`);
|
|
|
lk.log(`skuData=${JSON.stringify(skuData)}`);
|
|
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;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|