From 432ea24894ef33eca7386891d88c33187afe2e7e Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 28 Apr 2020 11:35:00 +0800 Subject: [PATCH] add citypartner support && upay application form --- .../impls/CityPartnerPrizeServiceImpl.java | 111 ++++-------------- .../beans/ClientMWAuthFilesInfo.java | 9 ++ .../core/impls/ClientManagerImpl.java | 1 + .../merchants/enums/UPayAuthFileEnum.java | 6 +- .../mappers/payment/TransactionMapper.xml | 4 +- .../static/payment/partner/partner-manage.js | 35 +++++- .../templates/partner_mw_auth_files.html | 17 +++ 7 files changed, 93 insertions(+), 90 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java index 349aa4013..50abd1285 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java @@ -1,88 +1,39 @@ package au.com.royalpay.payment.manage.citypartner.core.impls; -import java.io.IOException; -import java.io.OutputStream; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.swing.plaf.basic.BasicScrollPaneUI; - -import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.tools.CommonConsts; -import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.poi.hssf.usermodel.HSSFCellStyle; -import org.apache.poi.hssf.usermodel.HSSFFont; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.*; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.alibaba.fastjson.JSONObject; - import au.com.royalpay.payment.manage.citypartner.beans.AgentCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService; -import au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialSeniorPartnerCommissionDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialSeniorPartnerCommissionMapper; +import au.com.royalpay.payment.manage.mappers.financial.*; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; - +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import com.alibaba.fastjson.JSONObject; - import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; /** * Created by yixian on 2017-03-08. @@ -476,6 +427,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { BigDecimal total_surage = BigDecimal.ZERO; BigDecimal net_surage = BigDecimal.ZERO; BigDecimal royalpay_surage = BigDecimal.ZERO; + BigDecimal transaction_fee = BigDecimal.ZERO; JSONObject json = new JSONObject(); String channel = oneChannel.getKey(); if ("hf".equals(oneChannel.getKey().toLowerCase()) || "yeepay".equals(oneChannel.getKey().toLowerCase()) || "lakalapay".equals(oneChannel.getKey().toLowerCase())) { @@ -491,7 +443,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { for (JSONObject params : oneChannel.getValue()) { BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); - BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback")); + BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback")).subtract(params.getBigDecimal("transaction_fee")); //增加货币判断 int i = currencyScale(params.getString("clearing_currency")); total = total.add(tmpClearingAmount); @@ -499,11 +451,13 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP)); // net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); + transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } BigDecimal org_charge = total_surage.subtract(royalpay_surage); json.put("channel", oneChannel.getKey()); json.put("gross_amount", total); json.put("total_charge", total_surage); + json.put("transaction_fee", transaction_fee); json.put("net_charge", net_surage); json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); json.put("royalpay_charge", royalpay_surage); @@ -525,6 +479,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { BigDecimal net_surage = BigDecimal.ZERO; BigDecimal royalpay_surage = BigDecimal.ZERO; BigDecimal share_surage = BigDecimal.ZERO; + BigDecimal transaction_fee = BigDecimal.ZERO; JSONObject json = new JSONObject(); String channel = oneChannel.getKey(); @@ -534,7 +489,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { for (JSONObject params : oneChannel.getValue()) { BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); - BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback")); + BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback")).subtract(params.getBigDecimal("transaction_fee")); //增加货币判断 int i = currencyScale(params.getString("clearing_currency")); BigDecimal parent_surage = tmpClearingAmount.multiply(parentOrgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)).setScale(i, RoundingMode.HALF_UP); @@ -545,6 +500,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { //net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); share_surage = share_surage.add(roy_surage.subtract(parent_surage)).setScale(i, RoundingMode.HALF_UP); + transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } BigDecimal org_charge = total_surage.subtract(royalpay_surage); @@ -556,6 +512,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { json.put("partner_charge", royalpay_surage); json.put("share_charge", share_surage); json.put("org_charge", org_charge); + json.put("transaction_fee", transaction_fee); json.put("commission_type", "1"); json.put("create_time", new Date()); amountByChannel.add(json); @@ -579,6 +536,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { BigDecimal total_surage = BigDecimal.ZERO; BigDecimal net_surage = BigDecimal.ZERO; BigDecimal royalpay_surage = BigDecimal.ZERO; + BigDecimal transaction_fee = BigDecimal.ZERO; Date datefrom = new Date(); Date dateto = new Date(); JSONObject json = new JSONObject(); @@ -617,6 +575,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP)); //net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); + transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } BigDecimal org_charge = total_surage.subtract(royalpay_surage); if (channel.toLowerCase().equals("alipay_direct")) { @@ -642,6 +601,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { json.put("org_net_charge", net_surage); } json.put("org_charge", org_charge); + json.put("transaction_fee", transaction_fee); json.put("commission_type", "1"); json.put("create_time", new Date()); json.put("date_from", DateFormatUtils.format(datefrom, "yyyy-MM-dd")); @@ -825,6 +785,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { temp.put("total_charge", 0); temp.put("royalpay_charge", 0); temp.put("org_charge", 0); + temp.put("transaction_fee", 0); temp.put("share_charge", 0); temp.put("channel", channel.getString("channel")); temp.put("net_charge", 0); @@ -839,28 +800,8 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { mineCommission.put("share_charge", mineCommission.getBigDecimal("share_charge").subtract(channel.getBigDecimal("share_charge"))); financialPartnerCommissionMapper.update(mineCommission); } - channel.put("month", month); - channel.put("year", year); - channel.put("org_id", orgId); - //撤销agent表 -// financialAgentCommissionMapper.save(channel); } } - //撤销agent表 -// Map> groupByClientMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("client_id"))); -// for (Map.Entry> oneClient : groupByClientMap.entrySet()) { -// -// JSONObject org = orgMapper.findOne(oneClient.getValue().get(0).getInteger("org_id")); -// Map> groupByChannel = oneClient.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("channel"))); -// -// List clientChannelAmount = clientChannelAmount(oneClient.getKey(),org, groupByChannel, channelCharge,year,month,2); -// for (JSONObject channel : clientChannelAmount) { -// financialAgentCommissionDetailMapper.save(channel); -// } -// -// } - - } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientMWAuthFilesInfo.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientMWAuthFilesInfo.java index 45235245c..73f0db163 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientMWAuthFilesInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientMWAuthFilesInfo.java @@ -19,6 +19,7 @@ public class ClientMWAuthFilesInfo { private String kyc_utility_bill_file; private String upay_risk_level; private String upay_risk_remark; + private String upay_application_form; public JSONObject toJson(){ return (JSONObject)JSONObject.toJSON(this); @@ -130,4 +131,12 @@ public class ClientMWAuthFilesInfo { public void setKyc_utility_bill_file(String kyc_utility_bill_file) { this.kyc_utility_bill_file = kyc_utility_bill_file; } + + public void setUpay_application_form(String upay_application_form) { + this.upay_application_form = upay_application_form; + } + + public String getUpay_application_form() { + return upay_application_form; + } } 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 56088735f..1482ad7a6 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 @@ -3932,6 +3932,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateSysMWClientFiles(manager, clientId, UPayAuthFileEnum.UPAY_PROMOTIONAL_OFFER.getFileName(), filesInfo.getUpay_promotional_offer()); updateSysMWClientFiles(manager, clientId, UPayAuthFileEnum.UPAY_TERMS_CONDITIONS.getFileName(), filesInfo.getUpay_terms_conditions()); updateSysMWClientFiles(manager, clientId, UPayAuthFileEnum.KYC_UTILITY_BILL_FILE.getFileName(), filesInfo.getKyc_utility_bill_file()); + updateSysMWClientFiles(manager, clientId, UPayAuthFileEnum.UPAY_APPLICATION_FORM.getFileName(), filesInfo.getUpay_application_form()); } catch (Exception e) { logger.error("上传合规文件失败", e); } 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 992e1280c..202a44d5f 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 @@ -11,7 +11,8 @@ public enum UPayAuthFileEnum { UPAY_OFFER_LETTER("upay_offer_letter"), UPAY_PROMOTIONAL_OFFER("upay_promotional_offer"), UPAY_TERMS_CONDITIONS("upay_terms_conditions"), - KYC_UTILITY_BILL_FILE("kyc_utility_bill_file"); + KYC_UTILITY_BILL_FILE("kyc_utility_bill_file"), + UPAY_APPLICATION_FORM("upay_application_form"); private final String fileName; @@ -33,6 +34,7 @@ public enum UPayAuthFileEnum { UPAY_OFFER_LETTER.getFileName(), UPAY_PROMOTIONAL_OFFER.getFileName(), UPAY_TERMS_CONDITIONS.getFileName(), - KYC_UTILITY_BILL_FILE.getFileName()}; + KYC_UTILITY_BILL_FILE.getFileName(), + UPAY_APPLICATION_FORM.getFileName()}; } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index a4ee7285c..38e1504a7 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -940,6 +940,7 @@ t.transaction_time, if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount, if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge, + if(t.transaction_type = 'Credit', t.transaction_fee, -t.transaction_fee) transaction_fee, if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge, if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount, t.order_id, @@ -967,12 +968,13 @@ t.transaction_time, if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount, if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge, + if(t.transaction_type = 'Credit', t.transaction_fee, -t.transaction_fee) transaction_fee, if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge, if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount, t.order_id, t.org_rate, t.surcharge_cashback, - o.customer_surcharge + o.customer_surcharge, from pmt_transactions t LEFT JOIN pmt_orders o on o.order_id = t.order_id INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1 diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index db73e6dfc..6bc6cf720 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -3672,6 +3672,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.letterIsImage = true; $scope.promotionalIsImage = true; $scope.termsIsImage = true; + $scope.applicationIsImage = true; if ($scope.file.client_bank_file && $scope.file.client_bank_file.endsWith('pdf')) { $scope.bankIsImage = false; } @@ -3702,8 +3703,38 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter 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; + } + $scope.uploadApplicationFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.applicationFileProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + $scope.uploadFile = {}; + delete $scope.applicationFileProgress; + $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'}) + }, function (evt) { + $scope.applicationFileProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + } + } + }; $scope.uploadBankFile = function (file) { if (file != null) { if (file.size > 3 * 1024 * 1024) { 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 b3b301792..64e766aa7 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 @@ -65,6 +65,23 @@ +
+ +
+
+ + + +
+ + + + +
+