|
@@ -354,8 +354,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) -> routeOrderList(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 +1427,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 +1440,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.routeOrderList(params, managerDownload),
|
|
|
+ managerDownload.getName());
|
|
|
+ }
|
|
|
+
|
|
|
//学员小课记录导出
|
|
|
@Override
|
|
|
public HttpResponseResult exportStudentVipPractice(Map<String, Object> info) {
|
|
@@ -1567,6 +1600,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
|
|
@@ -1626,6 +1687,49 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
|
|
|
@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);
|
|
|
+ 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));
|
|
|
+ if(StringUtils.isNotEmpty(row.getGoodsJson())){
|
|
|
+ List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(row.getGoodsJson()).getString("orderItemList"), JSONObject.class);
|
|
|
+ String productName = orderItemList.stream().map(e -> e.get("productName").toString()).collect(Collectors.joining(","));
|
|
|
+ row.setGoodsNames(productName);
|
|
|
+ }
|
|
|
+ //活动购买的商品列表
|
|
|
+ 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++;
|
|
|
+ }
|
|
|
+ HSSFWorkbook workbook = getHSSFWorkbook(studentPaymentOrderExportDtos, ExportEnum.MALL_ORDER_LIST);
|
|
|
+ exportManagerDownload(workbook, managerDownload);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
public void orderList(Map<String, Object> params, ManagerDownload managerDownload) {
|
|
|
List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
|
|
|
long i = 1;
|
|
@@ -2321,6 +2425,110 @@ 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;
|
|
|
+ }
|
|
|
+ Set<Long> paymentOrderIds = studentPaymentOrderExportDtos.stream().map(e -> e.getId()).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ //计算手续费
|
|
|
+ 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);
|
|
|
+ //获取乐团信息
|
|
|
+ this.initMusicGroupInfo(basicOrder, musicGroupNameMap, firstMusicMap, userLastMusicIdMap, userLastMusicNameMap, calenderCooperationMap);
|
|
|
+ //填充备注信息
|
|
|
+ if (basicOrder.getGoodsList() != null) {
|
|
|
+ String goodsName = basicOrder.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
|
|
|
+ basicOrder.setMemo(goodsName);
|
|
|
+ }
|
|
|
+ if (basicOrder.getType() == OUTORDER && StringUtils.isNotEmpty(basicOrder.getMusicGroupId())) {
|
|
|
+ if (cooperationOrganMap.containsKey(Integer.valueOf(basicOrder.getMusicGroupId()))) {
|
|
|
+ basicOrder.setCooperationOrganName(cooperationOrganMap.get(Integer.valueOf(basicOrder.getMusicGroupId())));
|
|
|
+ CooperationOrgan cooperationOrganEduTeacher = musicGroupDao.findCooperationOrganEduTeacher(Integer.valueOf(basicOrder.getMusicGroupId()));
|
|
|
+ if (cooperationOrganEduTeacher != null) {
|
|
|
+ basicOrder.setEduTeacher(cooperationOrganEduTeacher.getLinkman());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //根据订单类型初始化业务数据
|
|
|
+ Optional.ofNullable(groupTypeConsumerMap1.get(basicOrder.getGroupType())).ifPresent(consumer -> consumer.accept(basicOrder));
|
|
|
+ this.setSubTypeDesc(basicOrder, userFirstVipMap, userFirstPracticeMap);
|
|
|
+
|
|
|
+ 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(StringUtils.isNotEmpty(basicOrder.getSporadicType()) && !basicOrder.getSporadicType().equals("其他")){
|
|
|
+ basicOrder.setTypeDesc(basicOrder.getSporadicType());
|
|
|
+ }
|
|
|
+ if (basicOrder.getRouteAmount().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果是零星收费的账户充值,不管销售还是服务,统一放在其他收费项目中
|
|
|
+ if (basicOrder.getType() == OrderTypeEnum.SPORADIC
|
|
|
+ && basicOrder.getGroupType() == GroupType.SPORADIC
|
|
|
+ && basicOrder.getServiceAmount().compareTo(BigDecimal.ZERO) == 0
|
|
|
+ && basicOrder.getSaleAmount().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ basicOrder.setOtherFee(basicOrder.getRouteAmount());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果有订单详情
|
|
|
+ List<StudentPaymentOrderDetail> detailList = orderDetailMap.get(basicOrder.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(detailList)) {
|
|
|
+ this.calcOrderDetail(basicOrder, detailList, userFirstVipMap);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果没有订单详情,则计算商品收入
|
|
|
+ List<SellOrder> sellOrderList = sellOrderMap.get(basicOrder.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(sellOrderList)) {
|
|
|
+ this.calcSellOrder(basicOrder, sellOrderList, goodsMap);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果只有订单,那么按分类统计
|
|
|
+ if (basicOrder.getServiceAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //计算服务收入
|
|
|
+ Optional.ofNullable(groupTypeConsumerMap.get(basicOrder.getGroupType())).ifPresent(c -> c.accept(basicOrder));
|
|
|
+ } else if (basicOrder.getSaleAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //计算销售收入
|
|
|
+ this.setSaleFee(basicOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HSSFWorkbook workbook = getHSSFWorkbook(studentPaymentOrderExportDtos, ExportEnum.ROUTE_ORDER_LIST1);
|
|
|
+ exportManagerDownload(workbook, managerDownload);
|
|
|
+ }
|
|
|
+
|
|
|
public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) {
|
|
|
//获取分润订单(不包含订单详情)(纯余额支付不处理)
|
|
|
List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage1(params);
|