Merge branch 'develop'

# Conflicts:
#	pom.xml
master
luoyang 5 years ago
commit 66deba0e80

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.3.40</version>
<version>1.3.41</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.4.0</jib-maven-plugin.version>
@ -111,6 +111,11 @@
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>

@ -11,6 +11,8 @@ public interface AppActService {
List<JSONObject> listAppActs();
JSONObject getAppActPopup();
JSONObject newAppAct(JSONObject manager, AppActBean appActBean);
PageList<JSONObject> listAppActs(JSONObject manager, AppActQueryBean appActQueryBean);

@ -64,7 +64,27 @@ public class AppActServiceImp implements AppActService {
// String url = act.getString("act_url");
// act.put("act_url", PlatformEnvironment.getEnv().concatUrl(url));
// }
return actAppMapper.listActs();
return new ArrayList<>();
}
@Override
public JSONObject getAppActPopup(){
JSONObject appActPopup = actAppMapper.getAppActPopup();
if (appActPopup == null) {
return new JSONObject();
}
int appLinkType = appActPopup.getIntValue("show_type");
switch (appLinkType) {
case 1:
appActPopup.put("link_type", "webview");
break;
case 2:
appActPopup.put("link_type", "app_route");
break;
default:
break;
}
return appActPopup;
}
@Override

@ -13,4 +13,6 @@ public interface RetailRSvcService {
JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode);
JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params);
JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker);
}

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.manage.appclient.extend.JWTUtil;
import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.codec.AESCrypt;
@ -122,6 +123,31 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
return result;
}
@Override
public JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker) {
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
if (svcInfo == null || StringUtils.isEmpty(svcInfo.getString("channel_pub_key"))
|| StringUtils.isEmpty(svcInfo.getString("platform_pub_key")) || StringUtils.isEmpty("platform_pri_key")) {
throw new BadRequestException("this channel config is wrong");
}
String aesKeyStr = org.apache.commons.codec.binary.Base64.encodeBase64String(AESCrypt.randomKey().getEncoded());
Key key = AESCrypt.fromKeyString(org.apache.commons.codec.binary.Base64.decodeBase64(aesKeyStr));
JSONObject result = new JSONObject();
result.put("sign_type", "RSA2");
result.put("partnerCode", encData(clientMoniker, key, svcInfo.getString("channel_pub_key")));
result.put("nonce_str", aesKeyStr);
result.put("timestamp", System.currentTimeMillis());
result = JSONObject.parseObject(JSON.toJSONString(result), Feature.OrderedField);
result.put("sign", SignUtils.buildSign(result.toJSONString(), svcInfo.getString("platform_pri_key")));
String encryptedStrInfo = JSON.toJSONString(result);
String jwtResult = JWTUtil.sign(encryptedStrInfo, JWTUtil.SECRET);
logger.info("clientMoniker:{} - json:{} - token:{}", clientMoniker, encryptedStrInfo, jwtResult);
return new JSONObject() {{
put("token", jwtResult);
}};
}
private String encData(String data, Key key, String publicKey) {
String pubKeyEncData = SignUtils.encData(data, publicKey);
return org.apache.commons.codec.binary.Base64.encodeBase64String(AESCrypt.encrypt(pubKeyEncData.getBytes(StandardCharsets.UTF_8), key));

@ -0,0 +1,68 @@
package au.com.royalpay.payment.manage.appclient.extend;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import java.util.Date;
public class JWTUtil {
// 过期时间5分钟
private static final long EXPIRE_TIME = 5 * 60 * 1000;
public static final String SECRET = "GeeK!@#$%";
/**
* token
*
* @param token
* @param secret
* @return
*/
public static boolean verify(String token, String userId, String secret) {
try {
Algorithm algorithm = Algorithm.HMAC256(secret);
JWTVerifier verifier = JWT.require(algorithm)
.withClaim("userId", userId)
.build();
DecodedJWT jwt = verifier.verify(token);
return true;
} catch (Exception exception) {
return false;
}
}
/**
* tokensecret
*
* @return token
*/
public static String getUserId(String token) {
try {
DecodedJWT jwt = JWT.decode(token);
return jwt.getClaim("userId").asString();
} catch (JWTDecodeException e) {
return null;
}
}
/**
* ,5min
*
* @param userId id
* @param secret
* @return token
*/
public static String sign(String userId, String secret) {
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
Algorithm algorithm = Algorithm.HMAC256(secret);
// 附带username信息
return JWT.create()
.withClaim("userId", userId)
.withExpiresAt(date)
.sign(algorithm);
}
}

@ -482,6 +482,11 @@ public class RetailAppController {
return appActService.listAppActs();
}
@GetMapping("/popup_acts")
public JSONObject getAppActPopup(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return appActService.getAppActPopup();
}
@GetMapping("/act/mondelay/desc")
public ModelAndView getActDetail(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
ModelAndView mav = new ModelAndView("activity/mondelay/mondelay");

@ -7,7 +7,6 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@ -33,4 +32,6 @@ public interface ActAppMapper {
void newAppAct(JSONObject params);
JSONObject getLatestWindowNotice(@Param("now") Date now);
JSONObject getAppActPopup();
}

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List;
@ -24,8 +25,13 @@ public interface ClientIncrementalMapper {
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findAllByclientMoniker(@Param("client_id") int clientId);
@AutoSql(type = SqlType.SELECT)
JSONObject findByClinetIdAndChannel(@Param("client_id")int clinet_id, @Param("channel")String channel);
@Select("select ci.*, " +
" si.source_code " +
" from sys_client_incremental ci inner join sys_incremental_channels si " +
" on ci.channel = si.channel" +
" where ci.client_id = #{client_id} " +
" and ci.channel = #{channel} ")
JSONObject findByClinetIdAndChannel(@Param("client_id")int clientId, @Param("channel")String channel);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject saveIncrementalService);

@ -551,6 +551,8 @@ public interface ClientManager {
*/
JSONObject partnerIncrementalServiceInfo(String clientMoniker, String incrementalId);
JSONObject getClientIncrementalServiceLoginToken(JSONObject account, String incrementalId);
JSONObject findByLookupCode(String code);
RSvcMchBean findSvcMchByAccountId(String accountId);

@ -22,6 +22,7 @@ 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.AppMerchantBean;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.complianceAudit.core.ClientComplianceApply;
import au.com.royalpay.payment.manage.dev.bean.TestMerchantAccountInfo;
@ -307,6 +308,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private IndustryLookupMapper industryLookupMapper;
@Resource
private GatewayMerchantApply gatewayMerchantApply;
@Resource
private RetailRSvcService retailRSvcService;
@Resource
@ -6496,6 +6499,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return incrementalInfo;
}
@Override
public JSONObject getClientIncrementalServiceLoginToken(JSONObject account,String channel){
JSONObject client = clientMapper.findClient(account.getIntValue("client_id"));
if (client == null) {
throw new InvalidShortIdException();
}
JSONObject incrementalInfo = clientIncrementalMapper.findByClinetIdAndChannel(client.getInteger("client_id"), channel);
if(incrementalInfo==null){
throw new BadRequestException("Merchant service not opened");
}
return retailRSvcService.getGeekSsoTokenInfo(incrementalInfo.getString("source_code"),client.getString("client_moniker"));
}
@Override
public void changePartnerIncrementalService(String clientMoniker, JSONObject incrementalService, JSONObject manager) {
JSONObject client = clientMapper.findClientByMoniker(clientMoniker);

@ -649,4 +649,10 @@ public class PartnerViewController {
return clientManager.partnerIncrementalServiceInfo(clientMoniker,channel);
}
@PartnerMapping(value = "/incremental_service/{channel}/login_token", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody
public JSONObject getClientIncrementalServiceLoginToken(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @PathVariable("channel") String channel){
return clientManager.getClientIncrementalServiceLoginToken(account,channel);
}
}

@ -12,4 +12,12 @@
order by active_date desc
limit 1
</select>
</mapper>
<select id="getAppActPopup" resultType="com.alibaba.fastjson.JSONObject">
select *
from act_app_list
where is_valid = 1
and expire_date &gt; #{now}
order by create_time desc
limit 1
</select>
</mapper>

@ -71,6 +71,18 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.serviceInfo.logo_url = $scope.CheckImgExists($scope.serviceInfo.logo_url)?$scope.serviceInfo.logo_url:'/static/images/royalpay_sign.png'
})
}
$scope.getGeekSsoLoginUrl = function () {
var url = "http://mch.dev.geekforbest.com/#/sso_login?token=";
$http.get("/client/partner_info/incremental_service/" + $stateParams.channel + "/login_token").then(function (res) {
url += res.data.token;
window.open(url, '_blank');
}, function (resp) {
console.log(resp.data.message)
window.open("https://mch.geekforbest.com/#/login", '_blank');
});
};
$scope.CheckImgExists =function (url) {
var xmlHttp ;
if (window.ActiveXObject)

@ -83,7 +83,10 @@
<h1>
<img height="40px" ng-src="{{serviceInfo.logo_url}}">
<span style="color:#F06101">{{serviceInfo.channel}}</span>
Service Info</h1>
Service Info
<a ng-if="serviceInfo.channel=='RP跨境商城'" type="button" ng-click="getGeekSsoLoginUrl()"
style="cursor: pointer;text-decoration: underline;padding-left: 20px"> 前去跨境商城</a>
</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-comments-o"></i> Service List

Loading…
Cancel
Save