mitao
2025-03-11 2e1a9c064309e60047473c78f0dd3a88c726bb8d
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/controller/management/MgtAuctionSalesroomController.java
@@ -5,6 +5,7 @@
import com.alibaba.excel.util.DateUtils;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.zxing.WriterException;
import com.ruoyi.auction.controller.management.dto.MgtAuctionSaleroomBidRecordQuery;
import com.ruoyi.auction.controller.management.dto.MgtAuctionSalesroomDTO;
@@ -16,6 +17,8 @@
import com.ruoyi.auction.mapper.AuctionBidRecordMapper;
import com.ruoyi.auction.service.IAuctionSalesroomGoodsService;
import com.ruoyi.auction.service.IAuctionSalesroomService;
import com.ruoyi.auction.util.weChat.EnvVersion;
import com.ruoyi.auction.util.weChat.WeChatUtil;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.enums.AuctionOrderTypeEnum;
@@ -34,10 +37,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
@@ -46,6 +46,7 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
@@ -67,6 +68,7 @@
    private final AuctionBidRecordMapper auctionBidRecordMapper;
    private final IAuctionSalesroomGoodsService auctionSalesroomGoodsService;
    private final GoodsSkuClient goodsSkuClient;
    private final WeChatUtil weChatUtil;
    /**
     * 分页查询拍卖场
@@ -91,8 +93,18 @@
    @ApiOperation(value = "查看二维码", notes = "查看二维码")
    public R<String> getQrCode(
            @ApiParam(name = "id", value = "拍卖场id", required = true) @PathVariable("id") Long id) {
        AuctionSalesroom auctionSalesroom = auctionSalesroomService.getById(id);
        if (StringUtils.isNotEmpty(auctionSalesroom.getQrCode())){
            return R.ok(auctionSalesroom.getQrCode());
        }
        try {
            return R.ok(auctionSalesroomService.getQrCode(id));
            String qrCode = weChatUtil.getwxacodeunlimit("pagesA/auctionDetail/auctionDetail", "id=" + auctionSalesroom.getAuctionSalesroomNo(),
                    EnvVersion.RELEASE, null);
            auctionSalesroom.setQrCode(qrCode);
            auctionSalesroomService.updateById(auctionSalesroom);
            return R.ok(qrCode);
        } catch (Exception e) {
            log.info("查看二维码异常", e);
            return R.fail();
@@ -161,7 +173,22 @@
    public void export(@RequestBody MgtAuctionSalesroomQuery query, HttpServletResponse response) {
        PageDTO<MgtAuctionSalesroomVO> page = auctionSalesroomService.getAuctionSalesroomPage(query);
        if (page.isEmpty()){
            return;
            response.setContentType(
                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.setCharacterEncoding("utf-8");
            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
            try {
                String fileName = URLEncoder.encode(
                                "优惠券领取明细" + DateUtils.format(new Date(), "yyyyMMddHHmmss"), "UTF-8")
                        .replaceAll("\\+", "%20");
                response.setHeader("Content-disposition",
                        "attachment;filename*=utf-8''" + fileName + ".xlsx");
                EasyExcel.write(response.getOutputStream(), AuctionBidRecordVO.class)
                        .sheet("优惠券领取明细")
                        .doWrite(new ArrayDeque<>());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        List<MgtAuctionSalesroomVO> list = page.getList();