From bace0e420eabafdcbebb3e803474fa38d37dccd9 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Tue, 9 Jan 2018 10:35:25 +0800 Subject: [PATCH 01/11] fix --- .../manage/mappers/system/OrgMapper.java | 2 ++ .../manage/organizations/core/OrgManager.java | 1 + .../core/impls/OrgManagerImpl.java | 29 +++++++++++++++++++ .../core/impls/TradeLogServiceImpl.java | 28 ++++-------------- .../manage/mappers/payment/OrderMapper.xml | 2 +- .../manage/mappers/system/OrgMapper.xml | 4 +++ .../managers/templates/new_manager.html | 6 ++-- 7 files changed, 45 insertions(+), 27 deletions(-) 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 968557be4..04ae18528 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 @@ -45,4 +45,6 @@ public interface OrgMapper { JSONObject findOrgByBDId(@Param("bd_id") int bd_id); PageList listOrgWithPages(JSONObject paraams, PageBounds order); + + List listOrgAndChild(@Param("org_id") int org_id); } 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 c682aee4f..d3f35d221 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 @@ -27,4 +27,5 @@ public interface OrgManager { List listAllOrg(); + JSONObject checkOrg(JSONObject manager, JSONObject params); } 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 76ece5f19..90ddc9abd 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 @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.manage.organizations.beans.OrgInfo; import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONArray; @@ -11,12 +12,14 @@ 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 org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * Created by yixian on 2016-10-18. @@ -132,4 +135,30 @@ public class OrgManagerImpl implements OrgManager { } } + @Override + public JSONObject checkOrg(JSONObject manager, JSONObject params){ + if (params.getString("org_id")==null){ + if (manager.getInteger("org_id")!=null){ + List orgs = orgMapper.listOrgAndChild(manager.getIntValue("org_id")); + if (orgs.size()>1){ + List orgIds = orgs.stream().map(org->org.getIntValue("org_id")).collect(Collectors.toList()); + params.put("org_ids",orgIds); + }else { + params.put("org_id",manager.getIntValue("org_id")); + } + } + }else { + 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_id"))){ + throw new ForbiddenException("You have no permission to query the org"); + } + + } + + } + return params; + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index fe9ed3449..4f2ab89ab 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -20,6 +20,7 @@ import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; @@ -121,7 +122,7 @@ public class TradeLogServiceImpl implements TradeLogService { private ClientCustomersMapper clientCustomersMapper; @Resource - private OrgMapper orgMapper; + private OrgManager orgManager; // @Value("classpath:/jasper/trans_flow.jasper") // @Value("classpath:/jasper/trans_flow_new.jasper") @@ -179,28 +180,7 @@ public class TradeLogServiceImpl implements TradeLogService { params.put("bd_group_bd", query.getGroup_bd()); } } - if (manager.getInteger("org_id") != null) { - if(params.getString("org_id") == null) { - JSONObject org = orgMapper.findOne(manager.getInteger("org_id")); - if(org.getString("parent_org_id") != null){ - params.put("org_id",manager.getInteger("org_id")); - }else { - JSONObject param = new JSONObject(); - param.put("parent_org_id", manager.getIntValue("org_id")); - param.put("type", 0); - List orgIds = new ArrayList<>(); - List childOrgs = orgMapper.listOrgsWithChid(param); - if(childOrgs.size()>0){ - for (JSONObject object : childOrgs) { - orgIds.add(object.getIntValue("org_id")); - } - orgIds.add(manager.getIntValue("org_id")); - params.put("org_ids", orgIds); - } - } - - } - } + orgManager.checkOrg(manager,params); PageList logs = orderMapper.listOrders(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); JSONObject analysis = orderMapper.analysisOrders(params); @@ -208,6 +188,8 @@ public class TradeLogServiceImpl implements TradeLogService { return result; } + + @Override public List listOrderRefunds(String orderId, String timezone) { List refunds = refundMapper.listOrderRefunds(orderId, new PageBounds(Order.formString("create_time.desc"))); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index c9893b8d6..15377e695 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -177,7 +177,7 @@ and o.gateway in #{gateway} - and p.org_id=#{org_id} + and p.org_id=#{org_id} and o.create_time >= #{from} and o.create_time < #{to} and date(o.create_time)=date(#{date}) diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml index fd1772188..c1a62ca1c 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml @@ -31,6 +31,10 @@ + + diff --git a/src/main/ui/static/config/managers/templates/new_manager.html b/src/main/ui/static/config/managers/templates/new_manager.html index 96a455d20..1fa60ccb9 100644 --- a/src/main/ui/static/config/managers/templates/new_manager.html +++ b/src/main/ui/static/config/managers/templates/new_manager.html @@ -36,17 +36,17 @@
-
+
-
+
-
+
From 532a122a2840b8fba3f2416a463f4f5999597005 Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 9 Jan 2018 10:47:27 +0800 Subject: [PATCH 02/11] compileError --- .../manage/appclient/core/impls/RetailAppServiceImp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index f022a5aa3..bb6d1edd3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -435,7 +435,7 @@ public class RetailAppServiceImp implements RetailAppService { @Override public void updateDevToken(JSONObject device, String devToken) { - deviceSupport.updateIphoneMessageToken(device, devToken); + deviceSupport.updateDeviceMessageToken(device, devToken); } @Override From 30485cde91a7c60321afa83ccd56c7946c8ca81b Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 9 Jan 2018 11:22:15 +0800 Subject: [PATCH 03/11] config --- .../au/com/royalpay/payment/manage/dev/web/TestController.java | 1 + src/main/resources/application.properties | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index f735826e8..2e0594400 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -314,6 +314,7 @@ public class TestController implements ApplicationEventPublisherAware { elem = alipayClient.onlineRefund(refundOrder, type == TradeType.GATEWAY_H5); xmlStr = XmlFormatUtils.formatXml(elem); res.put("xml", xmlStr); + break; default: throw new BadRequestException("Not Support channel:" + channel); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 548187901..1626209c0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -85,6 +85,8 @@ app.mail.host=https://mailsupport.royalpay.com.au mail.send.credentialCode=Fd1aRfdjc9 apple.message.apns.password=F1b5*ChJPp73 +android.message.secret=2b96d9bc6169c9554218aab1 +android.message.appkey=3f33a10d0a7d4ac94d8f2431 spring.thymeleaf.mode=LEGACYHTML5 From 322c4ea227ed4f361379cc71c1c64c302b3a2f07 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Tue, 9 Jan 2018 14:40:47 +0800 Subject: [PATCH 04/11] fix --- .../analysis/web/DashboardController.java | 47 ++++++------------- .../signin/web/ManagerAccountsController.java | 12 +++-- .../analysis/mappers/ClientAnalysisMapper.xml | 28 ++++++++--- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java index 856030e6c..ec3eaccfa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.analysis.web; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.core.DashboardService; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequirePartner; @@ -20,32 +21,28 @@ import java.util.List; public class DashboardController { @Resource private DashboardService dashboardService; + @Resource + private OrgManager orgManager; @ManagerMapping("/common_analysis_1") public JSONObject commonAnalysis1(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getCommonAnalysis1(params); } @ManagerMapping("/common_analysis_2") public JSONObject commonAnalysis2(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getCommonAnalysis2(params); } @ManagerMapping("/trade_in_types") public List tradeInTypes(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeInTypes(params); } @@ -53,18 +50,14 @@ public class DashboardController { public List topTradePartners(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestParam(defaultValue = "10") int limit) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTopTradePartners(params, limit); } @ManagerMapping("/rank_trade_partners") public List rankTradePartners(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -77,9 +70,7 @@ public class DashboardController { @ManagerMapping("/trade_in_hours") public List tradeInHours(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -92,18 +83,14 @@ public class DashboardController { @ManagerMapping("/fee_analysis") public List tradeInDays(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeAnalysisInDays(params); } @ManagerMapping("/partners_in_types") public List partnersInTypes(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -118,9 +105,7 @@ public class DashboardController { @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); params.put("trade_type", trade_type); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -134,9 +119,7 @@ public class DashboardController { @ManagerMapping("/trade_in_time") public List tradeInTime(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeAnalysisInTime(params); } @@ -154,9 +137,7 @@ public class DashboardController { @ManagerMapping("/Total_platform_amount") public JSONObject getPlatformAmount(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager){ JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getPlatformAmount(params); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java index 7e539b1a4..b93a106bf 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.signin.web; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequireManager; @@ -25,6 +26,8 @@ import java.util.Map; public class ManagerAccountsController { @Resource private ManagerAccountsService managerAccountsService; + @Resource + private OrgManager orgManager; // @RequestMapping(method = RequestMethod.GET) // @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) @@ -48,11 +51,14 @@ public class ManagerAccountsController { @ManagerMapping(value = "/roles/bd_user", method = RequestMethod.GET) public List listBDUsers(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { - return managerAccountsService.listBDUsers(loginManager); + JSONObject params = new JSONObject(); + orgManager.checkOrg(loginManager,params); + return managerAccountsService.listBDUsers(params); } @ManagerMapping(value = "/roles/org_bd_user", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.ACCOUNT_MANAGER}) - public List listOrgBDUsers(@RequestParam Map map) { - return managerAccountsService.listBDUsers((JSONObject) JSON.toJSON(map)); + public List listOrgBDUsers(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager,@RequestParam Map map) { + JSONObject params = (JSONObject) JSON.toJSON(map); + return managerAccountsService.listBDUsers(params); } @ManagerMapping(value = "/{userId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER,ManagerRole.BD_USER}) diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml index be9fe3d69..4f33ecef3 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml @@ -8,7 +8,9 @@ WHERE create_time >= #{begin} AND create_time <= #{end} and is_valid=1 and (approve_result is null or approve_result !=0) ]]> - and org_id=#{org_id} + and org_id=#{org_id} + and org_id in + #{org_id} GUEST:观察员
+
+ +
diff --git a/src/main/ui/static/config/managers/templates/managers.html b/src/main/ui/static/config/managers/templates/managers.html index 36fa9f08d..7908d970b 100644 --- a/src/main/ui/static/config/managers/templates/managers.html +++ b/src/main/ui/static/config/managers/templates/managers.html @@ -95,6 +95,7 @@ + Modify diff --git a/src/main/ui/static/config/managers/templates/modify.html b/src/main/ui/static/config/managers/templates/modify.html index cf678293b..5faa653ac 100644 --- a/src/main/ui/static/config/managers/templates/modify.html +++ b/src/main/ui/static/config/managers/templates/modify.html @@ -81,6 +81,9 @@ +

diff --git a/src/main/ui/static/config/managers/templates/new_manager.html b/src/main/ui/static/config/managers/templates/new_manager.html index 1fa60ccb9..da4e5fd2d 100644 --- a/src/main/ui/static/config/managers/templates/new_manager.html +++ b/src/main/ui/static/config/managers/templates/new_manager.html @@ -90,6 +90,9 @@ +

From c53ea04d2e807672cf35602906a5f37e8698ff2c Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 9 Jan 2018 16:19:41 +0800 Subject: [PATCH 06/11] fix~ --- .../manage/mappers/payment/OrderMapper.xml | 4 ++- .../manage/mappers/system/ManagerMapper.xml | 2 +- .../config/organizations/templates/orgs.html | 3 ++- .../static/payment/partner/partner-manage.js | 27 +++++++++++++++++++ .../payment/partner/templates/partners.html | 4 +-- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index 15377e695..1fa582785 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -359,11 +359,13 @@ and t.system_transaction_id =#{search_text} + and p.org_id in + #{org_id} and o.order_id=#{order_id} and o.gateway in #{gateway} - and p.org_id=#{org_id} + and p.org_id=#{org_id} and o.create_time >= #{from} and o.create_time < #{to} and date(o.create_time)=date(#{date}) diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml index 434d24c25..2ebe604e3 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml @@ -3,7 +3,7 @@ + ng-options="bd.manager_id as bd.display_name group by bd.org_name for bd in bdUserSource | bdOrgSelect:params">
From a9e1d653aad4255e365be36f0c7d00210631363f Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Tue, 9 Jan 2018 16:20:26 +0800 Subject: [PATCH 07/11] fix --- .../core/impls/SignInAccountServiceImpl.java | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java index 4d20ee720..042a1149d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java @@ -32,7 +32,10 @@ import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * account service for sign in @@ -64,14 +67,11 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati @Cacheable(value = ":login:managers:", key = "''+#accountId") public JSONObject getManager(String accountId) { JSONObject manager = managerMapper.findById(accountId); - JSONObject org = null; if (manager == null) { throw new ForbiddenException("用户不存在或已禁用"); } if (manager.getInteger("org_id") != null) { - org = orgMapper.findOne(manager.getIntValue("org_id")); - manager.put("org", org); - manager.put("parent_org_id",org.getIntValue("parent_org_id")); + manager.put("org", orgMapper.findOne(manager.getIntValue("org_id"))); } List funcs = permissionManager.listUserFunctions(manager.getIntValue("role")); List funcIds = new ArrayList<>(); @@ -90,36 +90,12 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati modules.put(module, mod); } } - if(org != null && org.getIntValue("type")==0 && org.getString("parent_org_id") != null){ - if(modules.containsKey("org")){ - deleteOrgModule(modules,"org"); - } - if(modules.containsKey("manager_accounts")){ - deleteOrgModule(modules,"manager_accounts"); - } - } - if(org != null && org.getIntValue("type")==0 && org.getString("parent_org_id") == null){ - if(modules.containsKey("manager_accounts")){ - deleteOrgModule(modules,"manager_accounts"); - } - } - manager.put("available_func_ids", funcIds); manager.put("available_func_names", funcNames); manager.put("modules", modules.values()); manager.put("module_names", modules.keySet()); return manager; } - private void deleteOrgModule(Map modules,String module){ - Iterator iterator = modules.keySet().iterator(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - if (module.equals(key)) { - iterator.remove(); - modules.remove(key); - } - } - } @Override @Cacheable(value = ":login:clients:", key = "''+#accountId") From 49609d0f2c3147a5473be1ac46a2f4472359829b Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Tue, 9 Jan 2018 16:28:59 +0800 Subject: [PATCH 08/11] fix --- src/main/ui/static/config/managers/templates/managers.html | 1 + .../static/config/sysconfigs/templates/permission_config.html | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main/ui/static/config/managers/templates/managers.html b/src/main/ui/static/config/managers/templates/managers.html index 7908d970b..0f6de078a 100644 --- a/src/main/ui/static/config/managers/templates/managers.html +++ b/src/main/ui/static/config/managers/templates/managers.html @@ -33,6 +33,7 @@ +
diff --git a/src/main/ui/static/config/sysconfigs/templates/permission_config.html b/src/main/ui/static/config/sysconfigs/templates/permission_config.html index 8bff132a6..e4dfa6819 100644 --- a/src/main/ui/static/config/sysconfigs/templates/permission_config.html +++ b/src/main/ui/static/config/sysconfigs/templates/permission_config.html @@ -67,6 +67,10 @@ GUEST + + + Org Manager +
From c964f9364964a5c0e3f68c3624650dbe20583b6e Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 9 Jan 2018 17:45:06 +0800 Subject: [PATCH 09/11] fix~ --- src/db/modify.sql | 1 + .../organizations/core/impls/OrgManagerImpl.java | 13 ------------- .../organizations/web/OrgManageController.java | 6 +++--- .../core/impls/ManagerAccountServiceImpl.java | 15 --------------- .../signin/web/ManagerAccountsController.java | 8 ++++---- .../organizations/templates/org_detail.html | 2 ++ .../payment/partner/templates/partners.html | 2 +- 7 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/db/modify.sql b/src/db/modify.sql index b5502c9fc..1eb8d6787 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -138,4 +138,5 @@ ALTER TABLE sys_clients_customers ADD COLUMN channel varchar(15) not NULL ; ALTER TABLE sys_clients_customers ADD COLUMN last_payment_time datetime DEFAULT NULL COMMENT '最后一次付款时间'; +ALTER TABLE sys_org ADD COLUMN parent_org_id int(11) DEFAULT NULL; 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 90ddc9abd..658f5f7fa 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 @@ -68,7 +68,6 @@ public class OrgManagerImpl implements OrgManager { public JSONObject listAllOrgs(OrgInfo orgInfo,JSONObject manager) { /* PageBounds sort = new PageBounds(Order.formString("sort_no.asc")); return orgMapper.listsOrgWithDetail(sort);*/ - checkBdRole(manager); JSONObject params = orgInfo.toJsonParam(); PageList listOrg = orgMapper.listOrgWithPages(params,new PageBounds(orgInfo.getPage(),orgInfo.getLimit(),Order.formString("sort_no.asc"))); return PageListUtils.buildPageListResult(listOrg); @@ -76,7 +75,6 @@ public class OrgManagerImpl implements OrgManager { @Override public JSONObject getOrgDetail(int orgId,JSONObject manager) { - checkBdRole(manager); return orgMapper.findOne(orgId); } @@ -124,17 +122,6 @@ public class OrgManagerImpl implements OrgManager { return listAllOrgs; } - private void checkBdRole(JSONObject manager){ - if(ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))){ - if(manager.getString("org_id") != null){ - JSONObject org = orgMapper.findOne(manager.getIntValue("org_id")); - if(org != null && org.getIntValue("type") == 0 && org.getString("parent_org_id") != null){ - throw new BadRequestException("Invalid Role"); - } - } - } - } - @Override public JSONObject checkOrg(JSONObject manager, JSONObject params){ if (params.getString("org_id")==null){ 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 28f4698bd..f86ff0da7 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 @@ -49,13 +49,13 @@ public class OrgManageController { return orgManager.listAllOrg(); } - @ManagerMapping(method = RequestMethod.POST, role = {ManagerRole.ADMIN,ManagerRole.BD_USER}) + @ManagerMapping(method = RequestMethod.POST, role = {ManagerRole.ADMIN}) public JSONObject saveOrg(@RequestBody @Valid OrgInfo org, Errors errors) { HttpUtils.handleValidErrors(errors); return orgManager.saveNewOrg(org); } - @ManagerMapping(value = "/{orgId}", method = RequestMethod.GET, role = {ManagerRole.ADMIN,ManagerRole.BD_USER}) + @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); } @@ -66,7 +66,7 @@ public class OrgManageController { orgManager.updateOrg(orgId, org); } - @ManagerMapping(value = "/{orgId}/enable_change_rate",method = RequestMethod.PUT,role = {ManagerRole.ADMIN,ManagerRole.BD_USER}) + @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); diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java index 82413d448..adf5d191f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java @@ -31,7 +31,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public List listManagers(JSONObject loginManager) { - checkBdRole(loginManager); JSONObject params = new JSONObject(); if (loginManager.getInteger("org_id") != null) { params.put("org_id", loginManager.getIntValue("org_id")); @@ -58,7 +57,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void saveManager(ManagerInfo manager, JSONObject loginManager) { - checkBdRole(loginManager); if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))) { if (manager.isAdmin() || manager.isFinacial() || manager.isOperator() || manager.isServant() || manager.isSitemanager() || manager.isDeveloper()) { throw new BadRequestException("Invalid Role"); @@ -74,7 +72,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void modify(String userId, ManagerInfo manager, JSONObject loginManager) { - checkBdRole(loginManager); JSONObject managerFromDb = managerMapper.findById(userId); if (managerFromDb == null) { throw new NotFoundException("manager not exists or invalid"); @@ -95,7 +92,6 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void disable(String userId, JSONObject loginManager) { - checkBdRole(loginManager); JSONObject manager = managerMapper.findById(userId); if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))){ if (manager.getIntValue("org_id") != loginManager.getIntValue("org_id")) { @@ -127,15 +123,4 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { return financialBDConfigMapper.getBdConfig(bd_id); } - private void checkBdRole(JSONObject loginManager){ - if(ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))){ - JSONObject manager = managerMapper.findById(loginManager.getString("manager_id")); - if(manager.getString("org_id") != null){ - JSONObject org = orgMapper.findOne(manager.getIntValue("org_id")); - if(org != null && org.getIntValue("type") == 0 && org.getString("parent_org_id") != null){ - throw new BadRequestException("Invalid Role"); - } - } - } - } } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java index b93a106bf..06c607702 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java @@ -36,14 +36,14 @@ public class ManagerAccountsController { // } @RequestMapping(method = RequestMethod.GET) - @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER,ManagerRole.BD_USER}) + @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) public List listManagerss(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager, @RequestParam Map map) { loginManager.putAll(map); return managerAccountsService.listManagers(loginManager); } @RequestMapping(method = RequestMethod.POST) - @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER,ManagerRole.BD_USER}) + @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) public void saveManager(@RequestBody @Valid ManagerInfo manager, Errors errors, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { HttpUtils.handleValidErrors(errors); managerAccountsService.saveManager(manager, loginManager); @@ -61,12 +61,12 @@ public class ManagerAccountsController { return managerAccountsService.listBDUsers(params); } - @ManagerMapping(value = "/{userId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER,ManagerRole.BD_USER}) + @ManagerMapping(value = "/{userId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) public void modify(@PathVariable String userId, @RequestBody ManagerInfo manager, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { managerAccountsService.modify(userId, manager, loginManager); } - @ManagerMapping(value = "/{userId}", method = RequestMethod.DELETE, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER,ManagerRole.BD_USER}) + @ManagerMapping(value = "/{userId}", method = RequestMethod.DELETE, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) public void disableUser(@PathVariable String userId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { managerAccountsService.disable(userId, loginManager); } 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 cd634a020..c23704ac5 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -192,6 +192,7 @@ + @@ -237,6 +238,7 @@ + Modify diff --git a/src/main/ui/static/payment/partner/templates/partners.html b/src/main/ui/static/payment/partner/templates/partners.html index 4b38b57b2..6be647567 100644 --- a/src/main/ui/static/payment/partner/templates/partners.html +++ b/src/main/ui/static/payment/partner/templates/partners.html @@ -148,7 +148,7 @@ -
+
From bf1770d55238d1f5b833a2981797054ab00f30bf Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 9 Jan 2018 18:03:42 +0800 Subject: [PATCH 10/11] fix~ --- .../manage/signin/core/impls/ManagerAccountServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java index adf5d191f..9708e6b27 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java @@ -57,7 +57,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void saveManager(ManagerInfo manager, JSONObject loginManager) { - if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))) { + if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role"))) { if (manager.isAdmin() || manager.isFinacial() || manager.isOperator() || manager.isServant() || manager.isSitemanager() || manager.isDeveloper()) { throw new BadRequestException("Invalid Role"); } @@ -77,7 +77,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { throw new NotFoundException("manager not exists or invalid"); } JSONObject obj = manager.accountJson(false); - if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))) { + if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role"))) { if (managerFromDb.getIntValue("org_id") != loginManager.getIntValue("org_id")) { throw new BadRequestException("You cannot modify accounts belong to other organizations"); } @@ -93,7 +93,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void disable(String userId, JSONObject loginManager) { JSONObject manager = managerMapper.findById(userId); - if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role")) && !ManagerRole.BD_USER.hasRole(loginManager.getIntValue("role"))){ + if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role"))){ if (manager.getIntValue("org_id") != loginManager.getIntValue("org_id")) { throw new BadRequestException("You cannot disable accounts belong to other organizations"); } From fc63e8428b6f716d077ce5116d1d5fb4aa01923d Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Tue, 9 Jan 2018 19:19:05 +0800 Subject: [PATCH 11/11] fix --- .../merchants/core/impls/ClientManagerImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 008a48d03..a0051133a 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 @@ -214,7 +214,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - checkOrgPermission(manager, client); + checkClientOrg(manager, client); client.put("show_all_permission", true); int role = manager != null ? manager.getIntValue("role") : 0; if (manager != null) { @@ -274,6 +274,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return client; } + private void checkClientOrg(JSONObject manager, JSONObject client) { + if (manager.getInteger("org_id")!=null){ + JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); + if (org.getInteger("parent_org_id")!=null){ + if (org.getIntValue("parent_org_id")!=manager.getIntValue("org_id")){ + throw new ForbiddenException("The org of client is not belong to you"); + } + }else { + checkOrgPermission(manager, client); + } + } + } + @Override public JSONObject getClientDetailById(int clientId) { JSONObject client = getClientInfo(clientId); @@ -1388,7 +1401,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - checkOrgPermission(manager, client); + checkClientOrg(manager,client); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); params.put("is_valid", "1");