| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @ApiOperation(value = "取消订单",tags = {"后台-订单管理","web-个人中心"}) |
| | | @PostMapping("/cancel") |
| | | public R cancel(Long orderId){ |
| | | TOrder byId = orderService.getById(orderId); |
| | | if (byId.getPaymentStatus()!=1){ |
| | | TOrder order = orderService.getById(orderId); |
| | | if (order.getPaymentStatus()!=1){ |
| | | return R.fail("订单状态异常"); |
| | | } |
| | | byId.setPaymentStatus(3); |
| | | byId.setCancelTime(LocalDateTime.now()); |
| | | orderService.updateById(byId); |
| | | order.setPaymentStatus(3); |
| | | order.setCancelTime(LocalDateTime.now()); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | TCourse course = courseService.getById(goodId); |
| | | |
| | | |
| | | TRegion byId = regionService.getById(course.getRegionId()); |
| | | course.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(course.getTechnicalId() ); |
| | | TTitleMajor byId2 = majorService.getById(course.getMajorId()); |
| | | course.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | TRegion region = regionService.getById(course.getRegionId()); |
| | | course.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | TTechnicalTitle tTechnicalTitle = tTechnicalTitleService.getById(course.getTechnicalId() ); |
| | | TTitleMajor titleMajor = majorService.getById(course.getMajorId()); |
| | | course.setTechnicalName(tTechnicalTitle.getTitileName()+"-"+titleMajor.getMajorName()); |
| | | |
| | | TOrder byId3 = orderService.getById(id); |
| | | TAppUser byId4 = appUserService.getById(byId3.getUserId()); |
| | | byId3.setName(byId4.getName()); |
| | | byId3.setPhone(byId4.getPhone()); |
| | | byId3.setAvatar(byId4.getAvatar()); |
| | | course.setOrder(byId3); |
| | | TOrder order = orderService.getById(id); |
| | | TAppUser appUser = appUserService.getById(order.getUserId()); |
| | | order.setName(appUser.getName()); |
| | | order.setPhone(appUser.getPhone()); |
| | | order.setAvatar(appUser.getAvatar()); |
| | | course.setOrder(order); |
| | | |
| | | Long count = orderService.lambdaQuery() |
| | | .eq(TOrder::getGoodId, course.getId()) |
| | |
| | | @ApiOperation(value = "工作总结详情",tags = "后台-订单管理") |
| | | @PostMapping("/generate/detail") |
| | | public R<TGeneratedRecords> detail(Long id){ |
| | | TOrder byId = orderService.getById(id); |
| | | TGeneratedRecords one = generatedRecordsService.lambdaQuery().eq(TGeneratedRecords::getUserId, byId.getUserId()).orderByDesc(TGeneratedRecords::getCreateTime).last("limit 1").one(); |
| | | if (one == null) { |
| | | TOrder order = orderService.getById(id); |
| | | TGeneratedRecords tGeneratedRecords = generatedRecordsService.lambdaQuery().eq(TGeneratedRecords::getUserId, order.getUserId()).orderByDesc(TGeneratedRecords::getCreateTime).last("limit 1").one(); |
| | | if (tGeneratedRecords == null) { |
| | | TGeneratedRecords generatedRecords = new TGeneratedRecords(); |
| | | generatedRecords.setOrder(byId); |
| | | generatedRecords.setOrder(order); |
| | | return R.ok(generatedRecords); |
| | | } |
| | | |
| | | TOrder byId3 = orderService.getById(id); |
| | | TAppUser byId4 = appUserService.getById(byId3.getUserId()); |
| | | byId3.setName(byId4.getName()); |
| | | byId3.setPhone(byId4.getPhone()); |
| | | byId3.setAvatar(byId4.getAvatar()); |
| | | one.setOrder(byId3); |
| | | TOrder tOrder = orderService.getById(id); |
| | | TAppUser appUser = appUserService.getById(tOrder.getUserId()); |
| | | tOrder.setName(appUser.getName()); |
| | | tOrder.setPhone(appUser.getPhone()); |
| | | tOrder.setAvatar(appUser.getAvatar()); |
| | | tGeneratedRecords.setOrder(tOrder); |
| | | |
| | | return R.ok(one); |
| | | return R.ok(tGeneratedRecords); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping(value = "/order/information/detail") |
| | | public R<TInformation> informationR1(Long goodId,Long id) { |
| | | TInformation record = informationService.getById(goodId); |
| | | TRegion byId = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor byId2 = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | TRegion region = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | TTechnicalTitle technicalTitle = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor titleMajor = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(technicalTitle.getTitileName()+"-"+titleMajor.getMajorName()); |
| | | |
| | | |
| | | TOrder byId3 = orderService.getById(id); |
| | | TAppUser byId4 = appUserService.getById(byId3.getUserId()); |
| | | byId3.setName(byId4.getName()); |
| | | byId3.setPhone(byId4.getPhone()); |
| | | byId3.setAvatar(byId4.getAvatar()); |
| | | record.setOrder(byId3); |
| | | TOrder order = orderService.getById(id); |
| | | TAppUser appUser = appUserService.getById(order.getUserId()); |
| | | order.setName(appUser.getName()); |
| | | order.setPhone(appUser.getPhone()); |
| | | order.setAvatar(appUser.getAvatar()); |
| | | record.setOrder(order); |
| | | |
| | | |
| | | return R.ok(record); |
| | |
| | | @PostMapping(value = "/information/detail") |
| | | public R<TInformation> informationR(Long goodId) { |
| | | TInformation record = informationService.getById(goodId); |
| | | TRegion byId = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor byId2 = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | TRegion region = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | TTechnicalTitle technicalTitle = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor tTitleMajor = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(technicalTitle.getTitileName()+"-"+tTitleMajor.getMajorName()); |
| | | |
| | | |
| | | |
| | |
| | | @ApiOperation(value = "退款",tags = "后台-资料管理") |
| | | @PostMapping(value = "/refund") |
| | | public R<TInformation> refund(Long orderId) throws AlipayApiException { |
| | | TOrder byId = orderService.getById(orderId); |
| | | if (byId.getPaymentStatus()!=2){ |
| | | TOrder order = orderService.getById(orderId); |
| | | if (order.getPaymentStatus()!=2){ |
| | | return R.fail("订单状态异常"); |
| | | } |
| | | |
| | | if (byId.getPaymentType()==1){ |
| | | payMoneyUtil.wxRefund(byId.getSerialNumber(), byId.getCode(),byId.getPaymentAmount().toString(), byId.getPaymentAmount().toString(),"/"); |
| | | if (order.getPaymentType()==1){ |
| | | payMoneyUtil.wxRefund(order.getSerialNumber(), order.getCode(),order.getPaymentAmount().toString(), order.getPaymentAmount().toString(),"/"); |
| | | } |
| | | if (byId.getPaymentType()==2){ |
| | | Map<String, String> stringStringMap = payMoneyUtil.aliRefund(byId.getCode(), byId.getPaymentAmount().toString()); |
| | | if (order.getPaymentType()==2){ |
| | | Map<String, String> stringStringMap = payMoneyUtil.aliRefund(order.getCode(), order.getPaymentAmount().toString()); |
| | | if ("10000".equals(stringStringMap.get("code"))){ |
| | | byId.setPaymentStatus(4); |
| | | orderService.updateById(byId); |
| | | order.setPaymentStatus(4); |
| | | orderService.updateById(order); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "导出",tags = "后台-订单管理") |
| | | @PostMapping(value = "/export") |
| | | public void mealGeneratorExport(@RequestBody OrderQuery orderQuery) { |
| | | orderQuery.setPageNum(1); |
| | | orderQuery.setPageSize(9999); |
| | | PageInfo<TOrder> tOrderPageInfo = orderService.pageList(orderQuery); |
| | | for (TOrder record : tOrderPageInfo.getRecords()) { |
| | | |
| | | |
| | | int pageSize = 100; |
| | | int currentPage = 0; |
| | | List<TOrder> page = new ArrayList<>(); |
| | | |
| | | while (true) { |
| | | orderQuery.setPageNum(currentPage * pageSize); |
| | | orderQuery.setPageSize(pageSize); |
| | | PageInfo<TOrder> tOrderPageInfo = orderService.pageList(orderQuery); |
| | | List<TOrder> records = tOrderPageInfo.getRecords(); |
| | | if (CollectionUtils.isEmpty(records)) { |
| | | break; // 没有更多数据,退出循环 |
| | | } |
| | | page.addAll(records); // 累加当前页数据 |
| | | currentPage++; // 进入下一页 |
| | | } |
| | | |
| | | List<TCourse> courses = courseService.lambdaQuery().list(); |
| | | List<TInformation> informations = informationService.lambdaQuery().list(); |
| | | for (TOrder record : page) { |
| | | record.getFormattedCreateTime(); |
| | | if (record.getGoodType()==1){ |
| | | TCourse byId = courseService.getById(record.getGoodId()); |
| | | record.setGoodName(byId.getCourseName()); |
| | | TCourse course = courses.stream().filter(e -> e.getId().equals(record.getGoodId())).findFirst().orElse(null); |
| | | record.setGoodName(course.getCourseName()); |
| | | }else if (record.getGoodType()==2){ |
| | | TInformation byId = informationService.getById(record.getGoodId()); |
| | | record.setGoodName(byId.getInformationName()); |
| | | TInformation information = informations.stream().filter(e -> e.getId().equals(record.getGoodId())).findFirst().orElse(null); |
| | | record.setGoodName(information.getInformationName()); |
| | | }else { |
| | | record.setGoodName("工作总结订单"); |
| | | } |
| | | } |
| | | |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrder.class,tOrderPageInfo.getRecords() ); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrder.class,page); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |