Pārlūkot izejas kodu

正品联盟后台part4

Aslee 4 gadi atpakaļ
vecāks
revīzija
2960c15b19
27 mainītis faili ar 458 papildinājumiem un 46 dzēšanām
  1. 0 5
      pom.xml
  2. 31 0
      src/main/java/com/caimei/config/ApiConfig.java
  3. 44 0
      src/main/java/com/caimei/config/ApiInterceptor.java
  4. 96 0
      src/main/java/com/caimei/config/GlobalTokenAspect.java
  5. 15 0
      src/main/java/com/caimei/controller/AuthProductApi.java
  6. 46 0
      src/main/java/com/caimei/controller/DefaultApi.java
  7. 3 3
      src/main/java/com/caimei/controller/ShopApi.java
  8. 7 0
      src/main/java/com/caimei/mapper/AuthProductMapper.java
  9. 0 5
      src/main/java/com/caimei/model/po/ProductParamPo.java
  10. 5 0
      src/main/java/com/caimei/model/po/ShopInfoPo.java
  11. 1 7
      src/main/java/com/caimei/model/vo/AuthVo.java
  12. 40 0
      src/main/java/com/caimei/model/vo/ProductFormVo.java
  13. 1 1
      src/main/java/com/caimei/model/vo/ProductListVo.java
  14. 14 2
      src/main/java/com/caimei/model/vo/ShopFormVo.java
  15. 17 0
      src/main/java/com/caimei/service/AuthProductService.java
  16. 1 1
      src/main/java/com/caimei/service/ShopService.java
  17. 25 2
      src/main/java/com/caimei/service/impl/AuthProductServiceImpl.java
  18. 17 0
      src/main/java/com/caimei/service/impl/AuthServiceImpl.java
  19. 16 4
      src/main/java/com/caimei/service/impl/ShopServiceImpl.java
  20. 3 0
      src/main/java/com/caimei/utils/AliyunSmsUtil.java
  21. 35 4
      src/main/java/com/caimei/utils/OSSUtils.java
  22. 7 0
      src/main/resources/application.yml
  23. 1 0
      src/main/resources/backup.sql
  24. 1 0
      src/main/resources/config/dev/application-dev.yml
  25. 1 1
      src/main/resources/mapper/AuthMapper.xml
  26. 26 5
      src/main/resources/mapper/AuthProductMapper.xml
  27. 5 6
      src/main/resources/mapper/ShopMapper.xml

+ 0 - 5
pom.xml

@@ -358,11 +358,6 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.3.5</version>
-        </dependency>
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>aliyun-java-sdk-core</artifactId>

+ 31 - 0
src/main/java/com/caimei/config/ApiConfig.java

@@ -0,0 +1,31 @@
+package com.caimei.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.annotation.Resource;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/5/18
+ */
+//@Configuration
+public class ApiConfig implements WebMvcConfigurer {
+    @Resource
+    private ApiInterceptor apiInterceptor;
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        //addPathPatterns 用于添加拦截规则
+        //excludePathPatterns 用于排除拦截
+        registry.addInterceptor(apiInterceptor)
+                .addPathPatterns("/auth/**")
+                .addPathPatterns("/shop/**")
+                .addPathPatterns("/upload/**")
+                .addPathPatterns("/update/password");
+//                .excludePathPatterns("/order/shareCode");
+    }
+}

+ 44 - 0
src/main/java/com/caimei/config/ApiInterceptor.java

@@ -0,0 +1,44 @@
+package com.caimei.config;
+
+import com.caimei.components.RedisService;
+import com.caimei.utils.JwtUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/5/18
+ */
+@Component
+public class ApiInterceptor implements HandlerInterceptor {
+
+    private RedisService redisService;
+
+    @Autowired
+    public void setRedisService(RedisService redisService) {
+        this.redisService = redisService;
+    }
+
+    @Value("${caimei.zplmapi}")
+    private String zplmapi;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String token = request.getHeader("X-Token");
+        String cacheToken = null != token ? String.valueOf(redisService.get(token)) : null;
+        if (null == cacheToken || !JwtUtil.isVerify(cacheToken)) {
+            // Token失效
+            response.sendRedirect(zplmapi + "/unauthorized");
+            return false;
+        }
+        return true;
+    }
+
+}

+ 96 - 0
src/main/java/com/caimei/config/GlobalTokenAspect.java

@@ -0,0 +1,96 @@
+package com.caimei.config;
+
+import com.caimei.components.RedisService;
+import com.caimei.utils.JwtUtil;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 把切面类加入到IOC容器中
+ * 所有请求都会更新redis存token的时间
+ *
+ * @author : Charles
+ * @date : 2020/3/17
+ */
+@Component
+@Aspect
+public class GlobalTokenAspect {
+
+    @Value("${caimei.oldapi}")
+    private String oldApi;
+
+    private RedisService redisService;
+    @Autowired
+    public void setRedisService(RedisService redisService) {
+        this.redisService = redisService;
+    }
+
+    /**
+     * 定义一个切入点 我这里是从controller切入
+     */
+    @Pointcut("execution(public * com.caimei.controller..*.*(..))")
+    public void pointCut() {
+    }
+
+    /**
+     * 前置通知
+     * 在进入方法前执行 可以对参数进行限制或者拦截
+     * 通常在这边做日志存储存到数据库中
+     * @param joinPoint
+     * @throws Throwable
+     */
+    @Before("pointCut()")
+    public void before(JoinPoint joinPoint) throws Throwable {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+        String token = request.getHeader("X-Token");
+        String cacheToken = null!=token ? String.valueOf(redisService.get(token)) : null;
+        // Redis过期后会得到"null"值,所以需判断字符串"null"
+        if (cacheToken != null && cacheToken.length() != 0 && !"null".equals(cacheToken)) {
+            if (JwtUtil.isVerify(cacheToken)) {
+               /* String mobileOrEmail = JwtUtil.parseTokenAud(cacheToken);*/
+                int userId = JwtUtil.parseTokenUid(cacheToken);
+                // 刷新token
+                tokenRefresh(token, userId);
+            }
+        }
+    }
+
+    /**
+     * JWT Token续签:
+     * 业务逻辑:登录成功后,用户在未过期时间内继续操作,续签token。
+     * 登录成功后,空闲超过过期时间,返回token已失效,重新登录。
+     * 实现逻辑:
+     * 1.登录成功后将token存储到redis里面(这时候k、v值一样都为token),并设置过期时间为token过期时间
+     * 2.当用户请求时token值还未过期,则重新设置redis里token的过期时间。
+     * 3.当用户请求时token值已过期,但redis中还在,则JWT重新生成token并覆盖v值(这时候k、v值不一样了),然后设置redis过期时间。
+     * 4.当用户请求时token值已过期,并且redis中也不存在,则用户空闲超时,返回token已失效,重新登录。
+     */
+    public boolean tokenRefresh(String token, Integer userID) {
+        String cacheToken = String.valueOf(redisService.get(token));
+        // 过期后会得到"null"值,所以需判断字符串"null"
+        if (cacheToken != null && cacheToken.length() != 0 && !"null".equals(cacheToken)) {
+            // 校验token有效性
+            if (!JwtUtil.isVerify(cacheToken)) {
+                // 生成token
+                String newToken = JwtUtil.createToken(userID);
+                // 将token存入redis,并设置超时时间
+                redisService.set(token, newToken, JwtUtil.getExpireTime());
+            } else {
+                // 重新设置超时时间
+                redisService.set(token, cacheToken, JwtUtil.getExpireTime());
+            }
+            return true;
+        }
+        return false;
+    }
+}

+ 15 - 0
src/main/java/com/caimei/controller/AuthProductApi.java

@@ -3,7 +3,9 @@ package com.caimei.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
+import com.caimei.model.vo.ShopFormVo;
 import com.caimei.model.vo.ShopListVo;
 import com.caimei.service.AuthProductService;
 import com.github.pagehelper.PageInfo;
@@ -92,4 +94,17 @@ public class AuthProductApi {
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) {
         return authProductService.saveProduct(productSaveDto);
     }
+
+    /**
+     * 获取授权商品回显数据
+     *
+     * @param productId 授权商品id
+     * @return ProductFormVo
+     */
+    @ApiOperation("授权商品回显数据")
+    @ApiImplicitParam(name = "productId", required = true, value = "授权商品id")
+    @GetMapping("/form/data")
+    public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
+        return authProductService.getProductFormData(productId);
+    }
 }

+ 46 - 0
src/main/java/com/caimei/controller/DefaultApi.java

@@ -0,0 +1,46 @@
+package com.caimei.controller;
+
+import com.caimei.module.base.entity.bo.JsonModel;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/3/4
+ */
+@RestController
+@Api(tags = "默认API")
+public class DefaultApi {
+    @GetMapping("/")
+    public String welcome(){
+        //return "欢迎使用!《采美365网》! <br><a href='swagger-ui.html'>swagger接口文档入口</a>";
+        return "欢迎使用!《正品联盟后台》!";
+    }
+    /**
+     * 刷新token, 供旧系统调用
+     */
+    @PostMapping("/token/refresh")
+    public String tokenRefresh() {
+        return "刷新Token成功!";
+    }
+
+    /**
+     * Token失效
+     */
+    @GetMapping("/unauthorized")
+    public JsonModel unauthorized() {
+        return new JsonModel().error(-99, "Token失效请重新登录!");
+    }
+
+    /**
+     * 处理非法请求
+     */
+    @GetMapping("/error")
+    public JsonModel error() {
+        return new JsonModel().error(-100, "非法的请求!");
+    }
+}

+ 3 - 3
src/main/java/com/caimei/controller/ShopApi.java

@@ -57,12 +57,12 @@ public class ShopApi {
     }
 
     /**
-     * 获取供应商表单数据
+     * 获取供应商回显数据
      *
      * @param authUserId 供应商用户id
-     * @return ShopVo
+     * @return ShopFormVo
      */
-    @ApiOperation("供应商表单数据")
+    @ApiOperation("供应商回显数据")
     @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/form/data")
     public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {

+ 7 - 0
src/main/java/com/caimei/mapper/AuthProductMapper.java

@@ -5,6 +5,7 @@ import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductPo;
 import com.caimei.model.vo.AuthVo;
 import com.caimei.model.vo.BrandVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -35,4 +36,10 @@ public interface AuthProductMapper {
     void insertProductParam(@Param("productId") Integer productId, @Param("paramName") String paramName, @Param("paramContent") String paramContent);
 
     Integer getProductIdBySnCode(String snCode);
+
+    ProductFormVo getProductFormByProductId(Integer productId);
+
+    List<ProductParamPo> getParamsByProductId(Integer productId);
+
+    List<Integer> getProductIdsByAuthId(Integer authId);
 }

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

@@ -10,11 +10,6 @@ import lombok.Data;
  */
 @Data
 public class ProductParamPo {
-    /**
-     * 授权商品id
-     */
-    @ApiModelProperty("授权商品id")
-    private Integer productId;
     /**
      * 商品参数名称
      */

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

@@ -31,6 +31,11 @@ public class ShopInfoPo{
      */
     private Integer countryId;
 
+    /**
+     * 官网认证链接
+     */
+    private String securityLink;
+
     /**
      * 代理声明类型:1弹窗,2链接,3图片,4文件
      */

+ 1 - 7
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -13,13 +13,7 @@ import java.util.Date;
 @Data
 public class AuthVo {
     @ApiModelProperty("授权id")
-    private Integer id;
-
-    /**
-     * 供应商用户id
-     */
-    @ApiModelProperty("供应商用户id")
-    private Integer authUserId;
+    private Integer authId;
 
     /**
      * 授权机构

+ 40 - 0
src/main/java/com/caimei/model/vo/ProductFormVo.java

@@ -0,0 +1,40 @@
+package com.caimei.model.vo;
+
+import com.caimei.model.po.ProductParamPo;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Aslee
+ * @date 2021/5/17
+ */
+@Data
+public class ProductFormVo {
+    @ApiModelProperty("商品id")
+    private Integer productId;
+
+    @ApiModelProperty("授权id")
+    private Integer authId;
+
+    @ApiModelProperty("商品名称")
+    private String productName;
+
+    @ApiModelProperty("商品SN码")
+    private String snCode;
+
+    @ApiModelProperty("商品图片")
+    private String productImage;
+
+    @ApiModelProperty("授权牌照")
+    private String certificateImage;
+
+    @ApiModelProperty("商品参数列表")
+    private List<ProductParamPo> paramList;
+
+    @ApiModelProperty("上架状态:0下架,1上架")
+    private Integer status;
+}

+ 1 - 1
src/main/java/com/caimei/model/vo/ProductListVo.java

@@ -27,5 +27,5 @@ public class ProductListVo {
     private Date createTime;
 
     @ApiModelProperty("创建人")
-    private Integer createBy;
+    private String createBy;
 }

+ 14 - 2
src/main/java/com/caimei/model/vo/ShopFormVo.java

@@ -24,13 +24,13 @@ public class ShopFormVo implements Serializable {
      * 供应商名称
      */
     @ApiModelProperty("供应商名称")
-    private String name;
+    private String shopName;
 
     /**
      * 供应商类型:1代理商 2品牌方
      */
     @ApiModelProperty("供应商类型")
-    private Integer type;
+    private Integer shopType;
 
     /**
      * 所属品牌Id
@@ -38,6 +38,12 @@ public class ShopFormVo implements Serializable {
     @ApiModelProperty("所属品牌Id")
     private Integer brandId;
 
+    /**
+     * 所属品牌Logo
+     */
+    @ApiModelProperty("所属品牌Logo")
+    private String brandAuthLogo;
+
     /**
      * 手机号
      */
@@ -56,6 +62,12 @@ public class ShopFormVo implements Serializable {
     @ApiModelProperty("产地国家Id")
     private Integer countryId;
 
+    /**
+     * 官网认证链接
+     */
+    @ApiModelProperty("官网认证链接")
+    private String securityLink;
+
     /**
      * 供应商状态:0停用 1启用
      */

+ 17 - 0
src/main/java/com/caimei/service/AuthProductService.java

@@ -2,9 +2,12 @@ package com.caimei.service;
 
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
 import com.github.pagehelper.PageInfo;
 
+import java.util.List;
+
 /**
  * Description
  *
@@ -56,4 +59,18 @@ public interface AuthProductService {
      * @return ResponseJson
      */
     ResponseJson saveProduct(ProductSaveDto productSaveDto);
+
+    /**
+     * 获取授权商品回显数据
+     * @param productId     商品id
+     * @return  ProductFormVo
+     */
+    ResponseJson<ProductFormVo> getProductFormData(Integer productId);
+
+    /**
+     * 根据品牌授权id获取商品id列表
+     * @param authId 授权id
+     * @return  Integer
+     */
+    List<Integer> getProductIdsByAuthId(Integer authId);
 }

+ 1 - 1
src/main/java/com/caimei/service/ShopService.java

@@ -78,7 +78,7 @@ public interface ShopService {
     ResponseJson saveShop(ShopSaveDto shopSaveDto);
 
     /**
-     * 获取供应商表单数据
+     * 获取供应商回显数据
      * @param authUserId 供应商用户id
      * @return  ShopVo
      */

+ 25 - 2
src/main/java/com/caimei/service/impl/AuthProductServiceImpl.java

@@ -5,6 +5,7 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductPo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
 import com.caimei.service.AuthProductService;
 import com.github.pagehelper.PageHelper;
@@ -65,7 +66,10 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (null == productId) {
             return ResponseJson.error("参数异常,请输入授权商品id");
         }
+        // 删除商品
         authProductMapper.deleteProductByProductId(productId);
+        // 删除商品参数
+        authProductMapper.deleteParamsByProductId(productId);
         return ResponseJson.success("删除授权商品成功");
     }
 
@@ -90,7 +94,7 @@ public class AuthProductServiceImpl implements AuthProductService {
             return ResponseJson.error("参数异常,请输入商品SN码", null);
         }
         Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
-        if (null != productIdBySnCode) {
+        if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
             return ResponseJson.error("参数异常,该商品SN码已存在,请重新输入", null);
         }
         if (StringUtils.isEmpty(productImage)) {
@@ -108,7 +112,7 @@ public class AuthProductServiceImpl implements AuthProductService {
             return ResponseJson.error("参数异常,商品参数列表不能为空", null);
         }
         // 是否为添加操作
-        Boolean insertFlag = null == productId;
+        boolean insertFlag = null == productId;
         /*
             组装商品数据
          */
@@ -148,4 +152,23 @@ public class AuthProductServiceImpl implements AuthProductService {
         });
         return ResponseJson.success("保存授权商品成功");
     }
+
+    @Override
+    public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
+        if (null == productId) {
+            return ResponseJson.error("参数异常,请输入商品id", null);
+        }
+        ProductFormVo productForm = authProductMapper.getProductFormByProductId(productId);
+        if (null == productForm) {
+            return ResponseJson.error("商品不存在", null);
+        }
+        List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
+        productForm.setParamList(paramList);
+        return ResponseJson.success(productForm);
+    }
+
+    @Override
+    public List<Integer> getProductIdsByAuthId(Integer authId) {
+        return authProductMapper.getProductIdsByAuthId(authId);
+    }
 }

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

@@ -5,11 +5,13 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.vo.AuthVo;
 import com.caimei.model.vo.BrandVo;
+import com.caimei.service.AuthProductService;
 import com.caimei.service.AuthService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -29,6 +31,13 @@ public class AuthServiceImpl implements AuthService {
     @Resource
     private AuthMapper authMapper;
 
+    private AuthProductService authProductService;
+
+    @Autowired
+    public void setAuthProductService(AuthProductService authProductService) {
+        this.authProductService = authProductService;
+    }
+
     @Override
     public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer authUserId, String authParty, Integer pageNum, Integer pageSize) {
         if (null == authUserId) {
@@ -63,7 +72,15 @@ public class AuthServiceImpl implements AuthService {
         if (null == authId) {
             return ResponseJson.error("参数异常,请输入授权id");
         }
+        // 删除品牌授权
         authMapper.deleteAuthByAuthId(authId);
+        // 删除商品及商品参数
+        List<Integer> productIdList = authProductService.getProductIdsByAuthId(authId);
+        productIdList.forEach(productId->{
+            if (null != productId) {
+                authProductService.deleteProduct(productId);
+            }
+        });
         return ResponseJson.success("删除品牌授权成功");
     }
 

+ 16 - 4
src/main/java/com/caimei/service/impl/ShopServiceImpl.java

@@ -80,10 +80,10 @@ public class ShopServiceImpl implements ShopService {
         String md5Password = Md5Util.md5(newPassword);
         userMapper.updatePasswordByUserId(authUserId, md5Password);
         String mobile = shopMapper.getShopMobileByUserId(authUserId);
-        boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 7, "{code:" + newPassword + "}");
+        boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 14, "{code:" + newPassword + "}");
         if (!smsFlag) {
             // 短信发送失败重试一次
-            AliyunSmsUtil.sendSms(mobile, 7, "{code:" + newPassword + "}");
+            AliyunSmsUtil.sendSms(mobile, 14, "{code:" + newPassword + "}");
         }
         log.info("正品联盟后台供应商重置密码,用户id:" + authUserId + ",新密码:" + newPassword);
         return ResponseJson.success("密码重置成功");
@@ -156,7 +156,7 @@ public class ShopServiceImpl implements ShopService {
             return ResponseJson.error("请选择供应商类型", null);
         }
         // 是否为添加操作
-        Boolean insertFlag = null == shopSaveDto.getAuthUserId();
+        boolean insertFlag = null == shopSaveDto.getAuthUserId();
         // 更新品牌授权logo
         shopMapper.updateBrandAuthLogo(shopSaveDto.getBrandId(),shopSaveDto.getBrandAuthLogo());
         /*
@@ -179,7 +179,14 @@ public class ShopServiceImpl implements ShopService {
             // 创建时间
             shop.setCreateTime(new Date());
             // 设置随机8位密码
-            shop.setPassword(Md5Util.md5(CodeUtil.generateCode(8)));
+            String password = Md5Util.md5(CodeUtil.generateCode(8));
+            shop.setPassword(password);
+            // 发送短信
+            boolean smsFlag = AliyunSmsUtil.sendSms(shopSaveDto.getMobile(), 14, "{code:" + password + "}");
+            if (!smsFlag) {
+                // 短信发送失败重试一次
+                AliyunSmsUtil.sendSms(shopSaveDto.getMobile(), 14, "{code:" + password + "}");
+            }
             // 插入供应商用户
             shopMapper.insertShop(shop);
         } else {
@@ -199,6 +206,8 @@ public class ShopServiceImpl implements ShopService {
         shopInfo.setBrandId(shopSaveDto.getBrandId());
         // 国家id
         shopInfo.setCountryId(shopSaveDto.getCountryId());
+        // 官网认证链接
+        shopInfo.setSecurityLink(shopSaveDto.getSecurityLink());
         if (null != shopSaveDto.getStatementType()) {
             shopInfo.setStatementType(shopSaveDto.getStatementType());
             if (1 == shopSaveDto.getStatementType()) {
@@ -237,6 +246,9 @@ public class ShopServiceImpl implements ShopService {
             return ResponseJson.error("参数异常,请输入供应商用户id", null);
         }
         ShopFormVo shopForm = shopMapper.getShopByAuthUserId(authUserId);
+        if (null == shopForm) {
+            return ResponseJson.error("供应商不存在", null);
+        }
         return ResponseJson.success(shopForm);
     }
 

+ 3 - 0
src/main/java/com/caimei/utils/AliyunSmsUtil.java

@@ -76,6 +76,9 @@ public class AliyunSmsUtil {
         } else if (type == 13) {
             // 模版内容: 您正在更换联系人手机号,您的验证码为:${code}。
             templateCode = "SMS_205435893";
+        } else if (type == 14) {
+            // 模版内容: 您正品联盟管理系统登录密码为:${code}。
+            templateCode = "SMS_217145278";
         }
         try {
             //可自助调整超时时间

+ 35 - 4
src/main/java/com/caimei/utils/OSSUtils.java

@@ -16,10 +16,40 @@ import java.util.UUID;
 
 @Component
 public class OSSUtils {
-    private static String endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
-    private static String accessKeyId = "LTAI4GBL3o4YkWnbKYgf2Xia";
-    private static String accessKeySecret = "dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK";
-    private static String privateBucket = "caimei-oss";
+    private static String endpoint;
+
+    @Value("${aliyunConfig.endpoint}")
+    public void setEndpoint(String endpoints) {
+        endpoint = endpoints;
+    }
+
+    private static String accessKeyId;
+
+    @Value("${aliyunConfig.accessKeyId}")
+    public void setAccessKeyId(String accessKeyIds) {
+        accessKeyId = accessKeyIds;
+    }
+
+    private static String accessKeySecret;
+
+    @Value("${aliyunConfig.accessKeySecret}")
+    public void setAccessKeySecret(String accessKeySecrets) {
+        accessKeySecret = accessKeySecrets;
+    }
+
+    private static String privateBucket;
+
+    @Value("${aliyunConfig.bucketName}")
+    public void setPrivateBucket(String bucketName) {
+        privateBucket = bucketName;
+    }
+
+    private static String active;
+
+    @Value("${spring.profiles.active}")
+    public void setActive(String actives) {
+        active = actives;
+    }
 
     public static String ossUpload(String fileName, File file, String contentType) {
         String url = null;
@@ -27,6 +57,7 @@ public class OSSUtils {
             OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
             ObjectMetadata meta = new ObjectMetadata();
             meta.setContentType(contentType);
+            fileName = active + "/" + fileName;
             UploadFileRequest uploadFileRequest = new UploadFileRequest(privateBucket, fileName);
             // 指定上传的本地文件。
             uploadFileRequest.setUploadFile(file.toString());

+ 7 - 0
src/main/resources/application.yml

@@ -13,6 +13,13 @@ mybatis:
   mapper-locations:
     - classpath:mapper/*.xml
 
+#阿里云配置
+aliyunConfig:
+  endpoint: https://oss-cn-shenzhen.aliyuncs.com
+  accessKeyId: LTAI4GBL3o4YkWnbKYgf2Xia
+  accessKeySecret: dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK
+  bucketName: caimei-oss
+
 
 
 

+ 1 - 0
src/main/resources/backup.sql

@@ -18,6 +18,7 @@ CREATE TABLE `cm_brand_auth_shop_info` (
                                                    `type` INT NULL COMMENT '供应商类型:1品牌方,2代理商',
                                                    `brandId` INT NULL COMMENT '所属品牌Id',
                                                    `countryId` INT NULL COMMENT '产地国家id',
+                                                   `securityLink` TEXT NULL COMMENT '官网认证链接',
                                                    `statementType` INT NULL COMMENT '代理声明类型:1弹窗,2链接,3图片,4文件',
                                                    `statementContent` TEXT NULL COMMENT '声明弹窗内容',
                                                    `statementLink` VARCHAR(255) NULL COMMENT '声明链接',

+ 1 - 0
src/main/resources/config/dev/application-dev.yml

@@ -63,6 +63,7 @@ wx:
 # 新旧www服务域名
 caimei:
   oldapi: http://localhost:8100
+  zplmapi: http://localhost:8012
   #支付异步回调地址
   notifyUrl: https://spi-b.caimei365.com/PayOrder/paymentCallback
   #支付链接重定向地址

+ 1 - 1
src/main/resources/mapper/AuthMapper.xml

@@ -20,7 +20,7 @@
         delete from cm_brand_auth where id = #{authId}
     </delete>
     <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
-        select id, authParty, a.status, a.createTime, u.name
+        select id as authId, authParty, a.status, a.createTime, u.name as createBy
         from cm_brand_auth a
                  left join cm_brand_auth_user u on a.createBy = u.authUserId
         where a.authUserId = #{authUserId}

+ 26 - 5
src/main/resources/mapper/AuthProductMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.AuthProductMapper">
-    <insert id="insertProduct">
+    <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductPo">
         insert into cm_brand_auth_product(`authId`, `name`, `snCode`, `image`, `certificateImage`, `status`,
                                           `createTime`, `createBy`)
         values (#{authId}, #{productName}, #{snCode}, #{productImage}, #{certificateImage}, #{status}, #{createTime},
@@ -22,7 +22,8 @@
         set `name`             = #{productName},
             `snCode`           = #{snCode},
             `image`            = #{productImage},
-            `certificateImage` = #{certificateImage}
+            `certificateImage` = #{certificateImage},
+            `status`           = #{status}
         where id = #{productId};
     </update>
     <delete id="deleteProductByProductId">
@@ -32,11 +33,12 @@
         delete from cm_brand_product_param where productId = #{productId}
     </delete>
     <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
-        select id as productId,name as productName,snCode,status,createTime,createBy
-        from cm_brand_auth_product
+        select id as productId,p.name as productName,snCode,p.status,p.createTime,u.name as createBy
+        from cm_brand_auth_product p
+        left join cm_brand_auth_user u on p.createBy = u.authUserId
         where authId = #{authId}
         <if test="productName != null and productName != ''">
-            and name like CONCAT('%',#{productName},'%')
+            and p.name like CONCAT('%',#{productName},'%')
         </if>
         <if test="snCode != null and snCode != ''">
             and snCode like CONCAT('%',#{snCode},'%')
@@ -45,4 +47,23 @@
     <select id="getProductIdBySnCode" resultType="java.lang.Integer">
         select id from cm_brand_auth_product where snCode = #{snCode} limit 1
     </select>
+    <select id="getProductFormByProductId" resultType="com.caimei.model.vo.ProductFormVo">
+        select `id`    as productId,
+               `authId`,
+               `name`  as productName,
+               `snCode`,
+               `image` as productImage,
+               `certificateImage`,
+               `status`
+        from cm_brand_auth_product
+        where id = #{productId}
+    </select>
+    <select id="getParamsByProductId" resultType="com.caimei.model.po.ProductParamPo">
+        select `name` as paramName, `content` as paramContent
+        from cm_brand_product_param
+        where productId = #{productId}
+    </select>
+    <select id="getProductIdsByAuthId" resultType="java.lang.Integer">
+        select id from cm_brand_auth_product where authId = #{authId}
+    </select>
 </mapper>

+ 5 - 6
src/main/resources/mapper/ShopMapper.xml

@@ -13,7 +13,7 @@
     <insert id="insertShopInfo">
         insert into cm_brand_auth_shop_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            authUserId,type,brandId,countryId,
+            authUserId,type,brandId,countryId,securityLink,
             <if test="statementType != null">
                 statementType,
             </if>
@@ -28,7 +28,7 @@
             </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            #{authUserId},#{type},#{brandId},#{countryId},
+            #{authUserId},#{type},#{brandId},#{countryId},#{securityLink},
             <if test="statementType != null">
                 #{statementType},
             </if>
@@ -60,8 +60,7 @@
     </update>
     <update id="updateShopByUserId">
         update cm_brand_auth_user
-        set `name`    = #{name},
-            `mobile`  = #{mobile},
+        set `mobile`  = #{mobile},
             `linkMan` = #{linkMan},
             `status`  = #{status}
         where authUserId = #{authUserId}
@@ -69,7 +68,7 @@
     <update id="updateShopInfoByUserId">
         update cm_brand_auth_shop_info
         <set>
-            type = #{type},brandId = #{brandId},countryId=#{countryId},
+            brandId = #{brandId},countryId=#{countryId},securityLink = #{securityLink},
             <if test="statementType != null">
                 statementType = #{statementType},
             </if>
@@ -136,7 +135,7 @@
         select count(*) from cm_brand_auth_file where md5Hex = #{md5Hex}
     </select>
     <select id="getShopByAuthUserId" resultType="com.caimei.model.vo.ShopFormVo">
-        select u.authUserId,u.name,u.mobile,u.linkMan,u.status as shopStatus,s.type,s.brandId,s.countryId,b.authLogo,
+        select u.authUserId,u.name as shopName,u.mobile,u.linkMan,u.status as shopStatus,s.type as shopType,s.brandId,s.countryId,s.securityLink,b.authLogo as brandAuthLogo,
                s.statementType,s.statementContent,s.statementLink,s.statementImage,f.name as statementFileName
                from cm_brand_auth_user u
                    left join cm_brand_auth_shop_info s on u.authUserId = s.authUserId