Advertisement
Shirai

update api in 2021

Apr 28th, 2021
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 39.02 KB | None | 0 0
  1. @RequestMapping(value = "/updateMemberCustomer",method = RequestMethod.POST )
  2.         @PreAuthorize("hasAnyRole('" + Roles.ROLE_OPERATION_STAFF + "','" + Roles.ROLE_ADMIN + "', '" + Roles.ROLE_CLT + "', '" + Roles.ROLE_FINANCE + "', '" + Roles.ROLE_LEGALCOMPLIANCE + "', '" + Roles.ROLE_RISKFRAUD + "', '" + Roles.ROLE_SALESUPPORT + "')")
  3.         public String updateMemberCustomer(HttpServletRequest servletRequest, HttpServletResponse servletResponse, ModelMap model) throws Exception {
  4.             if (!checkLogin(servletRequest, servletResponse))
  5.                 return REDIRECT_LOGIN;
  6.               HttpSession httpSession = servletRequest.getSession(true);
  7.               Long userId = (Long)httpSession.getAttribute("user_id");
  8.               String phoneNumber = servletRequest.getParameter("phone");
  9.               log.info("Start updateMemberCustomer for {} id {}", phoneNumber, userId);
  10.               String id = servletRequest.getParameter("accountId");
  11.               String imageUrlValue = servletRequest.getParameter("imageUrlValue");
  12.               String imageUrlValue1 = servletRequest.getParameter("imageUrlValue1");
  13.               String imageUrlValue2 = servletRequest.getParameter("imageUrlValue2");
  14.               String imageUrlValue3 = servletRequest.getParameter("imageUrlValue3");
  15.               String emailUpdate = servletRequest.getParameter("emailUpdate");
  16.               if(StringUtils.isEmpty(emailUpdate)) {
  17.                   emailUpdate = null;
  18.               }
  19.               String genderUpdate = servletRequest.getParameter("genderUpdate");
  20.               String currentCityUpdate = servletRequest.getParameter("currentCityUpdate");
  21.               String currentDistrictUpdate = servletRequest.getParameter("currentDistrictUpdate");
  22.               String currentAddressUpdate = servletRequest.getParameter("currentAddressUpdate");
  23.               String permanentCityUpdate = servletRequest.getParameter("permanentCityUpdate");
  24.               String permanentDistrictUpdate = servletRequest.getParameter("permanentDistrictUpdate");
  25.               String permanentAddressUpdate = servletRequest.getParameter("permanentAddressUpdate");
  26.               String occupationUpdate = servletRequest.getParameter("occupationUpdate");
  27.               String positionUpdate = servletRequest.getParameter("positionUpdate");
  28.               String nationalityUpdate = servletRequest.getParameter("nationalityUpdate");
  29.               String identitytypeUpdate = servletRequest.getParameter("identitytypeUpdate");
  30.               String nationalIdUpdate = servletRequest.getParameter("nationalIdUpdate");
  31.               String dateIssuanceUpdate = servletRequest.getParameter("dateIssuanceUpdate");
  32.               String placeResidenceUpdate = servletRequest.getParameter("placeResidenceUpdate");
  33.               String fileImageMessageValidate = servletRequest.getParameter("fileImageMessageValidate");
  34.               String fileImageMessageValidate1 = servletRequest.getParameter("fileImageMessageValidate1");
  35.               String fileImageMessageValidate2 = servletRequest.getParameter("fileImageMessageValidate2");
  36.               String fileImageMessageValidate3 = servletRequest.getParameter("fileImageMessageValidate3");
  37.              
  38.               String bankIdInfoUpdate = servletRequest.getParameter("bankIdInfoUpdate");
  39.               String bankNameUpdate = servletRequest.getParameter("bankNameUpdate");
  40.               String bankAccountNumberUpdate = servletRequest.getParameter("bankAccountNumberUpdate");
  41.               String accountNameUpdate = servletRequest.getParameter("accountNameUpdate");
  42.              
  43.               String firstNameUpdate = servletRequest.getParameter("firstNameUpdate");
  44.               String middleNameUpdate = servletRequest.getParameter("middleNameUpdate");
  45.               String lastNameUpdate = servletRequest.getParameter("lastNameUpdate");
  46.               String lastDateOfBirth = servletRequest.getParameter(DATE_OF_BIRTH);
  47.               String kycType = servletRequest.getParameter("kycType");
  48.  
  49.               Date dateNow = new Date();
  50.               Date dateIssuance = null;
  51.               Date dateOfB = null;
  52.               DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
  53.               if(!StringUtils.isEmpty(dateIssuanceUpdate)) {
  54.                   dateIssuance = dateFormat.parse(dateIssuanceUpdate);
  55.               }
  56.               if(!StringUtils.isEmpty(lastDateOfBirth)){
  57.                   dateOfB = dateFormat.parse(lastDateOfBirth);
  58.               }
  59.              
  60.               Pattern pattern = Pattern.compile("[!@#$%&+=|<>?{}\\[\\]~]");
  61.               Matcher matchercurrent = pattern.matcher(currentAddressUpdate);
  62.               Matcher matcherpermanent = pattern.matcher(permanentAddressUpdate);
  63.  
  64.               if(!StringUtils.isEmpty(emailUpdate) && Utils.validateEmail(emailUpdate) == false) {
  65.                   model.put(messageUpdateString, "error");
  66.                   String error = notify("vnwallet.table.column.action.update.message.failed")
  67.                           + notify("vnwallet.list.detail.message.error.service")
  68.                           + notify("vnwallet.list.detail.message.error.emailvalid");
  69.                   model.put(messageErrorString, error);
  70.                   log.info("updateMemberCustomer Error {}", error);
  71.                   model.put("emailUpdate", emailUpdate);
  72.                   model.put("genderUpdate", genderUpdate);
  73.                   model.put("currentCityUpdate", currentCityUpdate);
  74.                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  75.                   model.put("currentAddressUpdate", currentAddressUpdate);
  76.                   model.put("permanentCityUpdate", permanentCityUpdate);
  77.                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  78.                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  79.                   model.put("occupationUpdate", occupationUpdate);
  80.                   model.put("positionUpdate", positionUpdate);
  81.                   model.put("nationalityUpdate", nationalityUpdate);
  82.                   model.put("identitytypeUpdate", identitytypeUpdate);
  83.                   model.put("nationalIdUpdate", nationalIdUpdate);
  84.                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  85.                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  86.                  
  87.                   model.put("bankNameUpdate", bankNameUpdate);
  88.                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  89.                   model.put("accountNameUpdate", accountNameUpdate);
  90.                  
  91.                   model.put("firstNameUpdate", firstNameUpdate);
  92.                   model.put("middleNameUpdate", middleNameUpdate);
  93.                   model.put("lastNameUpdate", lastNameUpdate);
  94.                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  95.           } else {
  96.               if(!StringUtils.isEmpty(fileImageMessageValidate)) {
  97.                       model.put(messageUpdateString, "error");
  98.                       String error = notify("vnwallet.table.column.action.update.message.failed")
  99.                               + notify("vnwallet.list.detail.message.error.service") + fileImageMessageValidate;
  100.                       model.put(messageErrorString, error);
  101.                       log.info("updateMemberCustomer Error {}", error);
  102.                       model.put("emailUpdate", emailUpdate);
  103.                       model.put("genderUpdate", genderUpdate);
  104.                       model.put("currentCityUpdate", currentCityUpdate);
  105.                       model.put("currentDistrictUpdate", currentDistrictUpdate);
  106.                       model.put("currentAddressUpdate", currentAddressUpdate);
  107.                       model.put("permanentCityUpdate", permanentCityUpdate);
  108.                       model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  109.                       model.put("permanentAddressUpdate", permanentAddressUpdate);
  110.                      
  111.                       model.put("occupationUpdate", occupationUpdate);
  112.                       model.put("positionUpdate", positionUpdate);
  113.                       model.put("nationalityUpdate", nationalityUpdate);
  114.                       model.put("identitytypeUpdate", identitytypeUpdate);
  115.                       model.put("nationalIdUpdate", nationalIdUpdate);
  116.                       model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  117.                       model.put("placeResidenceUpdate", placeResidenceUpdate);
  118.                      
  119.                       model.put("bankNameUpdate", bankNameUpdate);
  120.                       model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  121.                       model.put("accountNameUpdate", accountNameUpdate);
  122.                      
  123.                       model.put("firstNameUpdate", firstNameUpdate);
  124.                       model.put("middleNameUpdate", middleNameUpdate);
  125.                       model.put("lastNameUpdate", lastNameUpdate);
  126.                       model.put(DATE_OF_BIRTH, lastDateOfBirth);
  127.               } else {
  128.                   if(!StringUtils.isEmpty(fileImageMessageValidate1)) {
  129.                           model.put(messageUpdateString, "error");
  130.                           String error = notify("vnwallet.table.column.action.update.message.failed")
  131.                                   + notify("vnwallet.list.detail.message.error.service") + fileImageMessageValidate1;
  132.                           model.put(messageErrorString, error);
  133.                           log.info("updateMemberCustomer Error {}", error);
  134.                           model.put("emailUpdate", emailUpdate);
  135.                           model.put("genderUpdate", genderUpdate);
  136.                           model.put("currentCityUpdate", currentCityUpdate);
  137.                           model.put("currentDistrictUpdate", currentDistrictUpdate);
  138.                           model.put("currentAddressUpdate", currentAddressUpdate);
  139.                           model.put("permanentCityUpdate", permanentCityUpdate);
  140.                           model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  141.                           model.put("permanentAddressUpdate", permanentAddressUpdate);
  142.                          
  143.                           model.put("occupationUpdate", occupationUpdate);
  144.                           model.put("positionUpdate", positionUpdate);
  145.                           model.put("nationalityUpdate", nationalityUpdate);
  146.                           model.put("identitytypeUpdate", identitytypeUpdate);
  147.                           model.put("nationalIdUpdate", nationalIdUpdate);
  148.                           model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  149.                           model.put("placeResidenceUpdate", placeResidenceUpdate);
  150.                          
  151.                           model.put("bankNameUpdate", bankNameUpdate);
  152.                           model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  153.                           model.put("accountNameUpdate", accountNameUpdate);
  154.                          
  155.                           model.put("firstNameUpdate", firstNameUpdate);
  156.                           model.put("middleNameUpdate", middleNameUpdate);
  157.                           model.put("lastNameUpdate", lastNameUpdate);
  158.                           model.put(DATE_OF_BIRTH, lastDateOfBirth);
  159.                   } else {
  160.                       if(!StringUtils.isEmpty(fileImageMessageValidate2)) {
  161.                               model.put(messageUpdateString, "error");
  162.                               String error = notify("vnwallet.table.column.action.update.message.failed")
  163.                                       + notify("vnwallet.list.detail.message.error.service")
  164.                                       + fileImageMessageValidate2;
  165.                               model.put(messageErrorString, error);
  166.                               log.info("updateMemberCustomer Error {}", error);
  167.                               model.put("emailUpdate", emailUpdate);
  168.                               model.put("genderUpdate", genderUpdate);
  169.                               model.put("currentCityUpdate", currentCityUpdate);
  170.                               model.put("currentDistrictUpdate", currentDistrictUpdate);
  171.                               model.put("currentAddressUpdate", currentAddressUpdate);
  172.                               model.put("permanentCityUpdate", permanentCityUpdate);
  173.                               model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  174.                               model.put("permanentAddressUpdate", permanentAddressUpdate);
  175.                              
  176.                               model.put("occupationUpdate", occupationUpdate);
  177.                               model.put("positionUpdate", positionUpdate);
  178.                               model.put("nationalityUpdate", nationalityUpdate);
  179.                               model.put("identitytypeUpdate", identitytypeUpdate);
  180.                               model.put("nationalIdUpdate", nationalIdUpdate);
  181.                               model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  182.                               model.put("placeResidenceUpdate", placeResidenceUpdate);
  183.                              
  184.                               model.put("bankNameUpdate", bankNameUpdate);
  185.                               model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  186.                               model.put("accountNameUpdate", accountNameUpdate);
  187.                              
  188.                               model.put("firstNameUpdate", firstNameUpdate);
  189.                               model.put("middleNameUpdate", middleNameUpdate);
  190.                               model.put("lastNameUpdate", lastNameUpdate);
  191.                               model.put(DATE_OF_BIRTH, lastDateOfBirth);
  192.                       } else {
  193.                           if(!StringUtils.isEmpty(fileImageMessageValidate3)) {
  194.                               model.put(messageUpdateString, "error");
  195.                               String error = notify("vnwallet.table.column.action.update.message.failed")
  196.                                       + notify("vnwallet.list.detail.message.error.service")
  197.                                       + fileImageMessageValidate3;
  198.                               model.put(messageErrorString, error);
  199.                               log.info("updateMemberCustomer Error {}", error);
  200.                               model.put("emailUpdate", emailUpdate);
  201.                               model.put("genderUpdate", genderUpdate);
  202.                               model.put("currentCityUpdate", currentCityUpdate);
  203.                               model.put("currentDistrictUpdate", currentDistrictUpdate);
  204.                               model.put("currentAddressUpdate", currentAddressUpdate);
  205.                               model.put("permanentCityUpdate", permanentCityUpdate);
  206.                               model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  207.                               model.put("permanentAddressUpdate", permanentAddressUpdate);
  208.                              
  209.                               model.put("occupationUpdate", occupationUpdate);
  210.                               model.put("positionUpdate", positionUpdate);
  211.                               model.put("nationalityUpdate", nationalityUpdate);
  212.                               model.put("identitytypeUpdate", identitytypeUpdate);
  213.                               model.put("nationalIdUpdate", nationalIdUpdate);
  214.                               model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  215.                               model.put("placeResidenceUpdate", placeResidenceUpdate);
  216.                              
  217.                               model.put("bankNameUpdate", bankNameUpdate);
  218.                               model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  219.                               model.put("accountNameUpdate", accountNameUpdate);
  220.                              
  221.                               model.put("firstNameUpdate", firstNameUpdate);
  222.                               model.put("middleNameUpdate", middleNameUpdate);
  223.                               model.put("lastNameUpdate", lastNameUpdate);
  224.                               model.put(DATE_OF_BIRTH, lastDateOfBirth);
  225.                       } else {
  226.                           if((dateIssuance!= null && dateIssuance.after(dateNow)) ||
  227.                                   (dateOfB != null && dateOfB.after(dateNow) && Utils.validateDateOfBirth(lastDateOfBirth, 15))) {
  228.                                   model.put(messageUpdateString, "error");
  229.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  230.                                           + notify("vnwallet.list.detail.message.error.service")
  231.                                           + notify("vnwallet.list.detail.message.error.dateissuance");
  232.                                   model.put(messageErrorString, error);
  233.                                   log.info("updateMemberCustomer Error {}", error);
  234.                                   model.put("emailUpdate", emailUpdate);
  235.                                   model.put("genderUpdate", genderUpdate);
  236.                                   model.put("currentCityUpdate", currentCityUpdate);
  237.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  238.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  239.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  240.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  241.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  242.                                   model.put("occupationUpdate", occupationUpdate);
  243.                                   model.put("positionUpdate", positionUpdate);
  244.                                   model.put("nationalityUpdate", nationalityUpdate);
  245.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  246.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  247.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  248.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  249.                                  
  250.                                   model.put("bankNameUpdate", bankNameUpdate);
  251.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  252.                                   model.put("accountNameUpdate", accountNameUpdate);
  253.                                  
  254.                                   model.put("firstNameUpdate", firstNameUpdate);
  255.                                   model.put("middleNameUpdate", middleNameUpdate);
  256.                                   model.put("lastNameUpdate", lastNameUpdate);
  257.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  258.                           } else {
  259.                           if(matchercurrent.find()) {
  260.                                   model.put(messageUpdateString, "error");
  261.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  262.                                           + notify("vnwallet.list.detail.message.error.service")
  263.                                           + notify("vnwallet.list.detail.message.error.matchercurren");
  264.                                   model.put(messageErrorString, error);
  265.                                   log.info("updateMemberCustomer Error {}", error);
  266.                                   model.put("emailUpdate", emailUpdate);
  267.                                   model.put("genderUpdate", genderUpdate);
  268.                                   model.put("currentCityUpdate", currentCityUpdate);
  269.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  270.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  271.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  272.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  273.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  274.                                   model.put("occupationUpdate", occupationUpdate);
  275.                                   model.put("positionUpdate", positionUpdate);
  276.                                   model.put("nationalityUpdate", nationalityUpdate);
  277.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  278.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  279.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  280.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  281.                                  
  282.                                   model.put("bankNameUpdate", bankNameUpdate);
  283.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  284.                                   model.put("accountNameUpdate", accountNameUpdate);
  285.                                  
  286.                                   model.put("firstNameUpdate", firstNameUpdate);
  287.                                   model.put("middleNameUpdate", middleNameUpdate);
  288.                                   model.put("lastNameUpdate", lastNameUpdate);
  289.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  290.                           }else {
  291.                           if(matcherpermanent.find()) {
  292.                                   model.put(messageUpdateString, "error");
  293.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  294.                                           + notify("vnwallet.list.detail.message.error.service")
  295.                                           + notify("vnwallet.list.detail.message.error.matcherpermanent");
  296.                                   model.put(messageErrorString, error);
  297.                                   log.info("updateMemberCustomer Error {}", error);
  298.                                   model.put("emailUpdate", emailUpdate);
  299.                                   model.put("genderUpdate", genderUpdate);
  300.                                   model.put("currentCityUpdate", currentCityUpdate);
  301.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  302.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  303.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  304.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  305.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  306.                                   model.put("occupationUpdate", occupationUpdate);
  307.                                   model.put("positionUpdate", positionUpdate);
  308.                                   model.put("nationalityUpdate", nationalityUpdate);
  309.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  310.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  311.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  312.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  313.                                  
  314.                                   model.put("bankNameUpdate", bankNameUpdate);
  315.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  316.                                   model.put("accountNameUpdate", accountNameUpdate);
  317.                                  
  318.                                   model.put("firstNameUpdate", firstNameUpdate);
  319.                                   model.put("middleNameUpdate", middleNameUpdate);
  320.                                   model.put("lastNameUpdate", lastNameUpdate);
  321.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  322.                           }  else {
  323.                               if(!StringUtils.isEmpty(identitytypeUpdate) && identitytypeUpdate.equals(profileIdentityNational) && !StringUtils.isEmpty(nationalIdUpdate) && (nationalIdUpdate.length() != lengthNational1 &&  nationalIdUpdate.length() != lengthNational2)) {
  324.                                   model.put(messageUpdateString, "error");
  325.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  326.                                           + notify("vnwallet.list.detail.message.error.service")
  327.                                           + notify("vnwallet.list.detail.message.error.lengthNational");
  328.                                   model.put(messageErrorString, error);
  329.                                   log.info("updateMemberCustomer Error {}", error);
  330.                                   model.put("emailUpdate", emailUpdate);
  331.                                   model.put("genderUpdate", genderUpdate);
  332.                                   model.put("currentCityUpdate", currentCityUpdate);
  333.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  334.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  335.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  336.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  337.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  338.                                   model.put("occupationUpdate", occupationUpdate);
  339.                                   model.put("positionUpdate", positionUpdate);
  340.                                   model.put("nationalityUpdate", nationalityUpdate);
  341.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  342.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  343.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  344.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  345.                                  
  346.                                   model.put("bankNameUpdate", bankNameUpdate);
  347.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  348.                                   model.put("accountNameUpdate", accountNameUpdate);
  349.                                  
  350.                                   model.put("firstNameUpdate", firstNameUpdate);
  351.                                   model.put("middleNameUpdate", middleNameUpdate);
  352.                                   model.put("lastNameUpdate", lastNameUpdate);
  353.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  354.                           }else {
  355.                               if(!StringUtils.isEmpty(identitytypeUpdate) && identitytypeUpdate.equals(profileIdentityPassport) && !StringUtils.isEmpty(nationalIdUpdate) && nationalIdUpdate.length() != lengthPassport) {
  356.                                   model.put(messageUpdateString, "error");
  357.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  358.                                           + notify("vnwallet.list.detail.message.error.service")
  359.                                           + notify("vnwallet.list.detail.message.error.lengthPassport");
  360.                                   model.put(messageErrorString, error);
  361.                                   log.info("updateMemberCustomer Error {}", error);
  362.                                   model.put("emailUpdate", emailUpdate);
  363.                                   model.put("genderUpdate", genderUpdate);
  364.                                   model.put("currentCityUpdate", currentCityUpdate);
  365.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  366.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  367.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  368.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  369.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  370.                                   model.put("occupationUpdate", occupationUpdate);
  371.                                   model.put("positionUpdate", positionUpdate);
  372.                                   model.put("nationalityUpdate", nationalityUpdate);
  373.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  374.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  375.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  376.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  377.                                  
  378.                                   model.put("bankNameUpdate", bankNameUpdate);
  379.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  380.                                   model.put("accountNameUpdate", accountNameUpdate);
  381.                                  
  382.                                   model.put("firstNameUpdate", firstNameUpdate);
  383.                                   model.put("middleNameUpdate", middleNameUpdate);
  384.                                   model.put("lastNameUpdate", lastNameUpdate);
  385.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  386.                           }else {
  387.                               if(!StringUtils.isEmpty(bankAccountNumberUpdate) && (bankAccountNumberUpdate.length() < 9 || bankAccountNumberUpdate.length() > 20 ) ) {
  388.                                   model.put(messageUpdateString, "error");
  389.                                   String error = notify("vnwallet.table.column.action.update.message.failed")
  390.                                           + notify("vnwallet.list.detail.message.error.service")
  391.                                           + notify("vnwallet.list.detail.message.error.lengthbankAccountNumber");
  392.                                   model.put(messageErrorString, error);
  393.                                   log.info("updateMemberCustomer Error {}", error);
  394.                                   model.put("emailUpdate", emailUpdate);
  395.                                   model.put("genderUpdate", genderUpdate);
  396.                                   model.put("currentCityUpdate", currentCityUpdate);
  397.                                   model.put("currentDistrictUpdate", currentDistrictUpdate);
  398.                                   model.put("currentAddressUpdate", currentAddressUpdate);
  399.                                   model.put("permanentCityUpdate", permanentCityUpdate);
  400.                                   model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  401.                                   model.put("permanentAddressUpdate", permanentAddressUpdate);
  402.                                   model.put("occupationUpdate", occupationUpdate);
  403.                                   model.put("positionUpdate", positionUpdate);
  404.                                   model.put("nationalityUpdate", nationalityUpdate);
  405.                                   model.put("identitytypeUpdate", identitytypeUpdate);
  406.                                   model.put("nationalIdUpdate", nationalIdUpdate);
  407.                                   model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  408.                                   model.put("placeResidenceUpdate", placeResidenceUpdate);
  409.                                  
  410.                                   model.put("bankNameUpdate", bankNameUpdate);
  411.                                   model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  412.                                   model.put("accountNameUpdate", accountNameUpdate);
  413.                                  
  414.                                   model.put("firstNameUpdate", firstNameUpdate);
  415.                                   model.put("middleNameUpdate", middleNameUpdate);
  416.                                   model.put("lastNameUpdate", lastNameUpdate);
  417.                                   model.put(DATE_OF_BIRTH, lastDateOfBirth);
  418.                           } else {
  419.                               CardPictures imageLink = new CardPictures();
  420.                               Part filePart = null;
  421.                              
  422.                               CardPictures imageLink1 = new CardPictures();
  423.                               Part filePart1 = null;
  424.                              
  425.                               CardPictures imageLink2 = new CardPictures();
  426.                               Part filePart2 = null;
  427.                              
  428.                               CardPictures imageLink3 = new CardPictures();
  429.                               Part filePart3 = null;
  430.                               try {
  431.                                   filePart = servletRequest.getPart("fileImage");
  432.                                   imageLink = uploadToAWS(userId, filePart);
  433.                                  
  434.                               } catch (Exception e){
  435.                                   model.put(messageUpdateString, "error");
  436.                                   log.error(e.getMessage(), e);
  437.                                   String error = notify("vnwallet.offer.detail.message.error.filepart")
  438.                                           + e.getMessage();
  439.                                   model.put(messageErrorString, error);
  440.                                   log.info("updateMemberCustomer Error {}", error);
  441.                               }
  442.                              
  443.                               try {
  444.                                   filePart1 = servletRequest.getPart("fileImage1");
  445.                                   imageLink1 = uploadToAWS(userId, filePart1);
  446.                               } catch (Exception e){
  447.                                   model.put(messageUpdateString, "error");
  448.                                   log.error(e.getMessage(), e);
  449.                                   String error = notify("vnwallet.offer.detail.message.error.filepart")
  450.                                           + e.getMessage();
  451.                                   model.put(messageErrorString, error);
  452.                                   log.info("updateMemberCustomer Error {}", error);
  453.                               }
  454.                              
  455.                               try {
  456.                                   filePart2 = servletRequest.getPart("fileImage2");
  457.                                   imageLink2 = uploadToAWS(userId, filePart2);
  458.                               } catch (Exception e){
  459.                                   model.put(messageUpdateString, "error");
  460.                                   log.error(e.getMessage(), e);
  461.                                   String error = notify("vnwallet.offer.detail.message.error.filepart")
  462.                                           + e.getMessage();
  463.                                   model.put(messageErrorString, error);
  464.                                   log.info("updateMemberCustomer Error {}", error);
  465.                               }
  466.                              
  467.                               try {
  468.                                   filePart3 = servletRequest.getPart("fileImage3");
  469.                                   imageLink3 = uploadToAWS(userId, filePart3);
  470.                               } catch (Exception e){
  471.                                   model.put(messageUpdateString, "error");
  472.                                   log.error(e.getMessage(), e);
  473.                                   String error = notify("vnwallet.offer.detail.message.error.filepart")
  474.                                           + e.getMessage();
  475.                                   model.put(messageErrorString, error);
  476.                                   log.info("updateMemberCustomer Error {}", error);
  477.                               }
  478.                              
  479.                               List<CardPictures> cardPicturesList = new ArrayList<CardPictures>();
  480.                               CardPictures cardPictures = new CardPictures();
  481.                               CardPictures cardPictures1 = new CardPictures();
  482.                               CardPictures cardPictures2 = new CardPictures();
  483.                               CardPictures cardPictures3 = new CardPictures();
  484.                               String[] imageUrlValues = null;
  485.                               String[] imageUrlValues1 = null;
  486.                               String[] imageUrlValues2 = null;
  487.                               String[] imageUrlValues3 = null;
  488.                               BankInfo bankInfo = new BankInfo();
  489.                              
  490.                               if(!StringUtils.isEmpty(imageUrlValue)) {
  491.                                   imageUrlValues = imageUrlValue.split("file_name=");
  492.                               }
  493.                               if(!StringUtils.isEmpty(imageUrlValue1)) {
  494.                                   imageUrlValues1 = imageUrlValue1.split("file_name=");
  495.                               }
  496.                               if(!StringUtils.isEmpty(imageUrlValue2)) {
  497.                                   imageUrlValues2 = imageUrlValue2.split("file_name=");
  498.                               }
  499.                              
  500.                               if(!StringUtils.isEmpty(imageUrlValue3)) {
  501.                                   imageUrlValues3 = imageUrlValue3.split("file_name=");
  502.                               }
  503.                               if(imageLink == null ||  (imageLink != null && StringUtils.isEmpty(imageLink.getPath()))) {
  504.                                   if(imageUrlValues != null) {
  505.                                       cardPictures.setName(imageUrlValues[1]);
  506.                                       cardPictures.setPath(imageUrlValue);
  507.                                   }
  508.                               } else{
  509.                                   cardPictures = imageLink;
  510.                               }
  511.                               if(imageLink1 == null ||  (imageLink1 != null && StringUtils.isEmpty(imageLink1.getPath()))) {
  512.                                   if(imageUrlValues1 != null) {
  513.                                       cardPictures1.setName(imageUrlValues1[1]);
  514.                                       cardPictures1.setPath(imageUrlValue1);
  515.                                   }
  516.                               } else {
  517.                                   cardPictures1 = imageLink1;
  518.                               }
  519.                               if(imageLink2 == null ||  (imageLink2 != null && StringUtils.isEmpty(imageLink2.getPath()))) {
  520.                                   if(imageUrlValues2 != null) {
  521.                                       cardPictures2.setName(imageUrlValues2[1]);
  522.                                       cardPictures2.setPath(imageUrlValue2);
  523.                                   }
  524.                               } else {
  525.                                   cardPictures2 = imageLink2;
  526.                               }
  527.                              
  528.                               if(imageLink3 == null ||  (imageLink3 != null && StringUtils.isEmpty(imageLink3.getPath()))) {
  529.                                   if(imageUrlValues3 != null) {
  530.                                       cardPictures3.setName(imageUrlValues3[1]);
  531.                                       cardPictures3.setPath(imageUrlValue3);
  532.                                   }
  533.                               } else {
  534.                                   cardPictures3 = imageLink3;
  535.                               }
  536.                              
  537.                               cardPictures2.setType(AttachmentType.ScannedSelfie.code);
  538.                               cardPictures3.setType(AttachmentType.ScannedBankCard.code);
  539.                               if(!StringUtils.isEmpty(identitytypeUpdate)) {
  540.                                   if(Integer.valueOf(identitytypeUpdate).equals(IdentityType.IdentityCard.code)) {
  541.                                       cardPictures.setType(AttachmentType.ScannerdIdentityCard.code);
  542.                                       cardPictures1.setType(AttachmentType.ScannerdIdentityCard.code);
  543.                                   }
  544.                                   if(Integer.valueOf(identitytypeUpdate).equals(IdentityType.Passport.code)) {
  545.                                       cardPictures.setType(AttachmentType.ScannedPassport.code);
  546.                                       cardPictures1.setType(AttachmentType.ScannedPassport.code);
  547.                                   }
  548.                               }
  549.                              
  550.                               if(cardPictures != null && !StringUtils.isEmpty(cardPictures.getPath())) {
  551.                                   cardPicturesList.add(cardPictures);
  552.                               }
  553.                               if(cardPictures1 != null && !StringUtils.isEmpty(cardPictures1.getPath())) {
  554.                                   cardPicturesList.add(cardPictures1);
  555.                               }
  556.                               if(cardPictures2 != null && !StringUtils.isEmpty(cardPictures2.getPath())) {
  557.                                   cardPicturesList.add(cardPictures2);
  558.                               }
  559.                               if(cardPictures3 != null && !StringUtils.isEmpty(cardPictures3.getPath())) {
  560.                                   cardPicturesList.add(cardPictures3);
  561.                               }
  562.                               UpdateMemberCustomerRequest request= new UpdateMemberCustomerRequest();
  563.                               if(!StringUtils.isEmpty(id)) {
  564.                                   request.setId(Long.valueOf(id));
  565.                               }
  566.                              
  567.                               if(StringUtils.isEmpty(bankIdInfoUpdate) && StringUtils.isEmpty(bankNameUpdate)) {
  568.                                   bankInfo = null;
  569.                               } else {
  570.                                   if(!StringUtils.isEmpty(bankIdInfoUpdate)) {
  571.                                       bankInfo.setBankIdInfo(Long.parseLong(bankIdInfoUpdate));
  572.                                   }else {
  573.                                       bankInfo.setBankIdInfo(null);
  574.                                   }
  575.                                   bankInfo.setAccountName(accountNameUpdate);
  576.                                   bankInfo.setBankName(bankNameUpdate);
  577.                                   bankInfo.setBankNo(bankAccountNumberUpdate);
  578.                               }
  579.                              
  580.                               request.setBankInfo(bankInfo);
  581.                               request.setFirstName(firstNameUpdate);
  582.                               request.setMiddleName(middleNameUpdate);
  583.                               request.setLastName(lastNameUpdate);
  584.                               request.setProfileEmail(emailUpdate);
  585.                               request.setGender(genderUpdate);
  586.                               request.setCurrentCity(currentCityUpdate);
  587.                               request.setCurrentDistrict(currentDistrictUpdate);
  588.                               request.setCurrentAddress(currentAddressUpdate);
  589.                               request.setPermanentCity(permanentCityUpdate);
  590.                               request.setPermanentDistrict(permanentDistrictUpdate);
  591.                               request.setPermanentAddress(permanentAddressUpdate);
  592.                               request.setOccupation(occupationUpdate);
  593.                               request.setPosition(positionUpdate);
  594.                               request.setNationality(nationalityUpdate);
  595.                               request.setInfoIdNo(nationalIdUpdate);
  596.                               request.setDateOfBirth(Utils.converDateTimeZone(lastDateOfBirth));
  597.                               if(!StringUtils.isEmpty(identitytypeUpdate)) {
  598.                                   request.setProfileIdentityType(Integer.valueOf(identitytypeUpdate));
  599.                               }
  600.                               request.setNationality(nationalityUpdate);
  601.                               request.setInformationDateInssuance(Utils.converDateTimeZone(dateIssuanceUpdate));
  602.                               request.setInformationPlaceInsuance(placeResidenceUpdate);
  603.                               request.setCardPictures(cardPicturesList);
  604.                               log.info(String.format("kycType is %s", kycType));
  605.                               request.setKycType(Integer.valueOf(kycType));
  606.                              
  607.                                   try {
  608.                                       UpdateMemberCustomerResponse dResponse = walletRestAPIService.updateMemberCustomerResponse(request);
  609.                                       if(dResponse != null &&  !StringUtils.isEmpty(dResponse.getCode()) && dResponse.getCode().equals(SUCCESSMESSAGE)) {
  610.                                          model.put(messageUpdateString, "success");
  611.                                          model.put("messageContent",  notify("vnwallet.table.column.action.update.message.success"));
  612.                                       } else {
  613.                                           if(dResponse != null &&  !StringUtils.isEmpty(dResponse.getCode()) && dResponse.getCode().equals(ACCESSTOKENEXPIRED)) {
  614.                                                 return REDIRECT_LOGOUT;
  615.                                           } else {
  616.                                               model.put(messageUpdateString, "error");
  617.                                               String error = notify(
  618.                                                       "vnwallet.table.column.action.update.message.failed")
  619.                                                       + notify("vnwallet.list.detail.message.error.service")
  620.                                                       + dResponse.getMsg();
  621.                                               model.put(messageErrorString, error);
  622.                                               log.info("updateMemberCustomer Error {}", error);
  623.                                               model.put("emailUpdate", emailUpdate);
  624.                                               model.put("genderUpdate", genderUpdate);
  625.                                               model.put("currentCityUpdate", currentCityUpdate);
  626.                                               model.put("currentDistrictUpdate", currentDistrictUpdate);
  627.                                               model.put("currentAddressUpdate", currentAddressUpdate);
  628.                                               model.put("permanentCityUpdate", permanentCityUpdate);
  629.                                               model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  630.                                               model.put("permanentAddressUpdate", permanentAddressUpdate);
  631.                                              
  632.                                               model.put("occupationUpdate", occupationUpdate);
  633.                                               model.put("positionUpdate", positionUpdate);
  634.                                               model.put("nationalityUpdate", nationalityUpdate);
  635.                                               model.put("identitytypeUpdate", identitytypeUpdate);
  636.                                               model.put("nationalIdUpdate", nationalIdUpdate);
  637.                                               model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  638.                                               model.put("placeResidenceUpdate", placeResidenceUpdate);
  639.                                              
  640.                                               model.put("bankNameUpdate", bankNameUpdate);
  641.                                               model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  642.                                               model.put("accountNameUpdate", accountNameUpdate);
  643.                                              
  644.                                               model.put("firstNameUpdate", firstNameUpdate);
  645.                                               model.put("middleNameUpdate", middleNameUpdate);
  646.                                               model.put("lastNameUpdate", lastNameUpdate);
  647.                                               model.put(DATE_OF_BIRTH, lastDateOfBirth);
  648.                                           }
  649.                                       }
  650.                                   } catch (WalletFrontException e) {
  651.                                           log.error(e.getErrorMessage(), e);
  652.                                           model.put(messageUpdateString, "error");
  653.                                           String error = notify("vnwallet.table.column.action.update.message.failed")
  654.                                                   + notify("vnwallet.list.detail.message.error.service")
  655.                                                   + e.getErrorMessage();
  656.                                           model.put(messageErrorString, error);
  657.                                           log.info("updateMemberCustomer Error {}", error);
  658.  
  659.                                           model.put("emailUpdate", emailUpdate);
  660.                                           model.put("genderUpdate", genderUpdate);
  661.                                           model.put("currentCityUpdate", currentCityUpdate);
  662.                                           model.put("currentDistrictUpdate", currentDistrictUpdate);
  663.                                           model.put("currentAddressUpdate", currentAddressUpdate);
  664.                                           model.put("permanentCityUpdate", permanentCityUpdate);
  665.                                           model.put("permanentDistrictUpdate", permanentDistrictUpdate);
  666.                                           model.put("permanentAddressUpdate", permanentAddressUpdate);
  667.                                          
  668.                                           model.put("occupationUpdate", occupationUpdate);
  669.                                           model.put("positionUpdate", positionUpdate);
  670.                                           model.put("nationalityUpdate", nationalityUpdate);
  671.                                           model.put("identitytypeUpdate", identitytypeUpdate);
  672.                                           model.put("nationalIdUpdate", nationalIdUpdate);
  673.                                           model.put("dateIssuanceUpdate", dateIssuanceUpdate);
  674.                                           model.put("placeResidenceUpdate", placeResidenceUpdate);
  675.                                          
  676.                                           model.put("bankNameUpdate", bankNameUpdate);
  677.                                           model.put("bankAccountNumberUpdate", bankAccountNumberUpdate);
  678.                                           model.put("accountNameUpdate", accountNameUpdate);
  679.                                          
  680.                                           model.put("firstNameUpdate", firstNameUpdate);
  681.                                           model.put("middleNameUpdate", middleNameUpdate);
  682.                                           model.put("lastNameUpdate", lastNameUpdate);
  683.                                           model.put(DATE_OF_BIRTH, lastDateOfBirth);
  684.                                     }
  685.                  
  686.                               }
  687.                           }
  688.                       }
  689.                       }}}}}
  690.                   }
  691.               }
  692.           }
  693.               return "redirect:"+SharedConstants.APPLICATION_DOMAIN_PUBLIC+"/users/detail?phone=" + phoneNumber;
  694.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement