|
@@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
@@ -354,8 +355,10 @@ public class ExportServiceImpl implements ExportService {
|
|
|
//导出到报表中心
|
|
|
// exportManageFuncMap.put(ExportEnum.SUPER_FIND_COURSE_SCHEDULES, (info,headColumns) -> this.superFindCourseSchedules(info,headColumns));
|
|
|
//针对不同的用户有不同的模板
|
|
|
+ exportManageFuncMap.put(ExportEnum.MALL_ROUTE_ORDER_LIST, (info) -> routeMallOrderList(info));
|
|
|
exportManageFuncMap.put(ExportEnum.ROUTE_ORDER_LIST1, (info) -> routeOrderList(info));
|
|
|
exportManageFuncMap.put(ExportEnum.ROUTE_ORDER_LIST2, (info) -> routeOrderList(info));
|
|
|
+ exportManageFuncMap.put(ExportEnum.MALL_ORDER_LIST, (info) -> mallOrderList(info));
|
|
|
exportManageFuncMap.put(ExportEnum.ORDER_LIST1, (info) -> orderList(info));
|
|
|
exportManageFuncMap.put(ExportEnum.ORDER_LIST2, (info) -> orderList(info));
|
|
|
exportManageFuncMap.put(ExportEnum.ORDER_LIST_SUM, (info) -> orderListSum(info));
|
|
@@ -1425,6 +1428,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
queryInfo.setOrderType("3");
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("noGroupType","MALL_SELL");
|
|
|
int count = studentPaymentRouteOrderDao.queryCount(params);
|
|
|
if (count <= 0) {
|
|
|
return BaseController.failed("没有可导出的数据");
|
|
@@ -1437,6 +1441,36 @@ public class ExportServiceImpl implements ExportService {
|
|
|
managerDownload.getName());
|
|
|
}
|
|
|
|
|
|
+ //财务管理导出
|
|
|
+ @Override
|
|
|
+ public HttpResponseResult routeMallOrderList(Map<String, Object> info) {
|
|
|
+ StudentPaymentOrderQueryInfo queryInfo = JSONObject.parseObject(JSONObject.toJSONString(info), StudentPaymentOrderQueryInfo.class);
|
|
|
+ SysUser sysUser = sysUserService.getUser();
|
|
|
+ queryInfo.setRoutingOrganId(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getRoutingOrganId(), sysUser.getIsSuperAdmin()));
|
|
|
+ if (StringUtils.isNotBlank(queryInfo.getSearch())) {
|
|
|
+ List<BasicUserDto> users = studentPaymentOrderDao.getUsers(queryInfo.getSearch());
|
|
|
+ List<Integer> userIds = users.stream().map(BasicUserDto::getUserId).collect(Collectors.toList());
|
|
|
+ if (userIds.size() <= 0) {
|
|
|
+ userIds.add(0);
|
|
|
+ }
|
|
|
+ queryInfo.setUserIds(userIds);
|
|
|
+ }
|
|
|
+ queryInfo.setOrderType("3");
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("paymentType","MALL_BUY");
|
|
|
+ int count = studentPaymentRouteOrderDao.queryCount(params);
|
|
|
+ if (count <= 0) {
|
|
|
+ return BaseController.failed("没有可导出的数据");
|
|
|
+ }
|
|
|
+ if (count > 50000) {
|
|
|
+ return BaseController.failed("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
+ }
|
|
|
+ ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.MALL_ROUTE_ORDER, sysUser.getId());
|
|
|
+ return this.asyncExport(() -> this.mallRouteOrderList(params, managerDownload),
|
|
|
+ managerDownload.getName());
|
|
|
+ }
|
|
|
+
|
|
|
//学员小课记录导出
|
|
|
@Override
|
|
|
public HttpResponseResult exportStudentVipPractice(Map<String, Object> info) {
|
|
@@ -1567,6 +1601,34 @@ public class ExportServiceImpl implements ExportService {
|
|
|
return this.asyncExport(() -> this.orderList(params, managerDownload),
|
|
|
managerDownload.getName());
|
|
|
}
|
|
|
+ //订单列表导出
|
|
|
+ @Override
|
|
|
+ public HttpResponseResult mallOrderList(Map<String, Object> info) {
|
|
|
+ StudentPaymentOrderQueryInfo queryInfo = JSONObject.parseObject(JSONObject.toJSONString(info), StudentPaymentOrderQueryInfo.class);
|
|
|
+ SysUser sysUser = sysUserService.getUser();
|
|
|
+ queryInfo.setOrganId(organizationService.getEmployeeOrgan(sysUser.getId(), queryInfo.getOrganId(), sysUser.getIsSuperAdmin()));
|
|
|
+ if (StringUtils.isNotBlank(queryInfo.getSearch())) {
|
|
|
+ List<BasicUserDto> users = studentPaymentOrderDao.getUsers(queryInfo.getSearch());
|
|
|
+ List<Integer> userIds = users.stream().map(BasicUserDto::getUserId).collect(Collectors.toList());
|
|
|
+ if (userIds.size() <= 0) {
|
|
|
+ userIds.add(0);
|
|
|
+ }
|
|
|
+ queryInfo.setUserIds(userIds);
|
|
|
+ }
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("paymentType","MALL_BUY");
|
|
|
+ int count = studentPaymentOrderDao.queryCount(params);
|
|
|
+ if (count <= 0) {
|
|
|
+ return BaseController.failed("没有可导出的数据");
|
|
|
+ }
|
|
|
+ if (count > 50000) {
|
|
|
+ return BaseController.failed("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
+ }
|
|
|
+ ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.MALL_ORDER, sysUser.getId());
|
|
|
+ return this.asyncExport(() -> this.mallOrderList(params, managerDownload),
|
|
|
+ managerDownload.getName());
|
|
|
+ }
|
|
|
|
|
|
//订单列表导出
|
|
|
@Override
|
|
@@ -1624,6 +1686,86 @@ public class ExportServiceImpl implements ExportService {
|
|
|
return BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void mallOrderList(Map<String, Object> params, ManagerDownload managerDownload){
|
|
|
+ List<StudentPaymentOrderMallExportDto> studentPaymentOrderExportDtos = studentPaymentOrderDao.exportMallQueryPage(params);
|
|
|
+ long i = 1;
|
|
|
+ //获取机构费率
|
|
|
+ Integer tenantId = (Integer) params.get("tenantId");
|
|
|
+ TenantConfig tenantConfig = tenantConfigService.queryByTenantId(tenantId);
|
|
|
+ //获取商城订单商品信息
|
|
|
+ List<String> goodsJsonList = studentPaymentOrderExportDtos.stream().map(e -> e.getGoodsJson()).collect(Collectors.toList());
|
|
|
+ goodsJsonList.removeAll(Collections.singleton(null));
|
|
|
+ Set<String> productIdList = new HashSet<>();
|
|
|
+ for (String goodsJson : goodsJsonList) {
|
|
|
+ List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(goodsJson).getString("orderItemList"), JSONObject.class);
|
|
|
+ productIdList.addAll(orderItemList.stream().map(e -> e.get("productId").toString()).collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
+ List<String> categoryNames = sellOrderDao.getMallProductCategory("mall_dev");
|
|
|
+ Map<Long,String> productCategoryMap = MapUtil.convertMybatisMap(sellOrderDao.getMallProductMap(productIdList,"mall_dev"));
|
|
|
+ for (StudentPaymentOrderMallExportDto row : studentPaymentOrderExportDtos) {
|
|
|
+ if (row.getActualAmount() == null) {
|
|
|
+ row.setActualAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (row.getBalancePaymentAmount() == null) {
|
|
|
+ row.setBalancePaymentAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ BigDecimal transferFee = BigDecimal.ZERO;
|
|
|
+ if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
|
|
|
+ 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));
|
|
|
+ //解析json
|
|
|
+ this.parseGoodsJson(row,categoryNames,productCategoryMap);
|
|
|
+ //活动购买的商品列表
|
|
|
+ String paymentChannel = "";
|
|
|
+ if (row.getPaymentChannel() == null) {
|
|
|
+ } else if (row.getPaymentChannel().equals("YQPAY")) {
|
|
|
+ paymentChannel = "双乾";
|
|
|
+ } else if (row.getPaymentChannel().equals("ADAPAY")) {
|
|
|
+ paymentChannel = "汇付";
|
|
|
+ } else if (row.getPaymentChannel().equals("BALANCE")) {
|
|
|
+ paymentChannel = "余额";
|
|
|
+ }
|
|
|
+ row.setPaymentChannel(paymentChannel);
|
|
|
+ row.setId(i);
|
|
|
+ row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ Map<String, String> headMap = getExportMap(new ExportDto(ExportEnum.MALL_ORDER_LIST));
|
|
|
+ for (int j = 0; j < categoryNames.size(); j++) {
|
|
|
+ int num = j + 1;
|
|
|
+ headMap.put(categoryNames.get(j),"category"+ num);
|
|
|
+ }
|
|
|
+ String[] header = headMap.keySet().toArray(new String[headMap.keySet().size()]);
|
|
|
+ String[] body = headMap.values().toArray(new String[headMap.keySet().size()]);
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ exportManagerDownload(workbook, managerDownload);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parseGoodsJson(StudentPaymentOrderMallExportDto row,List<String> categoryNames,Map<Long,String> productCategoryMap){
|
|
|
+ if(StringUtils.isNotEmpty(row.getGoodsJson())){
|
|
|
+ List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(row.getGoodsJson()).getString("orderItemList"), JSONObject.class);
|
|
|
+ for (JSONObject json : orderItemList) {
|
|
|
+ try {
|
|
|
+ String category = productCategoryMap.get(Long.parseLong(json.get("productId").toString()));
|
|
|
+ BigDecimal realAmount = new BigDecimal(json.get("realAmount").toString());
|
|
|
+ int index = categoryNames.indexOf(category) + 1;
|
|
|
+ if(index == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Method method = row.getClass().getMethod("getCategory" + index, null);
|
|
|
+ BigDecimal invoke = (BigDecimal)method.invoke(row);
|
|
|
+ invoke = invoke.add(realAmount);
|
|
|
+ Method method1 = row.getClass().getMethod("setCategory" + index, BigDecimal.class);
|
|
|
+ method1.invoke(row,invoke);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void orderList(Map<String, Object> params, ManagerDownload managerDownload) {
|
|
@@ -2321,6 +2463,57 @@ public class ExportServiceImpl implements ExportService {
|
|
|
return subtract;
|
|
|
}
|
|
|
|
|
|
+ public void mallRouteOrderList(Map<String, Object> params, ManagerDownload managerDownload) {
|
|
|
+ //获取分润订单(不包含订单详情)(纯余额支付不处理)
|
|
|
+ List<StudentPaymentOrderMallExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.exportMallQueryPage(params);
|
|
|
+ if (CollectionUtils.isEmpty(studentPaymentOrderExportDtos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //计算手续费
|
|
|
+ Map<String, BigDecimal> serviceChargeMap = new HashMap<>();
|
|
|
+ Map<String, Integer> orderCountMap = new HashMap<>();
|
|
|
+ Integer tenantId = (Integer) params.get("tenantId");
|
|
|
+ TenantConfig tenantConfig = tenantConfigService.queryByTenantId(tenantId);
|
|
|
+ Map<Integer, String> studentNameMap = new HashMap<>();
|
|
|
+ List<Integer> organIds = studentPaymentOrderExportDtos.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
|
|
|
+ Map<Integer, String> userOrganNameMap = organizationService.getMap("organization","id_","name_",organIds,tenantId,Integer.class,String.class);
|
|
|
+ if (studentPaymentOrderExportDtos.stream().anyMatch(e -> e.getUserId() != null)) {
|
|
|
+ List<Integer> studentIds = studentPaymentOrderExportDtos.stream().filter(e -> e.getUserId() != null).map(e -> e.getUserId()).distinct().collect(Collectors.toList());
|
|
|
+ //获取学员名称
|
|
|
+ studentNameMap = studentService.getMap("sys_user", "id_", "username_", studentIds, tenantId, Integer.class, String.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //用于计算手续费
|
|
|
+ Map<String, FeeFlagNumDto> feeFlagMap = new HashMap<>();
|
|
|
+ if (studentPaymentOrderExportDtos.stream().anyMatch(e -> Objects.equals(e.getPaymentChannel(), "ADAPAY"))) {
|
|
|
+ List<String> orderNoList = studentPaymentOrderExportDtos.stream().filter(e -> Objects.equals(e.getPaymentChannel(), "ADAPAY")).map(e -> e.getOrderNo()).distinct().collect(Collectors.toList());
|
|
|
+ List<FeeFlagNumDto> feeFlagNumDtos = studentPaymentRouteOrderDao.queryCountFeeFlagNum(orderNoList);
|
|
|
+ feeFlagMap = feeFlagNumDtos.stream().collect(Collectors.toMap(FeeFlagNumDto::getOrderNo, Function.identity()));
|
|
|
+ }
|
|
|
+ for (StudentPaymentOrderMallExportDto basicOrder : studentPaymentOrderExportDtos) {
|
|
|
+ basicOrder.getUser().setUsername(studentNameMap.get(basicOrder.getUserId()));
|
|
|
+ basicOrder.setUserOrganName(userOrganNameMap.get(basicOrder.getOrganId()));
|
|
|
+ //计算手续费
|
|
|
+ this.calcPlatformFee(basicOrder, serviceChargeMap, orderCountMap, tenantConfig, feeFlagMap);
|
|
|
+
|
|
|
+ String paymentChannel = "";
|
|
|
+ if (basicOrder.getPaymentChannel() == null) {
|
|
|
+ } else if (basicOrder.getPaymentChannel().equals("YQPAY")) {
|
|
|
+ paymentChannel = "双乾";
|
|
|
+ } else if (basicOrder.getPaymentChannel().equals("ADAPAY")) {
|
|
|
+ paymentChannel = "汇付";
|
|
|
+ } else if (basicOrder.getPaymentChannel().equals("BALANCE")) {
|
|
|
+ paymentChannel = "余额";
|
|
|
+ }
|
|
|
+ basicOrder.setPaymentChannel(paymentChannel);
|
|
|
+ if (basicOrder.getRouteAmount().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HSSFWorkbook workbook = getHSSFWorkbook(studentPaymentOrderExportDtos, ExportEnum.MALL_ROUTE_ORDER_LIST);
|
|
|
+ exportManagerDownload(workbook, managerDownload);
|
|
|
+ }
|
|
|
+
|
|
|
public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) {
|
|
|
//获取分润订单(不包含订单详情)(纯余额支付不处理)
|
|
|
List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage1(params);
|
|
@@ -2588,12 +2781,12 @@ public class ExportServiceImpl implements ExportService {
|
|
|
List<StudentStatisticsDto> rows = studentStatisticsService.queryStatisticsPage(queryInfo).getRows();
|
|
|
try {
|
|
|
HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "学生姓名", "学员编号", "联系电话", "声部", "学校", "年级", "学员状态", "未排课时", "总课时", "已完成课时",
|
|
|
- "剩余课时", "预收金额", "第一次课时间", "最近上课时间", "指导老师编号", "指导老师", "乐团主管编号", "乐团主管", "声部课老师编号", "声部课老师", "近30天课耗", "回访次数",
|
|
|
+ "剩余未开始课时","剩余课时(未开始+未排课资格)", "预收金额", "第一次课时间", "最近上课时间", "指导老师编号", "指导老师", "乐团主管编号", "乐团主管", "声部课老师编号", "声部课老师", "近30天课耗", "回访次数",
|
|
|
"回访状态", "原因", "回访日期"},
|
|
|
new String[]{"studentBasicInfo.organName", "studentBasicInfo.userName", "studentBasicInfo.userId",
|
|
|
"studentBasicInfo.phone", "studentBasicInfo.subjectName", "studentBasicInfo.cooperationOrganName", "studentBasicInfo.grade",
|
|
|
"studentBasicInfo.studentStatus",
|
|
|
- "noScheduleNum", "totalCourseNum", "overCourseNum", "subCourseNum", "preCourseFee", "firstCourseTime", "lastCourseTime", "teacherId", "teacherName", "musicDirectorId", "musicDirectorName",
|
|
|
+ "noScheduleNum", "totalCourseNum", "overCourseNum", "subCourseNum", "subTotalCourse", "preCourseFee", "firstCourseTime", "lastCourseTime", "teacherId", "teacherName", "musicDirectorId", "musicDirectorName",
|
|
|
"studentBasicInfo.subjectTeacherId", "studentBasicInfo.subjectTeacherName", "latelyCourseConsumer", "visitNum",
|
|
|
"lastVisitStatus == null?'':lastVisitStatus == 'LOST' ? '流失':lastVisitStatus == 'THINKING' ? '考虑中':" +
|
|
|
"lastVisitStatus == 'PENDING_PAYMENT' ? '确认缴费待缴费':lastVisitStatus == 'PAUSE' ? '暂停':lastVisitStatus == 'OTHER' ? '其他':''"
|
|
@@ -2973,7 +3166,7 @@ public class ExportServiceImpl implements ExportService {
|
|
|
}
|
|
|
|
|
|
//计算汇付手续费和平台手续费
|
|
|
- public void calcPlatformFee(StudentPaymentOrderExportDto row, Map<String, BigDecimal> serviceChargeMap,
|
|
|
+ public void calcPlatformFee(StudentPaymentOrderRouteDto row, Map<String, BigDecimal> serviceChargeMap,
|
|
|
Map<String, Integer> orderCountMap, TenantConfig tenantConfig, Map<String, FeeFlagNumDto> feeFlagMap) {
|
|
|
BigDecimal currentFee = BigDecimal.ZERO;
|
|
|
if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
|