Merge remote-tracking branch 'origin/develop' into develop

master
liuxinxin 5 years ago
commit a7463fa4cc

@ -8,10 +8,8 @@
<version>1.1.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.2.58</version>
<version>1.2.72</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.4.0</jib-maven-plugin.version>

@ -189,7 +189,9 @@ public interface RetailAppService {
void updateAccountEmail(JSONObject device, JSONObject codekey);
void bindAccountPhone(JSONObject device, JSONObject phone);
void sendBindAccountPhone(JSONObject device,JSONObject phone);
void sendUnbindAccountPhone(JSONObject device);
JSONObject updateAccountPhone(JSONObject device,JSONObject codekey);

@ -38,6 +38,8 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@ -52,6 +54,7 @@ import java.util.stream.Collectors;
@Service
public class ManageAppServiceImp implements ManageAppService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private ManageDeviceSupport manageDeviceSupport;
@ -470,6 +473,7 @@ public class ManageAppServiceImp implements ManageAppService {
throw new BadRequestException("Captcha has been sent.Please check your email or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
logger.debug("send sms code : {} ", codeKeyValue);
Context ctx = new Context();
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
ctx.setVariable("account",manager);
@ -512,6 +516,7 @@ public class ManageAppServiceImp implements ManageAppService {
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
logger.debug("send sms code : {} ", codeKeyValue);
String nationCode = phone.getString("nation_code");
String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();

@ -2098,6 +2098,7 @@ public class RetailAppServiceImp implements RetailAppService {
throw new BadRequestException("Captcha has been sent.Please check your email or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
logger.debug("send sms code : {} ", codeKeyValue);
Context ctx = new Context();
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
ctx.setVariable("account", account);
@ -2133,13 +2134,14 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
public void bindAccountPhone(JSONObject device, JSONObject phone) {
public void sendBindAccountPhone(JSONObject device, JSONObject phone) {
String codeKey = device.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 1 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
logger.debug("send sms code : {} ", codeKeyValue);
String nationCode = phone.getString("nation_code").contains("+")?phone.getString("nation_code").substring(1):phone.getString("nation_code");
String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
@ -2155,6 +2157,30 @@ public class RetailAppServiceImp implements RetailAppService {
}
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
}
@Override
public void sendUnbindAccountPhone(JSONObject device) {
String codeKey = device.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 1 minutes.");
}
JSONObject client = clientAccountMapper.findById(device.getString("account_id"));
String codeKeyValue = RandomStringUtils.random(6, false, true);
String nationCode = client.getString("nation_code").contains("+")?client.getString("nation_code").substring(1):client.getString("nation_code");
String phoneNumber = client.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("解綁绑定手机号");
param.add(codeKeyValue);
String expireMin = "1";
param.add(expireMin);
try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BadRequestException("Phone number is wrong.Please try again.");
}
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
}
@Override
public JSONObject updateAccountPhone(JSONObject device, JSONObject params) {
@ -2169,7 +2195,7 @@ public class RetailAppServiceImp implements RetailAppService {
if (!StringUtils.equals(captcha, params.getString("captcha"))) {
throw new BadRequestException("Verification code is wrong");
}
JSONObject account = clientAccountMapper.findByPhone(contactPhone, "+" + nationCode);
List<JSONObject> account = clientAccountMapper.findByPhone(contactPhone, "+" + nationCode);
if (account != null) {
throw new BadRequestException("Mobile phone number has been bound to other users, please unbind it before binding");
}

@ -727,10 +727,22 @@ public class RetailAppController {
* @param phone contact_phone
* @throws Exception
*/
@PutMapping("/account/phone")
public JSONObject bindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject phone) throws Exception {
retailAppService.bindAccountPhone(device, phone);
return new JSONObject();
@PutMapping("/account/phone_verify/bind")
public JSONObject sendBindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject phone) throws Exception {
retailAppService.sendBindAccountPhone(device, phone);
return new JSONObject();
}
/**
*
*
* @param device
* @throws Exception
*/
@PutMapping("/account/phone_verify/unbind")
public JSONObject unBindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device) throws Exception {
retailAppService.sendUnbindAccountPhone(device);
return new JSONObject();
}
/**

@ -208,7 +208,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
HttpUtils.handleValidErrors(errors);
JSONObject result = new JSONObject();
simpleClientApplyService.verifyLoginSMSCode(params.getString("verify_code"), contactPhone);
String signKey = signInStatusManager.getClientInfoByPhoneStatusKey(contactPhone, nationCode,RequestEnvironment.getClientIp());
String signKey = signInStatusManager.getClientInfoByPhoneStatusKey(contactPhone, nationCode);
if(signKey!=null){
JSONObject account = signInStatusManager.getCurrentClient(signKey);
account = JSON.parseObject(account.toJSONString());
@ -247,7 +247,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"phone");
signInStatusManager.verifyClientLoginPhoneBindCode(contactPhone,nationCode,RequestEnvironment.getClientIp());
signInStatusManager.verifyClientLoginPhoneBindCode(contactPhone,nationCode);
JSONObject account = signInStatusManager.getCurrentClient(signKey);
retailAppService.updateLoginClientAccountPhone(account, contactPhone,nationCode);
account.put("sign_key", signKey);
@ -271,7 +271,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
public JSONObject clientAppWechatSignIn(@RequestBody JSONObject params,
Errors errors) {
HttpUtils.handleValidErrors(errors);
JSONObject account = signInStatusManager.clientAppWechatSignIn(params.getString("code"),RequestEnvironment.getClientIp());
JSONObject account = signInStatusManager.clientAppWechatSignIn(params.getString("code"));
if(!account.getBoolean("bind_status")){
deviceSupport.validDeviceWithClient(account, params.getString("app_openid"));
return account;
@ -287,11 +287,11 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
*/
@PostMapping("/login/wechat_bind")
public JSONObject wechatLoginBind(@RequestBody JSONObject params){
JSONObject wechatInfo = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"),RequestEnvironment.getClientIp());
LoginInfo loginInfo = new LoginInfo();
loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"wechat");
JSONObject wechatInfo = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"));
JSONObject account = signInStatusManager.getCurrentClient(signKey);
params.put("nick_name",wechatInfo.getString("nick_name"));
params.put("union_id",wechatInfo.getString("union_id"));

@ -170,6 +170,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
param.add(registerClientCode);
String expireMin = "3";
param.add(expireMin);
logger.debug("send sms code : {} ", registerClientCode);
try {
if(request.getLocales().nextElement().equals(Locale.CHINESE)|| request.getLocales().nextElement().equals(Locale.SIMPLIFIED_CHINESE)){
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", "");
@ -279,7 +280,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
if (!nation_code.startsWith("+")) {
nation_code = "+" + nation_code;
}
JSONObject account = clientAccountMapper.findByPhone(contact_phone, nation_code);
List<JSONObject> account = clientAccountMapper.findByPhone(contact_phone, nation_code);
if (account != null) {
throw new ForbiddenException("用户名已被注册");
}
@ -597,7 +598,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
}
JSONObject apply = sysClientPreMapperMapper.findByUserName(username);
JSONObject account = clientAccountMapper.findByPhone(apply.getString("contact_phone"), "+61");
List<JSONObject> account = clientAccountMapper.findByPhone(apply.getString("contact_phone"), "+61");
if (account != null) {
throw new ForbiddenException("The user name has been registered");
}
@ -769,7 +770,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
Runnable task2 = () -> {
try {
if (signInfo != null) {
clientManager.registerClientApplyGMS(clientMoniker, sysAccount.getString("account_id"));
// clientManager.registerClientApplyGMS(clientMoniker, sysAccount.getString("account_id"));
}else {
clientManager.getNewAggregateAgreeFile(clientMoniker, null, true);
}
@ -872,6 +873,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
param.add("RoyalPay");
param.add(registerClientCode);
String expireMin = "1";
logger.debug("{} phone sms send code :{}",phoneNumber,registerClientCode);
param.add(expireMin);
try {
if(request.getLocales().nextElement().equals(Locale.CHINESE)|| request.getLocales().nextElement().equals(Locale.SIMPLIFIED_CHINESE)){

@ -28,7 +28,7 @@ public interface ClientAccountMapper {
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
JSONObject findByPhone(@Param("contact_phone") String contact_phone,@Param("nation_code")String nation_code);
List<JSONObject> findByPhone(@Param("contact_phone") String contact_phone,@Param("nation_code")String nation_code);
@AutoSql(type = SqlType.SELECT)
JSONObject findDetail(@Param("account_id") String accountId);

@ -420,15 +420,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.put("temp_sub_merchant", checkSubMerchantIdInCommonPool(subMerchantId));
}
}
if (client.getIntValue("approve_result") == 1
|| (client.getIntValue("approve_result") == 2 && (client.getIntValue("source") == 1 || client.getIntValue("source") == 2))) {
try {
JSONObject activeRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
if (activeRate != null) {
client.put("rate_value", activeRate.getDouble("rate_value"));
}
} catch (Exception ignore) {
try {
JSONObject activeRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
if (activeRate != null) {
client.put("rate_value", activeRate.getDouble("rate_value"));
}
} catch (Exception ignore) {
}
client.put("max_customer_surcharge_rate", PlatformEnvironment.getEnv().getMaxCustomerSurchargeRate());
if (client.getBigDecimal("rate_value") != null) {
@ -1557,7 +1555,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
checkPhoneAndWechatExist(account);
if (StringUtils.isNotBlank(account.getContactPhone())) {
checkPhoneAndWechatExist(account);
}
JSONObject accountJson = account.toJson();
JSONObject accountCheck = clientAccountMapper.findByUsernameForDuplicate(accountJson.getString("username"));
if (accountCheck != null) {
@ -1579,10 +1579,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
private void checkPhoneAndWechatExist(NewAccountBean account) {
if (clientAccountMapper.findByPhone(account.getContactPhone(), "+" + account.getNation_code()) != null) {
if (clientAccountMapper.findByPhone(account.getContactPhone(), account.getNation_code().startsWith("+")?account.getNation_code():"+"+account.getNation_code()) != null) {
throw new BadRequestException("Mobile phone number has been bound to other accounts");
}
;
}
@Override
@ -4977,11 +4976,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
String[] payType = clientConfig.getString("client_pay_type").split(",");
if (Arrays.asList(payType).contains("1")) {
registerAlipayOnlineGms(clientMoniker, null);
switchChannelPermission(account, clientMoniker, "Alipay", true);
enableGatewayAlipayOnline(account, clientMoniker, true);
}
if (Arrays.asList(payType).contains("2")) {
registerAlipayGms(clientMoniker, null);
enableGatewayAlipayOnline(account, clientMoniker, true);
switchChannelPermission(account, clientMoniker, "Alipay", true);
}
}
}

@ -73,7 +73,7 @@ public interface SignInStatusManager {
* @param code
* @return
*/
JSONObject clientAppWechatSignIn(String code,String ip);
JSONObject clientAppWechatSignIn(String code);
/**
*
@ -81,7 +81,7 @@ public interface SignInStatusManager {
* @param nationCode
* @return
*/
String getClientInfoByPhoneStatusKey(String phone,String nationCode,String ip);
String getClientInfoByPhoneStatusKey(String phone,String nationCode);
/**
*
@ -93,17 +93,15 @@ public interface SignInStatusManager {
/**
* openId
* @param codeId
* @param ip
* @return
*/
JSONObject verifyClientLoginWechatBindCode (String codeId,String ip);
JSONObject verifyClientLoginWechatBindCode (String codeId);
/**
*
* @param phone
* @param nationCode
* @param ip
* @return
*/
void verifyClientLoginPhoneBindCode (String phone,String nationCode,String ip);
void verifyClientLoginPhoneBindCode (String phone,String nationCode);
}

@ -82,12 +82,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}
@Override
public String getClientInfoByPhoneStatusKey(String phone, String nationCode,String ip) {
public String getClientInfoByPhoneStatusKey(String phone, String nationCode) {
String statusKey = newStatusKey();
JSONObject account = clientAccountMapper.findOneByPhoneAndCreateTimeDesc(phone, "+" + nationCode);
if (account == null) {
String expireMin = "5";
stringRedisTemplate.boundValueOps(getClientLoginPhoneBindRedisKey(phone,nationCode,ip)).set(phone, Long.parseLong(expireMin), TimeUnit.MINUTES);
stringRedisTemplate.boundValueOps(getClientLoginPhoneBindRedisKey(phone,nationCode)).set(phone, Long.parseLong(expireMin), TimeUnit.MINUTES);
return null;
}
stringRedisTemplate.boundValueOps(partnerLoginRedisKey(statusKey)).set(account.getString("account_id") + "", 30, TimeUnit.MINUTES);
@ -380,7 +380,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}
@Override
public JSONObject clientAppWechatSignIn(String code,String ip) {
public JSONObject clientAppWechatSignIn(String code) {
JSONObject user = mpClientAppWechatApiProvider.getApi("merchant-app").appLoginUser(code);
if(user==null){
throw new BadRequestException("WeChat users do not exist");
@ -396,7 +396,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
res.put("app_openid", openId);
res.put("status", "success");
String expireMin = "5";
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
return res;
}
String statusKey = newStatusKey();
@ -411,14 +411,14 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return result;
}
private String getClientLoginWechatBindRedisKey(String openId,String ip){
return "login:"+":"+CLIENT_LOGIN_WECHAT_BIND_PREFIX + "&"+openId+"&"+ip;
private String getClientLoginWechatBindRedisKey(String openId){
return "login:"+":"+CLIENT_LOGIN_WECHAT_BIND_PREFIX + "&"+openId;
}
@Override
public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
public JSONObject verifyClientLoginWechatBindCode(String openId){
String rediskey = getClientLoginWechatBindRedisKey(openId);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
throw new BadRequestException("The WeChat ID does not apply for binding");
@ -432,12 +432,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}};
}
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){
return "login:"+CLIENT_LOGIN_PHONE_BIND_PREFIX + "&"+nationCode+"&"+phone+"&"+ip;
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode){
return "login:"+CLIENT_LOGIN_PHONE_BIND_PREFIX + "&"+nationCode+"&"+phone;
}
public void verifyClientLoginPhoneBindCode(String phone,String nationCode,String ip){
String rediskey = getClientLoginPhoneBindRedisKey(phone,nationCode,ip);
public void verifyClientLoginPhoneBindCode(String phone,String nationCode){
String rediskey = getClientLoginPhoneBindRedisKey(phone,nationCode);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.equals(phone)) {
throw new BadRequestException("The phone number is for application binding");

Loading…
Cancel
Save