Aslee 3 سال پیش
والد
کامیت
ec14beccda

+ 1 - 1
src/main/java/com/caimei/mapper/AuthProductMapper.java

@@ -47,5 +47,5 @@ public interface AuthProductMapper {
 
     void updateImageByProductId(ProductPo product);
 
-    void updateProductAuditStatus(@Param("productId") Integer productId, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
+    void updateProductAuditStatus(@Param("productId") Integer productId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
 }

+ 2 - 0
src/main/java/com/caimei/mapper/ShopMapper.java

@@ -63,4 +63,6 @@ public interface ShopMapper {
     Integer getAuthWaitAuditNum(Integer authUserId);
 
     Integer getProductWaitAuditNum(Integer authUserId);
+
+    Integer getProductCount(@Param("authUserId") Integer authUserId, @Param("brandId") Integer brandId);
 }

+ 6 - 0
src/main/java/com/caimei/model/vo/ShopFormVo.java

@@ -57,4 +57,10 @@ public class ShopFormVo implements Serializable {
      */
     @ApiModelProperty("供应商信息列表")
     private List<ShopInfoVo> shopInfo;
+
+    /**
+     * 已存在商品的品牌id,以,隔开
+     */
+    @ApiModelProperty("已存在商品的品牌id,以,隔开")
+    private String existProductBrandIds;
 }

+ 7 - 1
src/main/java/com/caimei/service/impl/AuthProductServiceImpl.java

@@ -293,7 +293,13 @@ public class AuthProductServiceImpl implements AuthProductService {
             return ResponseJson.error("请输入审核人用户id");
         }
         Date auditTime = new Date();
-        authProductMapper.updateProductAuditStatus(productId, auditStatus, invalidReason, auditBy, auditTime);
+        Integer status = null;
+        if (0 == auditStatus) {
+            status = 0;
+        } else if (1 == auditStatus) {
+            status = 1;
+        }
+        authProductMapper.updateProductAuditStatus(productId, status, auditStatus, invalidReason, auditBy, auditTime);
         return ResponseJson.success("审核品牌授权成功");
     }
 }

+ 29 - 2
src/main/java/com/caimei/service/impl/ShopServiceImpl.java

@@ -95,7 +95,7 @@ public class ShopServiceImpl implements ShopService {
             // 短信发送失败重试一次
             AliyunSmsUtil.sendSms(mobile, 14, "{password:\"" + newPassword + "\"}");
         }
-        log.info("供应商重置密码,用户id:" + authUserId + ",新密码:" + newPassword);
+        log.info("供应商重置密码,用户id:" + authUserId);
         return ResponseJson.success("密码重置成功");
     }
 
@@ -189,6 +189,12 @@ public class ShopServiceImpl implements ShopService {
             if (null != userIdByShopName) {
                 return ResponseJson.error("该供应商名称已经存在,请重新输入", null);
             }
+        } else {
+            // 修改时验证新手机号是否已被使用
+            Integer userIdByMobile = shopMapper.getUserIdByMobile(mobile);
+            if (null != userIdByMobile && !userIdByMobile.equals(authUserId)) {
+                return ResponseJson.error("该手机号已被使用,请重新输入", null);
+            }
         }
         // 更新品牌授权logo
         shopInfoList.forEach(shopInfo->{
@@ -249,12 +255,23 @@ public class ShopServiceImpl implements ShopService {
         } else {
             // 数据库中供应商信息数据
             List<ShopBrandVo> dbInfoBrandList = shopMapper.getDbInfoBrandList(shop.getAuthUserId());
-            List<Integer> updateInfoBrandList = new ArrayList<>();
+            // 编辑后的品牌列表
             List<Integer> newInfoBrandList = new ArrayList<>();
+            // 编辑后的品牌列表和数据库中的品牌列表重复的需要更新的部分
+            List<Integer> updateInfoBrandList = new ArrayList<>();
             // 编辑后的供应商品牌id
             shopInfoList.forEach(shopInfo->{
                 newInfoBrandList.add(shopInfo.getBrandId());
             });
+            for (ShopBrandVo shopBrand : dbInfoBrandList) {
+                // 判断被删除的品牌下是否还有未删除的商品,若存在,提示供应商需要删除后才能删除品牌
+                if (!newInfoBrandList.contains(shopBrand.getBrandId())) {
+                    Integer productCount = shopMapper.getProductCount(shop.getAuthUserId(), shopBrand.getBrandId());
+                    if (null != productCount && productCount > 0) {
+                        return ResponseJson.error("该品牌已绑定供应商商品,无法进行删除");
+                    }
+                }
+            }
             for (ShopBrandVo shopBrand : dbInfoBrandList) {
                 if (!newInfoBrandList.contains(shopBrand.getBrandId())) {
                     // 删除被删除的数据
@@ -296,6 +313,16 @@ public class ShopServiceImpl implements ShopService {
         }
         List<ShopInfoVo> shopInfoList = shopMapper.getShopInfoByUserId(authUserId);
         shopForm.setShopInfo(shopInfoList);
+        String existProductBrandIds = "";
+        for (ShopInfoVo shopInfo : shopInfoList) {
+            if (null != shopInfo.getBrandId()) {
+                Integer productCount = shopMapper.getProductCount(authUserId, shopInfo.getBrandId());
+                if (null != productCount && productCount > 0) {
+                    existProductBrandIds += shopInfo.getBrandId() + ",";
+                }
+            }
+        }
+        shopForm.setExistProductBrandIds(existProductBrandIds);
         return ResponseJson.success(shopForm);
     }
 

+ 8 - 7
src/main/resources/mapper/AuthMapper.xml

@@ -46,13 +46,14 @@
         <if test="auditStatus != null">
             and a.auditStatus = #{auditStatus}
         </if>
-        <if test="listType == 2">
-            order by a.auditStatus desc,waitAuditNum desc, a.createTime desc
-        </if>
-        <if test="listType == 1">
-            order by a.createTime desc
-        </if>
-
+        <choose>
+            <when test="listType == 2">
+                order by a.auditStatus desc,waitAuditNum desc, a.createTime desc
+            </when>
+            <otherwise>
+                order by a.createTime desc
+            </otherwise>
+        </choose>
     </select>
     <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
         select count(*)

+ 11 - 8
src/main/resources/mapper/AuthProductMapper.xml

@@ -54,7 +54,8 @@
     </update>
     <update id="updateProductAuditStatus">
         update cm_brand_auth_product
-        set auditStatus   = #{auditStatus},
+        set status        = #{status},
+            auditStatus   = #{auditStatus},
             invalidReason = #{invalidReason},
             auditBy       = #{auditBy},
             auditTime     = #{auditTime}
@@ -80,17 +81,19 @@
             and snCode like CONCAT('%',#{snCode},'%')
         </if>
         <if test="status != null">
-            and p.status = #{auditStatus}
+            and p.status = #{status}
         </if>
         <if test="auditStatus != null">
             and p.auditStatus = #{auditStatus}
         </if>
-        <if test="listType == 1">
-            order by p.createTime desc
-        </if>
-        <if test="listType == 2">
-            order by p.auditStatus desc,p.createTime desc
-        </if>
+        <choose>
+            <when test="listType == 2">
+                order by p.auditStatus desc,p.createTime desc
+            </when>
+            <otherwise>
+                order by p.createTime desc
+            </otherwise>
+        </choose>
     </select>
     <select id="getProductIdBySnCode" resultType="java.lang.Integer">
         select id from cm_brand_auth_product where snCode = #{snCode} limit 1

+ 15 - 7
src/main/resources/mapper/ShopMapper.xml

@@ -117,12 +117,14 @@
             AND u.linkMan like CONCAT('%',#{linkMan},'%')
         </if>
         group by u.authUserId,u.createTime
-        <if test="listType == 2">
-            ORDER BY waitAuditNum desc, u.createTime DESC
-        </if>
-        <if test="listType != 2">
-            ORDER BY u.createTime DESC
-        </if>
+        <choose>
+            <when test="listType == 2">
+                ORDER BY waitAuditNum desc, u.createTime DESC
+            </when>
+            <otherwise>
+                ORDER BY u.createTime DESC
+            </otherwise>
+        </choose>
     </select>
     <select id="getShopMobileByUserId" resultType="java.lang.String">
         select mobile from cm_brand_auth_user where authUserId = #{authUserId}
@@ -179,7 +181,7 @@
         select authUserId from cm_brand_auth_user where mobile = #{mobile} and userIdentity = 2 limit 1
     </select>
     <select id="getDbInfoBrandList" resultType="com.caimei.model.vo.ShopBrandVo">
-        select id,brandId
+        select id, brandId
         from cm_brand_auth_shop_info
         where authUserId = #{authUserId}
     </select>
@@ -216,5 +218,11 @@
         where a.authUserId = #{authUserId}
           and p.auditStatus = 2
     </select>
+    <select id="getProductCount" resultType="java.lang.Integer">
+        select count(*)
+        from cm_brand_auth a
+                 left join cm_brand_auth_product p on p.authId = a.id
+        where a.authUserId = #{authUserId} and p.brandId = #{brandId}
+    </select>
 
 </mapper>