|
|
|
@ -32,6 +32,8 @@ import au.com.royalpay.payment.core.beans.MerchantApplicationResult;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.EmailException;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
|
import au.com.royalpay.payment.core.impls.MerchantChannelApplicationManager;
|
|
|
|
|
import au.com.royalpay.payment.core.mappers.MchChannelContractDAO;
|
|
|
|
|
import au.com.royalpay.payment.core.mappers.MchChannelContractMapper;
|
|
|
|
|
import au.com.royalpay.payment.core.mappers.SysClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
|
|
|
@ -87,6 +89,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException;
|
|
|
|
|
import au.com.royalpay.payment.tools.defines.IncrementalChannel;
|
|
|
|
|
import au.com.royalpay.payment.tools.defines.PayChannel;
|
|
|
|
|
import au.com.royalpay.payment.tools.defines.TradeType;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
@ -331,7 +334,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
private ApsNoticeClientMapper apsNoticeClientMapper;
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd MMM yyyy");
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MchChannelContractMapper mchChannelContractMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SmsSender smsSender;
|
|
|
|
@ -555,6 +559,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
client.put("enable_alipayplus", true);
|
|
|
|
|
}
|
|
|
|
|
client.put("enable_alipayaps", false);
|
|
|
|
|
Map<String, JSONObject> channelPermissions = new HashMap<>();
|
|
|
|
|
for (PaymentChannelApi channelApi : paymentApi.channels()) {
|
|
|
|
|
try {
|
|
|
|
|
MchChannelContract contract = channelApi.initContractSource().
|
|
|
|
|
findMchContract(client.getIntValue("client_id"), TradeType.CLIENT_CODE, PlatformEnvironment.getEnv().getForeignCurrencyEnum().toCurrencyInfo());
|
|
|
|
|
JSONObject config = new JSONObject();
|
|
|
|
|
config.put("channel", channelApi.channel());
|
|
|
|
|
if (contract != null) {
|
|
|
|
|
config.put("enable", contract.isValid());
|
|
|
|
|
config.put("pid", contract.getPid());
|
|
|
|
|
config.put("mid", contract.getMid());
|
|
|
|
|
config.put("mcc", contract.getMccCode());
|
|
|
|
|
logger.info("=====>mid:"+config.getString("channel")+":"+config.getString("mid"));
|
|
|
|
|
} else {
|
|
|
|
|
config.put("enable", false);
|
|
|
|
|
//aps渠道的默认值展示
|
|
|
|
|
if(channelApi.channel()==PayChannel.ALIPAY_APS_CASHIER.getChannelCode()){
|
|
|
|
|
config.put("mid", PlatformEnvironment.getEnv().getApsOnlinePrefix()+client.getString("client_moniker"));
|
|
|
|
|
}else if(channelApi.channel()==PayChannel.ALIPAY_APS_IN_STORE.getChannelCode()){
|
|
|
|
|
config.put("mid", client.getString("client_moniker"));
|
|
|
|
|
}
|
|
|
|
|
logger.info("=====>mid2:"+config.getString("channel")+":"+config.getString("mid"));
|
|
|
|
|
}
|
|
|
|
|
channelPermissions.put(channelApi.channel().toLowerCase(), config);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.put("available_channels", channelPermissions);
|
|
|
|
|
MerchantChannelPermissionResolver resolverApsInStore = this.paymentApi.channelApi(PayChannel.ALIPAY_APS_IN_STORE.getChannelCode()).getChannelPermissionResolver();
|
|
|
|
|
MerchantChannelPermissionResolver resolverApsCashier = this.paymentApi.channelApi(PayChannel.ALIPAY_APS_CASHIER.getChannelCode()).getChannelPermissionResolver();
|
|
|
|
|
if (!Objects.isNull(resolverApsInStore) && !Objects.isNull(resolverApsCashier) &&
|
|
|
|
@ -7144,13 +7177,28 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
client.put("isRetail", isRetail);
|
|
|
|
|
String pid = "";
|
|
|
|
|
if (isRetail) {
|
|
|
|
|
//todo 测试需要 先都改成线上,上线此处需要改成线下
|
|
|
|
|
pid = AlipayEnvironment.getEnv().getAlipayPlusApsRetailConfig().getPid();
|
|
|
|
|
} else {
|
|
|
|
|
pid = AlipayEnvironment.getEnv().getAlipayPlusApsOnlineConfig().getPid();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
client.put("pid", pid);
|
|
|
|
|
List<MchChannelContractDAO> channelContractDAOS = mchChannelContractMapper.listByPidClientId(isRetail ? PayChannel.ALIPAY_APS_IN_STORE.getChannelCode() : PayChannel.ALIPAY_APS_CASHIER.getChannelCode(), pid, client.getInteger("client_id"));
|
|
|
|
|
MchChannelContractDAO mchChannelContractDAO = channelContractDAOS.stream().max(Comparator.comparing(MchChannelContractDAO::getCreateTime)).orElse(null);
|
|
|
|
|
String mid = client.getString("client_moniker");
|
|
|
|
|
//数据库有数据
|
|
|
|
|
if (mchChannelContractDAO != null && StringUtils.isNotEmpty(mchChannelContractDAO.getMid())) {
|
|
|
|
|
mid = mchChannelContractDAO.getMid();
|
|
|
|
|
} else {
|
|
|
|
|
mid = client.getString("client_moniker");
|
|
|
|
|
PayChannel channel = isRetail ? PayChannel.ALIPAY_APS_IN_STORE : PayChannel.ALIPAY_APS_CASHIER;
|
|
|
|
|
if (channel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
String apsOnlinePrefix = PlatformEnvironment.getEnv().getApsOnlinePrefix() != null ?
|
|
|
|
|
PlatformEnvironment.getEnv().getApsOnlinePrefix() : "00_";
|
|
|
|
|
mid = apsOnlinePrefix + mid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.put("mid", mid);
|
|
|
|
|
AlipayApsMerchantRegister alipayApsMerchantRegister = Optional.ofNullable(merchantChannelApplicationManager.getRegister(AlipayApsMerchantRegister.class)).orElseThrow(() -> new ServerErrorException("No AlipayAps registry found"));
|
|
|
|
|
AlipayPlusRegisterResult alipayPlusRegisterResult = alipayApsMerchantRegister.findMerchant(client);
|
|
|
|
|
return alipayPlusRegisterResult.getRawResponse();
|
|
|
|
|