[Y] R service 加密参数

master
taylor.dang 5 years ago
parent 3b46cf5926
commit 9ac244038a

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.2.97</version> <version>1.3.0</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.4.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.4.0</jib-maven-plugin.version>
@ -212,6 +212,10 @@
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

@ -0,0 +1,3 @@
ALTER TABLE sys_incremental_channels ADD COLUMN channel_pub_key TEXT DEFAULT NULL AFTER source_code;
ALTER TABLE sys_incremental_channels ADD COLUMN platform_pub_key TEXT DEFAULT NULL AFTER channel_pub_key;
ALTER TABLE sys_incremental_channels ADD COLUMN platform_pri_key TEXT DEFAULT NULL AFTER platform_pub_key;

@ -0,0 +1,50 @@
package au.com.royalpay.payment.manage.appclient.beans;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RSvcMchBean {
/**
*
*/
private String merchantNumber;
/**
* partnerCode
*/
private String partnerCode;
/**
* CredentialCode
*/
private String credentialCode;
/**
* HostpayHost
*/
private String payHost;
/**
* logo
*/
private String logo;
/**
*
*/
private String industryCode;
/**
*
*/
private String industryName;
/**
*
*/
private String merchantName;
}

@ -0,0 +1,14 @@
package au.com.royalpay.payment.manage.appclient.core;
import com.alibaba.fastjson.JSONObject;
public interface RetailRSvcService {
/**
* Appservice code
*
* @param device
* @param sourceCode
* @return
*/
JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode);
}

@ -0,0 +1,53 @@
package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.encryptalgorithm.SignUtils;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.mappers.CommonIncrementalChannelMapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.security.Key;
@Service
public class RetailRSvcServiceImpl implements RetailRSvcService {
@Resource
private ClientManager clientManager;
@Resource
private DeviceSupport deviceSupport;
@Resource
private CommonIncrementalChannelMapper commonIncrementalChannelMapper;
@Override
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
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");
}
RSvcMchBean svcMchBean = clientManager.findSvcMchByAccountId(device.getString("account_id"));
String pubKeyEncCredentialCode = SignUtils.encData(svcMchBean.getCredentialCode(), svcInfo.getString("channel_pub_key"));
String aesKeyStr = Base64.encodeBase64String(AESCrypt.randomKey().getEncoded());
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(aesKeyStr));
String decCredentialCode = Base64.encodeBase64String(AESCrypt.encrypt(pubKeyEncCredentialCode.getBytes(StandardCharsets.UTF_8), key));
JSONObject result = (JSONObject) JSON.toJSON(svcMchBean);
result.put("sign_type", "RSA2");
result.put("enc_data", decCredentialCode);
result.put("nonce_str", aesKeyStr);
result.put("timestamp", System.currentTimeMillis());
result.put("sign", SignUtils.buildSign(result.toJSONString(), svcInfo.getString("platform_pri_key")));
return result;
}
}

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.advise.AppClientController;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
@AppClientController
@RequestMapping("/api/v1.0/retail/rsvc")
public class RetailRSvcController {
@Resource
private RetailRSvcService retailRSvcService;
@GetMapping(value = "/{source_code}/userinfo")
public JSONObject findUserInfoBySourceCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String source_code) {
return retailRSvcService.findMchInfoBySourceCode(device, source_code);
}
}

@ -99,4 +99,8 @@ public interface ClientAccountMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"}) @AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"})
List<JSONObject> findByWechatUnionId(@Param("wx_unionid")String unionId); List<JSONObject> findByWechatUnionId(@Param("wx_unionid")String unionId);
@AutoSql(type = SqlType.SELECT)
JSONObject findRSvcClientInfo(@Param("account_id")String accountId);
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; 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.AppMerchantBean;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.manage.merchants.beans.*; import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
@ -40,7 +41,7 @@ public interface ClientManager {
JSONObject listClients(JSONObject manager, PartnerQuery query); JSONObject listClients(JSONObject manager, PartnerQuery query);
void exportClients(JSONObject manager,PartnerQuery query,HttpServletResponse resp); void exportClients(JSONObject manager, PartnerQuery query, HttpServletResponse resp);
JSONObject listClientsByApp(JSONObject manager, AppMerchantBean query); JSONObject listClientsByApp(JSONObject manager, AppMerchantBean query);
@ -136,7 +137,7 @@ public interface ClientManager {
void toggleAccountReceiveNoticeByOpenId(String openid, boolean enable); void toggleAccountReceiveNoticeByOpenId(String openid, boolean enable);
@Transactional @Transactional
void togglePayNotice(JSONObject account,String clientMoniker, boolean enable); void togglePayNotice(JSONObject account, String clientMoniker, boolean enable);
@Transactional @Transactional
void changeRole(JSONObject manager, String clientMoniker, String accountId, int role); void changeRole(JSONObject manager, String clientMoniker, String accountId, int role);
@ -150,7 +151,7 @@ public interface ClientManager {
JSONObject getAccountByOpenId(String openid); JSONObject getAccountByOpenId(String openid);
void updateClientBDUser(JSONObject account,String clientMoniker, int managerId); void updateClientBDUser(JSONObject account, String clientMoniker, int managerId);
void refreshClientCredentialCode(JSONObject manager, String clientMoniker); void refreshClientCredentialCode(JSONObject manager, String clientMoniker);
@ -183,13 +184,13 @@ public interface ClientManager {
JSONObject getQRCode(JSONObject manager, String clientMoniker, QRCodeConfig config); JSONObject getQRCode(JSONObject manager, String clientMoniker, QRCodeConfig config);
String getQrCodeBoard(JSONObject client, QRCodeConfig config,JSONObject account,String plantform); String getQrCodeBoard(JSONObject client, QRCodeConfig config, JSONObject account, String plantform);
void writeAggregateQrCodeBoard(JSONObject manager, String clientMoniker, QRCodeConfig config, OutputStream ous,String plantform); void writeAggregateQrCodeBoard(JSONObject manager, String clientMoniker, QRCodeConfig config, OutputStream ous, String plantform);
void writeCBBankAggregateQrCodeBoard(JSONObject manager, String clientMoniker, OutputStream ous,String plantform); void writeCBBankAggregateQrCodeBoard(JSONObject manager, String clientMoniker, OutputStream ous, String plantform);
void writeQrCodeBoard(JSONObject manager, String clientMoniker, QRCodeConfig config, OutputStream ous,String plantform); void writeQrCodeBoard(JSONObject manager, String clientMoniker, QRCodeConfig config, OutputStream ous, String plantform);
void writePoster(JSONObject manager, String clientMoniker, OutputStream ous); void writePoster(JSONObject manager, String clientMoniker, OutputStream ous);
@ -198,7 +199,7 @@ public interface ClientManager {
void writeActivityPoster(JSONObject manager, String clientMoniker, String activityName, OutputStream ous) throws IOException; void writeActivityPoster(JSONObject manager, String clientMoniker, String activityName, OutputStream ous) throws IOException;
@Transactional @Transactional
void updateTimeZone(JSONObject account,String clientMoniker, String timezone); void updateTimeZone(JSONObject account, String clientMoniker, String timezone);
JSONObject listClientDevices(JSONObject manager, String clientMoniker, String remark, int page, int limit, String client_type, String[] client_ids); JSONObject listClientDevices(JSONObject manager, String clientMoniker, String remark, int page, int limit, String client_type, String[] client_ids);
@ -210,19 +211,19 @@ public interface ClientManager {
JSONObject getBankInfo(JSONObject manager, String clientMoniker, String bsb_no); JSONObject getBankInfo(JSONObject manager, String clientMoniker, String bsb_no);
void setMaxOrderAmount(JSONObject account,String clientMoniker, BigDecimal limit); void setMaxOrderAmount(JSONObject account, String clientMoniker, BigDecimal limit);
void setClientQRCodePaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge); void setClientQRCodePaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge);
void setClientApiPaySurCharge(JSONObject account,String clientMoniker, boolean enableApiSurcharge); void setClientApiPaySurCharge(JSONObject account, String clientMoniker, boolean enableApiSurcharge);
void setClientRetailPaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge); void setClientRetailPaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge);
void setClientCBBankPaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge); void setClientCBBankPaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge);
void setClientTaxInSurcharge(JSONObject account,String clientMoniker, boolean taxInSurcharge); void setClientTaxInSurcharge(JSONObject account, String clientMoniker, boolean taxInSurcharge);
void setClientCustomerTaxFree(JSONObject account,String clientMoniker, boolean customerTaxFree); void setClientCustomerTaxFree(JSONObject account, String clientMoniker, boolean customerTaxFree);
List<JSONObject> listClientsForSettlement(); List<JSONObject> listClientsForSettlement();
@ -282,7 +283,7 @@ public interface ClientManager {
void changeCBBankPaymentPage(JSONObject account, String paypad_version); void changeCBBankPaymentPage(JSONObject account, String paypad_version);
void changeManualSettle(JSONObject account , int client_id, boolean manual_settle,String operator_id,int type,String operation); void changeManualSettle(JSONObject account, int client_id, boolean manual_settle, String operator_id, int type, String operation);
void changeQRCodePaySurcharge(JSONObject account, boolean paySurcharge); void changeQRCodePaySurcharge(JSONObject account, boolean paySurcharge);
@ -296,37 +297,37 @@ public interface ClientManager {
void changeRequireRemark(JSONObject account, boolean requireRemark); void changeRequireRemark(JSONObject account, boolean requireRemark);
void changeSurcharge(JSONObject account,JSONObject device, UpdateSurchargeDTO updateSurchargeDTO); void changeSurcharge(JSONObject account, JSONObject device, UpdateSurchargeDTO updateSurchargeDTO);
void refusePartner(String clientMoniker, JSONObject manager, String refuse_remark); void refusePartner(String clientMoniker, JSONObject manager, String refuse_remark);
JSONArray getAllClientIds(int clientId); JSONArray getAllClientIds(int clientId);
void updateAppClient(JSONObject account,int client_id, AppClientBean appClientBean); void updateAppClient(JSONObject account, int client_id, AppClientBean appClientBean);
void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing,String remark); void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing, String remark);
void setSurchargeMode(JSONObject account, String clientMoniker, String surcharge_mode); void setSurchargeMode(JSONObject account, String clientMoniker, String surcharge_mode);
JSONObject surchargeAccount(JSONObject account, String clientMoniker); JSONObject surchargeAccount(JSONObject account, String clientMoniker);
void setAllowSurchargeCredit(JSONObject account,String clientMoniker, Boolean allow_surcharge_credit); void setAllowSurchargeCredit(JSONObject account, String clientMoniker, Boolean allow_surcharge_credit);
List<JSONObject> getAccountTransactions(JSONObject account,String clientMoniker); List<JSONObject> getAccountTransactions(JSONObject account, String clientMoniker);
List<JSONObject> getAccountDetailByMonths(JSONObject account,String clientMoniker); List<JSONObject> getAccountDetailByMonths(JSONObject account, String clientMoniker);
List<JSONObject> getAccountTransactionsByDetailId(JSONObject account,String clientMoniker, String detailId); List<JSONObject> getAccountTransactionsByDetailId(JSONObject account, String clientMoniker, String detailId);
List<JSONObject> getAccountMonthDetails(JSONObject account,String clientMoniker); List<JSONObject> getAccountMonthDetails(JSONObject account, String clientMoniker);
void saveAccountTransaction(JSONObject account,String clientMoniker, JSONObject transaction); void saveAccountTransaction(JSONObject account, String clientMoniker, JSONObject transaction);
void enableGatewayUpgrade(JSONObject account,String clientMoniker, boolean gatewayUpgrade); void enableGatewayUpgrade(JSONObject account, String clientMoniker, boolean gatewayUpgrade);
void enableGatewayAlipayOnline(JSONObject account,String clientMoniker, boolean gatewayAlipayOnline); void enableGatewayAlipayOnline(JSONObject account, String clientMoniker, boolean gatewayAlipayOnline);
void setCustomerSurchargeRate(JSONObject account,String clientMoniker, BigDecimal customer_surcharge_rate); void setCustomerSurchargeRate(JSONObject account, String clientMoniker, BigDecimal customer_surcharge_rate);
void setPartnerPublicKeyConfig(JSONObject account, String ipWhitelistConfig); void setPartnerPublicKeyConfig(JSONObject account, String ipWhitelistConfig);
@ -334,17 +335,17 @@ public interface ClientManager {
void setIpWhitelistConfig(JSONObject account, String ipWhitelistConfig); void setIpWhitelistConfig(JSONObject account, String ipWhitelistConfig);
void setOrderExpiryConfig(JSONObject account,String clientMoniker, String orderExpiryConfig); void setOrderExpiryConfig(JSONObject account, String clientMoniker, String orderExpiryConfig);
void getAgreeFile(String clientMoniker, JSONObject manager) throws Exception; void getAgreeFile(String clientMoniker, JSONObject manager) throws Exception;
void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception; void getAggregateAgreeFile(String clientMoniker, JSONObject manager, boolean renewal) throws Exception;
void getNewAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception; void getNewAggregateAgreeFile(String clientMoniker, JSONObject manager, boolean renewal) throws Exception;
void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception; void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception;
void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal); void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile, boolean renewal);
void completeAgree(String clientMoniker, JSONObject manager); void completeAgree(String clientMoniker, JSONObject manager);
@ -356,17 +357,18 @@ public interface ClientManager {
/** /**
* *
*
* @param manager * @param manager
* @param clientMoniker * @param clientMoniker
* @param query * @param query
*/ */
void excelSettlementLog(JSONObject manager, String clientMoniker, TradeLogQuery query,HttpServletResponse response); void excelSettlementLog(JSONObject manager, String clientMoniker, TradeLogQuery query, HttpServletResponse response);
void updateRefundPwd(JSONObject account, String pwd); void updateRefundPwd(JSONObject account, String pwd);
void validRefundPwd(JSONObject account, String pwd); void validRefundPwd(JSONObject account, String pwd);
void setWeekendDelay(JSONObject account,String client_moniker,int clientId, boolean delay); void setWeekendDelay(JSONObject account, String client_moniker, int clientId, boolean delay);
List<JSONObject> listSubMerchantIdApplys(JSONObject manager, String clientMoniker); List<JSONObject> listSubMerchantIdApplys(JSONObject manager, String clientMoniker);
@ -374,7 +376,7 @@ public interface ClientManager {
List<JSONObject> listYeepaySubMerchantIdApplys(JSONObject manager, String clientMoniker); List<JSONObject> listYeepaySubMerchantIdApplys(JSONObject manager, String clientMoniker);
String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply, JSONObject manager);
void registerAlipayGms(String clientMoniker, JSONObject manager); void registerAlipayGms(String clientMoniker, JSONObject manager);
@ -390,25 +392,25 @@ public interface ClientManager {
String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager); String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager);
List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager); List<JSONObject> listMerchantIds(String clientMoniker, JSONObject manager);
void clearCacheSubMerchantIdApplices(String clientMoniker); void clearCacheSubMerchantIdApplices(String clientMoniker);
JSONObject getCheckClientInfo(int client_id,String account_id, String channel); JSONObject getCheckClientInfo(int client_id, String account_id, String channel);
List<JSONObject> getClientSubMerchantIdLogs(String clientMoniker,JSONObject manager); List<JSONObject> getClientSubMerchantIdLogs(String clientMoniker, JSONObject manager);
void applyToCompliance(String client_moniker, JSONObject account); void applyToCompliance(String client_moniker, JSONObject account);
void sendVerifyEmail(JSONObject client,String accountId); void sendVerifyEmail(JSONObject client, String accountId);
JSONObject getWithConfig(int client_id); JSONObject getWithConfig(int client_id);
List<JSONObject> getClientsByBD(String bd_user); List<JSONObject> getClientsByBD(String bd_user);
JSONObject simpleQuery(JSONObject param, int page,int limit); JSONObject simpleQuery(JSONObject param, int page, int limit);
JSONObject getByEmail(String email, int page, int limit,List<String> ExceptClientIds); JSONObject getByEmail(String email, int page, int limit, List<String> ExceptClientIds);
void addSub(String client_moniker, JSONObject manager); void addSub(String client_moniker, JSONObject manager);
@ -416,25 +418,25 @@ public interface ClientManager {
String getShortLink(String client_moniker); String getShortLink(String client_moniker);
String getGatewayShortLink(String client_moniker,String channel); String getGatewayShortLink(String client_moniker, String channel);
@Transactional @Transactional
void switchHfLink(JSONObject manager, String clientMoniker,boolean allow); void switchHfLink(JSONObject manager, String clientMoniker, boolean allow);
@Transactional @Transactional
void switchGatewayLink(JSONObject manager, String clientMoniker,String channel,boolean allow); void switchGatewayLink(JSONObject manager, String clientMoniker, String channel, boolean allow);
void sendHfEmailNotice(JSONObject order); void sendHfEmailNotice(JSONObject order);
void sendGatewayEmailNotice(JSONObject order); void sendGatewayEmailNotice(JSONObject order);
void subRpayMerchantApplication(String clientMoniker,JSONObject merchantInfo, JSONObject manager); void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo, JSONObject manager);
void subYeepayMerchantApplication(String clientMoniker,JSONObject merchantInfo, JSONObject manager); void subYeepayMerchantApplication(String clientMoniker, JSONObject merchantInfo, JSONObject manager);
void subYeepayMerchantAdd(String clientMoniker,JSONObject merchantInfo, JSONObject manager); void subYeepayMerchantAdd(String clientMoniker, JSONObject merchantInfo, JSONObject manager);
void reSubYeepayMerchantApplication(String clientMoniker,JSONObject merchantInfo, JSONObject manager); void reSubYeepayMerchantApplication(String clientMoniker, JSONObject merchantInfo, JSONObject manager);
void updateAllPartnerPassword(String clientMoniker); void updateAllPartnerPassword(String clientMoniker);
@ -445,7 +447,7 @@ public interface ClientManager {
* *
* @param clientId * @param clientId
*/ */
boolean postponeClientRate(int clientId, String clientMoniker,String nextYearExipryDate); boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate);
JSONObject comListPartnerSelection(JSONObject manager, PartnerQuery query); JSONObject comListPartnerSelection(JSONObject manager, PartnerQuery query);
@ -474,7 +476,7 @@ public interface ClientManager {
*/ */
void resetRefundPassword(JSONObject account, JSONObject json); void resetRefundPassword(JSONObject account, JSONObject json);
void resetRefundPasswordByManage(String clientMoniker,JSONObject manage, JSONObject json); void resetRefundPasswordByManage(String clientMoniker, JSONObject manage, JSONObject json);
List<Integer> listLevel3Client(int client_id); List<Integer> listLevel3Client(int client_id);
@ -496,20 +498,23 @@ public interface ClientManager {
/** /**
* / * /
*
* @param clientMoniker * @param clientMoniker
* @param incrementalService * @param incrementalService
*/ */
void changePartnerIncrementalService(String clientMoniker, JSONObject incrementalService,JSONObject manager); void changePartnerIncrementalService(String clientMoniker, JSONObject incrementalService, JSONObject manager);
/** /**
* / * /
*
* @param clientMoniker * @param clientMoniker
* @param incrementalService * @param incrementalService
*/ */
void changeSwitchIncrementalService(String clientMoniker, JSONObject incrementalService,JSONObject manager); void changeSwitchIncrementalService(String clientMoniker, JSONObject incrementalService, JSONObject manager);
/** /**
* *
*
* @param clientMoniker * @param clientMoniker
* @return * @return
*/ */
@ -517,4 +522,6 @@ public interface ClientManager {
JSONObject findByLookupCode(String code); JSONObject findByLookupCode(String code);
RSvcMchBean findSvcMchByAccountId(String accountId);
} }

@ -17,6 +17,7 @@ import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.mappers.SysClientMapper; import au.com.royalpay.payment.core.mappers.SysClientMapper;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.tools.defines.IncrementalChannel; import au.com.royalpay.payment.tools.defines.IncrementalChannel;
import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
@ -6139,14 +6140,33 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public JSONObject findByLookupCode(String code){ public JSONObject findByLookupCode(String code) {
JSONObject industryInfo = industryLookupMapper.findByLookupCode(code); JSONObject industryInfo = industryLookupMapper.findByLookupCode(code);
if(industryInfo==null){ if (industryInfo == null) {
return new JSONObject(){{ return new JSONObject() {{
put("lookup_code","未知行业"); put("lookup_code", "code");
put("lookup_value", "未知行业");
}}; }};
} }
return industryInfo; return industryInfo;
} }
@Override
public RSvcMchBean findSvcMchByAccountId(String accountId) {
JSONObject mchInfo = clientAccountMapper.findRSvcClientInfo(accountId);
if (mchInfo == null || mchInfo.isEmpty()) {
throw new BadRequestException("Client Not Exists!");
}
RSvcMchBean svcMchBean = new RSvcMchBean();
svcMchBean.setMerchantNumber(mchInfo.getString("username"));
svcMchBean.setMerchantName(mchInfo.getString("short_name"));
svcMchBean.setPartnerCode(mchInfo.getString("client_moniker"));
svcMchBean.setCredentialCode(mchInfo.getString("credential_code"));
svcMchBean.setPayHost(PlatformEnvironment.getEnv().mainHost());
svcMchBean.setLogo(mchInfo.getString("logo_url"));
svcMchBean.setIndustryCode(mchInfo.getString("industry"));
svcMchBean.setIndustryName(findByLookupCode(mchInfo.getString("industry")).getString("lookup_value"));
return svcMchBean;
}
} }

@ -41,4 +41,24 @@
ORDER BY a.create_time DESC ORDER BY a.create_time DESC
limit 1 limit 1
</select> </select>
<select id="findRSvcClientInfo" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sa.username,
sc.client_id,
sc.client_moniker,
sc.credential_code,
sc.short_name,
sc.company_name,
ifnull(sc.logo_url,"NONE") logo_url,
sc.industry,
industry
FROM
sys_accounts sa,
sys_clients sc
WHERE
sa.account_id = #{account_id}
AND sc.client_id = sa.client_id
AND sc.is_valid = 1
AND sa.is_valid = 1
</select>
</mapper> </mapper>

@ -1,11 +1,23 @@
package au.com.royalpay.payment.manage.valid; package au.com.royalpay.payment.manage.valid;
import au.com.royalpay.payment.manage.analysis.beans.ato.CharacterUtils; import au.com.royalpay.payment.manage.analysis.beans.ato.CharacterUtils;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.encryptalgorithm.SignUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.stuxuhai.jpinyin.PinyinException; import com.github.stuxuhai.jpinyin.PinyinException;
import com.github.stuxuhai.jpinyin.PinyinFormat; import org.apache.commons.net.util.Base64;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import org.junit.Test; import org.junit.Test;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
/** /**
* Create by yixian at 2018-09-06 8:57 * Create by yixian at 2018-09-06 8:57
*/ */
@ -16,4 +28,38 @@ public class JPinYinTest {
System.out.println(CharacterUtils.convertFullWidthToHalfWidth(CharacterUtils.convertToPinYin(test))); System.out.println(CharacterUtils.convertFullWidthToHalfWidth(CharacterUtils.convertToPinYin(test)));
} }
@Test
public void testRSA() throws NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException, InvalidKeySpecException {
String rsa1_pub = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlxNzoulC++qq9a37bvNe5hyoWhlybZxrOGXRunMK84zpTlCL1tDfiwVYuXipAH8z9U0GcU6noEeY1WqIDftK89zLiUtOEkIMZsIDkiuCbJip61ArhI/oRhb6DeyRk9oLo+5kO428ZOr/9NdVJUapMEqKSEvdMzDvnU5ruU7jBcUZpLkn108478OcNTptxAvy4+xaErij8BOuIooG6F2IfIRz9TfcYV7ycaD449lks64oeMZJok+Gr+NyD8YXJDQrVw5tP1LUwDjQHJanmShCrPboSXKF6+h2Puv8F8Iy+vXZdP3Y6X9VHJdjBn3nMaohIrbuK9YCjTOAue+lFPzK+wIDAQAB";
String rsa1_pri = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXE3Oi6UL76qr1rftu817mHKhaGXJtnGs4ZdG6cwrzjOlOUIvW0N+LBVi5eKkAfzP1TQZxTqegR5jVaogN+0rz3MuJS04SQgxmwgOSK4JsmKn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Y/KrTbJAA/399W0eTCX7fQJqrqdPZX4rOzUinERZ+PdU1TscEy2yPfwJV9nvghJ6yFKYbwp/enYAJ6SfrMxQDafKUFXJfVyJ1IxjwTXba1xUL2W7AoGAc6PzW66wEVYqvzfWzWr22tR0JS87b0h9eqyqHib5XATKmpKpJztMZvgj50fCGWxWcwW+QoEoxFZqRXWiFiS1Tax+UY7QDRF55JOOfZyl1+eerAQAq99sVg0QAom/9V4jZNfX3JZvIYI15opGSdI2hsRrtW7CBvYxsGz7mT3cLoE=";
RSvcMchBean aaa = new RSvcMchBean();
aaa.setMerchantNumber("taylor");
aaa.setIndustryName("其他服务行业");
aaa.setIndustryCode("331");
aaa.setCredentialCode("7dlXrdvhyuN73NDpZsGYftdIMuZms1Qc");
aaa.setLogo("https://file.royalpay.com.au/open/2017/07/24/1500898932409_7uFGyWIpk4IRTQyT3INk2Nk3KHedOG.png");
aaa.setPayHost("http://192.168.1.6:9008/");
aaa.setPartnerCode("PINE");
aaa.setMerchantName("TEST");
String pubKeyEncCredentialCode = SignUtils.encData(aaa.getCredentialCode(), rsa1_pub);
String aesKeyStr = Base64.encodeBase64String(AESCrypt.randomKey().getEncoded());
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(aesKeyStr));
String decCredentialCode = Base64.encodeBase64String(AESCrypt.encrypt(pubKeyEncCredentialCode.getBytes(StandardCharsets.UTF_8), key));
JSONObject result = (JSONObject) JSONObject.toJSON(aaa);
result.put("sign_type", "RSA2");
result.put("enc_data", decCredentialCode);
result.put("nonce_str", aesKeyStr);
result.put("timestamp", System.currentTimeMillis());
result.put("sign", SignUtils.buildSign(result.toJSONString(), rsa2_pri));
System.err.println(result);
String signa = result.getString("sign");
result.remove("sign");
SignUtils.checkStringSign(result.toJSONString(), signa, rsa2_pub);
String aesData = new String(AESCrypt.decrypt(Base64.decodeBase64(result.getString("enc_data")), key), StandardCharsets.UTF_8);
System.err.println(SignUtils.decData(aesData, rsa1_pri));
}
} }

Loading…
Cancel
Save