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 + "
element named " + formName + " could not be found." + } + + if (formName in scope) { // found scope[formName] + addInputNameToForm(formName, ngModel, scope) + return + } + findForm(formName, ngModel, scope.$parent) // recursively search through $parent scopes + } + }) + + +}); \ No newline at end of file diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js index 82e390eb4..bfdd4a5d3 100644 --- a/src/main/ui/static/config/organizations/organizations.js +++ b/src/main/ui/static/config/organizations/organizations.js @@ -49,17 +49,17 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { controller: 'newOrgCtrl' }) }]); - app.controller('orgsCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog ) { + app.controller('orgsCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { $scope.params = {}; - if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) { + if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) { $scope.params.org_id = $scope.currentUser.org_id; } $scope.pagination = {}; $scope.types = angular.copy(types); $scope.listOrgs = function (page) { - var params = angular.copy( $scope.params); + var params = angular.copy($scope.params); params.page = page || $scope.pagination.page || 1; - $http.get('/sys/orgs/listsOrg',{params:params}).then(function (resp) { + $http.get('/sys/orgs/listsOrg', {params: params}).then(function (resp) { $scope.orgs_detail = resp.data.data; $scope.pagination = resp.data.pagination; }) @@ -71,7 +71,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); } $scope.disableOrg = function (org) { - $scope.org =angular.copy(org); + $scope.org = angular.copy(org); $scope.org.is_valid = 0; commonDialog.confirm({ title: 'Confirm!', @@ -86,7 +86,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }; $scope.listOrgs(1); }]); - app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$filter','$uibModal','commonDialog','chartParser', 'org','stateMap', function ($scope, $http, $state, Upload,$filter,$uibModal,commonDialog, chartParser,org,stateMap) { + app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$filter', '$uibModal', 'commonDialog', 'chartParser', 'org', 'stateMap', function ($scope, $http, $state, Upload, $filter, $uibModal, commonDialog, chartParser, org, stateMap) { $scope.analysis = {}; $scope.today = new Date(); $scope.chooseToday = function () { @@ -130,6 +130,24 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.params.begin = currentYearFirstDate; $scope.loadTransactionAmountInOrg(); }; + $scope.loadClientProfile = function () { + $http.get('/sys/orgs/' + $scope.org.org_id + '/default_client_profile').then(function (res) { + $scope.clientProfileFields = res.data; + }) + }; + $scope.loadClientProfile(); + $scope.submitClientProfile = function () { + let profile = {}; + for (let field of $scope.clientProfileFields) { + profile[field.field] = field.value; + } + $http.put('/sys/orgs/' + $scope.org.org_id + '/default_client_profile').then(function () { + commonDialog.alert({type: 'success', title: 'Success', content: 'Modify Success'}); + $scope.loadClientProfile(); + }, function (res) { + commonDialog.alert({type: 'error', title: 'Error', content: res.data.message}); + }) + }; $scope.scales = [ { key: 'today', @@ -186,8 +204,8 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { params: function () { var date = new Date(); date = date.setDate(1); - var oneDay=1000*60*60*24; - var end = $filter('date')(date-oneDay, 'yyyyMMdd'); + var oneDay = 1000 * 60 * 60 * 24; + var end = $filter('date')(date - oneDay, 'yyyyMMdd'); var date2 = new Date(); date2.setDate(1); @@ -211,8 +229,8 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadSeniorOrg = function () { $http.get('/sys/orgs/senior').then(function (resp) { $scope.seniorOrgs = resp.data; - var senior = {org_id:0,name:'I\'m Senior'} - var noop = {org_id:-1,name:'noop'} + var senior = {org_id: 0, name: 'I\'m Senior'} + var noop = {org_id: -1, name: 'noop'} $scope.seniorOrgs.unshift(noop); $scope.seniorOrgs.unshift(senior); }) @@ -249,13 +267,14 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { for (var i = 0; i < resp.data.length; i++) { $scope.legends[i] = resp.data[i].org_name; } - if($scope.orgAmounts.length >= 1){ + if ($scope.orgAmounts.length >= 1) { $scope.chooseOrg = resp.data[0].org_name; loadPartnersByOrgId(resp.data[0].org_id); } $scope.future_loading = false; }); }; + function loadPartnersByOrgId(org_id) { var params = angular.copy($scope.params); if (params.begin) { @@ -268,7 +287,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { } else { params.end = $filter('date')(new Date(), 'yyyyMMdd'); } - $http.get('/analysis/org/'+org_id+'/partners', {params: params}).then(function (resp) { + $http.get('/analysis/org/' + org_id + '/partners', {params: params}).then(function (resp) { $scope.salespartners = resp.data; $scope.partnerSales1 = []; $scope.partnerSales2 = []; @@ -298,6 +317,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }; $scope.chooseLast7Days(); + //$scope.loadTransactionAmountInOrg(); function loadFeeAnalysis(params) { @@ -426,7 +446,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { var params = {}; params.page = $scope.paginationc.page || 1; params.org_id = $scope.org.org_id; - $http.get('/sys/orgs/'+$scope.org.org_id + '/extract/search', {params: params}).then(function (resp) { + $http.get('/sys/orgs/' + $scope.org.org_id + '/extract/search', {params: params}).then(function (resp) { $scope.client_extarct = resp.data.data; $scope.paginationc = resp.data.pagination; @@ -436,8 +456,6 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.loadCommission(); - - $scope.uploadLogo = function (file) { if (file == null) { return; @@ -469,7 +487,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } - if($scope.org.type == 1){ + if ($scope.org.type == 1) { $scope.org.commission_type = 2; } $http.put('/sys/orgs/' + $scope.org.org_id, $scope.org).then(function () { @@ -481,23 +499,23 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }; $scope.toggleRateEditable = function () { - if($scope.org.rate_editable==org.data.rate_editable){ + if ($scope.org.rate_editable == org.data.rate_editable) { return; } - $http.put('/sys/orgs/'+$scope.org.org_id+'/enable_change_rate',{enabled:$scope.org.rate_editable}).then(function () { + $http.put('/sys/orgs/' + $scope.org.org_id + '/enable_change_rate', {enabled: $scope.org.rate_editable}).then(function () { - },function (resp) { + }, function (resp) { commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); }) }; - $scope.params = {role:'1111111',org_id:$scope.org.org_id}; + $scope.params = {role: '1111111', org_id: $scope.org.org_id}; $scope.paginationa = {}; $scope.listManagers = function (page) { var params = angular.copy($scope.params); params.page = page || $scope.paginationa.page || 1; - $http.get('/sys/manager_accounts',{params:params}).then(function (resp) { + $http.get('/sys/manager_accounts', {params: params}).then(function (resp) { $scope.managers = resp.data.data; $scope.paginationa = resp.data.pagination; }) @@ -593,7 +611,11 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { content: 'This operation will refresh the gateway short id, Are you sure?' }).then(function () { $http.get('/sys/orgs/' + $scope.org.org_id + '/init/merchant_code').then(function (response) { - commonDialog.alert({title: 'Success', content: "Gateway Short Id Refresh Successfully", type: 'success'}) + commonDialog.alert({ + title: 'Success', + content: "Gateway Short Id Refresh Successfully", + type: 'success' + }) $scope.org.gateway_short_id = response.data.partner_code; }, function (resp) { commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) @@ -601,7 +623,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) }; }]); - app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org','stateMap', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org,stateMap) { + app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal', 'commonDialog', 'org', 'stateMap', function ($scope, $http, $state, Upload, $uibModal, commonDialog, org, stateMap) { $scope.merchantCodeChecked = true; $scope.merchantIsValid = true; $scope.types = angular.copy(types); @@ -658,7 +680,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { var params = {}; params.page = $scope.paginationc.page || 1; params.org_id = $scope.org.org_id; - $http.get('/sys/orgs/'+$scope.org.org_id + '/extract/search', {params: params}).then(function (resp) { + $http.get('/sys/orgs/' + $scope.org.org_id + '/extract/search', {params: params}).then(function (resp) { $scope.client_extarct = resp.data.data; $scope.paginationc = resp.data.pagination; @@ -713,7 +735,11 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { content: 'This operation will refresh the gateway short id, Are you sure?' }).then(function () { $http.get('/sys/orgs/' + $scope.org.org_id + '/init/merchant_code').then(function (response) { - commonDialog.alert({title: 'Success', content: "Gateway Short Id Refresh Successfully", type: 'success'}) + commonDialog.alert({ + title: 'Success', + content: "Gateway Short Id Refresh Successfully", + type: 'success' + }) $scope.org.gateway_short_id = response.data.partner_code; }, function (resp) { commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) @@ -753,14 +779,14 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) } }]); - app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog','stateMap', function ($scope, $http, $state, Upload, commonDialog,stateMap) { + app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', 'stateMap', function ($scope, $http, $state, Upload, commonDialog, stateMap) { $scope.types = angular.copy(types); $scope.commission_types = angular.copy(commission_types); $scope.loadSeniorOrg = function () { $http.get('/sys/orgs/senior').then(function (resp) { $scope.seniorOrgs = resp.data; - var senior = {org_id:0,name:'I\'m Senior'} - var noop = {org_id:-1,name:'noop'} + var senior = {org_id: 0, name: 'I\'m Senior'} + var noop = {org_id: -1, name: 'noop'} $scope.seniorOrgs.unshift(noop); $scope.seniorOrgs.unshift(senior); }) @@ -799,10 +825,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } - if($scope.org.type == 1){ + if ($scope.org.type == 1) { $scope.org.commission_type = 2; } - if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) { + if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) { $scope.org.parent_org_id = angular.copy($scope.currentUser.org.org_id); $scope.org.type = '0'; } @@ -812,8 +838,8 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { content: 'Creation of new organization succeeded', type: 'success' }); - $state.go('organizations.detail',{orgId:resp.data.org_id},{reload:true}); - },function (resp) { + $state.go('organizations.detail', {orgId: resp.data.org_id}, {reload: true}); + }, function (resp) { commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); }) }; @@ -822,29 +848,29 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { $scope.manager = manager; $scope.isOrgModify = true; $scope.params = {}; - /* $scope.loadOrgs = function () { - $http.get('/sys/orgs').then(function (resp) { - $scope.orgs = resp.data; - }) - }; - $scope.loadOrgs(); + /* $scope.loadOrgs = function () { + $http.get('/sys/orgs').then(function (resp) { + $scope.orgs = resp.data; + }) + }; + $scope.loadOrgs(); - $scope.loadOrgsChild= function (org_id) { - $scope.choose_org = org_id; - var params = angular.copy($scope.params); - params.org_id = org_id; - $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { - $scope.orgs_child = resp.data; - }) - }; - if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ - $scope.loadOrgsChild($scope.currentUser.org_id); - } - if($scope.manager.parent_org_id){ - $scope.manager.org_id2 = $scope.manager.org_id; - $scope.manager.org_id = $scope.manager.parent_org_id; - $scope.loadOrgsChild($scope.manager.org_id); - };*/ + $scope.loadOrgsChild= function (org_id) { + $scope.choose_org = org_id; + var params = angular.copy($scope.params); + params.org_id = org_id; + $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { + $scope.orgs_child = resp.data; + }) + }; + if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + $scope.loadOrgsChild($scope.currentUser.org_id); + } + if($scope.manager.parent_org_id){ + $scope.manager.org_id2 = $scope.manager.org_id; + $scope.manager.org_id = $scope.manager.parent_org_id; + $scope.loadOrgsChild($scope.manager.org_id); + };*/ $scope.modify = function () { /*if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ if($scope.manager.org_id2 != "null") { @@ -852,9 +878,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { } delete $scope.manager.org_id2; }*/ - /* if($scope.manager.org_id2 != null && $scope.manager.org_id2 != 'null') { - $scope.manager.org_id = $scope.manager.org_id2; - }*/ + /* if($scope.manager.org_id2 != null && $scope.manager.org_id2 != 'null') { + $scope.manager.org_id = $scope.manager.org_id2; + }*/ $scope.errmsg = null; $http.put('/sys/manager_accounts/' + manager.manager_id, $scope.manager).then(function () { $scope.$close(); @@ -869,7 +895,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }; $scope.loadOrgs(); }]); - app.controller('newManagerCtrl', ['$scope', '$http','org',function ($scope, $http,org) { + app.controller('newManagerCtrl', ['$scope', '$http', 'org', function ($scope, $http, org) { $scope.isOrg = true; $scope.org = angular.copy(org); $scope.save = function (form) { @@ -883,12 +909,12 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } - if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ + if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) { $scope.manager.bd = true; - /* if($scope.manager.org_id2 != "null") { - $scope.manager.org_id = $scope.manager.org_id2; - } - delete $scope.manager.org_id2;*/ + /* if($scope.manager.org_id2 != "null") { + $scope.manager.org_id = $scope.manager.org_id2; + } + delete $scope.manager.org_id2;*/ } $http.post('/sys/manager_accounts', $scope.manager).then(function () { @@ -905,7 +931,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { return arr; } return arr.filter(function (item) { - return (filterObj.username==null || item.username.indexOf(filterObj.username) >= 0) && (item.role & parseInt(filterObj.role, 2)) > 0 && (!filterObj.org_id || item.org_id==filterObj.org_id) + return (filterObj.username == null || item.username.indexOf(filterObj.username) >= 0) && (item.role & parseInt(filterObj.role, 2)) > 0 && (!filterObj.org_id || item.org_id == filterObj.org_id) }) } }]); diff --git a/src/main/ui/static/config/organizations/templates/org_detail.html b/src/main/ui/static/config/organizations/templates/org_detail.html index d9443350e..22f89651b 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -757,7 +757,21 @@ + + +
+ +
+ +

+
+
+ + + +