瀏覽代碼

ldm机构数据导入

Aslee 3 年之前
父節點
當前提交
911de87c5b

+ 8 - 0
src/main/java/com/caimei/controller/AuthApi.java

@@ -173,6 +173,14 @@ public class AuthApi {
     }
 
 
+    @ApiOperation("ldm导入")
+    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    @PostMapping("/ldm/import")
+    public ResponseJson importLdmData(Integer authUserId) {
+        return authService.importLdmData(authUserId);
+    }
+
+
     @ApiOperation("excel导出")
     @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/export/excel")

+ 9 - 0
src/main/java/com/caimei/mapper/AuthMapper.java

@@ -1,6 +1,7 @@
 package com.caimei.mapper;
 
 import com.caimei.model.po.CmBrandAuthPo;
+import com.caimei.model.po.LdmDataPo;
 import com.caimei.model.vo.AuthVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -44,4 +45,12 @@ public interface AuthMapper {
     void insertBanner(@Param("authId") Integer authId, @Param("banner") String banner);
 
     List<String> getBannerList(Integer authId);
+
+    List<LdmDataPo> getLdmData();
+
+    Integer getProvinceId(String regId1);
+
+    Integer getCityId(String regId1);
+
+    Integer getTownId(String regId1);
 }

+ 5 - 0
src/main/java/com/caimei/model/po/CmBrandAuthPo.java

@@ -87,6 +87,11 @@ public class CmBrandAuthPo {
      */
     private Integer createBy;
 
+    /**
+     * 删除标志:1已删除,0不是
+     */
+    private Integer delFlag;
+
     /**
      * 商品列表
      */

+ 119 - 0
src/main/java/com/caimei/model/po/LdmDataPo.java

@@ -0,0 +1,119 @@
+package com.caimei.model.po;
+
+import com.caimei.model.vo.ProductFormVo;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * cm_brand_auth
+ * @author 
+ */
+@Data
+public class LdmDataPo {
+    private Integer id;
+
+    /**
+     * 供应商用户id
+     */
+    private Integer authUserId;
+
+    /**
+     * 被授权方名称
+     */
+    private String authParty;
+
+    /**
+     * 省id
+     */
+    private Integer provinceId;
+
+    /**
+     * 市id
+     */
+    private Integer cityId;
+
+    /**
+     * 区id
+     */
+    private Integer townId;
+
+    private String regId1;
+    private String regId2;
+    private String regId3;
+
+    /**
+     * 区域
+     */
+    private String area;
+
+    /**
+     * 详细地址
+     */
+    private String address;
+
+    /**
+     * 经度
+     */
+    private BigDecimal lng;
+
+    /**
+     * 纬度
+     */
+    private BigDecimal lat;
+
+    /**
+     * 联系方式
+     */
+    private String mobile;
+
+    /**
+     * 机构logo
+     */
+    private String logo;
+
+
+    private String pic1;
+
+    private String pic2;
+
+    private String pic3;
+
+    private String pic4;
+
+    private String pic5;
+
+    private String lngAndLat;
+
+    /**
+     * 上线状态:0已下线,1已上线,2待上线
+     */
+    private Integer status;
+
+    /**
+     * 审核状态:0审核未通过,1审核通过,2待审核
+     */
+    private Integer auditStatus;
+
+    /**
+     * 创建人Id
+     */
+    private Integer createBy;
+
+    /**
+     * 删除标志:1已删除,0不是
+     */
+    private Integer delFlag;
+
+    /**
+     * 商品列表
+     */
+    private List<ProductFormVo> productList;
+
+    /**
+     * 商品参数数量最大值
+     */
+    private Integer maxParamNum;
+
+}

+ 9 - 0
src/main/java/com/caimei/service/AuthService.java

@@ -78,6 +78,15 @@ public interface AuthService {
      */
     ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy);
 
+    /**
+     * 导入excel中的授权机构和商品数据
+     * @param file          excel表格
+     * @param authUserId    供应商用户id
+     * @param createBy
+     * @return
+     */
+    ResponseJson importLdmData(Integer authUserId);
+
     /**
      * 导出授权机构和商品数据
      * @param authUserId    供应商用户id

+ 6 - 0
src/main/java/com/caimei/service/UploadService.java

@@ -22,6 +22,12 @@ public interface UploadService {
      */
     String saveFile(MultipartFile file) throws IOException;
 
+    /**
+     * 通过url上传文件
+     * @return
+     */
+    String saveFileByUrl(String url,String fileName) throws Exception;
+
     /**
      * 将多张图片压缩并上传
      * @param imageArr

+ 353 - 0
src/main/java/com/caimei/service/impl/AuthServiceImpl.java

@@ -7,6 +7,7 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.AuthImportPo;
 import com.caimei.model.po.CmBrandAuthPo;
+import com.caimei.model.po.LdmDataPo;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
@@ -14,10 +15,14 @@ import com.caimei.model.vo.ProductFormVo;
 import com.caimei.service.AuthProductService;
 import com.caimei.service.AuthService;
 import com.caimei.service.ShopService;
+import com.caimei.service.UploadService;
 import com.caimei.utils.ExcelOperateUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.github.tobato.fastdfs.domain.StorePath;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
@@ -33,6 +38,7 @@ import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.math.BigDecimal;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.*;
@@ -68,6 +74,13 @@ public class AuthServiceImpl implements AuthService {
         this.shopService = shopService;
     }
 
+    private UploadService uploadService;
+
+    @Autowired
+    public void setUploadService(UploadService uploadService) {
+        this.uploadService = uploadService;
+    }
+
     @Value("${spring.profiles.active}")
     private String active;
 
@@ -77,6 +90,9 @@ public class AuthServiceImpl implements AuthService {
     @Value("${caimei.imageDomain}")
     private String imageDomain;
 
+    @Autowired
+    private FastFileStorageClient storageClient;
+
     @Override
     public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, Integer status, Integer auditStatus, Integer lowerAuditStatus, Integer pageNum, Integer pageSize) {
         if (null == authUserId) {
@@ -184,6 +200,7 @@ public class AuthServiceImpl implements AuthService {
         // 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
         auth.setStatus(2);
         auth.setAuditStatus(2);
+        auth.setDelFlag(0);
         /*
             保存授权
          */
@@ -256,6 +273,75 @@ public class AuthServiceImpl implements AuthService {
         return null;
     }
 
+    @Override
+    public ResponseJson importLdmData(Integer authUserId) {
+        List<LdmDataPo> ldmDataList = authMapper.getLdmData();
+        ldmDataList.forEach(ldmData->{
+            String lngAndLat = ldmData.getLngAndLat();
+            if (StringUtils.isNotEmpty(lngAndLat)) {
+                String[] split = lngAndLat.split(",");
+                BigDecimal lng = new BigDecimal(split[0]);
+                BigDecimal lat = new BigDecimal(split[1]);
+                ldmData.setLng(lng);
+                ldmData.setLat(lat);
+            }
+            String regId1 = ldmData.getRegId1();
+            if (StringUtils.isNotEmpty(regId1)) {
+                Integer provinceId = authMapper.getProvinceId(regId1);
+                ldmData.setProvinceId(provinceId);
+            }
+            String regId2 = ldmData.getRegId2();
+            if (StringUtils.isNotEmpty(regId2)) {
+                Integer cityId = authMapper.getCityId(regId2);
+                ldmData.setCityId(cityId);
+            }
+            String regId3 = ldmData.getRegId3();
+            if (StringUtils.isNotEmpty(regId3)) {
+                Integer townId = authMapper.getTownId(regId3);
+                ldmData.setTownId(townId);
+            }
+            String pic1 = ldmData.getPic1();
+            String pic2 = ldmData.getPic2();
+            String pic3 = ldmData.getPic3();
+            String pic4 = ldmData.getPic4();
+            String pic5 = ldmData.getPic5();
+            List<String> picList = new ArrayList<>();
+            picList.add(pic1);
+            picList.add(pic2);
+            picList.add(pic3);
+            picList.add(pic4);
+            picList.add(pic5);
+            String logo = null;
+            List<String> addPicList = new ArrayList<>();
+            for (String pic : picList) {
+                if (StringUtils.isNotEmpty(pic)) {
+                    try {
+                        String imagePath = "https://wangdian.skinovachina.com" + pic;
+                        String fileName = imagePath.substring(imagePath.lastIndexOf("/") + 1);
+                        String imageUrl = uploadService.saveFileByUrl(imagePath, fileName);
+                        addPicList.add(imageUrl);
+                        if (null == logo) {
+                            logo = imageUrl;
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+            CmBrandAuthPo authPo = new CmBrandAuthPo();
+            BeanUtils.copyProperties(ldmData, authPo);
+            authPo.setAuthUserId(authUserId);
+            authPo.setCreateBy(authUserId);
+            authPo.setLogo(logo);
+            authMapper.insertAuth(authPo);
+            // 保存轮播图
+            if (addPicList.size() > 0) {
+                addPicList.forEach(banner -> authMapper.insertBanner(authPo.getId(), banner));
+            }
+        });
+        return ResponseJson.success();
+    }
+
     @Override
     public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
         try {
@@ -527,6 +613,273 @@ public class AuthServiceImpl implements AuthService {
         return ResponseJson.success("导入成功");
     }
 
+    /*private ResponseJson saveLdmData(String filePath, Integer authUserId, Integer createBy) {
+        //判断是否为excel类型文件
+        if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx")) {
+            System.out.println("文件不是excel类型");
+        }
+        // 获取供应商品牌
+        List<String> shopBrands = shopService.getShopBrands(authUserId);
+
+        // 授权列表
+        List<AuthImportPo> authImportList = new ArrayList<>();
+
+        List<String> tempImageList = new ArrayList<>();
+
+        try {
+            FileInputStream fis = new FileInputStream(filePath);
+            // 得到表格数据
+            XSSFWorkbook workbook = new XSSFWorkbook(fis);
+            // 获取工作表数量
+            int sheetsNum = workbook.getNumberOfSheets();
+
+            //得到第一个工作表(机构表)
+            XSSFSheet authPartySheet = workbook.getSheetAt(0);
+            // 获得数据的总行数
+            int authPartyRowNum = authPartySheet.getLastRowNum();
+
+            //获得所有数据
+            for (int i = 1; i <= authPartyRowNum; i++) {
+                //获得第i行对象
+                Row row = authPartySheet.getRow(i);
+                //获得获得第i行第0列的机构名称
+                Cell cell1 = row.getCell(1);
+                String authParty = cell1.getStringCellValue();
+                // 机构状态
+                Cell cell2 = row.getCell(2);
+                Integer status = 1 == Integer.parseInt(cell2.getStringCellValue()) ? 1 : 0;
+                // 审核状态
+                Integer auditStatus = 1 == status ? 1 : 0;
+                // 手机号
+                Cell cell4 = row.getCell(4);
+                String mobile = cell4.getStringCellValue();
+                // 详细地址
+                Cell cell5 = row.getCell(5);
+                String address = cell5.getStringCellValue();
+                // 图片
+                Cell cell8 = row.getCell(8);
+                String pic1 = cell8.getStringCellValue();
+                Cell cell9 = row.getCell(9);
+                String pic2 = cell8.getStringCellValue();
+                Cell cell10 = row.getCell(10);
+                String pic3 = cell8.getStringCellValue();
+                Cell cell11 = row.getCell(11);
+                String pic4 = cell8.getStringCellValue();
+                Cell cell12 = row.getCell(12);
+                String pic5 = cell8.getStringCellValue();
+                // 经纬度
+                Cell cell13 = row.getCell(13);
+                String lngAndLat = cell13.getStringCellValue();
+                String[] split = lngAndLat.split(",");
+                BigDecimal lng = new BigDecimal(split[0]);
+                BigDecimal lat = new BigDecimal(split[1]);
+                // 删除标志
+                Cell cell16 = row.getCell(16);
+                String delTime = cell13.getStringCellValue();
+                Integer delFlag = !"NULL".equals(delTime) ? 1 : 0;
+                // 省市区
+                Cell cell18 = row.getCell(18);
+                String dbProvinceId = cell18.getStringCellValue();
+                Cell cell19 = row.getCell(19);
+                String dbCityId = cell18.getStringCellValue();
+                Cell cell20 = row.getCell(20);
+                String dbTownId = cell18.getStringCellValue();
+
+                if (StringUtils.isNotEmpty(authParty)) {
+                    *//*
+                     * 授权数据
+                     *//*
+                    AuthImportPo authImportPo = new AuthImportPo();
+                    // 商品列表
+                    List<ProductSaveDto> productList = new ArrayList<>();
+
+                    // 得到机构对应的商品工作表
+                    XSSFSheet productSheet = i < sheetsNum ? workbook.getSheetAt(i) : null;
+                    String sheetName = null != productSheet ? productSheet.getSheetName() : null;
+                    if (null == productSheet || !authParty.equals(sheetName)) {
+                        // 遍历所有工作表,找到表名与授权机构名称相同的商品工作表
+                        for (int j = 1; j < sheetsNum; j++) {
+                            productSheet = workbook.getSheetAt(j);
+                            sheetName = productSheet.getSheetName();
+                            if (!authParty.equals(sheetName)) {
+                                // 没有该机构对应的商品表
+                                productSheet = null;
+                            }
+                        }
+                    }
+                    if (null != productSheet) {
+                        //获得表头
+                        Row productRowHead = productSheet.getRow(0);
+                        //判断表头是否正确
+                        short cellTotalNum = productRowHead.getLastCellNum();
+                        if (cellTotalNum < 13) {
+                            return ResponseJson.error(authParty + "机构商品表格式错误");
+                        }
+                        // 获取表格图片
+                        Map<String, XSSFPictureData> pictures = ExcelOperateUtil.getPictures(productSheet);
+                        Map<String, String> imageMap = ExcelOperateUtil.printImg(pictures);
+                        // 校验商品数据是否符合规范
+                        int productRowNum = productSheet.getLastRowNum();
+                        for (int k = 1; k <= productRowNum; k++) {
+                            XSSFRow productRow = productSheet.getRow(k);
+                            if (null != productRow && productRow.getCell(0) != null) {
+                                String errorReason = "";
+                                // 校验商品名称
+                                String productName = productRow.getCell(0).getStringCellValue();
+                                if (StringUtils.isEmpty(productName)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
+                                }
+                                // 校验商品sn码
+                                String snCode = productRow.getCell(1).getStringCellValue();
+                                if (StringUtils.isEmpty(snCode)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
+                                } else {
+                                    Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
+                                    if (null != productIdBySnCode || snCodeList.contains(snCode)) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行商品sn码已存在,请重新输入";
+                                    } else {
+                                        snCodeList.add(snCode);
+                                    }
+                                }
+                                // 校验品牌名称
+                                String brand = productRow.getCell(2).getStringCellValue();
+                                Integer brandId = null;
+                                if (StringUtils.isEmpty(brand)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不能为空";
+                                } else {
+                                    if (!shopBrands.contains(brand)) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不存在";
+                                    } else {
+                                        brandId = authProductMapper.getBrandIdByBrandName(brand);
+                                    }
+                                }
+                                // 校验商品图片
+                                String productImage = imageMap.get(k + "-3");
+                                if (StringUtils.isEmpty(productImage)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品图片不能为空";
+                                }
+                                // 校验授权牌照
+                                String certificateImage = imageMap.get(k + "-4");
+                                if (StringUtils.isEmpty(certificateImage)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行授权牌照不能为空";
+                                }
+                                List<ProductParamPo> paramList = new ArrayList<>();
+                                // 校验参数列表
+                                for (int a = 5; a + 1 < cellTotalNum; a += 2) {
+                                    XSSFCell paramNameCell = productRow.getCell(a);
+                                    XSSFCell paramContentCell = productRow.getCell(a + 1);
+                                    boolean validName = null != paramNameCell;
+                                    boolean validContent = null != paramContentCell;
+                                    if (validName && validContent) {
+                                        String paramName = paramNameCell.getStringCellValue();
+                                        String paramContent = paramContentCell.getStringCellValue();
+                                        validName = StringUtils.isNotEmpty(paramName);
+                                        validContent = StringUtils.isNotEmpty(paramContent);
+                                        if (validName && validContent) {
+                                            ProductParamPo productParamPo = new ProductParamPo();
+                                            productParamPo.setParamName(paramName);
+                                            productParamPo.setParamContent(paramContent);
+                                            paramList.add(productParamPo);
+                                        } else if ((validName || validContent)) {
+                                            errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
+                                        }
+                                    } else if (validName || validContent) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
+                                    }
+                                }
+                                if (paramList.size() < 4) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数量不足";
+                                }
+                                if (StringUtils.isNotEmpty(errorReason)) {
+                                    // 删除临时图片文件
+                                    for (String image : imageMap.values()) {
+                                        if (StringUtils.isNotEmpty(image)) {
+                                            File tempFile = new File(image);
+                                            tempFile.delete();
+                                        }
+                                    }
+                                    return ResponseJson.error(errorReason);
+                                }
+                                *//*
+                                    组装商品数据
+                                 *//*
+                                ProductSaveDto product = new ProductSaveDto();
+                                // 品牌id
+                                product.setBrandId(brandId);
+                                // 商品名称
+                                product.setProductName(productName);
+                                // sn码
+                                product.setSnCode(snCode);
+                                // 商品图片
+                                product.setProductImage(uploadImage(productImage));
+                                // 授权牌照
+                                product.setCertificateImage(uploadImage(certificateImage));
+                                // 参数列表
+                                product.setParamList(paramList);
+                                // 创建人
+                                product.setCreateBy(createBy);
+                                productList.add(product);
+                                tempImageList.add(productImage);
+                                tempImageList.add(certificateImage);
+                            }
+                        }
+                    }
+                    // 授权机构
+                    authImportPo.setAuthParty(authParty);
+                    // 商品列表
+                    authImportPo.setProductList(productList);
+                    // 添加数据
+                    authImportList.add(authImportPo);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseJson.error("导入失败,请检查表格数据");
+        } finally {
+            // 删除临时数据
+            File tempFile = new File(filePath);
+            boolean delete = tempFile.delete();
+            log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时表格:" + delete);
+            tempImageList.forEach(tempImagePath->{
+                File tempImage = new File(tempImagePath);
+                boolean del = tempImage.delete();
+                log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时商品图片:" + del);
+            });
+        }
+        // 保存授权数据
+        authImportList.forEach(authImportPo -> {
+            String authParty = authImportPo.getAuthParty();
+            List<ProductSaveDto> productList = authImportPo.getProductList();
+            Integer authId = authMapper.getAuthIdByAuthParty(authParty, authUserId);
+            // 保存授权机构
+            if (null == authId) {
+                CmBrandAuthPo auth = new CmBrandAuthPo();
+                auth.setAuthUserId(authUserId);
+                auth.setAuthParty(authParty);
+                auth.setCreateBy(createBy);
+                ResponseJson responseJson = saveAuth(auth, null, true);
+                CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
+                authId = authPo.getId();
+            }
+            Integer finalAuthId = authId;
+            // 保存商品列表
+            productList.forEach(productDto -> {
+                try {
+                    productDto.setAuthId(finalAuthId);
+                    // 上传商品图片和授权牌照
+                    String productImage = productDto.getProductImage();
+                    String certificateImage = productDto.getCertificateImage();
+                    productDto.setProductImage(productImage);
+                    productDto.setCertificateImage(certificateImage);
+                    authProductService.saveProduct(productDto, true);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            });
+        });
+        return ResponseJson.success("导入成功");
+    }*/
+
     private ResponseJson exportData(List<CmBrandAuthPo> authPartyList, OutputStream outputStream) {
         try {
             HSSFWorkbook workbook = new HSSFWorkbook();

+ 13 - 0
src/main/java/com/caimei/service/impl/UploadServiceImpl.java

@@ -122,6 +122,19 @@ public class UploadServiceImpl implements UploadService {
         return filePath;
     }
 
+    @Override
+    public String saveFileByUrl(String url,String fileName) throws Exception {
+        InputStream input = new URL(url).openStream();
+        File file = inputStreamToFile(input, fileName);
+        String filePath = System.getProperty("java.io.tmpdir") + File.separator + fileName;
+        log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
+        String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = file.delete();
+        log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+        return imageUrl;
+    }
+
 
     /**
      *   工具类

+ 30 - 6
src/main/resources/mapper/AuthMapper.xml

@@ -3,9 +3,9 @@
 <mapper namespace="com.caimei.mapper.AuthMapper">
     <insert id="insertAuth" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthPo">
         insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
-                                   mobile, logo, status, createTime, createBy, auditStatus)
+                                   mobile, logo, status, createTime, createBy, auditStatus, delFlag)
         values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
-                #{mobile}, #{logo}, #{status}, NOW(), #{createBy}, #{auditStatus})
+                #{mobile}, #{logo}, #{status}, NOW(), #{createBy}, #{auditStatus}, #{delFlag})
     </insert>
     <insert id="insertBanner">
         insert into cm_brand_auth_banner (authId, banner)
@@ -40,9 +40,9 @@
             auditTime     = #{auditTime}
         where id = #{authId}
     </update>
-    <delete id="deleteAuthByAuthId">
-        delete from cm_brand_auth where id = #{authId}
-    </delete>
+    <update id="deleteAuthByAuthId">
+        update cm_brand_auth set delFlag = 1 where id = #{authId}
+    </update>
     <delete id="deleteBanner">
         delete from cm_brand_auth_banner where authId = #{authId}
     </delete>
@@ -56,7 +56,7 @@
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where auditStatus = 2 group by
             authId) ap on a.id = ap.authId
-        where a.authUserId = #{authUserId}
+        where a.authUserId = #{authUserId} and delFlag = 0
         <if test="authParty != null and authParty != ''">
             and a.authParty like CONCAT('%',#{authParty},'%')
         </if>
@@ -129,4 +129,28 @@
     <select id="getBannerList" resultType="java.lang.String">
         select banner from cm_brand_auth_banner where authId = #{authId}
     </select>
+    <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
+        select name as authParty,if(status = 1,1,0) as status,if(status = 1,1,0) as auditStatus,
+               tel as mobile,addr as address,pic1,pic2,pic3,pic4,pic5,du as lngAndLat,
+               if(deleted_at is null,0,1) as delFlag,regId1,regId2,regId3
+        from nissan_ht_alcohol;
+    </select>
+    <select id="getProvinceId" resultType="java.lang.Integer">
+        select provinceID
+        from province
+        where name like
+              concat('%', (select nissan_base_region1.name from nissan_base_region1 where code = #{regId1} limit 1), '%') limit 1;
+    </select>
+    <select id="getCityId" resultType="java.lang.Integer">
+        select cityID
+        from city
+        where name like
+              concat('%', (select nissan_base_region1.name from nissan_base_region1 where code = #{regId1} limit 1), '%') limit 1;
+    </select>
+    <select id="getTownId" resultType="java.lang.Integer">
+        select townID
+        from town
+        where name like
+              concat('%', (select nissan_base_region1.name from nissan_base_region1 where code = #{regId1} limit 1), '%') limit 1;
+    </select>
 </mapper>

+ 3 - 2
src/main/resources/mapper/ClubMapper.xml

@@ -64,8 +64,8 @@
         where id = #{clubUserId}
     </select>
     <select id="getWxClubList" resultType="com.caimei.model.vo.WxClubListVo">
-        select id as authId, authParty as clubName,concat(p.name,c.name,t.name) as area,a.address,a.mobile,a.logo,
-        round(st_distance(point(a.lng,a.lat),point(#{lng},#{lat}))*111195/1000,2) as distance
+        select id as authId, authParty as clubName,concat(ifnull(p.name,''),ifnull(c.name,''),ifnull(t.name,'')) as area,a.address,a.mobile,a.logo,
+        ifnull(round(st_distance(point(a.lng,a.lat),point(114.05454,22.52291))*111195/1000,2),99999) as distance
         from cm_brand_auth a
         left join cm_brand_auth_user au on a.authUserId = au.authUserId
         left join province p on a.provinceId = p.provinceID
@@ -74,6 +74,7 @@
         where au.appId = #{appId}
         and a.status = 1
         and a.auditStatus = 1
+        and a.delFlag = 0
         and au.status = 1
         <if test="clubName != null and clubName != ''">
             and a.authParty like concat('%',#{clubName},'%')