logic1.js 10.1 KB



test = {
    "getAccountCustomerInfoResponse": {
      "return": {
        "withholdingTaxRate": "3",
        "errorCode": "OSBbllngA00001",
        "type": "ax21:AccountCustomerInfoResponse",
        "message": "Success.",
        "uuid": "4b8541d3-e6b4-44c3-8291-8688e5dc72cc",
        "account": {
          "accountCollection": {
            "collectionIndicator": "",
            "suspensionReason": "",
            "fullSuspensionIndicator": "",
            "punishmentLevels": "",
            "startDate": {
              "nil": true
            },
            "status": "NONE"
          },
          "classify": "R",
          "accountSubType": {
            "code": "EVP",
            "description": "Enterprise VIP"
          },
          "ben": {
            "consolidateIndicator": "N",
            "billLanguage": "TH",
            "ben": "10000787",
            "bcBanId": "1465",
            "billMedia": "P",
            "status": {
              "code": "O",
              "description": "Open"
            }
          },
          "type": "ax24:AccountInfo",
          "legacyBan": "",
          "exernalId": "",
          "ouId": "1282",
          "delinquent": "",
          "contact": {
            "preferredContactNo": "*",
            "officePhone": "",
            "homePhone": "023345678",
            "language": "TH",
            "privatePhone": "",
            "fax": "",
            "email": ""
          },
          "agreementId": "1820",
          "customerId": "2456",
          "creditLimit": {
            "creditClass": "BV",
            "creditLimitReasonCode": "CREQ",
            "personalCreditLimit": "1000.0",
            "creditLimitExpirationDate": {
              "nil": true
            },
            "temporaryCreditLimit": "0.0",
            "obligationCalculationFormula": "Formula 2"
          },
          "company": {
            "code": "RF",
            "description": "True Move H Universal Communication Co., Ltd"
          },
          "arBalance": "853.86",
          "accountPriority": "",
          "address": {
            "country": "",
            "zipCode": "10540",
            "roomNo": "",
            "city": "สมุทรปราการ",
            "addressType": "B",
            "moo": "",
            "soi": "",
            "building": "",
            "street": "บางพลีน้อย",
            "district": "บางพลี",
            "addressLine1": "13 * *",
            "houseNo": "13",
            "addressLine2": "* * * * บางพลีน้อย",
            "addressLine3": "* บางปลา * บางพลี",
            "addressLine4": "สมุทรปราการ 10540",
            "floor": "",
            "subDistrict": "บางปลา"
          },
          "parentBan": {
            "nil": true
          },
          "initiationReason": {
            "nil": true
          },
          "creditStatus": {
            "reasonDescription": "",
            "lastActivityDate": {
              "nil": true
            },
            "reasonCode": "",
            "status": "NONE"
          },
          "convergenceCode": "",
          "accountId": "10000787",
          "statusDescription": "Active",
          "collectionStatus": {
            "reasonDescription": "",
            "lastActivityDate": null,
            "reasonCode": "",
            "status": "NONE"
          },
          "taxId": "",
          "withholdingTaxUpdateDate": {
            "nil": true
          },
          "withholdingTaxIndicator": "N",
          "name": {
            "branchCode": "",
            "nameType": "B",
            "firstName": "",
            "lastName": "",
            "organizationName": "มหาวิทยาลัยหอการค้าไทย",
            "branchName": "",
            "middleName": "",
            "storeId": "",
            "tilte": ""
          },
          "openDate": "2013-03-02T11:32:16.000+07:00",
          "branchNo": ""
        },
        "customer": {
          "creditLimitIndicator": "N",
          "income": "",
          "timeInBusiness": "1311",
          "occupation": "",
          "type": "ax24:CustomerInfo",
          "customerType": {
            "code": "C",
            "description": "Corporate"
          },
          "exernalId": "",
          "lastActivityCode": "NEW_ACCOUNT",
          "contactLanguage": "TH",
          "educationLevel": "",
          "contact": {
            "preferredContactNo": "",
            "officePhone": "",
            "homePhone": "023345678",
            "language": "TH",
            "privatePhone": "",
            "fax": "",
            "email": ""
          },
          "customerId": "2456",
          "trueCardGrading": {
            "nil": true
          },
          "certificateExpirationDate": "2014-12-31",
          "marketingChannel": "",
          "offerCurrency": "THB",
          "expirationDate": {
            "nil": true
          },
          "registerDate": "2013-03-02T11:32:13.000+07:00",
          "creditClass": "BX",
          "address": {
            "country": "",
            "zipCode": "10540",
            "roomNo": "",
            "city": "สมุทรปราการ",
            "addressType": "B",
            "moo": "",
            "soi": "",
            "building": "",
            "sinceDate": "2013-03-02T11:32:13+07:00",
            "street": "บางพลีน้อย",
            "district": "บางพลี",
            "addressLine1": "13 * *",
            "houseNo": "13",
            "addressLine2": "* * * * บางพลีน้อย",
            "addressLine3": "* บางปลา * บางพลี",
            "addressLine4": "สมุทรปราการ 10540",
            "floor": "",
            "subDistrict": "บางปลา"
          },
          "totalProduct": "1",
          "personal": {
            "gender": "",
            "accommodation": {
              "nil": true
            },
            "maritalStatus": ""
          },
          "birthDate": "1987-11-30",
          "lastActivityReasonCode": "CREQ",
          "nationality": "",
          "certificateNumber": "337/2515",
          "largeCustomerIndicator": "N",
          "periodOfWork": {
            "nil": true
          },
          "billCycleInfo": {
            "changeCycleRequestStatus": "N",
            "newBillCycle": {
              "nil": true
            },
            "changeCycleReqeustDate": {
              "nil": true
            },
            "billCycle": {
              "code": "2",
              "description": "Monthly Cycle close on the 1"
            },
            "changeCycleIndicator": "N"
          },
          "dealer": {
            "code": "90225773",
            "description": "คุณจรรจิรา จรรยาลิขิต"
          },
          "name": {
            "branchCode": "",
            "nameType": "B",
            "firstName": "",
            "lastName": "",
            "organizationName": "มหาวิทยาลัยหอการค้าไทย",
            "branchName": "",
            "middleName": "",
            "storeId": "",
            "tilte": ""
          },
          "customerGrading": "TOP",
          "taxExemptionIndicator": "N",
          "job": "",
          "effectiveDate": "2013-03-02T11:32:16.000+07:00",
          "certificateType": "O"
        }
      }
    }
  }


creditDate = getAccountCustomerInfoResponse.return.account.creditStatus.lastActivityDate // string
collectDate = getAccountCustomerInfoResponse.return.account.collectionStatus.lastActivityDate // string
creditStatus = getAccountCustomerInfoResponse.return.account.creditStatus.status // string
collectStatus = getAccountCustomerInfoResponse.return.account.collectionStatus.status // string

if("NONE".equals(creditStatus) && "NONE".equals(collectStatus)){ 
 if(CheckNullUtil.chkStringNotNull(creditDate) && CheckNullUtil.chkStringNotNull(collectDate)){      
  banStatusUpdated = compareDate("yyyy-MM-dd'T'HH:mm:ss.SSS",creditDate,collectDate); 
 }else{
  if(CheckNullUtil.chkStringNotNull(creditDate)){  
   banStatusUpdated = creditDate;
  }else if(CheckNullUtil.chkStringNotNull(collectDate)){
   banStatusUpdated = collectDate;
  }else{
   banStatusUpdated = accountMResult.getOpenDate();  
  }
 }
}else if("NONE".equals(creditStatus)&&"PSUS".equals(collectStatus)){
 banStatusUpdated = collectionStatusBean.getLastActivityDateStr();    
}else if("NONE".equals(creditStatus)&&"SUS".equals(collectStatus)){
 banStatusUpdated = collectionStatusBean.getLastActivityDateStr();
}else if("NONE".equals(creditStatus)&&"CAN".equals(collectStatus)){
 banStatusUpdated = collectionStatusBean.getLastActivityDateStr();
}else if("PSUS".equals(creditStatus)&&"NONE".equals(collectStatus)){
 banStatusUpdated = creditStatusBean.getLastActivityDateStr();
}else if("PSUS".equals(creditStatus)&&"PSUS".equals(collectStatus)){
 banStatusUpdated = compareDate("yyyy-MM-dd'T'HH:mm:ss.SSS",creditDate,collectDate);
}else if("PSUS".equals(creditStatus)&&"SUS".equals(collectStatus)){
 banStatusUpdated = collectionStatusBean.getLastActivityDateStr();
}else if("PSUS".equals(creditStatus)&&"CAN".equals(collectStatus)){
 banStatusUpdated = collectionStatusBean.getLastActivityDateStr();
}



private String compareDate(String format,String dateStr1,String dateStr2) throws ParseException {
    String result = null;
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    Date date1 = sdf.parse(dateStr1.substring(0,dateStr1.indexOf('+')));
    Date date2 = sdf.parse(dateStr2.substring(0,dateStr2.indexOf('+')));
    if (date1.after(date2)) {
     result = dateStr1;
    }
    if (date1.before(date2)) {
     result = dateStr2;
    }
    if (date1.equals(date2)) {
     result = dateStr1;
    }
    return result;
   }
   
   
   -----------------------------------------------------------------------------------------------------------------------------------
   
   
   if (jsoncreditStatus.get("lastActivityDate").toString().equals("{\"nil\":true}")
     ||jsoncreditStatus.get("lastActivityDate").toString().equals("")) {
    tmpBanStatus.setCreditLimitDate("");
   }
   else {
    tmpBanStatus.setCreditLimitDate(sdf2.format(sdf.parse(jsoncreditStatus.get("lastActivityDate").toString())));
   }