|
@@ -1,39 +1,66 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.*;
|
|
|
-import com.ym.mec.biz.dal.entity.*;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.system.ApplicationHome;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.dao.CooperationOrganDao;
|
|
|
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
+import com.ym.mec.biz.dal.dao.ManagerDownloadDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dao.PracticeGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SellOrderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
|
|
|
+import com.ym.mec.biz.dal.dao.VipGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dto.BaseNameDto;
|
|
|
+import com.ym.mec.biz.dal.dto.CourseScheduleEndDto;
|
|
|
+import com.ym.mec.biz.dal.dto.FeeFlagNumDto;
|
|
|
+import com.ym.mec.biz.dal.dto.PracticeCourseDto;
|
|
|
+import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentVipPracticeExportDto;
|
|
|
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
|
|
|
+import com.ym.mec.biz.dal.entity.Goods;
|
|
|
+import com.ym.mec.biz.dal.entity.ManagerDownload;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantConfig;
|
|
|
+import com.ym.mec.biz.dal.entity.VipGroup;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
|
|
|
import com.ym.mec.biz.service.CourseScheduleService;
|
|
|
import com.ym.mec.biz.service.ExportService;
|
|
|
import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
import com.ym.mec.biz.service.StudentService;
|
|
|
-import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.biz.service.TenantConfigService;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.thirdparty.storage.StoragePluginContext;
|
|
|
import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
|
-import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
|
import com.ym.mec.util.upload.UploadUtil;
|
|
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.system.ApplicationHome;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.io.*;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
@Service
|
|
|
public class ExportServiceImpl implements ExportService {
|
|
|
|
|
@@ -63,12 +90,15 @@ public class ExportServiceImpl implements ExportService {
|
|
|
private CourseScheduleService courseScheduleService;
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TenantConfigService tenantConfigService;
|
|
|
@Autowired
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
- public void orderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception {
|
|
|
+ public void orderList(Map<String, Object> params, ManagerDownload managerDownload, boolean isPlatformUser) throws Exception {
|
|
|
List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
|
|
|
long i = 1;
|
|
|
Map<Integer, String> cooperationOrganMap = new HashMap<>();
|
|
@@ -82,6 +112,11 @@ public class ExportServiceImpl implements ExportService {
|
|
|
List<CooperationOrgan> cooperationOrgans = cooperationOrganDao.getCooperationOrganByIds(cooperationOrganIds);
|
|
|
cooperationOrganMap = cooperationOrgans.stream().collect(Collectors.toMap(CooperationOrgan::getId, CooperationOrgan::getName));
|
|
|
}
|
|
|
+
|
|
|
+ //获取机构费率
|
|
|
+ Integer tenantId = (Integer) params.get("tenantId");
|
|
|
+ TenantConfig tenantConfig = tenantConfigService.queryByTenantId(tenantId);
|
|
|
+
|
|
|
for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
|
|
|
if (row.getActualAmount() == null) {
|
|
|
row.setActualAmount(BigDecimal.ZERO);
|
|
@@ -97,6 +132,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
row.setTransferFee(transferFee);
|
|
|
+ row.setPlatformFee(row.getActualAmount().multiply(tenantConfig.getChargeRate()).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
String goodsName = "";
|
|
|
if (row.getOrderDetailList() != null) {
|
|
@@ -281,6 +317,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
} else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
|
|
|
row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()));
|
|
|
row.setTransferFee(BigDecimal.ZERO);
|
|
|
+ row.setPlatformFee(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
//如果合作单位不存在取学员的第一个乐团的合作单位,乐团主管
|
|
@@ -325,15 +362,29 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
HSSFWorkbook workbook = null;
|
|
|
try {
|
|
|
- String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额", "现金支付", "余额支付", "优惠金额",
|
|
|
- "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费",
|
|
|
- "账户充值", "其它", "手续费", "到账时间",
|
|
|
- "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
- String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount", "expectAmount", "actualAmount", "balancePaymentAmount", "couponRemitFee",
|
|
|
- "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee",
|
|
|
- "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
|
|
|
- "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
- workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ if(isPlatformUser){
|
|
|
+ String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额", "现金支付", "余额支付", "优惠金额",
|
|
|
+ "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费",
|
|
|
+ "账户充值", "其它", "汇付手续费","平台手续费", "到账时间",
|
|
|
+ "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
+
|
|
|
+ String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount", "expectAmount", "actualAmount", "balancePaymentAmount", "couponRemitFee",
|
|
|
+ "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee",
|
|
|
+ "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "transferFee", "platformFee", "payTime", "musicGroupId",
|
|
|
+ "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ }else{
|
|
|
+ String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额", "现金支付", "余额支付", "优惠金额",
|
|
|
+ "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费",
|
|
|
+ "账户充值", "其它","平台手续费", "到账时间",
|
|
|
+ "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
+
|
|
|
+ String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount", "expectAmount", "actualAmount", "balancePaymentAmount", "couponRemitFee",
|
|
|
+ "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee",
|
|
|
+ "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "platformFee", "payTime", "musicGroupId",
|
|
|
+ "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ }
|
|
|
workbook.write(fileOutputStream);
|
|
|
fileOutputStream.getFD().sync();
|
|
|
fileOutputStream.close();
|
|
@@ -359,7 +410,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
- public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception {
|
|
|
+ public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload, boolean isPlatformUser) throws Exception {
|
|
|
List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage(params);
|
|
|
|
|
|
Map<Integer, String> cooperationOrganMap = new HashMap<>();
|
|
@@ -373,7 +424,10 @@ public class ExportServiceImpl implements ExportService {
|
|
|
List<CooperationOrgan> cooperationOrgans = cooperationOrganDao.getCooperationOrganByIds(cooperationOrganIds);
|
|
|
cooperationOrganMap = cooperationOrgans.stream().collect(Collectors.toMap(CooperationOrgan::getId, CooperationOrgan::getName));
|
|
|
}
|
|
|
- long i = 1;
|
|
|
+
|
|
|
+ //获取机构费率
|
|
|
+ Integer tenantId = (Integer) params.get("tenantId");
|
|
|
+ TenantConfig tenantConfig = tenantConfigService.queryByTenantId(tenantId);
|
|
|
|
|
|
Map<String,BigDecimal> serviceChargeMap = new HashMap<String, BigDecimal>();
|
|
|
Map<String,Integer> orderCountMap = new HashMap<String, Integer>();
|
|
@@ -433,6 +487,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
}
|
|
|
row.setTransferFee(currentFee);
|
|
|
+ row.setPlatformFee(row.getActualAmount().multiply(tenantConfig.getChargeRate()).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
String goodsName = "";
|
|
|
if (row.getOrderDetailList() != null) {
|
|
@@ -617,6 +672,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
} else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
|
|
|
row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()));
|
|
|
row.setTransferFee(BigDecimal.ZERO);
|
|
|
+ row.setPlatformFee(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
//如果合作单位不存在取学员的第一个乐团的合作单位和教学点
|
|
@@ -650,7 +706,6 @@ public class ExportServiceImpl implements ExportService {
|
|
|
}
|
|
|
row.setPaymentChannel(paymentChannel);
|
|
|
row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
|
|
|
- i++;
|
|
|
}
|
|
|
|
|
|
Map<Long, List<StudentPaymentOrderExportDto>> orderMap = studentPaymentOrderExportDtos.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
|
|
@@ -816,16 +871,29 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
HSSFWorkbook workbook = null;
|
|
|
try {
|
|
|
- String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额",
|
|
|
- "现金支付", "余额支付", "分润账户", "分润金额", "分配余额", "优惠金额", "乐团课", "VIP课", "网管课", "乐理课",
|
|
|
- "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "手续费", "到账时间",
|
|
|
- "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
- String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount"
|
|
|
- , "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "couponRemitFee",
|
|
|
- "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee",
|
|
|
- "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
|
|
|
- "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
- workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ if(isPlatformUser){
|
|
|
+ String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额",
|
|
|
+ "现金支付", "余额支付", "分润账户", "分润金额", "分配余额", "优惠金额", "乐团课", "VIP课", "网管课", "乐理课",
|
|
|
+ "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "汇付手续费", "平台手续费", "到账时间",
|
|
|
+ "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
+ String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount"
|
|
|
+ , "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "couponRemitFee",
|
|
|
+ "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee",
|
|
|
+ "rechargeFee", "otherFee", "transferFee", "platformFee", "payTime", "musicGroupId",
|
|
|
+ "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ }else{
|
|
|
+ String[] header = {"序号", "学生编号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额",
|
|
|
+ "现金支付", "余额支付", "分润账户", "分润金额", "分配余额", "优惠金额", "乐团课", "VIP课", "网管课", "乐理课",
|
|
|
+ "考级", "维修费用", "乐保费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "平台手续费", "到账时间",
|
|
|
+ "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
|
|
|
+ String[] body = {"id", "userId", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount"
|
|
|
+ , "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "couponRemitFee",
|
|
|
+ "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "maintenanceFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee",
|
|
|
+ "rechargeFee", "otherFee", "platformFee", "payTime", "musicGroupId",
|
|
|
+ "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ }
|
|
|
workbook.write(fileOutputStream);
|
|
|
fileOutputStream.getFD().sync();
|
|
|
fileOutputStream.close();
|