Browse Source

供应商/机构/设备保存

Aslee 2 years ago
parent
commit
1ad70ef8a4
40 changed files with 994 additions and 584 deletions
  1. 2 1
      src/main/java/com/caimei/config/WebConfig.java
  2. 22 3
      src/main/java/com/caimei/controller/admin/auth/AuthApi.java
  3. 37 4
      src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java
  4. 85 23
      src/main/java/com/caimei/controller/admin/auth/ShopApi.java
  5. 2 9
      src/main/java/com/caimei/controller/admin/sys/SysMenuApi.java
  6. 1 1
      src/main/java/com/caimei/controller/wechat/WxAuthApi.java
  7. 2 0
      src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java
  8. 13 3
      src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java
  9. 3 0
      src/main/java/com/caimei/mapper/cmMapper/ShopMapper.java
  10. 15 0
      src/main/java/com/caimei/model/dto/ProductSaveDto.java
  11. 5 40
      src/main/java/com/caimei/model/dto/ShopInfoDto.java
  12. 10 0
      src/main/java/com/caimei/model/po/CmBrandAuthPo.java
  13. 8 3
      src/main/java/com/caimei/model/po/ProductPo.java
  14. 0 54
      src/main/java/com/caimei/model/po/ShopInfoPo.java
  15. 5 0
      src/main/java/com/caimei/model/po/UserPo.java
  16. 10 0
      src/main/java/com/caimei/model/vo/AuthFormVo.java
  17. 5 5
      src/main/java/com/caimei/model/vo/AuthProductVo.java
  18. 23 3
      src/main/java/com/caimei/model/vo/ProductFormVo.java
  19. 38 11
      src/main/java/com/caimei/model/vo/ProductListVo.java
  20. 37 0
      src/main/java/com/caimei/model/vo/ProductRelationVo.java
  21. 2 2
      src/main/java/com/caimei/model/vo/ShopBrandVo.java
  22. 47 15
      src/main/java/com/caimei/model/vo/ShopFormVo.java
  23. 25 15
      src/main/java/com/caimei/model/vo/ShopInfoVo.java
  24. 19 3
      src/main/java/com/caimei/service/auth/AuthProductService.java
  25. 5 1
      src/main/java/com/caimei/service/auth/AuthService.java
  26. 7 1
      src/main/java/com/caimei/service/auth/ShopService.java
  27. 20 4
      src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java
  28. 309 133
      src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java
  29. 6 11
      src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
  30. 49 83
      src/main/java/com/caimei/service/auth/impl/ShopServiceImpl.java
  31. 1 2
      src/main/java/com/caimei/service/sys/SysMenuService.java
  32. 2 5
      src/main/java/com/caimei/service/sys/impl/SysMenuServiceImpl.java
  33. 1 2
      src/main/java/com/caimei/service/wechat/impl/LoginServiceImpl.java
  34. 1 1
      src/main/java/com/caimei/service/wechat/impl/RegisterServiceImpl.java
  35. 14 2
      src/main/java/com/caimei/service/wechat/impl/WxUserServiceImpl.java
  36. 21 0
      src/main/java/com/caimei/utils/ImageUtils.java
  37. 6 3
      src/main/java/com/caimei/utils/SmsUtils.java
  38. 11 2
      src/main/resources/mapper/AuthMapper.xml
  39. 104 73
      src/main/resources/mapper/AuthProductMapper.xml
  40. 21 66
      src/main/resources/mapper/ShopMapper.xml

+ 2 - 1
src/main/java/com/caimei/annotation/WebConfig.java → src/main/java/com/caimei/config/WebConfig.java

@@ -1,5 +1,6 @@
-package com.caimei.annotation;
+package com.caimei.config;
 
 
+import com.caimei.annotation.CurrentUserResolver;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

+ 22 - 3
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -19,8 +19,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -135,7 +133,8 @@ public class AuthApi {
             "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
             "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
             "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
             "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
             "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
             "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
-            "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true)
+            "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
+            "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
     @PostMapping("/save")
     @PostMapping("/save")
     public ResponseJson saveAuth(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
     public ResponseJson saveAuth(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
         if (null == sysUser) {
         if (null == sysUser) {
@@ -156,6 +155,8 @@ public class AuthApi {
         String lngAndLat = paramsMap.getString("lngAndLat");
         String lngAndLat = paramsMap.getString("lngAndLat");
         String mobile = paramsMap.getString("mobile");
         String mobile = paramsMap.getString("mobile");
         String userMobile = paramsMap.getString("userMobile");
         String userMobile = paramsMap.getString("userMobile");
+        String linkMan = paramsMap.getString("linkMan");
+        String linkMobile = paramsMap.getString("linkMobile");
         Integer firstClubType = paramsMap.getInteger("firstClubType");
         Integer firstClubType = paramsMap.getInteger("firstClubType");
         Integer secondClubType = paramsMap.getInteger("secondClubType");
         Integer secondClubType = paramsMap.getInteger("secondClubType");
         String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
         String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
@@ -202,6 +203,8 @@ public class AuthApi {
         auth.setLat(new BigDecimal(split[1]));
         auth.setLat(new BigDecimal(split[1]));
         auth.setMobile(mobile);
         auth.setMobile(mobile);
         auth.setUserMobile(userMobile);
         auth.setUserMobile(userMobile);
+        auth.setLinkMan(linkMan);
+        auth.setLinkMobile(linkMobile);
         auth.setFirstClubType(firstClubType);
         auth.setFirstClubType(firstClubType);
         auth.setSecondClubType(secondClubType);
         auth.setSecondClubType(secondClubType);
         auth.setMedicalLicenseImage(medicalLicenseImage);
         auth.setMedicalLicenseImage(medicalLicenseImage);
@@ -281,4 +284,20 @@ public class AuthApi {
     public ResponseJson checkAuth(Integer authId) {
     public ResponseJson checkAuth(Integer authId) {
         return authService.checkAuth(authId);
         return authService.checkAuth(authId);
     }
     }
+
+    @ApiOperation("勾选明星机构")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "authId", required = true, value = "授权机构id"),
+            @ApiImplicitParam(name = "starFlag", required = true, value = "明星机构标识:0不是,1是")
+    })
+    @PostMapping("/star")
+    public ResponseJson starAuth(Integer authId, Integer starFlag) {
+        if (null == authId) {
+            return ResponseJson.error("机构id不能为空");
+        }
+        if (null == starFlag) {
+            return ResponseJson.error("明星机构标识不能为空");
+        }
+        return authService.starAuth(authId, starFlag);
+    }
 }
 }

+ 37 - 4
src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java

@@ -9,6 +9,7 @@ import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductTypePo;
 import com.caimei.model.po.ProductTypePo;
 import com.caimei.model.po.SysUser;
 import com.caimei.model.po.SysUser;
+import com.caimei.model.vo.AuthProductVo;
 import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.ProductListVo;
 import com.caimei.model.vo.ProductListVo;
 import com.caimei.model.vo.ProductTypeListVo;
 import com.caimei.model.vo.ProductTypeListVo;
@@ -65,6 +66,22 @@ public class AuthProductApi {
     }
     }
 
 
 
 
+    @ApiOperation("供应商下设备sn码列表")
+    @GetMapping("/sn/list")
+    public ResponseJson<List<String>> getSnCodeList(@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 authProductService.getSnCodeList(authUserId);
+    }
+
+
     /**
     /**
      * 更新授权商品状态
      * 更新授权商品状态
      */
      */
@@ -109,14 +126,30 @@ public class AuthProductApi {
     @ApiOperation("添加/编辑授权商品")
     @ApiOperation("添加/编辑授权商品")
     @PostMapping("/save")
     @PostMapping("/save")
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
-        return authProductService.saveProduct(productSaveDto, false);
+        return authProductService.saveProduct(productSaveDto);
     }
     }
 
 
     @ApiOperation("授权商品回显数据")
     @ApiOperation("授权商品回显数据")
-    @ApiImplicitParam(name = "productId", required = true, value = "授权商品id")
+    @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id")
     @GetMapping("/form/data")
     @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 = true, value = "sn码")
+    })
+    @GetMapping("/details")
+    public ResponseJson<ProductFormVo> getProductDetails(Integer productId, String snCode) {
+        if (null == productId && null == snCode) {
+            return ResponseJson.error("设备id和sn码不能同时为空", null);
+        }
+        return authProductService.getProductDetails(productId, snCode);
     }
     }
 
 
     /**
     /**

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

@@ -8,6 +8,7 @@ import com.caimei.mapper.cmMapper.SystemMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ShopInfoDto;
 import com.caimei.model.dto.ShopInfoDto;
 import com.caimei.model.po.SysUser;
 import com.caimei.model.po.SysUser;
+import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.ShopService;
 import com.caimei.service.auth.ShopService;
 import com.caimei.utils.JwtUtil;
 import com.caimei.utils.JwtUtil;
@@ -26,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -88,8 +90,19 @@ public class ShopApi {
     @ApiOperation("供应商回显数据")
     @ApiOperation("供应商回显数据")
     @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
     @GetMapping("/form/data")
     @GetMapping("/form/data")
-    public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
-        // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
+    public ResponseJson<ShopFormVo> getShopFormData(@CurrentUser SysUser sysUser, Integer authUserId) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null == authUserId) {
+            if (null == sysUser) {
+                return ResponseJson.error("用户信息异常", null);
+            }
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        }
         return shopService.getShopFormData(authUserId);
         return shopService.getShopFormData(authUserId);
     }
     }
 
 
@@ -128,6 +141,7 @@ public class ShopApi {
         // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
         // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
         JSONObject paramsMap = JSONObject.parseObject(params);
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authUserId = paramsMap.getInteger("authUserId");
         Integer authUserId = paramsMap.getInteger("authUserId");
+        Integer cmShopId = paramsMap.getInteger("cmShopId");
         Integer shopType = paramsMap.getInteger("shopType");
         Integer shopType = paramsMap.getInteger("shopType");
         if (null == shopType) {
         if (null == shopType) {
             return ResponseJson.error("请选择供应商类型", null);
             return ResponseJson.error("请选择供应商类型", null);
@@ -146,44 +160,75 @@ public class ShopApi {
             return ResponseJson.error("参数异常,请输入供应商状态");
             return ResponseJson.error("参数异常,请输入供应商状态");
         }
         }
         String logo = (String) paramsMap.get("logo");
         String logo = (String) paramsMap.get("logo");
+        if (StringUtils.isEmpty(logo)) {
+            return ResponseJson.error("供应商logo不能为空");
+        }
         String qrCodeImage = (String) paramsMap.get("qrCodeImage");
         String qrCodeImage = (String) paramsMap.get("qrCodeImage");
         Integer wxAccountType = (Integer) paramsMap.get("wxAccountType");
         Integer wxAccountType = (Integer) paramsMap.get("wxAccountType");
         String appId = (String) paramsMap.get("appId");
         String appId = (String) paramsMap.get("appId");
         String appSecret = (String) paramsMap.get("appSecret");
         String appSecret = (String) paramsMap.get("appSecret");
         Integer createBy = paramsMap.getInteger("createBy");
         Integer createBy = paramsMap.getInteger("createBy");
+        /*
+            组装供应商用户数据
+         */
+        UserPo shop = new UserPo();
+        // 供应商用户id
+        shop.setAuthUserId(authUserId);
+        // 关联采美供应商id
+        shop.setCmShopId(cmShopId);
+        // 供应商名称
+        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);
+        // 供应商类型
+        shop.setShopType(shopType);
+        // 创建管理员id
+        shop.setCreateBy(createBy);
+        // 创建时间
+        shop.setCreateTime(new Date());
         List<Map<String, Object>> shopInfoData = (List<Map<String, Object>>) paramsMap.get("shopInfo");
         List<Map<String, Object>> shopInfoData = (List<Map<String, Object>>) paramsMap.get("shopInfo");
         if (null == shopInfoData || shopInfoData.size() <= 0) {
         if (null == shopInfoData || shopInfoData.size() <= 0) {
             return ResponseJson.error("参数异常,请输入供应商信息");
             return ResponseJson.error("参数异常,请输入供应商信息");
         }
         }
         List<ShopInfoDto> shopInfoList = new ArrayList<>();
         List<ShopInfoDto> shopInfoList = new ArrayList<>();
+        List<String> brandNameList = new ArrayList<>();
         for (Map<String, Object> infoMap : shopInfoData) {
         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 id = (Integer) infoMap.get("id");
+            String brandName = (String) infoMap.get("brandName");
+            String brandLogo = (String) infoMap.get("brandLogo");
+            String producePlace = (String) infoMap.get("producePlace");
             String manufacturer = (String) infoMap.get("manufacturer");
             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();
             ShopInfoDto shopInfo = new ShopInfoDto();
-            shopInfo.setBrandId(brandId);
-            shopInfo.setCountryId(countryId);
-            shopInfo.setBrandAuthLogo(brandAuthLogo);
-            shopInfo.setSecurityLink(securityLink);
+            shopInfo.setId(id);
+            shopInfo.setBrandName(brandName);
+            shopInfo.setBrandLogo(brandLogo);
+            shopInfo.setProducePlace(producePlace);
             shopInfo.setManufacturer(manufacturer);
             shopInfo.setManufacturer(manufacturer);
-            shopInfo.setStatementType(statementType);
-            shopInfo.setStatementContent(statementContent);
-            shopInfo.setStatementLink(statementLink);
-            shopInfo.setStatementImage(statementImage);
-            shopInfo.setStatementFileId(statementFileId);
             shopInfoList.add(shopInfo);
             shopInfoList.add(shopInfo);
         }
         }
-        return shopService.saveShop(authUserId, shopType, shopName, mobile, linkMan, shopStatus,logo, qrCodeImage, wxAccountType, appId, appSecret, createBy, shopInfoList);
+        return shopService.saveShop(shop, shopInfoList);
     }
     }
 
 
     /**
     /**
@@ -325,6 +370,23 @@ public class ShopApi {
         return shopService.changeMobile(authUserId, oldMobile, verifyCode, 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 authUserId = sysUser.getId();
+        if (null == authUserId) {
+            return ResponseJson.error("用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String linkMan = parseObject.getString("verifyCode");
+        return shopService.changeLinkMan(authUserId, linkMan);
+    }
+
     @ApiOperation("登录账号绑定")
     @ApiOperation("登录账号绑定")
     @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
     @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
     @PostMapping("/account/bind")
     @PostMapping("/account/bind")

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

@@ -34,18 +34,11 @@ public class SysMenuApi {
      * @param pageSize 每页大小
      * @param pageSize 每页大小
      */
      */
     @GetMapping("/list")
     @GetMapping("/list")
-    public ResponseJson<PageInfo<SysMenu>> menuList(@CurrentUser SysUser sysUser, Integer status, Integer menuType,
+    public ResponseJson<PageInfo<SysMenu>> menuList(Integer status, Integer menuType,
                                                     @RequestParam(value = "parentId", defaultValue = "0") Integer parentId,
                                                     @RequestParam(value = "parentId", defaultValue = "0") Integer parentId,
                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        // 管理员/供应商公用接口,管理员不需要传authUserId
-        if (null == sysUser) {
-            return ResponseJson.error("用户信息异常", null);
-        }
-        // 获取供应商用户id
-        Integer userIdentity = sysUser.getUserIdentity();
-        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
-        return sysMenuService.getMenuList(authUserId, parentId, menuType, status, pageNum, pageSize);
+        return sysMenuService.getMenuList(parentId, menuType, status, pageNum, pageSize);
     }
     }
 
 
     /**
     /**

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

@@ -167,7 +167,7 @@ public class WxAuthApi {
     @ApiOperation("添加/编辑授权商品")
     @ApiOperation("添加/编辑授权商品")
     @PostMapping("/product/save")
     @PostMapping("/product/save")
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
     public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
-        return authProductService.saveProduct(productSaveDto, false);
+        return authProductService.saveProduct(productSaveDto);
     }
     }
 
 
     /**
     /**

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

@@ -108,4 +108,6 @@ public interface AuthMapper {
     List<CmBrandAuthPo> getAllAuth(Integer authUserId);
     List<CmBrandAuthPo> getAllAuth(Integer authUserId);
 
 
     void checkAuth(Integer authId);
     void checkAuth(Integer authId);
+
+    void starAuth(@Param("authId") Integer authId, @Param("starFlag") Integer starFlag);
 }
 }

+ 13 - 3
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -35,14 +35,12 @@ public interface AuthProductMapper {
 
 
     Integer getProductIdBySnCode(String snCode);
     Integer getProductIdBySnCode(String snCode);
 
 
-    ProductFormVo getProductFormByProductId(Integer productId);
+    ProductFormVo getProductFormData(@Param("relationId") Integer relationId);
 
 
     List<ProductParamPo> getParamsByProductId(Integer productId);
     List<ProductParamPo> getParamsByProductId(Integer productId);
 
 
     List<Integer> getProductIdsByAuthId(Integer authId);
     List<Integer> getProductIdsByAuthId(Integer authId);
 
 
-    ProductPo getImageByProductId(Integer productId);
-
     List<ProductPo> getAllImage();
     List<ProductPo> getAllImage();
 
 
     void updateImageByProductId(ProductPo product);
     void updateImageByProductId(ProductPo product);
@@ -96,4 +94,16 @@ public interface AuthProductMapper {
     List<ProductParamPo> getProductTypeParamList(Integer productTypeId);
     List<ProductParamPo> getProductTypeParamList(Integer productTypeId);
 
 
     void checkAuthProduct(Integer productId);
     void checkAuthProduct(Integer productId);
+
+    Integer insertProductRelation(@Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
+
+    ProductRelationVo getProductRelation(Integer relationId);
+
+    void updateProductRelation(@Param("relationId") Integer relationId, @Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
+
+    Integer getProductRelationCount(Integer productId);
+
+    ProductFormVo getProductDetails(@Param("productId") Integer productId, @Param("snCode") String snCode);
+
+    List<String> getSnCodeList(Integer authUserId);
 }
 }

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

@@ -93,4 +93,7 @@ public interface ShopMapper {
     String getLoginAccount(Integer authUserId);
     String getLoginAccount(Integer authUserId);
 
 
     void bindLoginAccount(@Param("authUserId") Integer authUserId, @Param("loginAccount") String loginAccount);
     void bindLoginAccount(@Param("authUserId") Integer authUserId, @Param("loginAccount") String loginAccount);
+
+    void updateShopLinkMan(@Param("authUserId") Integer authUserId, @Param("linkMan") String linkMan);
+
 }
 }

+ 15 - 0
src/main/java/com/caimei/model/dto/ProductSaveDto.java

@@ -26,6 +26,16 @@ public class ProductSaveDto {
      */
      */
     private Integer authId;
     private Integer authId;
 
 
+    /**
+     * 机构设备关联id
+     */
+    private Integer relationId;
+
+    /**
+     * 认证方式:1新设备认证,2关联已认证设备
+     */
+    private Integer authType;
+
     /**
     /**
      * 品牌id
      * 品牌id
      */
      */
@@ -56,6 +66,11 @@ public class ProductSaveDto {
      */
      */
     private String certificateImage;
     private String certificateImage;
 
 
+    /**
+     * 授权牌照类型:1模板库生成,2自定义上传
+     */
+    private Integer certificateImageType;
+
     /**
     /**
      * 是否生成二维码授权牌:0否,1是
      * 是否生成二维码授权牌:0否,1是
      */
      */

+ 5 - 40
src/main/java/com/caimei/model/dto/ShopInfoDto.java

@@ -18,55 +18,20 @@ public class ShopInfoDto {
     /**
     /**
      * 所属品牌Id
      * 所属品牌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 manufacturer;
-
-    /**
-     * 公众号二维码图片
-     */
-    private String qrCodeImage;
-
-    /**
-     * 代理声明类型:1弹窗,2链接,3图片,4文件
-     */
-    private Integer statementType;
-
-    /**
-     * 声明弹窗内容
-     */
-    private String statementContent;
-
-    /**
-     * 声明链接
-     */
-    private String statementLink;
-
-    /**
-     * 声明图片
-     */
-    private String statementImage;
-
-    /**
-     * 声明文件id
-     */
-    private Integer statementFileId;
 }
 }

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

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

+ 8 - 3
src/main/java/com/caimei/model/po/ProductPo.java

@@ -60,7 +60,7 @@ public class ProductPo {
     private String appletsImage;
     private String appletsImage;
 
 
     /**
     /**
-     * 原授权牌照
+     * 原授权牌照(废弃)
      */
      */
     private String originalCertificateImage;
     private String originalCertificateImage;
 
 
@@ -69,6 +69,11 @@ public class ProductPo {
      */
      */
     private String certificateImage;
     private String certificateImage;
 
 
+    /**
+     * 授权牌照类型:1模板库生成,2自定义上传
+     */
+    private Integer certificateImageType;
+
     /**
     /**
      * pc添加水印授权牌照
      * pc添加水印授权牌照
      */
      */
@@ -80,12 +85,12 @@ public class ProductPo {
     private String appletsCertificateImage;
     private String appletsCertificateImage;
 
 
     /**
     /**
-     * 是否生成二维码授权牌:0否,1是
+     * 是否生成二维码授权牌:0否,1是(废弃)
      */
      */
     private Integer addQrCodeFlag;
     private Integer addQrCodeFlag;
 
 
     /**
     /**
-     * 生成二维码授权牌模板:1左下,2右边,3左边
+     * 生成二维码授权牌模板:1左下,2右边,3左边(废弃)
      */
      */
     private Integer addTemplateType;
     private Integer addTemplateType;
 
 

+ 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;
-
-}

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

@@ -15,6 +15,11 @@ public class UserPo {
      */
      */
     private Integer authUserId;
     private Integer authUserId;
 
 
+    /**
+     * 关联采美供应商id
+     */
+    private Integer cmShopId;
+
     /**
     /**
      * 账号名
      * 账号名
      */
      */

+ 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 userMobile;
 
 
+    /**
+     * 运营联系人
+     */
+    private String linkMan;
+
+    /**
+     * 运营联系人手机号
+     */
+    private String linkMobile;
+
     /**
     /**
      * 一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5
      * 一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5
      */
      */

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

@@ -71,23 +71,23 @@ public class AuthProductVo {
      */
      */
     private Integer authUserId;
     private Integer authUserId;
     /**
     /**
-     * 声明类型:1弹窗声明,2链接声明
+     * 声明类型:1弹窗声明,2链接声明(废弃)
      */
      */
     private Integer statementType;
     private Integer statementType;
     /**
     /**
-     * 声明弹窗内容
+     * 声明弹窗内容(废弃)
      */
      */
     private String statementContent;
     private String statementContent;
     /**
     /**
-     * 声明链接
+     * 声明链接(废弃)
      */
      */
     private String statementLink;
     private String statementLink;
     /**
     /**
-     * 声明图片
+     * 声明图片(废弃)
      */
      */
     private String statementImage;
     private String statementImage;
     /**
     /**
-     * 声明文件
+     * 声明文件(废弃)
      */
      */
     private StatementFileVo statementFile;
     private StatementFileVo statementFile;
     /**
     /**

+ 23 - 3
src/main/java/com/caimei/model/vo/ProductFormVo.java

@@ -24,6 +24,16 @@ public class ProductFormVo {
      */
      */
     private Integer authId;
     private Integer authId;
 
 
+    /**
+     * 机构设备关联id
+     */
+    private Integer relationId;
+
+    /**
+     * 认证方式:1新设备认证,2关联已认证设备
+     */
+    private Integer authType;
+
     /**
     /**
      * 品牌id
      * 品牌id
      */
      */
@@ -54,23 +64,28 @@ public class ProductFormVo {
      */
      */
     private String productImage;
     private String productImage;
 
 
+    /**
+     * 授权牌照类型:1模板库生成,2自定义上传
+     */
+    private Integer certificateImageType;
+
     /**
     /**
      * 授权牌照
      * 授权牌照
      */
      */
     private String certificateImage;
     private String certificateImage;
 
 
     /**
     /**
-     * 原授权牌照
+     * 原授权牌照(废弃)
      */
      */
     private String originalCertificateImage;
     private String originalCertificateImage;
 
 
     /**
     /**
-     * 是否生成二维码授权牌:0否,1是
+     * 是否生成二维码授权牌:0否,1是(废弃)
      */
      */
     private Integer addQrCodeFlag;
     private Integer addQrCodeFlag;
 
 
     /**
     /**
-     * 生成二维码授权牌模板:1左下,2右边,3左边
+     * 生成二维码授权牌模板:1左下,2右边,3左边(废弃)
      */
      */
     private Integer addTemplateType;
     private Integer addTemplateType;
 
 
@@ -103,4 +118,9 @@ public class ProductFormVo {
      * 审核不通过原因
      * 审核不通过原因
      */
      */
     private String invalidReason;
     private String invalidReason;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
 }
 }

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

@@ -11,37 +11,64 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 public class ProductListVo {
 public class ProductListVo {
-    @ApiModelProperty("商品id")
+    /**
+     * 商品id
+     */
     private Integer productId;
     private Integer productId;
 
 
-    @ApiModelProperty("商品名称")
+    /**
+     * 机构设备关联id
+     */
+    private Integer relationId;
+
+    /**
+     * 商品名称
+     */
     private String productName;
     private String productName;
 
 
-    @ApiModelProperty("商品SN码")
+    /**
+     * 商品SN码
+     */
     private String snCode;
     private String snCode;
 
 
-    @ApiModelProperty("上线状态:0下线,1上线,2待上线")
+    /**
+     * 上线状态:0下线,1上线,2待上线
+     */
     private Integer status;
     private Integer status;
 
 
-    @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer auditStatus;
     private Integer auditStatus;
 
 
-    @ApiModelProperty("供应商审核状态:0审核未通过,1审核通过,2待审核")
+    /**
+     * 供应商审核状态:0审核未通过,1审核通过,2待审核
+     */
     private Integer shopAuditStatus;
     private Integer shopAuditStatus;
 
 
-    @ApiModelProperty("创建时间")
+    /**
+     * 创建时间
+     */
     private Date createTime;
     private Date createTime;
 
 
-    @ApiModelProperty("创建人")
+    /**
+     * 创建人
+     */
     private String createBy;
     private String createBy;
 
 
-    @ApiModelProperty("审核时间")
+    /**
+     * 审核时间
+     */
     private Date auditTime;
     private Date auditTime;
 
 
-    @ApiModelProperty("审核人")
+    /**
+     * 审核人
+     */
     private String auditBy;
     private String auditBy;
 
 
-    @ApiModelProperty("审核不通过原因")
+    /**
+     * 审核不通过原因
+     */
     private String invalidReason;
     private String invalidReason;
 
 
     /**
     /**

+ 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;
+}

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

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

+ 47 - 15
src/main/java/com/caimei/model/vo/ShopFormVo.java

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

+ 25 - 15
src/main/java/com/caimei/model/vo/ShopInfoVo.java

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

+ 19 - 3
src/main/java/com/caimei/service/auth/AuthProductService.java

@@ -66,14 +66,15 @@ public interface AuthProductService {
      *                       }
      *                       }
      * @return ResponseJson
      * @return ResponseJson
      */
      */
-    ResponseJson saveProduct(ProductSaveDto productSaveDto, boolean importFlag) throws IOException;
+    ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException;
 
 
     /**
     /**
      * 获取授权商品回显数据
      * 获取授权商品回显数据
-     * @param productId     商品id
+     *
+     * @param relationId     机构设备关联id
      * @return  ProductFormVo
      * @return  ProductFormVo
      */
      */
-    ResponseJson<ProductFormVo> getProductFormData(Integer productId);
+    ResponseJson<ProductFormVo> getProductFormData(Integer relationId);
 
 
     /**
     /**
      * 根据品牌授权id获取商品id列表
      * 根据品牌授权id获取商品id列表
@@ -167,6 +168,21 @@ public interface AuthProductService {
      * @return
      * @return
      */
      */
     ResponseJson checkAuthProduct(Integer productId);
     ResponseJson checkAuthProduct(Integer productId);
+
+    /**
+     * 获取设备详情
+     * @param productId
+     * @param snCode
+     * @return
+     */
+    ResponseJson<ProductFormVo> getProductDetails(Integer productId, String snCode);
+
+    /**
+     * sn码列表
+     * @param authUserId
+     * @return
+     */
+    ResponseJson<List<String>> getSnCodeList(Integer authUserId);
 }
 }
 
 
 
 

+ 5 - 1
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 com.github.pagehelper.PageInfo;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
-import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -120,4 +119,9 @@ public interface AuthService {
      * @return
      * @return
      */
      */
     ResponseJson checkAuth(Integer authId);
     ResponseJson checkAuth(Integer authId);
+
+    /**
+     * 更改明星标识
+     */
+    ResponseJson starAuth(Integer authId, Integer starFlag);
 }
 }

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

@@ -2,6 +2,7 @@ package com.caimei.service.auth;
 
 
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ShopInfoDto;
 import com.caimei.model.dto.ShopInfoDto;
+import com.caimei.model.po.UserPo;
 import com.caimei.model.vo.*;
 import com.caimei.model.vo.*;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -84,7 +85,7 @@ public interface ShopService {
      * @param appSecret
      * @param appSecret
      * @param shopInfoList
      * @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);
 
 
     /**
     /**
      * 获取供应商回显数据
      * 获取供应商回显数据
@@ -169,4 +170,9 @@ public interface ShopService {
      * @return
      * @return
      */
      */
     ResponseJson updateAllAuthImage(Integer authUserId);
     ResponseJson updateAllAuthImage(Integer authUserId);
+
+    /**
+     * 更改联系人
+     */
+    ResponseJson changeLinkMan(Integer authUserId, String linkMan);
 }
 }

+ 20 - 4
src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java

@@ -147,8 +147,16 @@ public class AuthClubServiceImpl implements AuthClubService {
             clubUser.setPassword("rzt123456");
             clubUser.setPassword("rzt123456");
             clubUser.setStatus(1);
             clubUser.setStatus(1);
             clubMapper.insertClubUser(clubUser);
             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) {
             if (!sendSms) {
                 log.info("供应商添加机构用户-密码发送失败,手机号:" + mobile);
                 log.info("供应商添加机构用户-密码发送失败,手机号:" + mobile);
                 return ResponseJson.error("发送失败,请确认手机号无误");
                 return ResponseJson.error("发送失败,请确认手机号无误");
@@ -185,8 +193,16 @@ public class AuthClubServiceImpl implements AuthClubService {
         clubMapper.updateClubUserPassword(clubUserId, md5Password);
         clubMapper.updateClubUserPassword(clubUserId, md5Password);
         WxClubUserVo clubUser = clubMapper.getWxClubUser(null, null, null, null, clubUserId);
         WxClubUserVo clubUser = clubMapper.getWxClubUser(null, null, null, null, clubUserId);
         String mobile = clubUser.getMobile();
         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) {
         if (!sendSms) {
             log.info("机构用户重置密码发送失败,手机号:" + mobile);
             log.info("机构用户重置密码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
             return ResponseJson.error("发送失败,请确认手机号无误");

+ 309 - 133
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -2,6 +2,7 @@ package com.caimei.service.auth.impl;
 
 
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.OSSClientBuilder;
+import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.AuthProductMapper;
 import com.caimei.mapper.cmMapper.AuthProductMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
@@ -27,11 +28,17 @@ import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.imageio.ImageIO;
+import javax.swing.*;
 import java.awt.*;
 import java.awt.*;
+import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * Description
  * Description
@@ -63,6 +70,9 @@ public class AuthProductServiceImpl implements AuthProductService {
     @Value("${caimei.oldapi}")
     @Value("${caimei.oldapi}")
     private String wwwServer;
     private String wwwServer;
 
 
+    @Autowired
+    private FastDfsClient client;
+
     @Autowired
     @Autowired
     public void setUploadService(UploadService uploadService) {
     public void setUploadService(UploadService uploadService) {
         this.uploadService = uploadService;
         this.uploadService = uploadService;
@@ -117,8 +127,24 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success("删除授权商品成功");
         return ResponseJson.success("删除授权商品成功");
     }
     }
 
 
+    /**
+     * 保存逻辑
+     * relationId
+     *             null
+     *                 新设备:插入设备、插入关联信息
+     *                 关联设备:更新设备、插入关联信息
+     *             notNull
+     *                 数据库新设备
+     *                     新设备:更新设备、原设备无需更新关联关系
+     *                     关联设备:更新设备、更新关联信息(若原设备无机构关联,应删除该设备)
+     *                 数据库关联设备
+     *                     新设备:插入设备、更新关联信息
+     *                     关联设备:更新设备、更新关联信息
+     */
     @Override
     @Override
-    public ResponseJson saveProduct(ProductSaveDto productSaveDto, boolean importFlag) throws IOException {
+    public ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException {
+        Integer relationId = productSaveDto.getRelationId();
+        Integer authType = productSaveDto.getAuthType();
         Integer productId = productSaveDto.getProductId();
         Integer productId = productSaveDto.getProductId();
         Integer authId = productSaveDto.getAuthId();
         Integer authId = productSaveDto.getAuthId();
         Integer brandId = productSaveDto.getBrandId();
         Integer brandId = productSaveDto.getBrandId();
@@ -127,8 +153,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         String productImage = productSaveDto.getProductImage();
         String productImage = productSaveDto.getProductImage();
         String snCode = productSaveDto.getSnCode();
         String snCode = productSaveDto.getSnCode();
         String certificateImage = productSaveDto.getCertificateImage();
         String certificateImage = productSaveDto.getCertificateImage();
-        Integer addQrCodeFlag = productSaveDto.getAddQrCodeFlag();
-        Integer addTemplateType = productSaveDto.getAddTemplateType();
+        Integer certificateImageType = productSaveDto.getCertificateImageType();
         Integer createBy = productSaveDto.getCreateBy();
         Integer createBy = productSaveDto.getCreateBy();
         String purchaseWay = productSaveDto.getPurchaseWay();
         String purchaseWay = productSaveDto.getPurchaseWay();
         String invoiceImage = productSaveDto.getInvoiceImage();
         String invoiceImage = productSaveDto.getInvoiceImage();
@@ -163,29 +188,28 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
         if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
             return ResponseJson.error("参数异常,该商品SN码已存在,请重新输入", null);
             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 (1 == addQrCodeFlag && null == addTemplateType) {
-                return ResponseJson.error("参数异常,请选择二维码授权牌模板", null);
+        if (1 == source) {
+            if (2 == certificateImageType && StringUtils.isEmpty(certificateImage)) {
+                return ResponseJson.error("授权牌不能为空");
             }
             }
+        }else {
+            // 机构添加默认模板库生成
+            certificateImageType = 1;
         }
         }
         // 是否为添加操作
         // 是否为添加操作
-        boolean insertFlag = null == productId;
+        boolean newRelation = null == relationId;
+        ProductRelationVo dbRelation = null;
         ProductFormVo dbProduct = null;
         ProductFormVo dbProduct = null;
-        if (!insertFlag) {
-            dbProduct = authProductMapper.getProductFormByProductId(productId);
+        if (!newRelation) {
+            dbRelation = authProductMapper.getProductRelation(relationId);
+            dbProduct = authProductMapper.getProductFormData(relationId);
         }
         }
         /*
         /*
             组装商品数据
             组装商品数据
          */
          */
         ProductPo product = new ProductPo();
         ProductPo product = new ProductPo();
-        // 授权id
-        product.setAuthId(authId);
+        // 设备id
+        product.setProductId(productId);
         // 品牌id
         // 品牌id
         product.setBrandId(brandId);
         product.setBrandId(brandId);
         // 设备分类id
         // 设备分类id
@@ -200,8 +224,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         product.setSnCode(snCode);
         product.setSnCode(snCode);
         // 授权牌照
         // 授权牌照
         product.setCertificateImage(certificateImage);
         product.setCertificateImage(certificateImage);
-        product.setAddQrCodeFlag(addQrCodeFlag);
-        product.setAddTemplateType(addTemplateType);
+        product.setCertificateImageType(certificateImageType);
         // 购买渠道
         // 购买渠道
         product.setPurchaseWay(purchaseWay);
         product.setPurchaseWay(purchaseWay);
         // 发票图片
         // 发票图片
@@ -220,117 +243,64 @@ public class AuthProductServiceImpl implements AuthProductService {
         product.setAuditTime(new Date());
         product.setAuditTime(new Date());
         product.setCheckFlag(0);
         product.setCheckFlag(0);
         product.setShopAuditStatus(1 == source ? 1 : 2);
         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));
+        // 创建人id
+        product.setCreateBy(createBy);
+        // 创建来源
+        product.setCreateSource(source);
+        // 创建时间
+        product.setCreateTime(new Date());
+
+        if (newRelation) {
+            if (1 == authType) {
+                // 插入授权商品
+                authProductMapper.insertProduct(product);
+                // 插入机构设备关联关系
+                relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
+            } else {
+                // 关联设备,更新设备
+                authProductMapper.updateProductByProductId(product);
+                // 插入机构设备关联关系
+                relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
             }
             }
-            // 插入授权商品
-            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);
-            }
-            // 自动生成授权牌
-
         } else {
         } else {
-            // 商品id
-            product.setProductId(productId);
-            if (1 == source) {
-                ProductPo dbProductImage = authProductMapper.getImageByProductId(productId);
-                // 数据库该商品授权牌是否添加二维码
-                Integer dbAddQrCodeFlag = dbProductImage.getAddQrCodeFlag();
-                // 数据库该商品授权牌添加二维码模板
-                Integer dbAddTemplateType = dbProductImage.getAddTemplateType();
-                // 授权牌照是否重新上传
-                boolean updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(dbProductImage.getCertificateImage())) || (StringUtils.isEmpty(dbProductImage.getPcCertificateImage()) || StringUtils.isEmpty(dbProductImage.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(dbProductImage.getOriginalCertificateImage());
-                                addWaterMarkSign = true;
-                            }
-                        } else if (1 == addQrCodeFlag) {
-                            // 原本是,现在是
-                            if (updateImageFlag) {
-                                // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
-                                product.setOriginalCertificateImage(product.getCertificateImage());
-                                addQrCodeSign = true;
-                                addWaterMarkSign = true;
-                            } else if (!addTemplateType.equals(dbAddTemplateType)) {
-                                // 原图片,更改模板,将当前授权牌替换为原图,生成二维码授权牌,生成水印图片
-                                product.setCertificateImage(dbProductImage.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());
         authProductMapper.deleteParamsByProductId(product.getProductId());
@@ -345,6 +315,203 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success("保存授权商品成功");
         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(3165 * 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 void insertProduct(Integer createBy, Integer source, ProductPo product) throws IOException {
+        // 添加新设备
+        // 原授权牌照
+        product.setOriginalCertificateImage(product.getCertificateImage());
+        if (1 == source && StringUtils.isNotEmpty(product.getCertificateImage()) && (null == addQrCodeFlag || 0 == addQrCodeFlag)) {
+            //授权牌照不添加二维码,直接添加水印
+            product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
+            product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
+        }
+        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);
+        }
+    }*/
+
+    /*private void updateProduct(Integer productId, Integer addQrCodeFlag, Integer addTemplateType, Integer source, ProductPo product) throws IOException {
+        // 商品id
+        product.setProductId(productId);
+        if (1 == source) {
+            ProductPo dbProductImage = authProductMapper.getImageByProductId(productId);
+            // 数据库该商品授权牌是否添加二维码
+            Integer dbAddQrCodeFlag = dbProductImage.getAddQrCodeFlag();
+            // 数据库该商品授权牌添加二维码模板
+            Integer dbAddTemplateType = dbProductImage.getAddTemplateType();
+            // 授权牌照是否重新上传
+            boolean updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(dbProductImage.getCertificateImage())) || (StringUtils.isEmpty(dbProductImage.getPcCertificateImage()) || StringUtils.isEmpty(dbProductImage.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(dbProductImage.getOriginalCertificateImage());
+                            addWaterMarkSign = true;
+                        }
+                    } else if (1 == addQrCodeFlag) {
+                        // 原本是,现在是
+                        if (updateImageFlag) {
+                            // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
+                            product.setOriginalCertificateImage(product.getCertificateImage());
+                            addQrCodeSign = true;
+                            addWaterMarkSign = true;
+                        } else if (!addTemplateType.equals(dbAddTemplateType)) {
+                            // 原图片,更改模板,将当前授权牌替换为原图,生成二维码授权牌,生成水印图片
+                            product.setCertificateImage(dbProductImage.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;
+                        }
+                        // 原图片,不做更改
+                    }
+                }
+            } 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));
+            }
+        }
+        // 自动生成授权牌
+
+        // 更新授权商品
+        authProductMapper.updateProductByProductId(product);
+    }*/
+
     private String addWaterMark(String image,Integer type) throws IOException {
     private String addWaterMark(String image,Integer type) throws IOException {
         //type:1pc,2applets
         //type:1pc,2applets
         ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
         ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
@@ -367,7 +534,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         return imagePath;
         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 qrCodeLink = wwwServer + "/product/auth/product-" + productId + ".html";
         String qrCodeImage = ImageUtils.addQrCode(certificateImage, qrCodeLink, addTemplateType);
         String qrCodeImage = ImageUtils.addQrCode(certificateImage, qrCodeLink, addTemplateType);
         String imagePath = null;
         String imagePath = null;
@@ -381,20 +548,17 @@ public class AuthProductServiceImpl implements AuthProductService {
             log.info(">>>>>>>>>>>>>>>>二维码图片上传失败");
             log.info(">>>>>>>>>>>>>>>>二维码图片上传失败");
         }
         }
         return imagePath;
         return imagePath;
-    }
+    }*/
 
 
     @Override
     @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) {
         if (null == productForm) {
-            return ResponseJson.error("商品不存在", null);
+            return ResponseJson.error("设备不存在", null);
         }
         }
         List<ProductParamPo> paramList = authProductMapper.getProductTypeParamList(productForm.getProductTypeId());
         List<ProductParamPo> paramList = authProductMapper.getProductTypeParamList(productForm.getProductTypeId());
         if (null == paramList || paramList.size() == 0) {
         if (null == paramList || paramList.size() == 0) {
-            paramList = authProductMapper.getParamsByProductId(productId);
+            paramList = authProductMapper.getParamsByProductId(productForm.getProductId());
         }
         }
         productForm.setParamList(paramList);
         productForm.setParamList(paramList);
         return ResponseJson.success(productForm);
         return ResponseJson.success(productForm);
@@ -678,4 +842,16 @@ public class AuthProductServiceImpl implements AuthProductService {
         return ResponseJson.success();
         return ResponseJson.success();
     }
     }
 
 
+    @Override
+    public ResponseJson<ProductFormVo> getProductDetails(Integer productId, String snCode) {
+        ProductFormVo product =  authProductMapper.getProductDetails(productId, snCode);
+        return ResponseJson.success(product);
+    }
+
+    @Override
+    public ResponseJson<List<String>> getSnCodeList(Integer authUserId) {
+        List<String> snCodeList = authProductMapper.getSnCodeList(authUserId);
+        return ResponseJson.success(snCodeList);
+    }
+
 }
 }

+ 6 - 11
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.cmMapper.AuthProductMapper;
 import com.caimei.mapper.ldmMapper.LdmMapper;
 import com.caimei.mapper.ldmMapper.LdmMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
-import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.*;
 import com.caimei.model.po.*;
 import com.caimei.model.vo.*;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.AuthProductService;
 import com.caimei.service.auth.AuthProductService;
@@ -13,18 +12,13 @@ import com.caimei.service.auth.AuthService;
 import com.caimei.service.auth.ShopService;
 import com.caimei.service.auth.ShopService;
 import com.caimei.service.auth.UploadService;
 import com.caimei.service.auth.UploadService;
 import com.caimei.utils.Base64Util;
 import com.caimei.utils.Base64Util;
-import com.caimei.utils.ExcelOperateUtil;
 import com.caimei.utils.ImageUtils;
 import com.caimei.utils.ImageUtils;
-import com.caimei.utils.PoiUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.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.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.ClassPathResource;
@@ -35,20 +29,15 @@ import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
 import javax.swing.*;
 import javax.swing.*;
 import java.awt.*;
 import java.awt.*;
 import java.awt.Font;
 import java.awt.Font;
-import java.awt.image.BufferedImage;
 import java.io.*;
 import java.io.*;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URL;
-import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 import java.util.List;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 
 
 /**
 /**
  * Description
  * Description
@@ -206,6 +195,12 @@ public class AuthServiceImpl implements AuthService {
         return ResponseJson.success();
         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) {
     private void insertBanner(String pic, Integer authId) {
         if (StringUtils.isNotEmpty(pic)) {
         if (StringUtils.isNotEmpty(pic)) {
             String imagePath = "https://wangdian.skinovachina.com" + pic;
             String imagePath = "https://wangdian.skinovachina.com" + pic;

+ 49 - 83
src/main/java/com/caimei/service/auth/impl/ShopServiceImpl.java

@@ -21,12 +21,15 @@ import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * Description
  * Description
@@ -110,12 +113,15 @@ public class ShopServiceImpl implements ShopService {
         String md5Password = Md5Util.md5(newPassword);
         String md5Password = Md5Util.md5(newPassword);
         userMapper.updatePasswordByUserId(authUserId, md5Password);
         userMapper.updatePasswordByUserId(authUserId, md5Password);
         String mobile = shopMapper.getShopMobileByUserId(authUserId);
         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("密码重置成功");
         return ResponseJson.success("密码重置成功");
     }
     }
 
 
@@ -201,70 +207,39 @@ public class ShopServiceImpl implements ShopService {
     }
     }
 
 
     @Override
     @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 (insertFlag) {
             // 添加时验证手机号是否已被使用
             // 添加时验证手机号是否已被使用
             if (null != userIdByMobile) {
             if (null != userIdByMobile) {
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
             }
             }
             // 添加时验证供应商名称是否已被使用
             // 添加时验证供应商名称是否已被使用
-            Integer userIdByShopName = shopMapper.getUserIdByShopName(shopName);
+            Integer userIdByShopName = shopMapper.getUserIdByShopName(shop.getName());
             if (null != userIdByShopName) {
             if (null != userIdByShopName) {
                 return ResponseJson.error("该供应商名称已经存在,请重新输入", null);
                 return ResponseJson.error("该供应商名称已经存在,请重新输入", null);
             }
             }
             // 添加时验证appId是否已被使用
             // 添加时验证appId是否已被使用
-            if (StringUtils.isNotEmpty(appId) && null != userIdByAppId) {
+            if (StringUtils.isNotEmpty(shop.getAppId()) && null != userIdByAppId) {
                 return ResponseJson.error("该appId已被使用,请重新输入", null);
                 return ResponseJson.error("该appId已被使用,请重新输入", null);
             }
             }
         } else {
         } else {
             // 修改时验证新手机号是否已被使用
             // 修改时验证新手机号是否已被使用
-            if (null != userIdByMobile && !userIdByMobile.equals(authUserId)) {
+            if (null != userIdByMobile && !userIdByMobile.equals(shop.getAuthUserId())) {
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
                 return ResponseJson.error("该手机号已被使用,请重新输入", null);
             }
             }
             // 修改时验证新appId是否已被使用
             // 修改时验证新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);
                 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) {
         if (insertFlag) {
             // 用户身份:1管理员,2供应商
             // 用户身份:1管理员,2供应商
             shop.setUserIdentity(2);
             shop.setUserIdentity(2);
-            // 供应商类型
-            shop.setShopType(shopType);
-            // 创建管理员id
-            shop.setCreateBy(createBy);
-            // 创建时间
-            shop.setCreateTime(new Date());
             // 设置随机8位密码
             // 设置随机8位密码
             String password = CodeUtil.generateCode(8);
             String password = CodeUtil.generateCode(8);
             String md5Pwd = Md5Util.md5(password);
             String md5Pwd = Md5Util.md5(password);
@@ -272,16 +247,18 @@ public class ShopServiceImpl implements ShopService {
             // 插入供应商用户
             // 插入供应商用户
             shopMapper.insertShop(shop);
             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");
             sysUserService.saveRoleRelation(shop.getAuthUserId(), "1");
             log.info("添加供应商,供应商用户id:" + shop.getAuthUserId());
             log.info("添加供应商,供应商用户id:" + shop.getAuthUserId());
         } else {
         } else {
-            shop.setAuthUserId(authUserId);
             // 更新供应商用户
             // 更新供应商用户
             shopMapper.updateShopByUserId(shop);
             shopMapper.updateShopByUserId(shop);
             log.info("更新供应商,供应商用户id:" + shop.getAuthUserId());
             log.info("更新供应商,供应商用户id:" + shop.getAuthUserId());
@@ -294,49 +271,32 @@ public class ShopServiceImpl implements ShopService {
                 shopInfo.setAuthUserId(shop.getAuthUserId());
                 shopInfo.setAuthUserId(shop.getAuthUserId());
                 // 插入供应商信息
                 // 插入供应商信息
                 shopMapper.insertShopInfo(shopInfo);
                 shopMapper.insertShopInfo(shopInfo);
-                if (4 == shopInfo.getStatementType()) {
-                    shopMapper.updateFileUserId(shopInfo.getStatementFileId(), shop.getAuthUserId());
-                }
             });
             });
         } else {
         } 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<ShopBrandVo> dbBrandList = shopMapper.getDbInfoBrandList(shop.getAuthUserId());
+            // 原品牌列表编辑后剩余的品牌id列表
+            List<Integer> newBrandList = shopInfoList.stream().filter(shopInfo -> shopInfo.getId() != null).map(ShopInfoDto::getId).collect(Collectors.toList());
+            for (ShopBrandVo dbBrand : dbBrandList) {
+                if (!newBrandList.contains(dbBrand.getId())) {
+                    // 判断被删除的品牌下是否还有未删除的商品,若存在,提示供应商需要删除后才能删除品牌
+                    Integer productCount = shopMapper.getProductCount(shop.getAuthUserId(), dbBrand.getId());
                     if (null != productCount && productCount > 0) {
                     if (null != productCount && productCount > 0) {
-                        return ResponseJson.error("该品牌已绑定供应商商品,无法进行删除");
+                        // 设置手动回滚事务
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ResponseJson.error("对不起,该品牌已绑定设备认证,暂时无法删除");
+                    } else {
+                        // 删除品牌
+                        shopMapper.deleteShopInfoById(dbBrand.getId());
                     }
                     }
                 }
                 }
             }
             }
-            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 -> {
             shopInfoList.forEach(shopInfoVo -> {
                 shopInfoVo.setAuthUserId(shop.getAuthUserId());
                 shopInfoVo.setAuthUserId(shop.getAuthUserId());
                 // 保存供应商信息数据
                 // 保存供应商信息数据
-                if (updateInfoBrandList.contains(shopInfoVo.getBrandId())) {
+                if (shopInfoVo.getId() != null) {
                     // 更新
                     // 更新
                     shopMapper.updateShopInfo(shopInfoVo);
                     shopMapper.updateShopInfo(shopInfoVo);
-                    if (4 != shopInfoVo.getStatementType()) {
-                        // 没有选择文件代理声明的情况下,若存在原来的文件,删除代理声明文件
-                        deleteFile(shop.getAuthUserId(),shopInfoVo.getBrandId());
-                    }
                 } else {
                 } else {
                     // 插入
                     // 插入
                     shopMapper.insertShopInfo(shopInfoVo);
                     shopMapper.insertShopInfo(shopInfoVo);
@@ -427,7 +387,7 @@ public class ShopServiceImpl implements ShopService {
         }
         }
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";;
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";;
         String content = "您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
         String content = "您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
-        Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+        Boolean sendSms = SmsUtils.sendSms(null, mobile, content);
         if (!sendSms) {
         if (!sendSms) {
             log.info("短信验证码发送失败,手机号:" + mobile);
             log.info("短信验证码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
             return ResponseJson.error("发送失败,请确认手机号无误");
@@ -520,4 +480,10 @@ public class ShopServiceImpl implements ShopService {
         });
         });
         return ResponseJson.success();
         return ResponseJson.success();
     }
     }
+
+    @Override
+    public ResponseJson changeLinkMan(Integer authUserId, String linkMan) {
+        shopMapper.updateShopLinkMan(authUserId, linkMan);
+        return ResponseJson.success();
+    }
 }
 }

+ 1 - 2
src/main/java/com/caimei/service/sys/SysMenuService.java

@@ -19,14 +19,13 @@ import java.util.Set;
 public interface SysMenuService {
 public interface SysMenuService {
     /**
     /**
      * 获取菜单列表
      * 获取菜单列表
-     * @param authUserId
      * @param parentId 父级菜单Id
      * @param parentId 父级菜单Id
      * @param menuType 菜单类型:1管理员菜单,2供应商菜单
      * @param menuType 菜单类型:1管理员菜单,2供应商菜单
      * @param status   状态:0启用,1停用
      * @param status   状态:0启用,1停用
      * @param pageNum  页码
      * @param pageNum  页码
      * @param pageSize 每页大小
      * @param pageSize 每页大小
      */
      */
-    ResponseJson<PageInfo<SysMenu>> getMenuList(Integer authUserId, Integer parentId, Integer menuType, Integer status, int pageNum, int pageSize);
+    ResponseJson<PageInfo<SysMenu>> getMenuList(Integer parentId, Integer menuType, Integer status, int pageNum, int pageSize);
     /**
     /**
      * 获取所有启用的菜单列表(树状结构返回)
      * 获取所有启用的菜单列表(树状结构返回)
      */
      */

+ 2 - 5
src/main/java/com/caimei/service/sys/impl/SysMenuServiceImpl.java

@@ -44,18 +44,15 @@ public class SysMenuServiceImpl implements SysMenuService {
 
 
     /**
     /**
      * 获取菜单列表
      * 获取菜单列表
-     *
-     * @param authUserId
-     * @param parentId 父级菜单Id
+     *  @param parentId 父级菜单Id
      * @param status   状态:0启用,1停用
      * @param status   状态:0启用,1停用
      * @param pageNum  页码
      * @param pageNum  页码
      * @param pageSize 每页大小
      * @param pageSize 每页大小
      */
      */
     @Override
     @Override
-    public ResponseJson<PageInfo<SysMenu>> getMenuList(Integer authUserId, Integer parentId, Integer menuType, Integer status, int pageNum, int pageSize) {
+    public ResponseJson<PageInfo<SysMenu>> getMenuList(Integer parentId, Integer menuType, Integer status, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
         PageHelper.startPage(pageNum, pageSize);
         List<SysMenu> menus = systemMapper.getMenuList(parentId, menuType, status);
         List<SysMenu> menus = systemMapper.getMenuList(parentId, menuType, status);
-
         PageInfo<SysMenu> pageData = new PageInfo<>(menus);
         PageInfo<SysMenu> pageData = new PageInfo<>(menus);
         return ResponseJson.success(pageData);
         return ResponseJson.success(pageData);
     }
     }

+ 1 - 2
src/main/java/com/caimei/service/wechat/impl/LoginServiceImpl.java

@@ -6,7 +6,6 @@ import com.caimei.mapper.cmMapper.ClubMapper;
 import com.caimei.mapper.cmMapper.LoginMapper;
 import com.caimei.mapper.cmMapper.LoginMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
 import com.caimei.mapper.cmMapper.ShopMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
-import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.vo.AuthVo;
 import com.caimei.model.vo.AuthVo;
 import com.caimei.model.vo.ShopFormVo;
 import com.caimei.model.vo.ShopFormVo;
 import com.caimei.model.vo.WxClubUserVo;
 import com.caimei.model.vo.WxClubUserVo;
@@ -103,7 +102,7 @@ public class LoginServiceImpl implements LoginService {
         }
         }
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";
         String content = "欢迎登录" + shopName + "会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
         String content = "欢迎登录" + shopName + "会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
-        Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+        Boolean sendSms = SmsUtils.sendSms(1, mobile, content);
         if (!sendSms) {
         if (!sendSms) {
             log.info("会员登录验证码发送失败,手机号:" + mobile);
             log.info("会员登录验证码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
             return ResponseJson.error("发送失败,请确认手机号无误");

+ 1 - 1
src/main/java/com/caimei/service/wechat/impl/RegisterServiceImpl.java

@@ -161,7 +161,7 @@ public class RegisterServiceImpl implements RegisterService {
                     product.setAuthId(authId);
                     product.setAuthId(authId);
                     product.setSource(2);
                     product.setSource(2);
                     product.setCreateBy(clubUserId);
                     product.setCreateBy(clubUserId);
-                    ResponseJson result = authProductService.saveProduct(product, false);
+                    ResponseJson result = authProductService.saveProduct(product);
                     if (0 != result.getCode()) {
                     if (0 != result.getCode()) {
                         // 设置手动回滚事务
                         // 设置手动回滚事务
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

+ 14 - 2
src/main/java/com/caimei/service/wechat/impl/WxUserServiceImpl.java

@@ -4,7 +4,9 @@ import com.caimei.components.RedisService;
 import com.caimei.mapper.cmMapper.*;
 import com.caimei.mapper.cmMapper.*;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthFormVo;
+import com.caimei.model.vo.ShopFormVo;
 import com.caimei.model.vo.WxClubUserVo;
 import com.caimei.model.vo.WxClubUserVo;
+import com.caimei.service.auth.ShopService;
 import com.caimei.service.wechat.WxUserService;
 import com.caimei.service.wechat.WxUserService;
 import com.caimei.utils.CodeUtil;
 import com.caimei.utils.CodeUtil;
 import com.caimei.utils.Md5Util;
 import com.caimei.utils.Md5Util;
@@ -33,6 +35,8 @@ public class WxUserServiceImpl implements WxUserService {
     private ClubMapper clubMapper;
     private ClubMapper clubMapper;
     @Resource
     @Resource
     private AuthMapper authMapper;
     private AuthMapper authMapper;
+    @Resource
+    private ShopMapper shopMapper;
 
 
     @Value("${spring.profiles.active}")
     @Value("${spring.profiles.active}")
     private String active;
     private String active;
@@ -67,9 +71,17 @@ public class WxUserServiceImpl implements WxUserService {
                 return ResponseJson.error("用户不存在");
                 return ResponseJson.error("用户不存在");
             }
             }
         }
         }
+        // 获取供应商名称
+        ShopFormVo shop = shopMapper.getShopByUserId(authUserId);
+        String shopName = "";
+        if (null == shop) {
+            return ResponseJson.error("供应商不存在");
+        } else {
+            shopName = shop.getShopName();
+        }
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";
         String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";
-        String content = "您的短信验证码为:" + verifyCode + ",该验证码 " + (1 == type ? 30 : 5) + " 分钟内有效,请勿泄漏于他人。";
-        Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+        String content = "("+ shopName +")您认证通短信验证码为:" + verifyCode + ",该验证码 " + (1 == type ? 30 : 5) + " 分钟内有效,请勿泄漏于他人。【采美网提供技术支持】";
+        Boolean sendSms = SmsUtils.sendSms(1, mobile, content);
         String msgType = 1 == type ? "注册" : 2 == type ? "忘记密码" : "";
         String msgType = 1 == type ? "注册" : 2 == type ? "忘记密码" : "";
         if (!sendSms) {
         if (!sendSms) {
             log.info(msgType + "验证码发送失败,手机号:" + mobile);
             log.info(msgType + "验证码发送失败,手机号:" + mobile);

+ 21 - 0
src/main/java/com/caimei/utils/ImageUtils.java

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
+import sun.font.FontDesignMetrics;
 import sun.misc.BASE64Encoder;
 import sun.misc.BASE64Encoder;
 
 
 import javax.imageio.ImageIO;
 import javax.imageio.ImageIO;
@@ -668,4 +669,24 @@ public class ImageUtils {
 		}
 		}
 		return filePath;
 		return filePath;
 	}
 	}
+
+	/**
+	 * 获取水印文字总长度
+	 *
+	 * @param waterMarkContent 水印的文字
+	 * @param g
+	 * @return 水印文字总长度
+	 */
+	public static int getWatermarkLength(String waterMarkContent, Graphics2D g) {
+		return g.getFontMetrics(g.getFont()).charsWidth(waterMarkContent.toCharArray(), 0, waterMarkContent.length());
+	}
+
+	public static int getWordWidth(Font font, String content) {
+		FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
+		int width = 0;
+		for (int i = 0; i < content.length(); i++) {
+			width += metrics.charWidth(content.charAt(i));
+		}
+		return width;
+	}
 }
 }

+ 6 - 3
src/main/java/com/caimei/utils/SmsUtils.java

@@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
@@ -35,9 +34,11 @@ public class SmsUtils {
         SmsUtils.core = core;
         SmsUtils.core = core;
     }
     }
 
 
-    public static Boolean sendSms(int martId, String mobile, String content) {
+    public static Boolean sendSms(Integer type, String mobile, String content) {
         try {
         try {
-            if (!"prod".equals(active)) {
+            ArrayList<String> passList = new ArrayList<>();
+            passList.add("15113936829");
+            if (!"prod".equals(active) && !passList.contains(mobile)) {
                 return true;
                 return true;
             }
             }
             if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
             if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
@@ -46,6 +47,8 @@ public class SmsUtils {
                 Matcher matcher = pattern.matcher(mobile);
                 Matcher matcher = pattern.matcher(mobile);
                 if (matcher.matches()) {
                 if (matcher.matches()) {
                     Map<String, Object> map = new HashMap<>(2);
                     Map<String, Object> map = new HashMap<>(2);
+                    // 短信类型:1通知短信,2验证码短信,3营销短信
+                    map.put("type", type);
                     map.put("content", content);
                     map.put("content", content);
                     map.put("mobile", mobile);
                     map.put("mobile", mobile);
                     String url = core + "/tools/sms/send";
                     String url = core + "/tools/sms/send";

+ 11 - 2
src/main/resources/mapper/AuthMapper.xml

@@ -3,12 +3,12 @@
 <mapper namespace="com.caimei.mapper.cmMapper.AuthMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.AuthMapper">
     <insert id="insertAuth" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthPo">
     <insert id="insertAuth" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthPo">
         insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
         insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
-                                   mobile, userMobile, firstClubType, secondClubType, medicalLicenseImage, empNum,
+                                   mobile, userMobile, linkMan, linkMobile, firstClubType, secondClubType, medicalLicenseImage, empNum,
                                    logo, customFlag, remarks, authCode, authDate, authImageLogo, authImage,
                                    logo, customFlag, remarks, authCode, authDate, authImageLogo, authImage,
                                    authImageType, status, createTime, createBy, createSource, auditBy,
                                    authImageType, status, createTime, createBy, createSource, auditBy,
                                    auditTime, auditStatus, shopAuditBy, shopAuditTime, shopAuditStatus, checkFlag, delFlag)
                                    auditTime, auditStatus, shopAuditBy, shopAuditTime, shopAuditStatus, checkFlag, delFlag)
         values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
         values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
-                #{mobile}, #{userMobile}, #{firstClubType}, #{secondClubType}, #{medicalLicenseImage}, #{empNum},
+                #{mobile}, #{userMobile}, #{linkMan}, #{linkMobile}, #{firstClubType}, #{secondClubType}, #{medicalLicenseImage}, #{empNum},
                 #{logo}, #{customFlag}, #{remarks}, #{authCode}, #{authDate}, #{authImageLogo}, #{authImage},
                 #{logo}, #{customFlag}, #{remarks}, #{authCode}, #{authDate}, #{authImageLogo}, #{authImage},
                 #{authImageType}, #{status}, NOW(), #{createBy}, #{createSource}, #{auditBy},
                 #{authImageType}, #{status}, NOW(), #{createBy}, #{createSource}, #{auditBy},
                 #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{checkFlag}, #{delFlag})
                 #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{checkFlag}, #{delFlag})
@@ -33,6 +33,8 @@
             lat                 = #{lat},
             lat                 = #{lat},
             mobile              = #{mobile},
             mobile              = #{mobile},
             userMobile          = #{userMobile},
             userMobile          = #{userMobile},
+            linkMan             = #{linkMan},
+            linkMobile          = #{linkMobile},
             firstClubType       = #{firstClubType},
             firstClubType       = #{firstClubType},
             secondClubType      = #{secondClubType},
             secondClubType      = #{secondClubType},
             medicalLicenseImage = #{medicalLicenseImage},
             medicalLicenseImage = #{medicalLicenseImage},
@@ -99,6 +101,11 @@
         set checkFlag = 1
         set checkFlag = 1
         where id = #{authId}
         where id = #{authId}
     </update>
     </update>
+    <update id="starAuth">
+        update cm_brand_auth
+        set starFlag = #{starFlag}
+        where id = #{authId}
+    </update>
     <delete id="deleteBanner">
     <delete id="deleteBanner">
         delete from cm_brand_auth_banner where authId = #{authId}
         delete from cm_brand_auth_banner where authId = #{authId}
     </delete>
     </delete>
@@ -305,6 +312,8 @@
                lat,
                lat,
                mobile,
                mobile,
                userMobile,
                userMobile,
+               linkMan,
+               linkMobile,
                firstClubType,
                firstClubType,
                secondClubType,
                secondClubType,
                medicalLicenseImage,
                medicalLicenseImage,

+ 104 - 73
src/main/resources/mapper/AuthProductMapper.xml

@@ -2,14 +2,15 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.cmMapper.AuthProductMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.AuthProductMapper">
     <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductPo">
     <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductPo">
-        insert into cm_brand_auth_product(`authId`, `brandId`, `productTypeId`, `snCode`, name, image,
-                                          `originalCertificateImage`, `certificateImage`, `pcCertificateImage`,
-                                          `appletsCertificateImage`, `addQrCodeFlag`, `addTemplateType`,
+        insert into cm_brand_auth_product(`brandId`, `productTypeId`, `snCode`, name, image,
+                                          `certificateImage`, `pcCertificateImage`,
+                                          `appletsCertificateImage`,
                                           purchaseWay, invoiceImage, `status`, auditBy, auditTime,
                                           purchaseWay, invoiceImage, `status`, auditBy, auditTime,
-                                          `auditStatus`, shopAuditStatus, checkFlag, `createTime`, `createBy`, createSource)
-        values (#{authId}, #{brandId}, #{productTypeId}, #{snCode}, #{name}, #{image},
-                #{originalCertificateImage}, #{certificateImage}, #{pcCertificateImage},
-                #{appletsCertificateImage}, #{addQrCodeFlag}, #{addTemplateType},
+                                          `auditStatus`, shopAuditStatus, checkFlag, `createTime`, `createBy`,
+                                          createSource)
+        values (#{brandId}, #{productTypeId}, #{snCode}, #{name}, #{image},
+                #{certificateImage}, #{pcCertificateImage},
+                #{appletsCertificateImage},
                 #{purchaseWay}, #{invoiceImage}, #{status}, #{auditBy}, #{auditTime},
                 #{purchaseWay}, #{invoiceImage}, #{status}, #{auditBy}, #{auditTime},
                 #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource})
                 #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource})
     </insert>
     </insert>
@@ -25,6 +26,10 @@
         insert into cm_brand_product_type_param (productTypeId, name, content)
         insert into cm_brand_product_type_param (productTypeId, name, content)
         values (#{productTypeId}, #{paramName}, #{paramContent})
         values (#{productTypeId}, #{paramName}, #{paramContent})
     </insert>
     </insert>
+    <insert id="insertProductRelation" useGeneratedKeys="true" keyColumn="id">
+        insert into cm_brand_product_relation (authId, productId, authType)
+        values (#{authId}, #{productId}, #{authType})
+    </insert>
 
 
     <update id="updateProductStatusByProductId">
     <update id="updateProductStatusByProductId">
         update cm_brand_auth_product
         update cm_brand_auth_product
@@ -33,16 +38,11 @@
     </update>
     </update>
     <update id="updateProductByProductId">
     <update id="updateProductByProductId">
         update cm_brand_auth_product
         update cm_brand_auth_product
-        <set>
+        set
             `brandId`          = #{brandId},
             `brandId`          = #{brandId},
             `productTypeId`    = #{productTypeId},
             `productTypeId`    = #{productTypeId},
             `snCode`           = #{snCode},
             `snCode`           = #{snCode},
             `certificateImage` = #{certificateImage},
             `certificateImage` = #{certificateImage},
-            `addQrCodeFlag`    = #{addQrCodeFlag},
-            `addTemplateType`  = #{addTemplateType},
-            <if test="originalCertificateImage != null and originalCertificateImage != ''">
-                `originalCertificateImage`      = #{originalCertificateImage},
-            </if>
             <if test="pcCertificateImage != null and pcCertificateImage != ''">
             <if test="pcCertificateImage != null and pcCertificateImage != ''">
                 `pcCertificateImage`      = #{pcCertificateImage},
                 `pcCertificateImage`      = #{pcCertificateImage},
             </if>
             </if>
@@ -64,7 +64,6 @@
             `auditStatus`      = #{auditStatus},
             `auditStatus`      = #{auditStatus},
             `shopAuditStatus`  = #{shopAuditStatus},
             `shopAuditStatus`  = #{shopAuditStatus},
             checkFlag          = #{checkFlag}
             checkFlag          = #{checkFlag}
-        </set>
         where id = #{productId};
         where id = #{productId};
     </update>
     </update>
     <update id="updateImageByProductId">
     <update id="updateImageByProductId">
@@ -155,18 +154,27 @@
     <update id="checkAuthProduct">
     <update id="checkAuthProduct">
         update cm_brand_auth_product set checkFlag = 1 where id = #{productId}
         update cm_brand_auth_product set checkFlag = 1 where id = #{productId}
     </update>
     </update>
+    <update id="updateProductRelation">
+        update cm_brand_product_relation
+        set authId    = #{authId},
+            productId = #{productId},
+            authType  = #{authType}
+        where id = #{relationId}
+    </update>
     <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
     <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
         select p.id as productId,if(p.productTypeId is null,p.name,t.name) as productName,
         select p.id as productId,if(p.productTypeId is null,p.name,t.name) as productName,
-               snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
-               if(p.createSource = 1,cu.name,cbcu.mobile) as createBy,
-               au.name as auditBy,p.auditTime,p.invalidReason, ifnull(au1.name,au1.mobile) as shopAuditBy,p.shopAuditTime
+        snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
+        if(p.createSource = 1,cu.name,cbcu.mobile) as createBy,
+        au.name as auditBy,p.auditTime,p.invalidReason, ifnull(au1.name,au1.mobile) as shopAuditBy,
+        p.shopAuditTime,r.id as relationId
         from cm_brand_auth_product p
         from cm_brand_auth_product p
+        left join cm_brand_product_relation r on p.id = r.productId
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
         left join cm_brand_auth_user cu on p.createBy = cu.authUserId
         left join cm_brand_auth_user cu on p.createBy = cu.authUserId
         left join cm_brand_auth_user au on p.auditBy = au.authUserId
         left join cm_brand_auth_user au on p.auditBy = au.authUserId
         left join cm_brand_auth_user au1 on p.shopAuditBy = au1.authUserId
         left join cm_brand_auth_user au1 on p.shopAuditBy = au1.authUserId
         left join cm_brand_club_user cbcu on p.createBy = cbcu.id
         left join cm_brand_club_user cbcu on p.createBy = cbcu.id
-        where p.authId = #{authId}
+        where r.authId = #{authId}
         <if test="productName != null and productName != ''">
         <if test="productName != null and productName != ''">
             and (t.name like CONCAT('%',#{productName},'%') or t.name like CONCAT('%',#{productName},'%'))
             and (t.name like CONCAT('%',#{productName},'%') or t.name like CONCAT('%',#{productName},'%'))
         </if>
         </if>
@@ -205,28 +213,30 @@
     <select id="getProductIdBySnCode" resultType="java.lang.Integer">
     <select id="getProductIdBySnCode" resultType="java.lang.Integer">
         select id from cm_brand_auth_product where snCode = #{snCode} limit 1
         select id from cm_brand_auth_product where snCode = #{snCode} limit 1
     </select>
     </select>
-    <select id="getProductFormByProductId" resultType="com.caimei.model.vo.ProductFormVo">
+    <select id="getProductFormData" resultType="com.caimei.model.vo.ProductFormVo">
         select p.`id`                                                      as productId,
         select p.`id`                                                      as productId,
-               `authId`,
+               r.authId,
                if(p.productTypeId is null, cb1.name, cb2.name)             as brandName,
                if(p.productTypeId is null, cb1.name, cb2.name)             as brandName,
                p.productTypeId,
                p.productTypeId,
                if(p.productTypeId is null, p.name, t.name)                 as productName,
                if(p.productTypeId is null, p.name, t.name)                 as productName,
                `snCode`,
                `snCode`,
                if(p.productTypeId is null, p.image, t.image)               as productImage,
                if(p.productTypeId is null, p.image, t.image)               as productImage,
-               `certificateImage`,
-               `originalCertificateImage`,
-               addQrCodeFlag,
-               addTemplateType,
+               certificateImageType,
+               certificateImage,
                purchaseWay,
                purchaseWay,
                invoiceImage,
                invoiceImage,
                p.`status`,
                p.`status`,
                p.auditStatus,
                p.auditStatus,
-               if(shopAuditStatus = 0, shopInvalidReason, p.invalidReason) as invalidReason
+               p.createTime,
+               if(shopAuditStatus = 0, shopInvalidReason, p.invalidReason) as invalidReason,
+               r.id as relationId,
+               r.authType
         from cm_brand_auth_product p
         from cm_brand_auth_product p
+                 left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
                  left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
                  left join cm_brand cb1 on p.brandId = cb1.id
                  left join cm_brand cb1 on p.brandId = cb1.id
                  left join cm_brand cb2 on t.brandId = cb2.id
                  left join cm_brand cb2 on t.brandId = cb2.id
-        where p.id = #{productId}
+        where r.id = #{relationId}
     </select>
     </select>
     <select id="getParamsByProductId" resultType="com.caimei.model.po.ProductParamPo">
     <select id="getParamsByProductId" resultType="com.caimei.model.po.ProductParamPo">
         select `name` as paramName, `content` as paramContent
         select `name` as paramName, `content` as paramContent
@@ -234,22 +244,10 @@
         where productId = #{productId}
         where productId = #{productId}
     </select>
     </select>
     <select id="getProductIdsByAuthId" resultType="java.lang.Integer">
     <select id="getProductIdsByAuthId" resultType="java.lang.Integer">
-        select id from cm_brand_auth_product where authId = #{authId}
-    </select>
-    <select id="getImageByProductId" resultType="com.caimei.model.po.ProductPo">
-        select t.image as productImage,
-               t.pcImage,
-               t.appletsImage,
-               addQrCodeFlag,
-               originalCertificateImage,
-               certificateImage,
-               pcCertificateImage,
-               appletsCertificateImage,
-               addQrCodeFlag,
-               addTemplateType
+        select p.id
         from cm_brand_auth_product p
         from cm_brand_auth_product p
-                 left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
-        where p.id = #{productId}
+                 left join cm_brand_product_relation r on p.id = r.productId
+        where r.authId = #{authId};
     </select>
     </select>
     <select id="getAllImage" resultType="com.caimei.model.po.ProductPo">
     <select id="getAllImage" resultType="com.caimei.model.po.ProductPo">
         select id as productId,
         select id as productId,
@@ -263,15 +261,16 @@
     </select>
     </select>
     <select id="getWxProductList" resultType="com.caimei.model.vo.WxProductListVo">
     <select id="getWxProductList" resultType="com.caimei.model.vo.WxProductListVo">
         select p.id as productId,
         select p.id as productId,
-        p.authId,
+        r.authId,
         if(p.productTypeId is null,p.name,t.name) as productName,
         if(p.productTypeId is null,p.name,t.name) as productName,
         p.snCode,
         p.snCode,
         if(p.productTypeId is null,p.image,t.image) as productImage,
         if(p.productTypeId is null,p.image,t.image) as productImage,
         a.authParty as clubName,
         a.authParty as clubName,
         p.auditStatus
         p.auditStatus
         from cm_brand_auth_product p
         from cm_brand_auth_product p
+        left join cm_brand_product_relation r on p.id = r.productId
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
-        left join cm_brand_auth a on p.authId = a.id
+        left join cm_brand_auth a on r.authId = a.id
         left join cm_brand_auth_user au on a.authUserId = au.authUserId
         left join cm_brand_auth_user au on a.authUserId = au.authUserId
         <where>
         <where>
             <if test="listType == 1">
             <if test="listType == 1">
@@ -288,7 +287,7 @@
                 and p.snCode like concat('%',#{snCode},'%')
                 and p.snCode like concat('%',#{snCode},'%')
             </if>
             </if>
             <if test="authId != null">
             <if test="authId != null">
-                and p.authId = #{authId}
+                and r.authId = #{authId}
             </if>
             </if>
             <if test="authParty != null and authParty != ''">
             <if test="authParty != null and authParty != ''">
                 and a.authParty like concat('%',#{authParty},'%')
                 and a.authParty like concat('%',#{authParty},'%')
@@ -300,46 +299,45 @@
         select id from cm_brand where name = #{brand}
         select id from cm_brand where name = #{brand}
     </select>
     </select>
     <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
     <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
-        select p.id as productId, p.purchaseWay,
-               if(p.productTypeId is null,p.name,t.name) as productName,snCode,cb.name as brandName,
-               if(p.productTypeId is null,p.image,t.image) as productImage,certificateImage
+        select p.id                                          as productId,
+               p.purchaseWay,
+               if(p.productTypeId is null, p.name, t.name)   as productName,
+               snCode,
+               cb.name                                       as brandName,
+               if(p.productTypeId is null, p.image, t.image) as productImage,
+               certificateImage
         from cm_brand_auth_product p
         from cm_brand_auth_product p
-        left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
-        left join cm_brand cb on p.brandId = cb.id
-        where authId = #{authId}
+                 left join cm_brand_product_relation r on p.id = r.productId
+                 left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
+                 left join cm_brand cb on p.brandId = cb.id
+        where r.authId = #{authId}
         order by p.createTime desc
         order by p.createTime desc
     </select>
     </select>
     <select id="getAuthProductByProductId" resultType="com.caimei.model.vo.AuthProductVo">
     <select id="getAuthProductByProductId" resultType="com.caimei.model.vo.AuthProductVo">
-        select t.name       as productName,
+        select t.name             as productName,
                p.snCode,
                p.snCode,
-               t.image as pcImage,
-               t.image as appletsImage,
+               t.image            as pcImage,
+               t.image            as appletsImage,
                p.certificateImage as pcCertificateImage,
                p.certificateImage as pcCertificateImage,
                p.certificateImage as appletsCertificateImage,
                p.certificateImage as appletsCertificateImage,
                p.brandId,
                p.brandId,
-               b.authLogo,
-               b.name       as brandName,
-               c.name       as productionPlace,
-               a.id         as authId,
+               i.brandLogo        as authLogo,
+               i.brandName        as brandName,
+               i.producePlace     as productionPlace,
+               a.id               as authId,
                a.authParty,
                a.authParty,
-               a.logo       as clubLogo,
-               u.authUserId as authUserId,
-               u.name       as shopName,
+               a.logo             as clubLogo,
+               u.authUserId       as authUserId,
+               u.name             as shopName,
                u.shopType,
                u.shopType,
                u.qrCodeImage,
                u.qrCodeImage,
-               i.securityLink,
-               i.manufacturer,
-               i.statementType,
-               i.statementContent,
-               i.statementLink,
-               i.statementImage
+               i.manufacturer
         from cm_brand_auth_product p
         from cm_brand_auth_product p
+                 left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
                  left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
-                 left join cm_brand_auth a on p.authId = a.id
+                 left join cm_brand_auth a on r.authId = a.id
                  left join cm_brand_auth_user u on a.authUserId = u.authUserId
                  left join cm_brand_auth_user u on a.authUserId = u.authUserId
-                 left join cm_brand_auth_shop_info i on u.authUserId = i.authUserId and t.brandId = i.brandId
-                 left join cm_brand b on i.brandId = b.id
-                 left join country c on i.countryId = c.countryId
+                 left join cm_brand_auth_shop_info i on p.brandId = i.id
         where p.id = #{productId}
         where p.id = #{productId}
           and u.status = 1
           and u.status = 1
           and a.status = 1
           and a.status = 1
@@ -364,8 +362,9 @@
     <select id="getClubProductList" resultType="com.caimei.model.vo.WxProductListVo">
     <select id="getClubProductList" resultType="com.caimei.model.vo.WxProductListVo">
         select p.id as productId, t.name as productName, p.snCode
         select p.id as productId, t.name as productName, p.snCode
         from cm_brand_auth_product p
         from cm_brand_auth_product p
-        left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
-        where p.authId = #{authId}
+                 left join cm_brand_product_relation r on p.id = r.productId
+                 left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
+        where r.authId = #{authId}
           and p.status = 1
           and p.status = 1
           and p.auditStatus = 1
           and p.auditStatus = 1
         order by p.createTime desc
         order by p.createTime desc
@@ -434,7 +433,8 @@
     <select id="getAuthUserIdByProductId" resultType="java.lang.Integer">
     <select id="getAuthUserIdByProductId" resultType="java.lang.Integer">
         select a.authUserId
         select a.authUserId
         from cm_brand_auth_product p
         from cm_brand_auth_product p
-                 left join cm_brand_auth a on p.authId = a.id
+                 left join cm_brand_product_relation r on p.id = r.productId
+                 left join cm_brand_auth a on r.authId = a.id
         where p.id = #{productId}
         where p.id = #{productId}
     </select>
     </select>
     <select id="getProductTypeParamList" resultType="com.caimei.model.po.ProductParamPo">
     <select id="getProductTypeParamList" resultType="com.caimei.model.po.ProductParamPo">
@@ -442,4 +442,35 @@
         from cm_brand_product_type_param
         from cm_brand_product_type_param
         where productTypeId = #{productTypeId}
         where productTypeId = #{productTypeId}
     </select>
     </select>
+    <select id="getProductRelation" resultType="com.caimei.model.vo.ProductRelationVo">
+        select id as relationId, authId, productId, authType
+        from cm_brand_product_relation
+        where id = #{relationId}
+    </select>
+    <select id="getProductRelationCount" resultType="java.lang.Integer">
+        select count(*)
+        from cm_brand_product_relation
+        where productId = #{productId}
+    </select>
+    <select id="getProductDetails" resultType="com.caimei.model.vo.ProductFormVo">
+        select p.id as productId,if(p.productTypeId is null,p.name,t.name) as productName,
+        certificateImageType,certificateImage,purchaseWay,invoiceImage
+        from cm_brand_auth_product p
+        left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
+        <where>
+            <if test="productId != null">
+                and p.id = #{productId}
+            </if>
+            <if test="snCode != null">
+                and p.snCode = #{snCode}
+            </if>
+        </where>
+    </select>
+    <select id="getSnCodeList" resultType="java.lang.String">
+        select snCode
+        from cm_brand_auth_product p
+                 left join cm_brand_product_relation r on p.id = r.productId
+                 left join cm_brand_auth a on a.id = r.authId and a.delFlag = 0
+        where a.authUserId = #{authUserId}
+    </select>
 </mapper>
 </mapper>

+ 21 - 66
src/main/resources/mapper/ShopMapper.xml

@@ -6,42 +6,13 @@
         values (#{authUserId}, #{brandId}, #{name}, #{ossName}, #{md5Hex}, #{uploadTime})
         values (#{authUserId}, #{brandId}, #{name}, #{ossName}, #{md5Hex}, #{uploadTime})
     </insert>
     </insert>
     <insert id="insertShop"  keyColumn="authUserId" keyProperty="authUserId" useGeneratedKeys="true" parameterType="com.caimei.model.po.UserPo">
     <insert id="insertShop"  keyColumn="authUserId" keyProperty="authUserId" useGeneratedKeys="true" parameterType="com.caimei.model.po.UserPo">
-        insert into cm_brand_auth_user (`name`, `mobile`, `password`, `linkMan`, `userIdentity`, `shopType`, `logo`, `qrCodeImage`, `wxAccountType`, `appId`, `appSecret`, `createTime`,
+        insert into cm_brand_auth_user (`name`, cmShopId, `mobile`, `password`, `linkMan`, `userIdentity`, `shopType`, `logo`, `qrCodeImage`, `wxAccountType`, `appId`, `appSecret`, `createTime`,
                                         `createBy`,`status`)
                                         `createBy`,`status`)
-        values (#{name}, #{mobile}, #{password}, #{linkMan}, #{userIdentity}, #{shopType}, #{logo}, #{qrCodeImage}, #{wxAccountType}, #{appId}, #{appSecret}, #{createTime}, #{createBy}, #{status});
+        values (#{name}, #{cmShopId}, #{mobile}, #{password}, #{linkMan}, #{userIdentity}, #{shopType}, #{logo}, #{qrCodeImage}, #{wxAccountType}, #{appId}, #{appSecret}, #{createTime}, #{createBy}, #{status});
     </insert>
     </insert>
     <insert id="insertShopInfo">
     <insert id="insertShopInfo">
-        insert into cm_brand_auth_shop_info
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            authUserId,brandId,countryId,securityLink,manufacturer,
-            <if test="statementType != null">
-                statementType,
-            </if>
-            <if test="statementContent != null and statementContent != ''">
-                statementContent,
-            </if>
-            <if test="statementLink != null and statementLink != ''">
-                statementLink,
-            </if>
-            <if test="statementImage != null and statementImage != ''">
-                statementImage,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            #{authUserId},#{brandId},#{countryId},#{securityLink},#{manufacturer},
-            <if test="statementType != null">
-                #{statementType},
-            </if>
-            <if test="statementContent != null and statementContent != ''">
-                #{statementContent},
-            </if>
-            <if test="statementLink != null and statementLink != ''">
-                #{statementLink},
-            </if>
-            <if test="statementImage != null and statementImage != ''">
-                #{statementImage},
-            </if>
-        </trim>
+        insert into cm_brand_auth_shop_info (authUserId, brandName, brandLogo, producePlace, manufacturer)
+        values (#{authUserId}, #{brandName}, #{brandLogo}, #{producePlace}, #{manufacturer})
     </insert>
     </insert>
     <update id="updateShopStatusByUserId">
     <update id="updateShopStatusByUserId">
         update cm_brand_auth_user
         update cm_brand_auth_user
@@ -60,7 +31,10 @@
     </update>
     </update>
     <update id="updateShopByUserId">
     <update id="updateShopByUserId">
         update cm_brand_auth_user
         update cm_brand_auth_user
-        set `mobile`        = #{mobile},
+        set cmShopId        = #{cmShopId},
+            name            = #{name},
+            shopType        = #{shopType},
+            `mobile`        = #{mobile},
             `linkMan`       = #{linkMan},
             `linkMan`       = #{linkMan},
             `status`        = #{status},
             `status`        = #{status},
             `logo`          = #{logo},
             `logo`          = #{logo},
@@ -72,22 +46,11 @@
     </update>
     </update>
     <update id="updateShopInfo">
     <update id="updateShopInfo">
         update cm_brand_auth_shop_info
         update cm_brand_auth_shop_info
-        <set>
-            countryId=#{countryId},securityLink = #{securityLink},manufacturer = #{manufacturer},
-            <if test="statementType != null">
-                statementType = #{statementType},
-            </if>
-            <if test="statementContent != null and statementContent != ''">
-                statementContent = #{statementContent},
-            </if>
-            <if test="statementLink != null and statementLink != ''">
-                statementLink = #{statementLink},
-            </if>
-            <if test="statementImage != null and statementImage != ''">
-                statementImage = #{statementImage},
-            </if>
-        </set>
-        where authUserId = #{authUserId} and brandId = #{brandId}
+        set brandName    = #{brandName},
+            brandLogo    = #{brandLogo},
+            producePlace = #{producePlace},
+            manufacturer = #{manufacturer}
+        where id = #{id}
     </update>
     </update>
     <update id="handleFeedback">
     <update id="handleFeedback">
         update cm_brand_club_feedback
         update cm_brand_club_feedback
@@ -106,6 +69,11 @@
         set loginAccount = #{loginAccount}
         set loginAccount = #{loginAccount}
         where authUserId = #{authUserId}
         where authUserId = #{authUserId}
     </update>
     </update>
+    <update id="updateShopLinkMan">
+        update cm_brand_auth_user
+        set linkMan = #{linkMan}
+        where authUserId = #{authUserId}
+    </update>
     <delete id="deleteStatementFile">
     <delete id="deleteStatementFile">
         delete from cm_brand_auth_file where id = #{id}
         delete from cm_brand_auth_file where id = #{id}
     </delete>
     </delete>
@@ -243,7 +211,7 @@
         select count(*) from cm_brand_auth_file where md5Hex = #{md5Hex}
         select count(*) from cm_brand_auth_file where md5Hex = #{md5Hex}
     </select>
     </select>
     <select id="getShopByUserId" resultType="com.caimei.model.vo.ShopFormVo">
     <select id="getShopByUserId" resultType="com.caimei.model.vo.ShopFormVo">
-        select u.authUserId, u.name as shopName, u.loginAccount, u.mobile, u.linkMan, u.status as shopStatus, u.shopType as shopType,
+        select u.authUserId, u.cmShopId, u.name as shopName, u.loginAccount, u.mobile, u.linkMan, u.status as shopStatus, u.shopType,
                u.wxAccountType, u.logo, u.qrCodeImage, u.appId, u.appSecret,
                u.wxAccountType, u.logo, u.qrCodeImage, u.appId, u.appSecret,
                if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus
                if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus
         from cm_brand_auth_user u
         from cm_brand_auth_user u
@@ -275,26 +243,13 @@
         select authUserId from cm_brand_auth_user where mobile = #{mobile} and userIdentity = 2 limit 1
         select authUserId from cm_brand_auth_user where mobile = #{mobile} and userIdentity = 2 limit 1
     </select>
     </select>
     <select id="getDbInfoBrandList" resultType="com.caimei.model.vo.ShopBrandVo">
     <select id="getDbInfoBrandList" resultType="com.caimei.model.vo.ShopBrandVo">
-        select id, brandId
+        select id, brandName
         from cm_brand_auth_shop_info
         from cm_brand_auth_shop_info
         where authUserId = #{authUserId}
         where authUserId = #{authUserId}
     </select>
     </select>
     <select id="getShopInfoByUserId" resultType="com.caimei.model.vo.ShopInfoVo">
     <select id="getShopInfoByUserId" resultType="com.caimei.model.vo.ShopInfoVo">
-        select i.brandId,
-               i.countryId,
-               i.securityLink,
-               i.manufacturer,
-               i.statementType,
-               i.statementContent,
-               i.statementLink,
-               i.statementImage,
-               f.id as statementFileId,
-               f.name as statementFileName,
-               b.name as brandName,
-               b.authLogo as brandAuthLogo
+        select i.brandName,i.brandLogo,i.producePlace,i.manufacturer
         from cm_brand_auth_shop_info i
         from cm_brand_auth_shop_info i
-                 left join cm_brand b on i.brandId = b.id
-                 left join cm_brand_auth_file f on i.authUserId = f.authUserId and i.brandId = f.brandId
         where i.authUserId = #{authUserId}
         where i.authUserId = #{authUserId}
     </select>
     </select>
     <select id="getUserIdByShopName" resultType="java.lang.Integer">
     <select id="getUserIdByShopName" resultType="java.lang.Integer">