alipay gms query hotfix

master
yixian 4 years ago
parent 0d1f68cafb
commit 1c66a85d7c

@ -327,7 +327,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource @Resource
private SysClientUpayProfileMapper sysClientUpayProfileMapper; private SysClientUpayProfileMapper sysClientUpayProfileMapper;
@Resource @Resource
private PaymentApi paymentApi; private PaymentApi paymentApi;
@Resource @Resource
private MerchantChannelPermissionManager merchantChannelPermissionManager; private MerchantChannelPermissionManager merchantChannelPermissionManager;
@ -551,7 +551,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
client.put("enable_alipayplus", false); client.put("enable_alipayplus", false);
MerchantChannelPermissionResolver resolver = this.paymentApi.channelApi(PayChannel.ALIPAY_PLUS.getChannelCode()).getChannelPermissionResolver(); MerchantChannelPermissionResolver resolver = this.paymentApi.channelApi(PayChannel.ALIPAY_PLUS.getChannelCode()).getChannelPermissionResolver();
if(!Objects.isNull(resolver)) { if (!Objects.isNull(resolver)) {
if (resolver.newOrderEnabled(client)) { if (resolver.newOrderEnabled(client)) {
client.put("enable_alipayplus", true); client.put("enable_alipayplus", true);
} }
@ -1581,7 +1581,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override @Override
public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) { public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) {
for (PaymentChannelApi channelApi : paymentApi.channels()) { for (PaymentChannelApi channelApi : paymentApi.channels()) {
if (channelApi.channel().equalsIgnoreCase(channel) ) { if (channelApi.channel().equalsIgnoreCase(channel)) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new NotFoundException("Client Not Exists"); throw new NotFoundException("Client Not Exists");
@ -1590,7 +1590,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
try { try {
clientModifySupport.processModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow)); clientModifySupport.processModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow));
} catch (Exception e) { } catch (Exception e) {
logger.error("Failed to change channel switch:{}" ,channel); logger.error("Failed to change channel switch:{}", channel);
} }
logger.info("{}({}) switched client {} channel {} to {}", manager.getString("display_name"), manager.getString("manager_id"), clientMoniker, channel, allow); logger.info("{}({}) switched client {} channel {} to {}", manager.getString("display_name"), manager.getString("manager_id"), clientMoniker, channel, allow);
if (allow && (StringUtils.equalsAnyIgnoreCase("Wechat", channel) || StringUtils.equalsAnyIgnoreCase("Alipay", channel))) { if (allow && (StringUtils.equalsAnyIgnoreCase("Wechat", channel) || StringUtils.equalsAnyIgnoreCase("Alipay", channel))) {
@ -2013,21 +2013,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate");
configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate");
configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate");
addAlipayPlusRateConfig(config,clientId,PayChannel.ALIPAY_PLUS.getChannelCode()); addAlipayPlusRateConfig(config, clientId, PayChannel.ALIPAY_PLUS.getChannelCode());
} }
private void addAlipayPlusRateConfig(JSONObject config,int clientId, String channel){ private void addAlipayPlusRateConfig(JSONObject config, int clientId, String channel) {
if (config.getString("alipay_cn_retail") != null){ if (config.getString("alipay_cn_retail") != null) {
config.put("pay_type","alipay_cn_retail"); config.put("pay_type", "alipay_cn_retail");
configNewClientRate(config, clientId, channel, "alipay_cn_retail", null, null); configNewClientRate(config, clientId, channel, "alipay_cn_retail", null, null);
} }
if (config.getString("alipay_cn_online")!= null){ if (config.getString("alipay_cn_online") != null) {
config.put("pay_type","alipay_cn_online"); config.put("pay_type", "alipay_cn_online");
configNewClientRate(config, clientId, channel, "alipay_cn_online", null,null); configNewClientRate(config, clientId, channel, "alipay_cn_online", null, null);
} }
if (config.getString("alipay_other")!= null){ if (config.getString("alipay_other") != null) {
config.put("pay_type","alipay_other"); config.put("pay_type", "alipay_other");
configNewClientRate(config, clientId, channel, "alipay_other", null,null); configNewClientRate(config, clientId, channel, "alipay_other", null, null);
} }
config.remove("pay_type"); config.remove("pay_type");
} }
@ -2039,7 +2039,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
newConfig.putAll(config); newConfig.putAll(config);
newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_value", config.getBigDecimal(rateKey));
newConfig.put("rate_name", channel); newConfig.put("rate_name", channel);
newConfig.put("pay_type",config.getString("pay_type")); newConfig.put("pay_type", config.getString("pay_type"));
if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), config.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), config.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) {
return; return;
} }
@ -2052,14 +2052,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
newConfig.put("ext_rates", extRateParams.toJSONString()); newConfig.put("ext_rates", extRateParams.toJSONString());
} else { } else {
List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel);
existRate.stream().filter(existConfig->{ existRate.stream().filter(existConfig -> {
if(existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time")) ){ if (existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time"))) {
return false; return false;
} }
return true; return true;
} }
) )
.forEach((rateLog)->{ .forEach((rateLog) -> {
rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1)); rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1));
clientRateMapper.updateConfig(rateLog); clientRateMapper.updateConfig(rateLog);
}); });
@ -5829,16 +5829,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
AlipayMerchantEntity alipayMch = merchantChannelApplicationManager.getRegister(AlipayRetailApi.class).findMerchant(client); try {
Element resultElement = alipayMch.getRawResponseXml(); AlipayMerchantEntity alipayMch = merchantChannelApplicationManager.getRegister(AlipayRetailApi.class).findMerchant(client);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { Element responseElement = alipayMch.getRawResponseXml();
return "查询成功:" + resultElement.elementText("error"); String rejectReason = responseElement.elementText("reject_reason");
return "查询成功:" + responseElement.elementText("secondary_merchant_id") +
"报备状态:" + responseElement.elementText("status") + StringUtils.defaultString(rejectReason, "");
}catch (BadRequestException e){
logger.error(e.getMessage(),e);
return e.getMessage();
} }
Element responseElement = resultElement.element("response").element("alipay");
String rejectReason = responseElement.elementText("reject_reason");
return "查询成功:" + responseElement.elementText("secondary_merchant_id") +
"报备状态:" + responseElement.elementText("status") + StringUtils.defaultString(rejectReason, "");
} }
@Override @Override
@ -5969,17 +5969,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); try {
AlipayMerchantEntity entity = merchantChannelApplicationManager.getRegister(AlipayOnlineApi.class) AlipayMerchantEntity entity = merchantChannelApplicationManager.getRegister(AlipayOnlineApi.class)
.findMerchant(client); .findMerchant(client);
Element resultElement = entity.getRawResponseXml(); Element responseElement = entity.getRawResponseXml();
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { String rejectReason = responseElement.elementText("reject_reason");
return "查询成功" + resultElement.elementText("error"); return "查询成功:" + responseElement.elementText("secondary_merchant_id") +
} "报备状态:" + responseElement.elementText("status") + StringUtils.defaultString(rejectReason, "");
Element responseElement = resultElement.element("response").element("alipay"); } catch (BadRequestException e) {
String rejectReason = responseElement.elementText("reject_reason"); logger.error(e.getMessage(), e);
return "查询成功:" + responseElement.elementText("secondary_merchant_id") + return e.getMessage();
"报备状态:" + responseElement.elementText("status") + StringUtils.defaultString(rejectReason, ""); }
} }
@Override @Override

Loading…
Cancel
Save