diff --git a/pom.xml b/pom.xml
index 625a36471..bf22c8244 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
4.0.0
manage
- 2.3.46
+ 2.3.47
UTF-8
2.4.0
diff --git a/src/main/java/au/com/royalpay/payment/manage/gateway/core/impls/GatewayMerchantApplyImpl.java b/src/main/java/au/com/royalpay/payment/manage/gateway/core/impls/GatewayMerchantApplyImpl.java
index 0711291d1..864cc38de 100644
--- a/src/main/java/au/com/royalpay/payment/manage/gateway/core/impls/GatewayMerchantApplyImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/gateway/core/impls/GatewayMerchantApplyImpl.java
@@ -9,6 +9,8 @@ import au.com.royalpay.payment.manage.mappers.log.GatewayClientApplyNotifyLogMap
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
+import au.com.royalpay.payment.manage.organizations.core.OrgClientProfileUtils;
import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
@@ -16,6 +18,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 +83,31 @@ 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"));
+ DefaultClientProfile defaultProfile = OrgClientProfileUtils.getOrgProfile(org);
+ defaultProfile.applyToClientConfig(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"));
+ defaultProfile.applyToClientConfig(clientConfig);
+ 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 +175,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 +219,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 +232,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) {
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientConfigMapper.java
index 10343d308..d365a6442 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientConfigMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientConfigMapper.java
@@ -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.
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java
index 07801df2f..3f7964685 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java
@@ -1,12 +1,13 @@
package au.com.royalpay.payment.manage.mappers.system;
+import au.com.royalpay.payment.manage.organizations.core.OrgClientProfileUtils;
+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 com.alibaba.fastjson.JSONObject;
-import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
-import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
@@ -17,7 +18,6 @@ import java.util.List;
*/
@AutoMapper(tablename = "sys_org", pkName = "org_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface OrgMapper {
- @AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "type != 1")
List listOrgsWithDetail(PageBounds order);
@@ -39,11 +39,9 @@ public interface OrgMapper {
@AutoSql(SqlType.UPDATE)
void updateOrg(JSONObject org);
- @AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1 AND parent_org_id is null")
List listAllOrgs();
- @AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1 AND senior_parent_org_id=0")
List listSeniorOrgs();
@@ -54,4 +52,7 @@ public interface OrgMapper {
List listOrgAndChild(@Param("org_id") int org_id);
List listSeniorOrgId(@Param("senior_parent_org_id") int senior_parent_org_id);
+
+ @AutoSql(SqlType.UPDATE)
+ void updateOrgClientProfile(@Param("org_id") int orgId, @Param(OrgClientProfileUtils.PROFILE_KEY) String clientDefaultProfile);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysClientLegalPersonMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysClientLegalPersonMapper.java
index 7a8bbc56c..235cdc202 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysClientLegalPersonMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysClientLegalPersonMapper.java
@@ -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")
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
index 1e57c312d..6e6f13c8b 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
@@ -50,6 +50,8 @@ import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.*;
import au.com.royalpay.payment.manage.merchants.enums.UPayAuthFileEnum;
import au.com.royalpay.payment.manage.notice.core.MailService;
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
+import au.com.royalpay.payment.manage.organizations.core.OrgClientProfileUtils;
import au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils;
import au.com.royalpay.payment.manage.rservices.core.RServicesApplyService;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
@@ -96,6 +98,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 +789,10 @@ 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");
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 +809,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (clientMapper.findClientByMoniker(registery.getClientMoniker()) != null) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
+ DefaultClientProfile profile = OrgClientProfileUtils.getOrgProfile(org);
+ profile.applyToClientConfig(partner);
clientMapper.save(partner);
try {
@@ -813,6 +821,7 @@ 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"));
+ profile.applyToClientConfig(clientConfig);
clientConfigService.save(clientConfig);
permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"), partner.getString("client_moniker"));
} catch (Exception e) {
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java
new file mode 100644
index 000000000..c37355222
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/DefaultClientProfile.java
@@ -0,0 +1,127 @@
+package au.com.royalpay.payment.manage.organizations.beans;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.PropertyNamingStrategy;
+import com.alibaba.fastjson.annotation.JSONType;
+import com.google.common.base.CaseFormat;
+import com.yixsoft.support.mybatis.utils.ClassFieldsDescription;
+import com.yixsoft.support.mybatis.utils.FieldDescription;
+import org.apache.commons.lang3.ObjectUtils;
+import org.hibernate.validator.constraints.Range;
+import org.springframework.core.annotation.AnnotatedElementUtils;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@JSONType(naming = PropertyNamingStrategy.SnakeCase)
+public class DefaultClientProfile {
+ @ProfileDesc(value = "周末延迟清算", detail = "周末交易延迟到周二清算")
+ private boolean weekendDelay = true;
+ @ProfileDesc("手续费包含GST")
+ private boolean taxInSurcharge = false;
+ @ProfileDesc("允许退款")
+ private boolean enableRefund = true;
+ @ProfileDesc(value = "每日清算截止时间", detail = "默认基于GMT+10的0点,有效范围0-24,时区为商户时区")
+ @Range(max = 24)
+ private Integer settleHour;
+ @ProfileDesc("自动获取消费者信息")
+ private boolean requireCustinfo = true;
+ @ProfileDesc(value = "交易备注必填", detail = "仅限于商户静态码")
+ private boolean requireRemark = false;
+
+ public List desc() {
+ return new ClassFieldsDescription<>(getClass()).getFields().stream()
+ .map(this::convertFieldInfo)
+ .collect(Collectors.toList());
+ }
+
+ private JSONObject convertFieldInfo(FieldDescription field) {
+ Object value = field.readField(this);
+ String fieldName = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(field.getFieldName());
+ JSONObject info = new JSONObject();
+ info.put("field", fieldName);
+ info.put("value", value);
+ Class> fieldType = field.getMethod().getReturnType();
+ if (fieldType.isPrimitive()) {
+ if (fieldType.equals(Boolean.class)) {
+ info.put("type", "checkbox");
+ } else {
+ info.put("type", "number");
+ }
+ } else {
+ info.put("type", "text");
+ }
+
+ ProfileDesc getterDesc = AnnotatedElementUtils.findMergedAnnotation(field.getMethod(), ProfileDesc.class);
+ try {
+ ProfileDesc fieldDesc = AnnotatedElementUtils.findMergedAnnotation(getClass().getDeclaredField(field.getFieldName()), ProfileDesc.class);
+ ProfileDesc desc = ObjectUtils.defaultIfNull(getterDesc, fieldDesc);
+ if (desc != null) {
+ info.put("title", desc.value());
+ info.put("detail", desc.detail());
+ }
+ } catch (NoSuchFieldException e) {
+ }
+ return info;
+ }
+
+ public void applyToClientConfig(JSONObject client) {
+ JSONObject profile = (JSONObject) JSON.toJSON(this);
+ profile.forEach(client::putIfAbsent);
+ }
+
+ public boolean isWeekendDelay() {
+ return weekendDelay;
+ }
+
+ public DefaultClientProfile setWeekendDelay(boolean weekendDelay) {
+ this.weekendDelay = weekendDelay;
+ return this;
+ }
+
+ public boolean isTaxInSurcharge() {
+ return taxInSurcharge;
+ }
+
+ public DefaultClientProfile setTaxInSurcharge(boolean taxInSurcharge) {
+ this.taxInSurcharge = taxInSurcharge;
+ return this;
+ }
+
+ public boolean isEnableRefund() {
+ return enableRefund;
+ }
+
+ public DefaultClientProfile setEnableRefund(boolean enableRefund) {
+ this.enableRefund = enableRefund;
+ return this;
+ }
+
+ public Integer getSettleHour() {
+ return settleHour;
+ }
+
+ public DefaultClientProfile setSettleHour(Integer settleHour) {
+ this.settleHour = settleHour;
+ return this;
+ }
+
+ public boolean isRequireCustinfo() {
+ return requireCustinfo;
+ }
+
+ public DefaultClientProfile setRequireCustinfo(boolean requireCustinfo) {
+ this.requireCustinfo = requireCustinfo;
+ return this;
+ }
+
+ public boolean isRequireRemark() {
+ return requireRemark;
+ }
+
+ public DefaultClientProfile setRequireRemark(boolean requireRemark) {
+ this.requireRemark = requireRemark;
+ return this;
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/ProfileDesc.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/ProfileDesc.java
new file mode 100644
index 000000000..ceef5b485
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/ProfileDesc.java
@@ -0,0 +1,17 @@
+package au.com.royalpay.payment.manage.organizations.beans;
+
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Document
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.METHOD})
+public @interface ProfileDesc {
+ String value();
+
+ String detail() default "";
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgClientProfileUtils.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgClientProfileUtils.java
new file mode 100644
index 000000000..a52928e2f
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgClientProfileUtils.java
@@ -0,0 +1,30 @@
+package au.com.royalpay.payment.manage.organizations.core;
+
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONException;
+import com.alibaba.fastjson.JSONObject;
+
+public final class OrgClientProfileUtils {
+ public static final String PROFILE_KEY = "default_client_profile";
+
+ private OrgClientProfileUtils() {
+ }
+
+ public static DefaultClientProfile getOrgProfile(JSONObject org) {
+ String profile = org.getString(PROFILE_KEY);
+ if (profile == null) {
+ return new DefaultClientProfile();
+ }
+ try {
+ return JSON.parseObject(profile).toJavaObject(DefaultClientProfile.class);
+ } catch (JSONException e) {
+ return new DefaultClientProfile();
+ }
+ }
+
+ public static void applyOrgClientDefaultProfile(JSONObject org, JSONObject client) {
+ DefaultClientProfile profile = getOrgProfile(org);
+ profile.applyToClientConfig(client);
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java
index 805173cb2..8497b7857 100644
--- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java
@@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.organizations.core;
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
import au.com.royalpay.payment.manage.organizations.beans.OrgInfo;
import com.alibaba.fastjson.JSONObject;
@@ -46,4 +47,6 @@ public interface OrgManager {
JSONObject checkOrg(JSONObject manager, JSONObject params);
JSONObject checkOrgIds(JSONObject manager, JSONObject params);
+
+ void updateDefaultClientProfile(int orgId, JSONObject manager, DefaultClientProfile profile);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java
index 42a2cf925..4f4beea92 100644
--- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java
@@ -3,11 +3,13 @@ package au.com.royalpay.payment.manage.organizations.core.impls;
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgSignInfoMapper;
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
import au.com.royalpay.payment.manage.organizations.beans.OrgInfo;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.tools.codec.RSACrypt;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
@@ -91,8 +93,8 @@ public class OrgManagerImpl implements OrgManager {
children.add(child);
}
}
- if(children.size()> 0){
- org.put("children",children);
+ if (!children.isEmpty()) {
+ org.put("children", children);
}
}
return listOrgs;
@@ -312,24 +314,31 @@ public class OrgManagerImpl implements OrgManager {
if (manager.getInteger("org_id")!=null){
List orgs = orgMapper.listOrgAndChild(manager.getIntValue("org_id"));
List orgIds = orgs.stream().map(org->org.getIntValue("org_id")).collect(Collectors.toList());
- if (!orgIds.contains(params.getString("org_id2"))){
+ if (!orgIds.contains(params.getString("org_id2"))) {
throw new ForbiddenException("You have no permission to query the org");
}
}
- params.put("org_id",params.getString("org_id2"));
+ params.put("org_id", params.getString("org_id2"));
params.remove("org_id2");
}
}
return params;
}
- private void orgIds(JSONObject params,JSONObject manager){
+
+ @Override
+ public void updateDefaultClientProfile(int orgId, JSONObject manager, DefaultClientProfile profile) {
+ getOrgDetail(orgId, manager);
+ orgMapper.updateOrgClientProfile(orgId, JSON.toJSONString(profile));
+ }
+
+ private void orgIds(JSONObject params, JSONObject manager) {
List orgs = orgMapper.listOrgAndChild(Integer.parseInt(params.getString("org_id")));
- if (orgs.size()>1){
- List orgIds = orgs.stream().map(org->org.getIntValue("org_id")).collect(Collectors.toList());
- params.put("org_ids",orgIds);
+ if (orgs.size() > 1) {
+ List orgIds = orgs.stream().map(org -> org.getIntValue("org_id")).collect(Collectors.toList());
+ params.put("org_ids", orgIds);
params.remove("org_id");
- }else {
- params.put("org_id",params.getString("org_id"));
+ } else {
+ params.put("org_id", params.getString("org_id"));
}
}
private void checkOrgRate(JSONObject json){
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java
index 9dd4aff73..4abd0da3d 100644
--- a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java
@@ -1,6 +1,8 @@
package au.com.royalpay.payment.manage.organizations.web;
+import au.com.royalpay.payment.manage.organizations.beans.DefaultClientProfile;
import au.com.royalpay.payment.manage.organizations.beans.OrgInfo;
+import au.com.royalpay.payment.manage.organizations.core.OrgClientProfileUtils;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
@@ -38,20 +40,20 @@ public class OrgManageController {
@GetMapping(value = "/orgChild")
@RequireManager
- public List listOrgsWithChid(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,OrgInfo orgInfo) {
- return orgManager.listOrgsWithChid(manager,orgInfo);
+ public List listOrgsWithChid(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, OrgInfo orgInfo) {
+ return orgManager.listOrgsWithChid(manager, orgInfo);
}
@GetMapping(value = "/child")
@RequireManager
- public List listOrgAndChild(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,OrgInfo orgInfo) {
+ public List listOrgAndChild(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, OrgInfo orgInfo) {
return orgManager.listOrgAndChild(manager);
}
@GetMapping("/listsOrg")
@RequireManager
- public JSONObject listsOrg(OrgInfo orgInfo,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
- return orgManager.listAllOrgs(orgInfo,manager);
+ public JSONObject listsOrg(OrgInfo orgInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
+ return orgManager.listAllOrgs(orgInfo, manager);
}
@GetMapping("/list_all_Org")
@@ -67,8 +69,10 @@ public class OrgManageController {
}
@ManagerMapping(value = "/{orgId}", method = RequestMethod.GET, role = {ManagerRole.ADMIN})
- public JSONObject getOrgDetail(@PathVariable int orgId,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
- return orgManager.getOrgDetail(orgId,manager);
+ public JSONObject getOrgDetail(@PathVariable int orgId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
+ JSONObject org = orgManager.getOrgDetail(orgId, manager);
+ org.remove(OrgClientProfileUtils.PROFILE_KEY);
+ return org;
}
@ManagerMapping(value = "/{orgId}", method = RequestMethod.PUT)
@@ -77,6 +81,18 @@ public class OrgManageController {
orgManager.updateOrg(orgId, org, manager);
}
+ @ManagerMapping(value = "/{orgId}/default_client_profile", method = RequestMethod.GET, role = ManagerRole.ADMIN)
+ public List getOrgDefaultClientProfile(@PathVariable int orgId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
+ JSONObject org = orgManager.getOrgDetail(orgId, manager);
+ return OrgClientProfileUtils.getOrgProfile(org).desc();
+ }
+
+ @ManagerMapping(value = "/{orgId}/default_client_profile", method = RequestMethod.PUT, role = ManagerRole.ADMIN)
+ public void updateOrgProfile(@PathVariable int orgId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody @Valid DefaultClientProfile profile, Errors errors) {
+ HttpUtils.handleValidErrors(errors);
+ orgManager.updateDefaultClientProfile(orgId, manager, profile);
+ }
+
@ManagerMapping(value = "/{orgId}/partner_public_key", method = RequestMethod.PUT)
public void setPartnerPublicKeyConfig(@PathVariable int orgId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody JSONObject config) {
orgManager.setPartnerPublicKeyConfig(orgId, manager, config.getString("partner_public_key"));
@@ -87,14 +103,14 @@ public class OrgManageController {
orgManager.refreshPlatformPublicKeyConfig(orgId, manager);
}
- @ManagerMapping(value = "/{orgId}/enable_change_rate",method = RequestMethod.PUT,role = {ManagerRole.ADMIN})
- public void switchEnableChangeRate(@PathVariable int orgId, @RequestBody JSONObject enable){
+ @ManagerMapping(value = "/{orgId}/enable_change_rate", method = RequestMethod.PUT, role = {ManagerRole.ADMIN})
+ public void switchEnableChangeRate(@PathVariable int orgId, @RequestBody JSONObject enable) {
boolean enabled = enable.getBooleanValue("enabled");
- orgManager.switchPermission(orgId,"rate_editable",enabled);
+ orgManager.switchPermission(orgId, "rate_editable", enabled);
}
- @ManagerMapping(value = "/referrer",method = RequestMethod.GET)
- public List getReferrers(){
+ @ManagerMapping(value = "/referrer", method = RequestMethod.GET)
+ public List getReferrers() {
return orgManager.getReferrers();
}
@@ -102,7 +118,7 @@ public class OrgManageController {
public JSONObject getCityPartnerPrizeInfoAllList(@PathVariable int orgId,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "20") int limit, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
- return orgManager.getCityPartnerPrizeInfoList(page, limit,orgId,manager);
+ return orgManager.getCityPartnerPrizeInfoList(page, limit, orgId, manager);
}
@RequestMapping(value = "/{orgId}/init/merchant_code", method = RequestMethod.GET, produces = "application/json")
diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml
index 549243bbf..1e2309ba1 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml
@@ -139,7 +139,8 @@
INSERT sys_client_rates (manager_id, client_id, rate_name, rate_value, transaction_fee, active_time, expiry_time, create_time, update_time, manager_name, clean_days, remark)
- SELECT CONCAT('System-', CURRENT_DATE()),r.client_id,r.rate_name,r.rate_value,r.transaction_fee,DATE_ADD(r.expiry_time, INTERVAL 1 day),DATE_ADD(r.expiry_time, INTERVAL 1 year),NOW(), NOW(),
+ SELECT CONCAT('System-', CURRENT_DATE()),r.client_id,r.rate_name,r.rate_value,r.transaction_fee,DATE_ADD(r.expiry_time, INTERVAL 1 day),
+ IF(DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )<=NOW(),DATE_ADD( r.expiry_time, INTERVAL 2 YEAR ),DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )) expiry_time,NOW(), NOW(),
CONCAT('System-', CURRENT_DATE()),r.clean_days,'费率自动延期一年'
FROM (select rr.* from sys_client_rates rr
WHERE rr.client_id = #{clientId}
diff --git a/src/main/ui/static/commons/commons.js b/src/main/ui/static/commons/commons.js
index 51e7b3204..b9982e82b 100644
--- a/src/main/ui/static/commons/commons.js
+++ b/src/main/ui/static/commons/commons.js
@@ -26,6 +26,7 @@ define(['./app',
'./directives/royalCalendar',
'./directives/multiLevelSelect',
'./directives/jsonview',
+ './directives/ngInputName',
'./filters/propsFilter',
'./filters/inverseColor',
'./filters/limitToWithEllipsis',
diff --git a/src/main/ui/static/commons/directives/ngInputName.js b/src/main/ui/static/commons/directives/ngInputName.js
new file mode 100644
index 000000000..8318fb2aa
--- /dev/null
+++ b/src/main/ui/static/commons/directives/ngInputName.js
@@ -0,0 +1,55 @@
+define(['../app', 'angular'], function (app, angular) {
+ 'use strict';
+ app.directive('ngInputName', function () {
+ let myNameError = "myName directive error: "
+
+ return {
+ restrict: 'A', // Declares an Attributes Directive.
+ require: 'ngModel', // ngModelController.
+
+ link: function (scope, elem, attrs, ngModel) {
+ if (!ngModel) {
+ return
+ } // no ngModel exists for this element
+
+ // check myName input for proper formatting ex. something/something
+ checkInputFormat(attrs);
+
+ let inputName = attrs.myName.match('^\\w+').pop(); // match upto '/'
+ assignInputNameToInputModel(inputName, ngModel);
+
+ let formName = attrs.myName.match('\\w+$').pop(); // match after '/'
+ findForm(formName, ngModel, scope);
+ } // end link
+ } // end return
+
+ function checkInputFormat(attrs) {
+ if (!/\w\/\w/.test(attrs.rsName)) {
+ throw myNameError + "Formatting should be \"inputName/formName\" but is " + attrs.rsName
+ }
+ }
+
+ function assignInputNameToInputModel(inputName, ngModel) {
+ ngModel.$name = inputName
+ }
+
+ function addInputNameToForm(formName, ngModel, scope) {
+ scope[formName][ngModel.$name] = ngModel;
+ return
+ }
+
+ function findForm(formName, ngModel, scope) {
+ if (!scope) { // ran out of scope before finding scope[formName]
+ throw myNameError + "