Explorar o código

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

# Conflicts:
#	src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java
#	src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
#	src/main/resources/mapper/AuthMapper.xml
Aslee %!s(int64=2) %!d(string=hai) anos
pai
achega
441a8d3ea7

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

@@ -230,4 +230,11 @@ public class AuthApi {
         }
         return authService.exportDataByExcel(authUserId, response);
     }
+
+    @ApiOperation("ldm门店图/备注导入")
+    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    @GetMapping("/ldm/image/import")
+    public ResponseJson importLdmImage(Integer authUserId){
+        return authService.importLdmImage(authUserId);
+    }
 }

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

@@ -72,6 +72,10 @@ public interface AuthMapper {
 
     Integer getProvinceIdByCityId(Integer cityId);
 
+    List<AuthVo> getAuthByNameAndAddress(@Param("authParty") String authParty, @Param("address") String address);
+
+    void updateRemarks(@Param("authId") Integer authId, @Param("remarks") String remarks);
+
     AuthFormVo getAuthBaseInfo(@Param("authUserId") Integer authUserId, @Param("authId") Integer authId);
 
     AuthVo getAuthById(Integer authId);

+ 1 - 1
src/main/java/com/caimei/mapper/ldmMapper/LdmMapper.java

@@ -15,5 +15,5 @@ import java.util.List;
 public interface LdmMapper {
 
 
-    List<LdmDataPo> getLdmClubData(Integer ldmLatestClubId);
+    List<LdmDataPo> getLdmClubData(Integer ldmLatestClubId, Integer delFlag);
 }

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

@@ -116,4 +116,9 @@ public class LdmDataPo {
      */
     private Integer maxParamNum;
 
+    /**
+     * 店铺备注
+     */
+    private String remarks;
+
 }

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

@@ -110,4 +110,11 @@ public interface AuthService {
      * 机构下拉框列表
      */
     ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId);
+
+    /**
+     * ldm门店图/备注导入
+     * @param authUserId
+     * @return
+     */
+    ResponseJson importLdmImage(Integer authUserId);
 }

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

@@ -3,6 +3,7 @@ package com.caimei.service.auth.impl;
 import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.AuthProductMapper;
+import com.caimei.mapper.ldmMapper.LdmMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.*;
@@ -50,6 +51,9 @@ public class AuthServiceImpl implements AuthService {
     @Resource
     private AuthMapper authMapper;
 
+    @Resource
+    private LdmMapper ldmMapper;
+
     @Resource
     private AuthProductMapper authProductMapper;
 
@@ -156,6 +160,50 @@ public class AuthServiceImpl implements AuthService {
         return ResponseJson.success(authList);
     }
 
+    @Override
+    public ResponseJson importLdmImage(Integer authUserId) {
+        List<LdmDataPo> ldmClubData = ldmMapper.getLdmClubData(null, 0);
+        ldmClubData.forEach(ldmClub->{
+            String pic2 = ldmClub.getPic2();
+            String pic3 = ldmClub.getPic3();
+            String pic4 = ldmClub.getPic4();
+            List<AuthVo> authList = authMapper.getAuthByNameAndAddress(ldmClub.getAuthParty(), ldmClub.getAddress());
+            if (null != authList && authList.size() > 0 ) {
+                if (authList.size() > 1) {
+                    log.info(">>>>>>>>>>>>>>>>>>>>>导入ldm门店图错误:对应门店过多,门店名称:" + ldmClub.getAuthParty());
+                } else {
+                    AuthVo auth = authList.get(0);
+                    Integer authId = auth.getAuthId();
+                    if (StringUtils.isNotEmpty(pic2) || StringUtils.isNotEmpty(pic3) || StringUtils.isNotEmpty(pic4)) {
+                        authMapper.deleteBanner(authId);
+                        insertBanner(pic2, authId);
+                        insertBanner(pic3, authId);
+                        insertBanner(pic4, authId);
+                    }
+                    if (StringUtils.isNotEmpty(ldmClub.getRemarks())) {
+                        authMapper.updateRemarks(authId, ldmClub.getRemarks());
+                    }
+                }
+            } else {
+                log.info(">>>>>>>>>>>>>>>>>>>>>导入ldm门店图错误:找不到对应门店,门店名称:" + ldmClub.getAuthParty());
+            }
+        });
+        return ResponseJson.success();
+    }
+
+    private void insertBanner(String pic, Integer authId) {
+        if (StringUtils.isNotEmpty(pic)) {
+            String imagePath = "https://wangdian.skinovachina.com" + pic;
+            String fileName = imagePath.substring(imagePath.lastIndexOf("/") + 1);
+            try {
+                String banner = uploadService.saveFileByUrl(imagePath, fileName);
+                authMapper.insertBanner(authId, banner);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
     @Override
     public ResponseJson saveAuth(CmBrandAuthPo auth, List<String> bannerList, boolean importFlag, Integer source) {
         Integer authId = auth.getId();

+ 1 - 1
src/main/java/com/caimei/task/LdmTask.java

@@ -49,7 +49,7 @@ public class LdmTask {
     public void readLdmData() {
         AtomicReference<Integer> ldmLatestClubId = new AtomicReference<>(authMapper.getLdmLatestClubId());
         log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>开始同步,ldmLatestClubId:" + ldmLatestClubId.get());
-        List<LdmDataPo> ldmDataList = ldmMapper.getLdmClubData(ldmLatestClubId.get());
+        List<LdmDataPo> ldmDataList = ldmMapper.getLdmClubData(ldmLatestClubId.get(), null);
         ldmDataList.forEach(ldmData->{
             ldmLatestClubId.set(ldmData.getId());
             String lngAndLat = ldmData.getLngAndLat();

+ 12 - 0
src/main/resources/mapper/AuthMapper.xml

@@ -58,6 +58,12 @@
     <update id="updateLdmLatestClubId">
         update ldm_latest_club_id set ldmClubId = #{ldmLatestClubId} where id = 1;
     </update>
+    <update id="updateRemarks">
+        update cm_brand_auth
+        set customFlag = 1,
+            remarks = #{remarks}
+        where id = #{authId}
+    </update>
     <update id="updateAuthShopAuditStatus">
         update cm_brand_auth
         set shopAuditStatus = #{shopAuditStatus},
@@ -165,6 +171,7 @@
         from cm_brand_auth
         where authParty = #{authParty}
           and authUserId = #{authUserId}
+          and delFlag = 0
     </select>
     <select id="getAuthPartyList" resultType="com.caimei.model.po.CmBrandAuthPo">
         select id, authParty
@@ -314,4 +321,9 @@
         select name from town
         where townID = #{townId}
     </select>
+    <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
+        select id as authId from cm_brand_auth
+        where authParty like concat('%',#{authParty},'%') and address like concat('%',#{address},'%')
+        and delFlag = 0
+    </select>
 </mapper>

+ 10 - 2
src/main/resources/mapper/LdmMapper.xml

@@ -5,7 +5,15 @@
     <select id="getLdmClubData" resultType="com.caimei.model.po.LdmDataPo">
         select id,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 where id > #{ldmLatestClubId};
+               if(deleted_at is null,0,1) as delFlag,regId1,regId2,regId3,labe as remarks
+        from nissan_ht_alcohol
+        <where>
+            <if test="ldmLatestClubId != null">
+                and id > #{ldmLatestClubId}
+            </if>
+            <if test="delFlag != null">
+                and deleted_at is null
+            </if>
+        </where>
     </select>
 </mapper>