diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/LogClientSubMerchantIdMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/LogClientSubMerchantIdMapper.java new file mode 100644 index 000000000..9bb01369e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/LogClientSubMerchantIdMapper.java @@ -0,0 +1,19 @@ +package au.com.royalpay.payment.manage.mappers.log; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@AutoMapper(tablename = "log_client_sub_merchant_id", pkName = "id") +public interface LogClientSubMerchantIdMapper { + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject log); + + @AutoSql(type = SqlType.SELECT) + List listLogsByClientId(@Param("client_id") int client_id); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index ba7130b77..b8e2a4bc7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -286,4 +286,6 @@ public interface ClientManager { void clearCacheSubMerchantIdApplices(String clientMoniker); JSONObject getCheckClientInfo(int client_id,String account_id, String channel); + + List getClientSubMerchantIdLogs(String clientMoniker,JSONObject manager); } 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 1b0638e72..814cdc3c5 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 @@ -14,6 +14,7 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper; +import au.com.royalpay.payment.manage.mappers.log.LogClientSubMerchantIdMapper; import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; @@ -225,6 +226,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private MessageSource messageSource; @Resource private ClientsOperationLogMapper clientsOperationLogMapper; + @Resource + private LogClientSubMerchantIdMapper logClientSubMerchantIdMapper; + @Resource private ClientInfoCacheSupport clientInfoCacheSupport; @@ -278,6 +282,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("show_all_permission", true); int role = manager != null ? manager.getIntValue("role") : 0; if (manager != null) { + if(ManagerRole.OPERATOR.hasRole(role)){ + List log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id")); + client.put("sub_merchant_id_log", log.size()>0?true:false); + } if (ManagerRole.BD_USER.hasRole(role)) { int checkBDPermission = clientBDMapper.checkBDPermission(client.getIntValue("client_id"), manager.getString("manager_id")); client.put("show_all_permission", checkBDPermission > 0); @@ -581,16 +589,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid WeChatPayConfig.Merchant availableMerchant = mpPaymentApi.determineMerchant(subMerchantId); update.put("merchant_id", availableMerchant == null ? null : availableMerchant.getMerchantId()); update.put("sub_merchant_id", subMerchantId); + try{ + recordSubMerchantLog(client,subMerchantInfo,manager); + }catch(Exception e){ + logger.error("记录log_client_sub_merchant_id失败",e); + } clientMapper.update(update); List children = clientMapper.listChildClients(clientId); for (JSONObject child : children) { if (Objects.equals(child.getString("sub_merchant_id"), originSubMerchantId)) { update.put("client_id", child.getIntValue("client_id")); + try{ + recordSubMerchantLog(child,subMerchantInfo,manager); + }catch(Exception e){ + logger.error("记录log_client_sub_merchant_id失败",e); + } clientMapper.update(update); } } clientInfoCacheSupport.clearClientCache(clientId); } + private void recordSubMerchantLog(JSONObject client,JSONObject subMerchantInfo,JSONObject manager){ + JSONObject log = new JSONObject(); + log.put("sub_merchant_id_after",subMerchantInfo.getString("sub_merchant_id")); + log.put("operator",manager.getString("display_name")); + log.put("create_time",new Date()); + log.put("client_id",client.getIntValue("client_id")); + log.put("sub_merchant_id_before",client.getString("sub_merchant_id")); + logClientSubMerchantIdMapper.save(log); + } @Override public void auditClient(JSONObject manager, String clientMoniker, int pass) { @@ -3340,4 +3367,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } return sourceStr; } + + @Override + public List getClientSubMerchantIdLogs(String clientMoniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index f8e1c6561..e76212056 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -526,4 +526,9 @@ public class PartnerManageController { return clientManager.listMerchantIds(clientMoniker,manager); } + @ManagerMapping(value = "/{clientMoniker}/get_sub_merchant_id_logs",method = RequestMethod.GET,role = {ManagerRole.OPERATOR}) + public List getClientSubMerchantIdLogs(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return clientManager.getClientSubMerchantIdLogs(clientMoniker,manager); + } + } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index c6456d83c..ef81697a4 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1049,7 +1049,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } } }]); - app.controller('partnerPaymentInfoCtrl', ['$scope', '$http', '$state', 'commonDialog', function ($scope, $http, $state, commonDialog) { + app.controller('partnerPaymentInfoCtrl', ['$scope', '$http', '$state', 'commonDialog','$uibModal', function ($scope, $http, $state, commonDialog,$uibModal) { $scope.loadPartnerPaymentInfo = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { $scope.paymentInfo = resp.data; @@ -1068,6 +1068,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.reloadQRCode(); $scope.loadPartnerPaymentInfo(); + $scope.showSubMerchantLogs = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', + controller: 'clientSubMerchantIdLogCtrl', + size: 'lg', + resolve: { + logs: ['$http', function ($http) { + return $http.get('/sys/partners/'+$scope.partner.client_moniker+'/get_sub_merchant_id_logs'); + }] + } + }).result.then(function () { + $scope.loadSubClients(); + }); + }; + $scope.saveMaxOrderAmount = function (limit) { if (limit != null && isNaN(limit)) { commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'}); @@ -1366,6 +1381,9 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }; }]); + app.controller('clientSubMerchantIdLogCtrl', ['$scope', '$http', 'logs', function ($scope, $http, logs) { + $scope.logs = logs.data; + }]); app.controller('partnerSubCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) { $scope.newSubClient = function () { $uibModal.open({ diff --git a/src/main/ui/static/payment/partner/templates/client_sub_merchant_id_log.html b/src/main/ui/static/payment/partner/templates/client_sub_merchant_id_log.html new file mode 100644 index 000000000..287bb7742 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/client_sub_merchant_id_log.html @@ -0,0 +1,41 @@ +
+

Sub Merchant Id Logs

+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + +
Sub Merchant Id BeforeSub Merchant Id AfterOperatorCreate Time
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index 8f9872ac4..3d4e3c589 100644 --- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html @@ -12,6 +12,16 @@   Merchant ID:{{paymentInfo.merchant_id | choose_merchant_id}} +    + + + + logs + + +