diff --git a/pom.xml b/pom.xml
index 567bc941d..8062490b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
4.0.0
manage
- 1.3.40
+ 1.3.41
UTF-8
1.8.0
@@ -111,6 +111,11 @@
kaptcha
2.3.2
+
+ com.auth0
+ java-jwt
+ 3.7.0
+
joda-time
joda-time
diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java
index c79bfbb4b..0c19c46fa 100644
--- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java
+++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java
@@ -11,6 +11,8 @@ public interface AppActService {
List listAppActs();
+ JSONObject getAppActPopup();
+
JSONObject newAppAct(JSONObject manager, AppActBean appActBean);
PageList listAppActs(JSONObject manager, AppActQueryBean appActQueryBean);
diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java
index 8c9500a41..3c75e180f 100644
--- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java
+++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java
@@ -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
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java
index a734f73b8..61426d124 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java
@@ -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);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java
index ee045b991..0b78d5ddf 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java
@@ -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));
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/extend/JWTUtil.java b/src/main/java/au/com/royalpay/payment/manage/appclient/extend/JWTUtil.java
new file mode 100755
index 000000000..3ead06721
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/extend/JWTUtil.java
@@ -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;
+ }
+ }
+
+ /**
+ * 获得token中的信息无需secret解密也能获得
+ *
+ * @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);
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
index 783d7d8e2..545fbd33b 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
@@ -481,6 +481,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");
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java
index 317b7b985..052cae98a 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java
@@ -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();
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java
index 878ecfe6d..af8cd7808 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java
@@ -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 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);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
index 917d1ffb4..b3cb551ac 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
@@ -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);
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 1eed5c2c2..193220588 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
@@ -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);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
index 5a95da2f5..274a52fe2 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
@@ -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);
+ }
+
}
diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml
index ed731fad5..2a8bc1e08 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml
@@ -12,4 +12,12 @@
order by active_date desc
limit 1
-
\ No newline at end of file
+
+
diff --git a/src/main/ui/static/incrementalService/partner-incremental-service.js b/src/main/ui/static/incrementalService/partner-incremental-service.js
index 9a5bd04ef..db41f606c 100644
--- a/src/main/ui/static/incrementalService/partner-incremental-service.js
+++ b/src/main/ui/static/incrementalService/partner-incremental-service.js
@@ -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)
diff --git a/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html b/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html
index fc0d6a223..5ee935b5f 100644
--- a/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html
+++ b/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html
@@ -83,7 +83,10 @@
{{serviceInfo.channel}}
- Service Info
+ Service Info
+ 前去跨境商城
+
-
Service List