Merge branch 'develop'

# Conflicts:
#	pom.xml
master
taylor.dang 5 years ago
commit 8fcce78c76

@ -5,11 +5,11 @@
<parent>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId>
<version>2.1.25</version>
<version>2.1.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -0,0 +1,28 @@
package au.com.royalpay.payment.manage.appclient.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotEmpty;
/**
* @author taylor.dang
* @date 2020-04-20 21:26
*/
@Getter
@Setter
public class AppleLoginBean {
@JSONField(name = "identityToken")
@NotEmpty
private String identityToken;
@JSONField(name = "user")
@NotEmpty
private String user;
@JSONField(name = "devId")
@NotEmpty
private String devId;
@JSONField(name = "authorizationCode")
@NotEmpty
private String authorizationCode;
}

@ -1,9 +1,6 @@
package au.com.royalpay.payment.manage.appclient.core;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage;
import au.com.royalpay.payment.manage.appclient.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientKycFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo;
@ -201,6 +198,8 @@ public interface RetailAppService {
void updateLoginClientAccountPhone(JSONObject account,String contactPhone, String nationCode);
void updateLoginClientAccountOpenId(JSONObject client,JSONObject params);
void updateLoginClientAccountAppleId(JSONObject client,JSONObject params);
/**
* 退
*/
@ -251,6 +250,10 @@ public interface RetailAppService {
JSONObject bindAccountWechat(JSONObject device, JSONObject params);
JSONObject unbindAccountApple(JSONObject device);
JSONObject bindAccountApple(JSONObject device, AppleLoginBean appleLoginBean);
JSONObject getAccountBindInfos(JSONObject device);
JSONObject postAppMessage(JSONObject device, RetailAppMessage message);

@ -6,10 +6,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage;
import au.com.royalpay.payment.manage.appclient.beans.*;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.appclient.extend.GatewayOAuthRegister;
import au.com.royalpay.payment.manage.cashback.core.CashbackService;
@ -73,6 +70,8 @@ import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.*;
import au.com.royalpay.payment.tools.utils.apple.AppleAuthUtils;
import au.com.royalpay.payment.tools.utils.apple.UserClaim;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -2322,6 +2321,14 @@ public class RetailAppServiceImp implements RetailAppService {
clientAccountMapper.update(updateAccount);
}
@Override
public void updateLoginClientAccountAppleId(JSONObject account, JSONObject params) {
JSONObject updateAccount = new JSONObject();
updateAccount.put("account_id", account.getString("account_id"));
updateAccount.put("apple_userid", params.getString("apple_userid"));
clientAccountMapper.update(updateAccount);
}
@Override
public JSONObject unbindAccountPhone(JSONObject device, JSONObject params) {
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
@ -2379,6 +2386,36 @@ public class RetailAppServiceImp implements RetailAppService {
return result;
}
@Override
public JSONObject unbindAccountApple(JSONObject device) {
JSONObject account = new JSONObject();
account.put("account_id", device.getString("account_id"));
account.put("apple_userid", null);
clientAccountMapper.update(account);
JSONObject result = new JSONObject();
result.put("status", "success");
return result;
}
@Override
public JSONObject bindAccountApple(JSONObject device, AppleLoginBean appleLoginBean) {
UserClaim userClaim = AppleAuthUtils.verifyIdentifyToken(appleLoginBean.getIdentityToken());
if (!StringUtils.equalsIgnoreCase(userClaim.getSub(), appleLoginBean.getUser())) {
throw new ForbiddenException("apple userinfo is error");
}
JSONObject account = clientAccountMapper.findByAppleUserId(userClaim.getSub());
if (account != null) {
throw new BadRequestException("Apple UserID has been bound to other accounts, please unbind it before binding");
}
JSONObject updateAccount = new JSONObject();
updateAccount.put("account_id", device.getString("account_id"));
updateAccount.put("apple_userid", userClaim.getSub());
clientAccountMapper.update(updateAccount);
JSONObject result = new JSONObject();
result.put("status", "success");
return result;
}
@Override
public JSONObject getAccountBindInfos(JSONObject device) {
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
@ -2391,6 +2428,7 @@ public class RetailAppServiceImp implements RetailAppService {
result.put("nation_code", account.getString("nation_code"));
}
result.put("wechat_bind_status", account.containsKey("wx_unionid"));
result.put("apple_bind_status", account.containsKey("apple_userid"));
if (account.containsKey("wx_unionid")) {
result.put("wechat_name", account.getString("wechat_name"));
}

@ -3,10 +3,7 @@ package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage;
import au.com.royalpay.payment.manage.appclient.beans.*;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
@ -780,6 +777,7 @@ public class RetailAppController {
/**
*
*
* @param device
* @param params
*/
@ -791,6 +789,7 @@ public class RetailAppController {
/**
*
*
* @param device
*/
@PutMapping("/account/wechat/unbind")
@ -798,7 +797,26 @@ public class RetailAppController {
return retailAppService.unbindAccountWechat(device);
}
/**
* Apple
*
* @param device
*/
@PutMapping("/account/apple/bind")
public JSONObject bindAccountApple(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @Valid @RequestBody AppleLoginBean appleLoginBean) {
return retailAppService.bindAccountApple(device, appleLoginBean);
}
/**
* Apple
*
* @param device
*/
@PutMapping("/account/apple/unbind")
public JSONObject unbindAccountApple(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
return retailAppService.unbindAccountApple(device);
}
/**
@ -960,6 +978,7 @@ public class RetailAppController {
/**
* ()
*
* @param device
* @return
*/

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.manage.appclient.beans.AppleLoginBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailLoginInfo;
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
@ -138,6 +139,35 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
return res;
}
@PostMapping("/apple_signin")
public JSONObject mchAppleSignIn(@Valid @RequestBody AppleLoginBean appleLoginBean) {
return signInStatusManager.mchAppleSignIn(appleLoginBean);
}
/**
*
*
* @param params
* @return
*/
@PostMapping("/login/apple_bind")
public JSONObject appleLoginBind(@RequestBody JSONObject params) {
LoginInfo loginInfo = new LoginInfo();
loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo, "apple");
JSONObject account = signInStatusManager.getCurrentClient(signKey);
retailAppService.updateLoginClientAccountAppleId(account, params);
account = JSON.parseObject(account.toJSONString());
JSONObject result = new JSONObject();
account.put("sign_key", signKey);
result.put("account", account);
result.put("bind_status", true);
result.put("status", "success");
this.publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
return result;
}
@GetMapping("/captcha")
public JSONObject getCaptchaForDevice(@RequestParam(defaultValue = "false") boolean imgurl) throws IOException {
String capText = RandomStringUtils.random(4, false, true);
@ -231,6 +261,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
/**
* -
*
* @param contactPhone
* @param nationCode
* @param params
@ -260,6 +291,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
/**
* App
*
* @param params
* @return
*/
@ -278,6 +310,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
/**
*
*
* @param params
* @return
*/

@ -51,6 +51,10 @@ public interface ClientAccountMapper {
@AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"})
JSONObject findByAppOpenId(@Param("wxapp_openid") String openId);
@AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"})
JSONObject findByAppleUserId(@Param("apple_userid") String appleUserId);
@AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"})
JSONObject findByWxUnioinId(@Param("wx_unionid") String wx_unionid);
@ -85,6 +89,7 @@ public interface ClientAccountMapper {
/**
*
*
* @param unionId
* @return
*/

@ -48,6 +48,8 @@ public interface SignInAccountService {
JSONObject clientWechatAppSignIn(String openId);
JSONObject clientAppleSignIn(String appleUserId);
JSONObject clientWechatAppSignInByUnionId(String unionId);
String ForgetPassword(String partner_code) throws Exception;

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.signin.core;
import au.com.royalpay.payment.manage.appclient.beans.AppleLoginBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.servlet.ModelAndView;
@ -50,6 +51,8 @@ public interface SignInStatusManager {
JSONObject partnerWechatAppSignIn(String code);
JSONObject mchAppleSignIn(AppleLoginBean appleLoginBean);
String clientWechatSignIn(String openid);
JSONObject newClientWechatSignInQRCode();

@ -394,6 +394,17 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
return account;
}
@Override
public JSONObject clientAppleSignIn(String appleUserId) {
JSONObject account = clientAccountMapper.findByAppleUserId(appleUserId);
if (account == null) {
return null;
}
publisher.publishEvent(
new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
return account;
}
@Override
public JSONObject clientWechatAppSignInByUnionId(String unionId) {
if (StringUtils.isBlank(unionId) || unionId == "" || unionId == null) {

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.signin.core.impls;
import au.com.royalpay.payment.manage.appclient.beans.AppleLoginBean;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
@ -10,6 +11,8 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import au.com.royalpay.payment.tools.utils.apple.AppleAuthUtils;
import au.com.royalpay.payment.tools.utils.apple.UserClaim;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@ -63,9 +66,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return null;
}
op.expire(30, TimeUnit.MINUTES);
JSONObject account = signInAccountService.getClient(accountId);
return account;
return signInAccountService.getClient(accountId);
}
private String partnerLoginRedisKey(String statusKey) {
@ -99,11 +100,14 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
@Override
public String verifyClientAccountLogin(LoginInfo loginInfo, String verfiyType) {
JSONObject account = signInAccountService.clientAccountCheck(loginInfo);;
JSONObject account = signInAccountService.clientAccountCheck(loginInfo);
if ("phone".equals(verfiyType)) {
if (account.containsKey("contact_phone")) {
throw new BadRequestException("The account has been linked to the phone number!");
}
} else if (StringUtils.equalsIgnoreCase("apple", verfiyType)
&& StringUtils.isNotEmpty(account.getString("apple_userid"))) {
throw new BadRequestException("The account has been binded and exist appleId!");
} else {
if (account.containsKey("wechat_openid")) {
throw new BadRequestException("The account has been linked to the wechat!");
@ -286,6 +290,31 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return account;
}
@Override
public JSONObject mchAppleSignIn(AppleLoginBean appleLoginBean) {
UserClaim userClaim = AppleAuthUtils.verifyIdentifyToken(appleLoginBean.getIdentityToken());
if (!StringUtils.equalsIgnoreCase(userClaim.getSub(), appleLoginBean.getUser())) {
throw new ForbiddenException("apple userinfo is error");
}
JSONObject account = signInAccountService.clientAppleSignIn(userClaim.getSub());
if (account == null || account.isEmpty()) {
return new JSONObject() {{
put("apple_userid", userClaim.getSub());
put("bind_status", false);
}};
}
String statusKey = newStatusKey();
JSONObject result = new JSONObject();
stringRedisTemplate.boundValueOps(partnerLoginRedisKey(statusKey)).set(account.getString("account_id") + "", 30, TimeUnit.MINUTES);
account = getCurrentClient(statusKey);
account.put("sign_key", statusKey);
result.put("account", account);
account.put("apple_userid", userClaim.getSub());
result.put("bind_status", true);
result.put("status", "success");
return result;
}
@Override
public String clientWechatSignIn(String openid) {
JSONObject account = signInAccountService.clientWechatSignIn(openid);
@ -455,7 +484,6 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}
private void lockRandomCodeId(String codeId) {
stringRedisTemplate.boundValueOps(redisPrefix + "partner_signin" + codeId).set(codeId, 30, TimeUnit.SECONDS);
}

Loading…
Cancel
Save