Ver código fonte

Merge remote-tracking branch 'origin/developer' into developerB

# Conflicts:
#	src/main/java/com/caimei/mapper/cmMapper/FileMapper.java
#	src/main/resources/mapper/FileMapper.xml
zhijiezhao 2 anos atrás
pai
commit
84c7d25666
100 arquivos alterados com 3155 adições e 1937 exclusões
  1. 2 0
      src/main/java/com/caimei/AdminApplication.java
  2. 16 0
      src/main/java/com/caimei/annotation/CurrentUser.java
  3. 65 0
      src/main/java/com/caimei/annotation/CurrentUserResolver.java
  4. 2 2
      src/main/java/com/caimei/config/ApiInterceptor.java
  5. 97 0
      src/main/java/com/caimei/config/ArgumentFilter.java
  6. 33 0
      src/main/java/com/caimei/config/FilterConfig.java
  7. 22 0
      src/main/java/com/caimei/config/WebConfig.java
  8. 99 37
      src/main/java/com/caimei/controller/admin/auth/AuthApi.java
  9. 35 12
      src/main/java/com/caimei/controller/admin/auth/AuthClubApi.java
  10. 128 48
      src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java
  11. 24 7
      src/main/java/com/caimei/controller/admin/auth/AuthTemplateApi.java
  12. 44 8
      src/main/java/com/caimei/controller/admin/auth/DoctorApi.java
  13. 40 5
      src/main/java/com/caimei/controller/admin/auth/DownloadApi.java
  14. 269 85
      src/main/java/com/caimei/controller/admin/auth/ShopApi.java
  15. 12 2
      src/main/java/com/caimei/controller/admin/auth/UserApi.java
  16. 40 8
      src/main/java/com/caimei/controller/admin/data/ArticleApi.java
  17. 26 5
      src/main/java/com/caimei/controller/admin/data/FileApi.java
  18. 26 5
      src/main/java/com/caimei/controller/admin/data/ImageApi.java
  19. 25 4
      src/main/java/com/caimei/controller/admin/data/VideoApi.java
  20. 2 0
      src/main/java/com/caimei/controller/admin/sys/SysMenuApi.java
  21. 19 3
      src/main/java/com/caimei/controller/admin/sys/SysRoleApi.java
  22. 44 7
      src/main/java/com/caimei/controller/admin/sys/SysUserApi.java
  23. 32 6
      src/main/java/com/caimei/controller/admin/vip/VipApi.java
  24. 21 0
      src/main/java/com/caimei/controller/wechat/RegisterApi.java
  25. 37 26
      src/main/java/com/caimei/controller/wechat/WxAuthApi.java
  26. 4 0
      src/main/java/com/caimei/mapper/cmMapper/ArticleMapper.java
  27. 8 2
      src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java
  28. 21 7
      src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java
  29. 4 2
      src/main/java/com/caimei/mapper/cmMapper/ClubMapper.java
  30. 2 0
      src/main/java/com/caimei/mapper/cmMapper/DoctorMapper.java
  31. 6 1
      src/main/java/com/caimei/mapper/cmMapper/FileMapper.java
  32. 2 0
      src/main/java/com/caimei/mapper/cmMapper/ImageMapper.java
  33. 13 16
      src/main/java/com/caimei/mapper/cmMapper/ShopMapper.java
  34. 26 5
      src/main/java/com/caimei/mapper/cmMapper/SystemMapper.java
  35. 4 0
      src/main/java/com/caimei/mapper/cmMapper/VideoMapper.java
  36. 14 9
      src/main/java/com/caimei/model/dto/ProductSaveDto.java
  37. 7 42
      src/main/java/com/caimei/model/dto/ShopInfoDto.java
  38. 0 122
      src/main/java/com/caimei/model/dto/ShopSaveDto.java
  39. 10 0
      src/main/java/com/caimei/model/po/ArticlePo.java
  40. 0 45
      src/main/java/com/caimei/model/po/CmBrandAuthFilePo.java
  41. 15 0
      src/main/java/com/caimei/model/po/CmBrandAuthPo.java
  42. 16 0
      src/main/java/com/caimei/model/po/CmBrandDoctorPo.java
  43. 5 0
      src/main/java/com/caimei/model/po/FilePo.java
  44. 5 0
      src/main/java/com/caimei/model/po/ImagePo.java
  45. 5 0
      src/main/java/com/caimei/model/po/ProductImagePo.java
  46. 0 2
      src/main/java/com/caimei/model/po/ProductParamPo.java
  47. 11 16
      src/main/java/com/caimei/model/po/ProductPo.java
  48. 7 2
      src/main/java/com/caimei/model/po/ProductTypePo.java
  49. 0 54
      src/main/java/com/caimei/model/po/ShopInfoPo.java
  50. 4 0
      src/main/java/com/caimei/model/po/SysRole.java
  51. 12 0
      src/main/java/com/caimei/model/po/SysUser.java
  52. 10 0
      src/main/java/com/caimei/model/po/UserPo.java
  53. 5 0
      src/main/java/com/caimei/model/po/VideoPo.java
  54. 6 0
      src/main/java/com/caimei/model/vo/ArticleFormVo.java
  55. 6 0
      src/main/java/com/caimei/model/vo/ArticleListVo.java
  56. 10 0
      src/main/java/com/caimei/model/vo/AuthFormVo.java
  57. 10 41
      src/main/java/com/caimei/model/vo/AuthProductVo.java
  58. 78 16
      src/main/java/com/caimei/model/vo/AuthVo.java
  59. 0 20
      src/main/java/com/caimei/model/vo/BrandVo.java
  60. 1 1
      src/main/java/com/caimei/model/vo/ClubVo.java
  61. 21 0
      src/main/java/com/caimei/model/vo/CmShopVo.java
  62. 3 0
      src/main/java/com/caimei/model/vo/DoctorListVo.java
  63. 1 1
      src/main/java/com/caimei/model/vo/FeedbackVo.java
  64. 3 0
      src/main/java/com/caimei/model/vo/FileListVo.java
  65. 5 0
      src/main/java/com/caimei/model/vo/ImageFormVo.java
  66. 3 0
      src/main/java/com/caimei/model/vo/ImageListVo.java
  67. 21 16
      src/main/java/com/caimei/model/vo/ProductFormVo.java
  68. 56 12
      src/main/java/com/caimei/model/vo/ProductListVo.java
  69. 37 0
      src/main/java/com/caimei/model/vo/ProductRelationVo.java
  70. 3 0
      src/main/java/com/caimei/model/vo/ProductTypeListVo.java
  71. 2 2
      src/main/java/com/caimei/model/vo/ShopBrandVo.java
  72. 53 16
      src/main/java/com/caimei/model/vo/ShopFormVo.java
  73. 7 41
      src/main/java/com/caimei/model/vo/ShopInfoVo.java
  74. 6 36
      src/main/java/com/caimei/model/vo/ShopListVo.java
  75. 0 15
      src/main/java/com/caimei/model/vo/StatementFileVo.java
  76. 48 0
      src/main/java/com/caimei/model/vo/TemplateListVo.java
  77. 5 5
      src/main/java/com/caimei/model/vo/UserLoginVo.java
  78. 3 0
      src/main/java/com/caimei/model/vo/VideoListVo.java
  79. 3 0
      src/main/java/com/caimei/model/vo/WxClubDetailsVo.java
  80. 1 1
      src/main/java/com/caimei/model/vo/WxClubListVo.java
  81. 9 6
      src/main/java/com/caimei/model/vo/WxProductListVo.java
  82. 3 0
      src/main/java/com/caimei/model/vo/WxShopVo.java
  83. 14 1
      src/main/java/com/caimei/service/auth/ArticleService.java
  84. 13 4
      src/main/java/com/caimei/service/auth/AuthClubService.java
  85. 34 4
      src/main/java/com/caimei/service/auth/AuthProductService.java
  86. 15 12
      src/main/java/com/caimei/service/auth/AuthService.java
  87. 7 0
      src/main/java/com/caimei/service/auth/DoctorService.java
  88. 16 2
      src/main/java/com/caimei/service/auth/DownloadService.java
  89. 38 41
      src/main/java/com/caimei/service/auth/ShopService.java
  90. 4 2
      src/main/java/com/caimei/service/auth/UploadService.java
  91. 33 12
      src/main/java/com/caimei/service/auth/impl/ArticleServiceImpl.java
  92. 32 12
      src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java
  93. 334 174
      src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java
  94. 198 555
      src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
  95. 28 15
      src/main/java/com/caimei/service/auth/impl/DoctorServiceImpl.java
  96. 354 46
      src/main/java/com/caimei/service/auth/impl/DownloadServiceImpl.java
  97. 110 193
      src/main/java/com/caimei/service/auth/impl/ShopServiceImpl.java
  98. 135 37
      src/main/java/com/caimei/service/auth/impl/UploadServiceImpl.java
  99. 3 3
      src/main/java/com/caimei/service/auth/impl/UserServiceImpl.java
  100. 7 0
      src/main/java/com/caimei/service/data/FileService.java

+ 2 - 0
src/main/java/com/caimei/AdminApplication.java

@@ -4,6 +4,7 @@ import com.github.tobato.fastdfs.FdfsClientConfig;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.servlet.MultipartConfigFactory;
+import org.springframework.boot.web.servlet.ServletComponentScan;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.EnableMBeanExport;
 import org.springframework.context.annotation.Import;
@@ -21,6 +22,7 @@ import javax.servlet.MultipartConfigElement;
 @Import(FdfsClientConfig.class)
 // 解决jmx重复注册bean的问题
 @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
+@ServletComponentScan
 @SpringBootApplication
 public class AdminApplication {
 

+ 16 - 0
src/main/java/com/caimei/annotation/CurrentUser.java

@@ -0,0 +1,16 @@
+package com.caimei.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Aslee
+ * @date 2022/07/22
+ * 自定义注解:获取当前用户
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CurrentUser {
+}

+ 65 - 0
src/main/java/com/caimei/annotation/CurrentUserResolver.java

@@ -0,0 +1,65 @@
+package com.caimei.annotation;
+
+import com.caimei.components.RedisService;
+import com.caimei.mapper.cmMapper.SystemMapper;
+import com.caimei.model.po.SysUser;
+import com.caimei.model.po.UserPo;
+import com.caimei.utils.JwtUtil;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.MethodParameter;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.support.WebDataBinderFactory;
+import org.springframework.web.context.request.NativeWebRequest;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
+import org.springframework.web.method.support.ModelAndViewContainer;
+
+import javax.annotation.Resource;
+
+/**
+ * @author Aslee
+ * @date 2022/7/22
+ * 统一处理供应商和供应商子用户登陆后,authUserId不明确的问题
+ */
+@Component
+public class CurrentUserResolver implements HandlerMethodArgumentResolver {
+
+    private RedisService redisService;
+    @Autowired
+    public void setRedisService(RedisService redisService) {
+        this.redisService = redisService;
+    }
+
+    @Resource
+    private SystemMapper systemMapper;
+
+    @Override
+    public boolean supportsParameter(MethodParameter parameter) {
+        return parameter.hasParameterAnnotation(CurrentUser.class) &&
+                parameter.getParameterType().isAssignableFrom(SysUser.class);
+    }
+
+    @Override
+    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
+                                  NativeWebRequest request, WebDataBinderFactory factory) {
+        // header中获取用户token
+        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 (!cacheToken.contains(",")) {
+                // 后台管理员/供应商/供应商子用户登录
+                Integer authUserId = JwtUtil.parseTokenUid(cacheToken);
+                return systemMapper.getUser(authUserId);
+            } else {
+                // 前端机构用户登录
+                /*String[] tokenArr = cacheToken.split(",");
+                Integer authUserId = Integer.parseInt(tokenArr[1]);
+                return systemMapper.getUser(authUserId);*/
+                return null;
+            }
+        }
+//        return systemMapper.getUser(17);
+        return null;
+    }
+}

+ 2 - 2
src/main/java/com/caimei/config/ApiInterceptor.java

@@ -41,8 +41,8 @@ public class ApiInterceptor implements HandlerInterceptor {
         String cacheToken = null != token ? String.valueOf(redisService.get(token)) : null;
         if (null == cacheToken || !JwtUtil.isVerify(cacheToken)) {
             // Token失效
-            /*response.sendRedirect(zplmapi + "/unauthorized");
-            return false;*/
+            response.sendRedirect(zplmapi + "/unauthorized");
+            return false;
         }
         return true;
     }

+ 97 - 0
src/main/java/com/caimei/config/ArgumentFilter.java

@@ -0,0 +1,97 @@
+package com.caimei.config;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.twelvemonkeys.util.LinkedSet;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StreamUtils;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.*;
+
+@Slf4j
+//@Component
+public class ArgumentFilter implements Filter {
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
+        HttpServletRequest httpRequest = (HttpServletRequest) request;
+        HttpServletResponse httpResponse = (HttpServletResponse) response;
+        String token = httpRequest.getHeader("token");
+        Integer userId = 123456;
+        log.info("filter获取用户Id={}", userId);
+        HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(httpRequest) {
+            /*@Override
+            public Enumeration<String> getParameterNames(){
+                Set<String> paramNames = new LinkedSet<>();
+                paramNames.add("authUserId");
+                Enumeration<String> parameterNames = super.getParameterNames();
+                if (parameterNames.hasMoreElements()) {
+                    paramNames.add(parameterNames.nextElement());
+                }
+                return Collections.enumeration(paramNames);
+            }
+
+            @Override
+            public String[] getParameterValues(String name){
+                if ("authUserId".equals(name)) {
+                    return new String[]{"123456"};
+                }
+                return super.getParameterValues(name);
+            }*/
+
+            @Override
+            public ServletInputStream getInputStream() {
+                byte[] requestBody = new byte[0];
+                try {
+                    //获取request的输入流,并设置格式为UTF-8
+                    BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
+                    //将输入流数据放入StringBuilder
+                    StringBuilder stringBuilder = new StringBuilder();
+                    String inputStr = null;
+                    while ((inputStr = streamReader.readLine()) != null) {
+                        stringBuilder.append(inputStr);
+                    }
+                    Gson gson = new Gson();
+                    HashMap map = gson.fromJson(stringBuilder.toString(), HashMap.class);
+                    map.put("authUserId", "234567");
+                    requestBody = gson.toJson(map).getBytes();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+                final ByteArrayInputStream bais = new ByteArrayInputStream(requestBody);
+                return new ServletInputStream() {
+                    @Override
+                    public boolean isFinished() {
+                        return false;
+                    }
+
+                    @Override
+                    public boolean isReady() {
+                        return true;
+                    }
+
+                    @Override
+                    public void setReadListener(ReadListener readListener) {
+
+                    }
+
+                    @Override
+                    public int read() {
+                        return bais.read();
+                    }
+                };
+            }
+        };
+        filterChain.doFilter(requestWrapper, httpResponse);
+    }
+}

+ 33 - 0
src/main/java/com/caimei/config/FilterConfig.java

@@ -0,0 +1,33 @@
+package com.caimei.config;
+
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.Resource;
+import javax.servlet.Filter;
+
+//@Configuration
+public class FilterConfig {
+
+    @Resource
+    private ArgumentFilter argumentFilter;
+
+    @Bean
+    public FilterRegistrationBean<Filter> registerAuthFilter() {
+        FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
+        registration.setFilter(argumentFilter);
+        registration.addUrlPatterns("/auth/*");
+        registration.addUrlPatterns("/club/*");
+        registration.addUrlPatterns("/shop/*");
+        registration.addUrlPatterns("/user/update/password");
+        registration.addUrlPatterns("/data/*");
+        registration.addUrlPatterns("/sys/*");
+        registration.addUrlPatterns("/vip/*");
+        registration.addUrlPatterns("/auth/export/excel");
+        registration.setName("argumentFilter");
+        // 值越小,Filter越靠前
+        registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE);
+        return registration;
+    }
+}

+ 22 - 0
src/main/java/com/caimei/config/WebConfig.java

@@ -0,0 +1,22 @@
+package com.caimei.config;
+
+import com.caimei.annotation.CurrentUserResolver;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+    @Resource
+    private CurrentUserResolver currentUserResolver;
+
+    @Override
+    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
+        argumentResolvers.add(currentUserResolver);
+    }
+
+}

+ 99 - 37
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -1,8 +1,11 @@
 package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
+import com.caimei.annotation.Idempotent;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandAuthPo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
 import com.caimei.service.auth.AuthService;
@@ -17,7 +20,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -45,11 +47,12 @@ public class AuthApi {
      */
     @ApiOperation("授权列表")
     @ApiImplicitParams({
+            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
             @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
             @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
+            @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
             @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
             @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
             @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
@@ -58,20 +61,36 @@ public class AuthApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile,
-                                                      Integer status, Integer auditStatus, Integer lowerAuditStatus,
+    public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType,  String authParty, String mobile,
+                                                      Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
                                                       Integer shopAuditStatus, Integer sendStatus,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        return authService.getAuthList(listType, authUserId, authParty, mobile, status, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, pageNum, pageSize);
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, pageNum, pageSize);
     }
 
     @ApiOperation("机构下拉框列表")
-    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/select")
-    public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
+    public ResponseJson<List<AuthVo>> getAuthSelectList(@CurrentUser SysUser sysUser) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空", null);
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         return authService.getAuthSelectList(authUserId);
     }
@@ -82,7 +101,7 @@ public class AuthApi {
     @ApiOperation("更新授权状态")
     @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
     @PostMapping("/update/status")
-    public ResponseJson updateAuthStatus(@RequestBody Map<String,Integer> params) {
+    public ResponseJson updateAuthStatus(@RequestBody Map<String, Integer> params) {
         Integer authId = params.get("authId");
         Integer status = params.get("status");
         return authService.updateAuthStatus(authId, status);
@@ -94,7 +113,7 @@ public class AuthApi {
     @ApiOperation("删除授权")
     @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
     @PostMapping("/delete")
-    public ResponseJson deleteAuth(@RequestBody Map<String,Integer> params) {
+    public ResponseJson deleteAuth(@RequestBody Map<String, Integer> params) {
         Integer authId = params.get("authId");
         return authService.deleteAuth(authId);
     }
@@ -113,17 +132,28 @@ public class AuthApi {
      * 添加/编辑授权
      */
     @ApiOperation("添加/编辑授权")
-    @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
+    @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
             "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
             "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
             "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
-            "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
-            "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true)
+            "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
+            "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
+            "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
     @PostMapping("/save")
-    public ResponseJson saveAuth(@RequestBody String params) throws ParseException {
+    @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
+    public ResponseJson saveAuth(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authId = paramsMap.getInteger("authId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         Integer provinceId = paramsMap.getInteger("provinceId");
         Integer cityId = paramsMap.getInteger("cityId");
         Integer townId = paramsMap.getInteger("townId");
@@ -131,6 +161,8 @@ public class AuthApi {
         String lngAndLat = paramsMap.getString("lngAndLat");
         String mobile = paramsMap.getString("mobile");
         String userMobile = paramsMap.getString("userMobile");
+        String linkMan = paramsMap.getString("linkMan");
+        String linkMobile = paramsMap.getString("linkMobile");
         Integer firstClubType = paramsMap.getInteger("firstClubType");
         Integer secondClubType = paramsMap.getInteger("secondClubType");
         String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
@@ -150,7 +182,6 @@ public class AuthApi {
         String remarks = paramsMap.getString("remarks");
         List<String> bannerList = (List<String>) paramsMap.get("bannerList");
         String authParty = paramsMap.getString("authParty");
-        Integer createBy = paramsMap.getInteger("createBy");
         Integer source = paramsMap.getInteger("source");
         if (null == source) {
             // 默认供应商保存
@@ -177,6 +208,8 @@ public class AuthApi {
         auth.setLat(new BigDecimal(split[1]));
         auth.setMobile(mobile);
         auth.setUserMobile(userMobile);
+        auth.setLinkMan(linkMan);
+        auth.setLinkMobile(linkMobile);
         auth.setFirstClubType(firstClubType);
         auth.setSecondClubType(secondClubType);
         auth.setMedicalLicenseImage(medicalLicenseImage);
@@ -200,26 +233,36 @@ public class AuthApi {
     @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
             "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
     @PostMapping("/audit")
-    public ResponseJson auditAuth(@RequestBody String params) {
+    public ResponseJson auditAuth(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取审核人用户id
+        Integer auditBy = sysUser.getId();
+        if (null == auditBy) {
+            return ResponseJson.error("审核人用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authId = paramsMap.getInteger("authId");
         Integer auditStatus = paramsMap.getInteger("auditStatus");
         String invalidReason = paramsMap.getString("invalidReason");
-        Integer auditBy = paramsMap.getInteger("auditBy");
         Integer source = paramsMap.getInteger("source");
         return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
     }
 
     @ApiOperation("excel导入")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
-            @ApiImplicitParam(name = "createBy", required = true, value = "创建人用户id"),
-            @ApiImplicitParam(name = "file", required = true, value = "代理声明文件"),
-    })
+    @ApiImplicitParam(name = "file", required = true, value = "机构excel表格")
     @PostMapping("/import/excel")
-    public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
+    public ResponseJson importDataByExcel(@CurrentUser SysUser sysUser, MultipartFile file) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        Integer createBy = sysUser.getId();
         if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商id");
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         if (null == createBy) {
             return ResponseJson.error("参数异常,请输入创建人id");
@@ -230,21 +273,40 @@ public class AuthApi {
         return authService.importDataByExcel(file, authUserId, createBy);
     }
 
-
-    @ApiOperation("excel导出")
-    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
-    @GetMapping("/export/excel")
-    public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
+    @ApiOperation("ldm门店图/备注导入")
+    @GetMapping("/ldm/image/import")
+    public ResponseJson importLdmImage(@CurrentUser SysUser sysUser) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商id");
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return authService.exportDataByExcel(authUserId, response);
+        return authService.importLdmImage(authUserId);
     }
 
-    @ApiOperation("ldm门店图/备注导入")
-    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
-    @GetMapping("/ldm/image/import")
-    public ResponseJson importLdmImage(Integer authUserId){
-        return authService.importLdmImage(authUserId);
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkAuth(@PathVariable("id") Integer authId) {
+        return authService.checkAuth(authId);
+    }
+
+    @ApiOperation("勾选明星机构")
+    @ApiImplicitParam(name = "params", required = true, value = "authId:机构id;starFlag:明星机构标识:1明星机构,0不是")
+    @PostMapping("/star")
+    public ResponseJson starAuth(@RequestBody String params) {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        Integer authId = paramsMap.getInteger("authId");
+        Integer starFlag = paramsMap.getInteger("starFlag");
+        if (null == authId) {
+            return ResponseJson.error("机构id不能为空");
+        }
+        if (null == starFlag) {
+            return ResponseJson.error("明星机构标识不能为空");
+        }
+        return authService.starAuth(authId, starFlag);
     }
 }

+ 35 - 12
src/main/java/com/caimei/controller/admin/auth/AuthClubApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.ClubUserVo;
 import com.caimei.model.vo.ClubVo;
 import com.caimei.service.auth.AuthClubService;
@@ -35,46 +37,67 @@ public class AuthClubApi {
 
     @ApiOperation("机构列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
-            @ApiImplicitParam(name = "clubName", required = false, value = "机构名称"),
+            @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<ClubVo>> getClubList(Integer authUserId, String clubName,
+    public ResponseJson<PageInfo<ClubVo>> getClubList(@CurrentUser SysUser sysUser, String authParty,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        return authClubService.getClubList(authUserId, clubName, pageNum, pageSize);
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authClubService.getClubList(authUserId, authParty, pageNum, pageSize);
     }
 
 
     @ApiOperation("机构用户列表")
     @GetMapping("/user/list")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
             @ApiImplicitParam(name = "name", required = false, value = "姓名"),
             @ApiImplicitParam(name = "status", required = false, value = "状态:0停用,1启用"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
-    public ResponseJson<PageInfo<ClubUserVo>> getClubUserList(Integer authUserId, String mobile, String name, Integer status,
+    public ResponseJson<PageInfo<ClubUserVo>> getClubUserList(@CurrentUser SysUser sysUser, String mobile, String name, Integer status,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return authClubService.getClubUserList(authUserId, mobile, name, status, pageNum, pageSize);
     }
 
     @ApiOperation("添加/编辑机构用户")
     @PostMapping("/user/save")
-    @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id;authUserId:供应商用户id;mobile:手机号", required = true)
-    public ResponseJson saveClubUser(@RequestBody String params) {
+    @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id;mobile:手机号", required = true)
+    public ResponseJson saveClubUser(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer clubUserId = paramsMap.getInteger("clubUserId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         String mobile = paramsMap.getString("mobile");
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id");
-        }
         if (StringUtils.isEmpty(mobile)) {
             return ResponseJson.error("参数异常,请输入手机号");
         }

+ 128 - 48
src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java

@@ -2,11 +2,13 @@ package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.annotation.Idempotent;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductTypePo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
 import com.caimei.model.vo.ProductTypeListVo;
@@ -63,6 +65,23 @@ public class AuthProductApi {
     }
 
 
+    @ApiOperation("供应商下审核通过设备sn码列表")
+    @ApiImplicitParam(name = "authId", required = true, value = "授权id")
+    @GetMapping("/sn/list")
+    public ResponseJson<List<String>> getSnCodeList(@CurrentUser SysUser sysUser, Integer authId) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authProductService.getSnCodeList(authUserId, authId);
+    }
+
+
     /**
      * 更新授权商品状态
      */
@@ -95,8 +114,6 @@ public class AuthProductApi {
      *                   snCode                 商品SN码
      *                   productImage           商品图片
      *                   certificateImage       授权牌照
-     *                   addQrCodeFlag          是否生成二维码授权牌:0否,1是
-     *                   addTemplateType        生成二维码授权牌模板:1左下,2右边,3左边
      *                   purchaseWay            购买渠道
      *                   invoiceImage           发票图片
      *                   status                 上线状态:0已下线,1已上线,2待上线
@@ -106,15 +123,37 @@ public class AuthProductApi {
      */
     @ApiOperation("添加/编辑授权商品")
     @PostMapping("/save")
-    public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
-        return authProductService.saveProduct(productSaveDto, false);
+    @Idempotent(prefix = "idempotent_product_save", keys = {"#productSaveDto"}, expire = 5)
+    public ResponseJson saveProduct(@CurrentUser SysUser sysUser, @RequestBody ProductSaveDto productSaveDto) throws IOException {
+        // 获取创建人用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
+        productSaveDto.setCreateBy(createBy);
+        return authProductService.saveProduct(productSaveDto);
     }
 
     @ApiOperation("授权商品回显数据")
-    @ApiImplicitParam(name = "productId", required = true, value = "授权商品id")
+    @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id")
     @GetMapping("/form/data")
-    public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
-        return authProductService.getProductFormData(productId);
+    public ResponseJson<ProductFormVo> getProductFormData(Integer relationId) {
+        if (null == relationId) {
+            return ResponseJson.error("机构设备关联id不能为空", null);
+        }
+        return authProductService.getProductFormData(relationId);
+    }
+
+
+    @ApiOperation("关联设备获取设备信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "productId", required = false, value = "设备id"),
+            @ApiImplicitParam(name = "snCode", required = false, value = "sn码")
+    })
+    @GetMapping("/info")
+    public ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode) {
+        if (null == productId && null == snCode) {
+            return ResponseJson.error("设备id和sn码不能同时为空", null);
+        }
+        return authProductService.getProductInfo(productId, snCode);
     }
 
     /**
@@ -131,12 +170,19 @@ public class AuthProductApi {
             "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
     @Idempotent(prefix = "idempotent_product", keys = {"#params"}, expire = 5)
     @PostMapping("/audit")
-    public ResponseJson auditProduct(@RequestBody String params) {
+    public ResponseJson auditProduct(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取审核人用户id
+        Integer auditBy = sysUser.getId();
+        if (null == auditBy) {
+            return ResponseJson.error("审核人用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer productId = paramsMap.getInteger("productId");
         Integer auditStatus = paramsMap.getInteger("auditStatus");
         String invalidReason = paramsMap.getString("invalidReason");
-        Integer auditBy = paramsMap.getInteger("auditBy");
         Integer source = paramsMap.getInteger("source");
         return authProductService.auditProduct(productId, auditStatus, invalidReason, auditBy, source);
     }
@@ -152,23 +198,28 @@ public class AuthProductApi {
     }
 
     @ApiOperation("添加/编辑设备分类")
-    @ApiImplicitParam(name = "params", value = "productTypeId:设备分类id;authUserId:供应商用户id;name:设备分类名称;image:图片;createBy:创建人用户id;", required = true)
+    @ApiImplicitParam(name = "params", value = "productTypeId:设备分类id;infoId:品牌信息id;name:设备分类名称;image:图片;createBy:创建人用户id;paramList:参数列表;", required = true)
     @PostMapping("/type/save")
-    public ResponseJson saveProductType(@RequestBody String params) throws IOException {
+    public ResponseJson saveProductType(@CurrentUser SysUser sysUser, @RequestBody String params) throws IOException {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer productTypeId = paramsMap.getInteger("productTypeId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
-        Integer brandId = paramsMap.getInteger("brandId");
+        Integer infoId = paramsMap.getInteger("infoId");
         String name = paramsMap.getString("name");
         String image = paramsMap.getString("image");
-        Integer createBy = paramsMap.getInteger("createBy");
         String paramListStr = paramsMap.getString("paramList");
         List<ProductParamPo> paramList = JSONArray.parseArray(paramListStr, ProductParamPo.class);
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空");
-        }
-        if (null == brandId) {
-            return ResponseJson.error("参数异常,品牌id不能为空");
+        if (null == infoId) {
+            return ResponseJson.error("参数异常,品牌信息id不能为空");
         }
         if (StringUtils.isEmpty(name)) {
             return ResponseJson.error("参数异常,设备分类名称不能为空");
@@ -179,7 +230,7 @@ public class AuthProductApi {
         if (null == paramList || paramList.size() <= 0) {
             return ResponseJson.error("参数异常,参数列表不能为空", null);
         }
-        return authProductService.saveProductType(productTypeId, authUserId, brandId, name, image, createBy, paramList, 1);
+        return authProductService.saveProductType(productTypeId, authUserId, infoId, name, image, createBy, paramList, 1);
     }
 
     @ApiOperation("删除设备分类")
@@ -193,6 +244,34 @@ public class AuthProductApi {
         return authProductService.deleteProductType(productTypeId);
     }
 
+    @ApiOperation("设备分类列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
+            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1设备分类列表,2设备分类审核列表"),
+            @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"),
+            @ApiImplicitParam(name = "status", required = false, value = "上线状态:0下线,1上线,2待上线"),
+            @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
+            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
+            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
+    })
+    @GetMapping("/type/list")
+    public ResponseJson<PageInfo<ProductTypeListVo>> getProductTypeList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String name, Integer status, Integer auditStatus,
+                                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authProductService.getProductTypeList(listType, authUserId, name, status, auditStatus, pageNum, pageSize);
+    }
+
     @ApiOperation("更新设备分类状态")
     @ApiImplicitParam(name = "params", value = "productTypeId:设备分类id;status:上线状态:0已下线,1已上线,2待上线", required = true)
     @PostMapping("/type/update/status")
@@ -210,32 +289,17 @@ public class AuthProductApi {
         return authProductService.updateProductTypeStatus(productTypeId, status);
     }
 
-    @ApiOperation("设备分类列表")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1设备分类列表,2设备分类审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
-            @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"),
-            @ApiImplicitParam(name = "status", required = false, value = "上线状态:0下线,1上线,2待上线"),
-            @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
-            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
-            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
-    })
-    @GetMapping("/type/list")
-    public ResponseJson<PageInfo<ProductTypeListVo>> getProductTypeList(Integer listType, Integer authUserId, String name, Integer status, Integer auditStatus,
-                                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
-                                                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空", null);
-        }
-        return authProductService.getProductTypeList(listType, authUserId, name, status, auditStatus, pageNum, pageSize);
-    }
-
     @ApiOperation("设备分类下拉框列表")
-    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/type/select")
-    public ResponseJson<List<ProductTypeListVo>> getProductTypeSelectList(Integer authUserId) {
+    public ResponseJson<List<ProductTypeListVo>> getProductTypeSelectList(@CurrentUser SysUser sysUser) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空", null);
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         return authProductService.getProductTypeSelectList(authUserId);
     }
@@ -243,12 +307,19 @@ public class AuthProductApi {
     @ApiOperation("审核设备分类")
     @ApiImplicitParam(name = "params", value = "productTypeId:设备分类id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
     @PostMapping("/type/audit")
-    public ResponseJson auditProductType(@RequestBody String params) {
+    public ResponseJson auditProductType(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取审核人用户id
+        Integer auditBy = sysUser.getId();
+        if (null == auditBy) {
+            return ResponseJson.error("审核人用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer productTypeId = paramsMap.getInteger("productTypeId");
         Integer auditStatus = paramsMap.getInteger("auditStatus");
         String invalidReason = paramsMap.getString("invalidReason");
-        Integer auditBy = paramsMap.getInteger("auditBy");
         if (productTypeId == null) {
             return ResponseJson.error("请输入商品id");
         }
@@ -258,9 +329,18 @@ public class AuthProductApi {
         if (auditStatus == 0 && StringUtils.isEmpty(invalidReason)) {
             return ResponseJson.error("请输入审核不通过的原因");
         }
-        if (auditBy == null) {
-            return ResponseJson.error("请输入审核人用户id");
-        }
         return authProductService.auditProductType(productTypeId, auditStatus, invalidReason, auditBy);
     }
+
+    @ApiOperation("更改设备查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkAuthProduct(@PathVariable("id") Integer productId) {
+        return authProductService.checkAuthProduct(productId);
+    }
+
+    @ApiOperation("更改设备分类查看标记")
+    @PostMapping("/type/check/{id}")
+    public ResponseJson checkProductType(@PathVariable("id") Integer productTypeId) {
+        return authProductService.checkProductType(productTypeId);
+    }
 }

+ 24 - 7
src/main/java/com/caimei/controller/admin/auth/AuthTemplateApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.TemplateVo;
 import com.caimei.service.auth.AuthTemplateService;
 import com.github.pagehelper.PageInfo;
@@ -31,14 +33,19 @@ public class AuthTemplateApi {
     @ApiOperation("授权牌模板列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = true, value = "列表类型:1管理员列表,2供应商列表"),
-            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<TemplateVo>> getTemplateList(Integer listType, Integer authUserId,
+    public ResponseJson<PageInfo<TemplateVo>> getTemplateList(@CurrentUser SysUser sysUser, Integer listType,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         return authTemplateService.getTemplateList(listType, authUserId, pageNum, pageSize);
     }
 
@@ -46,12 +53,17 @@ public class AuthTemplateApi {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "templateId", required = false, value = "模板id"),
             @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
-            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
             @ApiImplicitParam(name = "authFlag", required = false, value = "是否作为机构授权牌模板:1是0否"),
             @ApiImplicitParam(name = "status", required = false, value = "启用状态:0停用,1启用")
     })
     @GetMapping("/form/data")
-    public ResponseJson<TemplateVo> getTemplateFormData(Integer templateId, Integer authId, Integer authUserId, Integer authFlag, Integer status) {
+    public ResponseJson<TemplateVo> getTemplateFormData(@CurrentUser SysUser sysUser, Integer templateId, Integer authId, Integer authFlag, Integer status) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == templateId && null == authId && null == authUserId) {
             return ResponseJson.error("参数异常", null);
         }
@@ -60,14 +72,19 @@ public class AuthTemplateApi {
 
     @ApiOperation("添加/编辑授权模板")
     @ApiImplicitParam(name = "params", required = true, value = "templateId:模板id;templateImage:模板图片;" +
-            "authUserId:供应商用户id;status:状态:1启用,0停用;qrPosition:二维码位置;qrSize:二维码尺寸;" +
+            "status:状态:1启用,0停用;qrPosition:二维码位置;qrSize:二维码尺寸;" +
             "logoSize:logo尺寸;authFlag:1设置为机构授权牌模板;productFlag:1设置为设备授权牌模板")
     @PostMapping("/save")
-    public ResponseJson saveTemplate(@RequestBody String params){
+    public ResponseJson saveTemplate(@CurrentUser SysUser sysUser, @RequestBody String params){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         JSONObject parseObject = JSONObject.parseObject(params);
         Integer templateId = parseObject.getInteger("templateId");
         String templateImage = parseObject.getString("templateImage");
-        Integer authUserId = parseObject.getInteger("authUserId");
         Integer status = parseObject.getInteger("status");
         String qrPosition = parseObject.getString("qrPosition");
         Integer qrSize = parseObject.getInteger("qrSize");

+ 44 - 8
src/main/java/com/caimei/controller/admin/auth/DoctorApi.java

@@ -1,8 +1,10 @@
 package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandDoctorPo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.DoctorFormVo;
 import com.caimei.model.vo.DoctorListVo;
 import com.caimei.service.auth.DoctorService;
@@ -36,7 +38,6 @@ public class DoctorApi {
     @ApiOperation("医师列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1医师列表,2医师审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"),
             @ApiImplicitParam(name = "doctorName", required = false, value = "医师姓名"),
             @ApiImplicitParam(name = "certificateNo", required = false, value = "从业资格证编号"),
@@ -46,9 +47,23 @@ public class DoctorApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<DoctorListVo>> getDoctorList(Integer listType, Integer authUserId, Integer doctorType, String doctorName, String certificateNo, Integer status, Integer auditStatus,
+    public ResponseJson<PageInfo<DoctorListVo>> getDoctorList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, Integer doctorType, String doctorName, String certificateNo, Integer status, Integer auditStatus,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        if (null == doctorType) {
+            return ResponseJson.error("参数异常,医师类型不能为空", null);
+        }
         return doctorService.getDoctorList(listType, authUserId, doctorType, doctorName, certificateNo, status, auditStatus, pageNum, pageSize);
     }
 
@@ -89,22 +104,30 @@ public class DoctorApi {
      * 添加/编辑医师
      */
     @ApiOperation("添加/编辑医师")
-    @ApiImplicitParam(name = "params", value = "doctorId:医师id;authUserId:供应商用户id;authId:机构id;doctorType:医师类型:1操作医师,2培训医师;" +
+    @ApiImplicitParam(name = "params", value = "doctorId:医师id;authId:机构id;doctorType:医师类型:1操作医师,2培训医师;" +
             "doctorName:医师姓名;" +"certificateNo:从业资格证编号;clubName:所在机构;createBy:创建人id;" +
             "bannerList:轮播图列表;" +"doctorImage:医师照片;equipmentList([{equipmentName:'',brand:'',image:''}]);" +
             "tagList(['标签1','标签2'];" + "paramList([{name:'参数1',content:'内容1'}..]))", required = true)
     @PostMapping("/save")
-    public ResponseJson saveDoctor(@RequestBody String params) {
+    public ResponseJson saveDoctor(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer doctorId = paramsMap.getInteger("doctorId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         Integer authId = paramsMap.getInteger("authId");
         Integer doctorType = paramsMap.getInteger("doctorType");
         String doctorName = paramsMap.getString("doctorName");
         String certificateNo = paramsMap.getString("certificateNo");
         String clubName = paramsMap.getString("clubName");
         String doctorImage = paramsMap.getString("doctorImage");
-        Integer createBy = paramsMap.getInteger("createBy");
         List<String> bannerList = (List<String>) paramsMap.get("bannerList");
         List<String> tagList = (List<String>) paramsMap.get("tagList");
         List<Map<String,Object>> equipmentList = (List<Map<String,Object>>) paramsMap.get("equipmentList");
@@ -133,12 +156,25 @@ public class DoctorApi {
     @ApiOperation("审核医师")
     @ApiImplicitParam(name = "params", value = "doctorId:医师id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
     @PostMapping("/audit")
-    public ResponseJson auditDoctor(@RequestBody String params) {
+    public ResponseJson auditDoctor(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取审核人用户id
+        Integer auditBy = sysUser.getId();
+        if (null == auditBy) {
+            return ResponseJson.error("审核人用户id不能为空", null);
+        }
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer doctorId = paramsMap.getInteger("doctorId");
         Integer auditStatus = paramsMap.getInteger("auditStatus");
         String invalidReason = paramsMap.getString("invalidReason");
-        Integer auditBy = paramsMap.getInteger("auditBy");
         return doctorService.auditDoctor(doctorId, auditStatus, invalidReason, auditBy);
     }
+
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkDoctor(@PathVariable("id") Integer doctorId) {
+        return doctorService.checkDoctor(doctorId);
+    }
 }

+ 40 - 5
src/main/java/com/caimei/controller/admin/auth/DownloadApi.java

@@ -1,5 +1,6 @@
 package com.caimei.controller.admin.auth;
 
+import com.caimei.model.ResponseJson;
 import com.caimei.service.auth.DownloadService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -7,6 +8,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -45,14 +47,47 @@ public class DownloadApi {
         }
     }
 
+    @ApiOperation("下载机构导入模板")
+    @GetMapping("/auth/template")
+    public void downloadAuthTemplate(HttpServletRequest request, HttpServletResponse response){
+        try {
+            downloadService.downloadAuthTemplate(request, response);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 
-    @ApiOperation("一键下载授权牌/设备二维码/机构二维码")
+    @ApiOperation("一键下载机构授权牌/设备授权牌/机构二维码/设备二维码")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
-            @ApiImplicitParam(name = "type", required = true, value = "1授权牌,2设备二维码,3机构二维码")
+            @ApiImplicitParam(name = "authIds", required = false, value = "勾选中的机构id,以,隔开"),
+            @ApiImplicitParam(name = "type", required = false, value = "1机构授权牌,2.设备授权牌,3机构二维码,4设备二维码")
     })
     @GetMapping("/shop/image")
-    public void downloadImage(Integer authUserId, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception {
-        downloadService.downloadShopImage(authUserId, type, request, response);
+    public void downloadImage(String authIds, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        if (StringUtils.isEmpty(authIds) || null == type) {
+            return;
+        }
+        downloadService.downloadShopImage(authIds, type, request, response);
     }
+
+    @ApiOperation("excel导出机构信息")
+    @ApiImplicitParam(name = "authIds", required = true, value = "机构id,以,隔开")
+    @GetMapping("/auth/excel")
+    public ResponseJson downloadAuthData(String authIds, HttpServletResponse response) {
+        if (StringUtils.isEmpty(authIds)) {
+            return ResponseJson.error("机构id不能为空");
+        }
+        return downloadService.downloadAuthData(authIds, response);
+    }
+
+    @ApiOperation("excel导出设备信息")
+    @ApiImplicitParam(name = "authIds", required = true, value = "机构id,以,隔开")
+    @GetMapping("/product/excel")
+    public ResponseJson downloadProductData(String authIds, HttpServletRequest request, HttpServletResponse response) throws IOException {
+        if (StringUtils.isEmpty(authIds)) {
+            return ResponseJson.error("机构id不能为空");
+        }
+        return downloadService.downloadProductData(authIds, request, response);
+    }
+
 }

+ 269 - 85
src/main/java/com/caimei/controller/admin/auth/ShopApi.java

@@ -1,11 +1,16 @@
 package com.caimei.controller.admin.auth;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
+import com.caimei.components.RedisService;
+import com.caimei.mapper.cmMapper.SystemMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ShopInfoDto;
+import com.caimei.model.po.SysUser;
+import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.ShopService;
+import com.caimei.utils.JwtUtil;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -14,10 +19,13 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -36,16 +44,27 @@ public class ShopApi {
 
     private final ShopService shopService;
 
+
+    private RedisService redisService;
+
+    @Autowired
+    public void setRedisService(RedisService redisService) {
+        this.redisService = redisService;
+    }
+
+    @Resource
+    private SystemMapper systemMapper;
+
     /**
      * 供应商列表
      */
     @ApiOperation("供应商列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1供应商列表,2授权信息审核列表,3资料审核列表,4医师审核列表,5添加会员列表,6设备分类审核列表,7授权牌物流列表"),
+            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1供应商列表,2授权信息审核列表,3资料审核列表,4医师审核列表,5已启用供应商列表,6设备分类审核列表,7授权牌物流列表"),
             @ApiImplicitParam(name = "shopName", required = false, value = "供应商名称"),
             @ApiImplicitParam(name = "loginAccount", required = false, value = "登录账号"),
             @ApiImplicitParam(name = "shopType", required = false, value = "供应商类型:1品牌方,2代理商"),
-            @ApiImplicitParam(name = "brandId", required = false, value = "所属品牌id"),
+            @ApiImplicitParam(name = "infoId", required = false, value = "品牌信息id"),
             @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
             @ApiImplicitParam(name = "linkMan", required = false, value = "联系人"),
             @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "下级审核状态,0未完成审核,1已完成审核"),
@@ -54,10 +73,15 @@ public class ShopApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName,String loginAccount, Integer shopType, Integer brandId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus,
+    public ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName,String loginAccount, Integer shopType, Integer infoId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        return shopService.getShopList(listType, shopName, loginAccount, shopType, brandId, mobile, linkMan, lowerAuditStatus, sendStatus, pageNum, pageSize);
+        return shopService.getShopList(listType, shopName, loginAccount, shopType, infoId, mobile, linkMan, lowerAuditStatus, sendStatus, pageNum, pageSize);
+    }
+
+    @GetMapping("/cm/list")
+    public ResponseJson<List<CmShopVo>> getCmShopList(){
+        return shopService.getCmShopList();
     }
 
     /**
@@ -69,7 +93,18 @@ public class ShopApi {
     @ApiOperation("供应商回显数据")
     @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/form/data")
-    public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
+    public ResponseJson<ShopFormVo> getShopFormData(@CurrentUser SysUser sysUser, Integer authUserId) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return shopService.getShopFormData(authUserId);
     }
 
@@ -88,15 +123,11 @@ public class ShopApi {
      *                    createBy           创建人用户id
      *                    shopInfo  [
      *                                  {
-     *                                      brandId            品牌id
-     *                                      countryId          产地国家id
-     *                                      brandAuthLogo      品牌授权logo
-     *                                      securityLink       官网认证链接
-     *                                      statementType      代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
-     *                                      statementContent   声明弹窗内容
-     *                                      statementLink      声明链接
-     *                                      statementImage     声明图片
-     *                                      statementFileId    声明文件id
+     *                                      infoId                  品牌信息id
+     *                                      brandName               品牌名称
+     *                                      brandLogo               品牌logo
+     *                                      producePlace            产地
+     *                                      manufacturer            制造商
      *                                  }
      *                              ]
      *                    }
@@ -105,8 +136,10 @@ public class ShopApi {
     @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;", required = true)
     @PostMapping("/save")
     public ResponseJson saveShop(@RequestBody String params) {
+        // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authUserId = paramsMap.getInteger("authUserId");
+        Integer cmShopId = paramsMap.getInteger("cmShopId");
         Integer shopType = paramsMap.getInteger("shopType");
         if (null == shopType) {
             return ResponseJson.error("请选择供应商类型", null);
@@ -125,44 +158,85 @@ public class ShopApi {
             return ResponseJson.error("参数异常,请输入供应商状态");
         }
         String logo = (String) paramsMap.get("logo");
-        String qrCodeImage = (String) paramsMap.get("qrCodeImage");
-        Integer wxAccountType = (Integer) paramsMap.get("wxAccountType");
-        String appId = (String) paramsMap.get("appId");
-        String appSecret = (String) paramsMap.get("appSecret");
+        if (StringUtils.isEmpty(logo)) {
+            return ResponseJson.error("供应商logo不能为空");
+        }
+        String prefix = (String) paramsMap.get("prefix");
+        if (StringUtils.isEmpty(prefix)) {
+            return ResponseJson.error("前缀不能为空");
+        }
+        String qrCodeImage = paramsMap.getString("qrCodeImage");
+        Integer wxAccountType = paramsMap.getInteger("wxAccountType");
+        String appId = paramsMap.getString("appId");
+        String appSecret = paramsMap.getString("appSecret");
         Integer createBy = paramsMap.getInteger("createBy");
+        /*
+            组装供应商用户数据
+         */
+        UserPo shop = new UserPo();
+        // 供应商用户id
+        shop.setAuthUserId(authUserId);
+        // 关联采美供应商id
+        shop.setCmShopId(cmShopId);
+        // 供应商名称
+        shop.setName(shopName);
+        // 前缀
+        shop.setPrefix(prefix);
+        // 手机号
+        shop.setMobile(mobile);
+        // 联系人
+        shop.setLinkMan(linkMan);
+        // 供应商状态
+        shop.setStatus(shopStatus);
+        // 供应商logo
+        shop.setLogo(logo);
+        // 公众号二维码图片
+        shop.setQrCodeImage(qrCodeImage);
+        // 公众号类型
+        shop.setWxAccountType(wxAccountType);
+        // 公众号appId
+        shop.setAppId(appId);
+        // 公众号appSecret
+        shop.setAppSecret(appSecret);
+        // 供应商类型
+        shop.setShopType(shopType);
+        // 创建管理员id
+        shop.setCreateBy(createBy);
+        // 创建时间
+        shop.setCreateTime(new Date());
         List<Map<String, Object>> shopInfoData = (List<Map<String, Object>>) paramsMap.get("shopInfo");
         if (null == shopInfoData || shopInfoData.size() <= 0) {
             return ResponseJson.error("参数异常,请输入供应商信息");
         }
         List<ShopInfoDto> shopInfoList = new ArrayList<>();
+        List<String> brandNameList = new ArrayList<>();
         for (Map<String, Object> infoMap : shopInfoData) {
-            Integer brandId = (Integer) infoMap.get("brandId");
-            Integer countryId = (Integer) infoMap.get("countryId");
-            String brandAuthLogo = (String) infoMap.get("brandAuthLogo");
-            String securityLink = (String) infoMap.get("securityLink");
+            Integer infoId = null;
+            String infoIdStr = infoMap.get("infoId").toString();
+            if (StringUtils.isNotEmpty(infoIdStr)) {
+                infoId = Integer.parseInt(infoIdStr);
+            }
+            String brandName = (String) infoMap.get("brandName");
+            String brandLogo = (String) infoMap.get("brandLogo");
+            String producePlace = (String) infoMap.get("producePlace");
             String manufacturer = (String) infoMap.get("manufacturer");
-            Integer statementType = (Integer) infoMap.get("statementType");
-            String statementContent = (String) infoMap.get("statementContent");
-            String statementLink = (String) infoMap.get("statementLink");
-            String statementImage = (String) infoMap.get("statementImage");
-            Integer statementFileId = (Integer) infoMap.get("statementFileId");
-            if (null == brandId || null == countryId || StringUtils.isEmpty(brandAuthLogo) || null == statementType) {
-                return ResponseJson.error("参数异常,供应商信息数据异常");
+            if (StringUtils.isEmpty(brandName) || StringUtils.isEmpty(brandLogo) || StringUtils.isEmpty(producePlace) || StringUtils.isEmpty(manufacturer)) {
+                return ResponseJson.error("供应商信息数据异常");
+            }
+            if (!brandNameList.contains(brandName)) {
+                brandNameList.add(brandName);
+            } else {
+                return ResponseJson.error("品牌名称重复");
             }
             ShopInfoDto shopInfo = new ShopInfoDto();
-            shopInfo.setBrandId(brandId);
-            shopInfo.setCountryId(countryId);
-            shopInfo.setBrandAuthLogo(brandAuthLogo);
-            shopInfo.setSecurityLink(securityLink);
+            shopInfo.setInfoId(infoId);
+            shopInfo.setBrandName(brandName);
+            shopInfo.setBrandLogo(brandLogo);
+            shopInfo.setProducePlace(producePlace);
             shopInfo.setManufacturer(manufacturer);
-            shopInfo.setStatementType(statementType);
-            shopInfo.setStatementContent(statementContent);
-            shopInfo.setStatementLink(statementLink);
-            shopInfo.setStatementImage(statementImage);
-            shopInfo.setStatementFileId(statementFileId);
             shopInfoList.add(shopInfo);
         }
-        return shopService.saveShop(authUserId, shopType, shopName, mobile, linkMan, shopStatus,logo, qrCodeImage, wxAccountType, appId, appSecret, createBy, shopInfoList);
+        return shopService.saveShop(shop, shopInfoList);
     }
 
     /**
@@ -172,6 +246,7 @@ public class ShopApi {
     @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;status:供应商状态:0停用 1启用", required = true)
     @PostMapping("/update/status")
     public ResponseJson updateShopStatus(@RequestBody Map<String,Integer> params) {
+        // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
         Integer authUserId = params.get("authUserId");
         Integer status = params.get("status");
         return shopService.updateShopStatus(authUserId, status);
@@ -184,44 +259,32 @@ public class ShopApi {
     @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id", required = true)
     @PostMapping("/reset/password")
     public ResponseJson resetShopPassword(@RequestBody Map<String,Integer> params) {
+        // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
         Integer authUserId = params.get("authUserId");
         return shopService.resetShopPassword(authUserId);
     }
 
-
-    /**
-     * 代理声明文件上传
-     *
-     * @param authUserId:供应商用户id
-     * @param brandId:品牌id
-     * @param file:代理声明文件
-     * @return Integer
-     */
-    @ApiOperation("代理声明文件上传")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
-            @ApiImplicitParam(name = "brandId", required = false, value = "品牌id"),
-            @ApiImplicitParam(name = "file", required = false, value = "代理声明文件"),
-    })
-    @PostMapping("/upload/file")
-    public ResponseJson<AuthFileVo> uploadFile(Integer authUserId, Integer brandId, MultipartFile file) {
-        return shopService.uploadFile(authUserId, brandId, file);
-    }
-
     /**
      * 品牌列表
      *
-     * @param type 1品牌方可用品牌列表,2代理商可用品牌列表,3供应商可用品牌列表
      * @return AuthVo
      */
-    @ApiOperation("品牌列表")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "type", value = "1品牌方品牌列表,2代理商品牌列表,3供应商可用品牌列表", required = true),
-            @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
-    })
-    @GetMapping("/brand/list")
-    public ResponseJson<List<BrandVo>> getBrandList(Integer type, Integer authUserId) {
-        return shopService.getBrandList(type, authUserId);
+    @ApiOperation("品牌信息列表")
+    @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
+    @GetMapping("/info/list")
+    public ResponseJson<List<ShopInfoVo>> getShopInfoList(@CurrentUser SysUser sysUser, Integer authUserId) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return shopService.getShopInfoList(authUserId);
     }
 
     /**
@@ -235,18 +298,26 @@ public class ShopApi {
 
     @ApiOperation("用户反馈列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
-            @ApiImplicitParam(name = "clubName", required = false, value = "机构名称"),
+            @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
             @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
             @ApiImplicitParam(name = "handleStatus", required = false, value = "处理状态:0未处理,1已处理"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/feedback/list")
-    public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String clubName, String mobile, Integer handleStatus,
+    public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(@CurrentUser SysUser sysUser, String authParty, String mobile, Integer handleStatus,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        return shopService.getFeedbackList(authUserId, clubName, mobile, handleStatus, pageNum, pageSize);
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return shopService.getFeedbackList(authUserId, authParty, mobile, handleStatus, pageNum, pageSize);
     }
 
     @ApiOperation("用户反馈表单数据")
@@ -276,38 +347,151 @@ public class ShopApi {
     }
 
     @ApiOperation("修改手机号")
-    @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;oldMobile:旧手机号;verifyCode:验证码;newMobile:新手机号;", required = true)
+    @ApiImplicitParam(name = "params", value = "oldMobile:旧手机号;verifyCode:验证码;newMobile:新手机号;", required = true)
     @PostMapping("/mobile/change")
-    public ResponseJson changeMobile(@RequestBody String params) {
+    public ResponseJson changeMobile(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject parseObject = JSONObject.parseObject(params);
-        Integer authUserId = parseObject.getInteger("authUserId");
         String verifyCode = parseObject.getString("verifyCode");
         String oldMobile = parseObject.getString("oldMobile");
         String newMobile = parseObject.getString("newMobile");
         return shopService.changeMobile(authUserId, oldMobile, verifyCode, newMobile);
     }
 
+    @ApiOperation("修改联系人")
+    @ApiImplicitParam(name = "params", value = "linkMan:联系人", required = true)
+    @PostMapping("/link/man/change")
+    public ResponseJson changeLinkMan(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String linkMan = parseObject.getString("linkMan");
+        return shopService.changeLinkMan(authUserId, linkMan);
+    }
+
+    @ApiOperation("修改公司logo")
+    @ApiImplicitParam(name = "params", value = "logo:公司logo", required = true)
+    @PostMapping("/logo/change")
+    public ResponseJson changeLogo(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String logo = parseObject.getString("logo");
+        return shopService.changeLogo(authUserId, logo);
+    }
+
     @ApiOperation("登录账号绑定")
-    @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
+    @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
     @PostMapping("/account/bind")
-    public ResponseJson bindLoginAccount(@RequestBody String params) {
+    public ResponseJson bindLoginAccount(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         JSONObject parseObject = JSONObject.parseObject(params);
-        Integer authUserId = parseObject.getInteger("authUserId");
         String verifyCode = parseObject.getString("verifyCode");
         String mobile = parseObject.getString("mobile");
         String loginAccount = parseObject.getString("loginAccount");
         return shopService.bindLoginAccount(authUserId, mobile, verifyCode, loginAccount);
     }
 
+    @ApiOperation("保存供应商品牌信息")
+    @ApiImplicitParam(name = "shopInfo", value = "品牌信息", required = true)
+    @PostMapping("/info/save")
+    public ResponseJson saveShopInfo(@CurrentUser SysUser sysUser, @RequestBody ShopInfoDto shopInfo) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return shopService.saveShopInfo(authUserId, shopInfo);
+    }
+
+    @ApiOperation("删除供应商品牌信息")
+    @ApiImplicitParam(name = "params", value = "infoId:品牌信息id", required = true)
+    @PostMapping("/info/delete")
+    public ResponseJson saveShopInfo(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        Integer infoId = parseObject.getInteger("infoId");
+        return shopService.deleteShopInfo(authUserId, infoId);
+    }
+
     @ApiOperation("一键更新机构授权牌")
-    @ApiImplicitParam(name = "params",value = "authUserId:供应商用户id")
     @PostMapping("/authImage/update/all")
-    public ResponseJson updateAllAuthImage(@RequestBody String params ){
-        JSONObject parseObject = JSONObject.parseObject(params);
-        Integer authUserId = parseObject.getInteger("authUserId");
+    public ResponseJson updateAllAuthImage(@CurrentUser SysUser sysUser){
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("供应商用户id不能为空");
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         return shopService.updateAllAuthImage(authUserId);
     }
+
+    @ApiOperation("管理员生成供应商token")
+    @GetMapping("/token/generate")
+    public ResponseJson<String> generateShopToken(Integer authUserId, HttpServletRequest request) {
+        // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
+        // 对管理员身份进行校验
+        String token = request.getHeader("X-Token");
+        String cacheToken = null != token ? String.valueOf(redisService.get(token)) : null;
+        if (null != cacheToken && JwtUtil.isVerify(cacheToken)) {
+            int adminId = JwtUtil.parseTokenUid(cacheToken);
+            SysUser user = systemMapper.getUser(adminId);
+            if (null == user || 1 != user.getUserIdentity()) {
+                return ResponseJson.error("生成token失败", null);
+            } else {
+                // 生成token给用户
+                String shopToken = JwtUtil.createToken(authUserId);
+                // 为了过期续签,将token存入redis,并设置超时时间
+                redisService.set(shopToken, shopToken, JwtUtil.getExpireTime());
+                return ResponseJson.success(shopToken);
+            }
+        } else {
+            return ResponseJson.error("生成token失败", null);
+        }
+    }
 }

+ 12 - 2
src/main/java/com/caimei/controller/admin/auth/UserApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.auth;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.PasswordDto;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.UserLoginVo;
 import com.caimei.service.auth.UserService;
 import io.swagger.annotations.Api;
@@ -42,7 +44,6 @@ public class UserApi {
     /**
      * 修改密码
      * @param passwordDto {
-     *                           authUserId         用户id
      *                           oldPassword        旧密码
      *                           newPassword        新密码
      *                           confirmPwd         确认密码
@@ -50,7 +51,16 @@ public class UserApi {
      */
     @ApiOperation("修改密码")
     @PostMapping("/update/password")
-    public ResponseJson updatePassword(@RequestBody PasswordDto passwordDto) {
+    public ResponseJson updatePassword(@CurrentUser SysUser sysUser, @RequestBody PasswordDto passwordDto) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 供应商和子用户都可以修改密码,直接取id即可
+        Integer authUserId = sysUser.getId();
+        if (null == authUserId) {
+            return ResponseJson.error("用户id不能为空", null);
+        }
+        passwordDto.setAuthUserId(authUserId);
         return userService.updatePassword(passwordDto);
     }
 }

+ 40 - 8
src/main/java/com/caimei/controller/admin/data/ArticleApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.data;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.ArticleFormVo;
 import com.caimei.model.vo.ArticleListVo;
 import com.caimei.service.auth.ArticleService;
@@ -35,7 +37,6 @@ public class ArticleApi {
     @ApiOperation("文章列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1文章列表,2文章审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "articleTitle", required = false, value = "文章标题"),
             @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
             @ApiImplicitParam(name = "status", required = false, value = "文章状态:0已下线,1已上线,2待上线"),
@@ -43,23 +44,38 @@ public class ArticleApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status,
+    public ResponseJson<PageInfo<ArticleListVo>> getArticleList(@CurrentUser SysUser sysUser, Integer listType, String articleTitle, Integer auditStatus, Integer status,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return articleService.getArticleList(listType, authUserId, articleTitle, auditStatus, status, pageNum, pageSize);
     }
 
     @ApiOperation("添加/编辑文章")
-    @ApiImplicitParam(name = "params", value = "articleId:文章id;authUserId:供应商用户id;articleTitle:文章标题;articleImage:文章图片;articleContent:文章内容", required = true)
+    @ApiImplicitParam(name = "params", value = "articleId:文章id;articleTitle:文章标题;articleImage:文章图片;articleContent:文章内容", required = true)
     @PostMapping("/save")
-    public ResponseJson saveArticle(@RequestBody String params) {
+    public ResponseJson saveArticle(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer articleId = paramsMap.getInteger("articleId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         String articleTitle = paramsMap.getString("articleTitle");
         String articleImage = paramsMap.getString("articleImage");
         String articleContent = paramsMap.getString("articleContent");
-        return articleService.saveArticle(articleId, authUserId, articleTitle, articleImage, articleContent);
+        Integer sort = paramsMap.getInteger("sort");
+        return articleService.saveArticle(articleId, authUserId, articleTitle, articleImage, articleContent, sort);
     }
 
     @ApiOperation("文章回显数据")
@@ -72,7 +88,7 @@ public class ArticleApi {
     @ApiOperation("更新文章状态")
     @ApiImplicitParam(name = "params", value = "articleId:文章id;status:文章状态:0停用 1启用;", required = true)
     @PostMapping("/update/status")
-    public ResponseJson updateArticleStatus(@RequestBody Map<String,Integer> params) {
+    public ResponseJson updateArticleStatus(@RequestBody Map<String, Integer> params) {
         Integer articleId = params.get("articleId");
         Integer status = params.get("status");
         return articleService.updateArticleStatus(articleId, status);
@@ -81,7 +97,7 @@ public class ArticleApi {
     @ApiOperation("删除文章")
     @ApiImplicitParam(name = "params", value = "articleId:文章id", required = true)
     @PostMapping("/delete")
-    public ResponseJson deleteArticle(@RequestBody Map<String,Integer> params) {
+    public ResponseJson deleteArticle(@RequestBody Map<String, Integer> params) {
         Integer articleId = params.get("articleId");
         return articleService.deleteArticle(articleId);
     }
@@ -97,4 +113,20 @@ public class ArticleApi {
         Integer auditBy = paramsMap.getInteger("auditBy");
         return articleService.auditArticle(articleId, auditStatus, invalidReason, auditBy);
     }
+
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkArticle(@PathVariable("id") Integer articleId) {
+        return articleService.checkArticle(articleId);
+    }
+
+    @ApiOperation("更改排序值")
+    @ApiImplicitParam(name = "params", required = true, value = "articleId:文章id;sort:排序值")
+    @PostMapping("/sort/update")
+    public ResponseJson updateSort(@RequestBody String params) {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        Integer articleId = paramsMap.getInteger("articleId");
+        Integer sort = paramsMap.getInteger("sort");
+        return articleService.updateSort(articleId, sort);
+    }
 }

+ 26 - 5
src/main/java/com/caimei/controller/admin/data/FileApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.data;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.CourseFileListVo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.service.data.FileService;
@@ -35,7 +37,6 @@ public class FileApi {
     @ApiOperation("文件列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1文件列表,2文件审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "fileType", required = false, value = "文件类型:1单个文件,2资料包"),
             @ApiImplicitParam(name = "fileTitle", required = false, value = "文件标题"),
             @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
@@ -44,19 +45,33 @@ public class FileApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<FileListVo>> getFileList(Integer listType, Integer authUserId, Integer fileType, String fileTitle, Integer auditStatus, Integer status,
+    public ResponseJson<PageInfo<FileListVo>> getFileList(@CurrentUser SysUser sysUser, Integer listType, Integer fileType, String fileTitle, Integer auditStatus, Integer status,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return fileService.getFileList(listType, authUserId, fileType, fileTitle, auditStatus, status, pageNum, pageSize);
     }
 
     @ApiOperation("添加/编辑文件")
-    @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;authUserId:供应商用户id;fileType:文件类型:1单个文件,2资料包;fileTitle:文件标题;fileName:文件名称;filePreviewUrl:文件预览链接;fileDownloadUrl:oss名称")
+    @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;fileType:文件类型:1单个文件,2资料包;fileTitle:文件标题;fileName:文件名称;filePreviewUrl:文件预览链接;fileDownloadUrl:oss名称")
     @PostMapping("/save")
-    public ResponseJson saveFile(@RequestBody String params) {
+    public ResponseJson saveFile(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer fileId = paramsMap.getInteger("fileId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         Integer fileType = paramsMap.getInteger("fileType");
         String fileTitle = paramsMap.getString("fileTitle");
         String fileName = paramsMap.getString("fileName");
@@ -140,4 +155,10 @@ public class FileApi {
         Integer fileId = params.get("fileId");
         return fileService.deleteCourseFile(fileId);
     }
+
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkFile(@PathVariable("id") Integer fileId) {
+        return fileService.checkFile(fileId);
+    }
 }

+ 26 - 5
src/main/java/com/caimei/controller/admin/data/ImageApi.java

@@ -2,7 +2,9 @@ package com.caimei.controller.admin.data;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.ImageFormVo;
 import com.caimei.model.vo.ImageListVo;
 import com.caimei.service.data.ImageService;
@@ -36,7 +38,6 @@ public class ImageApi {
     @ApiOperation("图片列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1图片列表,2图片审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "imageTitle", required = false, value = "图片标题"),
             @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
             @ApiImplicitParam(name = "status", required = false, value = "图片状态:0已下线,1已上线,2待上线"),
@@ -44,19 +45,33 @@ public class ImageApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<ImageListVo>> getImageList(Integer listType, Integer authUserId, String imageTitle, Integer auditStatus, Integer status,
+    public ResponseJson<PageInfo<ImageListVo>> getImageList(@CurrentUser SysUser sysUser, Integer listType, String imageTitle, Integer auditStatus, Integer status,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return imageService.getImageList(listType, authUserId, imageTitle, auditStatus, status, pageNum, pageSize);
     }
 
     @ApiOperation("添加/编辑图片")
-    @ApiImplicitParam(name = "params", value = "imageId:图片id;authUserId:供应商用户id;imageTitle:图片标题;imageArr:图片数组", required = true)
+    @ApiImplicitParam(name = "params", value = "imageId:图片id;imageTitle:图片标题;imageArr:图片数组", required = true)
     @PostMapping("/save")
-    public ResponseJson saveImage(@RequestBody String params) throws Exception {
+    public ResponseJson saveImage(@CurrentUser SysUser sysUser, @RequestBody String params) throws Exception {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer imageId = paramsMap.getInteger("imageId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         String imageTitle = paramsMap.getString("imageTitle");
         JSONArray imageArr = paramsMap.getJSONArray("imageArr");
         return imageService.saveImage(imageId, authUserId, imageTitle, imageArr);
@@ -97,4 +112,10 @@ public class ImageApi {
         Integer auditBy = paramsMap.getInteger("auditBy");
         return imageService.auditImage(imageId, auditStatus, invalidReason, auditBy);
     }
+
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkImage(@PathVariable("id") Integer imageId) {
+        return imageService.checkImage(imageId);
+    }
 }

+ 25 - 4
src/main/java/com/caimei/controller/admin/data/VideoApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.data;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.VideoListVo;
 import com.caimei.service.data.VideoService;
 import com.github.pagehelper.PageInfo;
@@ -34,7 +36,6 @@ public class VideoApi {
     @ApiOperation("视频列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1视频列表,2视频审核列表"),
-            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
             @ApiImplicitParam(name = "videoTitle", required = false, value = "视频标题"),
             @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
             @ApiImplicitParam(name = "status", required = false, value = "视频状态:0已下线,1已上线,2待上线"),
@@ -42,19 +43,33 @@ public class VideoApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<VideoListVo>> getVideoList(Integer listType, Integer authUserId, String videoTitle, Integer auditStatus, Integer status,
+    public ResponseJson<PageInfo<VideoListVo>> getVideoList(@CurrentUser SysUser sysUser, Integer listType, String videoTitle, Integer auditStatus, Integer status,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return videoService.getVideoList(listType, authUserId, videoTitle, auditStatus, status, pageNum, pageSize);
     }
 
     @ApiOperation("添加/编辑视频")
     @ApiImplicitParam(name = "params", required = false, value = "videoId:视频id;authUserId:供应商用户id;videoTitle:视频标题;videoName:视频名称;videoPreviewUrl:视频预览链接;videoDownloadUrl:oss名称")
     @PostMapping("/save")
-    public ResponseJson saveVideo(@RequestBody String params) {
+    public ResponseJson saveVideo(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer videoId = paramsMap.getInteger("videoId");
-        Integer authUserId = paramsMap.getInteger("authUserId");
         String videoTitle = paramsMap.getString("videoTitle");
         String videoImage = paramsMap.getString("videoImage");
         String videoName = paramsMap.getString("videoName");
@@ -91,4 +106,10 @@ public class VideoApi {
         Integer auditBy = paramsMap.getInteger("auditBy");
         return videoService.auditVideo(videoId, auditStatus, invalidReason, auditBy);
     }
+
+    @ApiOperation("更改查看标记")
+    @PostMapping("/check/{id}")
+    public ResponseJson checkVideo(@PathVariable("id") Integer videoId) {
+        return videoService.checkVideo(videoId);
+    }
 }

+ 2 - 0
src/main/java/com/caimei/controller/admin/sys/SysMenuApi.java

@@ -1,8 +1,10 @@
 package com.caimei.controller.admin.sys;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.SysMenu;
 import com.caimei.model.po.SysMenuTree;
+import com.caimei.model.po.SysUser;
 import com.caimei.service.sys.SysMenuService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.web.bind.annotation.*;

+ 19 - 3
src/main/java/com/caimei/controller/admin/sys/SysRoleApi.java

@@ -1,7 +1,9 @@
 package com.caimei.controller.admin.sys;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.SysRole;
+import com.caimei.model.po.SysUser;
 import com.caimei.service.sys.SysRoleService;
 import com.github.pagehelper.PageInfo;
 import org.springframework.util.StringUtils;
@@ -28,9 +30,15 @@ public class SysRoleApi {
      * @param pageSize 每页大小
      */
     @GetMapping("/list")
-    public ResponseJson<PageInfo<SysRole>> roleList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+    public ResponseJson<PageInfo<SysRole>> roleList(@CurrentUser SysUser sysUser, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return sysRoleService.getRoleList(pageNum, pageSize);
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        return sysRoleService.getRoleList(authUserId, pageNum, pageSize);
     }
 
     /**
@@ -59,7 +67,15 @@ public class SysRoleApi {
      * 添加角色
      */
     @PostMapping("/create")
-    public ResponseJson<Void> addRole(@RequestBody SysRole sysRole) {
+    public ResponseJson<Void> addRole(@CurrentUser SysUser sysUser, @RequestBody SysRole sysRole) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        sysRole.setAuthUserId(authUserId);
+        sysRole.setRoleType(1 == userIdentity ? 1 : 3);
         return sysRoleService.addRole(sysRole);
     }
 

+ 44 - 7
src/main/java/com/caimei/controller/admin/sys/SysUserApi.java

@@ -1,5 +1,6 @@
 package com.caimei.controller.admin.sys;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.SysUser;
 import com.caimei.service.sys.SysUserService;
@@ -25,9 +26,17 @@ public class SysUserApi {
      * 获取用户信息
      */
     @GetMapping("/info")
-    public ResponseJson<SysUser> getUserInfo(Integer authUserId) {
+    public ResponseJson<SysUser> getUserInfo(@CurrentUser SysUser sysUser) {
 //        String token = request.getHeader(ConstantKey.TOKEN_NAME);
 //        String username = jwtService.getUsername(token);
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取用户信息,直接取id即可
+        Integer authUserId = sysUser.getId();
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return sysUserService.getInfoByUserId(authUserId);
     }
 
@@ -49,10 +58,16 @@ public class SysUserApi {
      * @param pageSize 每页大小
      */
     @GetMapping("/list")
-    public ResponseJson<PageInfo<SysUser>> userList(String username, String linkMan,
+    public ResponseJson<PageInfo<SysUser>> userList(@CurrentUser SysUser sysUser, String username, String linkMan,
                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return sysUserService.getUserList(username, linkMan, pageNum, pageSize);
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        return sysUserService.getUserList(authUserId, username, linkMan, pageNum, pageSize);
     }
 
     /**
@@ -78,11 +93,19 @@ public class SysUserApi {
     }
 
     /**
-     * 添加管理员
+     * 添加管理员/供应商子用户
      */
-    @PostMapping("/admin/create")
-    public ResponseJson<Void> addAdmin(@RequestBody SysUser sysUser) {
-        return sysUserService.addAdmin(sysUser);
+    @PostMapping("/create")
+    public ResponseJson<Void> createUser(@CurrentUser SysUser currentUser, @RequestBody SysUser sysUser) {
+        if (null == currentUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        Integer userIdentity = currentUser.getUserIdentity();
+        sysUser.setUserIdentity(1 == userIdentity ? 1 : 3);
+        sysUser.setLoginAccount(1 == userIdentity ? sysUser.getUsername() : sysUser.getLoginAccount());
+        sysUser.setParentId(1 == userIdentity ? 1 : 2 == userIdentity ? currentUser.getId() : currentUser.getParentId());
+        sysUser.setCreateBy(currentUser.getId());
+        return sysUserService.createUser(sysUser);
     }
 
     /**
@@ -95,6 +118,20 @@ public class SysUserApi {
         }
         return sysUserService.deleteUser(id);
     }
+
+    /**
+     * 根据ID更新用户状态
+     */
+    @PostMapping("/status/update/{id}")
+    public ResponseJson<Void> updateUserStatus(@PathVariable("id") Integer id, @RequestBody SysUser sysUser) {
+        if (null == id || id <= 0) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        if (null == sysUser || null == sysUser.getStatus()) {
+            return ResponseJson.error("用户状态不能为空!", null);
+        }
+        return sysUserService.updateUserStatus(id, sysUser.getStatus());
+    }
 /*
     *//**
      * 用户修改资料

+ 32 - 6
src/main/java/com/caimei/controller/admin/vip/VipApi.java

@@ -1,8 +1,10 @@
 package com.caimei.controller.admin.vip;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.SysMenu;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.*;
 import com.caimei.service.vip.VipService;
 import com.github.pagehelper.PageInfo;
@@ -57,14 +59,19 @@ public class VipApi {
 
     @ApiOperation("在线支付开通会员")
     @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "authUserId", value = "用户id"),
             @ApiImplicitParam(required = false, name = "packageId", value = "会员套餐id"),
             @ApiImplicitParam(required = false, name = "services", value = "订制服务id,以,分开")
     })
     @GetMapping("/pay")
-    public ResponseJson<Integer> payVip(Integer authUserId, Integer packageId, String services) {
+    public ResponseJson<Integer> payVip(@CurrentUser SysUser sysUser, Integer packageId, String services) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
         if (null == authUserId) {
-            return ResponseJson.error("参数异常,用户id不能为空", null);
+            return ResponseJson.error("供应商用户id不能为空", null);
         }
         if (null == packageId) {
             return ResponseJson.error("参数异常,套餐id不能为空", null);
@@ -102,17 +109,36 @@ public class VipApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/history/list")
-    public ResponseJson<PageInfo<VipHistoryListVo>> vipHistoryList(Integer authUserId, Integer vipPackageId, Integer vipStatus, String payBeginTime,
+    public ResponseJson<PageInfo<VipHistoryListVo>> vipHistoryList(@CurrentUser SysUser sysUser, Integer authUserId, Integer vipPackageId, Integer vipStatus, String payBeginTime,
                                                                    String payEndTime, String endBeginTime, String endEndTime,
                                                                    @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                    @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return vipService.vipHistoryList(authUserId, vipPackageId, vipStatus, payBeginTime, payEndTime, endBeginTime, endEndTime, pageNum, pageSize);
     }
 
     @ApiOperation("会员数据")
-    @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id")
     @GetMapping("/info")
-    public ResponseJson<VipInfoVo> vipInfo(Integer authUserId) {
+    public ResponseJson<VipInfoVo> vipInfo(@CurrentUser SysUser sysUser) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
         return vipService.getVipInfo(authUserId);
     }
 

+ 21 - 0
src/main/java/com/caimei/controller/wechat/RegisterApi.java

@@ -1,11 +1,15 @@
 package com.caimei.controller.wechat;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.Idempotent;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.WxClubUserVo;
+import com.caimei.service.auth.AuthProductService;
 import com.caimei.service.wechat.RegisterService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
@@ -27,6 +31,8 @@ public class RegisterApi {
 
     private final RegisterService registerService;
 
+    private final AuthProductService authProductService;
+
     @ApiOperation("普通注册")
     @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;password:密码;authUserId:供应商用户id;", required = true)
     @PostMapping("/simple")
@@ -65,6 +71,7 @@ public class RegisterApi {
             "clubUserInfo:机构用户数据;" +
             "authInfo:机构数据;" +
             "productInfo:设备数据", required = true)
+    @Idempotent(prefix = "idempotent_club_user", keys = {"#params"}, expire = 5)
     @PostMapping("/all")
     public ResponseJson allRegister(@RequestBody String params) {
         JSONObject parseObject = JSONObject.parseObject(params);
@@ -91,4 +98,18 @@ public class RegisterApi {
         }
         return registerService.allRegister(authUserId, clubUserId, authId, registerType, clubUserInfo, authInfo, productInfo);
     }
+
+
+    @ApiOperation("关联设备获取设备信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "productId", required = false, value = "设备id"),
+            @ApiImplicitParam(name = "snCode", required = false, value = "sn码")
+    })
+    @GetMapping("/product/info")
+    public ResponseJson<ProductFormVo> getProductDetails(Integer productId, String snCode) {
+        if (null == productId && null == snCode) {
+            return ResponseJson.error("设备id和sn码不能同时为空", null);
+        }
+        return authProductService.getProductInfo(productId, snCode);
+    }
 }

+ 37 - 26
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -58,7 +58,7 @@ public class WxAuthApi {
             @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
             @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
             @ApiImplicitParam(name = "lngAndLat", required = false, value = "用户当前经纬度"),
-            @ApiImplicitParam(name = "clubName", required = false, value = "机构名称"),
+            @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
             @ApiImplicitParam(name = "provinceId", required = false, value = "省id"),
             @ApiImplicitParam(name = "cityId", required = false, value = "市id"),
             @ApiImplicitParam(name = "townId", required = false, value = "区id"),
@@ -67,14 +67,24 @@ public class WxAuthApi {
     })
     @IpSave(saveName = "已认证机构列表",saveParams = true)
     @GetMapping("/club/list")
-    public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String clubName, Integer provinceId,
+    public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
                                                               Integer cityId, Integer townId,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         if (null == authUserId && StringUtils.isEmpty(appId)) {
             return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
         }
-        return authClubService.getWxClubList(authUserId, appId, lngAndLat, clubName, provinceId, cityId, townId, pageNum, pageSize);
+        return authClubService.getWxClubList(authUserId, appId, lngAndLat, authParty, provinceId, cityId, townId, pageNum, pageSize);
+    }
+
+    @ApiOperation("明星机构列表")
+    @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id")
+    @GetMapping("/club/star/list")
+    public ResponseJson<List<WxClubListVo>> getStarClubList(Integer authUserId) {
+        if (null == authUserId) {
+            return ResponseJson.error("参数异常,供应商用户id不能为空", null);
+        }
+        return authClubService.getWxStarClubList(authUserId);
     }
 
     @ApiOperation("已认证机构详情")
@@ -105,11 +115,11 @@ public class WxAuthApi {
 
     @ApiOperation("认证商品列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1供应商设备分类上线设备列表 2设备认证列表"),
+            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1已上线设备列表 2设备认证记录列表"),
             @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
             @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
             @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"),
-            @ApiImplicitParam(name = "snCode", required = false, value = "sn码后四位"),
+            @ApiImplicitParam(name = "snCode", required = false, value = "sn码"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
@@ -126,26 +136,22 @@ public class WxAuthApi {
      * 获取授权商品回显数据
      */
     @ApiOperation("授权商品回显数据")
-    @ApiImplicitParam(name = "productId", required = true, value = "授权商品id")
+    @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id")
     @GetMapping("/product/form/data")
-    public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
-        return authProductService.getProductFormData(productId);
+    public ResponseJson<ProductFormVo> getProductFormData(Integer relationId) {
+        return authProductService.getProductFormData(relationId);
     }
 
     /**
      * 品牌列表
      *
-     * @param type 1品牌方可用品牌列表,2代理商可用品牌列表,3供应商可用品牌列表
      * @return AuthVo
      */
     @ApiOperation("品牌列表")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "type", value = "1品牌方品牌列表,2代理商品牌列表,3供应商可用品牌列表", required = true),
-            @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
-    })
-    @GetMapping("/brand/list")
-    public ResponseJson<List<BrandVo>> getBrandList(Integer type, Integer authUserId) {
-        return shopService.getBrandList(type, authUserId);
+    @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
+    @GetMapping("/shop/info/list")
+    public ResponseJson<List<ShopInfoVo>> getShopInfoList(Integer authUserId) {
+        return shopService.getShopInfoList(authUserId);
     }
 
     /**
@@ -153,13 +159,10 @@ public class WxAuthApi {
      * @param productSaveDto {
      *                   productId              授权商品id
      *                   authId                 授权id
-     *                   brandId                品牌id
+     *                   infoId                 品牌信息id
      *                   productTypeId          设备分类id
      *                   snCode                 商品SN码
      *                   productImage           商品图片
-     *                   certificateImage       授权牌照
-     *                   addQrCodeFlag          是否生成二维码授权牌:0否,1是
-     *                   addTemplateType        生成二维码授权牌模板:1左下,2右边,3左边
      *                   purchaseWay            购买渠道
      *                   invoiceImage           发票图片
      *                   status                 上线状态:0已下线,1已上线,2待上线
@@ -171,7 +174,7 @@ public class WxAuthApi {
     @ApiOperation("添加/编辑授权商品")
     @PostMapping("/product/save")
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
-        return authProductService.saveProduct(productSaveDto, false);
+        return authProductService.saveProduct(productSaveDto);
     }
 
     /**
@@ -214,11 +217,6 @@ public class WxAuthApi {
         List<String> bannerList = (List<String>) paramsMap.get("bannerList");
         String authParty = paramsMap.getString("authParty");
         Integer createBy = paramsMap.getInteger("createBy");
-        Integer source = paramsMap.getInteger("source");
-        if (null == source) {
-            // 默认供应商保存
-            source = 1;
-        }
         /*
             组装授权数据
          */
@@ -267,6 +265,19 @@ public class WxAuthApi {
         return authProductService.getAuthProductDetails(productId);
     }
 
+    @ApiOperation("关联设备获取设备信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "productId", required = false, value = "设备id"),
+            @ApiImplicitParam(name = "snCode", required = false, value = "sn码")
+    })
+    @GetMapping("/product/info")
+    public ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode) {
+        if (null == productId && null == snCode) {
+            return ResponseJson.error("设备id和sn码不能同时为空", null);
+        }
+        return authProductService.getProductInfo(productId, snCode);
+    }
+
     @ApiOperation("已认证医师列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),

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

@@ -34,4 +34,8 @@ public interface ArticleMapper {
     ArticleFormVo getArticleForm(Integer articleId);
 
     List<WxArticleListVo> getWxArticleList(@Param("authUserId") Integer authUserId, @Param("articleTitle") String articleTitle);
+
+    void checkArticle(Integer articleId);
+
+    void updateSort(Integer articleId, Integer sort);
 }

+ 8 - 2
src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java

@@ -21,7 +21,7 @@ import java.util.List;
 @Mapper
 public interface AuthMapper {
 
-    List<AuthVo> getAuthList(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus);
+    List<AuthVo> getAuthList(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus);
 
     void updateAuthStatusByAuthId(@Param("authId") Integer authId, @Param("status") Integer status);
 
@@ -41,7 +41,7 @@ public interface AuthMapper {
 
     Integer getAuthIdByAuthParty(@Param("authParty") String authParty, @Param("authUserId") Integer authUserId);
 
-    List<CmBrandAuthPo> getAuthPartyList(Integer authUserId);
+    List<AuthFormVo> getAuthPartyList(@Param("authIds") String authIds);
 
     void deleteBanner(Integer authId);
 
@@ -106,4 +106,10 @@ public interface AuthMapper {
     void updateAuthImage(CmBrandAuthPo auth);
 
     List<CmBrandAuthPo> getAllAuth(Integer authUserId);
+
+    void checkAuth(Integer authId);
+
+    void starAuth(@Param("authId") Integer authId, @Param("starFlag") Integer starFlag);
+
+    void addScanCount(Integer authId);
 }

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

@@ -35,14 +35,12 @@ public interface AuthProductMapper {
 
     Integer getProductIdBySnCode(String snCode);
 
-    ProductFormVo getProductFormByProductId(Integer productId);
+    ProductFormVo getProductFormData(@Param("relationId") Integer relationId);
 
     List<ProductParamPo> getParamsByProductId(Integer productId);
 
     List<Integer> getProductIdsByAuthId(Integer authId);
 
-    ProductPo getImageByProductId(Integer productId);
-
     List<ProductPo> getAllImage();
 
     void updateImageByProductId(ProductPo product);
@@ -51,16 +49,12 @@ public interface AuthProductMapper {
 
     List<WxProductListVo> getWxProductList(@Param("listType") Integer listType, @Param("authId") Integer authId, @Param("authParty") String authParty, @Param("productTypeId") Integer productTypeId, @Param("snCode") String snCode);
 
-    Integer getBrandIdByBrandName(String brand);
-
     List<ProductFormVo> getAuthProductList(Integer authId);
 
     void updateCertificateImage(ProductPo product);
 
     AuthProductVo getAuthProductByProductId(Integer productId);
 
-    StatementFileVo getStatementFile(Integer authUserId, Integer brandId);
-
     List<ProductParamPo> getAuthProductParams(Integer productId);
 
     List<WxProductListVo> getClubProductList(Integer authId);
@@ -94,4 +88,24 @@ public interface AuthProductMapper {
     void insertProductTypeParam(@Param("productTypeId") Integer productTypeId, @Param("paramName") String paramName, @Param("paramContent") String paramContent);
 
     List<ProductParamPo> getProductTypeParamList(Integer productTypeId);
+
+    void checkAuthProduct(Integer productId);
+
+    Integer insertProductRelation(@Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
+
+    ProductRelationVo getProductRelation(@Param("relationId") Integer relationId, @Param("productId") Integer productId, @Param("authId") Integer authId);
+
+    void updateProductRelation(@Param("relationId") Integer relationId, @Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
+
+    Integer getProductRelationCount(Integer productId);
+
+    ProductFormVo getProductInfo(@Param("productId") Integer productId, @Param("snCode") String snCode);
+
+    List<String> getSnCodeList(Integer authUserId, Integer authId);
+
+    List<WxClubListVo> getProductClubList(Integer productId);
+
+    void addScanCount(Integer productId);
+
+    void checkProductType(Integer productTypeId);
 }

+ 4 - 2
src/main/java/com/caimei/mapper/cmMapper/ClubMapper.java

@@ -15,13 +15,13 @@ import java.util.List;
  */
 @Mapper
 public interface ClubMapper {
-    List<ClubVo> getClubList(@Param("authUserId") Integer authUserId, @Param("clubName") String clubName);
+    List<ClubVo> getClubList(@Param("authUserId") Integer authUserId, @Param("authParty") String authParty);
 
     List<ClubUserVo> getClubUserList(@Param("authUserId") Integer authUserId, @Param("mobile") String mobile, String name, @Param("status") Integer status);
 
     void insertClubUser(ClubUserPo clubUser);
 
-    List<WxClubListVo> getWxClubList(@Param("authUserId") Integer authUserId, @Param("clubName") String clubName, @Param("provinceId") Integer provinceId, @Param("cityId") Integer cityId, @Param("townId") Integer townId, @Param("lng") Double lng, @Param("lat") Double lat);
+    List<WxClubListVo> getWxClubList(@Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("provinceId") Integer provinceId, @Param("cityId") Integer cityId, @Param("townId") Integer townId, @Param("lng") Double lng, @Param("lat") Double lat);
 
     Integer checkMobile(@Param("mobile") String mobile, @Param("appId") String appId);
 
@@ -46,4 +46,6 @@ public interface ClubMapper {
     void unbindAuthId(Integer clubUserId);
 
     String getDbPassword(Integer clubUserId);
+
+    List<WxClubListVo> getWxStarClubList(Integer authUserId);
 }

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

@@ -60,4 +60,6 @@ public interface DoctorMapper {
     List<String> getTagList(Integer doctorId);
 
     List<ParamVo> getParamList(Integer doctorId);
+
+    void checkDoctor(Integer doctorId);
 }

+ 6 - 1
src/main/java/com/caimei/mapper/cmMapper/FileMapper.java

@@ -45,8 +45,13 @@ public interface FileMapper {
 
     void deleteCourseFileByFileId(Integer fileId);
 
-    List<ProductImagePo> getProductImageList(Integer authUserId);
+    List<ProductImagePo> getProductImageList(@Param("authId") Integer authId);
 
+    List<AuthVo> getAuthImageList(@Param("authIds") String authIds);
+
+    FilePo getFileForm(Integer fileId);
+
+    void checkFile(Integer fileId);
     List<AuthVo> getAuthImageList(Integer authUserId);
 
     FileTreeVo findFileById(Integer fileId);

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

@@ -40,4 +40,6 @@ public interface ImageMapper {
     List<String> getImageListByImageId(Integer imageId);
 
     List<WxImageListVo> getWxImageList(Integer authUserId, String imageTitle);
+
+    void checkImage(Integer imageId);
 }

+ 13 - 16
src/main/java/com/caimei/mapper/cmMapper/ShopMapper.java

@@ -1,7 +1,6 @@
 package com.caimei.mapper.cmMapper;
 
 import com.caimei.model.dto.ShopInfoDto;
-import com.caimei.model.po.CmBrandAuthFilePo;
 import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -18,39 +17,29 @@ import java.util.List;
 @Mapper
 public interface ShopMapper {
 
-    List<ShopListVo> getShopList(@Param("listType") Integer listType, @Param("shopName") String shopName, @Param("loginAccount") String loginAccount, @Param("shopType") Integer shopType, @Param("brandId") Integer brandId, @Param("mobile") String mobile, @Param("linkMan") String linkMan, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("sendStatus") Integer sendStatus);
+    List<ShopListVo> getShopList(@Param("listType") Integer listType, @Param("shopName") String shopName, @Param("loginAccount") String loginAccount, @Param("shopType") Integer shopType, @Param("infoId") Integer infoId, @Param("mobile") String mobile, @Param("linkMan") String linkMan, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("sendStatus") Integer sendStatus);
 
     void updateShopStatusByUserId(@Param("authUserId") Integer authUserId, @Param("status") Integer status);
 
     String getShopMobileByUserId(Integer authUserId);
 
-    CmBrandAuthFilePo getStatementFile(CmBrandAuthFilePo searchFile);
-
-    void insertStatementFile(CmBrandAuthFilePo cmBrandAuthFile);
-
     Integer getFileNumByMd5Hex(String md5Hex);
 
-    void deleteStatementFile(Integer id);
-
     void insertShop(UserPo shop);
 
-    void updateBrandAuthLogo(@Param("brandId") Integer brandId, @Param("brandAuthLogo") String brandAuthLogo);
-
-    void updateFileUserId(@Param("statementFileId") Integer statementFileId,@Param("authUserId") Integer authUserId);
-
     void insertShopInfo(ShopInfoDto shopInfo);
 
     void updateShopByUserId(UserPo shop);
 
     ShopFormVo getShopByUserId(Integer authUserId);
 
-    List<BrandVo> getBrandList(@Param("type") Integer type,@Param("authUserId") Integer authUserId);
+    List<ShopInfoVo> getShopInfoList(@Param("authUserId") Integer authUserId);
 
     List<CountryVo> getCountryList();
 
     Integer getUserIdByMobile(String mobile);
 
-    List<ShopBrandVo> getDbInfoBrandList(Integer authUserId);
+    List<ShopInfoVo> getDbInfoList(Integer authUserId);
 
     void deleteShopInfoById(Integer infoId);
 
@@ -64,9 +53,9 @@ public interface ShopMapper {
 
     Integer getProductWaitAuditNum(Integer authUserId);
 
-    Integer getProductCount(@Param("authUserId") Integer authUserId, @Param("brandId") Integer brandId);
+    Integer getProductCount(@Param("authUserId") Integer authUserId, @Param("infoId") Integer infoId);
 
-    List<FeedbackVo> getFeedbackList(@Param("authUserId") Integer authUserId, @Param("clubName") String clubName, @Param("mobile") String mobile, @Param("handleStatus") Integer handleStatus);
+    List<FeedbackVo> getFeedbackList(@Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("handleStatus") Integer handleStatus);
 
     FeedbackVo getFeedback(Integer feedbackId);
 
@@ -93,4 +82,12 @@ public interface ShopMapper {
     String getLoginAccount(Integer authUserId);
 
     void bindLoginAccount(@Param("authUserId") Integer authUserId, @Param("loginAccount") String loginAccount);
+
+    void updateShopLinkMan(@Param("authUserId") Integer authUserId, @Param("linkMan") String linkMan);
+
+    void updateShopLogo(@Param("authUserId") Integer authUserId, @Param("logo") String logo);
+
+    List<CmShopVo> getCmShopList();
+
+    Integer getUserIdByPrefix(String prefix);
 }

+ 26 - 5
src/main/java/com/caimei/mapper/cmMapper/SystemMapper.java

@@ -18,7 +18,7 @@ public interface SystemMapper {
     /**
      * 根据用户名称查找可登录用户
      */
-    SysUser findByUsername(String username);
+    SysUser findByUsername(@Param("username") String username);
     /**
      * 根据用户Id查找可登录用户
      */
@@ -56,7 +56,7 @@ public interface SystemMapper {
     /**
      * 获取用户列表
      */
-    List<SysUser> getUserList(String username, String linkMan);
+    List<SysUser> getUserList(Integer authUserId, String username, String linkMan);
     /**
      * 根据ID获取用户
      */
@@ -76,8 +76,9 @@ public interface SystemMapper {
     List<SysRole> getRoleListByUserId(Integer userId);
     /**
      * 获取角色列表
+     * @param authUserId
      */
-    List<SysRole> getRoleList();
+    List<SysRole> getRoleList(Integer authUserId);
     /**
      * 根据ID获取角色
      */
@@ -85,7 +86,7 @@ public interface SystemMapper {
     /**
      * 根据角色名称获取角色
      */
-    SysRole getRoleByRoleName(String roleName);
+    SysRole getRoleByRoleName(@Param("authUserId") Integer authUserId, @Param("roleName") String roleName);
     /**
      * 根据ID更新角色
      */
@@ -182,7 +183,7 @@ public interface SystemMapper {
      */
     void insertPermission(SysPermission permission);
 
-    void insertAdminUser(SysUser sysUser);
+    void insertUser(SysUser sysUser);
 
     /**
      * 根据菜单id查询会员菜单角色id
@@ -208,4 +209,24 @@ public interface SystemMapper {
     void deleteMenuRoleRelation(Integer menuId);
 
     List<Integer> getMenuIdList(String parentId, int menuType);
+
+    void updateUserStatus(@Param("id") Integer id, @Param("status") Integer status);
+
+    List<SysRole> getShopRoleList(Integer authUserId);
+
+    /**
+     * 获取基础菜单列表
+     * @param roleId
+     * @return
+     */
+    List<SysMenu> getBaseMenuList(Integer roleId);
+
+    /**
+     * 获取供应商菜单对应的角色id
+     */
+    Integer getShopRoleIdByMenuId(Integer menuId);
+
+    SysUser findByMobile(String mobile);
+
+    SysUser findByLoginAccount(String loginAccount);
 }

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

@@ -33,4 +33,8 @@ public interface VideoMapper {
     void updateVideoSelective(VideoPo video);
 
     List<WxVideoListVo> getWxVideoList(@Param("authUserId") Integer authUserId, @Param("videoTitle") String videoTitle);
+
+    VideoPo getVideoForm(Integer videoId);
+
+    void checkVideo(Integer videoId);
 }

+ 14 - 9
src/main/java/com/caimei/model/dto/ProductSaveDto.java

@@ -27,9 +27,19 @@ public class ProductSaveDto {
     private Integer authId;
 
     /**
-     * 品牌id
+     * 机构设备关联id
      */
-    private Integer brandId;
+    private Integer relationId;
+
+    /**
+     * 认证方式:1新设备认证,2关联已认证设备
+     */
+    private Integer authType;
+
+    /**
+     * 品牌信息id
+     */
+    private Integer infoId;
 
     /**
      * 设备分类id
@@ -57,14 +67,9 @@ public class ProductSaveDto {
     private String certificateImage;
 
     /**
-     * 是否生成二维码授权牌:0否,1是
-     */
-    private Integer addQrCodeFlag;
-
-    /**
-     * 生成二维码授权牌模板:1左下,2右边,3左边
+     * 授权牌照类型:1模板库生成,2自定义上传
      */
-    private Integer addTemplateType;
+    private Integer certificateImageType;
 
     /**
      * 购买渠道

+ 7 - 42
src/main/java/com/caimei/model/dto/ShopInfoDto.java

@@ -8,7 +8,7 @@ import lombok.Data;
  */
 @Data
 public class ShopInfoDto {
-    private Integer id;
+    private Integer infoId;
 
     /**
      * 用户Id
@@ -16,57 +16,22 @@ public class ShopInfoDto {
     private Integer authUserId;
 
     /**
-     * 所属品牌Id
+     * 品牌名称
      */
-    private Integer brandId;
+    private String brandName;
 
     /**
-     * 品牌授权logo
+     * 品牌logo
      */
-    private String brandAuthLogo;
+    private String brandLogo;
 
     /**
-     * 产地国家id
+     * 产地
      */
-    private Integer countryId;
-
-    /**
-     * 官网认证链接
-     */
-    private String securityLink;
+    private String producePlace;
 
     /**
      * 制造商
      */
     private String manufacturer;
-
-    /**
-     * 公众号二维码图片
-     */
-    private String qrCodeImage;
-
-    /**
-     * 代理声明类型:1弹窗,2链接,3图片,4文件
-     */
-    private Integer statementType;
-
-    /**
-     * 声明弹窗内容
-     */
-    private String statementContent;
-
-    /**
-     * 声明链接
-     */
-    private String statementLink;
-
-    /**
-     * 声明图片
-     */
-    private String statementImage;
-
-    /**
-     * 声明文件id
-     */
-    private Integer statementFileId;
 }

+ 0 - 122
src/main/java/com/caimei/model/dto/ShopSaveDto.java

@@ -1,122 +0,0 @@
-package com.caimei.model.dto;
-
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * Description
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
-@Data
-public class ShopSaveDto {
-    /**
-     * 供应商id
-     */
-    @ApiModelProperty("供应商id")
-    private Integer authUserId;
-
-    /**
-     * 供应商类型:1代理商,2品牌方
-     */
-    @NotNull(message = "供应商类型不能为空")
-    @ApiModelProperty("供应商类型:1代理商,2品牌方")
-    private Integer shopType;
-
-    /**
-     * 品牌id
-     */
-    @NotNull(message = "品牌id不能为空")
-    @ApiModelProperty("品牌id")
-    private Integer brandId;
-
-    /**
-     * 供应商名称
-     */
-    @NotNull(message = "供应商名称不能为空")
-    @ApiModelProperty("供应商名称")
-    private String shopName;
-
-    /**
-     * 手机号
-     */
-    @NotNull(message = "手机号不能为空")
-    @ApiModelProperty("手机号")
-    private String mobile;
-
-    /**
-     * 联系人
-     */
-    @NotNull(message = "联系人不能为空")
-    @ApiModelProperty("联系人")
-    private String linkMan;
-
-    /**
-     * 产地国家id
-     */
-    @NotNull(message = "产地不能为空")
-    @ApiModelProperty("产地国家id")
-    private Integer countryId;
-
-    /**
-     * 品牌授权logo
-     */
-    @NotNull(message = "品牌logo不能为空")
-    @ApiModelProperty("品牌授权logo")
-    private String brandAuthLogo;
-
-    /**
-     * 供应商状态:0停用 1启用
-     */
-    @NotNull(message = "供应商状态不能为空")
-    @ApiModelProperty("供应商状态:0停用 1启用")
-    private Integer shopStatus;
-
-    /**
-     * 官网认证链接
-     */
-    @ApiModelProperty("官网认证链接")
-    private String securityLink;
-
-    /**
-     * 代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
-     */
-    @ApiModelProperty("代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)")
-    private Integer statementType;
-
-    /**
-     * 声明弹窗内容
-     */
-    @ApiModelProperty("声明弹窗内容")
-    private String statementContent;
-
-    /**
-     * 声明链接
-     */
-    @ApiModelProperty("声明链接")
-    private String statementLink;
-
-    /**
-     * 声明图片
-     */
-    @ApiModelProperty("声明图片")
-    private String statementImage;
-
-    /**
-     * 声明文件id
-     */
-    @ApiModelProperty("声明文件id")
-    private Integer statementFileId;
-
-    /**
-     * 创建人用户id
-     */
-    @ApiModelProperty("创建人用户id")
-    private Integer createBy;
-}

+ 10 - 0
src/main/java/com/caimei/model/po/ArticlePo.java

@@ -64,4 +64,14 @@ public class ArticlePo {
      * 审核时间
      */
     private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
+
+    /**
+     * 排序值
+     */
+    private Integer sort;
 }

+ 0 - 45
src/main/java/com/caimei/model/po/CmBrandAuthFilePo.java

@@ -1,45 +0,0 @@
-package com.caimei.model.po;
-
-import lombok.Data;
-
-import java.util.Date;
-
-/**
- * Description
- *
- * @author : Aslee
- * @date : 2021/05/13
- */
-@Data
-public class CmBrandAuthFilePo {
-    private Integer id;
-    /**
-     * 供应商用户id
-     */
-    private Integer authUserId;
-
-    /**
-     * 品牌id
-     */
-    private Integer brandId;
-
-    /**
-     * 声明文件名称
-     */
-    private String name;
-
-    /**
-     * oss存储名
-     */
-    private String ossName;
-
-    /**
-     * 文件唯一标识
-     */
-    private String md5Hex;
-
-    /**
-     * 上传时间
-     */
-    private Date uploadTime;
-}

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

@@ -72,6 +72,16 @@ public class CmBrandAuthPo {
      */
     private String userMobile;
 
+    /**
+     * 运营联系人
+     */
+    private String linkMan;
+
+    /**
+     * 运营联系人手机号
+     */
+    private String linkMobile;
+
     /**
      * 一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5
      */
@@ -202,4 +212,9 @@ public class CmBrandAuthPo {
      */
     private Integer authImageType;
 
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
+
 }

+ 16 - 0
src/main/java/com/caimei/model/po/CmBrandDoctorPo.java

@@ -3,6 +3,7 @@ package com.caimei.model.po;
 import com.caimei.model.vo.ProductFormVo;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -63,4 +64,19 @@ public class CmBrandDoctorPo {
      */
     private Integer createBy;
 
+    /**
+     * 管理员审核人id,对应cm_brand_auth_user
+     */
+    private Integer auditBy;
+
+    /**
+     * 审核时间
+     */
+    private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
+
 }

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

@@ -74,4 +74,9 @@ public class FilePo {
      * 审核时间
      */
     private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
 }

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

@@ -59,4 +59,9 @@ public class ImagePo {
      * 审核时间
      */
     private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
 }

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

@@ -29,4 +29,9 @@ public class ProductImagePo {
      * sn码
      */
     private String snCode;
+
+    /**
+     * 设备名称
+     */
+    private String productName;
 }

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

@@ -13,11 +13,9 @@ public class ProductParamPo {
     /**
      * 商品参数名称
      */
-    @ApiModelProperty("商品参数名称")
     private String paramName;
     /**
      * 商品参数内容
      */
-    @ApiModelProperty("商品参数内容")
     private String paramContent;
 }

+ 11 - 16
src/main/java/com/caimei/model/po/ProductPo.java

@@ -25,9 +25,9 @@ public class ProductPo {
     private Integer authId;
 
     /**
-     * 品牌Id
+     * 品牌信息Id
      */
-    private Integer brandId;
+    private Integer infoId;
 
     /**
      * 设备分类id
@@ -60,14 +60,14 @@ public class ProductPo {
     private String appletsImage;
 
     /**
-     * 授权牌照
+     * 授权牌照
      */
-    private String originalCertificateImage;
+    private String certificateImage;
 
     /**
-     * 授权牌照
+     * 授权牌照类型:1模板库生成,2自定义上传
      */
-    private String certificateImage;
+    private Integer certificateImageType;
 
     /**
      * pc添加水印授权牌照
@@ -79,16 +79,6 @@ public class ProductPo {
      */
     private String appletsCertificateImage;
 
-    /**
-     * 是否生成二维码授权牌:0否,1是
-     */
-    private Integer addQrCodeFlag;
-
-    /**
-     * 生成二维码授权牌模板:1左下,2右边,3左边
-     */
-    private Integer addTemplateType;
-
     /**
      * 购买渠道
      */
@@ -138,4 +128,9 @@ public class ProductPo {
      * 审核时间
      */
     private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
 }

+ 7 - 2
src/main/java/com/caimei/model/po/ProductTypePo.java

@@ -24,9 +24,9 @@ public class ProductTypePo {
     private Integer authUserId;
 
     /**
-     * 品牌id
+     * 品牌信息id
      */
-    private Integer brandId;
+    private Integer infoId;
 
     /**
      * 品牌名称
@@ -92,4 +92,9 @@ public class ProductTypePo {
      * 参数列表
      */
     private List<ProductParamPo> paramList;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
 }

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

@@ -1,54 +0,0 @@
-package com.caimei.model.po;
-
-import java.io.Serializable;
-import lombok.Data;
-
-/**
- * cm_brand_auth_shop_info
- * @author 
- */
-@Data
-public class ShopInfoPo{
-    private Integer id;
-
-    /**
-     * 用户Id
-     */
-    private Integer authUserId;
-
-    /**
-     * 所属品牌Id
-     */
-    private Integer brandId;
-
-    /**
-     * 产地国家id
-     */
-    private Integer countryId;
-
-    /**
-     * 官网认证链接
-     */
-    private String securityLink;
-
-    /**
-     * 代理声明类型:1弹窗,2链接,3图片,4文件
-     */
-    private Integer statementType;
-
-    /**
-     * 声明弹窗内容
-     */
-    private String statementContent;
-
-    /**
-     * 声明链接
-     */
-    private String statementLink;
-
-    /**
-     * 声明图片
-     */
-    private String statementImage;
-
-}

+ 4 - 0
src/main/java/com/caimei/model/po/SysRole.java

@@ -17,6 +17,10 @@ public class SysRole {
      * 角色ID
      */
     private Integer id;
+    /**
+     * 供应商用户id
+     */
+    private Integer authUserId;
     /**
      * 角色名称
      */

+ 12 - 0
src/main/java/com/caimei/model/po/SysUser.java

@@ -18,10 +18,22 @@ public class SysUser {
      * 用户Id
      */
     private Integer id;
+    /**
+     * 子用户对应的供应商用户id
+     */
+    private Integer parentId;
+    /**
+     * 用户身份:1管理员,2供应商,3供应商子用户
+     */
+    private Integer userIdentity;
     /**
      * 用户名
      */
     private String username;
+    /**
+     * 登录账号
+     */
+    private String loginAccount;
     /**
      * 手机号
      */

+ 10 - 0
src/main/java/com/caimei/model/po/UserPo.java

@@ -15,11 +15,21 @@ public class UserPo {
      */
     private Integer authUserId;
 
+    /**
+     * 关联采美供应商id
+     */
+    private Integer cmShopId;
+
     /**
      * 账号名
      */
     private String name;
 
+    /**
+     * 前缀
+     */
+    private String prefix;
+
     /**
      * 手机号
      */

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

@@ -74,4 +74,9 @@ public class VideoPo {
      * 审核时间
      */
     private Date auditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
 }

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

@@ -26,4 +26,10 @@ public class ArticleFormVo {
 
     @ApiModelProperty("创建时间")
     private Date createTime;
+
+    @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
+    private Integer auditStatus;
+
+    @ApiModelProperty("排序值")
+    private Integer sort;
 }

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

@@ -39,4 +39,10 @@ public class ArticleListVo {
 
     @ApiModelProperty("审核时间")
     private Date auditTime;
+
+    @ApiModelProperty("排序值")
+    private Integer sort;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

+ 10 - 0
src/main/java/com/caimei/model/vo/AuthFormVo.java

@@ -76,6 +76,16 @@ public class AuthFormVo implements Serializable {
      */
     private String userMobile;
 
+    /**
+     * 运营联系人
+     */
+    private String linkMan;
+
+    /**
+     * 运营联系人手机号
+     */
+    private String linkMobile;
+
     /**
      * 一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5
      */

+ 10 - 41
src/main/java/com/caimei/model/vo/AuthProductVo.java

@@ -31,17 +31,13 @@ public class AuthProductVo {
      */
     private String certificateImage;
     /**
-     * 品牌授权Id
+     * 品牌信息logo
      */
-    private Integer authId;
+    private String brandLogo;
     /**
-     * 品牌授权logo
+     * 品牌信息Id
      */
-    private String authLogo;
-    /**
-     * 品牌Id
-     */
-    private Integer brandId;
+    private Integer infoId;
     /**
      * 品牌名称
      */
@@ -49,11 +45,7 @@ public class AuthProductVo {
     /**
      * 产地
      */
-    private String productionPlace;
-    /**
-     * 防伪链接
-     */
-    private String securityLink;
+    private String producePlace;
     /**
      * 制造商
      */
@@ -70,34 +62,6 @@ public class AuthProductVo {
      * 供应商用户id
      */
     private Integer authUserId;
-    /**
-     * 声明类型:1弹窗声明,2链接声明
-     */
-    private Integer statementType;
-    /**
-     * 声明弹窗内容
-     */
-    private String statementContent;
-    /**
-     * 声明链接
-     */
-    private String statementLink;
-    /**
-     * 声明图片
-     */
-    private String statementImage;
-    /**
-     * 声明文件
-     */
-    private StatementFileVo statementFile;
-    /**
-     * 被授权方
-     */
-    private String authParty;
-    /**
-     * 机构logo
-     */
-    private String clubLogo;
     /**
      * 商品参数
      */
@@ -118,4 +82,9 @@ public class AuthProductVo {
      * 小程序授权牌照图片(含水印)
      */
     private String appletsCertificateImage;
+
+    /**
+     * 设备关联的机构列表
+     */
+    private List<WxClubListVo> clubList;
 }

+ 78 - 16
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -12,54 +12,96 @@ import java.util.Date;
  */
 @Data
 public class AuthVo {
-    @ApiModelProperty("授权id")
+    /**
+     * 授权id
+     */
     private Integer authId;
 
-    @ApiModelProperty("供应商用户id")
+    /**
+     * 供应商用户id
+     */
     private Integer authUserId;
 
-    @ApiModelProperty("授权机构")
+    /**
+     * 授权机构
+     */
     private String authParty;
 
-    @ApiModelProperty("机构用户手机号")
+    /**
+     * 机构授权牌
+     */
+    private String authImage;
+
+    /**
+     * 机构用户手机号
+     */
     private String mobile;
 
-    @ApiModelProperty("上线状态:0已下线,1已上线,2待上线")
+    /**
+     * 上线状态:0已下线,1已上线,2待上线
+     */
     private Integer status;
 
-    @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer auditStatus;
 
-    @ApiModelProperty("供应商审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 供应商审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer shopAuditStatus;
 
-    @ApiModelProperty("寄送状态:0未寄送,1已寄送")
+    /**
+     * 寄送状态:0未寄送,1已寄送
+     */
     private Integer sendStatus;
 
-    @ApiModelProperty("创建时间")
+    /**
+     * 创建时间
+     */
     private Date createTime;
 
-    @ApiModelProperty("创建人")
+    /**
+     * 创建人
+     */
     private String createBy;
 
-    @ApiModelProperty("下级审核状态,0未完成审核,1已完成审核")
+    /**
+     * 下级审核状态,0未完成审核,1已完成审核
+     */
     private Integer lowerAuditStatus;
 
-    @ApiModelProperty("下级待审核数量")
+    /**
+     * 下级待审核数量
+     */
     private Integer waitAuditNum;
 
-    @ApiModelProperty("供应商审核下级待审核数量")
+    /**
+     * 供应商审核下级待审核数量
+     */
     private Integer shopWaitAuditNum;
 
-    @ApiModelProperty("审核人")
+    /**
+     * 审核人
+     */
     private String auditBy;
 
-    @ApiModelProperty("审核时间")
+    /**
+     * 审核时间
+     */
     private Date auditTime;
 
-    @ApiModelProperty("审核不通过原因")
+    /**
+     * 审核不通过原因
+     */
     private String invalidReason;
 
+    /**
+     * 供应商审核不通过原因
+     */
+    private String shopInvalidReason;
+
     /**
      * 供应商审核人
      */
@@ -74,4 +116,24 @@ public class AuthVo {
      * 机构下设备数量
      */
     private Integer productNum;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
+
+    /**
+     * 明星机构标识:0不是,1是
+     */
+    private Integer starFlag;
+
+    /**
+     * 扫码次数
+     */
+    private Integer scanCount;
+
+    /**
+     *  设备列表最大参数数量
+     */
+    private Integer maxParamNum;
 }

+ 0 - 20
src/main/java/com/caimei/model/vo/BrandVo.java

@@ -1,20 +0,0 @@
-package com.caimei.model.vo;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * @author Aslee
- * @date 2021/5/17
- */
-@Data
-public class BrandVo {
-    @ApiModelProperty("品牌id")
-    private Integer id;
-
-    @ApiModelProperty("品牌名称")
-    private String name;
-
-    @ApiModelProperty("品牌logo")
-    private String authLogo;
-}

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

@@ -19,7 +19,7 @@ public class ClubVo {
      * 机构名称
      */
     @ApiModelProperty("机构名称")
-    private String clubName;
+    private String authParty;
 
     /**
      * 创建时间

+ 21 - 0
src/main/java/com/caimei/model/vo/CmShopVo.java

@@ -0,0 +1,21 @@
+package com.caimei.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author Aslee
+ * @date 2022/8/1
+ */
+@Data
+public class CmShopVo {
+    /**
+     * 采美供应商id
+     */
+    private Integer cmShopId;
+
+    /**
+     * 采美供应商名称
+     */
+    private String cmShopName;
+}

+ 3 - 0
src/main/java/com/caimei/model/vo/DoctorListVo.java

@@ -41,4 +41,7 @@ public class DoctorListVo {
 
     @ApiModelProperty("审核不通过原因")
     private String invalidReason;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

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

@@ -16,7 +16,7 @@ public class FeedbackVo {
     private Integer feedbackId;
 
     @ApiModelProperty("机构名称")
-    private String clubName;
+    private String authParty;
 
     @ApiModelProperty("手机号")
     private String mobile;

+ 3 - 0
src/main/java/com/caimei/model/vo/FileListVo.java

@@ -44,4 +44,7 @@ public class FileListVo {
 
     @ApiModelProperty("审核时间")
     private Date auditTime;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

+ 5 - 0
src/main/java/com/caimei/model/vo/ImageFormVo.java

@@ -22,4 +22,9 @@ public class ImageFormVo {
 
     @ApiModelProperty("图片详情列表")
     private List<String> imageList;
+
+    /**
+     * 审核状态:0审核未通过,1审核通过,2待审核
+     */
+    private Integer auditStatus;
 }

+ 3 - 0
src/main/java/com/caimei/model/vo/ImageListVo.java

@@ -35,4 +35,7 @@ public class ImageListVo {
 
     @ApiModelProperty("审核时间")
     private Date auditTime;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

+ 21 - 16
src/main/java/com/caimei/model/vo/ProductFormVo.java

@@ -25,9 +25,19 @@ public class ProductFormVo {
     private Integer authId;
 
     /**
-     * 品牌id
+     * 机构设备关联id
      */
-    private Integer brandId;
+    private Integer relationId;
+
+    /**
+     * 认证方式:1新设备认证,2关联已认证设备
+     */
+    private Integer authType;
+
+    /**
+     * 品牌信息id
+     */
+    private Integer infoId;
 
     /**
      * 品牌名称
@@ -55,24 +65,14 @@ public class ProductFormVo {
     private String productImage;
 
     /**
-     * 授权牌照
+     * 授权牌照类型:1模板库生成,2自定义上传
      */
-    private String certificateImage;
+    private Integer certificateImageType;
 
     /**
-     * 原授权牌照
-     */
-    private String originalCertificateImage;
-
-    /**
-     * 是否生成二维码授权牌:0否,1是
-     */
-    private Integer addQrCodeFlag;
-
-    /**
-     * 生成二维码授权牌模板:1左下,2右边,3左边
+     * 授权牌照
      */
-    private Integer addTemplateType;
+    private String certificateImage;
 
     /**
      * 购买渠道
@@ -103,4 +103,9 @@ public class ProductFormVo {
      * 审核不通过原因
      */
     private String invalidReason;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
 }

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

@@ -11,42 +11,76 @@ import java.util.Date;
  */
 @Data
 public class ProductListVo {
-    @ApiModelProperty("商品id")
+    /**
+     * 商品id
+     */
     private Integer productId;
 
-    @ApiModelProperty("供应商用户id")
+    /**
+     * 供应商用户id
+     */
     private Integer authUserId;
 
-    @ApiModelProperty("商品名称")
+    /**
+     * 机构设备关联id
+     */
+    private Integer relationId;
+
+    /**
+     * 商品名称
+     */
     private String productName;
 
-    @ApiModelProperty("商品SN码")
+    /**
+     * 商品SN码
+     */
     private String snCode;
 
-    @ApiModelProperty("上线状态:0下线,1上线,2待上线")
+    /**
+     * 上线状态:0下线,1上线,2待上线
+     */
     private Integer status;
 
-    @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer auditStatus;
 
-    @ApiModelProperty("供应商审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 供应商审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer shopAuditStatus;
 
-    @ApiModelProperty("创建时间")
+    /**
+     * 创建时间
+     */
     private Date createTime;
 
-    @ApiModelProperty("创建人")
+    /**
+     * 创建人
+     */
     private String createBy;
 
-    @ApiModelProperty("审核时间")
+    /**
+     * 审核时间
+     */
     private Date auditTime;
 
-    @ApiModelProperty("审核人")
+    /**
+     * 审核人
+     */
     private String auditBy;
 
-    @ApiModelProperty("审核不通过原因")
+    /**
+     * 审核不通过原因
+     */
     private String invalidReason;
 
+    /**
+     * 供应商审核不通过原因
+     */
+    private String shopInvalidReason;
+
     /**
      * 供应商审核人
      */
@@ -56,4 +90,14 @@ public class ProductListVo {
      * 供应商审核时间
      */
     private Date shopAuditTime;
+
+    /**
+     * 是否查看过:1是,0否
+     */
+    private Integer checkFlag;
+
+    /**
+     * 扫码次数
+     */
+    private Integer scanCount;
 }

+ 37 - 0
src/main/java/com/caimei/model/vo/ProductRelationVo.java

@@ -0,0 +1,37 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/5/11
+ */
+@Data
+public class ProductRelationVo implements Serializable {
+    /**
+     * 机构设备关联id
+     */
+    private Integer relationId;
+
+    /**
+     * 授权机构id
+     */
+    private Integer authId;
+
+    /**
+     * 设备id
+     */
+    private Integer productId;
+
+    /**
+     * 认证方式:1新设备认证,2关联已认证设备
+     */
+    private Integer authType;
+}

+ 3 - 0
src/main/java/com/caimei/model/vo/ProductTypeListVo.java

@@ -40,4 +40,7 @@ public class ProductTypeListVo {
 
     @ApiModelProperty("审核不通过原因")
     private String invalidReason;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

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

@@ -12,6 +12,6 @@ public class ShopBrandVo {
     @ApiModelProperty("供应商信息id")
     private Integer id;
 
-    @ApiModelProperty("品牌id")
-    private Integer brandId;
+    @ApiModelProperty("品牌名称")
+    private String brandName;
 }

+ 53 - 16
src/main/java/com/caimei/model/vo/ShopFormVo.java

@@ -1,6 +1,5 @@
 package com.caimei.model.vo;
 
-import com.caimei.model.po.ShopInfoPo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -16,47 +15,85 @@ import java.util.List;
  */
 @Data
 public class ShopFormVo implements Serializable {
-    @ApiModelProperty("供应商用户id")
+    /**
+     * 供应商用户id
+     */
     private Integer authUserId;
 
-    @ApiModelProperty("供应商名称")
+    /**
+     * 关联采美供应商id
+     */
+    private Integer cmShopId;
+
+    /**
+     * 供应商名称
+     */
     private String shopName;
 
-    @ApiModelProperty("登录账号")
+    /**
+     * 登录账号
+     */
     private String loginAccount;
 
-    @ApiModelProperty("供应商类型")
+    /**
+     * 前缀
+     */
+    private String prefix;
+
+    /**
+     * 供应商类型
+     */
     private Integer shopType;
 
-    @ApiModelProperty("代理商logo")
+    /**
+     * 代理商logo
+     */
     private String logo;
 
-    @ApiModelProperty("微信公众号类型:1订阅号,2服务号")
+    /**
+     * 微信公众号类型:1订阅号,2服务号
+     */
     private Integer wxAccountType;
 
-    @ApiModelProperty("公众号二维码图片")
+    /**
+     * 公众号二维码图片
+     */
     private String qrCodeImage;
 
-    @ApiModelProperty("供应商公众号appId")
+    /**
+     * 供应商公众号appId
+     */
     private String appId;
 
-    @ApiModelProperty("供应商公众号appSecret")
+    /**
+     * 供应商公众号appSecret
+     */
     private String appSecret;
 
-    @ApiModelProperty("手机号")
+    /**
+     * 手机号
+     */
     private String mobile;
 
-    @ApiModelProperty("联系人")
+    /**
+     * 联系人
+     */
     private String linkMan;
 
-    @ApiModelProperty("供应商状态:0停用 1启用")
+    /**
+     * 供应商状态:0停用 1启用
+     */
     private Integer shopStatus;
 
-    @ApiModelProperty("供应商信息列表")
+    /**
+     * 供应商信息列表
+     */
     private List<ShopInfoVo> shopInfo;
 
-    @ApiModelProperty("已存在商品的品牌id,以,隔开")
-    private String existProductBrandIds;
+    /**
+     * 已存在商品的品牌信息id,以,隔开
+     */
+    private String existProductInfoIds;
 
     /**
      * 会员状态:0已过期,1生效中,2待生效,3非会员

+ 7 - 41
src/main/java/com/caimei/model/vo/ShopInfoVo.java

@@ -9,10 +9,11 @@ import lombok.Data;
  */
 @Data
 public class ShopInfoVo {
+
     /**
-     * 所属品牌Id
+     * 供应商信息id
      */
-    private Integer brandId;
+    private Integer infoId;
 
     /**
      * 所属品牌名称
@@ -20,52 +21,17 @@ public class ShopInfoVo {
     private String brandName;
 
     /**
-     * 品牌授权logo
-     */
-    private String brandAuthLogo;
-
-    /**
-     * 产地国家id
+     * 品牌logo
      */
-    private Integer countryId;
+    private String brandLogo;
 
     /**
-     * 官网认证链接
+     * 产地
      */
-    private String securityLink;
+    private String producePlace;
 
     /**
      * 制造商
      */
     private String manufacturer;
-
-    /**
-     * 代理声明类型:1弹窗,2链接,3图片,4文件
-     */
-    private Integer statementType;
-
-    /**
-     * 声明弹窗内容
-     */
-    private String statementContent;
-
-    /**
-     * 声明链接
-     */
-    private String statementLink;
-
-    /**
-     * 声明图片
-     */
-    private String statementImage;
-
-    /**
-     * 声明文件Id
-     */
-    private Integer statementFileId;
-
-    /**
-     * 声明文件名称
-     */
-    private String statementFileName;
 }

+ 6 - 36
src/main/java/com/caimei/model/vo/ShopListVo.java

@@ -16,69 +16,39 @@ import java.util.List;
  */
 @Data
 public class ShopListVo implements Serializable {
-    /**
-     * 供应商用户id
-     */
     @ApiModelProperty("供应商用户id")
     private Integer authUserId;
 
-    /**
-     * 供应商名称
-     */
     @ApiModelProperty("供应商名称")
     private String name;
 
-    /**
-     * 登录账号
-     */
     @ApiModelProperty("登录账号")
     private String loginAccount;
 
-    /**
-     * 供应商类型:1代理商 2品牌方
-     */
+    @ApiModelProperty("供应商前缀")
+    private String prefix;
+
     @ApiModelProperty("供应商类型")
     private Integer shopType;
 
-    /**
-     * 所属品牌
-     */
-    @ApiModelProperty("所属品牌")
+    @ApiModelProperty("品牌名称")
     private String brandName;
 
-    /**
-     * 品牌id
-     */
-    @ApiModelProperty("所属品牌")
-    private String brandId;
+    @ApiModelProperty("品牌信息id")
+    private String infoId;
 
-    /**
-     * 手机号
-     */
     @ApiModelProperty("手机号")
     private String mobile;
 
-    /**
-     * 联系人
-     */
     @ApiModelProperty("联系人")
     private String linkMan;
 
-    /**
-     * 供应商状态:0停用 1启用
-     */
     @ApiModelProperty("供应商状态:0停用 1启用")
     private Integer shopStatus;
 
-    /**
-     * 创建时间
-     */
     @ApiModelProperty("创建时间")
     private Date createTime;
 
-    /**
-     * 创建人
-     */
     @ApiModelProperty("创建人")
     private String createBy;
 

+ 0 - 15
src/main/java/com/caimei/model/vo/StatementFileVo.java

@@ -1,15 +0,0 @@
-package com.caimei.model.vo;
-
-import com.caimei.model.po.CmBrandAuthFilePo;
-import lombok.Data;
-
-/**
- * @author Aslee
- */
-@Data
-public class StatementFileVo extends CmBrandAuthFilePo {
-    /**
-     * 访问声明文件链接
-     */
-    private String url;
-}

+ 48 - 0
src/main/java/com/caimei/model/vo/TemplateListVo.java

@@ -0,0 +1,48 @@
+package com.caimei.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author Aslee
+ * @date 2022/7/6
+ */
+@Data
+public class TemplateListVo {
+    /**
+     * 模板id
+     */
+    private Integer templateId;
+
+    /**
+     *供应商用户id
+     */
+    private Integer authUserId;
+
+    /**
+     *作为机构认证模板:1是,其余否
+     */
+    private Integer authFlag;
+
+    /**
+     *作为设备认证模板:1是,其余否
+     */
+    private Integer productFlag;
+
+    /**
+     * 二维码位置:top,left
+     */
+    private String qrPosition;
+
+    /**
+     * 状态:0停用,1启用
+     */
+    private Integer status;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+}

+ 5 - 5
src/main/java/com/caimei/model/vo/UserLoginVo.java

@@ -37,6 +37,11 @@ public class UserLoginVo implements Serializable {
      */
     @ApiModelProperty("登录账号")
     private String loginAccount;
+    /**
+     * 登录账号
+     */
+    @ApiModelProperty("前缀")
+    private String prefix;
     /**
      * 密码
      */
@@ -52,11 +57,6 @@ public class UserLoginVo implements Serializable {
      */
     @ApiModelProperty("供应商类型:1品牌方 2代理商")
     private Integer shopType;
-    /**
-     * 品牌id
-     */
-    @ApiModelProperty("品牌id")
-    private Integer brandId;
     /**
      * 用户身份: 1管理员 2供应商
      */

+ 3 - 0
src/main/java/com/caimei/model/vo/VideoListVo.java

@@ -47,4 +47,7 @@ public class VideoListVo {
 
     @ApiModelProperty("审核时间")
     private Date auditTime;
+
+    @ApiModelProperty("是否查看过:1是,0否")
+    private Integer checkFlag;
 }

+ 3 - 0
src/main/java/com/caimei/model/vo/WxClubDetailsVo.java

@@ -35,6 +35,9 @@ public class WxClubDetailsVo implements Serializable {
     @ApiModelProperty("机构logo")
     private String logo;
 
+    @ApiModelProperty("机构授权牌")
+    private String authImage;
+
     @ApiModelProperty("轮播图")
     private List<String> bannerList;
 

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

@@ -17,7 +17,7 @@ public class WxClubListVo {
     private Integer authId;
 
     @ApiModelProperty("机构名称")
-    private String clubName;
+    private String authParty;
 
     @ApiModelProperty("省市区")
     private String area;

+ 9 - 6
src/main/java/com/caimei/model/vo/WxProductListVo.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 微信公众号商品列表
@@ -12,12 +13,12 @@ import java.util.Date;
  */
 @Data
 public class WxProductListVo {
+    @ApiModelProperty("机构设备关联id")
+    private Integer relationId;
+
     @ApiModelProperty("商品id")
     private Integer productId;
 
-    @ApiModelProperty("授权机构id")
-    private Integer authId;
-
     @ApiModelProperty("商品名称")
     private String productName;
 
@@ -27,9 +28,11 @@ public class WxProductListVo {
     @ApiModelProperty("商品图片")
     private String productImage;
 
-    @ApiModelProperty("机构名称")
-    private String clubName;
-
     @ApiModelProperty("审核状态:0未通过,1已通过,2待审核")
     private String auditStatus;
+
+    /**
+     * 设备关联的机构列表
+     */
+    private List<WxClubListVo> clubList;
 }

+ 3 - 0
src/main/java/com/caimei/model/vo/WxShopVo.java

@@ -25,4 +25,7 @@ public class WxShopVo implements Serializable {
 
     @ApiModelProperty("logo")
     private String logo;
+
+    @ApiModelProperty("前缀")
+    private String prefix;
 }

+ 14 - 1
src/main/java/com/caimei/service/auth/ArticleService.java

@@ -35,9 +35,10 @@ public interface ArticleService {
      * @param articleTitle      文章标题
      * @param articleImage      文章图片
      * @param articleContent    文章内容
+     * @param sort
      * @return  ResponseJson
      */
-    ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent);
+    ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort);
 
     /**
      * 更新文章状态
@@ -80,4 +81,16 @@ public interface ArticleService {
      * @return
      */
     ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle, Integer pageNum, Integer pageSize);
+
+    /**
+     * 更改查看标记
+     * @param articleId
+     * @return
+     */
+    ResponseJson checkArticle(Integer articleId);
+
+    /**
+     * 更改排序值
+     */
+    ResponseJson updateSort(Integer articleId, Integer sort);
 }

+ 13 - 4
src/main/java/com/caimei/service/auth/AuthClubService.java

@@ -4,6 +4,8 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.vo.*;
 import com.github.pagehelper.PageInfo;
 
+import java.util.List;
+
 /**
  * Description
  *
@@ -16,12 +18,12 @@ public interface AuthClubService {
      * 机构列表
      *
      * @param authUserId    供应商用户id
-     * @param clubName      机构名称
+     * @param authParty      机构名称
      * @param pageNum       第几页
      * @param pageSize      一页多少条
      * @return AuthVo
      */
-    ResponseJson<PageInfo<ClubVo>> getClubList(Integer authUserId, String clubName, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<ClubVo>> getClubList(Integer authUserId, String authParty, Integer pageNum, Integer pageSize);
 
     /**
      * 机构用户列表
@@ -39,12 +41,12 @@ public interface AuthClubService {
      * 微信公众号机构列表
      *
      * @param authUserId 供应商用户id
-     * @param clubName   机构名称
+     * @param authParty   机构名称
      * @param pageNum    第几页
      * @param pageSize   一页多少条
      * @return
      */
-    ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String clubName, Integer provinceId,
+    ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
                                                        Integer cityId, Integer townId, Integer pageNum, Integer pageSize);
 
     /**
@@ -91,4 +93,11 @@ public interface AuthClubService {
      * @return
      */
     ResponseJson resetClubUserPassword(Integer clubUserId);
+
+    /**
+     *
+     * @param authUserId
+     * @return
+     */
+    ResponseJson<List<WxClubListVo>> getWxStarClubList(Integer authUserId);
 }

+ 34 - 4
src/main/java/com/caimei/service/auth/AuthProductService.java

@@ -66,14 +66,15 @@ public interface AuthProductService {
      *                       }
      * @return ResponseJson
      */
-    ResponseJson saveProduct(ProductSaveDto productSaveDto, boolean importFlag) throws IOException;
+    ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException;
 
     /**
      * 获取授权商品回显数据
-     * @param productId     商品id
+     *
+     * @param relationId     机构设备关联id
      * @return  ProductFormVo
      */
-    ResponseJson<ProductFormVo> getProductFormData(Integer productId);
+    ResponseJson<ProductFormVo> getProductFormData(Integer relationId);
 
     /**
      * 根据品牌授权id获取商品id列表
@@ -124,7 +125,7 @@ public interface AuthProductService {
     /**
      * 保存设备分类
      */
-    ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, Integer brandId, String name, String image, Integer createBy, List<ProductParamPo> paramList, Integer createSource) throws IOException;
+    ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, Integer infoId, String name, String image, Integer createBy, List<ProductParamPo> paramList, Integer createSource) throws IOException;
 
     /**
      * 删除设备分类
@@ -161,6 +162,35 @@ public interface AuthProductService {
      * @return
      */
     ResponseJson<ProductTypePo> getProductTypeFromData(Integer productTypeId);
+    /**
+     * 更改查看标记
+     * @param productId
+     * @return
+     */
+    ResponseJson checkAuthProduct(Integer productId);
+
+    /**
+     * 获取设备详情
+     * @param productId
+     * @param snCode
+     * @return
+     */
+    ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode);
+
+    /**
+     * sn码列表
+     * @param authUserId
+     * @param authId
+     * @return
+     */
+    ResponseJson<List<String>> getSnCodeList(Integer authUserId, Integer authId);
+
+    /**
+     * 更改设备分类查看标记
+     * @param productTypeId
+     * @return
+     */
+    ResponseJson checkProductType(Integer productTypeId);
 }
 
 

+ 15 - 12
src/main/java/com/caimei/service/auth/AuthService.java

@@ -8,7 +8,6 @@ import com.caimei.model.vo.TemplateVo;
 import com.github.pagehelper.PageInfo;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -27,14 +26,15 @@ public interface AuthService {
      * @param authParty        授权机构
      * @param mobile
      * @param status           上线状态:0已下线,1已上线,2待上线
-     * @param auditStatus      审核状态:0审核未通过,1审核通过,2待审核
+     * @param starFlag         明星机构标识:0不是,1是
      * @param lowerAuditStatus 商品信息审核状态:0未完成审核,1已完成审核
      * @param shopAuditStatus  供应商审核状态:0审核未通过,1审核通过,2待审核
      * @param pageNum          第几页
      * @param pageSize         一页多少条
+     * @param auditStatus      审核状态:0审核未通过,1审核通过,2待审核
      * @return AuthVo
      */
-    ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
 
     /**
      * 更新授权状态
@@ -83,15 +83,6 @@ public interface AuthService {
      */
     ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy);
 
-
-    /**
-     * 导出授权机构和商品数据
-     * @param authUserId    供应商用户id
-     * @param response
-     * @return
-     */
-    ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response);
-
     /**
      * 授权机构回显数据
      * @param authId    机构id
@@ -122,4 +113,16 @@ public interface AuthService {
      * 添加水印
      */
     String addWaterMark(String image,Integer type);
+
+    /**
+     * 更改查看标记
+     * @param authId
+     * @return
+     */
+    ResponseJson checkAuth(Integer authId);
+
+    /**
+     * 更改明星标识
+     */
+    ResponseJson starAuth(Integer authId, Integer starFlag);
 }

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

@@ -98,4 +98,11 @@ public interface DoctorService {
      * @return
      */
     ResponseJson<DoctorFormVo> getAuthDoctorDetails(Integer doctorId);
+
+    /**
+     * 更改查看标记
+     * @param doctorId
+     * @return
+     */
+    ResponseJson checkDoctor(Integer doctorId);
 }

+ 16 - 2
src/main/java/com/caimei/service/auth/DownloadService.java

@@ -1,5 +1,7 @@
 package com.caimei.service.auth;
 
+import com.caimei.model.ResponseJson;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -22,8 +24,20 @@ public interface DownloadService {
 
     /**
      * 一键下载授权牌,二维码
-     * @param authUserId
+     * @param authIds
      * @param type
      */
-    void downloadShopImage(Integer authUserId, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception;
+    void downloadShopImage(String authIds, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception;
+
+    /**
+     * 导出授权机构数据
+     * @param authIds
+     * @param response
+     * @return
+     */
+    ResponseJson downloadAuthData(String authIds, HttpServletResponse response);
+
+    ResponseJson downloadProductData(String authIds, HttpServletRequest request, HttpServletResponse response) throws IOException;
+
+    void downloadAuthTemplate(HttpServletRequest request, HttpServletResponse response) throws IOException;
 }

+ 38 - 41
src/main/java/com/caimei/service/auth/ShopService.java

@@ -2,9 +2,9 @@ package com.caimei.service.auth;
 
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ShopInfoDto;
+import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
 import com.github.pagehelper.PageInfo;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -17,13 +17,11 @@ import java.util.List;
 public interface ShopService {
     /**
      * 供应商列表数据
-     *
-     *
      * @param listType  列表类型:1供应商列表,2审核列表
      * @param shopName  供应商名称
      * @param loginAccount
      * @param shopType  供应商类型:1品牌方,2代理商
-     * @param brandId   所属品牌Id
+     * @param infoId    品牌信息Id
      * @param mobile    手机号
      * @param linkMan   联系人
      * @param lowerAuditStatus  下级审核状态,0未完成审核,1已完成审核
@@ -31,7 +29,7 @@ public interface ShopService {
      * @param pageSize  一页多少条
      * @return PageInfo<ShopVo>
      */
-    ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName, String loginAccount, Integer shopType, Integer brandId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName, String loginAccount, Integer shopType, Integer infoId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
 
     /**
      * 更新供应商状态
@@ -48,43 +46,19 @@ public interface ShopService {
      */
     ResponseJson resetShopPassword(Integer authUserId);
 
-    /**
-     * 上传文件
-     *
-     * @param authUserId 供应商用户id
-     * @param brandId :品牌id
-     * @param file       上传文件
-     * @return
-     */
-    ResponseJson<AuthFileVo> uploadFile(Integer authUserId, Integer brandId, MultipartFile file);
-
     /**
      * 添加供应商
-     * @param shopSaveDto {
+     * @param shop {
      *                    shopType           供应商类型:1代理商,2品牌方
-     *                    brandId            品牌id
      *                    shopName           供应商名称
      *                    mobile             手机号
      *                    linkMan            联系人
-     *                    countryId          产地国家id
-     *                    brandAuthLogo      品牌授权logo
      *                    shopStatus         供应商状态:0停用 1启用
-     *                    securityLink       官网认证链接
-     *                    statementType      代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
-     *                    statementContent   声明弹窗内容
-     *                    statementLink      声明链接
-     *                    statementImage     声明图片
-     *                    statementFileId    声明文件id
      *                    createBy           创建人用户id
      *                    }
-     * @param logo
-     * @param qrCodeImage
-     * @param wxAccountType
-     * @param appId
-     * @param appSecret
      * @param shopInfoList
      */
-    ResponseJson saveShop(Integer authUserId, Integer shopType, String shopName, String mobile, String linkMan, Integer shopStatus, String logo, String qrCodeImage, Integer wxAccountType, String appId, String appSecret, Integer createBy, List<ShopInfoDto> shopInfoList);
+    ResponseJson saveShop(UserPo shop, List<ShopInfoDto> shopInfoList);
 
     /**
      * 获取供应商回显数据
@@ -94,17 +68,11 @@ public interface ShopService {
     ResponseJson<ShopFormVo> getShopFormData(Integer authUserId);
 
     /**
-     * 根据供应商用户id删除代理声明文件
-     */
-    void deleteFile(Integer authUserId,Integer brandId);
-
-    /**
-     * 品牌列表
-     * @param type 1品牌方品牌列表,2代理商品牌列表
+     * 品牌信息列表
      * @param authUserId    供应商用户id
      * @return AuthVo
      */
-    ResponseJson<List<BrandVo>> getBrandList(Integer type, Integer authUserId);
+    ResponseJson<List<ShopInfoVo>> getShopInfoList(Integer authUserId);
 
     /**
      * 产地国家列表
@@ -115,14 +83,14 @@ public interface ShopService {
     /**
      * 用户反馈列表
      * @param authUserId    供应商用户id
-     * @param clubName
+     * @param authParty
      * @param mobile
      * @param handleStatus
      * @param pageNum
      * @param pageSize
      * @return
      */
-    ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String clubName, String mobile, Integer handleStatus, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String authParty, String mobile, Integer handleStatus, Integer pageNum, Integer pageSize);
 
     /**
      * 用户反馈表单数据
@@ -169,4 +137,33 @@ public interface ShopService {
      * @return
      */
     ResponseJson updateAllAuthImage(Integer authUserId);
+
+    /**
+     * 更改联系人
+     */
+    ResponseJson changeLinkMan(Integer authUserId, String linkMan);
+
+    /**
+     * 更改logo
+     */
+    ResponseJson changeLogo(Integer authUserId, String logo);
+
+    /**
+     * 保存供应商品牌信息
+     * @param authUserId
+     * @param shopInfo
+     * @return
+     */
+    ResponseJson saveShopInfo(Integer authUserId, ShopInfoDto shopInfo);
+
+    /**
+     * 删除供应商品牌信息
+     */
+    ResponseJson deleteShopInfo(Integer authUserId, Integer infoId);
+
+    /**
+     * 采美供应商列表
+     * @return
+     */
+    ResponseJson<List<CmShopVo>> getCmShopList();
 }

+ 4 - 2
src/main/java/com/caimei/service/auth/UploadService.java

@@ -6,6 +6,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -37,9 +38,10 @@ public interface UploadService {
 
     /**
      * 将多张图片压缩
-     * @param fileList
+     * @param fileMap
+     * @param type
      * @return
      * @throws Exception
      */
-    String createImageZip(List<UploadFilePo> fileList) throws  Exception;
+    String createImageZip(Map<String,List<UploadFilePo>> fileMap, Integer type) throws  Exception;
 }

+ 33 - 12
src/main/java/com/caimei/service/auth/impl/ArticleServiceImpl.java

@@ -36,9 +36,6 @@ public class ArticleServiceImpl implements ArticleService {
 
     @Override
     public ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status, Integer pageNum, Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
         listType = null == listType ? 1 : listType;
         PageHelper.startPage(pageNum, pageSize);
         List<ArticleListVo> articleList = articleMapper.getArticleList(listType, authUserId, articleTitle, auditStatus, status);
@@ -47,7 +44,7 @@ public class ArticleServiceImpl implements ArticleService {
     }
 
     @Override
-    public ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent) {
+    public ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort) {
         if (null == articleId && null == authUserId) {
             return ResponseJson.error("参数异常,请输入供应商用户id");
         }
@@ -60,8 +57,14 @@ public class ArticleServiceImpl implements ArticleService {
         if (StringUtils.isEmpty(articleContent)) {
             return ResponseJson.error("参数异常,请输入文章内容");
         }
-        // 处理富文本内容
-
+        if (null == sort) {
+            return ResponseJson.error("排序值不能为空");
+        }
+        boolean insertFlag = null == articleId;
+        ArticleFormVo dbArticle = null;
+        if (!insertFlag) {
+            dbArticle = articleMapper.getArticleForm(articleId);
+        }
         /*
             组装文章数据
          */
@@ -69,15 +72,21 @@ public class ArticleServiceImpl implements ArticleService {
         article.setTitle(articleTitle);
         article.setImage(articleImage);
         article.setContent(articleContent);
-        // 上线状态默认为“待上线”,审核状态为“待审核”
-//        article.setStatus(2);
-//        article.setAuditStatus(2);
-        article.setStatus(1);
-        article.setAuditStatus(1);
+        article.setSort(sort);
+        // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
+        if (null != dbArticle && 1 != dbArticle.getAuditStatus()) {
+            // 被驳回的数据,编辑后变为待审核状态
+            article.setStatus(2);
+            article.setAuditStatus(2);
+        } else {
+            article.setStatus(1);
+            article.setAuditStatus(1);
+        }
         Integer adminUserId = authMapper.getAdminUserId();
         article.setAuditBy(adminUserId);
         article.setAuditTime(new Date());
-        if (null == articleId) {
+        article.setCheckFlag(0);
+        if (insertFlag) {
             article.setAuthUserId(authUserId);
             article.setCreateTime(new Date());
             // 插入文章
@@ -166,4 +175,16 @@ public class ArticleServiceImpl implements ArticleService {
         PageInfo<WxArticleListVo> pageData = new PageInfo<>(articleList);
         return ResponseJson.success(pageData);
     }
+
+    @Override
+    public ResponseJson checkArticle(Integer articleId) {
+        articleMapper.checkArticle(articleId);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson updateSort(Integer articleId, Integer sort) {
+        articleMapper.updateSort(articleId, sort);
+        return null;
+    }
 }

+ 32 - 12
src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java

@@ -42,21 +42,18 @@ public class AuthClubServiceImpl implements AuthClubService {
     private DoctorMapper doctorMapper;
 
     @Override
-    public ResponseJson<PageInfo<ClubVo>> getClubList(Integer authUserId, String clubName, Integer pageNum, Integer pageSize) {
+    public ResponseJson<PageInfo<ClubVo>> getClubList(Integer authUserId, String authParty, Integer pageNum, Integer pageSize) {
         if (null == authUserId) {
             return ResponseJson.error("参数异常,请输入供应商用户id", null);
         }
         PageHelper.startPage(pageNum, pageSize);
-        List<ClubVo> clubList = clubMapper.getClubList(authUserId, clubName);
+        List<ClubVo> clubList = clubMapper.getClubList(authUserId, authParty);
         PageInfo<ClubVo> pageData = new PageInfo<>(clubList);
         return ResponseJson.success(pageData);
     }
 
     @Override
     public ResponseJson<PageInfo<ClubUserVo>> getClubUserList(Integer authUserId, String mobile, String name, Integer status, Integer pageNum, Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
         PageHelper.startPage(pageNum, pageSize);
         List<ClubUserVo> clubUserList = clubMapper.getClubUserList(authUserId, mobile, name, status);
         PageInfo<ClubUserVo> pageData = new PageInfo<>(clubUserList);
@@ -64,7 +61,7 @@ public class AuthClubServiceImpl implements AuthClubService {
     }
 
     @Override
-    public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String clubName, Integer provinceId,
+    public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
                                                               Integer cityId, Integer townId, Integer pageNum, Integer pageSize) {
         if (null == authUserId && StringUtils.isNotEmpty(appId)) {
             authUserId = shopMapper.getUserIdByAppId(appId);
@@ -78,7 +75,7 @@ public class AuthClubServiceImpl implements AuthClubService {
             lat = Double.parseDouble(split[1]);
         }
         PageHelper.startPage(pageNum, pageSize);
-        List<WxClubListVo> clubList = clubMapper.getWxClubList(authUserId, clubName, provinceId, cityId, townId, lng, lat);
+        List<WxClubListVo> clubList = clubMapper.getWxClubList(authUserId, authParty, provinceId, cityId, townId, lng, lat);
         PageInfo<WxClubListVo> pageData = new PageInfo<>(clubList);
         return ResponseJson.success(pageData);
     }
@@ -117,6 +114,8 @@ public class AuthClubServiceImpl implements AuthClubService {
             doctor.setTagList(tagList);
         });
         clubDetail.setDoctorList(doctorList);
+        // 增加扫码次数
+        authMapper.addScanCount(authId);
         return ResponseJson.success(clubDetail);
     }
 
@@ -151,8 +150,16 @@ public class AuthClubServiceImpl implements AuthClubService {
             clubUser.setPassword(md5Password);
             clubUser.setStatus(1);
             clubMapper.insertClubUser(clubUser);
-            String content = "您认证通登录密码为:rzt123456";
-            Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+            // 获取供应商名称
+            ShopFormVo shop = shopMapper.getShopByUserId(authUserId);
+            String shopName = "";
+            if (null == shop) {
+                return ResponseJson.error("供应商不存在");
+            } else {
+                shopName = shop.getShopName();
+            }
+            String content = "("+ shopName +")您认证通登录密码为:rzt123456,请勿泄漏于他人。【采美网提供技术支持】";
+            Boolean sendSms = SmsUtils.sendSms(1, mobile, content);
             if (!sendSms) {
                 log.info("供应商添加机构用户-密码发送失败,手机号:" + mobile);
                 return ResponseJson.error("发送失败,请确认手机号无误");
@@ -188,15 +195,28 @@ public class AuthClubServiceImpl implements AuthClubService {
         clubMapper.updateClubUserPassword(clubUserId, md5Password);
         WxClubUserVo clubUser = clubMapper.getWxClubUser(null, null, null, null, clubUserId);
         String mobile = clubUser.getMobile();
-        String content = "您认证通登录密码为:" + newPassword;
-        Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+        // 获取供应商名称
+        ShopFormVo shop = shopMapper.getShopByUserId(clubUser.getAuthUserId());
+        String shopName = "";
+        if (null == shop) {
+            return ResponseJson.error("供应商不存在");
+        } else {
+            shopName = shop.getShopName();
+        }
+        String content = "("+ shopName +")您认证通登录密码为:rzt123456,请勿泄漏于他人。【采美网提供技术支持】";
+        Boolean sendSms = SmsUtils.sendSms(1, mobile, content);
         if (!sendSms) {
             log.info("机构用户重置密码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
         } else {
             log.info("机构用户重置密码发送成功,手机号:" + mobile);
-
         }
         return ResponseJson.success("密码重置成功");
     }
+
+    @Override
+    public ResponseJson<List<WxClubListVo>> getWxStarClubList(Integer authUserId) {
+        List<WxClubListVo> starClubList = clubMapper.getWxStarClubList(authUserId);
+        return ResponseJson.success(starClubList);
+    }
 }

+ 334 - 174
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -1,7 +1,6 @@
 package com.caimei.service.auth.impl;
 
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
+import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.AuthProductMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
@@ -23,15 +22,23 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
+import javax.swing.*;
 import java.awt.*;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -63,16 +70,14 @@ public class AuthProductServiceImpl implements AuthProductService {
     @Value("${caimei.oldapi}")
     private String wwwServer;
 
+    @Autowired
+    private FastDfsClient client;
+
     @Autowired
     public void setUploadService(UploadService uploadService) {
         this.uploadService = uploadService;
     }
 
-    private String endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
-    private String accessKeyId = "LTAI4GBL3o4YkWnbKYgf2Xia";
-    private String accessKeySecret = "dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK";
-    private String bucketName = "caimei-oss";
-
     @Override
     public ResponseJson<PageInfo<ProductListVo>> getProductList(Integer listType, Integer authId, String productName,
                                                                 String snCode, Integer status, Integer auditStatus,
@@ -117,18 +122,33 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success("删除授权商品成功");
     }
 
+    /**
+     * 保存逻辑
+     * relationId
+     * null
+     * 新设备:插入设备、插入关联信息
+     * 关联设备:更新设备、插入关联信息
+     * notNull
+     * 数据库新设备
+     * 新设备:更新设备、原设备无需更新关联关系
+     * 关联设备:更新设备、更新关联信息(若原设备无机构关联,应删除该设备)
+     * 数据库关联设备
+     * 新设备:插入设备、更新关联信息
+     * 关联设备:更新设备、更新关联信息
+     */
     @Override
-    public ResponseJson saveProduct(ProductSaveDto productSaveDto, boolean importFlag) throws IOException {
-        Integer productId = productSaveDto.getProductId();
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException {
+        Integer relationId = productSaveDto.getRelationId();
+        Integer authType = productSaveDto.getAuthType();
         Integer authId = productSaveDto.getAuthId();
-        Integer brandId = productSaveDto.getBrandId();
+        Integer infoId = productSaveDto.getInfoId();
         Integer productTypeId = productSaveDto.getProductTypeId();
         String productName = productSaveDto.getProductName();
         String productImage = productSaveDto.getProductImage();
         String snCode = productSaveDto.getSnCode();
         String certificateImage = productSaveDto.getCertificateImage();
-        Integer addQrCodeFlag = productSaveDto.getAddQrCodeFlag();
-        Integer addTemplateType = productSaveDto.getAddTemplateType();
+        Integer certificateImageType = productSaveDto.getCertificateImageType();
         Integer createBy = productSaveDto.getCreateBy();
         String purchaseWay = productSaveDto.getPurchaseWay();
         String invoiceImage = productSaveDto.getInvoiceImage();
@@ -139,9 +159,9 @@ public class AuthProductServiceImpl implements AuthProductService {
         }
         AuthVo auth = authMapper.getAuthById(authId);
         if (null == productTypeId) {
-            // 新增设备分类,需要传入设备名称,品牌id,参数列表
-            if (null == brandId) {
-                return ResponseJson.error("参数异常,请输入品牌id", null);
+            // 新增设备分类,需要传入设备名称,品牌信息id,参数列表
+            if (null == infoId) {
+                return ResponseJson.error("参数异常,请输入品牌信息id", null);
             }
             if (StringUtils.isEmpty(productName)) {
                 return ResponseJson.error("参数异常,请输入设备分类id或设备名称", null);
@@ -159,31 +179,86 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (StringUtils.isBlank(snCode)) {
             return ResponseJson.error("参数异常,请输入商品SN码", null);
         }
+        if (1 == source) {
+            if (2 == certificateImageType && StringUtils.isEmpty(certificateImage)) {
+                return ResponseJson.error("授权牌不能为空");
+            }
+        } else {
+            // 机构添加默认模板库生成
+            certificateImageType = 1;
+        }
+        // 是否为添加操作
+        boolean newRelation = null == relationId;
+        ProductRelationVo dbRelation = null;
+        ProductFormVo dbProduct = null;
+        // 数据库设备id
+        Integer dbProductId = null;
+        // 当前设备id
+        Integer productId = null;
+        // 数据库中sn码对应设备id
         Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
-        if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
-            return ResponseJson.error("参数异常,该商品SN码已存在,请重新输入", null);
-        }
-        /*if (1 == source && StringUtils.isBlank(certificateImage)) {
-            return ResponseJson.error("参数异常,请上传授权牌照", null);
-        }*/
-        if (!importFlag && 1 == source) {
-            if (null == addQrCodeFlag) {
-                return ResponseJson.error("参数异常,请选择是否生成二维码授权牌", null);
+        if (newRelation) {
+            // 添加
+            if (1 == authType) {
+                // 新设备,设备id为null
+                if (null != productIdBySnCode) {
+                    return ResponseJson.error("该商品SN码已存在,请重新输入", null);
+                }
+            } else if (2 == authType){
+                // 关联设备
+                productId = productIdBySnCode;
+                // 检测机构是否已关联该设备
+                ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
+                if (null != productRelation) {
+                    return ResponseJson.error("不能重复关联同一台设备");
+                }
             }
-            if (1 == addQrCodeFlag && null == addTemplateType) {
-                return ResponseJson.error("参数异常,请选择二维码授权牌模板", null);
+        }else {
+            // 编辑
+            dbRelation = authProductMapper.getProductRelation(relationId, null, null);
+            dbProduct = authProductMapper.getProductFormData(relationId);
+            dbProductId = dbProduct.getProductId();
+            if (1 == dbRelation.getAuthType()) {
+                // 原本为新增设备
+                if (1 == authType) {
+                    // 设备id不变
+                    productId = dbProductId;
+                    if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
+                        return ResponseJson.error("该商品SN码已存在,请重新输入", null);
+                    }
+                } else if (2 == authType){
+                    productId = productIdBySnCode;
+                    // 检测机构是否已关联该设备
+                    ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
+                    if (null != productRelation) {
+                        return ResponseJson.error("不能重复关联同一台设备");
+                    }
+                }
+            } else if (2 == dbRelation.getAuthType()){
+                // 原本为关联设备
+                if (1 == authType) {
+                    // 设备id为null
+                    if (null != productIdBySnCode) {
+                        return ResponseJson.error("该商品SN码已存在,请重新输入", null);
+                    }
+                } else if (2 == authType) {
+                    productId = productIdBySnCode;
+                    // 检测机构是否已关联该设备
+                    ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
+                    if (null != productRelation && !productRelation.getRelationId().equals(dbRelation.getRelationId())) {
+                        return ResponseJson.error("不能重复关联同一台设备");
+                    }
+                }
             }
         }
-        // 是否为添加操作
-        boolean insertFlag = null == productId;
         /*
             组装商品数据
          */
         ProductPo product = new ProductPo();
-        // 授权id
-        product.setAuthId(authId);
-        // 品牌id
-        product.setBrandId(brandId);
+        // 设备id
+        product.setProductId(productId);
+        // 品牌信息id
+        product.setInfoId(infoId);
         // 设备分类id
         product.setProductTypeId(productTypeId);
         if (null == productTypeId) {
@@ -196,133 +271,87 @@ public class AuthProductServiceImpl implements AuthProductService {
         product.setSnCode(snCode);
         // 授权牌照
         product.setCertificateImage(certificateImage);
-        product.setAddQrCodeFlag(addQrCodeFlag);
-        product.setAddTemplateType(addTemplateType);
+        product.setCertificateImageType(certificateImageType);
         // 购买渠道
         product.setPurchaseWay(purchaseWay);
         // 发票图片
         product.setInvoiceImage(invoiceImage);
-        // 商品信息保存后,上线状态默认为“待上线”,审核状态为“待审核”
-        /*product.setStatus(2);
-        product.setAuditStatus(2);*/
         // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
-        product.setStatus(1 == source ? 1 : 2);
-        product.setAuditStatus(1 == source ? 1 : 2);
+        if (1 == authType) {
+            product.setShopAuditStatus(1 == source ? 1 : 2);
+            if (null != dbProduct && 1 != dbProduct.getAuditStatus()) {
+                // 被驳回的数据,编辑变为待审核状态
+                product.setStatus(2);
+                product.setAuditStatus(2);
+            } else {
+                product.setStatus(1 == source ? 1 : 2);
+                product.setAuditStatus(1 == source ? 1 : 2);
+            }
+        } else {
+            product.setStatus(1);
+            product.setAuditStatus(1);
+            product.setShopAuditStatus(1);
+        }
         Integer adminUserId = authMapper.getAdminUserId();
         product.setAuditBy(adminUserId);
         product.setAuditTime(new Date());
-        product.setShopAuditStatus(1 == source ? 1 : 2);
-        if (insertFlag) {
-            // 原授权牌照
-            product.setOriginalCertificateImage(product.getCertificateImage());
-            // 创建人id
-            product.setCreateBy(createBy);
-            // 创建来源
-            product.setCreateSource(source);
-            // 创建时间
-            product.setCreateTime(new Date());
-            if (1 == source && StringUtils.isNotEmpty(product.getCertificateImage()) && (null == addQrCodeFlag || 0 == addQrCodeFlag)) {
-                //授权牌照不添加二维码,直接添加水印
-                product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
-                product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
-            }
-            // 插入授权商品
-            authProductMapper.insertProduct(product);
-            if (1 == source && StringUtils.isNotEmpty(product.getCertificateImage()) && (null != addQrCodeFlag && 1 == addQrCodeFlag)) {
-                // 生成二维码授权牌
-                String addQrCodeImg = addQrCode(product.getCertificateImage(), product.getProductId(), addTemplateType);
-                product.setCertificateImage(addQrCodeImg);
-                //授权牌照添加水印
-                product.setPcCertificateImage(addWaterMark(addQrCodeImg, 1));
-                product.setAppletsCertificateImage(addWaterMark(addQrCodeImg, 2));
-                //更新授权牌照
-                authProductMapper.updateCertificateImage(product);
+        product.setCheckFlag(0);
+        // 创建人id
+        product.setCreateBy(createBy);
+        // 创建来源
+        product.setCreateSource(source);
+        // 创建时间
+        product.setCreateTime(new Date());
+
+        if (newRelation) {
+            if (1 == authType) {
+                // 插入授权商品
+                authProductMapper.insertProduct(product);
+            } else {
+                // 关联设备,更新设备
+                authProductMapper.updateProductByProductId(product);
             }
-            // 自动生成授权牌
-
+            // 插入机构设备关联关系
+            relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
         } else {
-            // 商品id
-            product.setProductId(productId);
-            if (1 == source) {
-                ProductPo dbProduct = authProductMapper.getImageByProductId(productId);
-                // 数据库该商品授权牌是否添加二维码
-                Integer dbAddQrCodeFlag = dbProduct.getAddQrCodeFlag();
-                // 数据库该商品授权牌添加二维码模板
-                Integer dbAddTemplateType = dbProduct.getAddTemplateType();
-                // 授权牌照是否重新上传
-                boolean updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(dbProduct.getCertificateImage())) || (StringUtils.isEmpty(dbProduct.getPcCertificateImage()) || StringUtils.isEmpty(dbProduct.getAppletsCertificateImage()));
-                boolean addQrCodeSign = false;
-                boolean addWaterMarkSign = false;
-                if (StringUtils.isNotEmpty(product.getCertificateImage())) {
-                    if (null != dbAddQrCodeFlag && 1 == dbAddQrCodeFlag) {
-                        if (0 == addQrCodeFlag) {
-                            // 原本是,现在否
-                            if (updateImageFlag) {
-                                // 新上传图片,将原图片替换为当前图片,生成水印图片
-                                product.setOriginalCertificateImage(product.getCertificateImage());
-                                addWaterMarkSign = true;
-                            } else {
-                                // 原图片,将当前授权牌替换为原图,生成水印图片
-                                product.setCertificateImage(dbProduct.getOriginalCertificateImage());
-                                addWaterMarkSign = true;
-                            }
-                        } else if (1 == addQrCodeFlag) {
-                            // 原本是,现在是
-                            if (updateImageFlag) {
-                                // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
-                                product.setOriginalCertificateImage(product.getCertificateImage());
-                                addQrCodeSign = true;
-                                addWaterMarkSign = true;
-                            } else if (!addTemplateType.equals(dbAddTemplateType)) {
-                                // 原图片,更改模板,将当前授权牌替换为原图,生成二维码授权牌,生成水印图片
-                                product.setCertificateImage(dbProduct.getOriginalCertificateImage());
-                                addQrCodeSign = true;
-                                addWaterMarkSign = true;
-                            }
-                            // else 原图片,不更改模板,不做更改
-                        }
-                    } else {
-                        if (1 == addQrCodeFlag) {
-                            // 原本否,现在是
-                            if (updateImageFlag) {
-                                // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
-                                product.setOriginalCertificateImage(product.getCertificateImage());
-                                addQrCodeSign = true;
-                                addWaterMarkSign = true;
-                            } else {
-                                // 原图片,生成二维码授权牌,生成水印图片
-                                addQrCodeSign = true;
-                                addWaterMarkSign = true;
-                            }
-                        } else {
-                            // 原本否,现在否
-                            if (updateImageFlag) {
-                                // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
-                                product.setOriginalCertificateImage(product.getCertificateImage());
-                                addWaterMarkSign = true;
-                            }
-                            // 原图片,不做更改
-                        }
+            if (1 == dbRelation.getAuthType()) {
+                // 更新设备
+                authProductMapper.updateProductByProductId(product);
+                if (2 == authType) {
+                    // 更新机构设备关联关系
+                    authProductMapper.updateProductRelation(dbRelation.getRelationId(), authId, product.getProductId(), authType);
+                    // 原本关联的新增设备若无关联机构,删除该设备
+                    Integer relationCount = authProductMapper.getProductRelationCount(dbProduct.getProductId());
+                    if (relationCount <= 0) {
+                        authProductMapper.deleteProductByProductId(dbProduct.getProductId());
                     }
-                }else {
-                    product.setPcCertificateImage(null);
-                    product.setAppletsCertificateImage(null);
-                }
-                if (addQrCodeSign) {
-                    // 生成二维码授权牌
-                    String addQrCodeImg = addQrCode(product.getCertificateImage(), productId, addTemplateType);
-                    product.setCertificateImage(addQrCodeImg);
                 }
-                if (addWaterMarkSign) {
-                    //授权牌照添加水印
-                    product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
-                    product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
+            } else {
+                if (1 == authType) {
+                    // 插入授权商品
+                    authProductMapper.insertProduct(product);
+                } else {
+                    // 更新设备
+                    authProductMapper.updateProductByProductId(product);
                 }
+                // 更新机构设备关联关系
+                authProductMapper.updateProductRelation(dbRelation.getRelationId(), authId, product.getProductId(), authType);
             }
-            // 自动生成授权牌
-
-            // 更新授权商品
-            authProductMapper.updateProductByProductId(product);
+        }
+        ProductFormVo newDbProduct = authProductMapper.getProductFormData(relationId);
+        // 保存之后生成授权牌和水印授权牌
+        if (1 == product.getCertificateImageType()) {
+            // 模板库生成
+            // 获取对应模板
+            TemplateVo authTemplate = authMapper.getAuthTemplate(authId, null, 2);
+            certificateImage = generateAuthImage(authTemplate, newDbProduct);
+            product.setCertificateImage(certificateImage);
+        }
+        // 添加水印
+        if (StringUtils.isNotEmpty(product.getCertificateImage())) {
+            product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
+            product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
+            authProductMapper.updateCertificateImage(product);
         }
         // 删除商品参数
         authProductMapper.deleteParamsByProductId(product.getProductId());
@@ -337,6 +366,97 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success("保存授权商品成功");
     }
 
+    public String generateAuthImage(TemplateVo authTemplate, ProductFormVo product) {
+        if (null != authTemplate) {
+            // 根据模板id设置相关数据
+            Map<String, Object> templateInfo = getTemplateInfo(authTemplate, product);
+            Object templateImage = templateInfo.get("templateImage");
+            if (null != templateImage) {
+                String authImage = ImageUtils.generateAuthImage(templateInfo);
+                log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + authImage);
+                // 临时图片
+                File tempFile = new File(authImage);
+                String imageUrl = null;
+                try {
+                    imageUrl = imageDomain + "/" + client.uploadFile(authImage);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                // 删除临时图片
+                boolean delete = tempFile.delete();
+                log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+                return imageUrl;
+            } else {
+                return null;
+            }
+        }
+        return null;
+    }
+
+    private Map<String,Object> getTemplateInfo(TemplateVo template, ProductFormVo product) {
+        HashMap<String, Object> map = new HashMap<>();
+        Integer templateId = template.getTemplateId();
+        if (1 == templateId) {
+            map.put("templateImage", template.getTemplateImage());
+            double rate = 0.15;
+            String productName = product.getProductName();
+            if (StringUtils.isNotEmpty(productName)) {
+                map.put("addWord1_content", productName);
+                map.put("addWord1_color", "0,0,0");
+                map.put("addWord1_type", "思源宋体");
+                map.put("addWord1_style", Font.BOLD);
+                map.put("addWord1_size", (int) Math.round(233 * rate));
+                // 获取设备名字位置
+                try {
+                    ImageIcon imageIcon = new ImageIcon(new URL(template.getTemplateImage()));
+                    Image srcImg = imageIcon.getImage();
+                    int srcWidth = srcImg.getWidth(null);
+                    int wordWidth = ImageUtils.getWordWidth(new Font("思源宋体", Font.BOLD, (int) Math.round(233 * rate)), productName);
+                    int x = (srcWidth - (int) Math.round(238 * rate) - wordWidth) / 2 + (int) Math.round(238 * rate);
+                    int y = (int) Math.round(1630 * rate);
+                    // 居中
+                    map.put("addWord1_x", x);
+                    map.put("addWord1_y", y);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            // 添加认证编号信息
+            if (StringUtils.isNotEmpty(product.getSnCode())) {
+                map.put("addWord2_content", product.getSnCode());
+                map.put("addWord2_color", "218,185,107");
+                map.put("addWord2_type", "思源宋体");
+                map.put("addWord2_style", Font.BOLD);
+                map.put("addWord2_size", (int) Math.round(90 * rate));
+                map.put("addWord2_x", (int) Math.round(2168 * rate));
+                map.put("addWord2_y", (int) Math.round(3160 * rate));
+            }
+            // 添加认证日期信息
+            if (null != product.getCreateTime()) {
+                SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
+                map.put("addWord3_content", format.format(product.getCreateTime()));
+                map.put("addWord3_color", "218,185,107");
+                map.put("addWord3_type", "思源宋体");
+                map.put("addWord3_style", Font.PLAIN);
+                map.put("addWord3_size", (int) Math.round(90 * rate));
+                map.put("addWord3_x", (int) Math.round(2085 * rate));
+                map.put("addWord3_y", (int) Math.round(3292 * rate));
+            }
+            // 添加二维码信息
+            if (StringUtils.isNotEmpty(template.getQrPosition())) {
+                String qrCodeLink = wwwServer + "/product/auth/product-" + product.getProductId() + ".html";
+                map.put("addQr1_link", qrCodeLink);
+                map.put("addQr1_size", template.getQrSize());
+                String[] split = template.getQrPosition().split(",");
+                if (split.length == 2) {
+                    map.put("addQr1_x", Integer.parseInt(split[0]));
+                    map.put("addQr1_y", Integer.parseInt(split[1]));
+                }
+            }
+        }
+        return map;
+    }
+
     private String addWaterMark(String image,Integer type) throws IOException {
         //type:1pc,2applets
         ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
@@ -359,7 +479,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         return imagePath;
     }
 
-    private String addQrCode(String certificateImage, Integer productId, Integer addTemplateType) throws IOException {
+    /*private String addQrCode(String certificateImage, Integer productId, Integer addTemplateType) throws IOException {
         String qrCodeLink = wwwServer + "/product/auth/product-" + productId + ".html";
         String qrCodeImage = ImageUtils.addQrCode(certificateImage, qrCodeLink, addTemplateType);
         String imagePath = null;
@@ -373,20 +493,17 @@ public class AuthProductServiceImpl implements AuthProductService {
             log.info(">>>>>>>>>>>>>>>>二维码图片上传失败");
         }
         return imagePath;
-    }
+    }*/
 
     @Override
-    public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
-        if (null == productId) {
-            return ResponseJson.error("参数异常,请输入商品id", null);
-        }
-        ProductFormVo productForm = authProductMapper.getProductFormByProductId(productId);
+    public ResponseJson<ProductFormVo> getProductFormData(Integer relationId) {
+        ProductFormVo productForm = authProductMapper.getProductFormData(relationId);
         if (null == productForm) {
-            return ResponseJson.error("商品不存在", null);
+            return ResponseJson.error("设备不存在", null);
         }
         List<ProductParamPo> paramList = authProductMapper.getProductTypeParamList(productForm.getProductTypeId());
         if (null == paramList || paramList.size() == 0) {
-            paramList = authProductMapper.getParamsByProductId(productId);
+            paramList = authProductMapper.getParamsByProductId(productForm.getProductId());
         }
         productForm.setParamList(paramList);
         return ResponseJson.success(productForm);
@@ -453,7 +570,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 if (null == productType) {
                     List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
                     try {
-                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getBrandId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
+                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getInfoId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
                         int code = result.getCode();
                         if (0 == code) {
                             productType = result.getData();
@@ -482,7 +599,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 if (null == productType) {
                     List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(productId);
                     try {
-                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getBrandId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
+                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getInfoId(), product.getName(), product.getImage(), product.getCreateBy(), paramList, 2);
                         int code = result.getCode();
                         if (0 == code) {
                             productType = result.getData();
@@ -505,11 +622,19 @@ public class AuthProductServiceImpl implements AuthProductService {
     @Override
     public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, String authParty, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
-        if (1 == listType && null == productTypeId) {
-            return ResponseJson.error("参数异常,请输入设备分类id", null);
+        if (1 == listType) {
+            if (null == productTypeId) {
+                return ResponseJson.error("参数异常,请输入设备分类id", null);
+            } else if (StringUtils.isEmpty(snCode) && StringUtils.isEmpty(authParty)) {
+                return ResponseJson.error("搜索条件不能为空", null);
+            }
         }
         PageHelper.startPage(pageNum, pageSize);
         List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, snCode);
+        productList.forEach(product->{
+            List<WxClubListVo> clubList = authProductMapper.getProductClubList(product.getProductId());
+            product.setClubList(clubList);
+        });
         PageInfo<WxProductListVo> pageData = new PageInfo<>(productList);
         return ResponseJson.success(pageData);
     }
@@ -520,32 +645,28 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (null == authProduct) {
             return ResponseJson.error("商品不存在", null);
         }
-        // 代理声明文件
-        if (null != authProduct.getStatementType() && authProduct.getStatementType() == 4) {
-            StatementFileVo statementFile = authProductMapper.getStatementFile(authProduct.getAuthUserId(), authProduct.getBrandId());
-            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-            // 设置URL过期时间为1个小时
-            Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
-            String url = ossClient.generatePresignedUrl(bucketName, active + "/authFile/" + statementFile.getOssName(), expiration).toString();
-            statementFile.setUrl(url);
-            ossClient.shutdown();
-            authProduct.setStatementFile(statementFile);
-        }
+        authProduct.setClubList(authProductMapper.getProductClubList(productId));
         // 商品参数
         authProduct.setParamList(authProductMapper.getAuthProductParams(productId));
+        // 增加扫码次数
+        authProductMapper.addScanCount(productId);
         return ResponseJson.success(authProduct);
     }
 
     @Override
-    public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, Integer brandId, String name, String image, Integer createBy, List<ProductParamPo> paramList, Integer createSource) throws IOException {
+    public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, Integer infoId, String name, String image, Integer createBy, List<ProductParamPo> paramList, Integer createSource) throws IOException {
         // 是否为添加操作
         boolean insertFlag = null == productTypeId;
+        ProductTypePo dbProductType = null;
+        if (!insertFlag) {
+            dbProductType = authProductMapper.getProductType(productTypeId, null, null);
+        }
         /*
          * 组装设备分类数据
          */
         ProductTypePo productType = new ProductTypePo();
         productType.setAuthUserId(authUserId);
-        productType.setBrandId(brandId);
+        productType.setInfoId(infoId);
         productType.setName(name);
         productType.setImage(image);
         productType.setCreateBy(createBy);
@@ -554,12 +675,19 @@ public class AuthProductServiceImpl implements AuthProductService {
         /*productType.setStatus(2);
         productType.setAuditStatus(2);*/
         // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
-        productType.setStatus(1 == createSource ? 1 : 2);
-        productType.setAuditStatus(1 == createSource ? 1 : 2);
+        if (null != dbProductType && 1 != dbProductType.getAuditStatus()) {
+            // 被驳回的数据,编辑变为待审核状态
+            productType.setStatus(2);
+            productType.setAuditStatus(2);
+        } else {
+            productType.setStatus(1 == createSource ? 1 : 2);
+            productType.setAuditStatus(1 == createSource ? 1 : 2);
+        }
         Integer adminUserId = authMapper.getAdminUserId();
         productType.setAuditBy(adminUserId);
         productType.setAuditTime(new Date());
         productType.setCreateSource(createSource);
+        productType.setCheckFlag(0);
         if (insertFlag) {
             // 创建人id
             productType.setCreateBy(createBy);
@@ -573,7 +701,6 @@ public class AuthProductServiceImpl implements AuthProductService {
         } else {
             // 设备分类id
             productType.setProductTypeId(productTypeId);
-            ProductTypePo dbProductType = authProductMapper.getProductType(productTypeId, null, null);
             // 设备分类图片是否重新上传
             boolean updateImageFlag = (StringUtils.isNotBlank(productType.getImage()) && !productType.getImage().equals(dbProductType.getImage()))
                     || (StringUtils.isEmpty(productType.getPcImage()) || StringUtils.isEmpty(productType.getAppletsImage()));
@@ -664,4 +791,37 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success(productType);
     }
 
+    @Override
+    public ResponseJson checkAuthProduct(Integer productId) {
+        authProductMapper.checkAuthProduct(productId);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode) {
+        ProductFormVo product =  authProductMapper.getProductInfo(productId, snCode);
+        if (null == product) {
+            return ResponseJson.error(-1, "设备SN码不存在", null);
+        }
+        if (2 == product.getAuditStatus()) {
+            return ResponseJson.error(-2, "设备待审核", null);
+        }
+        if (0 == product.getAuditStatus()) {
+            return ResponseJson.error(-3, "设备审核失败", null);
+        }
+        return ResponseJson.success(product);
+    }
+
+    @Override
+    public ResponseJson<List<String>> getSnCodeList(Integer authUserId, Integer authId) {
+        List<String> snCodeList = authProductMapper.getSnCodeList(authUserId, authId);
+        return ResponseJson.success(snCodeList);
+    }
+
+    @Override
+    public ResponseJson checkProductType(Integer productTypeId) {
+        authProductMapper.checkProductType(productTypeId);
+        return ResponseJson.success();
+    }
+
 }

+ 198 - 555
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -5,7 +5,6 @@ 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.*;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.AuthProductService;
@@ -13,38 +12,32 @@ import com.caimei.service.auth.AuthService;
 import com.caimei.service.auth.ShopService;
 import com.caimei.service.auth.UploadService;
 import com.caimei.utils.Base64Util;
-import com.caimei.utils.ExcelOperateUtil;
 import com.caimei.utils.ImageUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
 import javax.swing.*;
 import java.awt.*;
 import java.awt.Font;
-import java.awt.image.BufferedImage;
 import java.io.*;
 import java.math.BigDecimal;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Description
@@ -65,9 +58,6 @@ public class AuthServiceImpl implements AuthService {
     @Value("${caimei.zpapi}")
     private String zpServer;
 
-    @Resource
-    private AuthProductMapper authProductMapper;
-
     private AuthProductService authProductService;
 
     @Autowired
@@ -100,15 +90,11 @@ public class AuthServiceImpl implements AuthService {
 
     @Override
     public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
-                                                      String mobile, Integer status, Integer auditStatus, Integer lowerAuditStatus,
-                                                      Integer shopAuditStatus, Integer sendStatus,
-                                                      Integer pageNum, Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
+                                                      String mobile, Integer status, Integer starFlag, Integer auditStatus,
+                                                      Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
         PageHelper.startPage(pageNum, pageSize);
-        List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus);
+        List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus);
         PageInfo<AuthVo> pageData = new PageInfo<>(authList);
         return ResponseJson.success(pageData);
     }
@@ -164,7 +150,7 @@ public class AuthServiceImpl implements AuthService {
 
     @Override
     public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
-        List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null);
+        List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null, null);
         return ResponseJson.success(authList);
     }
 
@@ -199,6 +185,18 @@ public class AuthServiceImpl implements AuthService {
         return ResponseJson.success();
     }
 
+    @Override
+    public ResponseJson checkAuth(Integer authId) {
+        authMapper.checkAuth(authId);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson starAuth(Integer authId, Integer starFlag) {
+        authMapper.starAuth(authId, starFlag);
+        return ResponseJson.success();
+    }
+
     private void insertBanner(String pic, Integer authId) {
         if (StringUtils.isNotEmpty(pic)) {
             String imagePath = "https://wangdian.skinovachina.com" + pic;
@@ -215,18 +213,15 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public ResponseJson saveAuth(CmBrandAuthPo auth, List<String> bannerList, boolean importFlag, Integer source) {
         Integer authId = auth.getId();
-        Integer authUserId = auth.getAuthUserId();
-        String authParty = auth.getAuthParty();
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id");
+        boolean insertFlag = null == authId;
+        AuthVo dbAuth = null;
+        if (!insertFlag) {
+            dbAuth = authMapper.getAuthById(authId);
         }
+        String authParty = auth.getAuthParty();
         if (StringUtils.isBlank(authParty)) {
             return ResponseJson.error("参数异常,请输入授权机构名称");
         }
-        /*Integer authIdByAuthParty = authMapper.getAuthIdByAuthParty(authParty, authUserId);
-        if (null != authIdByAuthParty && !authIdByAuthParty.equals(authId)) {
-            return ResponseJson.error("参数异常,该授权机构已存在,请重新输入");
-        }*/
         if (null == auth.getFirstClubType()) {
             return ResponseJson.error("请勾选机构类型");
         }
@@ -264,21 +259,29 @@ public class AuthServiceImpl implements AuthService {
                 return ResponseJson.error("参数异常,请上传轮播图");
             }
         }
-        // 保存品牌授权信息,上线状态默认为“待上线”,审核状态为“待审核”
-        /*auth.setStatus(2);
-        auth.setAuditStatus(2);*/
         // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
-        auth.setStatus(1 == source ? 1 : 2);
-        auth.setAuditStatus(1 == source ? 1 : 2);
+        if (null != dbAuth && 1 != dbAuth.getAuditStatus()) {
+            // 被驳回的数据,编辑变为待审核状态
+            auth.setStatus(2);
+            auth.setAuditStatus(2);
+        } else {
+            auth.setStatus(1 == source ? 1 : 2);
+            auth.setAuditStatus(1 == source ? 1 : 2);
+        }
         Integer adminUserId = authMapper.getAdminUserId();
         auth.setAuditBy(adminUserId);
         auth.setAuditTime(new Date());
+        if (1 == source) {
+            auth.setShopAuditBy(auth.getCreateBy());
+            auth.setShopAuditTime(new Date());
+        }
         auth.setDelFlag(0);
+        auth.setCheckFlag(0);
         auth.setShopAuditStatus(1 == source ? 1 : 2);
         /*
             保存授权
          */
-        if (null == authId) {
+        if (insertFlag) {
             authMapper.insertAuth(auth);
         } else {
             authMapper.updateAuthByAuthId(auth);
@@ -293,12 +296,12 @@ public class AuthServiceImpl implements AuthService {
             TemplateVo authTemplate = authMapper.getAuthTemplate(auth.getId(), null, 1);
             authImage = generateAuthImage(authTemplate, auth);
             auth.setAuthImage(authImage);
-            // 添加水印
-            if (StringUtils.isNotEmpty(authImage)) {
-                auth.setPcAuthImage(addWaterMark(authImage, 1));
-                auth.setAppletsAuthImage(addWaterMark(authImage, 2));
-                authMapper.updateAuthImage(auth);
-            }
+        }
+        // 添加水印
+        if (StringUtils.isNotEmpty(auth.getAuthImage())) {
+            auth.setPcAuthImage(addWaterMark(auth.getAuthImage(), 1));
+            auth.setAppletsAuthImage(addWaterMark(auth.getAuthImage(), 2));
+            authMapper.updateAuthImage(auth);
         }
         // 保存轮播图
         if (null != bannerList) {
@@ -395,7 +398,7 @@ public class AuthServiceImpl implements AuthService {
                 map.put("addWord1_style", Font.BOLD);
                 map.put("addWord1_size", (int) Math.round(90 * rate));
                 map.put("addWord1_x", (int) Math.round(2168 * rate));
-                map.put("addWord1_y", (int) Math.round(3165 * rate));
+                map.put("addWord1_y", (int) Math.round(3160 * rate));
             }
             // 添加认证日期信息
             if (null != auth.getAuthDate()) {
@@ -434,9 +437,6 @@ public class AuthServiceImpl implements AuthService {
         if (auditStatus == 0 && StringUtils.isEmpty(invalidReason)) {
             return ResponseJson.error("请输入审核不通过的原因");
         }
-        if (auditBy == null) {
-            return ResponseJson.error("请输入审核人用户id");
-        }
         source = null == source ? 1 : source;
         Date auditTime = new Date();
         // 授权状态更新
@@ -455,11 +455,12 @@ public class AuthServiceImpl implements AuthService {
         if (2 == source) {
             authMapper.updateAuthShopAuditStatus(authId, status, auditStatus, invalidReason, auditBy, auditTime);
         }
-        return ResponseJson.success("审核品牌授权成功");
+        return ResponseJson.success("审核机构认证成功");
     }
 
 
     @Override
+    @Transactional(rollbackFor=Exception.class)
     public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
         String originalFilename = file.getOriginalFilename();
         String randomStr = UUID.randomUUID().toString();
@@ -485,42 +486,6 @@ public class AuthServiceImpl implements AuthService {
         return null;
     }
 
-    @Override
-    public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
-        try {
-            // 导出表格名
-            String fileName = new String("机构商品数据.xls".getBytes("UTF-8"),"iso-8859-1");
-            // 机构数据
-            List<CmBrandAuthPo> authPartyList = authMapper.getAuthPartyList(authUserId);
-            authPartyList.forEach(authParty->{
-                // 商品参数数量最大值
-                final Integer[] maxParamNum = {0};
-                Integer authId = authParty.getId();
-                List<ProductFormVo> productList = authProductMapper.getAuthProductList(authId);
-                productList.forEach(product->{
-                    // 参数列表
-                    List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(product.getProductId());
-                    product.setParamList(paramList);
-                    if (paramList.size() > maxParamNum[0]) {
-                        maxParamNum[0] = paramList.size();
-                    }
-                });
-                authParty.setMaxParamNum(maxParamNum[0]);
-                authParty.setProductList(productList);
-            });
-            OutputStream outputStream = response.getOutputStream();
-            response.reset();
-            response.setHeader("Access-Control-Allow-Origin", "*");
-            response.setHeader("Access-Control-Allow-Credentials", "true");
-            response.setHeader("Content-disposition",
-                    "attachment; filename="+fileName);
-            response.setContentType("application/vnd.ms-excel");
-            return exportData(authPartyList, outputStream);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return ResponseJson.error("导出失败");
-        }
-    }
 
     private ResponseJson saveExcelData(String filePath, Integer authUserId, Integer createBy) {
         //判断是否为excel类型文件
@@ -531,182 +496,173 @@ public class AuthServiceImpl implements AuthService {
         List<String> shopBrands = shopService.getShopBrands(authUserId);
 
         // 授权列表
-        List<AuthImportPo> authImportList = new ArrayList<>();
-
-        List<String> tempImageList = new ArrayList<>();
+        List<CmBrandAuthPo> authImportList = new ArrayList<>();
 
         try {
             FileInputStream fis = new FileInputStream(filePath);
             // 得到表格数据
             XSSFWorkbook workbook = new XSSFWorkbook(fis);
-            // 获取工作表数量
-            int sheetsNum = workbook.getNumberOfSheets();
 
             //得到第一个工作表(机构表)
             XSSFSheet authPartySheet = workbook.getSheetAt(0);
             //获得表头
             Row rowHead = authPartySheet.getRow(0);
             //判断表头是否正确
-            if (1 != rowHead.getLastCellNum() || !"授权机构".equals(rowHead.getCell(0).getStringCellValue())) {
+            if (9 != rowHead.getLastCellNum() || !"机构名称".equals(rowHead.getCell(0).getStringCellValue())) {
                 return ResponseJson.error("授权机构表格式错误");
             }
             // 获得数据的总行数
             int authPartyRowNum = authPartySheet.getLastRowNum();
-            // 商品sn码列表
-            List<String> snCodeList = new ArrayList<>();
 
             //获得所有数据
             for (int i = 1; i <= authPartyRowNum; i++) {
                 //获得第i行对象
-                Row row = authPartySheet.getRow(i);
-                //获得获得第i行第0列的机构名称
-                Cell cell = row.getCell(0);
-                // 机构名称
+                Row authPartyRow = authPartySheet.getRow(i);
+                if (null == authPartyRow) {
+                    break;
+                }
+                Cell cell = null;
+                // 校验机构名称
+                cell = authPartyRow.getCell(0);
+                cell.setCellType(CellType.STRING);
                 String authParty = cell.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 (StringUtils.isBlank(authParty)) {
+                    return ResponseJson.error("第" + i + 1 + "行机构名称不能为空");
+                }
+                // 校验省市区
+                cell = authPartyRow.getCell(1);
+                cell.setCellType(CellType.STRING);
+                String area = cell.getStringCellValue();
+                if (StringUtils.isBlank(area)) {
+                    return ResponseJson.error("第" + i + 1 + "行所在地区不能为空");
+                }
+                String[] areaSplit = area.split("/");
+                if (areaSplit.length < 2 || areaSplit.length > 3) {
+                    return ResponseJson.error("第" + i + 1 + "行所在地区格式错误");
+                }
+                // 省份
+                String provinceName = areaSplit[0];
+                if (StringUtils.isBlank(provinceName)) {
+                    return ResponseJson.error("第" + i + 1 + "行省份不能为空");
+                }
+                if (provinceName.length() > 2) {
+                    provinceName = provinceName.substring(0, provinceName.length() - 1).trim();
+                }
+                Integer provinceId = authMapper.getProvinceId(provinceName);
+                // 市名
+                String cityName = areaSplit[1];
+                if (StringUtils.isBlank(cityName)) {
+                    return ResponseJson.error("第" + i + 1 + "行市名不能为空");
+                }
+                if (cityName.length() > 2) {
+                    cityName = cityName.substring(0, cityName.length() - 1).trim();
+                }
+                Integer cityId = authMapper.getCityId(cityName);
+                Integer townId = null;
+                if (areaSplit.length > 2) {
+                    // 区名
+                    String townName = areaSplit[2];
+                    if (StringUtils.isNotEmpty(townName) && townName.length() > 2) {
+                        townName = townName.substring(0, townName.length() - 1).trim();
                     }
-                    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);
-                                    }
+                    List<TownPo> townList = authMapper.getTownList(townName);
+                    for (int j = 0; j < townList.size(); j++) {
+                        TownPo town = townList.get(j);
+                        if (null == townId) {
+                            if (null != cityId) {
+                                if (town.getCityId().equals(cityId)) {
+                                    townId = town.getTownId();
                                 }
-                                // 校验品牌名称
-                                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();
-                                        }
+                            } else {
+                                Integer checkCityId = authMapper.getCityIdByTownId(town.getTownId());
+                                if (null != provinceId && null != checkCityId) {
+                                    Integer checkProvinceId = authMapper.getProvinceIdByCityId(cityId);
+                                    if (provinceId.equals(checkProvinceId)) {
+                                        cityId = checkCityId;
+                                        townId = town.getTownId();
                                     }
-                                    return ResponseJson.error(errorReason);
                                 }
-                                /*
-                                    组装商品数据
-                                 */
-                                ProductSaveDto product = new ProductSaveDto();
-                                // 品牌id
-                                product.setBrandId(brandId);
-                                // 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);
                 }
+                // 校验详细地址
+                cell = authPartyRow.getCell(2);
+                cell.setCellType(CellType.STRING);
+                String address = cell.getStringCellValue();
+                if (StringUtils.isBlank(address)) {
+                    return ResponseJson.error("第" + i + 1 + "行详细地址不能为空");
+                }
+                // 校验经纬度
+                cell = authPartyRow.getCell(3);
+                cell.setCellType(CellType.STRING);
+                String lngAndLat = cell.getStringCellValue();
+                if (StringUtils.isBlank(lngAndLat)) {
+                    return ResponseJson.error("第" + i + 1 + "行经纬度不能为空");
+                }
+                String[] split = lngAndLat.split(",");
+                if (2 != split.length) {
+                    return ResponseJson.error("第" + i + 1 + "行经纬度格式错误");
+                }
+                BigDecimal lng = new BigDecimal(split[0]);
+                BigDecimal lat = new BigDecimal(split[1]);
+                // 校验联系电话
+                cell = authPartyRow.getCell(4);
+                cell.setCellType(CellType.STRING);
+                String mobile = cell.getStringCellValue();
+                if (StringUtils.isBlank(mobile)) {
+                    return ResponseJson.error("第" + i + 1 + "行联系电话不能为空");
+                }
+                // 认证编号
+                cell = authPartyRow.getCell(5);
+                cell.setCellType(CellType.STRING);
+                String authCode = cell.getStringCellValue();
+                // 认证日期
+                Date authDate = null;
+                cell = authPartyRow.getCell(6);
+                cell.setCellType(CellType.STRING);
+                String authDateStr = cell.getStringCellValue();
+                if (StringUtils.isNotBlank(authDateStr)) {
+                    SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
+                    authDate = format.parse(authDateStr);
+                }
+                // 校验员工人数
+                Integer empNum = null;
+                cell = authPartyRow.getCell(7);
+                cell.setCellType(CellType.STRING);
+                String empNumStr = cell.getStringCellValue();
+                if (StringUtils.isBlank(empNumStr)) {
+                    return ResponseJson.error("第" + i + 1 + "行员工人数不能为空");
+                }
+                try {
+                    empNum = Integer.parseInt(empNumStr);
+                } catch (Exception e) {
+                    return ResponseJson.error("第" + i + 1 + "行员工人数格式错误");
+                }
+                // 校验店铺备注
+                cell = authPartyRow.getCell(8);
+                cell.setCellType(CellType.STRING);
+                String remarks = cell.getStringCellValue();
+                Integer customFlag = 0;
+                if (StringUtils.isNotEmpty(remarks)) {
+                    customFlag = 1;
+                }
+                CmBrandAuthPo authPo = new CmBrandAuthPo();
+                authPo.setAuthParty(authParty);
+                authPo.setProvinceId(provinceId);
+                authPo.setCityId(cityId);
+                authPo.setTownId(townId);
+                authPo.setAddress(address);
+                authPo.setLng(lng);
+                authPo.setLat(lat);
+                authPo.setMobile(mobile);
+                authPo.setAuthCode(authCode);
+                authPo.setAuthDate(authDate);
+                authPo.setAuthImageType(1);
+                authPo.setEmpNum(empNum);
+                authPo.setCustomFlag(customFlag);
+                authPo.setRemarks(remarks);
+                authImportList.add(authPo);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -716,337 +672,24 @@ public class AuthServiceImpl implements AuthService {
             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);
+        for (int i = 0; i < authImportList.size(); i++) {
+            CmBrandAuthPo authPo = authImportList.get(i);
             // 保存授权机构
-            if (null == authId) {
-                CmBrandAuthPo auth = new CmBrandAuthPo();
-                auth.setAuthUserId(authUserId);
-                auth.setAuthParty(authParty);
-                auth.setCreateBy(createBy);
-                // 导入数据
-                ResponseJson responseJson = saveAuth(auth, null, true, 1);
-                CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
-                authId = authPo.getId();
+            authPo.setAuthUserId(authUserId);
+            authPo.setCreateBy(createBy);
+            authPo.setCreateSource(1);
+            authPo.setFirstClubType(5);
+            // 导入数据
+            ResponseJson result = saveAuth(authPo, null, true, 1);
+            if (result.getCode() != 0) {
+                // 设置手动回滚事务
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return ResponseJson.error("导入失败");
             }
-            Integer finalAuthId = authId;
-            // 保存商品列表
-            productList.forEach(productDto -> {
-                try {
-                    productDto.setAuthId(finalAuthId);
-                    // 上传商品图片和授权牌照
-                    String productImage = productDto.getProductImage();
-                    String certificateImage = productDto.getCertificateImage();
-                    productDto.setProductImage(productImage);
-                    productDto.setCertificateImage(certificateImage);
-                    productDto.setSource(1);
-                    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();
-            // 创建机构工作表
-            HSSFSheet authPartySheet = workbook.createSheet("授权机构");
-            // sheet样式定义
-            HSSFCellStyle topCellStyle = this.getTopCellStyle(workbook);
-            HSSFCellStyle customCellStyle = this.getCustomCellStyle(workbook);
-            // 创建列头行
-            HSSFRow topRow = authPartySheet.createRow(0);
-            HSSFCell topRowCell = topRow.createCell(0);
-            topRowCell.setCellType(CellType.valueOf("STRING"));
-            HSSFRichTextString text = new HSSFRichTextString("授权机构");
-            topRowCell.setCellValue(text);
-            topRowCell.setCellStyle(topCellStyle);
-            // 行索引
-            AtomicInteger authPartyRowNum = new AtomicInteger(1);
-            // 每个机构创建一行数据
-            authPartyList.forEach(authParty -> {
-                HSSFRow authPartyRow = authPartySheet.createRow(authPartyRowNum.get());
-                HSSFCell authPartyCell = authPartyRow.createCell(0);
-                authPartyCell.setCellType(CellType.valueOf("STRING"));
-                HSSFRichTextString authPartyName = new HSSFRichTextString(authParty.getAuthParty().trim());
-                authPartyCell.setCellValue(authPartyName);
-                authPartyCell.setCellStyle(customCellStyle);
-                authPartyRowNum.getAndIncrement();
-            });
-            // 让列宽随着导出的列长自动适应
-            int columnWidth = authPartySheet.getColumnWidth(0) / 256;
-            for (int rowNum = 0; rowNum < authPartySheet.getLastRowNum(); rowNum++) {
-                HSSFRow currentRow;
-                // 当前行未被使用过
-                if (authPartySheet.getRow(rowNum) == null) {
-                    currentRow = authPartySheet.createRow(rowNum);
-                } else {
-                    currentRow = authPartySheet.getRow(rowNum);
-                }
-                if (currentRow.getCell(0) != null) {
-                    HSSFCell currentCell = currentRow.getCell(0);
-                    if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
-                        int length = currentCell.getStringCellValue()
-                                .getBytes().length;
-                        if (columnWidth < length) {
-                            columnWidth = length;
-                        }
-                    }
-                }
-            }
-            authPartySheet.setColumnWidth(0, (columnWidth + 4) * 256);
-            List<String> sheetNameList = new ArrayList<>();
-            // 创建每个机构对应的商品表
-            authPartyList.forEach(authParty -> {
-                // 授权机构名称作为表名
-                String productSheetName = authParty.getAuthParty();
-                // 商品列表
-                List<ProductFormVo> productList = authParty.getProductList();
-                // 创建商品工作表
-                int k = 1;
-                while (sheetNameList.contains(productSheetName)) {
-                    productSheetName = productSheetName.replace("(" + (k-1) + ")", "") + "(" + k + ")";
-                    k++;
-                }
-                sheetNameList.add(productSheetName);
-                HSSFSheet productSheet = workbook.createSheet(productSheetName);
-                // 创建列头行
-                HSSFRow productTopRow = productSheet.createRow(0);
-                // 添加列头单元格(5个固定列+参数列表)
-                String[] rowName = {"商品名称", "商品SN码", "所属品牌", "商品图片(尺寸:128px×88px)",
-                        "授权牌(尺寸:128px×88px)", "参数名称1", "参数值1", "参数名称2", "参数值2", "参数名称3",
-                        "参数值3", "参数名称4", "参数值4", "参数名称5", "参数值5", "参数名称6", "参数值6", "参数名称7",
-                        "参数值7", "参数名称8", "参数值8", "参数名称9", "参数值9", "参数名称10", "参数值10", "参数名称11",
-                        "参数值11", "参数名称12", "参数值12"};
-                for (int i = 0; i < 5 + (0 == authParty.getMaxParamNum() ? 4 : authParty.getMaxParamNum()) * 2; i++) {
-                    HSSFCell productTopRowCell = productTopRow.createCell(i);
-                    productTopRowCell.setCellType(CellType.valueOf("STRING"));
-                    HSSFRichTextString columnText = new HSSFRichTextString(rowName[i]);
-                    productTopRowCell.setCellValue(columnText);
-                    productTopRowCell.setCellStyle(topCellStyle);
-                }
-                // 添加商品数据到单元格中
-                // 行索引
-                AtomicInteger productRowNum = new AtomicInteger(1);
-                productList.forEach(product -> {
-                    // 创建商品行
-                    HSSFRow productRow = productSheet.createRow(productRowNum.get());
-                    // 设置行高度
-                    productRow.setHeight((short) 2200);
-                    // 参数列表
-                    List<ProductParamPo> paramList = product.getParamList();
-                    // 组装商品数据
-                    List<String> productData = new ArrayList<>();
-                    productData.add(product.getProductName());
-                    productData.add(product.getSnCode());
-                    productData.add(product.getBrandName());
-                    productData.add(product.getProductImage());
-                    productData.add(product.getCertificateImage());
-                    paramList.forEach(param -> {
-                        productData.add(param.getParamName());
-                        productData.add(param.getParamContent());
-                    });
-                    for (int j = 0; j < 5 + paramList.size() * 2; j++) {
-                        HSSFCell productCell = productRow.createCell(j);
-                        if (j == 3 || j == 4) {
-//                            productSheet.addMergedRegion(new CellRangeAddress(j + 1,j + 1,j + 1,j + 1)) ;
-                            // 头像
-                            String imageUrl = productData.get(j);
-                            if (StringUtils.isNotEmpty(imageUrl)) {
-
-                                String fileType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
-                                InputStream imageStream = getImageStream(imageUrl);
-                                if (null != imageStream) {
-                                    try {
-                                        BufferedImage bufferedImage = ImageIO.read(imageStream);
-                                        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
-                                        ImageIO.write(bufferedImage, fileType, byteArrayOut);
-                                        byte[] data = byteArrayOut.toByteArray();
-                                        HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
-                                        // 设置图片位置
-                                        HSSFClientAnchor anchor = new HSSFClientAnchor(30, 30, 700, 200, (short) j, productRowNum.get(), (short) j, productRowNum.get());
-                                        drawingPatriarch.createPicture(anchor, workbook.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
-                                    } catch (Exception e) {
-                                        e.printStackTrace();
-                                    }
-                                } else {
-                                    productCell.setCellType(CellType.valueOf("STRING"));
-                                    productCell.setCellValue("");
-                                }
-                            } else {
-                                productCell.setCellType(CellType.valueOf("STRING"));
-                                productCell.setCellValue("");
-                            }
-                        } else {
-                            productCell.setCellType(CellType.valueOf("STRING"));
-                            HSSFRichTextString productCellValue = new HSSFRichTextString(productData.get(j));
-                            productCell.setCellValue(productCellValue);
-                            productCell.setCellStyle(customCellStyle);
-                        }
-                    }
-                    productRowNum.getAndIncrement();
-                });
-
-                // 让列宽随着导出的列长自动适应
-                for (int colNum = 0; (colNum < 5 + authParty.getMaxParamNum() * 2); colNum++) {
-                    if (colNum == 3 || colNum == 4) {
-                        productSheet.setColumnWidth(colNum, 8200);
-                    } else {
-                        int productColumnWidth = productSheet.getColumnWidth(colNum) / 256;
-                        for (int rowNum = 0; rowNum < productSheet.getLastRowNum(); rowNum++) {
-                            HSSFRow currentRow;
-                            // 当前行未被使用过
-                            if (productSheet.getRow(rowNum) == null) {
-                                currentRow = productSheet.createRow(rowNum);
-                            } else {
-                                currentRow = productSheet.getRow(rowNum);
-                            }
-                            if (currentRow.getCell(colNum) != null) {
-                                HSSFCell currentCell = currentRow.getCell(colNum);
-                                if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
-                                    int length = currentCell.getStringCellValue()
-                                            .getBytes().length;
-                                    if (productColumnWidth < length) {
-                                        productColumnWidth = length;
-                                    }
-                                }
-                            }
-                        }
-                        productSheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
-                    }
-                }
-
-            });
-            outputStream.flush();
-            workbook.write(outputStream);
-            outputStream.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-            return ResponseJson.error("导出失败");
         }
-        return ResponseJson.success("导出成功");
-    }
-
-    private String uploadImage(String filePath) throws IOException {
-        // 临时图片
-        File tempFile = new File(filePath);
-        log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
-        String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
-        return imageUrl;
-    }
-
-
-    /**
-     * 列头单元格样式
-     */
-    private HSSFCellStyle getTopCellStyle(HSSFWorkbook workbook) {
-
-        // 设置字体
-        HSSFFont font = workbook.createFont();
-        // 设置字体大小
-        font.setFontHeightInPoints((short) 11);
-        // 字体加粗
-        font.setBold(true);
-        // 设置字体名字
-        font.setFontName("Courier New");
-        // 设置样式;
-        HSSFCellStyle style = workbook.createCellStyle();
-        // 设置底边框;
-        style.setBorderBottom(BorderStyle.THIN);
-        // 设置底边框颜色;
-        style.setBottomBorderColor(IndexedColors.BLACK.index);
-        // 设置左边框;
-        style.setBorderLeft(BorderStyle.THIN);
-        // 设置左边框颜色;
-        style.setLeftBorderColor(IndexedColors.BLACK.index);
-        // 设置右边框;
-        style.setBorderRight(BorderStyle.THIN);
-        // 设置右边框颜色;
-        style.setRightBorderColor(IndexedColors.BLACK.index);
-        // 设置顶边框;
-        style.setBorderTop(BorderStyle.THIN);
-        // 设置顶边框颜色;
-        style.setTopBorderColor(IndexedColors.BLACK.index);
-        // 在样式用应用设置的字体;
-        style.setFont(font);
-        // 设置自动换行;
-        style.setWrapText(false);
-        // 设置水平对齐的样式为居中对齐;
-        style.setAlignment(HorizontalAlignment.CENTER);
-        // 设置垂直对齐的样式为居中对齐;
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-
-        return style;
-    }
-
-    /**
-     * 列数据信息单元格样式
-     */
-    private HSSFCellStyle getCustomCellStyle(HSSFWorkbook workbook) {
-        // 设置字体
-        HSSFFont font = workbook.createFont();
-        // 设置字体大小
-        // font.setFontHeightInPoints((short)10);
-        // 字体加粗
-        // font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
-        // 设置字体名字
-        font.setFontName("Courier New");
-        // 设置样式;
-        HSSFCellStyle style = workbook.createCellStyle();
-        // 设置底边框;
-        style.setBorderBottom(BorderStyle.THIN);
-        // 设置底边框颜色;
-        style.setBottomBorderColor(IndexedColors.BLACK.index);
-        // 设置左边框;
-        style.setBorderLeft(BorderStyle.THIN);
-        // 设置左边框颜色;
-        style.setLeftBorderColor(IndexedColors.BLACK.index);
-        // 设置右边框;
-        style.setBorderRight(BorderStyle.THIN);
-        // 设置右边框颜色;
-        style.setRightBorderColor(IndexedColors.BLACK.index);
-        // 设置顶边框;
-        style.setBorderTop(BorderStyle.THIN);
-        // 设置顶边框颜色;
-        style.setTopBorderColor(IndexedColors.BLACK.index);
-        // 在样式用应用设置的字体;
-        style.setFont(font);
-        // 设置自动换行;
-        style.setWrapText(false);
-        // 设置水平对齐的样式为居中对齐;
-        style.setAlignment(HorizontalAlignment.CENTER);
-        // 设置垂直对齐的样式为居中对齐;
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-        return style;
+        return ResponseJson.success("导入成功");
     }
 
-
-    public InputStream getImageStream(String url) {
-        try {
-            HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
-            connection.setReadTimeout(5000);
-            connection.setConnectTimeout(5000);
-            connection.setRequestMethod("GET");
-            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
-                InputStream inputStream = connection.getInputStream();
-                return inputStream;
-            }
-        } catch (IOException e) {
-            System.out.println("获取网络图片出现异常,图片路径为:" + url);
-            e.printStackTrace();
-        }
-        return null;
-    }
 }

+ 28 - 15
src/main/java/com/caimei/service/auth/impl/DoctorServiceImpl.java

@@ -1,5 +1,6 @@
 package com.caimei.service.auth.impl;
 
+import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.DoctorMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
 import com.caimei.model.ResponseJson;
@@ -27,6 +28,9 @@ import java.util.*;
 @Service
 public class DoctorServiceImpl implements DoctorService {
 
+    @Resource
+    private AuthMapper authMapper;
+
     @Resource
     private DoctorMapper doctorMapper;
 
@@ -41,12 +45,6 @@ public class DoctorServiceImpl implements DoctorService {
 
     @Override
     public ResponseJson<PageInfo<DoctorListVo>> getDoctorList(Integer listType, Integer authUserId, Integer doctorType, String doctorName, String certificateNo, Integer status, Integer auditStatus, Integer pageNum, Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
-        if (null == doctorType) {
-            return ResponseJson.error("参数异常,医师类型不能为空", null);
-        }
         listType = null == listType ? 1 : listType;
         PageHelper.startPage(pageNum, pageSize);
         List<DoctorListVo> doctorList = doctorMapper.getDoctorList(listType, authUserId, doctorType, doctorName, certificateNo, status, auditStatus);
@@ -119,9 +117,6 @@ public class DoctorServiceImpl implements DoctorService {
         Integer doctorId = doctor.getId();
         Integer authUserId = doctor.getAuthUserId();
         String certificateNo = doctor.getCertificateNo();
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id");
-        }
         if (StringUtils.isBlank(doctor.getName())) {
             return ResponseJson.error("参数异常,请输入医师名称");
         }
@@ -155,9 +150,24 @@ public class DoctorServiceImpl implements DoctorService {
         if (1 == doctor.getDoctorType() && (null == equipmentList || equipmentList.size() <= 0)) {
             return ResponseJson.error("参数异常,请上传设备列表");
         }
-        // 保存医师信息,上线状态默认为“待上线”,审核状态为“待审核”
-        doctor.setStatus(2);
-        doctor.setAuditStatus(2);
+        boolean insertFlag = null == doctorId;
+        CmBrandDoctorPo dbDoctor = null;
+        if (!insertFlag) {
+            dbDoctor = doctorMapper.getDoctorById(doctorId);
+        }
+        // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
+        if (null != dbDoctor && 1 != dbDoctor.getAuditStatus()) {
+            // 被驳回的数据,编辑变为待审核状态
+            doctor.setStatus(2);
+            doctor.setAuditStatus(2);
+        } else {
+            doctor.setStatus(1);
+            doctor.setAuditStatus(1);
+        }
+        Integer adminUserId = authMapper.getAdminUserId();
+        doctor.setAuditBy(adminUserId);
+        doctor.setAuditTime(new Date());
+        doctor.setCheckFlag(0);
         /*
             保存医师
          */
@@ -196,9 +206,6 @@ public class DoctorServiceImpl implements DoctorService {
         if (auditStatus == 0 && StringUtils.isEmpty(invalidReason)) {
             return ResponseJson.error("请输入审核不通过的原因");
         }
-        if (auditBy == null) {
-            return ResponseJson.error("请输入审核人用户id");
-        }
         Date auditTime = new Date();
         // 医师状态更新
         Integer status = null;
@@ -251,4 +258,10 @@ public class DoctorServiceImpl implements DoctorService {
         doctor.setParamList(paramList);
         return ResponseJson.success(doctor);
     }
+
+    @Override
+    public ResponseJson checkDoctor(Integer doctorId) {
+        doctorMapper.checkDoctor(doctorId);
+        return ResponseJson.success();
+    }
 }

+ 354 - 46
src/main/java/com/caimei/service/auth/impl/DownloadServiceImpl.java

@@ -1,32 +1,39 @@
 package com.caimei.service.auth.impl;
 
 import com.aliyuncs.utils.StringUtils;
+import com.caimei.mapper.cmMapper.AuthMapper;
+import com.caimei.mapper.cmMapper.AuthProductMapper;
 import com.caimei.mapper.cmMapper.FileMapper;
-import com.caimei.model.en.QrCodeSize;
+import com.caimei.model.ResponseJson;
 import com.caimei.model.po.ProductImagePo;
+import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.UploadFilePo;
+import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.service.auth.DownloadService;
 import com.caimei.service.auth.UploadService;
-import com.caimei.utils.ImageUtils;
+import com.caimei.utils.FileIOUtils;
 import com.caimei.utils.OSSUtils;
+import com.caimei.utils.PoiUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
 import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Description
@@ -41,6 +48,12 @@ public class DownloadServiceImpl implements DownloadService {
     @Resource
     private FileMapper fileMapper;
 
+    @Resource
+    private AuthMapper authMapper;
+
+    @Resource
+    private AuthProductMapper authProductMapper;
+
     private UploadService uploadService;
 
     @Value("${caimei.oldapi}")
@@ -64,40 +77,53 @@ public class DownloadServiceImpl implements DownloadService {
     }
 
     @Override
-    public void downloadShopImage(Integer authUserId, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception {
-        if (null == authUserId || null == type) {
-            return;
-        }
+    public void downloadShopImage(String authIds, Integer type, HttpServletRequest request, HttpServletResponse response) throws Exception {
         ArrayList<UploadFilePo> fileList = new ArrayList<>();
-        List<ProductImagePo> productImageList = fileMapper.getProductImageList(authUserId);
-        List<AuthVo> authImageList = fileMapper.getAuthImageList(authUserId);
+        HashMap<String, List<UploadFilePo>> fileMap = new HashMap<>();
+        List<AuthVo> authImageList = fileMapper.getAuthImageList(authIds);
         if (1 == type) {
-            productImageList.forEach(productImage -> {
-                UploadFilePo file = new UploadFilePo();
-                file.setFileUrl(productImage.getCertificateImage());
-                file.setFileName(productImage.getAuthParty() + "-" + productImage.getSnCode());
-                if (StringUtils.isNotEmpty(file.getFileUrl())) {
+            // 机构授权牌
+            List<String> fileNameList = new ArrayList<>();
+            authImageList.forEach(authImage ->{
+                if (StringUtils.isNotEmpty(authImage.getAuthImage())) {
+                    UploadFilePo file = new UploadFilePo();
+                    String fileName = authImage.getAuthParty();
+                    int k = 1;
+                    while (fileNameList.contains(fileName)) {
+                        fileName = fileName.replace("(" + (k-1) + ")", "") + "(" + k + ")";
+                        k++;
+                    }
+                    fileNameList.add(fileName);
+                    file.setFileUrl(authImage.getAuthImage());
+                    file.setFileName(fileName);
                     fileList.add(file);
                 }
             });
+            if (fileList.size() > 0) {
+                fileMap.put("机构授权牌", fileList);
+            }
         } else if (2 == type) {
-            productImageList.forEach(productImage -> {
-                String qrCodeLink = wwwServer + "/product/auth/product-" + productImage.getProductId() + ".html";
-                // 生成二维码
-                BufferedImage qrCodeImage = ImageUtils.createQrCode(qrCodeLink, QrCodeSize.XLARGE);
-                String fileName = productImage.getAuthParty() + "-" + productImage.getSnCode();
-                String imagePath = createBufferedImageFile(qrCodeImage, fileName, "png");
-                UploadFilePo file = new UploadFilePo();
-                file.setFileUrl(imagePath);
-                file.setFileName(productImage.getAuthParty() + "-" + productImage.getSnCode());
-                fileList.add(file);
+            // 设备授权牌
+            authImageList.forEach(authImage->{
+                List<ProductImagePo> productList = fileMapper.getProductImageList(authImage.getAuthId());
+                ArrayList<UploadFilePo> list = new ArrayList<>();
+                productList.forEach(product->{
+                    if (StringUtils.isNotEmpty(product.getCertificateImage())) {
+                        UploadFilePo file = new UploadFilePo();
+                        file.setFileUrl(product.getCertificateImage());
+                        file.setFileName(product.getProductName() + "-" + product.getSnCode());
+                        list.add(file);
+                    }
+                });
+                if (list.size() > 0) {
+                    fileMap.put(authImage.getAuthParty(), list);
+                }
             });
-        } else {
+        } else if (3 == type) {
+            // 机构二维码
             List<String> fileNameList = new ArrayList<>();
             authImageList.forEach(authImage -> {
-                String qrCodeLink = zpServer + "/" + authUserId + "/app/approve/club/detail?id=" + authImage.getAuthId();
-                // 生成二维码
-                BufferedImage qrCodeImage = ImageUtils.createQrCode(qrCodeLink, QrCodeSize.LARGE);
+                String qrCodeLink = zpServer + "/" + authImage.getAuthUserId() + "/app/approve/club/detail?id=" + authImage.getAuthId();
                 String fileName = authImage.getAuthParty();
                 int k = 1;
                 while (fileNameList.contains(fileName)) {
@@ -105,32 +131,314 @@ public class DownloadServiceImpl implements DownloadService {
                     k++;
                 }
                 fileNameList.add(fileName);
-                String imagePath = createBufferedImageFile(qrCodeImage, fileName, "png");
                 UploadFilePo file = new UploadFilePo();
-                file.setFileUrl(imagePath);
+                file.setFileUrl(qrCodeLink);
                 file.setFileName(authImage.getAuthParty());
                 fileList.add(file);
+//                String imagePath = createBufferedImageFile(qrCodeImage, fileName, "png");
+            });
+            if (fileList.size() > 0) {
+                fileMap.put("机构二维码", fileList);
+            }
+        } else {
+            // 设备二维码
+            authImageList.forEach(authImage->{
+                List<ProductImagePo> productList = fileMapper.getProductImageList(authImage.getAuthId());
+                ArrayList<UploadFilePo> list = new ArrayList<>();
+                productList.forEach(product->{
+                    String qrCodeLink = wwwServer + "/product/auth/product-" + product.getProductId() + ".html";
+                    UploadFilePo file = new UploadFilePo();
+                    file.setFileUrl(qrCodeLink);
+                    file.setFileName(product.getProductName() + "-" + product.getSnCode());
+                    list.add(file);
+                });
+                if (list.size() > 0) {
+                    fileMap.put(authImage.getAuthParty(), list);
+                }
             });
         }
-        String fileName = 1 == type ? "授权牌" : 2 == type ? "设备二维码" : "机构二维码";
+        String fileName = 1 == type ? "机构授权牌" : 2 == type ? "设备授权牌" : 3 == type ? "机构二维码" : "设备二维码";
         // 将授权牌压缩成zip文件
-        String imageZipPath = uploadService.createImageZip(fileList);
+        String imageZipPath = uploadService.createImageZip(fileMap, type);
         download(request, response, imageZipPath, fileName + ".zip");
+        // 删除临时文件夹
+        String tempPath = imageZipPath.substring(0, imageZipPath.lastIndexOf("/"));
+        File tempFile = new File(tempPath);
+        boolean delete = tempFile.delete();
+        log.info("【图片压缩包】,删除图片压缩包文件夹:" + delete);
+    }
+
+    @Override
+    public ResponseJson downloadAuthData(String authIds, HttpServletResponse response) {
+        try {
+            // 导出表格名
+            String fileName = new String("机构信息.xlsx".getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
+            // 机构数据
+            List<AuthFormVo> authPartyList = authMapper.getAuthPartyList(authIds);
+            OutputStream outputStream = response.getOutputStream();
+            response.reset();
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            response.setHeader("Access-Control-Allow-Credentials", "true");
+            response.setHeader("Content-disposition",
+                    "attachment; filename="+fileName);
+//            response.setContentType("application/vnd.ms-excel"); -- xls
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            return generateAuthExcel(authPartyList, outputStream);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseJson.error("导出失败");
+        }
+    }
+
+    @Override
+    public ResponseJson downloadProductData(String authIds, HttpServletRequest request, HttpServletResponse response) throws IOException {
+        HashMap<AuthVo, List<ProductFormVo>> fileMap = new HashMap<>();
+        // 机构列表
+        List<AuthVo> authImageList = fileMapper.getAuthImageList(authIds);
+        // 设备列表
+        authImageList.forEach(authImage->{
+            final Integer[] maxParamNum = {0};
+            List<ProductFormVo> productList = authProductMapper.getAuthProductList(authImage.getAuthId());
+            productList.forEach(product->{
+                // 参数列表
+                List<ProductParamPo> paramList = new ArrayList<>();
+                if (null == product.getProductTypeId()) {
+                    paramList = authProductMapper.getParamsByProductId(product.getProductId());
+                } else {
+                    paramList = authProductMapper.getProductTypeParamList(product.getProductTypeId());
+                }
+                product.setParamList(paramList);
+                if (paramList.size() > maxParamNum[0]) {
+                    maxParamNum[0] = paramList.size();
+                }
+            });
+            authImage.setMaxParamNum(maxParamNum[0]);
+            if (productList.size() > 0) {
+                fileMap.put(authImage, productList);
+            }
+        });
+        // 将授权牌压缩成zip文件
+        String imageZipPath = createExcelZip(fileMap);
+        download(request, response, imageZipPath, "设备信息.zip");
+        // 删除临时文件夹
+        String tempPath = imageZipPath.substring(0, imageZipPath.lastIndexOf("/"));
+        File tempFile = new File(tempPath);
+        boolean delete = tempFile.delete();
+        log.info("【图片压缩包】,删除图片压缩包文件夹:" + delete);
+        return null;
+    }
+
+    @Override
+    public void downloadAuthTemplate(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        String ossName = "认证通机构导入模板.xlsx";
+        OSSUtils.downFile("authFile/", ossName, ossName);
+        download(request, response, "./" + ossName, ossName);
     }
 
-    private String createBufferedImageFile(BufferedImage qrCodeImage, String fileName, String prefix) {
-        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/";
+    private String createExcelZip(HashMap<AuthVo, List<ProductFormVo>> authMap) throws FileNotFoundException {
+        String randomStr = UUID.randomUUID().toString();
+        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempImage/";
         if ("dev".equals(active)){
-            filePath = "D:\\WorkSpace\\file\\tempImport\\";
+            filePath = "D:\\uploadZip\\";
         }
-        filePath = filePath + fileName + "." + prefix;
-        File file = new File(filePath);
+        // 压缩文件夹上层临时文件夹路径
+        String tempPath = filePath + randomStr;
+        // 压缩文件夹路径
+        String basePath = "";
+        // 生成唯一临时文件夹
+        filePath += randomStr + "/";
+        // 在临时文件夹中生成要压缩的基础文件夹
+        String baseDirName = "设备信息";
+        filePath += baseDirName;
+        basePath = filePath;
+        File fileDir = new File(filePath);
+        if (!fileDir.exists()) {
+            fileDir.mkdirs();
+        }
+        // 往基础文件夹中填充相应数据
+        for (Map.Entry<AuthVo, List<ProductFormVo>> entry : authMap.entrySet()) {
+            AuthVo auth = entry.getKey();
+            List<ProductFormVo> productList = entry.getValue();
+            generateProductExcel(filePath, auth, productList);
+        }
+        // 将文件夹转为压缩文件
+        String zipPath = tempPath + "/" + baseDirName + ".zip";
+        FileOutputStream zipOut = new FileOutputStream(zipPath);
+        FileIOUtils.zipFolder(basePath, zipOut, true);
+        return zipPath;
+    }
+
+    private void generateProductExcel(String tempFilePath, AuthVo authParty, List<ProductFormVo> productList) {
+        String fileName = authParty.getAuthParty();
+        String filePath = tempFilePath + "/" + fileName + ".xlsx";
+        try {
+            FileOutputStream outputStream = new FileOutputStream(filePath);
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            // 创建设备工作表
+            XSSFSheet productSheet = workbook.createSheet("设备信息");
+            // sheet样式定义
+            XSSFCellStyle topCellStyle = PoiUtils.getXSSFTopCellStyle(workbook);
+            XSSFCellStyle customCellStyle = PoiUtils.getXSSFCustomCellStyle(workbook);
+            // 创建列头行
+            XSSFRow authTopRow = productSheet.createRow(0);
+            // 添加列头单元格(4个固定列+参数列表)
+            String[] rowName = {"设备名称", "设备SN码", "所属品牌", "购买渠道",
+                    "参数名1", "参数值1", "参数名2", "参数值2", "参数名3", "参数值3", "参数名4", "参数值4", "参数名5",
+                    "参数值5", "参数名6", "参数值6", "参数名7", "参数值7", "参数名8", "参数值8", "参数名9", "参数值9",
+                    "参数名10", "参数值10", "参数名11", "参数值11", "参数名12", "参数值12"};
+            for (int i = 0; i < 4 + (0 == authParty.getMaxParamNum() ? 4 : authParty.getMaxParamNum()) * 2; i++) {
+                XSSFCell authTopRowCell = authTopRow.createCell(i);
+                authTopRowCell.setCellType(CellType.valueOf("STRING"));
+                XSSFRichTextString columnText = new XSSFRichTextString(rowName[i]);
+                authTopRowCell.setCellValue(columnText);
+                authTopRowCell.setCellStyle(topCellStyle);
+            }
+            // 行索引
+            AtomicInteger productRowNum = new AtomicInteger(1);
+            productList.forEach(product->{
+                // 创建设备行
+                XSSFRow productRow = productSheet.createRow(productRowNum.get());
+                // 参数列表
+                List<ProductParamPo> paramList = product.getParamList();
+                // 组装设备数据
+                List<String> productData = new ArrayList<>();
+                productData.add(product.getProductName());
+                productData.add(product.getSnCode());
+                productData.add(product.getBrandName());
+                productData.add(product.getPurchaseWay());
+                paramList.forEach(param -> {
+                    productData.add(param.getParamName());
+                    productData.add(param.getParamContent());
+                });
+                for (int j = 0; j < 4 + paramList.size() * 2; j++) {
+                    XSSFCell productCell = productRow.createCell(j);
+                    productCell.setCellType(CellType.valueOf("STRING"));
+                    XSSFRichTextString productCellValue = new XSSFRichTextString(productData.get(j));
+                    productCell.setCellValue(productCellValue);
+                    productCell.setCellStyle(customCellStyle);
+                }
+                productRowNum.getAndIncrement();
+
+            });
+            // 让列宽随着导出的列长自动适应
+            for (int colNum = 0; colNum < rowName.length; colNum++) {
+                int productColumnWidth = productSheet.getColumnWidth(colNum) / 256;
+                for (int rowNum = 0; rowNum < productSheet.getLastRowNum(); rowNum++) {
+                    XSSFRow currentRow;
+                    // 当前行未被使用过
+                    if (productSheet.getRow(rowNum) == null) {
+                        currentRow = productSheet.createRow(rowNum);
+                    } else {
+                        currentRow = productSheet.getRow(rowNum);
+                    }
+                    if (currentRow.getCell(colNum) != null) {
+                        XSSFCell currentCell = currentRow.getCell(colNum);
+                        if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
+                            int length = currentCell.getStringCellValue()
+                                    .getBytes().length;
+                            if (productColumnWidth < length) {
+                                productColumnWidth = length;
+                            }
+                        }
+                    }
+                }
+                productSheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
+            }
+            workbook.write(outputStream);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private ResponseJson generateAuthExcel(List<AuthFormVo> authPartyList, OutputStream outputStream) {
         try {
-            ImageIO.write(qrCodeImage, prefix, file);
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            // 创建机构工作表
+            XSSFSheet authPartySheet = workbook.createSheet("授权机构");
+            // sheet样式定义
+            XSSFCellStyle topCellStyle = PoiUtils.getXSSFTopCellStyle(workbook);
+            XSSFCellStyle customCellStyle = PoiUtils.getXSSFCustomCellStyle(workbook);
+            // 创建列头行
+            XSSFRow authTopRow = authPartySheet.createRow(0);
+            // 添加列头单元格
+            String[] rowName = {"机构名称(必填)", "所在地区(必填)", "详细地址(必填)", "经纬度(必填)",
+                    "联系电话(必填)", "认证编号(选填)", "认证日期(选填)", "员工人数(必填)", "店铺备注(选填)"};
+            for (int i = 0; i < rowName.length; i++) {
+                XSSFCell authTopRowCell = authTopRow.createCell(i);
+                authTopRowCell.setCellType(CellType.valueOf("STRING"));
+                XSSFRichTextString columnText = new XSSFRichTextString(rowName[i]);
+                authTopRowCell.setCellValue(columnText);
+                authTopRowCell.setCellStyle(topCellStyle);
+            }
+            // 行索引
+            AtomicInteger authPartyRowNum = new AtomicInteger(1);
+
+            authPartyList.forEach(authParty -> {
+                // 创建机构行
+                XSSFRow authRow = authPartySheet.createRow(authPartyRowNum.get());
+                // 组装机构数据
+                List<String> authData = new ArrayList<>();
+                authData.add(authParty.getAuthParty());
+                authData.add(authParty.getArea());
+                authData.add(authParty.getAddress());
+                authData.add(authParty.getLngAndLat());
+                authData.add(authParty.getMobile());
+                authData.add(authParty.getAuthCode());
+                SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
+                Date authDate = authParty.getAuthDate();
+                if (null != authDate) {
+                    authData.add(format.format(authDate));
+                } else {
+                    authData.add("");
+                }
+                authData.add(authParty.getEmpNum().toString());
+                authData.add(authParty.getRemarks());
+                for (int j = 0; j < authData.size(); j++) {
+                    XSSFCell authCell = authRow.createCell(j);
+                    authCell.setCellStyle(customCellStyle);
+                    if (j == 7) {
+                        authCell.setCellType(CellType.NUMERIC);
+                        authCell.setCellValue(Integer.parseInt(authData.get(j)));
+                    } else {
+                        authCell.setCellType(CellType.valueOf("STRING"));
+                        XSSFRichTextString authCellValue = new XSSFRichTextString(authData.get(j));
+                        authCell.setCellValue(authCellValue);
+                    }
+                }
+                authPartyRowNum.getAndIncrement();
+            });
+            // 让列宽随着导出的列长自动适应
+            for (int colNum = 0; colNum < rowName.length; colNum++) {
+                int productColumnWidth = authPartySheet.getColumnWidth(colNum) / 256;
+                for (int rowNum = 0; rowNum < authPartySheet.getLastRowNum(); rowNum++) {
+                    XSSFRow currentRow;
+                    // 当前行未被使用过
+                    if (authPartySheet.getRow(rowNum) == null) {
+                        currentRow = authPartySheet.createRow(rowNum);
+                    } else {
+                        currentRow = authPartySheet.getRow(rowNum);
+                    }
+                    if (currentRow.getCell(colNum) != null) {
+                        XSSFCell currentCell = currentRow.getCell(colNum);
+                        if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
+                            int length = currentCell.getStringCellValue()
+                                    .getBytes().length;
+                            if (productColumnWidth < length) {
+                                productColumnWidth = length;
+                            }
+                        }
+                    }
+                }
+                authPartySheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
+            }
+            outputStream.flush();
+            workbook.write(outputStream);
+            outputStream.close();
         } catch (Exception e) {
             e.printStackTrace();
+            return ResponseJson.error("导出失败");
         }
-        return filePath;
+        return null;
     }
 
     public void download(HttpServletRequest request, HttpServletResponse response, String filePath, String fileName) throws IOException {

+ 110 - 193
src/main/java/com/caimei/service/auth/impl/ShopServiceImpl.java

@@ -6,7 +6,6 @@ import com.caimei.mapper.cmMapper.ShopMapper;
 import com.caimei.mapper.cmMapper.UserMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ShopInfoDto;
-import com.caimei.model.po.CmBrandAuthFilePo;
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
@@ -17,16 +16,15 @@ import com.caimei.utils.*;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.io.FileInputStream;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Description
@@ -57,10 +55,10 @@ public class ShopServiceImpl implements ShopService {
     private String active;
 
     @Override
-    public ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName, String loginAccount, Integer shopType, Integer brandId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize) {
+    public ResponseJson<PageInfo<ShopListVo>> getShopList(Integer listType, String shopName, String loginAccount, Integer shopType, Integer infoId, String mobile, String linkMan, Integer lowerAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
         PageHelper.startPage(pageNum, pageSize);
-        List<ShopListVo> shopList = shopMapper.getShopList(listType, shopName, loginAccount, shopType, brandId, mobile, linkMan, lowerAuditStatus, sendStatus);
+        List<ShopListVo> shopList = shopMapper.getShopList(listType, shopName, loginAccount, shopType, infoId, mobile, linkMan, lowerAuditStatus, sendStatus);
         ListIterator<ShopListVo> iterator = shopList.listIterator();
         while (iterator.hasNext()) {
             // 根据是否完成商品信息审核筛选项,设置下级审核状态
@@ -110,161 +108,62 @@ public class ShopServiceImpl implements ShopService {
         String md5Password = Md5Util.md5(newPassword);
         userMapper.updatePasswordByUserId(authUserId, md5Password);
         String mobile = shopMapper.getShopMobileByUserId(authUserId);
-        boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 14, "{password:\"" + newPassword + "\"}");
-        if (!smsFlag) {
-            // 短信发送失败重试一次
-            AliyunSmsUtil.sendSms(mobile, 14, "{password:\"" + newPassword + "\"}");
+        // 发送短信
+        String content = "您认证通密码为:" + newPassword + ",请勿泄漏于他人。";
+        Boolean sendSms = SmsUtils.sendSms(1, mobile, content);
+        if (!sendSms) {
+            log.info("供应商重置密码发送失败,手机号:" + mobile);
+            return ResponseJson.error("发送失败,请确认手机号无误");
+        } else {
+            log.info("供应商重置密码发送成功,手机号:" + mobile + ",密码:" + newPassword);
         }
-        log.info("供应商重置密码,用户id:" + authUserId);
         return ResponseJson.success("密码重置成功");
     }
 
     @Override
-    public ResponseJson<AuthFileVo> uploadFile(Integer authUserId, Integer brandId, MultipartFile file) {
-        authUserId = (null != authUserId && authUserId > 0) ? authUserId : null;
-        String fileAllName = file.getOriginalFilename();
-        String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
-        String fileName = file.getResource().getFilename();
-        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-        String filePath = uuid + "." + fileType;
-        String contentType = OSSUtils.getContentType(fileAllName);
-        log.info(">>>>>>>>>>>>>上传文件,用户id:" + authUserId);
-        try {
-            //保存本地
-            File uploadFile = OSSUtils.ossUpload(file);
-            //判断文件的唯一性,转换成16进制md5值
-            String md5Hex = DigestUtils.md5Hex(new FileInputStream(uploadFile));
-            CmBrandAuthFilePo cmBrandAuthFile = null;
-            if (null != authUserId) {
-                // 查找该供应商下是否已存在相同文件
-                CmBrandAuthFilePo searchFile = new CmBrandAuthFilePo();
-                searchFile.setAuthUserId(authUserId);
-                searchFile.setBrandId(brandId);
-                searchFile.setMd5Hex(md5Hex);
-                cmBrandAuthFile = shopMapper.getStatementFile(searchFile);
-            }
-            if (cmBrandAuthFile == null) {
-                log.info("默认路径>>>" + uploadFile.getAbsolutePath());
-                // 修改情况下,如果原来已经选择了文件代理声明,并且旧文件与新文件不同,需要将旧文件删除
-                if (null != authUserId) {
-                    deleteFile(authUserId, brandId);
-                }
-                // 查找oss中是否已存在该文件,若存在则不需要重新上传
-                CmBrandAuthFilePo searchFile = new CmBrandAuthFilePo();
-                searchFile.setMd5Hex(md5Hex);
-                CmBrandAuthFilePo sameFile = shopMapper.getStatementFile(searchFile);
-                if (null == sameFile) {
-                    //将新文件上传oss
-                    OSSUtils.ossUpload(filePath, uploadFile, contentType, null);
-                }
-                //删除本地文件
-                OSSUtils.deleteFile(uploadFile);
-                //保存关联关系
-                cmBrandAuthFile = new CmBrandAuthFilePo();
-                cmBrandAuthFile.setAuthUserId(authUserId);
-                cmBrandAuthFile.setBrandId(brandId);
-                cmBrandAuthFile.setName(fileName);
-                cmBrandAuthFile.setOssName(null == sameFile ? filePath : sameFile.getOssName());
-                cmBrandAuthFile.setMd5Hex(md5Hex);
-                cmBrandAuthFile.setUploadTime(new Date());
-                shopMapper.insertStatementFile(cmBrandAuthFile);
-            } else {
-                //删除本地文件
-                OSSUtils.deleteFile(uploadFile);
-            }
-            AuthFileVo fileVo = new AuthFileVo();
-            fileVo.setFileId(cmBrandAuthFile.getId());
-            fileVo.setFileName(cmBrandAuthFile.getName());
-            return ResponseJson.success("文件上传成功", fileVo);
-        } catch (Exception e) {
-            log.error("<<<<< 文件上传异常 >>>>>");
-            return ResponseJson.error("文件上传失败", null);
-        }
-    }
-
-    @Override
-    public void deleteFile(Integer authUserId, Integer brandId) {
-        CmBrandAuthFilePo searchFile = new CmBrandAuthFilePo();
-        searchFile.setAuthUserId(authUserId);
-        searchFile.setBrandId(brandId);
-        CmBrandAuthFilePo oldFile = shopMapper.getStatementFile(searchFile);
-        if (oldFile != null) {
-            Integer num = shopMapper.getFileNumByMd5Hex(oldFile.getMd5Hex());
-            log.info(">>>>>>>>>>>>>>>文件使用数:" + num);
-            if (num == 1) {
-                log.info(">>>>>>>>>>>>>>>删除文件:" + oldFile.getOssName());
-                // 如果这个文件只有这个供应商在使用,删除oss服务器上的文件
-                OSSUtils.deleteSingleFile(oldFile.getOssName());
-            }
-            shopMapper.deleteStatementFile(oldFile.getId());
-        }
-    }
-
-    @Override
-    public ResponseJson saveShop(Integer authUserId, Integer shopType, String shopName, String mobile, String linkMan, Integer shopStatus, String logo, String qrCodeImage, Integer wxAccountType, String appId, String appSecret, Integer createBy, List<ShopInfoDto> shopInfoList) {
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseJson saveShop(UserPo shop, List<ShopInfoDto> shopInfoList) {
         // 是否为添加操作
-        boolean insertFlag = null == authUserId;
-        Integer userIdByMobile = shopMapper.getUserIdByMobile(mobile);
-        Integer userIdByAppId = shopMapper.getUserIdByAppId(appId);
+        boolean insertFlag = null == shop.getAuthUserId();
+        Integer userIdByMobile = shopMapper.getUserIdByMobile(shop.getMobile());
+        Integer userIdByAppId = shopMapper.getUserIdByAppId(shop.getAppId());
         if (insertFlag) {
             // 添加时验证手机号是否已被使用
             if (null != userIdByMobile) {
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
             }
             // 添加时验证供应商名称是否已被使用
-            Integer userIdByShopName = shopMapper.getUserIdByShopName(shopName);
+            Integer userIdByShopName = shopMapper.getUserIdByShopName(shop.getName());
             if (null != userIdByShopName) {
                 return ResponseJson.error("该供应商名称已经存在,请重新输入", null);
             }
+            // 添加时验证前缀是否已被使用
+            Integer userIdByPrefix = shopMapper.getUserIdByPrefix(shop.getPrefix());
+            if (null != userIdByPrefix) {
+                return ResponseJson.error("该供应商前缀已经存在,请重新输入", null);
+            }
             // 添加时验证appId是否已被使用
-            if (StringUtils.isNotEmpty(appId) && null != userIdByAppId) {
+            if (StringUtils.isNotEmpty(shop.getAppId()) && null != userIdByAppId) {
                 return ResponseJson.error("该appId已被使用,请重新输入", null);
             }
         } else {
             // 修改时验证新手机号是否已被使用
-            if (null != userIdByMobile && !userIdByMobile.equals(authUserId)) {
+            if (null != userIdByMobile && !userIdByMobile.equals(shop.getAuthUserId())) {
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
             }
+            // 修改时验证前缀是否已被使用
+            Integer userIdByPrefix = shopMapper.getUserIdByPrefix(shop.getPrefix());
+            if (null != userIdByPrefix && !userIdByPrefix.equals(shop.getAuthUserId())) {
+                return ResponseJson.error("该供应商前缀已经存在,请重新输入", null);
+            }
             // 修改时验证新appId是否已被使用
-            if (StringUtils.isNotEmpty(appId) && null != userIdByAppId && !userIdByAppId.equals(authUserId)) {
+            if (StringUtils.isNotEmpty(shop.getAppId()) && null != userIdByAppId && !userIdByAppId.equals(shop.getAuthUserId())) {
                 return ResponseJson.error("该appId已被使用,请重新输入", null);
             }
         }
-        // 更新品牌授权logo
-        shopInfoList.forEach(shopInfo->{
-            shopMapper.updateBrandAuthLogo(shopInfo.getBrandId(), shopInfo.getBrandAuthLogo());
-        });
-        /*
-            组装供应商用户数据
-         */
-        UserPo shop = new UserPo();
-        // 供应商名称
-        shop.setName(shopName);
-        // 手机号
-        shop.setMobile(mobile);
-        // 联系人
-        shop.setLinkMan(linkMan);
-        // 供应商状态
-        shop.setStatus(shopStatus);
-        // 代理商logo
-        shop.setLogo(logo);
-        // 公众号二维码图片
-        shop.setQrCodeImage(qrCodeImage);
-        // 公众号类型
-        shop.setWxAccountType(wxAccountType);
-        // 公众号appId
-        shop.setAppId(appId);
-        // 公众号appSecret
-        shop.setAppSecret(appSecret);
         if (insertFlag) {
             // 用户身份:1管理员,2供应商
             shop.setUserIdentity(2);
-            // 供应商类型
-            shop.setShopType(shopType);
-            // 创建管理员id
-            shop.setCreateBy(createBy);
-            // 创建时间
-            shop.setCreateTime(new Date());
             // 设置随机8位密码
             String password = CodeUtil.generateCode(8);
             String md5Pwd = Md5Util.md5(password);
@@ -272,16 +171,18 @@ public class ShopServiceImpl implements ShopService {
             // 插入供应商用户
             shopMapper.insertShop(shop);
             // 发送短信
-            boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 14, "{password:\"" + password + "\"}");
-            if (!smsFlag) {
-                // 短信发送失败重试一次
-                AliyunSmsUtil.sendSms(mobile, 14, "{password:\"" + password + "\"}");
+            String content = "您认证通密码为:" + password + ",请勿泄漏于他人。";
+            Boolean sendSms = SmsUtils.sendSms(1, shop.getMobile(), content);
+            if (!sendSms) {
+                log.info("供应商密码发送失败,手机号:" + shop.getMobile());
+                return ResponseJson.error("发送失败,请确认手机号无误");
+            } else {
+                log.info("供应商密码发送成功,手机号:" + shop.getMobile() + ",密码:" + password);
             }
             // 给供应商分配供应商基础角色
             sysUserService.saveRoleRelation(shop.getAuthUserId(), "1");
             log.info("添加供应商,供应商用户id:" + shop.getAuthUserId());
         } else {
-            shop.setAuthUserId(authUserId);
             // 更新供应商用户
             shopMapper.updateShopByUserId(shop);
             log.info("更新供应商,供应商用户id:" + shop.getAuthUserId());
@@ -294,49 +195,32 @@ public class ShopServiceImpl implements ShopService {
                 shopInfo.setAuthUserId(shop.getAuthUserId());
                 // 插入供应商信息
                 shopMapper.insertShopInfo(shopInfo);
-                if (4 == shopInfo.getStatementType()) {
-                    shopMapper.updateFileUserId(shopInfo.getStatementFileId(), shop.getAuthUserId());
-                }
             });
         } else {
-            // 数据库中供应商信息数据
-            List<ShopBrandVo> dbInfoBrandList = shopMapper.getDbInfoBrandList(shop.getAuthUserId());
-            // 编辑后的品牌列表
-            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());
+            // 数据库中品牌列表数据
+            List<ShopInfoVo> dbInfoList = shopMapper.getDbInfoList(shop.getAuthUserId());
+            // 原品牌列表编辑后剩余的品牌信息id列表
+            List<Integer> newInfoIdList = shopInfoList.stream().filter(shopInfo -> shopInfo.getInfoId() != null).map(ShopInfoDto::getInfoId).collect(Collectors.toList());
+            for (ShopInfoVo dbInfo : dbInfoList) {
+                if (!newInfoIdList.contains(dbInfo.getInfoId())) {
+                    // 判断被删除的品牌下是否还有未删除的商品,若存在,提示供应商需要删除后才能删除品牌
+                    Integer productCount = shopMapper.getProductCount(shop.getAuthUserId(), dbInfo.getInfoId());
                     if (null != productCount && productCount > 0) {
-                        return ResponseJson.error("该品牌已绑定供应商商品,无法进行删除");
+                        // 设置手动回滚事务
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ResponseJson.error("对不起,该品牌已绑定设备认证,暂时无法删除");
+                    } else {
+                        // 删除品牌
+                        shopMapper.deleteShopInfoById(dbInfo.getInfoId());
                     }
                 }
             }
-            for (ShopBrandVo shopBrand : dbInfoBrandList) {
-                if (!newInfoBrandList.contains(shopBrand.getBrandId())) {
-                    // 删除被删除的数据
-                    shopMapper.deleteShopInfoById(shopBrand.getId());
-                    // 删除文件
-                    deleteFile(authUserId, shopBrand.getBrandId());
-                } else {
-                    // 保存数据库已有且未被删除的供应商品牌id
-                    updateInfoBrandList.add(shopBrand.getBrandId());
-                }
-            }
             shopInfoList.forEach(shopInfoVo -> {
                 shopInfoVo.setAuthUserId(shop.getAuthUserId());
                 // 保存供应商信息数据
-                if (updateInfoBrandList.contains(shopInfoVo.getBrandId())) {
+                if (shopInfoVo.getInfoId() != null) {
                     // 更新
                     shopMapper.updateShopInfo(shopInfoVo);
-                    if (4 != shopInfoVo.getStatementType()) {
-                        // 没有选择文件代理声明的情况下,若存在原来的文件,删除代理声明文件
-                        deleteFile(shop.getAuthUserId(),shopInfoVo.getBrandId());
-                    }
                 } else {
                     // 插入
                     shopMapper.insertShopInfo(shopInfoVo);
@@ -357,26 +241,22 @@ public class ShopServiceImpl implements ShopService {
         }
         List<ShopInfoVo> shopInfoList = shopMapper.getShopInfoByUserId(authUserId);
         shopForm.setShopInfo(shopInfoList);
-        String existProductBrandIds = "";
+        String existProductInfoIds = "";
         for (ShopInfoVo shopInfo : shopInfoList) {
-            if (null != shopInfo.getBrandId()) {
-                Integer productCount = shopMapper.getProductCount(authUserId, shopInfo.getBrandId());
+            if (null != shopInfo.getInfoId()) {
+                Integer productCount = shopMapper.getProductCount(authUserId, shopInfo.getInfoId());
                 if (null != productCount && productCount > 0) {
-                    existProductBrandIds += shopInfo.getBrandId() + ",";
+                    existProductInfoIds += shopInfo.getInfoId() + ",";
                 }
             }
         }
-        shopForm.setExistProductBrandIds(existProductBrandIds);
+        shopForm.setExistProductInfoIds(existProductInfoIds);
         return ResponseJson.success(shopForm);
     }
 
     @Override
-    public ResponseJson<List<BrandVo>> getBrandList(Integer type, Integer authUserId) {
-        type = null == type ? 2 : type;
-        if (3 == type && null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
-        List<BrandVo> brandList = shopMapper.getBrandList(type, authUserId);
+    public ResponseJson<List<ShopInfoVo>> getShopInfoList(Integer authUserId) {
+        List<ShopInfoVo> brandList = shopMapper.getShopInfoList(authUserId);
         return ResponseJson.success(brandList);
     }
 
@@ -387,12 +267,9 @@ public class ShopServiceImpl implements ShopService {
     }
 
     @Override
-    public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String clubName, String mobile, Integer handleStatus, Integer pageNum, Integer pageSize) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,请输入供应商用户id", null);
-        }
+    public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String authParty, String mobile, Integer handleStatus, Integer pageNum, Integer pageSize) {
         PageHelper.startPage(pageNum, pageSize);
-        List<FeedbackVo> feedbackList = shopMapper.getFeedbackList(authUserId, clubName, mobile, handleStatus);
+        List<FeedbackVo> feedbackList = shopMapper.getFeedbackList(authUserId, authParty, mobile, handleStatus);
         PageInfo<FeedbackVo> pageData = new PageInfo<>(feedbackList);
         return ResponseJson.success(pageData);
     }
@@ -430,7 +307,7 @@ public class ShopServiceImpl implements ShopService {
         }
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";;
         String content = "您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
-        Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+        Boolean sendSms = SmsUtils.sendSms(null, mobile, content);
         if (!sendSms) {
             log.info("短信验证码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
@@ -443,9 +320,6 @@ public class ShopServiceImpl implements ShopService {
 
     @Override
     public ResponseJson changeMobile(Integer authUserId, String oldMobile, String verifyCode, String newMobile) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空");
-        }
         if (StringUtils.isEmpty(verifyCode)) {
             return ResponseJson.error("参数异常,验证码不能为空");
         }
@@ -476,9 +350,6 @@ public class ShopServiceImpl implements ShopService {
 
     @Override
     public ResponseJson bindLoginAccount(Integer authUserId, String mobile, String verifyCode, String loginAccount) {
-        if (null == authUserId) {
-            return ResponseJson.error("参数异常,供应商用户id不能为空");
-        }
         if (StringUtils.isEmpty(verifyCode)) {
             return ResponseJson.error("参数异常,验证码不能为空");
         }
@@ -529,4 +400,50 @@ public class ShopServiceImpl implements ShopService {
         });
         return ResponseJson.success();
     }
+
+    @Override
+    public ResponseJson changeLinkMan(Integer authUserId, String linkMan) {
+        shopMapper.updateShopLinkMan(authUserId, linkMan);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson changeLogo(Integer authUserId, String logo) {
+        shopMapper.updateShopLogo(authUserId, logo);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson saveShopInfo(Integer authUserId, ShopInfoDto shopInfo) {
+        boolean insertFlag = null == shopInfo.getInfoId();
+        if (insertFlag) {
+            shopInfo.setAuthUserId(authUserId);
+            // 插入供应商信息
+            shopMapper.insertShopInfo(shopInfo);
+        } else {
+            // 更新
+            shopMapper.updateShopInfo(shopInfo);
+        }
+        return ResponseJson.success("保存成功");
+    }
+
+    @Override
+    public ResponseJson deleteShopInfo(Integer authUserId, Integer infoId) {
+        // 判断被删除的品牌下是否还有未删除的商品,若存在,提示供应商需要删除后才能删除品牌
+        Integer productCount = shopMapper.getProductCount(authUserId, infoId);
+        if (null != productCount && productCount > 0) {
+            return ResponseJson.error("对不起,该品牌已绑定设备认证,暂时无法删除");
+        } else {
+            // 删除品牌
+            shopMapper.deleteShopInfoById(infoId);
+        }
+        return ResponseJson.success("删除成功");
+    }
+
+    @Override
+    public ResponseJson<List<CmShopVo>> getCmShopList() {
+        List<CmShopVo> cmShopList = shopMapper.getCmShopList();
+        return ResponseJson.success(cmShopList);
+    }
+
 }

+ 135 - 37
src/main/java/com/caimei/service/auth/impl/UploadServiceImpl.java

@@ -2,22 +2,23 @@ package com.caimei.service.auth.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.caimei.config.FastDfsClient;
+import com.caimei.model.en.QrCodeSize;
 import com.caimei.model.po.UploadFilePo;
 import com.caimei.service.auth.UploadService;
+import com.caimei.utils.FileIOUtils;
+import com.caimei.utils.ImageUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
 import java.io.*;
-import java.net.HttpURLConnection;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Description
@@ -72,7 +73,9 @@ public class UploadServiceImpl implements UploadService {
             file.setFileName(imgRandomId);
             fileList.add(file);
         }
-        String imageZipPath = createImageZip(fileList);
+        HashMap<String, List<UploadFilePo>> map = new HashMap<>(1);
+        map.put("图片压缩包", fileList);
+        String imageZipPath = createImageZip(map, 5);
         // 上传zip
         String imageUrl = imageDomain + "/" + client.uploadFile(imageZipPath);
         // 删除临时图片
@@ -82,44 +85,138 @@ public class UploadServiceImpl implements UploadService {
         return imageUrl;
     }
 
+    /**
+     * 创建图片压缩包
+     * @param fileMap
+     * @param type      1机构授权牌,2设备授权牌,3机构二维码,4设备二维码,5资料库图片压缩包
+     * @return
+     * @throws Exception
+     */
     @Override
-    public String createImageZip(List<UploadFilePo> fileList) throws Exception {
+    public String createImageZip(Map<String,List<UploadFilePo>> fileMap, Integer type) throws Exception {
         String randomStr = UUID.randomUUID().toString();
         String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempImage/";
         if ("dev".equals(active)){
             filePath = "D:\\uploadZip\\";
         }
-        filePath += randomStr + ".zip";
-        File zipFile = new File(filePath);
-        log.info("【图片上传】>>>>>>>>>>>>>>>>图片压缩包临时路径:" + filePath);
-        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
-        BufferedOutputStream bo = new BufferedOutputStream(out);
-        for (UploadFilePo file : fileList) {
-            String fileUrl = file.getFileUrl();
-            File image = null;
-            if (fileUrl.startsWith("http")) {
-                HttpURLConnection httpUrl = (HttpURLConnection) new URL(fileUrl).openConnection();
-                httpUrl.connect();
-                String prefix = fileUrl.substring(fileUrl.lastIndexOf("."));
-                image = inputStreamToFile(httpUrl.getInputStream(), file.getFileName() + "." + prefix);
-            } else {
-                image = new File(fileUrl);
+        // 压缩文件夹上层临时文件夹路径
+        String tempPath = filePath + randomStr;
+        // 压缩文件夹路径
+        String basePath = "";
+        // 生成唯一临时文件夹
+        filePath += randomStr + "/";
+        // 在临时文件夹中生成要压缩的基础文件夹
+        String baseDirName = "";
+        switch (type) {
+            case 1:
+                baseDirName = "机构授权牌";
+                break;
+            case 2:
+                baseDirName = "设备授权牌";
+                break;
+            case 3:
+                baseDirName = "机构二维码";
+                break;
+            case 4:
+                baseDirName = "设备二维码";
+                break;
+            case 5:
+                baseDirName = "图片包";
+                break;
+            default:
+                baseDirName = "";
+        }
+//        basePath = filePath += baseDirName;
+        filePath += baseDirName;
+        basePath = filePath;
+        File baseDir = new File(basePath);
+        if (!baseDir.exists()) {
+            baseDir.mkdirs();
+        }
+        // 往基础文件夹中填充相应数据
+        if (1 == type) {
+            // 机构授权牌
+            List<UploadFilePo> fileList = fileMap.get("机构授权牌");
+            for (int i = 0; i < fileList.size(); i++) {
+                // 把机构授权牌链接转换为图片
+                UploadFilePo file = fileList.get(i);
+                String fileUrl = file.getFileUrl();
+                URL url = new URL(fileUrl);
+                InputStream inputStream = url.openStream();
+                BufferedImage authImage = ImageIO.read(inputStream);
+                String extName = fileUrl.substring(fileUrl.lastIndexOf(".") + 1);
+                String tempFilePath = filePath + "/" + file.getFileName() + "." + extName;
+                FileOutputStream outImgStream = new FileOutputStream(tempFilePath);
+                ImageIO.write(authImage, extName, outImgStream);
+                inputStream.close();
+                outImgStream.flush();
+                outImgStream.close();
+            }
+        } else if (2 == type) {
+            // 设备授权牌
+            for (Map.Entry<String, List<UploadFilePo>> entry : fileMap.entrySet()) {
+                String authParty = entry.getKey();
+                List<UploadFilePo> fileList = entry.getValue();
+                filePath = basePath + "/" + authParty;
+                File authDir = new File(filePath);
+                if (!authDir.exists()) {
+                    authDir.mkdirs();
+                }
+                for (int i = 0; i < fileList.size(); i++) {
+                    // 把设备授权牌链接转换为图片
+                    UploadFilePo file = fileList.get(i);
+                    String fileUrl = file.getFileUrl();
+                    URL url = new URL(fileUrl);
+                    InputStream inputStream = url.openStream();
+                    BufferedImage authImage = ImageIO.read(inputStream);
+                    String extName = fileUrl.substring(fileUrl.lastIndexOf(".") + 1);
+                    String tempFilePath = filePath + "/" + file.getFileName() + "." + extName;
+                    FileOutputStream outImgStream = new FileOutputStream(tempFilePath);
+                    ImageIO.write(authImage, extName, outImgStream);
+                    inputStream.close();
+                    outImgStream.flush();
+                    outImgStream.close();
+                }
+
+            }
+        } else if (3 == type) {
+            // 机构二维码
+            List<UploadFilePo> fileList = fileMap.get("机构二维码");
+            for (int i = 0; i < fileList.size(); i++) {
+                // 把机构二维码链接转换为图片
+                UploadFilePo file = fileList.get(i);
+                String fileUrl = file.getFileUrl();
+                String fileName = file.getFileName();
+                BufferedImage qrCodeImage = ImageUtils.createQrCode(fileUrl, QrCodeSize.LARGE);
+                String tempFilePath = filePath + "/" + fileName;
+                ImageUtils.transferBufferdImage(qrCodeImage, tempFilePath, "png");
             }
-            out.putNextEntry(new ZipEntry(image.getName()));
-            FileInputStream in = new FileInputStream(image);
-            BufferedInputStream bi = new BufferedInputStream(in);
-            int b;
-            while ((b = bi.read()) != -1) {
-                bo.write(b);
+        } else if (4 == type) {
+            // 设备二维码
+            for (Map.Entry<String, List<UploadFilePo>> entry : fileMap.entrySet()) {
+                String authParty = entry.getKey();
+                List<UploadFilePo> fileList = entry.getValue();
+                filePath = basePath + "/" + authParty;
+                File authDir = new File(filePath);
+                if (!authDir.exists()) {
+                    authDir.mkdirs();
+                }
+                for (int i = 0; i < fileList.size(); i++) {
+                    // 把设备授权牌链接转换为图片
+                    UploadFilePo file = fileList.get(i);
+                    String fileUrl = file.getFileUrl();
+                    String fileName = file.getFileName();
+                    BufferedImage qrCodeImage = ImageUtils.createQrCode(fileUrl, QrCodeSize.LARGE);
+                    String tempFilePath = filePath + "/" + fileName;
+                    ImageUtils.transferBufferdImage(qrCodeImage, tempFilePath, "png");
+                }
             }
-            bo.flush();
-            bi.close();
-            in.close();
-            image.delete();
         }
-        bo.close();
-        out.close();
-        return filePath;
+        // 将文件夹转为压缩文件
+        String zipPath = tempPath + "/" + baseDirName + ".zip";
+        FileOutputStream zipOut = new FileOutputStream(zipPath);
+        FileIOUtils.zipFolder(basePath, zipOut, true);
+        return zipPath;
     }
 
     @Override
@@ -141,7 +238,8 @@ public class UploadServiceImpl implements UploadService {
      * inputStream 转 File
      */
     public static File inputStreamToFile(InputStream ins, String name) throws Exception{
-        File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
+//        File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
+        File file = new File("D:\\uploadZip\\机构二维码\\" + File.separator + name);
         if (file.exists()) {
             return file;
         }

+ 3 - 3
src/main/java/com/caimei/service/auth/impl/UserServiceImpl.java

@@ -130,15 +130,15 @@ public class UserServiceImpl implements UserService {
     private ResponseJson<UserLoginVo> logonVerify(UserLoginVo loginUser) {
         // 生成token给用户
         String token = JwtUtil.createToken(loginUser.getAuthUserId());
-        // 为了过期续签,将token存入redis,并设置超时时间
-        redisService.set(token, token, JwtUtil.getExpireTime());
-        loginUser.setToken(token);
         // 供应商
         if (null != loginUser.getShopStatus() && null != loginUser.getUserIdentity() && 2 == loginUser.getUserIdentity()) {
             if (0 == loginUser.getShopStatus()) {
                 return ResponseJson.error(-2, "您的企业账号已被冻结,请联系客服处理", null);
             }
         }
+        // 为了过期续签,将token存入redis,并设置超时时间
+        redisService.set(token, token, JwtUtil.getExpireTime());
+        loginUser.setToken(token);
         // 清除密码
         loginUser.setPassword(null);
         return ResponseJson.success("登录成功", loginUser);

+ 7 - 0
src/main/java/com/caimei/service/data/FileService.java

@@ -109,4 +109,11 @@ public interface FileService {
      * @return
      */
     ResponseJson deleteCourseFile(Integer fileId);
+
+    /**
+     * 更改查看标记
+     * @param fileId
+     * @return
+     */
+    ResponseJson checkFile(Integer fileId);
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff