无关风月
2025-01-01 ca070436770f715572405880cfe548c02f639c73
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderController.java
@@ -100,13 +100,13 @@
    @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();
    }
@@ -117,19 +117,24 @@
        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())
                .eq(TOrder::getGoodType, 1)
                .eq(TOrder::getPaymentStatus, 2).count();
        course.setBuyNum(Integer.parseInt(String.valueOf(count)));
        return R.ok(course);
    }
@@ -137,22 +142,22 @@
    @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);
    }
@@ -160,19 +165,19 @@
    @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);
@@ -183,11 +188,11 @@
    @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());
@@ -197,19 +202,19 @@
    @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);
            }
        }
@@ -220,24 +225,25 @@
    @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()) {
        List<TOrder> tOrders = orderService.listExport(orderQuery);
        List<TCourse> courses = courseService.lambdaQuery().list();
        List<TInformation> informations = informationService.lambdaQuery().list();
        for (TOrder record : tOrders) {
            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,tOrders );
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");