|
|
@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
|
|
|
|
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.core.RetailRSvcService;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.extend.JWTUtil;
|
|
|
|
import au.com.royalpay.payment.manage.appclient.extend.JWTUtil;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.tools.codec.AESCrypt;
|
|
|
|
import au.com.royalpay.payment.tools.codec.AESCrypt;
|
|
|
@ -38,6 +39,8 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
|
|
|
|
private CommonIncrementalChannelMapper commonIncrementalChannelMapper;
|
|
|
|
private CommonIncrementalChannelMapper commonIncrementalChannelMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientServicesApplyMapper clientServicesApplyMapper;
|
|
|
|
private ClientServicesApplyMapper clientServicesApplyMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ClientConfigMapper clientConfigMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
|
|
|
|
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
|
|
|
@ -128,6 +131,41 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public JSONObject setUpShopBySourceCode(String sourceCode, JSONObject params) {
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(params.getString("nonce_str")));
|
|
|
|
|
|
|
|
String signa = params.getString("sign");
|
|
|
|
|
|
|
|
params.remove("sign");
|
|
|
|
|
|
|
|
params = JSONObject.parseObject(JSON.toJSONString(params), Feature.OrderedField);
|
|
|
|
|
|
|
|
boolean checkSign = SignUtils.validSign(params.toJSONString(), signa, svcInfo.getString("channel_pub_key"));
|
|
|
|
|
|
|
|
if (!checkSign) {
|
|
|
|
|
|
|
|
throw new BadRequestException("sign is wrong");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String clientMoniker = decData(params.getString("partnerCode"), key, svcInfo.getString("platform_pri_key"));
|
|
|
|
|
|
|
|
logger.debug("{} new shop set up :{}", clientMoniker,params.toJSONString());
|
|
|
|
|
|
|
|
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
|
|
|
|
|
|
|
|
if (client == null) {
|
|
|
|
|
|
|
|
throw new InvalidShortIdException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id"));
|
|
|
|
|
|
|
|
clientConfig.put("geek_shop_status", 1);
|
|
|
|
|
|
|
|
clientConfigMapper.update(clientConfig);
|
|
|
|
|
|
|
|
result.put("result_status", "SUCCESS");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.error("set up geek shop fail:{} - {}",sourceCode,e.getMessage());
|
|
|
|
|
|
|
|
result.put("result_status", "SYSTEMERROR");
|
|
|
|
|
|
|
|
result.put("result_msg", e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker) {
|
|
|
|
public JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker) {
|
|
|
|
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
|
|
|
|
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
|
|
|
|