diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java index ad7970323..5ee09d9b7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java @@ -8,6 +8,8 @@ import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson.JSONObject; +import javax.servlet.http.HttpServletResponse; + /** * Created by yixian on 2017-02-07. */ @@ -40,4 +42,6 @@ public interface BDPrizeService { void deleteCommConfig(String config_id); void updateBdKpiConfig(List configs, JSONObject manager)throws ParseException; + + void exportCommissionMonth(String month, HttpServletResponse response) throws Exception; } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java index 98b16f2b1..741b3b17c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java @@ -5,12 +5,7 @@ import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService; import au.com.royalpay.payment.manage.bdprize.support.BDPrizeCalculator; import au.com.royalpay.payment.manage.bdprize.support.impls.BDPrizeCalculatorDefaultImpl; import au.com.royalpay.payment.manage.bdprize.support.impls.DefaultClientWithBDAwayDeterminor; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDCommissionConfigMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeRecordMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDRateConfigMapper; +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.ClientBDMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; @@ -27,6 +22,11 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds; 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.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +34,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.OutputStream; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -44,6 +45,7 @@ import java.util.GregorianCalendar; import java.util.List; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yixian on 2017-02-07. @@ -74,6 +76,8 @@ public class BDPrizeServiceImpl implements BDPrizeService { @Resource private FinancialBDCommissionConfigMapper financialBDCommissionConfigMapper; + @Resource + private FinancialLeaderPrizeLogMapper financialLeaderPrizeLogMapper; @Value("${app.backup-app:false}") private boolean backupSystem; @@ -239,54 +243,88 @@ public class BDPrizeServiceImpl implements BDPrizeService { // cityPrizeLog.put("total_prize", total_prize); // } // report.put("cityPrizeLogs", cityPrizeLog); - + List leaderPrizeLog = financialLeaderPrizeLogMapper.listLeaderPrizeLog(report.getString("record_id")); + if (leaderPrizeLog.size() > 0) { + for (JSONObject prizeLog : leaderPrizeLog) { + if (prizeLog.getIntValue("bd_type") == 3) { + report.put("sydneyPrizeLog", prizeLog); + } + if (prizeLog.getIntValue("bd_type") == 4) { + report.put("directPrizeLogs", prizeLog); + } + if (prizeLog.getIntValue("bd_type") == 5) { + report.put("ngDepartmentPrizeLog", prizeLog); + } + } + return report; + } //bd_type=3 悉尼分公司经理 悉尼销售组和大客户组流水提成 - - JSONObject sydneyPrizeLog = new JSONObject(); - BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear()); - sydneyPrizeLog.put("total_amount",sydneyAmount); - JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3); - if (sydneyGMRate == null) { - sydneyPrizeLog.put("total_prize", 0.00); - } else { - BigDecimal sydney_commission_rate = new BigDecimal(sydneyGMRate.getString("commission_rate")); - BigDecimal total_prize = sydneyAmount.multiply(sydney_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - sydneyPrizeLog.put("total_prize", total_prize); + if (!locker.lock(report.getString("record_id"), 300_000)) { + throw new ServerErrorException("Processing task, wait for a moment"); } - report.put("sydneyPrizeLog", sydneyPrizeLog); - - - //COO & NJ commission - JSONObject params = new JSONObject(); - params.put("begin", TimeZoneUtils.beginDate(TimeZoneUtils.getFirstDay(monthDate.toString()))); - params.put("end", TimeZoneUtils.getPerFirstDayOfMonth(TimeZoneUtils.getLastDay(monthDate.toString()))); - BigDecimal totalprize = transactionAnalysisMapper.analysisTotalAmount(params); + try { + List prizeLogList = new ArrayList<>(); + JSONObject sydneyPrizeLog = new JSONObject(); + BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear()); + sydneyPrizeLog.put("total_amount",sydneyAmount); + sydneyPrizeLog.put("bd_type", 3); + JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3); + if (sydneyGMRate == null) { + sydneyPrizeLog.put("total_prize", 0.00); + } else { + BigDecimal sydney_commission_rate = new BigDecimal(sydneyGMRate.getString("commission_rate")); + BigDecimal total_prize = sydneyAmount.multiply(sydney_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + sydneyPrizeLog.put("total_prize", total_prize); + } + report.put("sydneyPrizeLog", sydneyPrizeLog); + prizeLogList.add(sydneyPrizeLog); + + + //COO & NJ commission + JSONObject params = new JSONObject(); + params.put("begin", TimeZoneUtils.beginDate(TimeZoneUtils.getFirstDay(monthDate.toString()))); + params.put("end", TimeZoneUtils.getPerFirstDayOfMonth(TimeZoneUtils.getLastDay(monthDate.toString()))); + BigDecimal totalprize = transactionAnalysisMapper.analysisTotalAmount(params); + + JSONObject directPrizeLogs = new JSONObject(); + directPrizeLogs.put("total_amount", totalprize); + directPrizeLogs.put("bd_type", 4); + JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 4); + if (rate == null) { + directPrizeLogs.put("total_prize", 0.00); + } else { + BigDecimal _commission_rate = new BigDecimal(rate.getString("commission_rate")); + BigDecimal _total_amount = new BigDecimal(directPrizeLogs.getString("total_amount")); + BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + directPrizeLogs.put("total_prize", total_prize); + } + report.put("directPrizeLogs", directPrizeLogs); + prizeLogList.add(directPrizeLogs); + + JSONObject ngDepartmentPrizeLog = new JSONObject(); + ngDepartmentPrizeLog.put("total_amount", totalprize); + ngDepartmentPrizeLog.put("bd_type", 5); + JSONObject ngRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 5); + if (ngRate == null) { + ngDepartmentPrizeLog.put("total_prize", 0.00); + } else { + BigDecimal ng_commission_rate = new BigDecimal(ngRate.getString("commission_rate")); + BigDecimal ng_total_prize = totalprize.multiply(ng_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + ngDepartmentPrizeLog.put("total_prize", ng_total_prize); + } + report.put("ngDepartmentPrizeLog", ngDepartmentPrizeLog); + prizeLogList.add(ngDepartmentPrizeLog); - JSONObject directPrizeLogs = new JSONObject(); - directPrizeLogs.put("total_amount", totalprize); - JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 4); - if (rate == null) { - directPrizeLogs.put("total_prize", 0.00); - } else { - BigDecimal _commission_rate = new BigDecimal(rate.getString("commission_rate")); - BigDecimal _total_amount = new BigDecimal(directPrizeLogs.getString("total_amount")); - BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - directPrizeLogs.put("total_prize", total_prize); + for (JSONObject prizeLog : prizeLogList) { + prizeLog.put("record_id", report.getString("record_id")); + prizeLog.put("create_time", new Date()); + financialLeaderPrizeLogMapper.save(prizeLog); + } + return report; + } finally { + locker.unlock(report.getString("record_id")); } - report.put("directPrizeLogs", directPrizeLogs); - JSONObject ngDepartmentPrizeLog = new JSONObject(); - ngDepartmentPrizeLog.put("total_amount", totalprize); - JSONObject ngRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 5); - if (ngRate == null) { - ngDepartmentPrizeLog.put("total_prize", 0.00); - } else { - BigDecimal ng_commission_rate = new BigDecimal(ngRate.getString("commission_rate")); - BigDecimal ng_total_prize = totalprize.multiply(ng_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - ngDepartmentPrizeLog.put("total_prize", ng_total_prize); - } - report.put("ngDepartmentPrizeLog", ngDepartmentPrizeLog); - return report; } @Override @@ -469,4 +507,136 @@ public class BDPrizeServiceImpl implements BDPrizeService { financialBDConfigMapper.updateBDConfig(config); } } + + @Override + public void exportCommissionMonth(String month, HttpServletResponse resp) throws Exception { + OutputStream ous = null; + JSONObject report = findReport(month); + if (report != null) { + List logs = (List) report.get("logs"); + resp.setContentType("application/octet-stream;"); + resp.addHeader("Content-Disposition", "attachment; filename=" + "BD_Commission_Info_" + month + ".xls"); + ous = resp.getOutputStream(); + HSSFWorkbook wb = new HSSFWorkbook(); + Cell cell = null; + HSSFFont font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setFontHeightInPoints((short) 10); + CellStyle titleStyle = wb.createCellStyle(); + titleStyle.setFont(font); + HSSFCellStyle style = wb.createCellStyle(); + //设置背景颜色 + style.setFillForegroundColor(HSSFColor.RED.index); + //solid 填充 foreground 前景色 + style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + Sheet sheet = wb.createSheet("BD_Commission_Info_" + month); + sheet.setDefaultColumnWidth(20); + int rowNum = 0; + Row row = sheet.createRow(rowNum); + //bd and manager + String[] BDTitle = {"BD Name","KPI", "BD Level", "Transaction Amount", "Total Commission","Send Commission", "Hold prize", "Prize Type"}; + for (int i = 0; i < BDTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(BDTitle[i]); + } + for (JSONObject log : logs) { + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(log.getString("bd_name")); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("kpi_amount")==null?BigDecimal.ZERO.toPlainString():log.getBigDecimal("kpi_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(financialBdLevel(log.getIntValue("bd_level"))); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_amount").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_prize").toPlainString()); + row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("send_prize").toPlainString()); + row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("hold_prize").toPlainString()); + if (log.getIntValue("prize_type") == 0) { + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue("BD"); + } + if (log.getIntValue("prize_type") == 1) { + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue("Group"); + } + if (!log.getBoolean("is_valid")) { + for (int i = 0; i <= 7; i++) { + row.getCell(i).setCellStyle(style); + } + } + } + //analysis + String[] analysisTitle = {"month", "Total Commission", "Total Send", "Total Hold", "Total Fund"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < analysisTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(analysisTitle[i]); + } + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(month); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_prize").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_send_prize").toPlainString()); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_hold_prize").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_donation").toPlainString()); + //channel + String[] channelTitle = {"channel", "BD Total Commission", "BD Total Send", "BD Total Hold", "BD Total Fund"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < channelTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(channelTitle[i]); + } + for (String channel: channels) { + JSONObject channelReport = report.getJSONObject(channel + "Report"); + if (channelReport != null) { + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(channel); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_prize").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_send_prize").toPlainString()); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_hold_prize").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_donation").toPlainString()); + } + } + //Sydney GM & COO & NJ commission + String[] GMTitle = {"name", "Transaction Amount", "Total Commission"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < GMTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(GMTitle[i]); + } + JSONObject sydneyPrizeLog = report.getJSONObject("sydneyPrizeLog"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("Sydney GM"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(sydneyPrizeLog.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(sydneyPrizeLog.getBigDecimal("total_prize").toPlainString()); + + JSONObject ngDepartmentPrizeLog = report.getJSONObject("ngDepartmentPrizeLog"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("NJ Department"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(ngDepartmentPrizeLog.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(ngDepartmentPrizeLog.getBigDecimal("total_prize").toPlainString()); + + JSONObject directPrizeLogs = report.getJSONObject("directPrizeLogs"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("COO"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(directPrizeLogs.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(directPrizeLogs.getBigDecimal("total_prize").toPlainString()); + + wb.write(ous); + ous.flush(); + } + } + + private String financialBdLevel (int level) { + switch (level) { + case 0: + return "Leader"; + case 1: + return "Junior"; + case 2: + return "Intermediate"; + case 3: + return "Senior"; + default: + return "Unknown"; + } + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java index e3e75e552..d817e993e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java @@ -15,10 +15,12 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.io.IOException; import java.text.ParseException; import java.util.List; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yixian on 2017-02-07. @@ -97,4 +99,9 @@ public class BDPrizeController { public void updatKpiConfig(@PathVariable String month , @RequestBody List info , @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws ParseException { bdPrizeService.updateBdKpiConfig(info,manager); } + + @ManagerMapping(value = "/commission/export/{month}",method = RequestMethod.GET, role = {ManagerRole.SALES_MANAGER, ManagerRole.FINANCIAL_STAFF,ManagerRole.DIRECTOR, ManagerRole.ADMIN}) + public void exportCommissionMonth(@PathVariable String month, HttpServletResponse response) throws Exception { + bdPrizeService.exportCommissionMonth(month, response); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java new file mode 100644 index 000000000..412a9a1f3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java @@ -0,0 +1,11 @@ +package au.com.royalpay.payment.manage.management.sysconfig.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +public interface SysPaymentConfig { + List getPaymentChannel(); + + void updatePaymentChannel(JSONObject manager, String channel, int type); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java new file mode 100644 index 000000000..67d7af1ef --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java @@ -0,0 +1,34 @@ +package au.com.royalpay.payment.manage.management.sysconfig.core.impls; + +import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig; +import au.com.royalpay.payment.manage.mappers.system.RateMapper; +import au.com.royalpay.payment.manage.mappers.system.SysChannelConfigMapper; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +@Service +public class SysPaymentConfigImpl implements SysPaymentConfig { + @Resource + private SysChannelConfigMapper sysChannelConfigMapper; + + @Override + public List getPaymentChannel() { + return sysChannelConfigMapper.selectAll(); + } + + @Override + public void updatePaymentChannel(JSONObject manager, String channel, int type) { + JSONObject paymentConfig = sysChannelConfigMapper.find(channel, type); + if (paymentConfig == null) { + throw new BadRequestException("不存在该快捷通道"); + } + Date lastUpdateTime = new Date(); + sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), false); + sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), true); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java index 6aaea6373..1575ca76d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java @@ -1,17 +1,15 @@ package au.com.royalpay.payment.manage.management.sysconfig.web; import au.com.royalpay.payment.manage.management.sysconfig.core.ClearDateManager; +import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -27,6 +25,8 @@ public class SysConfigController { private SysConfigManager sysConfigManager; @Resource private ClearDateManager clearDateManager; + @Resource + private SysPaymentConfig sysPaymentConfig; @ManagerMapping(value = "/base", method = RequestMethod.GET) public JSONObject getBaseConfig() { @@ -48,8 +48,13 @@ public class SysConfigController { clearDateManager.setMonthClearDays(monthPattern, days); } + @ManagerMapping(value = "/payment/config", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.FINANCIAL_STAFF, ManagerRole.OPERATOR}) + public List selectPaymentChannel() { + return sysPaymentConfig.getPaymentChannel(); + } - public static void main(String[] args) { - System.out.println("asd".equals(null)); + @ManagerMapping(value = "/payment/{channel}/config/{type}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.FINANCIAL_STAFF, ManagerRole.OPERATOR}) + public void updatePaymentChannel(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String channel, @PathVariable int type) { + sysPaymentConfig.updatePaymentChannel(manager, channel, type); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java new file mode 100644 index 000000000..c52de5f97 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java @@ -0,0 +1,19 @@ +package au.com.royalpay.payment.manage.mappers.financial; + +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 = "financial_leader_prize_log", pkName = "leader_prize_log") +public interface FinancialLeaderPrizeLogMapper { + + @AutoSql(type = SqlType.SELECT) + List listLeaderPrizeLog(@Param(value = "record_id") String record_id); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject prizeLog); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java index 8f62c7c2b..cb60bf3df 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java @@ -30,4 +30,12 @@ public interface CouponAccuessLogMapper { List findCouponByOrderId(@Param("order_id") String order_id); PageList getCouponAccuessLog(@Param("client_id")int client_id, @Param("keyword")String keyword, PageBounds pageBounds); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 0") + List findAccuessLogByOrderId(@Param("order_id") String order_id, PageBounds pageBounds); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 1") + List findUsedCouponByOrderIdList(@Param("order_id") String order_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java new file mode 100644 index 000000000..2d4eb5549 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java @@ -0,0 +1,24 @@ +package au.com.royalpay.payment.manage.mappers.system; + +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.Date; +import java.util.List; + +@AutoMapper(tablename = "cb_channel_config",pkName = "channel_id") +public interface SysChannelConfigMapper { + @AutoSql(type = SqlType.SELECT) + List selectAll(); + + @AutoSql(type = SqlType.SELECT) + JSONObject find(@Param(value = "channel_id") String channel, @Param(value = "type") int type); + + void updatePaymentConfig(@Param(value = "channel_id") String channel, @Param(value = "type") int type, @Param(value = "last_update_date")Date lastUpdateDate, + @Param(value = "last_update_by")String lastUpdateBy, @Param(value = "is_valid") boolean is_valid); + + JSONObject findOne(@Param(value = "type") int type); +} 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 82976ea57..c1ca75c61 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 @@ -271,7 +271,7 @@ public interface ClientManager { void updateAppClient(JSONObject account,int client_id, AppClientBean appClientBean); - void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing); + void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing,String remark); void enableGatewayUpgrade(JSONObject account,String clientMoniker, boolean gatewayUpgrade); @@ -369,4 +369,13 @@ public interface ClientManager { JSONObject comListPartnerSelection(JSONObject manager, PartnerQuery query); List getClientBySimpleQuery(JSONObject param); + + void switchPaymentConfig(String clientMoniker, HttpServletResponse response) throws IOException; + + @Transactional + void switchCBBankLink(JSONObject manager, String clientMoniker, boolean allow); + + String cbBankPayLink(String clientMoniker); + + void switchPaymentConfigPC(String clientMoniker, HttpServletResponse response) throws IOException; } 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 bc15a15cf..a809bffdb 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 @@ -27,25 +27,7 @@ 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; import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; -import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper; -import au.com.royalpay.payment.manage.mappers.system.MailSendMapper; -import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper; -import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; -import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper; -import au.com.royalpay.payment.manage.mappers.system.SysRpayMerchantApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; +import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; @@ -313,6 +295,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private PermissionPartnerManagerImpl permissionPartnerManagerImpl; @Resource private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper; + @Resource + private SysChannelConfigMapper sysChannelConfigMapper; @Resource private SmsSender smsSender; @@ -445,6 +429,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid String yeepayQrcodeUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/yeepay/partners/" + client.getString("client_moniker") + "/jump/app"); client.put("yeepayQrcodeUrl", QRCodeUtils.qrcodeImageCode(yeepayQrcodeUrl, 250, true)); } + if (client.getString("cb_bankpay_url") != null) { + String cbBankPayQrcodeUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link"); + client.put("cbBankPayQrcodeUrl", QRCodeUtils.qrcodeImageCode(cbBankPayQrcodeUrl, 250, true)); + } return client; } @@ -1244,7 +1232,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) { for (PaymentChannelApi channelApi : channels) { - if (channelApi.channel().equalsIgnoreCase(channel)) { + if (channelApi.channel().equalsIgnoreCase(channel) || "CB_BankPay".equalsIgnoreCase(channel)) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new NotFoundException("Client Not Exists"); @@ -1553,6 +1541,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (PaymentChannelApi channel : channels) { rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), channel.channel(), includingInactive)); } + rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), "CB_BankPay", includingInactive)); if (!rates.isEmpty()) { try { for (JSONObject rate : rates) { @@ -1624,20 +1613,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkAddRate(config, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); checkAddRate(config, "Bestpay", "bestpay_rate_value", org, "min_bestpay_rate"); checkAddRate(config, "jd", "jd_rate_value", org, "min_jd_rate"); - checkAddRate(config, "hf", "hf_rate_value", org, "min_hf_rate"); +// checkAddRate(config, "hf", "hf_rate_value", org, "min_hf_rate"); checkAddRate(config, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); - checkAddRate(config, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); +// checkAddRate(config, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); + checkAddRate(config, "CB_BankPay", "min_cb_bankpay_value", org, "min_cb_bankpay_rate"); configNewClientRate(config, clientId, "Wechat", "wechat_rate_value", org, "min_wechat_rate"); configNewClientRate(config, clientId, "Alipay", "alipay_rate_value", org, "min_alipay_rate"); configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value", org, "min_bestpay_rate"); configNewClientRate(config, clientId, "jd", "jd_rate_value", org, "min_jd_rate"); - configNewClientRate(config, clientId, "hf", "hf_rate_value", org, "min_hf_rate"); +// configNewClientRate(config, clientId, "hf", "hf_rate_value", org, "min_hf_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); - configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); +// configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); + configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); //todo 暂不更新Rpay+ 费率信息 - rpayApi.modifySurchargeConfig(client); + //rpayApi.modifySurchargeConfig(client); } @@ -3234,12 +3225,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Transactional - public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing) { + public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing,String remark) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); } clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "skip_clearing", skip_clearing)); + + if (!skip_clearing) { + if ("".equals(remark) || remark==null){ + throw new ServerErrorException("请填写关闭清算原因"); + } + JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); + clientConfig.put("skip_settle_remark", remark); + clientConfigMapper.update(clientConfig); + } + + client.put("skip_clearing", skip_clearing); if (client.getString("rpay_enterprise_id") != null) { rpayApi.switchMerchantSettle(client); @@ -4257,6 +4259,65 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return PageListUtils.buildPageListResult(partners); } + @Override + public void switchPaymentConfig(String clientMoniker, HttpServletResponse response) throws IOException { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(paymentConfig.getString("path")), clientMoniker)); + } + + @Override + public void switchCBBankLink(JSONObject manager, String clientMoniker, boolean allow) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + if (StringUtils.isEmpty(client.getString("cb_bankpay_url"))) { + String longUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link/pc"); + String cb_bankpay_url = getCBBankShortLink(longUrl); + client.put("cb_bankpay_url", cb_bankpay_url); + client.put("enable_cb_bankpay_link", allow); + clientMapper.update(client); + } else { + client.put("enable_cb_bankpay_link", allow); + clientMapper.update(client); + } + } + + @Override + public String cbBankPayLink(String clientMoniker) { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + return String.format(PlatformEnvironment.getEnv().concatUrl(paymentConfig.getString("path")), clientMoniker); + } + + @Override + public void switchPaymentConfigPC(String clientMoniker, HttpServletResponse response) throws IOException { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + String path = paymentConfig.getString("path"); + path = path.replaceAll("app","pc"); + response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(path), clientMoniker)); + } private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); @@ -4281,4 +4342,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid }).start(); } + private String getCBBankShortLink(String longUrl) { + MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); + return api.registerShortUrl(longUrl); + } } 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 7bb29b70d..3b9dcdb6d 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 @@ -367,7 +367,7 @@ public class PartnerManageController { @ManagerMapping(value = "/{clientMoniker}/skip_clearing", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}) public void skipClearing(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject skip_clearing) { - clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing")); + clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing"),skip_clearing.getString("remark")); } @ManagerMapping(value = "/{clientMoniker}/settle_hour", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF}) @@ -621,4 +621,24 @@ public class PartnerManageController { return clientManager.comListPartnerSelection(manager, query); } + + @RequestMapping(value = "/{clientMoniker}/cb_bankpay/link", method = RequestMethod.GET) + public void switchPaymentWay(@PathVariable String clientMoniker, HttpServletResponse response) throws IOException { + clientManager.switchPaymentConfig(clientMoniker, response); + } + + @ManagerMapping(value = "/{clientMoniker}/cb_bankpay", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void switchCBBankPayLinkPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.switchCBBankLink(manager, clientMoniker, pass.getBooleanValue("allow")); + } + + @RequestMapping(value = "/{clientMoniker}/jump/link", method = RequestMethod.GET) + public String jumpCBBankPayLink(@PathVariable String clientMoniker) { + return clientManager.cbBankPayLink(clientMoniker); + } + + @RequestMapping(value = "/{clientMoniker}/cb_bankpay/link/pc", method = RequestMethod.GET) + public void switchPaymentWayPC(@PathVariable String clientMoniker, HttpServletResponse response) throws IOException { + clientManager.switchPaymentConfigPC(clientMoniker, response); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java index 772911b27..e65588da3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java @@ -30,6 +30,7 @@ public class OrgInfo { private Double jd_rate_value; private Double hf_rate_value; private Double yeepay_rate_value; + private Double cb_bankpay_rate_value; private int is_valid; private String search_text; private int page = 1; @@ -44,6 +45,7 @@ public class OrgInfo { private Double min_alipayonline_rate; private Double min_hf_rate; private Double min_yeepay_rate; + private Double min_cb_bankpay_rate; private String state; private String senior_parent_org_id; @@ -341,4 +343,20 @@ public class OrgInfo { public void setMin_yeepay_rate(Double min_yeepay_rate) { this.min_yeepay_rate = min_yeepay_rate; } + + public Double getCb_bankpay_rate_value() { + return cb_bankpay_rate_value; + } + + public void setCb_bankpay_rate_value(Double cb_bankpay_rate_value) { + this.cb_bankpay_rate_value = cb_bankpay_rate_value; + } + + public Double getMin_cb_bankpay_rate() { + return min_cb_bankpay_rate; + } + + public void setMin_cb_bankpay_rate(Double min_cb_bankpay_rate) { + this.min_cb_bankpay_rate = min_cb_bankpay_rate; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java new file mode 100644 index 000000000..c11c56ba5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java @@ -0,0 +1,194 @@ +package au.com.royalpay.payment.manage.processors; + +import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.coupon.CouponInfo; +import au.com.royalpay.payment.core.events.PaymentFinishedEvent; +import au.com.royalpay.payment.core.events.RefundSendEvent; +import au.com.royalpay.payment.core.processors.PaymentProcessor; +import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.env.SysConfigManager; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Service +public class CtripCouponOnlyLogProcessor implements PaymentProcessor { + + // todo 重构逻辑 + private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass()); + + + private static final String COUPON_ID = "CTRIP_COUPON_ONLY_LOG"; + + @Value("${app.customer.host}") + private String CUSTOMER_HOST; + + @Value("${customer.app.appid}") + private String CUSTOMER_APP_ID; + + @Value("${customer.app.auth-code}") + private String CUSTOMER_AUTH_CODE; + + @Resource + private MerchantInfoProvider merchantInfoProvider; + + @Resource + private SysConfigManager sysConfigManager; + + @Resource + private CouponAccuessLogMapper payCouponAccuessLogMapper; + @Resource + private PaymentApi paymentApi; + @Override + public String processorId() { + return COUPON_ID + "_USE"; + } + + @Override + public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) { + JSONObject tmpEle = paymentInfo.getTmpEle(); + if (tmpEle == null) { + return; + } + if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) { + return; + } + if (!isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id")); + if (couponInfo == null) { + return; + } + BigDecimal payFee = paymentInfo.getTotalFee(); + BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); + } + BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO + : couponInfo.getBigDecimal("condition"); + if (payFee.compareTo(couponCondition) < 0) { + return; + } + JSONObject couponAccuessLog = new JSONObject(); + couponAccuessLog.put("client_id",order.getIntValue("client_id")); + couponAccuessLog.put("customer_openid","创建订单时无"); + couponAccuessLog.put("creation_date",new Date()); + couponAccuessLog.put("order_id",order.getString("order_id")); + couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id")); + //携程满减 + if (StringUtils.equals(couponInfo.getString("type"), "31")) { + BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); + } + couponAccuessLog.put("coupon_deal_amount", actureAmount); + } + //携程折扣 + if (StringUtils.equals(couponInfo.getString("type"), "32")) { + BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP); + BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency()); + couponAccuessLog.put("coupon_deal_amount", couponDealAmount); + } + couponAccuessLog.put("currency", order.getString("currency")); + couponAccuessLog.put("min_pay_amount", couponCondition); + payCouponAccuessLogMapper.save(couponAccuessLog); + } + + @Override + public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) { + JSONObject order = finishedEvent.getOrder(); + String orderId = order.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))); + if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) { + if (!isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + String couponLogId = accuessCouponLog.getString("coupon_id"); + logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]"); + accuessCouponLog.put("is_valid", 1); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("customer_openid",order.getString("customer_id")); + + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + + @Override + public void registerCoupon(JSONObject client, String customerOpenId, String channel, List coupons) { + return; + } + + @Override + public void handleAfterRefund(RefundSendEvent event) { + //do nothing + JSONObject refundOrder = event.getRefundOrder(); + String orderId = refundOrder.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId); + if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) { + if (!isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + accuessCouponLog.put("is_valid", 0); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("refund_id",refundOrder.getString("refund_id")); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + + @Override + public String registerBanner(JSONObject client, String channel) { + return null; + } + + // 使用券的信息 + private JSONObject getPreOrderCoupon(String couponLogId,int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + String timestamp = System.currentTimeMillis() + ""; + String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE; + String sign = DigestUtils.sha256Hex(base).toLowerCase(); + String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID) + .queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString(); + HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET); + try { + HttpRequestResult result = gen.execute(); + if (result.isSuccess()) { + return result.getResponseContentJSONObj(); + } + } catch (Exception ignored) { + logger.error("积分商城优惠券 [" + couponLogId + "]使用失败"); + ignored.printStackTrace(); + } + return null; + } + + private boolean isOnlyLogMerchant(int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) { + return true; + } + return false; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java new file mode 100644 index 000000000..1354d7813 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java @@ -0,0 +1,266 @@ +package au.com.royalpay.payment.manage.processors; + +import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.core.beans.PaymentQueryResult; +import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.coupon.CouponInfo; +import au.com.royalpay.payment.core.events.PaymentFinishedEvent; +import au.com.royalpay.payment.core.events.RefundSendEvent; +import au.com.royalpay.payment.core.mappers.PmtOrderMapper; +import au.com.royalpay.payment.core.processors.PaymentProcessor; +import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.env.SysConfigManager; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Service +public class CtripCouponProvideProcessor implements PaymentProcessor { + + // todo 重构逻辑 + private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass()); + + + private static final String COUPON_ID = "CTRIP_COUPON"; + + @Value("${app.customer.host}") + private String CUSTOMER_HOST; + + @Value("${customer.app.appid}") + private String CUSTOMER_APP_ID; + + @Value("${customer.app.auth-code}") + private String CUSTOMER_AUTH_CODE; + + @Resource + private MerchantInfoProvider merchantInfoProvider; + @Resource + private SysConfigManager sysConfigManager; + @Resource + private CouponAccuessLogMapper payCouponAccuessLogMapper; + @Resource + private PaymentApi paymentApi; + @Resource + private PmtOrderMapper pmtOrderMapper; + @Resource + private TransactionService transactionService; + @Override + public String processorId() { + return COUPON_ID + "_USE"; + } + + @Override + public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) { + /*if (order.getIntValue("client_id") != 9) { + return; + }*/ + JSONObject tmpEle = paymentInfo.getTmpEle(); + if (tmpEle == null) { + return; + } + if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) { + return; + } + logger.info("tmpEle:" + tmpEle.toJSONString()); + if (isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id")); + if (couponInfo == null) { + return; + } + BigDecimal payFee = paymentInfo.getTotalFee(); + BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); + } + BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO + : couponInfo.getBigDecimal("condition"); + if (payFee.compareTo(couponCondition) < 0) { + return; + } + JSONObject couponAccuessLog = new JSONObject(); + couponAccuessLog.put("client_id",order.getIntValue("client_id")); + couponAccuessLog.put("customer_openid","创建订单时无"); + couponAccuessLog.put("creation_date",new Date()); + couponAccuessLog.put("order_id",order.getString("order_id")); + couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id")); + BigDecimal currentDiscount = paymentInfo.getDiscount(); + //携程满减 + if (StringUtils.equals(couponInfo.getString("type"), "31")) { + BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); + } + paymentInfo.setDiscount(currentDiscount.add(actureAmount)); + couponAccuessLog.put("coupon_deal_amount", actureAmount); + } + //携程折扣 + if (StringUtils.equals(couponInfo.getString("type"), "32")) { + BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP); + BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency()); + paymentInfo.setDiscount(currentDiscount.add(couponDealAmount)); + couponAccuessLog.put("coupon_deal_amount", couponDealAmount); + } + couponAccuessLog.put("currency", order.getString("currency")); + couponAccuessLog.put("min_pay_amount", couponCondition); + payCouponAccuessLogMapper.save(couponAccuessLog); + + JSONObject updateOrder = new JSONObject(); + BigDecimal customerPay = paymentInfo.getUserPayAmount(); + updateOrder.put("customer_payment_amount", customerPay); + BigDecimal couponDiscount = paymentInfo.getDiscount(); + updateOrder.put("coupon_payment_amount", couponDiscount); + updateOrder.put("order_id", paymentInfo.getOrderId()); + + pmtOrderMapper.update(updateOrder); + + order.put("customer_payment_amount", customerPay); + order.put("coupon_payment_amount", couponDiscount); + } + + @Override + public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) { + JSONObject order = finishedEvent.getOrder(); + /*if (order.getIntValue("client_id") != 9) { + return; + }*/ + String orderId = order.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))); + if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) { + if (isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + String couponLogId = accuessCouponLog.getString("coupon_id"); + logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]"); + + //传入流水 + JSONObject useCoupontrans = new JSONObject(); + useCoupontrans.put("org_id", order.getIntValue("org_id")); + useCoupontrans.put("system_transaction_id", accuessCouponLog.getString("accuess_id")); + useCoupontrans.put("order_id", order.getString("order_id")); + useCoupontrans.put("client_id", order.getIntValue("client_id")); + useCoupontrans.put("transaction_currency", order.getString("currency")); + if (StringUtils.equals(order.getString("currency"), "CNY")) { + useCoupontrans.put("cny_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + } + useCoupontrans.put("clearing_currency", PlatformEnvironment.getEnv().getForeignCurrency()); + useCoupontrans.put("clearing_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + useCoupontrans.put("transaction_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + useCoupontrans.put("exchange_rate", finishedEvent.getExchangeRate()); + useCoupontrans.put("channel", order.getString("channel")); + useCoupontrans.put("transaction_type", "Credit"); + PaymentQueryResult pay = finishedEvent.getPaymentQueryResult(); + useCoupontrans.put("transaction_time", pay.getPayTime()); + useCoupontrans.put("clearing_status", 0); + useCoupontrans.put("system_generate", 1); + useCoupontrans.put("remark", "Ctrip Coupon from Customer:" + couponLogId); + accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId,new PageBounds(Order.formString("last_update_date.desc"))).get(0); + if (accuessCouponLog != null) { + transactionService.saveTransaction(useCoupontrans); + accuessCouponLog.put("is_valid", 1); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("transaction_id", useCoupontrans.getString("transaction_id")); + accuessCouponLog.put("customer_openid",order.getString("customer_id")); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + + } + } + + @Override + public void registerCoupon(JSONObject client, String customerOpenId, String channel, List coupons) { + return; + } + + @Override + public void handleAfterRefund(RefundSendEvent event) { + //do nothing + JSONObject refundOrder = event.getRefundOrder(); + /*if (refundOrder.getIntValue("client_id") != 9) { + return; + }*/ + logger.info("积分商城携程优惠券开始退款"); + String orderId = refundOrder.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId); + if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) { + if (isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + JSONObject trans = transactionService.findTransaction(accuessCouponLog.getString("transaction_id")); + if (trans != null) { + logger.info("正在退款的券的初始信息" + trans.toJSONString()); + trans.remove("transaction_id"); + trans.put("transaction_type", "Debit"); + String coupon_id = accuessCouponLog.getString("coupon_id"); + trans.put("refund_id", refundOrder.getString("refund_id")); + trans.put("transaction_time", new Date()); + trans.put("remark", "Refund for Customer Ctrip Coupon:" + coupon_id); + logger.info("正在退款的券的信息" + trans.toJSONString()); + transactionService.saveTransaction(trans); + logger.error("订单[" + orderId + "]发送全额退款,携程优惠券【" + coupon_id + "】转为Debit"); + accuessCouponLog.put("transaction_refund_id", trans.getString("transaction_id")); + accuessCouponLog.put("refund_id", refundOrder.getString("refund_id")); + accuessCouponLog.put("is_valid", 0); + accuessCouponLog.put("last_update_date", new Date()); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + } + + @Override + public String registerBanner(JSONObject client, String channel) { + return null; + } + + // 使用券的信息 + private JSONObject getPreOrderCoupon(String couponLogId,int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + String timestamp = System.currentTimeMillis() + ""; + String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE; + String sign = DigestUtils.sha256Hex(base).toLowerCase(); + String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID) + .queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString(); + HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET); + try { + HttpRequestResult result = gen.execute(); + if (result.isSuccess()) { + return result.getResponseContentJSONObj(); + } + } catch (Exception ignored) { + logger.error("积分商城优惠券 [" + couponLogId + "]使用失败"); + ignored.printStackTrace(); + } + return null; + } + + private boolean isOnlyLogMerchant(int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) { + return true; + } + return false; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java index 74a62881f..88168752b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java @@ -126,6 +126,8 @@ public interface RiskBusinessService { */ JSONObject getRiskEventMaterialsRemark(String riskId); + void banRiskEvent(String riskId); + JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager); JSONObject updateIsSendClient(String riskId); diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index 22f4494ac..b6065a86a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -335,7 +335,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } private void setRiskOrders(JSONObject params){ - if(StringUtils.isNotBlank(params.getString("order_ids"))){ + if(StringUtils.isNotBlank(params.getString("real_order_ids"))){ String riskId = params.getString("risk_id"); String orderIds = params.getString("real_order_ids"); for(String orderId : orderIds.split(",")){ @@ -980,6 +980,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo return result; } + @Override + public void banRiskEvent(String riskId) { + JSONObject params = new JSONObject(); + params.put("risk_id",riskId); + params.put("is_valid",0); + riskEventMapper.update(params); + } + @Transactional @Override public JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager) { diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java index b589de9fb..ef501dec0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java @@ -151,6 +151,11 @@ public class RiskBusinessController { riskBusinessService.sendUrgeEmail(risk_id); } + @RequestMapping(value = "/ban/{risk_id}",method = RequestMethod.DELETE) + public void banEvent(@PathVariable String risk_id){ + riskBusinessService.banRiskEvent(risk_id); + } + @GetMapping(value = "/partners") public List getPartners(PartnerQuery partnerQuery) { JSONObject param = partnerQuery.toJsonParam(); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml index 24f56ef19..a62886d13 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml @@ -11,7 +11,8 @@ r.*,l.kpi_amount, sum(total_prize) total_prize, sum(send_prize) total_send_prize, - sum(total_donation) total_donation + sum(total_donation) total_donation, + sum(hold_prize) total_hold_prize FROM financial_bd_prize_records r INNER JOIN financial_bd_prize_log l ON l.record_id = r.record_id WHERE r.month = #{month} @@ -20,7 +21,8 @@ SELECT sum(total_prize) total_prize, sum(send_prize) total_send_prize, - sum(total_donation) total_donation + sum(total_donation) total_donation, + sum(hold_prize) total_hold_prize FROM financial_bd_prize_log WHERE record_id = #{record_id} AND channel = #{channel} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml index e188bec19..5ce07e53d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml @@ -51,6 +51,7 @@ ON sc.client_id = scb.client_id + re.is_valid = 1 AND re.risk_id = #{risk_id} @@ -175,6 +176,7 @@ ON re.risk_id = ro.risk_id + re.is_valid = 1 AND re.risk_id = #{risk_id} @@ -257,6 +259,7 @@ ) ro ON re.risk_id = ro.risk_id + re.is_valid = 1 AND re.risk_id = #{risk_id} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml new file mode 100644 index 000000000..a7bc1b1af --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml @@ -0,0 +1,20 @@ + + + + + update cb_channel_config + SET is_valid = #{is_valid},last_update_by = #{last_update_by},last_update_date = #{last_update_date} + + type = #{type} + + and channel_id = #{channel_id} + + + and channel_id != #{channel_id} + + + + + \ No newline at end of file diff --git a/src/main/ui/static/analysis/risk_business.js b/src/main/ui/static/analysis/risk_business.js index 29aa25c7c..9e4c5a1c8 100644 --- a/src/main/ui/static/analysis/risk_business.js +++ b/src/main/ui/static/analysis/risk_business.js @@ -292,6 +292,20 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], orderChannel = null; } + $scope.deleteRiskEvent = function () { + commonDialog.confirm({ + title: 'Delete This Risk Event', + content: 'Are you sure to delete this risk event?' + }).then(function () { + $http.delete('/risk/business/ban/' + $scope.riskEvent.risk_id).then(function () { + $state.go('analysis_monitoring.risk_business'); + commonDialog.alert({title: 'Delete', content: 'Risk Event Already Disabled', type: 'error'}); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; + /** * order_ids在指定位置换行 * @param str diff --git a/src/main/ui/static/analysis/templates/riskEvent_detail.html b/src/main/ui/static/analysis/templates/riskEvent_detail.html index 08917465a..229b61246 100644 --- a/src/main/ui/static/analysis/templates/riskEvent_detail.html +++ b/src/main/ui/static/analysis/templates/riskEvent_detail.html @@ -9,6 +9,9 @@ +
+ +
diff --git a/src/main/ui/static/config/bdprize/bdprize.js b/src/main/ui/static/config/bdprize/bdprize.js index c44b807b9..b5d76ee4e 100644 --- a/src/main/ui/static/config/bdprize/bdprize.js +++ b/src/main/ui/static/config/bdprize/bdprize.js @@ -141,6 +141,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) { } } }) + }; + $scope.exportCommission = function (monModal) { + location.href = '/sys/bd_prize/commission/export/' + monModal; } }]); app.controller('bdRateConfigCtrl', ['$scope', '$http', 'rates', function ($scope, $http, rates) { diff --git a/src/main/ui/static/config/bdprize/templates/bd_prize_root.html b/src/main/ui/static/config/bdprize/templates/bd_prize_root.html index e39214443..c7e5c591d 100644 --- a/src/main/ui/static/config/bdprize/templates/bd_prize_root.html +++ b/src/main/ui/static/config/bdprize/templates/bd_prize_root.html @@ -49,18 +49,20 @@
- diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html index a9d931c59..023fb7319 100644 --- a/src/main/ui/static/config/organizations/templates/new_org.html +++ b/src/main/ui/static/config/organizations/templates/new_org.html @@ -179,7 +179,7 @@
-
@@ -190,8 +190,8 @@ %
- -
--> + +
+ +
+
+ + % +
+
@@ -267,7 +279,7 @@ -
@@ -278,8 +290,8 @@ %
- -
--> + +
+ +
+
+ + % +
+
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 b87d465dc..df2f98844 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -152,7 +152,7 @@ % -
+ +
+ +
+ + % +
@@ -218,7 +225,7 @@ % -
@@ -235,6 +242,15 @@ id="min_yeepay_rate_input" name="min_yeepay_rate" max="100" min="0"> %
+
--> +
+ +
+ + % +
diff --git a/src/main/ui/static/config/sysconfigs/sysconfigs.js b/src/main/ui/static/config/sysconfigs/sysconfigs.js index bb71c95ce..a8a32ea2a 100644 --- a/src/main/ui/static/config/sysconfigs/sysconfigs.js +++ b/src/main/ui/static/config/sysconfigs/sysconfigs.js @@ -13,6 +13,10 @@ define(['angular', 'uiRouter'], function (angular) { url: '/basic', templateUrl: '/static/config/sysconfigs/templates/basic.html', controller: 'basicConfigCtrl' + }).state('sysconfig.payment_bankpay_config', { + url: '/payment', + templateUrl: '/static/config/sysconfigs/templates/payment_bankpay_config.html', + controller: 'paymentChannelConfigCtrl' }).state('permission', { url: '/permission', templateUrl: '/static/config/sysconfigs/templates/permission_config.html', @@ -66,6 +70,51 @@ define(['angular', 'uiRouter'], function (angular) { }]); + app.controller('paymentChannelConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { + $scope.loadPaymentChannel = function () { + $scope.cb_bankpay_channel = null; + $scope.pay_channel = null; + $scope.cb_bankpay = []; + $scope.pay = []; + $http.get('/sysconfig/payment/config').then(function (resp) { + resp.data.forEach(function (channel) { + if (channel.type === 1) { + if (channel.is_valid) { + $scope.cb_bankpay_channel = channel.channel_id; + } + $scope.cb_bankpay.push(channel); + } + if (channel.type === 2) { + if (channel.is_valid) { + $scope.pay_channel = channel.channel_id; + } + $scope.pay.push(channel); + } + + }) + }) + }; + $scope.loadPaymentChannel(); + $scope.updatePaymentConfig = function (type,channel) { + if (channel == null) { + commonDialog.alert({type: 'error', title: 'Error', content: '支付通道不能为空'}); + return; + } + commonDialog.confirm({ + title: 'Confirm', + content: '你确定要将支付通道更改为:' + channel + }).then(function () { + $http.put('/sysconfig/payment/'+ channel + '/config/' + type).then(function (resp) { + commonDialog.alert({type: 'success', title: 'Success', content: '修改成功'}); + $scope.loadPaymentChannel(); + }, function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}); + $scope.loadPaymentChannel(); + }); + }) + } + }]); + app.controller('servantsConfigCtrl', ['$scope','$http','commonDialog', function ($scope,$http,commonDialog) { $scope.ctrl={}; $scope.loadServants = function () { diff --git a/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html b/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html new file mode 100644 index 000000000..da1e8d5e6 --- /dev/null +++ b/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html @@ -0,0 +1,40 @@ +
+

Basic Config

+ +
+ +
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+
+
+
diff --git a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html index 970daaa5e..d48cbb4c3 100644 --- a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html +++ b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html @@ -35,10 +35,10 @@ - + diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 6a11acef0..64372f1d9 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1318,6 +1318,16 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}); } }; + $scope.copyCBBankPayLink = function() { + var e=document.getElementById("cpcbbankpay"); + e.select(); + var successful = document.execCommand("Copy"); + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}); + }else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}); + } + }; $scope.loadPartnerPaymentInfo = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { $scope.paymentInfo = resp.data; @@ -1624,6 +1634,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }; + $scope.toggleCBBankPayLink = function () { + if (!$scope.paymentInfo) { + return; + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', {allow: $scope.paymentInfo.enable_cb_bankpay_link}).then(function () { + $scope.loadPartnerPaymentInfo(); + }, function (resp) { + commonDialog.alert({ + title: 'Failed to change cb_bankpay permission status', + content: resp.data.message, + type: 'error' + }); + }) + }; + $scope.toggleGatewayEmailNotice = function (channel) { if (!$scope.paymentInfo) { return; @@ -1887,7 +1912,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.loadSubClients(); }]); - app.controller('partnerRatesCtrl', ['$scope', '$rootScope', '$http', '$uibModal', 'commonDialog', function ($scope, $rootScope, $http, $uibModal, commonDialog) { + app.controller('partnerRatesCtrl', ['$scope', '$rootScope', '$http', '$uibModal', 'commonDialog','$sce', function ($scope, $rootScope, $http, $uibModal, commonDialog,$sce) { $scope.bankCtrl = {edit: true, rate_name: 'Wechat'}; $scope.init = {skip_clearing:false,tax_in_surcharge:false,customer_tax_free:false}; $scope.getBankAccount = function () { @@ -1906,19 +1931,39 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }); }; + $scope.skipClearing = function (skipClearing) { if (!$scope.init.skip_clearing) { $scope.init.skip_clearing = true; return; } - commonDialog.confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?' - }).then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { - $scope.getBankAccount(); - }); - }) + if (!skipClearing) { + commonDialog.confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?' + }).then(function () { + commonDialog.inputText({title: '请输入关闭跳过清算的原因'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { + skip_clearing: skipClearing, + remark: text + }).then(function (resp) { + $scope.getBankAccount(); + }); + }); + }) + }else{ + commonDialog.confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') + }).then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { + $scope.getBankAccount(); + }); + }) + } + + }; $scope.taxInSurcharge = function (taxInSurcharge) { if (!$scope.init.tax_in_surcharge) { @@ -2067,6 +2112,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t1.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t1.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t1.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t1.CB_Bankpay); $scope.rate.transaction_fee = 0; break; } @@ -2079,6 +2125,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t2.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t2.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t2.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t2.CB_Bankpay); $scope.rate.transaction_fee = 0; break; } @@ -2091,6 +2138,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t3.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t3.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t3.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t3.CB_Bankpay); $scope.rate.transaction_fee = 0; break; } diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index 5385003d5..2f51eed68 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -170,9 +170,10 @@
  • Alipay(Online)
  • Bestpay
  • JDpay
  • -
  • HFpay
  • +
  • Rpay+
  • -
  • Yeepay
  • + +
  • CB_BankPay
  • diff --git a/src/main/ui/static/payment/partner/templates/partner_new_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_rate.html index f9400f322..0fbebc5f0 100644 --- a/src/main/ui/static/payment/partner/templates/partner_new_rate.html +++ b/src/main/ui/static/payment/partner/templates/partner_new_rate.html @@ -112,7 +112,7 @@ -
    @@ -134,7 +134,7 @@
    - + -->
    @@ -160,7 +160,7 @@
    -
    @@ -181,6 +181,30 @@
    + + --> + +
    + +
    +
    + +
    %
    +
    +
    +
    + No more than 5.0% +
    +
    + No less than 0.6% +
    +
    + Required Field +
    +
    +
    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 b7a2a6c5e..164a898f3 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 @@ -211,7 +211,7 @@ -
    + +
    + +
    + +
    @@ -345,7 +351,7 @@

    -
    + + + + +
    +
    CB Bank Payment
    +
    +
    + +
    + + +
    +
    + + +
    +   仅支持微信客户端扫描 +
    diff --git a/src/main/ui/static/templates/payment/v1/payment.js b/src/main/ui/static/templates/payment/v1/payment.js index 781f43f4b..cedcc0887 100644 --- a/src/main/ui/static/templates/payment/v1/payment.js +++ b/src/main/ui/static/templates/payment/v1/payment.js @@ -62,7 +62,21 @@ $(function () { updatePrice(); } }); - + $('.cb_bankpay').click(function () { + $.ajax({ + url: '/sys/partners/' + window.client_moniker + '/jump/link', + method: 'GET', + success: function (res) { + location.href = res; + }, + error: function (resp) { + var config = { + template: resp + }; + showWeuiDialog(config); + } + }) + }); $('#key_B').bind('touchstart', function () { backspace(); });