Commit 3aa57883cda6942995793bcab92ffe603f6e3317
1 parent
03f3be38
Exists in
master
and in
1 other branch
fix bug
Showing
2 changed files
with
9 additions
and
9 deletions
Show diff stats
ais-structure/src/modules/helper/connection.js
@@ -508,7 +508,7 @@ function arrayUrl(arrUrl,url,filter,fields,freeSpace,arrData) | @@ -508,7 +508,7 @@ function arrayUrl(arrUrl,url,filter,fields,freeSpace,arrData) | ||
508 | } | 508 | } |
509 | 509 | ||
510 | if(loopUrl != "") | 510 | if(loopUrl != "") |
511 | - arrUrl.push(url+"?filter=("+filter+"(|"+loopUrl+")"+fields); | 511 | + arrUrl.push(url+"?filter=("+filter+"(|"+loopUrl+"))"+fields); |
512 | return arrUrl; | 512 | return arrUrl; |
513 | } | 513 | } |
514 | 514 |
ais-structure/src/modules/membercard/postMembership.ctrl.js
@@ -34,7 +34,6 @@ exports.postMembership = async function (req, res, next){ | @@ -34,7 +34,6 @@ exports.postMembership = async function (req, res, next){ | ||
34 | if(err.length > 0) | 34 | if(err.length > 0) |
35 | { | 35 | { |
36 | log.addErrorSummary(req,req.body.clientName, postMethod+"_"+getCmd, "null", "Fail"); | 36 | log.addErrorSummary(req,req.body.clientName, postMethod+"_"+getCmd, "null", "Fail"); |
37 | - // console.log(err); | ||
38 | var response = responseMsg.error(req, getCmd, 40300); | 37 | var response = responseMsg.error(req, getCmd, 40300); |
39 | }else | 38 | }else |
40 | { | 39 | { |
@@ -99,7 +98,6 @@ exports.postMembership = async function (req, res, next){ | @@ -99,7 +98,6 @@ exports.postMembership = async function (req, res, next){ | ||
99 | log.addSuccessSummary(req,d01,getMethod+"_"+sendMemberCardCmd,resultObj.resultCode,resultObj.resultDescription); | 98 | log.addSuccessSummary(req,d01,getMethod+"_"+sendMemberCardCmd,resultObj.resultCode,resultObj.resultDescription); |
100 | 99 | ||
101 | var todo = await checkOwnerCard(resultObj.resultData,objectData); | 100 | var todo = await checkOwnerCard(resultObj.resultData,objectData); |
102 | - // console.log(todo); | ||
103 | if(todo){ | 101 | if(todo){ |
104 | var getCustomer = await getCustomerD01(req, objDataGetCustomer); | 102 | var getCustomer = await getCustomerD01(req, objDataGetCustomer); |
105 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); | 103 | var response = await getCustomerHandler(req, getCustomer, resultObj, objDataMembership); |
@@ -145,7 +143,6 @@ exports.postMembership = async function (req, res, next){ | @@ -145,7 +143,6 @@ exports.postMembership = async function (req, res, next){ | ||
145 | 143 | ||
146 | function validator(req, api) | 144 | function validator(req, api) |
147 | { | 145 | { |
148 | - // console.log(req.body); | ||
149 | var list = []; | 146 | var list = []; |
150 | list.push([true, "body", "commandId", "int"]); | 147 | list.push([true, "body", "commandId", "int"]); |
151 | list.push([true, "body", "clientName", "string"]); | 148 | list.push([true, "body", "clientName", "string"]); |
@@ -207,7 +204,6 @@ async function postMemberCardD01(req, data){ | @@ -207,7 +204,6 @@ async function postMemberCardD01(req, data){ | ||
207 | isDirect : false | 204 | isDirect : false |
208 | }; | 205 | }; |
209 | 206 | ||
210 | - // console.log(data) | ||
211 | 207 | ||
212 | const resultCustomer = await connection.requestJsonToD01(req,data.reqMembership, data.cmd, data.method, data.filter); | 208 | const resultCustomer = await connection.requestJsonToD01(req,data.reqMembership, data.cmd, data.method, data.filter); |
213 | var resultObj = resultCustomer.response | 209 | var resultObj = resultCustomer.response |
@@ -232,7 +228,6 @@ async function postMemberCardD01(req, data){ | @@ -232,7 +228,6 @@ async function postMemberCardD01(req, data){ | ||
232 | 228 | ||
233 | async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMembership){ | 229 | async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMembership){ |
234 | 230 | ||
235 | - // console.log(getCustomer.response) | ||
236 | if(!getCustomer.isErr){ | 231 | if(!getCustomer.isErr){ |
237 | //if get data exits post membercard | 232 | //if get data exits post membercard |
238 | if(!getCustomer.isDataNotFound){ | 233 | if(!getCustomer.isDataNotFound){ |
@@ -267,7 +262,14 @@ async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMember | @@ -267,7 +262,14 @@ async function getCustomerHandler(req, getCustomer, getMemberCard, objDataMember | ||
267 | return result; | 262 | return result; |
268 | } | 263 | } |
269 | 264 | ||
270 | - var getResult = await getResultTodo(req, getMemberCard, objDataMembership); | 265 | + if(!getMemberCard.resultData){ // get membercard data not found do post |
266 | + var getResult = { | ||
267 | + doPost : true, | ||
268 | + doNothing : false | ||
269 | + } | ||
270 | + } else { // get data exits check todo | ||
271 | + var getResult = await getResultTodo(req, getMemberCard, objDataMembership); | ||
272 | + } | ||
271 | 273 | ||
272 | if(getResult.doNothing){ | 274 | if(getResult.doNothing){ |
273 | var response = responseMsg.success(req,getCmd) | 275 | var response = responseMsg.success(req,getCmd) |
@@ -332,7 +334,6 @@ async function checkOwnerCard(resultData,objectData){ | @@ -332,7 +334,6 @@ async function checkOwnerCard(resultData,objectData){ | ||
332 | } | 334 | } |
333 | 335 | ||
334 | for(var i = 0 ; i < resultData.length ; i++){ | 336 | for(var i = 0 ; i < resultData.length ; i++){ |
335 | - // console.log(resultData[i]) | ||
336 | if(resultData[i].cardOwnerIdList.includes(customerId)){ | 337 | if(resultData[i].cardOwnerIdList.includes(customerId)){ |
337 | dataCount.userOwnCardCount = dataCount.userOwnCardCount++; | 338 | dataCount.userOwnCardCount = dataCount.userOwnCardCount++; |
338 | } | 339 | } |
@@ -344,7 +345,6 @@ async function checkOwnerCard(resultData,objectData){ | @@ -344,7 +345,6 @@ async function checkOwnerCard(resultData,objectData){ | ||
344 | return dataCount; | 345 | return dataCount; |
345 | }; | 346 | }; |
346 | var count = await countf(resultData); | 347 | var count = await countf(resultData); |
347 | - // console.log(count); | ||
348 | 348 | ||
349 | if(count.userOwnCardCount < userMembershipCardLimit | 349 | if(count.userOwnCardCount < userMembershipCardLimit |
350 | && count.cardOwnUserCount < userOwnerCardLimit){ | 350 | && count.cardOwnUserCount < userOwnerCardLimit){ |