From f333d3801b5d7afb68b8c0dd4111ff9f23a70e66 Mon Sep 17 00:00:00 2001 From: luoyang Date: Thu, 30 Apr 2020 11:32:57 +0800 Subject: [PATCH] =?UTF-8?q?add=20mw=20=E5=90=88=E8=A7=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=9A=E4=B8=AA=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../mappers/system/ClientMWFilesMapper.java | 5 + .../manage/merchants/core/ClientManager.java | 2 + .../core/impls/ClientManagerImpl.java | 28 +- .../merchants/enums/UPayAuthFileEnum.java | 2 +- .../web/PartnerManageController.java | 6 +- .../mappers/system/ClientMWFilesMapper.xml | 8 + .../static/payment/partner/partner-manage.js | 126 ++------- .../templates/partner_mw_auth_files.html | 240 ++++++++++++++---- 9 files changed, 258 insertions(+), 161 deletions(-) create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.xml diff --git a/pom.xml b/pom.xml index 096da615a..925a87734 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 2.2.19 + 2.2.20 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.java index e5064a1cf..24d7e73d7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.java @@ -24,4 +24,9 @@ public interface ClientMWFilesMapper { @AutoSql(SqlType.SELECT) @AdvanceSelect(addonWhereClause = "is_valid = 1") List findClientFile(@Param("client_id") int clientId, PageBounds pageBounds); + + @AutoSql(SqlType.SELECT) + JSONObject findFileById(@Param("file_id") String file_id); + + void deleteByClientAndFileId(@Param("file_id") String file_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 b204554ce..88c64ed46 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 @@ -278,6 +278,8 @@ public interface ClientManager { void deleteAuthFilesByAdmin(String fileId); + void deleteMWAuthFilesByAdmin(String fileId); + void uploadAuthFiles(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo); void uploadAuthFilesManager(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo); 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 41d2f4bab..eb3c9c259 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 @@ -3840,10 +3840,25 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } + String[] fileKeys = UPayAuthFileEnum.ALL.getFileNameArrays(); List clientFiles = clientMWAuthFilesInfo.findClientFile(client.getIntValue("client_id"), new PageBounds(1,999999, Order.formString("last_update_date.asc"))); JSONObject fileJson = new JSONObject(); - for (JSONObject file : clientFiles) { - fileJson.put(file.getString("file_name"), file.getString("file_value")); + if (clientFiles != null && clientFiles.size() > 0) { + for (String fileKey : fileKeys) { + List clientFileUrl = clientFiles.stream() + .filter(json -> (fileKey.equals(json.getString("file_name")))) + .sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date"))) + .map(json -> { + JSONObject params = new JSONObject(); + params.put("file_id", json.getString("file_id")); + params.put("file_value", json.getString("file_value")); + return params; + }) + .collect(Collectors.toList()); + if (clientFileUrl != null && clientFileUrl.size() > 0) { + fileJson.put(fileKey, clientFileUrl); + } + } } return fileJson; } @@ -3929,6 +3944,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientFilesMapper.deleteByClientAndFileId(fileId); } + @Override + public void deleteMWAuthFilesByAdmin(String fileId) { + JSONObject file = clientMWAuthFilesInfo.findFileById(fileId); + if (file == null) { + throw new BadRequestException("The file has deleted"); + } + clientMWAuthFilesInfo.deleteByClientAndFileId(fileId); + } + @Override @Transactional public void uploadAuthFiles(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo) { diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/enums/UPayAuthFileEnum.java b/src/main/java/au/com/royalpay/payment/manage/merchants/enums/UPayAuthFileEnum.java index bdaa59ecf..c81cfb906 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/enums/UPayAuthFileEnum.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/enums/UPayAuthFileEnum.java @@ -28,7 +28,7 @@ public enum UPayAuthFileEnum { public String[] getFileNameArrays() { return new String[]{CLIENT_BANK_FILE.getFileName(), CLIENT_COMPANY_FILE.getFileName(), - UPAY_OFFER_LETTER.getFileName(), + UPAY_DRIVER_LICENSE.getFileName(), REFUND_EXCHANGE_POLICY.getFileName(), UPAY_PRIVACY_POLICY.getFileName(), CARD_SECURITY_POLICY.getFileName(), 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 1ea7c90d1..958ddd64b 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 @@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.io.OutputStream; -import java.util.Date; import java.util.List; /** @@ -611,6 +610,11 @@ public class PartnerManageController { clientManager.deleteAuthFilesByAdmin(fileId); } + @ManagerMapping(value = "/auth_file/{fileId}/mw_delete", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER}) + public void deleteMWAuthFiles(@PathVariable String fileId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.deleteMWAuthFilesByAdmin(fileId); + } + @ManagerMapping(value = "/{clientMoniker}/file", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER}) public void uploadAuthFiles(@PathVariable String clientMoniker, @RequestBody ClientAuthFilesInfo filesInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.xml new file mode 100644 index 000000000..5fbb5d9e0 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMWFilesMapper.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index fed52eaf4..86e1bcfa6 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -3837,54 +3837,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_risk_level = $scope.partner.upay_risk_level; $scope.file.upay_risk_remark = $scope.partner.upay_risk_remark; - $scope.bankIsImage = true; - $scope.asicIsImage = true; - $scope.idIsImage = true; - $scope.utilityIsImage = true; - $scope.refundIsImage = true; - $scope.privacyIsImage = true; - $scope.cardIsImage = true; - $scope.letterIsImage = true; - $scope.promotionalIsImage = true; - $scope.termsIsImage = true; - $scope.applicationIsImage = true; - $scope.descIsImage = true; - if ($scope.file.client_bank_file && $scope.file.client_bank_file.endsWith('pdf')) { - $scope.bankIsImage = false; - } - if ($scope.file.client_company_file && $scope.file.client_company_file.endsWith('pdf')) { - $scope.asicIsImage = false; - } - if ($scope.file.upay_driver_license && $scope.file.upay_driver_license.endsWith('pdf')) { - $scope.idIsImage = false; - } - if ($scope.file.kyc_utility_bill_file && $scope.file.kyc_utility_bill_file.endsWith('pdf')) { - $scope.utilityIsImage = false; - } - if ($scope.file.refund_exchange_policy && $scope.file.refund_exchange_policy.endsWith('pdf')) { - $scope.refundIsImage = false; - } - if ($scope.file.upay_privacy_policy && $scope.file.upay_privacy_policy.endsWith('pdf')) { - $scope.privacyIsImage = false; - } - if ($scope.file.card_security_policy && $scope.file.card_security_policy.endsWith('pdf')) { - $scope.cardIsImage = false; - } - if ($scope.file.upay_offer_letter && $scope.file.upay_offer_letter.endsWith('pdf')) { - $scope.letterIsImage = false; - } - if ($scope.file.upay_promotional_offer && $scope.file.upay_promotional_offer.endsWith('pdf')) { - $scope.promotionalIsImage = false; - } - if ($scope.file.upay_terms_conditions && $scope.file.upay_terms_conditions.endsWith('pdf')) { - $scope.termsIsImage = false; - } - if ($scope.file.upay_application_form && $scope.file.upay_application_form.endsWith('pdf')) { - $scope.applicationIsImage = false; - } - if ($scope.file.upay_desc_file && $scope.file.upay_desc_file.endsWith('pdf')) { - $scope.descIsImage = false; - } $scope.uploadApplicationFile = function (file) { if (file != null) { if (file.size > 3 * 1024 * 1024) { @@ -3900,11 +3852,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_application_form = resp.data.url; $scope.uploadFile.upay_application_form = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_application_form.endsWith('pdf')) { - $scope.bankIsImage = false; - } else { - $scope.bankIsImage = true; - } }, function (resp) { delete $scope.applicationFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -3929,11 +3876,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.client_bank_file = resp.data.url; $scope.uploadFile.client_bank_file = resp.data.url; $scope.updateFile(); - if ($scope.file.client_bank_file.endsWith('pdf')) { - $scope.bankIsImage = false; - } else { - $scope.bankIsImage = true; - } }, function (resp) { delete $scope.bankFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -3958,11 +3900,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.client_company_file = resp.data.url; $scope.uploadFile.client_company_file = resp.data.url; $scope.updateFile(); - if ($scope.file.client_company_file.endsWith('pdf')) { - $scope.bankIsImage = false; - } else { - $scope.bankIsImage = true; - } }, function (resp) { delete $scope.ASICProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -3987,11 +3924,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_driver_license = resp.data.url; $scope.uploadFile.upay_driver_license = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_driver_license.endsWith('pdf')) { - $scope.idIsImage = false; - } else { - $scope.idIsImage = true; - } }, function (resp) { delete $scope.idProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4016,11 +3948,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.kyc_utility_bill_file = resp.data.url; $scope.uploadFile.kyc_utility_bill_file = resp.data.url; $scope.updateFile(); - if ($scope.file.kyc_utility_bill_file.endsWith('pdf')) { - $scope.utilityIsImage = false; - } else { - $scope.utilityIsImage = true; - } }, function (resp) { delete $scope.residenceFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4045,11 +3972,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.refund_exchange_policy = resp.data.url; $scope.uploadFile.refund_exchange_policy = resp.data.url; $scope.updateFile(); - if ($scope.file.refund_exchange_policy.endsWith('pdf')) { - $scope.utilityIsImage = false; - } else { - $scope.utilityIsImage = true; - } }, function (resp) { delete $scope.refundPolicyFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4074,11 +3996,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_privacy_policy = resp.data.url; $scope.uploadFile.upay_privacy_policy = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_privacy_policy.endsWith('pdf')) { - $scope.privacyIsImage = false; - } else { - $scope.privacyIsImage = true; - } }, function (resp) { delete $scope.privacyFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4103,11 +4020,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.card_security_policy = resp.data.url; $scope.uploadFile.card_security_policy = resp.data.url; $scope.updateFile(); - if ($scope.file.card_security_policy.endsWith('pdf')) { - $scope.privacyIsImage = false; - } else { - $scope.privacyIsImage = true; - } }, function (resp) { delete $scope.cardFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4132,11 +4044,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_offer_letter = resp.data.url; $scope.uploadFile.upay_offer_letter = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_offer_letter.endsWith('pdf')) { - $scope.letterIsImage = false; - } else { - $scope.letterIsImage = true; - } }, function (resp) { delete $scope.letterFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4161,11 +4068,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_promotional_offer = resp.data.url; $scope.uploadFile.upay_promotional_offer = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_promotional_offer.endsWith('pdf')) { - $scope.promotionalIsImage = false; - } else { - $scope.promotionalIsImage = true; - } }, function (resp) { delete $scope.promotionalFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4190,11 +4092,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_terms_conditions = resp.data.url; $scope.uploadFile.upay_terms_conditions = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_terms_conditions.endsWith('pdf')) { - $scope.termsIsImage = false; - } else { - $scope.termsIsImage = true; - } }, function (resp) { delete $scope.termsFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4219,11 +4116,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.file.upay_desc_file = resp.data.url; $scope.uploadFile.upay_desc_file = resp.data.url; $scope.updateFile(); - if ($scope.file.upay_desc_file.endsWith('pdf')) { - $scope.descIsImage = false; - } else { - $scope.descIsImage = true; - } }, function (resp) { delete $scope.descFileProgress; commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) @@ -4297,6 +4189,24 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }; $scope.complianceChangeCheck(); + $scope.deleteMWComplianceFiles = function (file_id) { + commonDialog.confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?' + }).then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/mw_delete').then(function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success' + }); + $state.reload(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; + }]); app.controller('partnerKycFileCtrl', ['$scope', '$http', '$rootScope', 'commonDialog', '$state', 'Upload', 'file', function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { diff --git a/src/main/ui/static/payment/partner/templates/partner_mw_auth_files.html b/src/main/ui/static/payment/partner/templates/partner_mw_auth_files.html index ed93c1215..f5ce6cb1a 100644 --- a/src/main/ui/static/payment/partner/templates/partner_mw_auth_files.html +++ b/src/main/ui/static/payment/partner/templates/partner_mw_auth_files.html @@ -74,12 +74,24 @@ Upload - - - - + + + + + + + +
1 + + + +
@@ -91,12 +103,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -108,12 +132,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -125,12 +161,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -142,12 +190,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -159,12 +219,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -176,12 +248,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -193,12 +277,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -210,12 +306,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -227,12 +335,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -244,12 +364,24 @@ Upload -
- - - + + + + + + + +
1 + + + +
@@ -261,12 +393,24 @@ Upload -
- - - + + + + + + + +
1 + + + +