xuhy
2025-12-31 5fbf6c24a047cd345682aa1e6fa043fff2f44bd2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TMerchantController.java
@@ -24,6 +24,8 @@
import com.ruoyi.system.query.TMerchantQuery;
import com.ruoyi.system.service.TMerchantService;
import com.ruoyi.system.service.TMerchantTypeService;
import com.ruoyi.system.vo.TMerchantVO;
import com.ruoyi.web.controller.tool.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -46,6 +48,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -76,7 +79,7 @@
     */
    @ApiOperation(value = "获取商户信息管理分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TMerchant>> pageList(@RequestBody TMerchantQuery query) {
    public R<PageInfo<TMerchantVO>> pageList(@RequestBody TMerchantQuery query) {
        return R.ok(merchantService.pageList(query));
    }
@@ -148,9 +151,14 @@
    @GetMapping("/import-template")
    public void importTemplate() {
        List<MerchantImport> merchantImports = new ArrayList<>();
        MerchantImport merchantImport = new MerchantImport();
        merchantImports.add(merchantImport);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MerchantImport.class, merchantImports);
        // 查询分类列表
        List<TMerchantType> merchantTypes = merchantTypeService.list(Wrappers.lambdaQuery(TMerchantType.class).orderByDesc(TMerchantType::getCreateTime));
        List<String> dataList = new ArrayList<>();
        if (!CollectionUtils.isEmpty(merchantTypes)) {
            dataList = merchantTypes.stream().map(TMerchantType::getTypeName).collect(Collectors.toList());
        }
        ExcelUtil.selectList(workbook, 1, 65535, 2, 2, dataList.toArray(new String[dataList.size()]), 1);
        HttpServletResponse response = WebUtils.response();
        ServletOutputStream outputStream = null;
        try {
@@ -205,18 +213,22 @@
        for (MerchantImport merchantImport : merchantImports) {
            if (!StringUtils.hasLength(merchantImport.getMerchantName())){
                result.append("第"+i+"行:[", "商户名称"+"]不能为空");
                i++;
                continue;
            }
            if (!StringUtils.hasLength(merchantImport.getMerchantPhone())){
                result.append("第"+i+"行:[", "商户电话"+"]不能为空");
                i++;
                continue;
            }
            if (!StringUtils.hasLength(merchantImport.getTypeName())){
                result.append("第"+i+"行:[", "商户分类"+"]不能为空");
                i++;
                continue;
            }
            if (!StringUtils.hasLength(merchantImport.getAddress())){
                result.append("第"+i+"行:[", "商户地址"+"]不能为空");
                i++;
                continue;
            }
            TMerchantType merchantType = merchantTypeService.getOne(Wrappers.lambdaQuery(TMerchantType.class)
@@ -224,6 +236,7 @@
                    .last("LIMIT 1"));
            if(Objects.isNull(merchantType)){
                result.append("第"+i+"行:[", "商户分类"+"]不存在");
                i++;
                continue;
            }
            TMerchant merchant = new TMerchant();