org default client profile setters

master
yixian 4 years ago
parent a05d93d48d
commit fb8908a026

@ -16,6 +16,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.apache.commons.codec.binary.Base64;
@ -80,27 +81,35 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
@Override
@Transactional
public JSONObject applicationMerchant(JSONObject org, JSONObject registerInfo) {
ClientRegisterInfo registerBean = JSONObject.toJavaObject(registerInfo, ClientRegisterInfo.class);
ClientRegisterInfo registerBean = JSON.toJavaObject(registerInfo, ClientRegisterInfo.class);
registerBean.checkParamsInvalid();
JSONObject result = new JSONObject();
JSONObject manager = managerMapper.findAvailableByLoginIdAndOrgId(registerBean.getApplyId(), org.getString("org_id"));
if (manager == null) {
throw new ParamInvalidException("applyId","applyId is invalid");
throw new ParamInvalidException("applyId", "applyId is invalid");
}
boolean hasParentBoolean = StringUtils.isNotBlank(registerBean.getParentPartnerCode());
int parentClientId = 0;
if (hasParentBoolean) {
JSONObject parentClient = clientMapper.findClientByMoniker(registerBean.getParentPartnerCode());
if (parentClient == null) {
throw new ParamInvalidException("parentPartnerCode","parentPartnerCode is invalid");
throw new ParamInvalidException("parentPartnerCode", "parentPartnerCode is invalid");
}
parentClientId = parentClient.getIntValue("client_id");
}
try {
JSONObject client = registerBean.insertClientInfo(clientManager.initMerchantCode(), manager.getString("display_name"), hasParentBoolean, parentClientId);
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);
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")));
permissionPartnerManagerImpl.permissionClientModuleSave(client.getIntValue("client_id"), client.getString("client_moniker"));
JSONObject clientBd = new JSONObject();
@ -168,7 +177,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
break;
}
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"));
if (approveResult == 5) {
result.put("refuse_description", client.getString("refuse_remark"));
@ -212,7 +221,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
log.put("updatetime", new Date());
gatewayClientApplyNotifyLogMapper.update(log);
logger.debug("商户状态[{}]异步通知[{}]推送完成:[{}]", clientMoniker, notifyUrl, result.getStatusCode());
}else {
} else {
Throwable exp = result.getException();
log.put("success", false);
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");
JSONObject log = gatewayClientApplyNotifyLogMapper.findHistoryByClientId(clientId);
if (log == null) {

@ -1,18 +1,10 @@
package au.com.royalpay.payment.manage.mappers.system;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yixsoft.support.mybatis.autosql.annotations.AdvanceSelect;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.annotations.Param;
/**
* Created by wangning on 2018-04-08.

@ -1,10 +1,9 @@
package au.com.royalpay.payment.manage.mappers.system;
import com.yixsoft.support.mybatis.autosql.annotations.AdvanceSelect;
import com.alibaba.fastjson.JSONObject;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
@AutoMapper(tablename = "sys_client_legal_person", pkName = "client_id")

@ -96,6 +96,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import io.jsonwebtoken.lang.Assert;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
@ -786,7 +787,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
partner.put("ali_sub_merchant_id", registery.getClientMoniker());
partner.put("credential_code", RandomStringUtils.random(32, true, true));
partner.put("creator", manager.getString("manager_id"));
partner.put("org_id", manager.getIntValue("org_id"));
int orgId = manager.getIntValue("org_id");
partner.put("org_id", orgId);
JSONObject org = orgMapper.findOne(orgId);
Assert.notNull(orgId, "Merchant Org shall not be null");
JSONObject orgDefaultClientProfile = org.getJSONObject("default_client_profile");
if (StringUtils.isNotEmpty(registery.getLogoId())) {
partner.put("logo_url", attachmentClient.getFileUrl(registery.getLogoId()));
partner.put("logo_thumbnail", attachmentClient.getThumbnail(registery.getLogoId(), 600).getString("url"));
@ -803,6 +808,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (clientMapper.findClientByMoniker(registery.getClientMoniker()) != null) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
if (orgDefaultClientProfile != null) {
orgDefaultClientProfile.forEach(partner::putIfAbsent);
}
clientMapper.save(partner);
try {
@ -813,6 +821,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientConfig.put("client_pay_desc", partner.get("client_pay_desc"));
clientConfig.put("enable_cross_payment", partner.get("enable_cross_payment"));
clientConfig.put("enable_card_payment", partner.get("enable_card_payment"));
if (orgDefaultClientProfile != null) {
orgDefaultClientProfile.forEach(clientConfig::putIfAbsent);
}
clientConfigService.save(clientConfig);
permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"), partner.getString("client_moniker"));
} catch (Exception e) {

Loading…
Cancel
Save