|
|
@ -2,10 +2,15 @@ package au.com.royalpay.payment.manage.appclient.web;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.RetailLoginInfo;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.RetailLoginInfo;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
|
|
|
|
|
|
|
|
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.SignInStatusManager;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
|
|
|
|
import au.com.royalpay.payment.tools.CommonConsts;
|
|
|
|
import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent;
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
|
|
|
|
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.env.RequestEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
@ -17,12 +22,17 @@ import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationEvent;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisherAware;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
@ -32,7 +42,7 @@ import java.io.IOException;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/api/v1.0/retail_valid")
|
|
|
|
@RequestMapping("/api/v1.0/retail_valid")
|
|
|
|
public class RetailValidationController {
|
|
|
|
public class RetailValidationController implements ApplicationEventPublisherAware {
|
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private Producer captchaProducer;
|
|
|
|
private Producer captchaProducer;
|
|
|
@ -44,6 +54,16 @@ public class RetailValidationController {
|
|
|
|
private ManageDeviceSupport manageDeviceSupport;
|
|
|
|
private ManageDeviceSupport manageDeviceSupport;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private RetailAppService retailAppService;
|
|
|
|
private RetailAppService retailAppService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private SimpleClientApplyService simpleClientApplyService;
|
|
|
|
|
|
|
|
private ApplicationEventPublisher publisher;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
|
|
|
|
|
|
|
this.publisher = applicationEventPublisher;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/devices/{devType}/register")
|
|
|
|
@PostMapping("/devices/{devType}/register")
|
|
|
|
public JSONObject register(@RequestBody String registeration, @PathVariable String devType) {
|
|
|
|
public JSONObject register(@RequestBody String registeration, @PathVariable String devType) {
|
|
|
@ -151,4 +171,73 @@ public class RetailValidationController {
|
|
|
|
public JSONObject getAdDetail(@PathVariable String article_id) {
|
|
|
|
public JSONObject getAdDetail(@PathVariable String article_id) {
|
|
|
|
return retailAppService.getAdDetail(article_id);
|
|
|
|
return retailAppService.getAdDetail(article_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 登录发送手机验证码
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param phoneNumber
|
|
|
|
|
|
|
|
* @param nationCode
|
|
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/send/{phoneNumber}/verify_code")
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
|
|
public String sendLoginMobileVerifyCode(@PathVariable("phoneNumber") @NotEmpty(message = "phone number can't be null") String phoneNumber,
|
|
|
|
|
|
|
|
@RequestParam("nationCode") @NotEmpty(message = "nation code can't be null") String nationCode,
|
|
|
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
|
|
|
return simpleClientApplyService.getAndSendLoginSmsCode(phoneNumber, nationCode, request);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 登录校验手机验证
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param phoneNumber
|
|
|
|
|
|
|
|
* @param nationCode
|
|
|
|
|
|
|
|
* @param params
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/login/verify/{phoneNumber}/verify_code")
|
|
|
|
|
|
|
|
public JSONObject verifyLoginMobileCode(@PathVariable("phoneNumber") @NotEmpty(message = "phone number can't be null") String phoneNumber,
|
|
|
|
|
|
|
|
@RequestParam("nationCode") @NotEmpty(message = "nation code can't be null") String nationCode,
|
|
|
|
|
|
|
|
@RequestBody JSONObject params) {
|
|
|
|
|
|
|
|
if (params.getString("codeKey").isEmpty() && params.getString("codeKey") == null) {
|
|
|
|
|
|
|
|
throw new BadRequestException("verify code can't be null");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
simpleClientApplyService.verifyLoginSMSCode(params.getString("codeKey"), phoneNumber);
|
|
|
|
|
|
|
|
nationCode = "+"+nationCode;
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
|
|
String signKey = signInStatusManager.getClientInfoByPhoneStatusKey(phoneNumber, nationCode);
|
|
|
|
|
|
|
|
JSONObject client = signInStatusManager.getCurrentClient(signKey);
|
|
|
|
|
|
|
|
client = JSON.parseObject(client.toJSONString());
|
|
|
|
|
|
|
|
if (params.getString("devId") != null) {
|
|
|
|
|
|
|
|
deviceSupport.validDeviceWithClient(client, params.getString("devId"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(client!=null){
|
|
|
|
|
|
|
|
result =client;
|
|
|
|
|
|
|
|
client.put("sign_key", signKey);
|
|
|
|
|
|
|
|
result.put("bind_status", true);
|
|
|
|
|
|
|
|
this.publisher.publishEvent(new ClientLoginEvent(this, client.getIntValue("client_id"), client.getString("account_id"), RequestEnvironment.getClientIp(), "MOBILE"));
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
result.put("bind_status", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 商戶端App微信授权登录
|
|
|
|
|
|
|
|
* @param data
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping("/client_app_wechat_signin")
|
|
|
|
|
|
|
|
public JSONObject clientAppWechatSignIn(@RequestBody JSONObject data) {
|
|
|
|
|
|
|
|
JSONObject res = signInStatusManager.clientAppWechatSignIn(data.getString("code"));
|
|
|
|
|
|
|
|
if (!res.getBooleanValue("not_exists")) {
|
|
|
|
|
|
|
|
deviceSupport.validDeviceWithClient(res, res.getString("app_openid"));
|
|
|
|
|
|
|
|
this.publisher.publishEvent(new ClientLoginEvent(this, res.getIntValue("client_id"), res.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|