diff --git a/pom.xml b/pom.xml index d2d370dfe..c7dd78e36 100644 --- a/pom.xml +++ b/pom.xml @@ -136,7 +136,11 @@ com.alibaba druid - + + com.github.qcloudsms + qcloudsms + 1.0.3 + cn.jpush.api diff --git a/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyBean.java b/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyBean.java index 6520aa333..abe3c616c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyBean.java +++ b/src/main/java/au/com/royalpay/payment/manage/application/beans/ClientPreApplyBean.java @@ -2,9 +2,6 @@ package au.com.royalpay.payment.manage.application.beans; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.lang3.time.DateUtils; - -import java.util.Date; /** * Created by yuan on 2018/5/23. 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 4a5582db9..0b7897563 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 @@ -23,6 +23,8 @@ public interface SimpleClientApplyService { void deleteVerifyMailKey(String codeKey); + void verifyMail(String address, JSONObject loginAccount); + void updateApplyInfo(ClientPreApplyBean companyBean,String client_moniker); 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 2c6b57b4e..c2d51150f 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 @@ -6,18 +6,23 @@ import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.mappers.preapply.SysClientPreMapperMapper; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.manage.signin.beans.LoginInfo; +import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.system.core.MailGunService; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; +import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.utils.PasswordUtils; import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; import com.alibaba.fastjson.JSONObject; +import com.github.qcloudsms.SmsSingleSender; + import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -59,6 +64,9 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { private SpringTemplateEngine thymeleaf; @Resource private ClientManager clientManager; + @Resource + private SignInAccountService signInAccountService; + @Resource private ClientAccountMapper clientAccountMapper; @@ -77,10 +85,10 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { @Resource private ClientConfigMapper clientConfigMapper; - @Resource private StringRedisTemplate stringRedisTemplate; - private final SmsSingleSender smsSingleSender = new SmsSingleSender(appId, appKey); + private final SmsSingleSender ssender = new SmsSingleSender(appId, appKey); + // TODO: 2018/5/24 kira private final int REGISTER_CLIENT_TEMPLID = 126008; private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT"; private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS"; @@ -88,12 +96,12 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { private final List tags = new ArrayList<>(); @PostConstruct - public void init(){ + public void init() { tags.add("account"); } @Override - public void verifyRegisterSMSCode(String codeKey,String phoneNumber) { + public void verifyRegisterSMSCode(String codeKey, String phoneNumber) { String rediskey = getRegisterClientRedisKey(phoneNumber); String codeValue = stringRedisTemplate.boundValueOps(rediskey).get(); if (codeValue == null || !codeValue.equals(codeKey)) { @@ -119,7 +127,6 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { if (StringUtils.isNotEmpty(value)) { throw new BadRequestException("SMS has been sent,Please check your messages or try again in 3 minutes."); } - JSONObject sysConfig = sysConfigManager.getSysConfig(); ArrayList param = new ArrayList<>(); String registerClientCode = RandomStringUtils.random(6, true, true); @@ -127,23 +134,23 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { String expireMin = (String) sysConfig.getOrDefault("sms.verification.code.expire", 3); param.add(expireMin); try { - smsSingleSender.sendWithParam(nationCode, phoneNumber, REGISTER_CLIENT_TEMPLID, param, "", "", ""); + ssender.sendWithParam(nationCode, phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", ""); // } catch (Exception e) { throw new ServerErrorException("System Error"); } - stringRedisTemplate.boundValueOps(getRegisterClientRedisKey(phoneNumber)).set(registerClientCode,Long.parseLong(expireMin), TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps(getRegisterClientRedisKey(phoneNumber)).set(registerClientCode, Long.parseLong(expireMin), TimeUnit.MINUTES); return registerClientCode; } @Override - public void sendVerifyEmail(String address,int client_id) { - JSONObject client= clientManager.getClientInfo(client_id); - if(client==null){ + public void sendVerifyEmail(String address, int client_id) { + JSONObject client = clientManager.getClientInfo(client_id); + if (client == null) { throw new BadRequestException("Merchant not found"); } - String key = checkOrGenerateVerifyMailKey(address,null); + String key = checkOrGenerateVerifyMailKey(address, null); Context ctx = new Context(); - ctx.setVariable("url", PlatformEnvironment.getEnv().concatUrl("/register/account/mail/"+address+"/verify/" + key+"/jump")); + ctx.setVariable("url", PlatformEnvironment.getEnv().concatUrl("/register/account/mail/" + address + "/verify/" + key + "/jump")); final String content = thymeleaf.process("mail/register_application", ctx); SendMail sendMail = new SendMail(); Set to = new HashSet<>(); @@ -159,17 +166,17 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { @Override public String checkOrGenerateRegisterProcessKey(String accountName, String codeKey) { - Assert.notNull(accountName,"accountName can't be null"); - if(StringUtils.isNotEmpty(codeKey)){ + Assert.notNull(accountName, "accountName can't be null"); + if (StringUtils.isNotEmpty(codeKey)) { String redisAccountName = stringRedisTemplate.boundValueOps(getRegisterClientProcessRedisKey(codeKey)).get(); - if(!accountName.equals(redisAccountName)){ + if (!accountName.equals(redisAccountName)) { throw new BadRequestException("Data error,Please re-register for safety."); - }else { + } else { return codeKey; } } - String key = RandomStringUtils.random(10, true, false); - stringRedisTemplate.boundValueOps(getRegisterClientProcessRedisKey(key)).set(accountName,1,TimeUnit.HOURS); + String key = RandomStringUtils.random(10, true, false); + stringRedisTemplate.boundValueOps(getRegisterClientProcessRedisKey(key)).set(accountName, 1, TimeUnit.HOURS); return key; } @@ -179,18 +186,18 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { } @Override - public String checkOrGenerateVerifyMailKey(String address, String codeKey){ - Assert.notNull(address,"address can't be null"); - if(StringUtils.isNotEmpty(codeKey)){ + public String checkOrGenerateVerifyMailKey(String address, String codeKey) { + Assert.notNull(address, "address can't be null"); + if (StringUtils.isNotEmpty(codeKey)) { String redisAddress = stringRedisTemplate.boundValueOps(getVerifyMailRedisKey(codeKey)).get(); - if(!address.equals(redisAddress)){ + if (!address.equals(redisAddress)) { throw new BadRequestException("Mail expired"); - }else { + } else { return codeKey; } } - String key = RandomStringUtils.random(10, true, false); - stringRedisTemplate.boundValueOps(getRegisterClientProcessRedisKey(key)).set(address,1,TimeUnit.HOURS); + String key = RandomStringUtils.random(10, true, false); + stringRedisTemplate.boundValueOps(getVerifyMailRedisKey(key)).set(address, 1, TimeUnit.HOURS); return key; } @@ -355,13 +362,29 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { } return banInfo; } + + @Override + public void verifyMail(String address, JSONObject loginAccount) { + LoginInfo loginInfo = new LoginInfo(); + loginInfo.setLoginId(loginAccount.getString("userName")); + loginInfo.setPassword(loginAccount.getString("password")); + JSONObject account = signInAccountService.accountCheck(loginInfo); + JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id")); + if (!address.equals(client.getString("contact_email"))) { + throw new BadRequestException(LocaleSupport.localeMessage("error.login.password")); + } + + } + private String getRegisterClientRedisKey(String phoneNumber){ return REGISTER_CLIENT_PREFIX +phoneNumber; } - private String getRegisterClientProcessRedisKey(String codeKey){ - return REGISTER_CLIENT_PROCESS_PREFIX+codeKey; + + private String getRegisterClientProcessRedisKey(String codeKey) { + return REGISTER_CLIENT_PROCESS_PREFIX + codeKey; } - private String getVerifyMailRedisKey(String codekey){ - return VERIFY_MAIL_PREFIX+codekey; + + private String getVerifyMailRedisKey(String codekey) { + return VERIFY_MAIL_PREFIX + codekey; } } 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 02fabda40..9a7c34cd8 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 @@ -3,8 +3,6 @@ package au.com.royalpay.payment.manage.application.web; import au.com.royalpay.payment.manage.application.beans.ClientPreApplyBean; import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; -import au.com.royalpay.payment.manage.signin.beans.LoginInfo; -import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.http.HttpUtils; @@ -23,8 +21,6 @@ import javax.validation.Valid; public class SimpleClientApplyController { @Resource private SimpleClientApplyService simpleClientApplyService; - @Resource - private SignInAccountService signInAccountService; @RequestMapping(value = "/account/{account_name}", method = RequestMethod.GET) @ResponseBody @@ -49,7 +45,7 @@ public class SimpleClientApplyController { @RequestMapping(value = "/account/mail/{address}/verify/{codeKey}/jump", method = RequestMethod.GET) public ModelAndView jumpVerifyMail(@PathVariable String codeKey, @PathVariable String address){ simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); - ModelAndView view = new ModelAndView("verify_mail"); + ModelAndView view = new ModelAndView("mail/register_application"); view.addObject("codeKey", codeKey); view.addObject("address", address); return view; @@ -59,10 +55,7 @@ public class SimpleClientApplyController { @ResponseBody public void verifyMail(@PathVariable String codeKey, @PathVariable String address,@RequestBody JSONObject account){ simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); - LoginInfo loginInfo = new LoginInfo(); - loginInfo.setLoginId(account.getString("userName")); - loginInfo.setPassword(account.getString("password")); - signInAccountService.accountCheck(loginInfo); + simpleClientApplyService.verifyMail(address,account); simpleClientApplyService.deleteVerifyMailKey(codeKey); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 827aaa9a4..ec73b90f2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1633,8 +1633,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public String getQrCodeBoard(JSONObject client, QRCodeConfig config,JSONObject account,String plantform) { // JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); -// return merchantInfoProvider.getQrCodeBoard(client, config); - return merchantInfoProvider.getQrCodeBoard(client, config,account,plantform); + return merchantInfoProvider.getQrCodeBoard(client, config); +// return merchantInfoProvider.getQrCodeBoard(client, config,account,plantform); } @Override @@ -1658,8 +1658,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid qrboardConfig.put("brandw", "600"); qrboardConfig.put("brandh", "200"); String type = qrboardConfig.getString("type"); - QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform); -// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config); +// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform); + QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config); board.drawBoardImage(ous); } catch (Exception e) { throw new ServerErrorException("QR board config not set for current organize", e); @@ -1679,8 +1679,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject qrboardConfig = JSON.parseObject(qrBoardConfigString); String type = qrboardConfig.getString("type"); - QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform); -// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config); +// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform); + QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config); board.drawBoardImage(ous); } catch (Exception e) { throw new ServerErrorException("QR board config not set for current organize", e); diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index c9015a1d9..91173a856 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -1,6 +1,6 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.schema-name=royalpay_production -spring.datasource.host=192.168.99.100:3306 +spring.datasource.host=192.168.0.49:3306 spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.username=root spring.datasource.password=root \ No newline at end of file diff --git a/src/main/resources/templates/mail/register_application.html b/src/main/resources/templates/mail/register_application.html index a3e88d8fd..8e4e8fc38 100644 --- a/src/main/resources/templates/mail/register_application.html +++ b/src/main/resources/templates/mail/register_application.html @@ -16,38 +16,46 @@ - - - -

Register Invitation

- - - - -

Dear Partner,

-

Thank you for registering an account with us!

-

This is a system verification email from RoyalPay. RoyalPay is an exciting platform that makes international payments as easy as local ones. - To get started, click on the button below:

+

Before you can use RoyalPay Cross-border Payment, you need to verify your email address.

- - - - -
- Register your account right now! -
- + + + + + +
+ Verify mail address +
- + + +
+
+

Once you're ready ro start integrating RoyalPay, we recommend taking a look at our + docs +

if you have any question please contact us

+ Email: info@royalpay.com.au
+ Tel: 1300 10 77 50
+ +
+ + Customer Service +
+
+ + RoyalPay WeChat Official Account +
+ + diff --git a/src/main/resources/templates/mail/verify_mail.html b/src/main/resources/templates/mail/verify_mail.html index e038622e9..421c98c45 100644 --- a/src/main/resources/templates/mail/verify_mail.html +++ b/src/main/resources/templates/mail/verify_mail.html @@ -4,37 +4,16 @@ RoyalPay | Reset Password - - - - - - - - - - - - - - + - - - - - - +