Skip to content

Commit f2a4670

Browse files
authored
Merge pull request ONDC-Official#25 from ONDC-Official/V.1.2.0
customisation refactoring at org level + log fixes
2 parents b74e9ae + ff259ef commit f2a4670

32 files changed

+126941
-1275
lines changed

seller-app-api/lib/config/development_env_config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
},
8585
"sellerConfig": {
8686
"BPP_ID": "sellerapp-staging.datasyndicate.in",
87-
"BPP_URI": "https://c38b-2402-e280-3e33-24e-2d49-d6ad-2534-226e.ngrok-free.app",
87+
"BPP_URI": "https://7e3b-2401-4900-1c5d-2b13-814b-de08-9df3-b44e.ngrok-free.app",
8888
"BAP_ID": "sellerapp-staging.datasyndicate.in",
89-
"BAP_URI": "https://c38b-2402-e280-3e33-24e-2d49-d6ad-2534-226e.ngrok-free.app",
89+
"BAP_URI": "https://7e3b-2401-4900-1c5d-2b13-814b-de08-9df3-b44e.ngrok-free.app",
9090
"LOGISTICS_BAP_ID": "dev-ondc.shiprocket.in",
9191
"LOGISTICS_DELIVERY_TYPE": "Same Day Delivery",
9292
"storeOpenSchedule": {

seller-app-api/lib/config/production_env_config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
},
8383
"sellerConfig": {
8484
"BPP_ID": "sellerapp-staging.datasyndicate.in",
85-
"BPP_URI": "https://6607-2402-e280-3e33-24e-7533-b3a7-881b-4166.in.ngrok.io",
85+
"BPP_URI": "https://7e3b-2401-4900-1c5d-2b13-814b-de08-9df3-b44e.ngrok-free.app",
8686
"BAP_ID": "sellerapp-staging.datasyndicate.in",
87-
"BAP_URI": "https://6607-2402-e280-3e33-24e-7533-b3a7-881b-4166.in.ngrok.io",
87+
"BAP_URI": "https://7e3b-2401-4900-1c5d-2b13-814b-de08-9df3-b44e.ngrok-free.app",
8888
"storeOpenSchedule": {
8989
"time": {
9090
"days": "1,2,3,4,5,6,7",

seller-app-api/services/v2/ondc.service.js

+34-59
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ class OndcService {
2222

2323
const order = payload;
2424
const selectMessageId = payload.context.message_id;
25-
2625
this.postSearchRequest(order, selectMessageId)
2726

28-
return {}
27+
return {"message": {"ack": {"status": "ACK"}}}
2928
} catch (err) {
3029
logger.error('error', `[Ondc Service] search logistics payload - search logistics payload : param :`, err);
3130
throw err;
@@ -55,46 +54,14 @@ class OndcService {
5554
let totalPrice = 0
5655
let itemData = {};
5756
for (let item of payload.message.order.items) {
58-
let tags = item.tags;
59-
if (tags && tags.length > 0) {
60-
let tagData = tags.find((tag) => {
61-
return tag.code === 'type'
62-
})
63-
let tagTypeData = tagData.list.find((tagType) => {
64-
return tagType.code === 'type'
65-
})
66-
itemType = tagTypeData.value;
67-
if (itemType === 'customization') {
68-
resultData = itemData?.customizationDetails?.customizations.find((row) => {
69-
return row._id === item.id
70-
})
71-
if (resultData) {
72-
73-
if (resultData) {
74-
let price = resultData?.price * item.quantity.count
75-
totalPrice += price
76-
}
77-
}
78-
} else {
79-
resultData = await productService.getForOndc(item.id)
80-
if (Object.keys(resultData).length > 0) {
81-
82-
if (resultData?.commonDetails) {
83-
let price = resultData?.commonDetails?.MRP * item.quantity.count
84-
totalPrice += price
85-
}
86-
87-
}
88-
}
89-
90-
} else {
91-
resultData = await productService.getForOndc(item.id)
92-
if (Object.keys(resultData).length > 0) {
93-
94-
if (resultData?.commonDetails) {
95-
let price = resultData?.commonDetails?.MRP * item.quantity.count
96-
totalPrice += price
97-
}
57+
resultData = await productService.getForOndc(item.id)
58+
if (Object.keys(resultData).length > 0) {
59+
if (resultData?.commonDetails) {
60+
let price = resultData?.commonDetails?.MRP * item.quantity.count
61+
totalProductValue += price
62+
}else{
63+
let price = resultData?.MRP * item.quantity.count
64+
totalProductValue += price
9865
}
9966
}
10067
}
@@ -274,7 +241,7 @@ class OndcService {
274241
//process select request and send it to protocol layer
275242
this.postSelectRequest(searchRequest, logisticsMessageId, selectMessageId)
276243

277-
return searchRequest
244+
return {"message": {"ack": {"status": "ACK"}}}
278245
} catch (err) {
279246
logger.error('error', `[Ondc Service] search logistics payload - search logistics payload : param :`, err);
280247
throw err;
@@ -829,7 +796,7 @@ class OndcService {
829796

830797
this.postInitRequest(initRequest, logisticsMessageId, initMessageId)
831798

832-
return {'status': 'ACK'}
799+
return {"message": {"ack": {"status": "ACK"}}}
833800
} catch (err) {
834801
logger.error('error', `[Ondc Service] build init request :`, {error: err.stack, message: err.message});
835802
console.log(err)
@@ -1087,7 +1054,8 @@ class OndcService {
10871054
"message_id": logisticsMessageId,
10881055
"city": logistics.context.city,
10891056
"country": "IND",
1090-
"timestamp": contextTimestamp
1057+
"timestamp": contextTimestamp,
1058+
"ttl": "PT30S"
10911059
},
10921060
"message": {
10931061
"order": {
@@ -1227,7 +1195,7 @@ class OndcService {
12271195
this.postConfirmRequest(confirmRequest, logisticsMessageId, selectMessageId)
12281196
//}, 10000); //TODO move to config
12291197

1230-
return {status: "ACK"}
1198+
return {"message": {"ack": {"status": "ACK"}}}
12311199
} catch (err) {
12321200
throw err;
12331201
}
@@ -1416,7 +1384,8 @@ class OndcService {
14161384
"message_id": logisticsMessageId,
14171385
"city": "std:080",
14181386
"country": "IND",
1419-
"timestamp": new Date()
1387+
"timestamp": new Date(),
1388+
"ttl": "PT30S"
14201389
},
14211390
"message":
14221391
{
@@ -1431,7 +1400,7 @@ class OndcService {
14311400
this.postTrackRequest(trackRequest, logisticsMessageId, selectMessageId)
14321401
// }, 5000); //TODO move to config
14331402

1434-
return {status: 'ACK'}
1403+
return {"message": {"ack": {"status": "ACK"}}}
14351404
} catch (err) {
14361405
throw err;
14371406
}
@@ -1549,7 +1518,8 @@ class OndcService {
15491518
"message_id": logisticsMessageId,
15501519
"city": "std:080",
15511520
"country": "IND",
1552-
"timestamp": new Date()
1521+
"timestamp": new Date(),
1522+
"ttl": "PT30S"
15531523
},
15541524
"message":
15551525
{
@@ -1564,7 +1534,7 @@ class OndcService {
15641534
this.postStatusRequest(statusRequest, logisticsMessageId, selectMessageId, unsoliciated, payload)
15651535
//}, 5000); //TODO move to config
15661536

1567-
return {status: 'ACK'}
1537+
return {"message": {"ack": {"status": "ACK"}}}
15681538
} catch (err) {
15691539
throw err;
15701540
}
@@ -1622,7 +1592,8 @@ class OndcService {
16221592
"message_id": logisticsMessageId,
16231593
"city": "std:080", //TODO: take it from request
16241594
"country": "IND",
1625-
"timestamp": new Date()
1595+
"timestamp": new Date(),
1596+
"ttl": "PT30S"
16261597
},
16271598
"message": {
16281599
"order": {
@@ -1716,16 +1687,17 @@ class OndcService {
17161687
"context": {
17171688
"domain": "nic2004:60232",
17181689
"action": "cancel",
1719-
"core_version": "1.1.0",
1690+
"core_version": "1.2.0",
17201691
"bap_id": config.get("sellerConfig").BPP_ID,
1721-
"bap_uri": config.get("sellerConfig").BPP_URI,
1692+
"bap_uri": config.get("sellerConfig").BAP_URI,
17221693
"bpp_id": logistics.context.bpp_id,//STORED OBJECT
17231694
"bpp_uri": logistics.context.bpp_uri, //STORED OBJECT
17241695
"transaction_id": confirmRequest.logisticsTransactionId,
17251696
"message_id": logisticsMessageId,
17261697
"city": "std:080", //TODO: take it from request
17271698
"country": "IND",
1728-
"timestamp": new Date()
1699+
"timestamp": new Date(),
1700+
"ttl": "PT30S"
17291701
},
17301702
"message": {
17311703
"order_id": order.orderId,
@@ -1778,7 +1750,8 @@ class OndcService {
17781750
"message_id": logisticsMessageId,
17791751
"city": "std:080", //TODO: take it from request
17801752
"country": "IND",
1781-
"timestamp": new Date()
1753+
"timestamp": new Date(),
1754+
"ttl": "PT30S"
17821755
},
17831756
"message": {
17841757
"order": {
@@ -1842,7 +1815,7 @@ class OndcService {
18421815
//process select request and send it to protocol layer
18431816
this.postUpdateRequestV2(searchRequest, null, updateMessageId)
18441817

1845-
return {status: 'ACK'}
1818+
return {"message": {"ack": {"status": "ACK"}}}
18461819
} catch (err) {
18471820
throw err;
18481821
}
@@ -2238,7 +2211,8 @@ class OndcService {
22382211
"message_id": logisticsMessageId,
22392212
"city": "std:080",
22402213
"country": "IND",
2241-
"timestamp": new Date()
2214+
"timestamp": new Date(),
2215+
"ttl": "PT30S"
22422216
},
22432217
"message":
22442218
{
@@ -2254,7 +2228,7 @@ class OndcService {
22542228
this.postCancelRequest(trackRequest, logisticsMessageId, selectMessageId)
22552229
//}, 5000); //TODO move to config
22562230

2257-
return {status: 'ACK'}
2231+
return {"message": {"ack": {"status": "ACK"}}}
22582232
} catch (err) {
22592233
throw err;
22602234
}
@@ -2636,7 +2610,8 @@ class OndcService {
26362610
"message_id": logisticsMessageId,
26372611
"city": "std:080",
26382612
"country": "IND",
2639-
"timestamp": new Date()
2613+
"timestamp": new Date(),
2614+
"ttl": "PT30S"
26402615
},
26412616
"message":
26422617
{

0 commit comments

Comments
 (0)