| | |
| | | package com.xinquan.order.controller.management; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.WebUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.domain.export.OrderExport; |
| | | import com.xinquan.order.domain.export.WaterExport; |
| | | import com.xinquan.system.api.domain.AppUserWithdraw; |
| | | import com.xinquan.system.api.domain.PrizeRedemptionRecord; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.OrderListDTO; |
| | | import com.xinquan.order.api.domain.vo.OrderCountVO; |
| | | import com.xinquan.order.domain.OrderPaymentRecord; |
| | | import com.xinquan.order.service.OrderPaymentRecordService; |
| | | import com.xinquan.order.service.OrderService; |
| | | import com.xinquan.system.api.RemoteUserService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.SysUser; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.aspectj.weaver.ast.Or; |
| | | import org.omg.CORBA.PRIVATE_MEMBER; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/mgt/order/order") |
| | | public class MgtOrderController { |
| | | @Resource |
| | | private OrderService orderService; |
| | | @Resource |
| | | private OrderPaymentRecordService orderPaymentRecordService; |
| | | @Resource |
| | | private RemoteAppUserService remoteAppUserService; |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | public static void main(String[] args) { |
| | | } |
| | | @PostMapping("/getOrderList") |
| | | public R<List<Order>> getOrderList(@RequestParam("status") Integer status, |
| | | @RequestParam("timeType") Integer timeType, |
| | | @RequestParam("time") String time) |
| | | { |
| | | LocalDate today = LocalDate.now(); |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // 获取当前年份 |
| | | int currentYear = LocalDate.now().getYear(); |
| | | List<Long> longs = new ArrayList<>(); |
| | | longs.add(1L); |
| | | longs.add(2L); |
| | | longs.add(3L); |
| | | LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | String startTime =null; |
| | | String endTime =null; |
| | | switch (timeType){ |
| | | case 1: |
| | | // 获取今年第一天和今年最后一天 |
| | | // 获取今年的第一天 |
| | | LocalDate firstDayOfYear = LocalDate.of(currentYear, 1, 1); |
| | | LocalDateTime firstDayOfYearDateTime = firstDayOfYear.atStartOfDay(); |
| | | // 获取今年的最后一天 |
| | | LocalDate lastDayOfYear = LocalDate.of(currentYear, 12, 31); |
| | | LocalDateTime lastDayOfYearDateTime = lastDayOfYear.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfYearString = firstDayOfYearDateTime.format(formatter); |
| | | String lastDayOfYearString = lastDayOfYearDateTime.format(formatter); |
| | | startTime = firstDayOfYearString; |
| | | endTime = lastDayOfYearString; |
| | | break; |
| | | case 2: |
| | | // 获取今日的最开始时间(00:00:00) |
| | | LocalDateTime startOfDay = today.atStartOfDay(); |
| | | // 获取今日的最晚时间(23:59:59) |
| | | LocalDateTime endOfDay = today.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String startOfDayString = startOfDay.format(formatter); |
| | | String endOfDayString = endOfDay.format(formatter); |
| | | startTime = startOfDayString; |
| | | endTime = endOfDayString; |
| | | break; |
| | | case 3: |
| | | // 获取本周的第一天(周一) |
| | | LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY)); |
| | | LocalDateTime firstDayOfWeekDateTime = firstDayOfWeek.atStartOfDay(); |
| | | // 获取本周的最后一天(周日) |
| | | LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY)); |
| | | LocalDateTime lastDayOfWeekDateTime = lastDayOfWeek.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfWeekString = firstDayOfWeekDateTime.format(formatter); |
| | | String lastDayOfWeekString = lastDayOfWeekDateTime.format(formatter); |
| | | startTime = firstDayOfWeekString; |
| | | endTime = lastDayOfWeekString; |
| | | break; |
| | | case 4: |
| | | // 获取当前日期 |
| | | // 获取本月的第一天 |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDateTime firstDayOfMonthDateTime = firstDayOfMonth.atStartOfDay(); |
| | | // 获取本月的最后一天 |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | LocalDateTime lastDayOfMonthDateTime = lastDayOfMonth.atTime(23, 59, 59); |
| | | // 格式化日期时间 |
| | | String firstDayOfMonthString = firstDayOfMonthDateTime.format(formatter); |
| | | String lastDayOfMonthString = lastDayOfMonthDateTime.format(formatter); |
| | | startTime = firstDayOfMonthString; |
| | | endTime = lastDayOfMonthString; |
| | | break; |
| | | } |
| | | if (!time.equals("1")){ |
| | | String[] split = time.split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | if (startTime!=null){ |
| | | orderLambdaQueryWrapper.between(Order::getCreateTime,startTime,endTime); |
| | | } |
| | | if (status!=0){ |
| | | orderLambdaQueryWrapper.eq(Order::getPaymentStatus, status); |
| | | } |
| | | if (status!=0){ |
| | | orderLambdaQueryWrapper.eq(Order::getPaymentStatus, status); |
| | | } |
| | | orderLambdaQueryWrapper.in(Order::getOrderFrom,longs); |
| | | List<Order> list = orderService.list(orderLambdaQueryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | @PutMapping("/export") |
| | | @ApiOperation(value = "收支流水-导出", tags = {"管理后台-财务管理"}) |
| | | public void export(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (courseDTO.getPayType()!=null){ |
| | | courseLambdaQueryWrapper.eq(Order::getPayType, courseDTO.getPayType()); |
| | | } |
| | | if (courseDTO.getPaymentStatus()!=null){ |
| | | courseLambdaQueryWrapper.eq(Order::getPaymentStatus, courseDTO.getPaymentStatus()); |
| | | } |
| | | if (courseDTO.getOrderFrom()!=null){ |
| | | courseLambdaQueryWrapper.eq(Order::getOrderFrom, courseDTO.getOrderFrom()); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | Page<Order> objectPage = new Page<>(); |
| | | objectPage.setTotal(page.size()); |
| | | objectPage.setCurrent(courseDTO.getPageCurr()); |
| | | objectPage.setSize(courseDTO.getPageSize()); |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | record.setPlatformMoney(record.getRealPayAmount()!=null?record.getRealPayAmount():record.getTotalAmount().subtract(record.getCommissionAmount()==null?BigDecimal.ZERO:record.getCommissionAmount())); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getCoverUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getTotalAmount()); |
| | | break; |
| | | case 4: |
| | | record.setBuyContent("充值"); |
| | | record.setPlatformMoney(record.getRealPayAmount()!=null?record.getRealPayAmount() |
| | | .subtract(record.getCommissionAmount()!=null?record.getCommissionAmount():BigDecimal.ZERO):BigDecimal.ZERO); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<WaterExport> waterExports = new ArrayList<>(); |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | record.setPlatformMoney(record.getRealPayAmount().subtract(record.getCommissionAmount()==null?BigDecimal.ZERO:record.getCommissionAmount())); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getIconUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | case 4: |
| | | record.setBuyContent("余额充值"); |
| | | record.setPlatformMoney((record.getRealPayAmount()!=null?record.getRealPayAmount():record.getTotalAmount()) |
| | | .subtract(record.getCommissionAmount()!=null?record.getCommissionAmount():BigDecimal.ZERO)); |
| | | break; |
| | | } |
| | | } |
| | | WaterExport waterExport = new WaterExport(); |
| | | waterExport.setCode(record.getBizOrderNo()); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | waterExport.setUserName(byId1.getNickname()); |
| | | waterExport.setCellphone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getPaymentStatus()!=2){ |
| | | waterExport.setRealPayAmount("¥"+0); |
| | | waterExport.setCommissionAmount("¥"+0); |
| | | waterExport.setPlatformMoney("¥"+0); |
| | | }else{ |
| | | waterExport.setRealPayAmount("¥"+record.getRealPayAmount()); |
| | | waterExport.setCommissionAmount("¥"+(record.getCommissionAmount()==null?new BigDecimal("0")+"":record.getCommissionAmount()+"")); |
| | | waterExport.setPlatformMoney("¥"+record.getPlatformMoney()); |
| | | } |
| | | |
| | | waterExport.setBuyContent(record.getBuyContent()); |
| | | waterExport.setOrderFrom(record.getOrderFrom()+""); |
| | | waterExport.setPayType(record.getPayType()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | waterExport.setCreateTime(format); |
| | | waterExport.setPaymentStatus(record.getPaymentStatus()+""); |
| | | waterExports.add(waterExport); |
| | | } |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), WaterExport.class, waterExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("收支流水导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/waterList") |
| | | @ApiOperation(value = "收支流水-分页", tags = {"管理后台-财务管理"}) |
| | | public R<Page<Order>> waterList(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | |
| | | |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPayType())){ |
| | | courseLambdaQueryWrapper.in(Order::getPayType,Arrays.asList(courseDTO.getPayType().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPaymentStatus())){ |
| | | if (courseDTO.getPaymentStatus().equals("4")){ |
| | | courseLambdaQueryWrapper.eq(Order::getRefundStatus,3); |
| | | }else{ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getPaymentStatus().split(","))); |
| | | |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getOrderFrom())){ |
| | | courseLambdaQueryWrapper.in(Order::getOrderFrom, Arrays.asList(courseDTO.getOrderFrom().split(","))); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | // 提现订单 |
| | | if (appUserWithdraw.getWithdrawStatus()==2){ |
| | | order.setRefundStatus(3); |
| | | }else{ |
| | | order.setRefundStatus(1); |
| | | } |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | Page<Order> objectPage = new Page<>(); |
| | | objectPage.setTotal(page.size()); |
| | | objectPage.setCurrent(courseDTO.getPageCurr()); |
| | | objectPage.setSize(courseDTO.getPageSize()); |
| | | for (Order record : page) { |
| | | |
| | | record.setUid(record.getId().toString()); |
| | | record.setPlatformMoney((record.getRealPayAmount()!=null?record.getRealPayAmount():record.getTotalAmount()).subtract(record.getCommissionAmount()==null?BigDecimal.ZERO:record.getCommissionAmount())); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getCoverUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getTotalAmount()); |
| | | break; |
| | | case 4: |
| | | record.setBuyContent("充值"); |
| | | |
| | | break; |
| | | } |
| | | } |
| | | if (record.getPaymentStatus()!=2){ |
| | | record.setPlatformMoney(null); |
| | | record.setRealPayAmount(null); |
| | | record.setCommissionAmount(null); |
| | | } |
| | | } |
| | | // 手动分页 |
| | | List<Order> testing = testing(page.size(), courseDTO.getPageCurr(), courseDTO.getPageSize(), page); |
| | | objectPage.setRecords(testing); |
| | | return R.ok(objectPage); |
| | | } |
| | | @PostMapping("/waterListTest") |
| | | @ApiOperation(value = "测试手动分页-分页", tags = {"管理后台-测试接口"}) |
| | | public R<List<Order>> waterListTest(@RequestBody OrderListDTO courseDTO) { |
| | | List<Order> list = orderService.list(null); |
| | | return R.ok(testing(list.size(), courseDTO.getPageCurr(), courseDTO.getPageSize(), list)); |
| | | } |
| | | public static List<Order> testing(long total, long current, long size, List<Order> str){ |
| | | List<Order> result = new ArrayList<>(); |
| | | //获取初始化分页结构 |
| | | Page<Order> page = new Page<>(current - 1, size, total); |
| | | //获取集合下标初始值 |
| | | long startIndex = (current - 1) * size; |
| | | //获取集合下标结束值 |
| | | long endInddex = 0; |
| | | if(startIndex + page.getCurrent() >= total || size > total){ |
| | | endInddex = total; |
| | | }else { |
| | | endInddex = Math.min(startIndex + page.getSize(), total); |
| | | } |
| | | //如果输入的开始查询下标大于集合大小,则查询为空值 |
| | | if(startIndex > total){ |
| | | result = Collections.emptyList(); |
| | | }else{ |
| | | result = str.subList((int)startIndex,(int)endInddex); |
| | | } |
| | | return result; |
| | | } |
| | | @PostMapping("/waterCount") |
| | | @ApiOperation(value = "收支流水列表上方合计数据", tags = {"管理后台-财务管理"}) |
| | | public R<OrderCountVO> waterCount(@RequestBody OrderListDTO courseDTO) { |
| | | OrderCountVO orderCountVO = new OrderCountVO(); |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPayType())){ |
| | | courseLambdaQueryWrapper.in(Order::getPayType,Arrays.asList(courseDTO.getPayType().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPaymentStatus())){ |
| | | if (courseDTO.getPaymentStatus().equals("4")){ |
| | | courseLambdaQueryWrapper.eq(Order::getRefundStatus,3); |
| | | }else{ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getPaymentStatus().split(","))); |
| | | |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getOrderFrom())){ |
| | | courseLambdaQueryWrapper.in(Order::getOrderFrom, Arrays.asList(courseDTO.getOrderFrom().split(","))); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | List<AppUserWithdraw> data2 = remoteAppUserService.getWithdraw(courseDTO).getData(); |
| | | for (AppUserWithdraw appUserWithdraw : data2) { |
| | | Order order = new Order(); |
| | | order.setId(appUserWithdraw.getId()); |
| | | order.setBizOrderNo(appUserWithdraw.getCode()); |
| | | order.setUid(appUserWithdraw.getId()+""); |
| | | order.setBuyContent("提现"); |
| | | order.setAppUserId(appUserWithdraw.getAppUserId()); |
| | | order.setOrderFrom(5); |
| | | order.setPaymentStatus(appUserWithdraw.getWithdrawStatus()+1); |
| | | order.setPayType(4); |
| | | // 提现订单 |
| | | if (appUserWithdraw.getWithdrawStatus()==2){ |
| | | order.setRefundStatus(3); |
| | | }else{ |
| | | order.setRefundStatus(1); |
| | | } |
| | | order.setTotalAmount(appUserWithdraw.getAmount()); |
| | | order.setRealPayAmount(appUserWithdraw.getAmount()); |
| | | order.setPlatformMoney(appUserWithdraw.getAmount().multiply(new BigDecimal("-1"))); |
| | | order.setPaymentTime(appUserWithdraw.getWithdrawTime()); |
| | | order.setCreateTime(appUserWithdraw.getCreateTime()); |
| | | page.add(order); |
| | | } |
| | | Integer payCount = 0; |
| | | Integer completeCount = 0; |
| | | Integer cancelCount = 0; |
| | | BigDecimal totalMoney = new BigDecimal("0"); |
| | | for (Order record : page) { |
| | | if (record.getPaymentStatus()!=null){ |
| | | switch (record.getPaymentStatus()){ |
| | | case 1: |
| | | payCount++; |
| | | break; |
| | | case 2: |
| | | completeCount++; |
| | | break; |
| | | case 3: |
| | | cancelCount++; |
| | | break; |
| | | } |
| | | } |
| | | totalMoney = totalMoney.add(record.getTotalAmount()); |
| | | } |
| | | orderCountVO.setTotalCount(page.size()); |
| | | orderCountVO.setPayCount(payCount); |
| | | orderCountVO.setCompleteCount(completeCount); |
| | | orderCountVO.setCancelCount(cancelCount); |
| | | orderCountVO.setTotalMoney(totalMoney); |
| | | return R.ok(orderCountVO); |
| | | } |
| | | |
| | | |
| | | @PutMapping("/exportOrder") |
| | | @ApiOperation(value = "订单列表-导出", tags = {"管理后台-订单列表管理"}) |
| | | public void exportOrder(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | List<Integer> payType1 = new ArrayList<>(); |
| | | payType1.add(1); |
| | | payType1.add(5); |
| | | List<Integer> payType2 = new ArrayList<>(); |
| | | payType2.add(2); |
| | | payType2.add(6); |
| | | List<Integer> payType3 = new ArrayList<>(); |
| | | payType3.add(3); |
| | | payType3.add(7); |
| | | List<Integer> payType4 = new ArrayList<>(); |
| | | payType4.add(4); |
| | | payType4.add(5); |
| | | payType4.add(6); |
| | | payType4.add(7); |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(courseDTO.getIds())){ |
| | | courseLambdaQueryWrapper.in(Order::getId, Arrays.asList(courseDTO.getIds().split(","))); |
| | | } |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 4); |
| | | courseLambdaQueryWrapper.ne(Order::getOrderFrom, 5); |
| | | if (StringUtils.hasLength(courseDTO.getPayType())){ |
| | | courseLambdaQueryWrapper.in(Order::getPayType,Arrays.asList(courseDTO.getPayType().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPaymentStatus())){ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getPaymentStatus().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getOrderFrom())){ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getOrderFrom().split(","))); |
| | | } |
| | | courseLambdaQueryWrapper.eq(courseDTO.getUid()!=null&&(!courseDTO.getUid().isEmpty()),Order::getAppUserId, courseDTO.getUid()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | List<OrderExport> orderExports = new ArrayList<>(); |
| | | for (Order record : page) { |
| | | record.setUid(record.getId().toString()); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getIconUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | } |
| | | } |
| | | OrderExport orderExport = new OrderExport(); |
| | | orderExport.setCode(record.getBizOrderNo()); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | orderExport.setUserName(byId1.getNickname()); |
| | | orderExport.setCellphone(byId1.getCellPhone()); |
| | | } |
| | | orderExport.setRealPayAmount("¥"+record.getRealPayAmount()); |
| | | orderExport.setBuyContent(record.getBuyContent()); |
| | | orderExport.setOrderFrom(record.getOrderFrom()+""); |
| | | orderExport.setPayType(record.getPayType()); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String format = df.format(record.getCreateTime()); |
| | | orderExport.setCreateTime(format); |
| | | orderExport.setPaymentStatus(record.getPaymentStatus()+""); |
| | | orderExports.add(orderExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), OrderExport.class, orderExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("订单管理导出.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @PostMapping("/orderList") |
| | | @ApiOperation(value = "订单列表管理列表-分页", tags = {"管理后台-订单列表管理"}) |
| | | public R<PageDTO<Order>> orderList(@RequestBody OrderListDTO courseDTO) { |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPayType())){ |
| | | courseLambdaQueryWrapper.in(Order::getPayType,Arrays.asList(courseDTO.getPayType().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPaymentStatus())){ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getPaymentStatus().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getOrderFrom())){ |
| | | courseLambdaQueryWrapper.in(Order::getOrderFrom, Arrays.asList(courseDTO.getOrderFrom().split(","))); |
| | | } |
| | | courseLambdaQueryWrapper.eq(courseDTO.getUid()!=null&&(!courseDTO.getUid().isEmpty()),Order::getAppUserId, courseDTO.getUid()); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | |
| | | Page<Order> page = orderService.page(new Page<>(courseDTO.getPageCurr(), courseDTO.getPageSize()), courseLambdaQueryWrapper); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | | for (Order record : page.getRecords()) { |
| | | record.setUid(record.getId().toString()); |
| | | AppUser byId1 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | if (Objects.nonNull(byId1)){ |
| | | record.setUserName(byId1.getNickname()); |
| | | record.setCellPhone(byId1.getCellPhone()); |
| | | record.setAvatar(byId1.getAvatar()); |
| | | } |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | String[] split = data.getCoverUrl().split(","); |
| | | if (split.length>=2){ |
| | | record.setCoverUrl(split[0]); |
| | | }else { |
| | | record.setCoverUrl(data.getCoverUrl()); |
| | | } |
| | | record.setIconUrl(StringUtils.hasLength(data.getCoverUrl())?data.getCoverUrl().split(",")[0]:""); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(record.getRealPayAmount()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(record.getRealPayAmount()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return R.ok(PageDTO.of(page, Order.class)); |
| | | } |
| | | @PostMapping("/orderCount") |
| | | @ApiOperation(value = "订单列表管理列表上方合计数据", tags = {"管理后台-订单列表管理"}) |
| | | public R<OrderCountVO> orderCount(@RequestBody OrderListDTO courseDTO) { |
| | | OrderCountVO orderCountVO = new OrderCountVO(); |
| | | String startTime = null; |
| | | String endTime = null; |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getTime())){ |
| | | String[] split = courseDTO.getTime().split(" - "); |
| | | startTime = split[0]+" 00:00:00"; |
| | | endTime = split[1]+" 23:59:59"; |
| | | } |
| | | |
| | | LambdaQueryWrapper<Order> courseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (startTime!=null){ |
| | | courseLambdaQueryWrapper.between(Order::getCreateTime, startTime, endTime); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPayType())){ |
| | | courseLambdaQueryWrapper.in(Order::getPayType,Arrays.asList(courseDTO.getPayType().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getPaymentStatus())){ |
| | | courseLambdaQueryWrapper.in(Order::getPaymentStatus, Arrays.asList(courseDTO.getPaymentStatus().split(","))); |
| | | } |
| | | if (StringUtils.hasLength(courseDTO.getOrderFrom())){ |
| | | courseLambdaQueryWrapper.in(Order::getOrderFrom, Arrays.asList(courseDTO.getOrderFrom().split(","))); |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getBuyContent())){ |
| | | // 查询购买内容 |
| | | List<Long> collect1 = orderService.lambdaQuery().like(Order::getBuyContent, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> collect2 = orderService.lambdaQuery().like(Order::getBizOrderNo, courseDTO.getBuyContent()).list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | List<Long> data = remoteCourseService.getCourseIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data) |
| | | .eq(Order::getOrderFrom, 2) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | List<Long> data1 = remoteMeditationService.getMeditationIdsByName(courseDTO.getBuyContent()).getData(); |
| | | if (!data1.isEmpty()){ |
| | | List<Long> collect3 = orderService.lambdaQuery().in(Order::getBusinessId, data1) |
| | | .eq(Order::getOrderFrom, 1) |
| | | .list().stream() |
| | | .map(Order::getId).collect(Collectors.toList()); |
| | | if (!collect3.isEmpty()){ |
| | | collect1.addAll(collect3); |
| | | } |
| | | } |
| | | |
| | | collect1.addAll(collect2); |
| | | List<Long> collect = collect1.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getId,collect); |
| | | } |
| | | courseLambdaQueryWrapper.orderByDesc(Order::getCreateTime); |
| | | if (org.springframework.util.StringUtils.hasLength(courseDTO.getUserNameOrPhone())){ |
| | | List<Long> collect = remoteAppUserService.getAppUserByNameOrPhone(courseDTO.getUserNameOrPhone()).getData(); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | courseLambdaQueryWrapper.in(Order::getAppUserId, collect); |
| | | } |
| | | List<Order> page = orderService.list(courseLambdaQueryWrapper); |
| | | Integer payCount = 0; |
| | | Integer completeCount = 0; |
| | | Integer cancelCount = 0; |
| | | BigDecimal totalMoney = new BigDecimal("0"); |
| | | for (Order record : page) { |
| | | if (record.getPaymentStatus()!=null){ |
| | | switch (record.getPaymentStatus()){ |
| | | case 1: |
| | | payCount++; |
| | | break; |
| | | case 2: |
| | | completeCount++; |
| | | break; |
| | | case 3: |
| | | cancelCount++; |
| | | break; |
| | | } |
| | | } |
| | | if (record.getRealPayAmount()!=null){ |
| | | totalMoney = totalMoney.add(record.getTotalAmount()); |
| | | } |
| | | } |
| | | orderCountVO.setTotalCount(page.size()); |
| | | orderCountVO.setPayCount(payCount); |
| | | orderCountVO.setCompleteCount(completeCount); |
| | | orderCountVO.setCancelCount(cancelCount); |
| | | orderCountVO.setTotalMoney(totalMoney); |
| | | return R.ok(orderCountVO); |
| | | } |
| | | |
| | | @GetMapping("/detailOrder") |
| | | @ApiOperation(value = "查看详情订单列表管理", tags = "管理后台-订单列表管理") |
| | | public R<Order> detailOrder(String uid) { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Order record = orderService.getById(uid); |
| | | |
| | | if (record.getGiveUserId()!=null){ |
| | | AppUser data1 = remoteAppUserService.getAppUserById(record.getGiveUserId() + "").getData(); |
| | | record.setUserNameGive(data1.getNickname()); |
| | | } |
| | | |
| | | record.setPlatformMoney(record.getRealPayAmount()==null?new BigDecimal("0"):(record.getRealPayAmount().subtract( |
| | | record.getCommissionAmount()==null?new BigDecimal("0"):record.getCommissionAmount()))); |
| | | if (record.getOrderFrom()!=null){ |
| | | switch (record.getOrderFrom()){ |
| | | case 1: |
| | | Meditation data = remoteMeditationService.getMeditationById(record.getBusinessId()).getData(); |
| | | if (data!=null){ |
| | | record.setCategoryMeditationName(data.getCategoryName()); |
| | | record.setMeditationTitle(data.getMeditationTitle()); |
| | | record.setIconUrl(data.getCoverUrl()); |
| | | record.setDetailDescription(data.getDetailDescription()); |
| | | record.setGeneralPriceMeditation(data.getGeneralPrice()); |
| | | record.setListingStatusMeditation(data.getListingStatus()); |
| | | record.setMeditationUid(data.getId()+""); |
| | | record.setUuid(data.getId()+""); |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | Course data1 = remoteCourseService.getCourseById(record.getBusinessId()).getData(); |
| | | if (data1!=null){ |
| | | record.setCategoryCourseName(data1.getCategoryName()); |
| | | record.setCourseTitle(data1.getCourseTitle()); |
| | | record.setCoverUrl(data1.getCoverUrl()); |
| | | record.setTutor(data1.getTutor()); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | record.setGeneralPriceCourse(data1.getGeneralPrice()); |
| | | record.setListingStatusCourse(data1.getListingStatus()); |
| | | record.setCourseUid(data1.getId()+""); |
| | | record.setType(data1.getCourseType()+""); |
| | | record.setUuid(data1.getId()+""); |
| | | record.setCourseChapterCount(data1.getCourseChapterCount()); |
| | | } |
| | | break; |
| | | case 3: |
| | | record.setBuyContent(record.getBuyContent()); |
| | | record.setGeneralPriceVip(record.getRealPayAmount()); |
| | | break; |
| | | } |
| | | } |
| | | record.setUid(record.getId().toString()); |
| | | AppUser byId2 = remoteAppUserService.getAppUserById(record.getAppUserId()+"").getData(); |
| | | AppUser byId3 = remoteAppUserService.getAppUserById(record.getGiveUserId()+"").getData(); |
| | | if (Objects.nonNull(byId2)){ |
| | | record.setUserName(byId2.getNickname()); |
| | | record.setAvatar(byId2.getAvatar()); |
| | | record.setCellPhone(byId2.getCellPhone()); |
| | | } |
| | | if (Objects.nonNull(byId3)){ |
| | | record.setUserNameGive(byId3.getNickname()); |
| | | record.setAvatarGive(byId3.getAvatar()); |
| | | record.setCellPhoneGive(byId3.getCellPhone()); |
| | | } |
| | | if (record.getChangePriceOperator()!=null){ |
| | | SysUser data = remoteUserService.getSysUserById(record.getChangePriceOperator() + "").getData(); |
| | | record.setChangePriceOperatorName(data.getNickName()+"("+data.getUserName()+")"); |
| | | } |
| | | if (record.getPayType()!=null){ |
| | | List<OrderPaymentRecord> list = orderPaymentRecordService.list(new LambdaQueryWrapper<OrderPaymentRecord>() |
| | | .eq(OrderPaymentRecord::getOrderId, record.getId()) |
| | | .orderByDesc(OrderPaymentRecord::getPaymentType) |
| | | ); |
| | | if (record.getPayType() ==5 || record.getPayType()==6 || record.getPayType()==7){ |
| | | if(record.getRealPayAmount()!=null){ |
| | | switch (record.getPayType()){ |
| | | case 5: |
| | | if (!list.isEmpty()){ |
| | | OrderPaymentRecord orderPaymentRecord = list.get(1); |
| | | OrderPaymentRecord orderPaymentRecord1 = list.get(0); |
| | | switch (orderPaymentRecord.getPaymentType()){ |
| | | case 1: |
| | | record.setPaymentType("微信(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | case 2: |
| | | record.setPaymentType("支付宝(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | |
| | | break; |
| | | case 3: |
| | | record.setPaymentType("内购(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case 6: |
| | | if (!list.isEmpty()){ |
| | | OrderPaymentRecord orderPaymentRecord = list.get(1); |
| | | OrderPaymentRecord orderPaymentRecord1 = list.get(0); |
| | | switch (orderPaymentRecord.getPaymentType()){ |
| | | case 1: |
| | | record.setPaymentType("微信(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | case 2: |
| | | record.setPaymentType("支付宝(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | |
| | | break; |
| | | case 3: |
| | | record.setPaymentType("内购(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case 7: |
| | | if (!list.isEmpty()){ |
| | | OrderPaymentRecord orderPaymentRecord = list.get(1); |
| | | OrderPaymentRecord orderPaymentRecord1 = list.get(0); |
| | | switch (orderPaymentRecord.getPaymentType()){ |
| | | case 1: |
| | | record.setPaymentType("微信(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | case 2: |
| | | record.setPaymentType("支付宝(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | |
| | | break; |
| | | case 3: |
| | | record.setPaymentType("内购(¥"+(orderPaymentRecord.getPayAmount()==null?"":orderPaymentRecord.getPayAmount())+")" |
| | | +" + 余额(¥"+orderPaymentRecord1.getPayAmount()+")"); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | if(record.getRealPayAmount()!=null){ |
| | | switch (record.getPayType()){ |
| | | case 1: |
| | | record.setPaymentType("微信(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | case 2: |
| | | record.setPaymentType("支付宝(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | case 4: |
| | | record.setPaymentType("余额(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | case 3: |
| | | record.setPaymentType("内购(¥"+record.getRealPayAmount()+")"); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (record.getRefundStatus()==3){ |
| | | // 已退款 |
| | | record.setPaymentStatus(4); |
| | | record.setCancelTime(record.getRefundTime()); |
| | | } |
| | | return R.ok(record); |
| | | } |
| | | @GetMapping("/cancel") |
| | | @ApiOperation(value = "取消订单", tags = "管理后台-订单列表管理") |
| | | public R updateState(String uid) { |
| | | Order byId = orderService.getById(uid); |
| | | byId.setPaymentStatus(3); |
| | | byId.setCancelTime(LocalDateTime.now()); |
| | | orderService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/getChangeMoney") |
| | | @ApiOperation(value = "获取改价页面数据", tags = "管理后台-订单列表管理") |
| | | public R<Order> getChangeMoney(String uid) { |
| | | Order byId = orderService.getById(uid); |
| | | AppUser data = remoteAppUserService.getAppUserById(byId.getAppUserId() + "").getData(); |
| | | if (data!=null){ |
| | | byId.setCellPhone(data.getCellPhone()); |
| | | byId.setUserName(data.getNickname()); |
| | | byId.setAvatar(data.getAvatar()); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/ChangeMoney") |
| | | @ApiOperation(value = "改价", tags = "管理后台-订单列表管理") |
| | | public R ChangeMoney(String uid,String amount) { |
| | | Order byId = orderService.getById(uid); |
| | | byId.setChangePrice(new BigDecimal(amount)); |
| | | byId.setChangePriceTime(LocalDateTime.now()); |
| | | byId.setRealPayAmount(byId.getTotalAmount().add(byId.getChangePrice())); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | byId.setChangePriceOperator(loginUser.getUserid()); |
| | | orderService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |