|
|
@ -16,6 +16,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
@ -80,27 +81,35 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public JSONObject applicationMerchant(JSONObject org, JSONObject registerInfo) {
|
|
|
|
public JSONObject applicationMerchant(JSONObject org, JSONObject registerInfo) {
|
|
|
|
ClientRegisterInfo registerBean = JSONObject.toJavaObject(registerInfo, ClientRegisterInfo.class);
|
|
|
|
ClientRegisterInfo registerBean = JSON.toJavaObject(registerInfo, ClientRegisterInfo.class);
|
|
|
|
registerBean.checkParamsInvalid();
|
|
|
|
registerBean.checkParamsInvalid();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject manager = managerMapper.findAvailableByLoginIdAndOrgId(registerBean.getApplyId(), org.getString("org_id"));
|
|
|
|
JSONObject manager = managerMapper.findAvailableByLoginIdAndOrgId(registerBean.getApplyId(), org.getString("org_id"));
|
|
|
|
if (manager == null) {
|
|
|
|
if (manager == null) {
|
|
|
|
throw new ParamInvalidException("applyId","applyId is invalid");
|
|
|
|
throw new ParamInvalidException("applyId", "applyId is invalid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean hasParentBoolean = StringUtils.isNotBlank(registerBean.getParentPartnerCode());
|
|
|
|
boolean hasParentBoolean = StringUtils.isNotBlank(registerBean.getParentPartnerCode());
|
|
|
|
int parentClientId = 0;
|
|
|
|
int parentClientId = 0;
|
|
|
|
if (hasParentBoolean) {
|
|
|
|
if (hasParentBoolean) {
|
|
|
|
JSONObject parentClient = clientMapper.findClientByMoniker(registerBean.getParentPartnerCode());
|
|
|
|
JSONObject parentClient = clientMapper.findClientByMoniker(registerBean.getParentPartnerCode());
|
|
|
|
if (parentClient == null) {
|
|
|
|
if (parentClient == null) {
|
|
|
|
throw new ParamInvalidException("parentPartnerCode","parentPartnerCode is invalid");
|
|
|
|
throw new ParamInvalidException("parentPartnerCode", "parentPartnerCode is invalid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parentClientId = parentClient.getIntValue("client_id");
|
|
|
|
parentClientId = parentClient.getIntValue("client_id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject client = registerBean.insertClientInfo(clientManager.initMerchantCode(), manager.getString("display_name"), hasParentBoolean, parentClientId);
|
|
|
|
JSONObject client = registerBean.insertClientInfo(clientManager.initMerchantCode(), manager.getString("display_name"), hasParentBoolean, parentClientId);
|
|
|
|
client.put("org_id", org.getString("org_id"));
|
|
|
|
client.put("org_id", org.getString("org_id"));
|
|
|
|
|
|
|
|
JSONObject defaultProfile = org.getJSONObject("default_client_profile");
|
|
|
|
|
|
|
|
if (defaultProfile != null) {
|
|
|
|
|
|
|
|
defaultProfile.forEach(client::putIfAbsent);
|
|
|
|
|
|
|
|
}
|
|
|
|
clientMapper.save(client);
|
|
|
|
clientMapper.save(client);
|
|
|
|
clientConfigMapper.save(registerBean.insertClientConfigInfo(client.getIntValue("client_id"), client.getString("client_moniker")));
|
|
|
|
JSONObject clientConfig = registerBean.insertClientConfigInfo(client.getIntValue("client_id"), client.getString("client_moniker"));
|
|
|
|
|
|
|
|
if (defaultProfile != null) {
|
|
|
|
|
|
|
|
defaultProfile.forEach(clientConfig::putIfAbsent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clientConfigMapper.save(clientConfig);
|
|
|
|
sysClientLegalPersonMapper.save(registerBean.insertClientLegalInfo(client.getIntValue("client_id")));
|
|
|
|
sysClientLegalPersonMapper.save(registerBean.insertClientLegalInfo(client.getIntValue("client_id")));
|
|
|
|
permissionPartnerManagerImpl.permissionClientModuleSave(client.getIntValue("client_id"), client.getString("client_moniker"));
|
|
|
|
permissionPartnerManagerImpl.permissionClientModuleSave(client.getIntValue("client_id"), client.getString("client_moniker"));
|
|
|
|
JSONObject clientBd = new JSONObject();
|
|
|
|
JSONObject clientBd = new JSONObject();
|
|
|
@ -168,7 +177,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.put("partner_status", clientStatus);
|
|
|
|
result.put("partner_status", clientStatus);
|
|
|
|
if ( approveResult == 1 || approveResult == 5) {
|
|
|
|
if (approveResult == 1 || approveResult == 5) {
|
|
|
|
result.put("approve_time", DateFormatUtils.format(client.getDate("approve_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
result.put("approve_time", DateFormatUtils.format(client.getDate("approve_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
if (approveResult == 5) {
|
|
|
|
if (approveResult == 5) {
|
|
|
|
result.put("refuse_description", client.getString("refuse_remark"));
|
|
|
|
result.put("refuse_description", client.getString("refuse_remark"));
|
|
|
@ -212,7 +221,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
|
|
|
|
log.put("updatetime", new Date());
|
|
|
|
log.put("updatetime", new Date());
|
|
|
|
gatewayClientApplyNotifyLogMapper.update(log);
|
|
|
|
gatewayClientApplyNotifyLogMapper.update(log);
|
|
|
|
logger.debug("商户状态[{}]异步通知[{}]推送完成:[{}]", clientMoniker, notifyUrl, result.getStatusCode());
|
|
|
|
logger.debug("商户状态[{}]异步通知[{}]推送完成:[{}]", clientMoniker, notifyUrl, result.getStatusCode());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
Throwable exp = result.getException();
|
|
|
|
Throwable exp = result.getException();
|
|
|
|
log.put("success", false);
|
|
|
|
log.put("success", false);
|
|
|
|
log.put("http_code", result.getStatusCode());
|
|
|
|
log.put("http_code", result.getStatusCode());
|
|
|
@ -225,7 +234,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject preInsertServerNotifyLog(JSONObject client,String notifyUrl) {
|
|
|
|
private JSONObject preInsertServerNotifyLog(JSONObject client, String notifyUrl) {
|
|
|
|
int clientId = client.getIntValue("client_id");
|
|
|
|
int clientId = client.getIntValue("client_id");
|
|
|
|
JSONObject log = gatewayClientApplyNotifyLogMapper.findHistoryByClientId(clientId);
|
|
|
|
JSONObject log = gatewayClientApplyNotifyLogMapper.findHistoryByClientId(clientId);
|
|
|
|
if (log == null) {
|
|
|
|
if (log == null) {
|
|
|
|