Quellcode durchsuchen

Merge remote-tracking branch 'remotes/origin/developer' into developerA

# Conflicts:
#	src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
Aslee vor 3 Jahren
Ursprung
Commit
8f998754ac

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

@@ -171,6 +171,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/auth/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/auth/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

+ 89 - 0
src/main/java/com/caimei/service/auth/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,17 @@ import com.caimei.model.vo.ProductFormVo;
 import com.caimei.service.auth.AuthProductService;
 import com.caimei.service.auth.AuthService;
 import com.caimei.service.auth.ShopService;
+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 +41,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 +77,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 +93,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 +203,7 @@ public class AuthServiceImpl implements AuthService {
         // 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
         auth.setStatus(2);
         auth.setAuditStatus(2);
+        auth.setDelFlag(0);
         /*
             保存授权
          */
@@ -256,6 +276,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 {

+ 13 - 0
src/main/java/com/caimei/service/auth/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},'%')