tango-app-api-infra 3.1.26 → 3.1.28

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.1.26",
3
+ "version": "3.1.28",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -69,6 +69,19 @@ export async function createTicket( req, res ) {
69
69
  showToClient: req.body.showToClient,
70
70
  processType: ( auditInputData?.data?.length && auditOutputData?.data?.length ) ? 'audit' : 'reduction',
71
71
  };
72
+
73
+ const reqData = {
74
+ 'dateString': dayjs( new Date( req.body.Date ) ).format( 'YYYY-MM-DD' ),
75
+ 'storeId': req.body.storeId,
76
+ };
77
+
78
+
79
+ const getFootfall = await postApi( `${JSON.parse( process.env.URL ).oldapidomain}/getFootfall`, reqData );
80
+
81
+ if ( getFootfall?.data?.length ) {
82
+ req.body.dataMismatch['reportedFootfall'] = getFootfall.data[0].footfall_count;
83
+ }
84
+
72
85
  req.body.issueDate = new Date( req.body.Date );
73
86
  req.body.ticketId = 'TE_DM_' + new Date().valueOf();
74
87
  let create = await createTangoTicket( req.body );
@@ -118,6 +131,25 @@ export async function createTicket( req, res ) {
118
131
  }
119
132
  }
120
133
 
134
+ async function postApi( url, data ) {
135
+ const requestOptions = {
136
+ method: 'POST',
137
+ headers: {
138
+ 'Content-Type': 'application/json',
139
+ 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66',
140
+ },
141
+ body: JSON.stringify( data ),
142
+ };
143
+
144
+ try {
145
+ const response = await fetch( url, requestOptions );
146
+ const data = await response.json();
147
+ return data;
148
+ } catch ( error ) {
149
+ logger.error( { error: error, message: data, function: 'postApi' } );
150
+ }
151
+ }
152
+
121
153
  export async function updateMat( req, res ) {
122
154
  try {
123
155
  let updateValue = {};
@@ -76,6 +76,7 @@ export async function clientList( req, res ) {
76
76
  try {
77
77
  let clientList = await findClient( { status: { $in: [ 'active', 'hold' ] } },
78
78
  { 'clientName': 1, 'clientId': 1, 'ticketConfigs': 1 } );
79
+ logger.info({clientList:clientList,"message":"clientList"})
79
80
  res.sendSuccess( clientList );
80
81
  } catch ( error ) {
81
82
  logger.error( { error: error, function: 'basicList' } );
@@ -92,6 +93,8 @@ export async function basicList( req, res ) {
92
93
  }
93
94
  let storeList = await findStore( { 'clientId': { $in: clients }, 'status': 'active', 'edge.firstFile': true },
94
95
  { 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
96
+ logger.info({storeList:storeList,"message":"storeList"})
97
+
95
98
  res.sendSuccess( storeList );
96
99
  } catch ( error ) {
97
100
  logger.error( { error: error, function: 'basicList' } );
@@ -103,6 +106,7 @@ export async function basicList( req, res ) {
103
106
  export async function setTicketTime( req, res ) {
104
107
  try {
105
108
  let input = req.body;
109
+ logger.info( { input: input ,"message":"setTicketTime"} );
106
110
  for ( let i = 0; i < input.stores.length; i++ ) {
107
111
  await updateOneStore( { storeId: input.stores[i].storeId }, { 'ticketConfigs.nextTicektGenerationTime': new Date( input.stores[i].nextTicektGenerationTime ) } );
108
112
  };
@@ -116,6 +120,7 @@ export async function setTicketTime( req, res ) {
116
120
  export async function downStoresList( req, res ) {
117
121
  try {
118
122
  let storesList = await findStore( { 'ticketConfigs.hibernation': { $lt: new Date() }, 'ticketConfigs.nextTicektGenerationTime': new Date( req.body.getTime ) }, { storeId: 1, storeName: 1, storeProfile: 1, ticketConfigs: 1 } );
123
+ logger.info( { storesList: storesList,"message":"downStoresList" } );
119
124
  if ( storesList.length > 0 ) {
120
125
  res.sendSuccess( storesList );
121
126
  } else {