diff --git a/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyStep1Bean.java b/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyStep1Bean.java new file mode 100644 index 000000000..23b1a0a18 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyStep1Bean.java @@ -0,0 +1,78 @@ +package au.com.royalpay.payment.manage.application.beans; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import org.hibernate.validator.constraints.NotEmpty; + +/** + * Created by yuan on 2018/5/23. + */ +public class ClientPreApplyStep1Bean { + @NotEmpty(message = "username can't be null") + private String username; + @NotEmpty(message = "password can't be null") + private String password; + @NotEmpty(message = "contact_person can't be null") + private String contact_person; + @NotEmpty(message = "contact_phone can't be null") + private String contact_phone; + @NotEmpty(message = "contact_email can't be null") + private String contact_email; + @NotEmpty(message = "phoneCodeKey can't be null") + private String phoneCodeKey; + + + public JSONObject insertObject() { + JSONObject res = (JSONObject) JSON.toJSON(this); + return res; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getContact_person() { + return contact_person; + } + + public void setContact_person(String contact_person) { + this.contact_person = contact_person; + } + + public String getContact_phone() { + return contact_phone; + } + + public void setContact_phone(String contact_phone) { + this.contact_phone = contact_phone; + } + + public String getContact_email() { + return contact_email; + } + + public void setContact_email(String contact_email) { + this.contact_email = contact_email; + } + + public String getPhoneCodeKey() { + return phoneCodeKey; + } + + public void setPhoneCodeKey(String phoneCodeKey) { + this.phoneCodeKey = phoneCodeKey; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/application/core/SimpleClientApplyService.java b/src/main/java/au/com/royalpay/payment/manage/application/core/SimpleClientApplyService.java index c0297ab6f..d2725d1f4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/application/core/SimpleClientApplyService.java +++ b/src/main/java/au/com/royalpay/payment/manage/application/core/SimpleClientApplyService.java @@ -1,7 +1,7 @@ package au.com.royalpay.payment.manage.application.core; -import au.com.royalpay.payment.manage.application.beans.ClientPreApplyBean; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; + import com.alibaba.fastjson.JSONObject; public interface SimpleClientApplyService { @@ -25,7 +25,7 @@ public interface SimpleClientApplyService { void verifyMail(String address, JSONObject loginAccount); - void saveOrUpdateApplyInfo(ClientPreApplyBean companyBean, String client_moniker); + void saveOrUpdateApplyInfo(JSONObject companyBean, String username); JSONObject getBankInfo(String bsb_no); diff --git a/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java index bd2e2d51d..a4264d6f5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java @@ -1,6 +1,5 @@ package au.com.royalpay.payment.manage.application.core.impls; -import au.com.royalpay.payment.manage.application.beans.ClientPreApplyBean; import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; import au.com.royalpay.payment.manage.mappers.preapply.SysClientPreMapperMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; @@ -224,9 +223,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { @Override @Transactional - public void saveOrUpdateApplyInfo(ClientPreApplyBean companyBean, String username) { + public void saveOrUpdateApplyInfo(JSONObject applyInfo, String username) { JSONObject apply = sysClientPreMapperMapper.findByUserName(username); - JSONObject applyInfo = companyBean.insertObject(); if (apply == null ){ applyInfo.put("client_pre_apply_id", IdUtil.getId()); sysClientPreMapperMapper.save(applyInfo); diff --git a/src/main/java/au/com/royalpay/payment/manage/application/web/SimpleClientApplyController.java b/src/main/java/au/com/royalpay/payment/manage/application/web/SimpleClientApplyController.java index e5fe5b512..0cd80e262 100644 --- a/src/main/java/au/com/royalpay/payment/manage/application/web/SimpleClientApplyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/application/web/SimpleClientApplyController.java @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.application.web; import au.com.royalpay.payment.manage.application.beans.ClientPreApplyBean; +import au.com.royalpay.payment.manage.application.beans.ClientPreApplyStep1Bean; import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; import au.com.royalpay.payment.tools.CommonConsts; @@ -24,7 +25,7 @@ public class SimpleClientApplyController { private SimpleClientApplyService simpleClientApplyService; @RequestMapping(value = "/account/{account_name}/check", method = RequestMethod.GET) - public void checkAccountName(@PathVariable String account_name){ + public void checkAccountName(@PathVariable String account_name) { simpleClientApplyService.checkAccountName(account_name); } @@ -32,17 +33,16 @@ public class SimpleClientApplyController { @ResponseBody public void registerAccount(@PathVariable String codeKey, @RequestBody @Valid NewAccountBean accountBean, Errors errors, HttpServletResponse response) { HttpUtils.handleValidErrors(errors); - simpleClientApplyService.verifyRegisterSMSCode(codeKey,accountBean.getContactPhone()); + simpleClientApplyService.verifyRegisterSMSCode(codeKey, accountBean.getContactPhone()); JSONObject account = simpleClientApplyService.newAccount(accountBean); String statusKey = simpleClientApplyService.partnerSignIn(account); HttpUtils.setCookie(response, CommonConsts.CODE_KEY, statusKey); } - @RequestMapping(value = "/account/mail/{address}/verify/{codeKey}/jump", method = RequestMethod.GET) - public ModelAndView jumpVerifyMail(@PathVariable String codeKey, @PathVariable String address){ - simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); + public ModelAndView jumpVerifyMail(@PathVariable String codeKey, @PathVariable String address) { + simpleClientApplyService.checkOrGenerateVerifyMailKey(address, codeKey); ModelAndView view = new ModelAndView("mail/register_application"); view.addObject("codeKey", codeKey); view.addObject("address", address); @@ -51,23 +51,39 @@ public class SimpleClientApplyController { @RequestMapping(value = "/account/mail/{address}/verify/{codeKey}", method = RequestMethod.POST) @ResponseBody - public void verifyMail(@PathVariable String codeKey, @PathVariable String address,@RequestBody JSONObject account){ - simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); - simpleClientApplyService.verifyMail(address,account); + public void verifyMail(@PathVariable String codeKey, @PathVariable String address, @RequestBody JSONObject account) { + simpleClientApplyService.checkOrGenerateVerifyMailKey(address, codeKey); + simpleClientApplyService.verifyMail(address, account); simpleClientApplyService.deleteVerifyMailKey(codeKey); } + @RequestMapping(value = "/info/update/{username}/step1", method = RequestMethod.POST) + @ResponseBody + public void registerCompanyInfoStep1(@PathVariable String username, @RequestBody @Valid ClientPreApplyStep1Bean account) { + simpleClientApplyService.verifyRegisterSMSCode(account.getPhoneCodeKey(), account.getContact_phone()); + simpleClientApplyService.saveOrUpdateApplyInfo(account.insertObject(), username); + } + + @RequestMapping(value = "/info/phone/{phone_number}/verify", method = RequestMethod.POST) + @ResponseBody + public JSONObject registerCompanyInfoStep1(@PathVariable String phone_number, @RequestParam String nation_code) { + JSONObject result = new JSONObject(); + result.put("phoneCodeKey", simpleClientApplyService.getAndSendSmsCode(phone_number, nation_code)); + return result; + } + @RequestMapping(value = "/info/update/{username}", method = RequestMethod.POST) public JSONObject registerCompanyInfo(@PathVariable String username, @RequestBody @Valid ClientPreApplyBean applyBean) { JSONObject result = new JSONObject(); - String codeKey = simpleClientApplyService.checkOrGenerateRegisterProcessKey(username, StringUtils.isEmpty(applyBean.getCodeKey())?null:applyBean.getCodeKey()); - simpleClientApplyService.saveOrUpdateApplyInfo(applyBean,username); - result.put("codeKey",codeKey); + String codeKey = simpleClientApplyService.checkOrGenerateRegisterProcessKey(username, + StringUtils.isEmpty(applyBean.getCodeKey()) ? null : applyBean.getCodeKey()); + simpleClientApplyService.saveOrUpdateApplyInfo(applyBean.insertObject(), username); + result.put("codeKey", codeKey); return result; } @RequestMapping(value = "/info/bank/{bsb_no}", method = RequestMethod.GET) - public JSONObject getBankInfo(@PathVariable String bsb_no,@RequestParam String username,@RequestParam String codeKey) { + public JSONObject getBankInfo(@PathVariable String bsb_no, @RequestParam String username, @RequestParam String codeKey) { simpleClientApplyService.checkOrGenerateRegisterProcessKey(username, codeKey); return simpleClientApplyService.getBankInfo(bsb_no); }