瀏覽代碼

认证通1.7.4功能开发代码提交

JiangChongBo 2 年之前
父節點
當前提交
c9d15b442b
共有 23 個文件被更改,包括 901 次插入72 次删除
  1. 195 3
      src/main/java/com/caimei/controller/admin/auth/AuthApi.java
  2. 19 0
      src/main/java/com/caimei/controller/admin/auth/AuthClubApi.java
  3. 32 0
      src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java
  4. 11 0
      src/main/java/com/caimei/controller/wechat/WxAuthApi.java
  5. 16 2
      src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java
  6. 15 1
      src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java
  7. 3 0
      src/main/java/com/caimei/mapper/cmMapper/ClubMapper.java
  8. 5 0
      src/main/java/com/caimei/model/dto/ProductSaveDto.java
  9. 14 0
      src/main/java/com/caimei/model/po/CmBrandAuthPo.java
  10. 20 0
      src/main/java/com/caimei/model/vo/AuthFormVo.java
  11. 22 0
      src/main/java/com/caimei/model/vo/AuthVo.java
  12. 4 0
      src/main/java/com/caimei/model/vo/ProductListVo.java
  13. 25 0
      src/main/java/com/caimei/model/vo/WxClubDetailsVo.java
  14. 10 0
      src/main/java/com/caimei/model/vo/WxClubUserVo.java
  15. 7 0
      src/main/java/com/caimei/service/auth/AuthClubService.java
  16. 22 0
      src/main/java/com/caimei/service/auth/AuthProductService.java
  17. 13 1
      src/main/java/com/caimei/service/auth/AuthService.java
  18. 5 0
      src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java
  19. 65 4
      src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java
  20. 53 4
      src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
  21. 263 55
      src/main/resources/mapper/AuthMapper.xml
  22. 68 0
      src/main/resources/mapper/AuthProductMapper.xml
  23. 14 2
      src/main/resources/mapper/ClubMapper.xml

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

@@ -8,6 +8,7 @@ import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.service.auth.AuthService;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
@@ -61,7 +62,7 @@ public class AuthApi {
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     @GetMapping("/list")
-    public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType,  String authParty, String mobile,
+    public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
                                                       Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
                                                       Integer shopAuditStatus, Integer sendStatus,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -80,6 +81,49 @@ public class AuthApi {
         return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, pageNum, pageSize);
     }
 
+    /**
+     * 授权列表
+     *1.7.4版本
+     * 新加两个查询条件
+     *
+     * name 商品名称
+     * snCode 商品sn码
+     * **/
+    @ApiOperation("授权列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
+            @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
+            @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
+            @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
+            @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
+            @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
+            @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
+            @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
+            @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
+            @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
+            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
+            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
+    })
+    @GetMapping("/listAll")
+    public ResponseJson<PageInfo<AuthVo>> getAuthListAll(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
+                                                      Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
+                                                      Integer shopAuditStatus, Integer sendStatus, String name, String snCode,
+                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
+        if (null != sysUser && 1 != sysUser.getId()) {
+            // 获取供应商用户id
+            Integer userIdentity = sysUser.getUserIdentity();
+            authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+            if (null == authUserId) {
+                return ResponseJson.error("供应商用户id不能为空", null);
+            }
+        } else if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authService.getAuthListAll(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, name, snCode, pageNum, pageSize);
+    }
+
     @ApiOperation("机构下拉框列表")
     @GetMapping("/select")
     public ResponseJson<List<AuthVo>> getAuthSelectList(@CurrentUser SysUser sysUser) {
@@ -183,6 +227,8 @@ public class AuthApi {
         List<String> bannerList = (List<String>) paramsMap.get("bannerList");
         String authParty = paramsMap.getString("authParty");
         Integer source = paramsMap.getInteger("source");
+        String relationId=paramsMap.getString("relationId");
+        String relationName=paramsMap.getString("relationName");
         if (null == source) {
             // 默认供应商保存
             source = 1;
@@ -222,9 +268,116 @@ public class AuthApi {
         auth.setAuthImageType(authImageType);
         auth.setCreateBy(createBy);
         auth.setCreateSource(1);
+        auth.setRelationId(relationId);
+        auth.setRelationName(relationName);
         return authService.saveAuth(auth, bannerList, false, source);
     }
+    /**
+     * 添加/编辑授权
+     * 1.7.4版本:编辑时新加关联机构操作
+     *
+     */
+    @ApiOperation("添加/编辑授权")
+    @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
+            "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
+            "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
+            "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
+            "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
+            "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
+            "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
+    @PostMapping("/saverelationg")
+    @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
+    public ResponseJson savesaverelationg(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
 
+        JSONObject paramsMap = JSONObject.parseObject(params);
+//        Integer authUserId = paramsMap.getInteger("authUserId");
+//        Integer createBy = paramsMap.getInteger("createBy");
+
+        Integer authId = paramsMap.getInteger("authId");
+        Integer provinceId = paramsMap.getInteger("provinceId");
+        Integer cityId = paramsMap.getInteger("cityId");
+        Integer townId = paramsMap.getInteger("townId");
+        String address = paramsMap.getString("address");
+        String lngAndLat = paramsMap.getString("lngAndLat");
+        String mobile = paramsMap.getString("mobile");
+        String userMobile = paramsMap.getString("userMobile");
+        String linkMan = paramsMap.getString("linkMan");
+        String linkMobile = paramsMap.getString("linkMobile");
+        Integer firstClubType = paramsMap.getInteger("firstClubType");
+        Integer secondClubType = paramsMap.getInteger("secondClubType");
+        String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
+        Integer empNum = paramsMap.getInteger("empNum");
+        String logo = paramsMap.getString("logo");
+        String authCode = paramsMap.getString("authCode");
+        String authDateStr = paramsMap.getString("authDate");
+        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
+        String relationId=paramsMap.getString("relationId");
+        String relationName=paramsMap.getString("relationName");
+        Date authDate = null;
+        if (StringUtils.isNotEmpty(authDateStr)) {
+            authDate = format.parse(authDateStr);
+        }
+        Integer authImageType = paramsMap.getInteger("authImageType");
+        String authImageLogo = paramsMap.getString("authImageLogo");
+        String authImage = paramsMap.getString("authImage");
+        Integer customFlag = paramsMap.getInteger("customFlag");
+        String remarks = paramsMap.getString("remarks");
+        List<String> bannerList = (List<String>) paramsMap.get("bannerList");
+        String authParty = paramsMap.getString("authParty");
+        Integer source = paramsMap.getInteger("source");
+        if (null == source) {
+            // 默认供应商保存
+            source = 1;
+        }
+        /*
+            组装授权数据
+         */
+        CmBrandAuthPo auth = new CmBrandAuthPo();
+        auth.setId(authId);
+        auth.setAuthUserId(authUserId);
+        auth.setAuthParty(authParty);
+        auth.setProvinceId(provinceId);
+        auth.setCityId(cityId);
+        auth.setTownId(townId);
+        auth.setAddress(address);
+        auth.setCustomFlag(customFlag);
+        auth.setRemarks(remarks);
+        if (StringUtils.isEmpty(lngAndLat)) {
+            return ResponseJson.error("参数异常,经纬度不能为空");
+        }
+        String[] split = lngAndLat.split(",");
+        auth.setLng(new BigDecimal(split[0]));
+        auth.setLat(new BigDecimal(split[1]));
+        auth.setMobile(mobile);
+        auth.setUserMobile(userMobile);
+        auth.setLinkMan(linkMan);
+        auth.setLinkMobile(linkMobile);
+        auth.setFirstClubType(firstClubType);
+        auth.setSecondClubType(secondClubType);
+        auth.setMedicalLicenseImage(medicalLicenseImage);
+        auth.setEmpNum(empNum);
+        auth.setLogo(logo);
+        auth.setAuthCode(authCode);
+        auth.setAuthDate(authDate);
+        auth.setAuthImageLogo(authImageLogo);
+        auth.setAuthImage(authImage);
+        auth.setAuthImageType(authImageType);
+        auth.setCreateBy(createBy);
+        auth.setCreateSource(1);
+        auth.setRelationId(relationId);
+        auth.setRelationName(relationName);
+        return authService.saveAuth(auth, bannerList, false, source);
+    }
 
     /**
      * 审核品牌授权
@@ -295,18 +448,57 @@ public class AuthApi {
     }
 
     @ApiOperation("勾选明星机构")
-    @ApiImplicitParam(name = "params", required = true, value = "authId:机构id;starFlag:明星机构标识:1明星机构,0不是")
+    @ApiImplicitParam(name = "params", required = true, value = "authId:机构id;starFlag:明星机构标识:1明星机构,0不是;starNum明星机构数值(用于排序,数值越大排名越前)")
     @PostMapping("/star")
     public ResponseJson starAuth(@RequestBody String params) {
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authId = paramsMap.getInteger("authId");
         Integer starFlag = paramsMap.getInteger("starFlag");
+        String  starNum=paramsMap.getString("starNum");
         if (null == authId) {
             return ResponseJson.error("机构id不能为空");
         }
         if (null == starFlag) {
             return ResponseJson.error("明星机构标识不能为空");
         }
-        return authService.starAuth(authId, starFlag);
+        return authService.starAuth(authId, starFlag,starNum);
+    }
+    /**
+     * 获取机构关联的机构信息
+     * 1.7.4版本:编辑时新加关联机构操作
+     *
+     */
+    @PostMapping("/product/relation/list")
+    public ResponseJson<List<AuthFormVo>> getRelationgInfo(@CurrentUser SysUser sysUser,@RequestBody String params){
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        String  snCode=paramsMap.getString("snCode");
+        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 authService.getRelationgInfo(snCode,authUserId);
+    }
+    /**
+     * 获取可绑定机构机构信息
+     * 1.7.4版本:编辑时新加关联机构操作
+     *
+     */
+    @GetMapping("/club/bind/list")
+    public ResponseJson<List<AuthFormVo>> getClubBindAuth(@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 authService.getClubBindAuth(authUserId);
     }
 }

+ 19 - 0
src/main/java/com/caimei/controller/admin/auth/AuthClubApi.java

@@ -140,4 +140,23 @@ public class AuthClubApi {
         Integer clubUserId = params.get("clubUserId");
         return authClubService.resetClubUserPassword(clubUserId);
     }
+
+    @PostMapping("/user/bind/save")
+    public ResponseJson saveBindAuth(@CurrentUser SysUser sysUser,@RequestBody String params) {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        Integer authId = paramsMap.getInteger("authId");
+        Integer clubUserId = paramsMap.getInteger("clubUserId");
+        String authParty=paramsMap.getString("authParty");
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return authClubService.saveBindAuth(authId,authParty,authUserId,clubUserId);
+    }
 }

+ 32 - 0
src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java

@@ -81,6 +81,26 @@ public class AuthProductApi {
         return authProductService.getSnCodeList(authUserId, authId);
     }
 
+    /**
+     * 1.7.4:
+     * 新加获取关联机构下的sn码
+     * **/
+    @ApiOperation("供应商下审核通过设备sn码列表")
+    @ApiImplicitParam(name = "authId", required = true, value = "授权id")
+    @GetMapping("/sn/listSn")
+    public ResponseJson<List<String>> getSnCodeListSn(@CurrentUser SysUser sysUser, Integer authId) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+
+        return authProductService.getSnCodeList1(authUserId, authId);
+    }
 
     /**
      * 更新授权商品状态
@@ -131,6 +151,18 @@ public class AuthProductApi {
         productSaveDto.setCreateBy(createBy);
         return authProductService.saveProduct(productSaveDto);
     }
+    @ApiOperation("添加/编辑授权商品(关联机构sn码)")
+    @PostMapping("/save/relation")
+    public ResponseJson saveProductAndRelaTion(@RequestBody ProductSaveDto productSaveDto) throws IOException {
+        List<String> snList = productSaveDto.getSnList();
+        Integer authId=productSaveDto.getAuthId();
+        Integer authType=productSaveDto.getAuthType();
+        if(snList.size()<0){
+            ResponseJson.error("该机构没有关联其他机构,请先关联机构");
+        }
+        return authProductService.saveProductAndRelaTion(authId,snList,authType);
+
+    }
 
     @ApiOperation("授权商品回显数据")
     @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id")

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

@@ -1,10 +1,12 @@
 package com.caimei.controller.wechat;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.aop.IpSave;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.CmBrandAuthPo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.*;
 import com.github.pagehelper.PageInfo;
@@ -303,4 +305,13 @@ public class WxAuthApi {
     public ResponseJson<DoctorFormVo> getAuthDoctorDetails(Integer doctorId) {
         return doctorService.getAuthDoctorDetails(doctorId);
     }
+
+    @ApiOperation("获取机构下所有的设备信息")
+    @GetMapping("/get/product/list")
+    public ResponseJson<List<ProductListVo>> getPronductInfo(Integer authId,Integer authUserId){
+        if (null == authUserId) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        return authProductService.getPronductInfo(authId,authUserId);
+    }
 }

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

@@ -5,6 +5,7 @@ import com.caimei.model.po.LdmDataPo;
 import com.caimei.model.po.TownPo;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.TemplateVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -22,6 +23,7 @@ import java.util.List;
 public interface AuthMapper {
 
     List<AuthVo> getAuthList(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus);
+    List<AuthVo> getAuthListAll(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus,@Param("name") String name,@Param("snCode") String snCode);
 
     void updateAuthStatusByAuthId(@Param("authId") Integer authId, @Param("status") Integer status);
 
@@ -109,7 +111,19 @@ public interface AuthMapper {
 
     void checkAuth(Integer authId);
 
-    void starAuth(@Param("authId") Integer authId, @Param("starFlag") Integer starFlag);
+    void starAuth(@Param("authId") Integer authId, @Param("starFlag") Integer starFlag,@Param("starNum") String starNum);
 
     void addScanCount(Integer authId);
-}
+
+    //根据id查询机构集合
+    List<AuthFormVo> getAuthIdList(@Param("relationIdList") String[] relationIdList);
+    //获取关联机构的信息
+    AuthFormVo  getRelationgInfo(Integer authId,Integer authUserId);
+    /**
+     *  1.7.4版本
+     * 获取可绑定机构机构信息
+     * **/
+    List<AuthFormVo> getClubBindAuth(Integer authUserId);
+
+    List<ProductFormVo> getRelationgList(String snCode);
+ }

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

@@ -1,9 +1,11 @@
 package com.caimei.mapper.cmMapper;
 
+import com.caimei.model.ResponseJson;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductPo;
 import com.caimei.model.po.ProductTypePo;
 import com.caimei.model.vo.*;
+import com.github.pagehelper.PageInfo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -101,11 +103,23 @@ public interface AuthProductMapper {
 
     ProductFormVo getProductInfo(@Param("productId") Integer productId, @Param("snCode") String snCode);
 
-    List<String> getSnCodeList(Integer authUserId, Integer authId);
+    List<String> getSnCodeList(Integer authUserId, Integer authId,@Param("snCodeList") List<String> snCodeList);
+    List<String> getSnCodeList1(Integer authUserId, Integer authId,String[] relationIdList,@Param("snCodeList") List<String> snCodeList);
+
+    List<Integer> getAllSn(Integer authId);
+
+    List<String> getAllSnlist(@Param("productIdList") List<Integer> productIdList);
+
 
     List<WxClubListVo> getProductClubList(Integer productId);
 
     void addScanCount(Integer productId);
 
     void checkProductType(Integer productTypeId);
+    //获取关联机构
+    String getRelationId(Integer authId);
+    //根据sn码产品id
+    List<ProductPo> getSnList( @Param("sn") String sn);
+
+    List<ProductListVo> getPronductInfo(Integer authId, Integer authUserId);
 }

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

@@ -48,4 +48,7 @@ public interface ClubMapper {
     String getDbPassword(Integer clubUserId);
 
     List<WxClubListVo> getWxStarClubList(Integer authUserId);
+
+    //绑定更换机构
+    void saveBindAuth(Integer authId,String authParty,Integer authUserId,Integer clubUserId);
 }

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

@@ -95,4 +95,9 @@ public class ProductSaveDto {
      * 来源:1供应商保存,2机构保存
      */
     private Integer source;
+
+    /**
+     * SN码集合(用于关联其他关联机构)
+     */
+    private List<String> SnList;
 }

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

@@ -217,4 +217,18 @@ public class CmBrandAuthPo {
      */
     private Integer checkFlag;
 
+    /**
+     * 关联机构ID(多个用,隔开)
+     */
+    private String relationId;
+    /**
+     * 关联机构名称(多个用,隔开)
+     */
+    private String relationName;
+
+    /**
+     * 明星机构排序值(数值越大,排名越前)
+     */
+    private String starNum;
+
 }

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

@@ -1,5 +1,6 @@
 package com.caimei.model.vo;
 
+import com.caimei.model.po.CmBrandAuthPo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -175,4 +176,23 @@ public class AuthFormVo implements Serializable {
      * 机构授权牌模板
      */
     private TemplateVo authTemplate;
+
+    /**
+     * 关联机构ID(多个用,隔开)
+     */
+    private String relationId;
+    /**
+     * 关联机构名称(多个用,隔开)
+     */
+    private String relationName;
+    /**
+     * 关联机构ID集合(便于前端赋值)
+     */
+    private List<AuthFormVo> releationClubList;
+    /**
+     * 明星机构排序值(数值越大,排名越前)
+     */
+    private String starNum;
+
+
 }

+ 22 - 0
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -136,4 +136,26 @@ public class AuthVo {
      *  设备列表最大参数数量
      */
     private Integer maxParamNum;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+    /**
+     * 商品sn码
+     */
+    private String snCode;
+
+    /**
+     * 关联机构ID(多个用,隔开)
+     */
+    private String relationId;
+    /**
+     * 关联机构名称(多个用,隔开)
+     */
+    private String relationName;
+    /**
+     * 明星机构排序值(数值越大,排名越前)
+     */
+    private String starNum;
 }

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

@@ -100,4 +100,8 @@ public class ProductListVo {
      * 扫码次数
      */
     private Integer scanCount;
+    /**
+     * 商品图片
+     */
+    private String image;
 }

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

@@ -50,4 +50,29 @@ public class WxClubDetailsVo implements Serializable {
     @ApiModelProperty("店铺备注")
     private String remarks;
 
+    /**
+     * 运营联系人
+     * **/
+    private String linkMan;
+    /**
+     * 运营联系人手机号
+     * **/
+    private String linkMobile;
+    /**
+     * 医疗许可证图片
+     * **/
+    private String medicalLicenseImage;
+    /**
+     * 一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5
+     * **/
+    private Integer firstClubType;
+    /**
+     * 医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6
+     * **/
+    private Integer secondClubType;
+    /**
+     * 员工人数
+     * **/
+    private Integer empNum;
+
 }

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

@@ -2,6 +2,7 @@ package com.caimei.model.vo;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springframework.data.annotation.Transient;
 
 import java.util.Date;
 
@@ -38,4 +39,13 @@ public class WxClubUserVo {
 
     @ApiModelProperty("状态:0停用,1启用")
     private Integer status;
+    /***
+     * 机构名称
+     * */
+    private String authParty;
+
+    /***
+     * 用户头像
+     * */
+    private String logo;
 }

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

@@ -100,4 +100,11 @@ public interface AuthClubService {
      * @return
      */
     ResponseJson<List<WxClubListVo>> getWxStarClubList(Integer authUserId);
+
+    /**
+     *
+     * 更换绑定机构
+     */
+
+    ResponseJson saveBindAuth(Integer authId,String authParty,Integer authUserId,Integer clubUserId);
 }

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

@@ -1,9 +1,11 @@
 package com.caimei.service.auth;
 
+import com.caimei.annotation.CurrentUser;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.po.ProductTypePo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.*;
 import com.github.pagehelper.PageInfo;
 
@@ -68,6 +70,13 @@ public interface AuthProductService {
      */
     ResponseJson saveProduct(ProductSaveDto productSaveDto) throws IOException;
 
+    /**
+     * 添加/编辑授权商品(关联机构设备保存)
+     * @param authId
+     * @return
+     */
+    ResponseJson saveProductAndRelaTion(Integer authId,List<String> snlist,Integer authType) throws IOException;
+
     /**
      * 获取授权商品回显数据
      *
@@ -185,12 +194,25 @@ public interface AuthProductService {
      */
     ResponseJson<List<String>> getSnCodeList(Integer authUserId, Integer authId);
 
+    /**
+     * sn码列表1
+     * @param authUserId
+     * @param authId
+     * @return
+     */
+    ResponseJson<List<String>> getSnCodeList1(Integer authUserId, Integer authId);
+
     /**
      * 更改设备分类查看标记
      * @param productTypeId
      * @return
      */
     ResponseJson checkProductType(Integer productTypeId);
+    /**
+     * 获取机构下所有的设备信息
+     *
+     */
+    ResponseJson<List<ProductListVo>> getPronductInfo( Integer authId,Integer authUserId);
 }
 
 

+ 13 - 1
src/main/java/com/caimei/service/auth/AuthService.java

@@ -4,6 +4,7 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.vo.AuthFormVo;
 import com.caimei.model.vo.AuthVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.model.vo.TemplateVo;
 import com.github.pagehelper.PageInfo;
 import org.springframework.web.multipart.MultipartFile;
@@ -35,6 +36,7 @@ public interface AuthService {
      * @return AuthVo
      */
     ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<AuthVo>> getAuthListAll(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, String name,String snCode,Integer pageNum, Integer pageSize);
 
     /**
      * 更新授权状态
@@ -124,5 +126,15 @@ public interface AuthService {
     /**
      * 更改明星标识
      */
-    ResponseJson starAuth(Integer authId, Integer starFlag);
+    ResponseJson starAuth(Integer authId, Integer starFlag,String starNum);
+    /**
+     * 获取机构关联的机构信息
+     * 1.7.4版本:编辑时新加关联机构操作
+     *
+     */
+    ResponseJson<List<AuthFormVo>> getRelationgInfo(String  snCode, Integer authUserId);
+    /**
+     * 获取可绑定机构机构信息
+     * **/
+    ResponseJson<List<AuthFormVo>> getClubBindAuth(Integer authUserId);
 }

+ 5 - 0
src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java

@@ -219,4 +219,9 @@ public class AuthClubServiceImpl implements AuthClubService {
         List<WxClubListVo> starClubList = clubMapper.getWxStarClubList(authUserId);
         return ResponseJson.success(starClubList);
     }
+    @Override
+    public ResponseJson saveBindAuth(Integer authId,String authParty,Integer authUserId,Integer clubUserId){
+        clubMapper.saveBindAuth(authId,authParty,authUserId,clubUserId);
+        return ResponseJson.success("绑定机构成功");
+    }
 }

+ 65 - 4
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -35,10 +35,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Description
@@ -153,6 +151,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         String purchaseWay = productSaveDto.getPurchaseWay();
         String invoiceImage = productSaveDto.getInvoiceImage();
         Integer source = null == productSaveDto.getSource() ? 1 : productSaveDto.getSource();
+        List<String> snList=productSaveDto.getSnList();
         List<ProductParamPo> paramList = productSaveDto.getParamList();
         if (null == authId) {
             return ResponseJson.error("参数异常,请输入授权id", null);
@@ -333,6 +332,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 } else {
                     // 更新设备
                     authProductMapper.updateProductByProductId(product);
+                    //1.7.4改为
                 }
                 // 更新机构设备关联关系
                 authProductMapper.updateProductRelation(dbRelation.getRelationId(), authId, product.getProductId(), authType);
@@ -365,6 +365,42 @@ public class AuthProductServiceImpl implements AuthProductService {
         }
         return ResponseJson.success("保存授权商品成功");
     }
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public  ResponseJson saveProductAndRelaTion(Integer authId,List<String> snlist,Integer authType) throws IOException{
+        //判断机构关联id是否有值(有则机构关联关联了其他机构属于新增操作,无则属于编辑操作)
+        String relaId = authProductMapper.getRelationId(authId);
+        List<Integer>  listSnId=new ArrayList<>();
+        if(null!=relaId&&!"".equals(relaId)){
+            //根据sn码获取产品id
+            for(int i=0;i<snlist.size();i++){
+                List<ProductPo> List = authProductMapper.getSnList(snlist.get(i));
+                //判断本身机构下的设备和关联机构下 设备有不有重复的
+                if(List.get(0).getAuthId()!=authId){
+                    listSnId.add(List.get(0).getProductId());
+                }
+            }
+            //根据产品id插入机构设备关联关系
+            for(int i=0;i<snlist.size();i++){
+                authProductMapper.insertProductRelation(authId, listSnId.get(i), authType);
+            }
+            return ResponseJson.success("保存授权商品成功");
+        }else{
+            //根据sn码获取产品id
+            for(int i=0;i<snlist.size();i++){
+                List<ProductPo> List = authProductMapper.getSnList(snlist.get(i));
+                //判断本身机构下的设备和关联机构下 设备有不有重复的
+                if(List.get(0).getAuthId()!=authId){
+                    listSnId.add(List.get(0).getProductId());
+                }
+            }
+            //根据产品id插入机构设备关联关系
+            for(int i=0;i<snlist.size();i++){
+                authProductMapper.insertProductRelation(authId, listSnId.get(i), authType);
+            }
+            return ResponseJson.success("保存授权商品成功");
+        }
+    }
 
     public String generateAuthImage(TemplateVo authTemplate, ProductFormVo product) {
         if (null != authTemplate) {
@@ -814,14 +850,39 @@ public class AuthProductServiceImpl implements AuthProductService {
 
     @Override
     public ResponseJson<List<String>> getSnCodeList(Integer authUserId, Integer authId) {
-        List<String> snCodeList = authProductMapper.getSnCodeList(authUserId, authId);
+        //获取该机构下所有的sn码
+        List<Integer> liallSn = authProductMapper.getAllSn(authId);
+        List<String> allSnlist = authProductMapper.getAllSnlist(liallSn);
+        List<String> snCodeList = authProductMapper.getSnCodeList(authUserId, authId,allSnlist);
         return ResponseJson.success(snCodeList);
     }
 
+    @Override
+    public ResponseJson<List<String>> getSnCodeList1(Integer authUserId, Integer authId) {
+        //判断该机构是否与其他机构关联
+        String relationId = authProductMapper.getRelationId(authId);
+        String[] relationIdList=null;
+        List<String> snCodeList=new ArrayList<>();
+        if (!"".equals(relationId)&&null !=relationId){
+            relationIdList = relationId.split(",");
+            //获取该机构下所有的sn码
+            List<Integer> liallSn = authProductMapper.getAllSn(authId);
+            List<String> allSnlist = authProductMapper.getAllSnlist(liallSn);
+            snCodeList = authProductMapper.getSnCodeList1(authUserId, authId,relationIdList,allSnlist);
+        }
+        return ResponseJson.success(snCodeList);
+
+    }
+
     @Override
     public ResponseJson checkProductType(Integer productTypeId) {
         authProductMapper.checkProductType(productTypeId);
         return ResponseJson.success();
     }
 
+    public ResponseJson<List<ProductListVo>> getPronductInfo( Integer authId,Integer authUserId){
+        List<ProductListVo> pronductInfo = authProductMapper.getPronductInfo(authId, authUserId);
+        return ResponseJson.success(pronductInfo);
+    }
+
 }

+ 53 - 4
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -98,7 +98,16 @@ public class AuthServiceImpl implements AuthService {
         PageInfo<AuthVo> pageData = new PageInfo<>(authList);
         return ResponseJson.success(pageData);
     }
-
+    @Override
+    public ResponseJson<PageInfo<AuthVo>> getAuthListAll(Integer listType, Integer authUserId, String authParty,
+                                                       String mobile, Integer status, Integer starFlag, Integer auditStatus,
+                                                       Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, String name,String snCode,Integer pageNum, Integer pageSize) {
+        listType = null == listType ? 1 : listType;
+        PageHelper.startPage(pageNum, pageSize);
+        List<AuthVo> authList = authMapper.getAuthListAll(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus,name,snCode);
+        PageInfo<AuthVo> pageData = new PageInfo<>(authList);
+        return ResponseJson.success(pageData);
+    }
     @Override
     public ResponseJson updateAuthStatus(Integer authId, Integer status) {
         if (null == authId) {
@@ -140,6 +149,13 @@ public class AuthServiceImpl implements AuthService {
             return ResponseJson.error("参数异常,机构id不能为空", null);
         }
         AuthFormVo authFormVo = authMapper.getAuthFormById(authId);
+        //该机构关联机构用集合形式返回便于前端赋值
+        if(null!=authFormVo.getRelationId()&&!"".equals(authFormVo.getRelationId())){
+            String[] relationIdList = authFormVo.getRelationId().split(",");
+            List<AuthFormVo> authIdList = authMapper.getAuthIdList(relationIdList);
+            authFormVo.setReleationClubList(authIdList);
+        }
+
         if (null != authFormVo.getLng()) {
             authFormVo.setLngAndLat(authFormVo.getLng() + "," + authFormVo.getLat());
         }
@@ -192,8 +208,8 @@ public class AuthServiceImpl implements AuthService {
     }
 
     @Override
-    public ResponseJson starAuth(Integer authId, Integer starFlag) {
-        authMapper.starAuth(authId, starFlag);
+    public ResponseJson starAuth(Integer authId, Integer starFlag,String starNum) {
+        authMapper.starAuth(authId, starFlag,starNum);
         return ResponseJson.success();
     }
 
@@ -691,5 +707,38 @@ public class AuthServiceImpl implements AuthService {
         }
         return ResponseJson.success("导入成功");
     }
-
+    /**
+     * 获取机构关联的机构信息
+     * 1.7.4版本:
+     *
+     */
+    @Override
+    public ResponseJson<List<AuthFormVo>> getRelationgInfo(String  snCode,Integer authUserId){
+        //根据sn码获取关联这个产品的机构列表
+        List<ProductFormVo> relationgList = authMapper.getRelationgList(snCode);
+        String  relationgInfo=null;
+        List<AuthFormVo> authIdList=null;
+        if(relationgList.size()>0){
+            for(int i=0;i<relationgList.size();i++){
+                if(null!=relationgInfo){
+                    relationgInfo+=",";
+                }
+                relationgInfo+=relationgList.get(i).getRelationId();
+            }
+            if(null!=relationgInfo){
+                String[] relationIdList = relationgInfo.split(",");
+                authIdList = authMapper.getAuthIdList(relationIdList);
+            }
+        }
+        return ResponseJson.success(authIdList);
+    }
+    /**
+     *  1.7.4版本
+     * 获取可绑定机构机构信息
+     * **/
+    @Override
+    public ResponseJson<List<AuthFormVo>> getClubBindAuth(Integer authUserId){
+        List<AuthFormVo> clubBindAuth = authMapper.getClubBindAuth(authUserId);
+        return  ResponseJson.success(clubBindAuth);
+    }
 }

+ 263 - 55
src/main/resources/mapper/AuthMapper.xml

@@ -1,17 +1,22 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.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,
-                                   mobile, userMobile, linkMan, linkMobile, firstClubType, secondClubType, medicalLicenseImage, empNum,
+                                   mobile, userMobile, linkMan, linkMobile, firstClubType, secondClubType,
+                                   medicalLicenseImage, empNum,
                                    logo, customFlag, remarks, authCode, authDate, authImageLogo, authImage,
                                    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},
-                #{mobile}, #{userMobile}, #{linkMan}, #{linkMobile}, #{firstClubType}, #{secondClubType}, #{medicalLicenseImage}, #{empNum},
+                #{mobile}, #{userMobile}, #{linkMan}, #{linkMobile}, #{firstClubType}, #{secondClubType},
+                #{medicalLicenseImage}, #{empNum},
                 #{logo}, #{customFlag}, #{remarks}, #{authCode}, #{authDate}, #{authImageLogo}, #{authImage},
                 #{authImageType}, #{status}, NOW(), #{createBy}, #{createSource}, #{auditBy},
-                #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{checkFlag}, #{delFlag})
+                #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{checkFlag},
+                #{delFlag})
     </insert>
     <insert id="insertBanner">
         insert into cm_brand_auth_banner (authId, banner)
@@ -50,7 +55,9 @@
             status              = #{status},
             auditStatus         = #{auditStatus},
             shopAuditStatus     = #{shopAuditStatus},
-            checkFlag           = #{checkFlag}
+            checkFlag           = #{checkFlag},
+            relationId          = #{relationId},
+            relationName        = #{relationName}
         where id = #{id}
     </update>
     <update id="updateAuthAuditStatus">
@@ -63,15 +70,19 @@
         where id = #{authId}
     </update>
     <update id="deleteAuthByAuthId">
-        update cm_brand_auth set delFlag = 1 where id = #{authId}
+        update cm_brand_auth
+        set delFlag = 1
+        where id = #{authId}
     </update>
     <update id="updateLdmLatestClubId">
-        update ldm_latest_club_id set ldmClubId = #{ldmLatestClubId} where id = 1;
+        update ldm_latest_club_id
+        set ldmClubId = #{ldmLatestClubId}
+        where id = 1;
     </update>
     <update id="updateRemarks">
         update cm_brand_auth
         set customFlag = 1,
-            remarks = #{remarks}
+            remarks    = #{remarks}
         where id = #{authId}
     </update>
     <update id="updateAuthShopAuditStatus">
@@ -103,19 +114,26 @@
     </update>
     <update id="starAuth">
         update cm_brand_auth
-        set starFlag = #{starFlag}
+        set starFlag = #{starFlag},
+            starNum=#{starNum}
         where id = #{authId}
     </update>
     <update id="addScanCount">
-        update cm_brand_auth set scanCount = scanCount + 1 where id = #{authId}
+        update cm_brand_auth
+        set scanCount = scanCount + 1
+        where id = #{authId}
     </update>
     <delete id="deleteBanner">
-        delete from cm_brand_auth_banner where authId = #{authId}
+        delete
+        from cm_brand_auth_banner
+        where authId = #{authId}
     </delete>
     <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
-        select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus, a.createTime,
-        if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name) as auditBy,a.auditTime,a.invalidReason,
-               ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
+        select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
+        a.createTime,
+        if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
+        as auditBy,a.auditTime,a.invalidReason,
+        ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
         a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
         ifnull(ap.waitAuditNum,0) as waitAuditNum,
         ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
@@ -128,14 +146,14 @@
         left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
         left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
         left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
-            left join cm_brand_product_relation r on p.id = r.productId
-            where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
+        left join cm_brand_product_relation r on p.id = r.productId
+        where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
         left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
-            left join cm_brand_product_relation r on p.id = r.productId
-            where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
+        left join cm_brand_product_relation r on p.id = r.productId
+        where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
         left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
-            left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
-            on a.id = cp.authId
+        left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
+        on a.id = cp.authId
         where a.authUserId = #{authUserId} and a.delFlag = 0
         <if test="authParty != null and authParty != ''">
             and a.authParty like CONCAT('%',#{authParty},'%')
@@ -184,19 +202,133 @@
         </if>
         <choose>
             <when test="listType == 2">
-                order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc, a.createTime desc
+                order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
+                a.createTime desc
             </when>
             <when test="listType == 3">
-                order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc, a.createTime desc
+                order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
+                a.createTime desc
             </when>
             <otherwise>
                 order by a.createTime desc, a.id desc
             </otherwise>
         </choose>
     </select>
+
+    <select id="getAuthListAll" resultType="com.caimei.model.vo.AuthVo">
+        select DISTINCT a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
+        a.createTime,
+        if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
+        as auditBy,a.auditTime,a.invalidReason,
+        ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
+        a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
+        ifnull(ap.waitAuditNum,0) as waitAuditNum,
+        ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
+        if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
+        a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum,
+        a.starNum,a.relationId,a.relationName
+        from cm_brand_auth a
+        left join cm_brand_auth_user cu on a.createBy = cu.authUserId
+        left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
+        left join cm_brand_auth_user au on a.auditBy = au.authUserId
+        left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
+        left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
+
+
+        left join (select r.authId,p.name,p.snCode,count(*) as waitAuditNum from cm_brand_auth_product p
+        left join cm_brand_product_relation r on p.id = r.productId
+        where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
+        left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
+        left join cm_brand_product_relation r on p.id = r.productId
+        where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
+        left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
+        left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
+        on a.id = cp.authId
+        LEFT JOIN (SELECT
+        r.authId,
+        if(p.name IS NULL,t.name,p.name) as productName,
+        p.snCode
+        FROM
+        cm_brand_auth_product p
+        LEFT JOIN cm_brand_product_relation r ON p.id = r.productId
+        LEFT JOIN cm_brand_auth aw on aw.id=r.authId
+        LEFT JOIN cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
+        where p.shopAuditStatus=1
+        ) dp on a.id = dp.authId
+        where a.authUserId = #{authUserId} and a.delFlag = 0
+        <if test="authParty != null and authParty != ''">
+            and a.authParty like CONCAT('%',#{authParty},'%')
+        </if>
+        <if test="status != null">
+            and a.status = #{status}
+        </if>
+        <if test="starFlag != null">
+            and a.starFlag = #{starFlag}
+        </if>
+        <if test="auditStatus != null">
+            and a.auditStatus = #{auditStatus}
+        </if>
+
+        <if test="name != null and name != ''">
+            and dp.productName = #{name}
+        </if>
+        <if test="snCode != null and snCode != ''">
+            and dp.snCode = #{snCode}
+        </if>
+
+
+        <if test="1 == listType or 2 == listType">
+            and a.shopAuditStatus = 1
+        </if>
+        <if test="mobile != null and mobile != ''">
+            and cbcu2.mobile like concat('%', #{mobile},'%')
+        </if>
+        <if test="4 == listType">
+            and a.auditStatus = 1
+        </if>
+        <if test="shopAuditStatus != null">
+            <if test="0 == shopAuditStatus">
+                and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
+            </if>
+            <if test="1 == shopAuditStatus">
+                and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
+            </if>
+        </if>
+        <if test="sendStatus != null">
+            <if test="0 == sendStatus">
+                and a.sendStatus != 1
+            </if>
+            <if test="1 == sendStatus">
+                and a.sendStatus = 1
+            </if>
+        </if>
+        <if test="lowerAuditStatus != null">
+            <if test="0 == lowerAuditStatus">
+                and ifnull(ap.waitAuditNum,0) > 0
+            </if>
+            <if test="1 == lowerAuditStatus">
+                and ifnull(ap.waitAuditNum,0) = 0
+            </if>
+        </if>
+        <choose>
+            <when test="listType == 2">
+                order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
+                a.createTime desc
+            </when>
+            <when test="listType == 3">
+                order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
+                a.createTime desc
+            </when>
+            <otherwise>
+                order by a.createTime desc, a.id desc
+            </otherwise>
+        </choose>
+    </select>
+
     <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
         select count(*)
-        from cm_brand_auth_product p left join cm_brand_product_relation r on p.id = r.productId
+        from cm_brand_auth_product p
+                 left join cm_brand_product_relation r on p.id = r.productId
         where r.authId = #{authId}
           and p.auditStatus = 2
     </select>
@@ -226,59 +358,89 @@
                  left join province p on a.provinceId = p.provinceID
                  left join city c on a.cityId = c.cityID
                  left join town t on a.townId = t.townID
-        where a.delFlag = 0 and find_in_set(a.id, #{authIds})
+        where a.delFlag = 0
+          and find_in_set(a.id, #{authIds})
         order by createTime desc
     </select>
     <select id="getBannerList" resultType="java.lang.String">
-        select banner from cm_brand_auth_banner where authId = #{authId}
+        select banner
+        from cm_brand_auth_banner
+        where authId = #{authId}
     </select>
     <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
-        select name as authParty,if(status = 1,1,0) as status,if(status = 1,1,0) as auditStatus,
-               tel as mobile,addr as address,pic1,pic2,pic3,pic4,pic5,du as lngAndLat,
-               if(deleted_at is null,0,1) as delFlag,regId1,regId2,regId3
+        select name                         as authParty,
+               if(status = 1, 1, 0)         as status,
+               if(status = 1, 1, 0)         as auditStatus,
+               tel                          as mobile,
+               addr                         as address,
+               pic1,
+               pic2,
+               pic3,
+               pic4,
+               pic5,
+               du                           as lngAndLat,
+               if(deleted_at is null, 0, 1) as delFlag,
+               regId1,
+               regId2,
+               regId3
         from nissan_ht_alcohol;
     </select>
     <select id="getProvinceId" resultType="java.lang.Integer">
         select provinceID
         from province
         where name like
-              concat(#{provinceName},'%') limit 1;
+              concat(#{provinceName}, '%') limit 1;
     </select>
     <select id="getCityId" resultType="java.lang.Integer">
         select cityID
         from city
         where name like
-              concat(#{cityName},'%') limit 1;
+              concat(#{cityName}, '%') limit 1;
     </select>
     <select id="getTownId" resultType="java.lang.Integer">
         select townID
         from town
         where name like
-              concat(#{townName},'%') limit 1;
+              concat(#{townName}, '%') limit 1;
     </select>
     <select id="getLdmLatestClubId" resultType="java.lang.Integer">
-        select ldmClubId from ldm_latest_club_id where id = 1;
+        select ldmClubId
+        from ldm_latest_club_id
+        where id = 1;
     </select>
     <select id="getCityIdByTownId" resultType="java.lang.Integer">
-        select cityID from town where townID = #{townId}
+        select cityID
+        from town
+        where townID = #{townId}
     </select>
     <select id="getProvinceName" resultType="java.lang.String">
-        select name from nissan_base_region1 where code = #{regId1} and level = 0 limit 1
+        select name
+        from nissan_base_region1
+        where code = #{regId1}
+          and level = 0 limit 1
     </select>
     <select id="getCityName" resultType="java.lang.String">
-        select name from nissan_base_region1 where code = #{regId1} and level = 1 limit 1
+        select name
+        from nissan_base_region1
+        where code = #{regId1}
+          and level = 1 limit 1
     </select>
     <select id="getTownName" resultType="java.lang.String">
-        select name from nissan_base_region1 where code = #{regId1} and level = 2 limit 1
+        select name
+        from nissan_base_region1
+        where code = #{regId1}
+          and level = 2 limit 1
     </select>
     <select id="getTownList" resultType="com.caimei.model.po.TownPo">
         select townID as townId, cityID as cityId
         from town
         where name like
-              concat(#{townName},'%');
+              concat(#{townName}, '%');
     </select>
     <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
-        select provinceID from city where cityID = #{cityId}
+        select provinceID
+        from city
+        where cityID = #{cityId}
     </select>
     <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
         select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
@@ -295,14 +457,14 @@
         </where>
     </select>
     <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
-        select id      as authId,
+        select id                               as authId,
                a.authUserId,
                authParty,
                a.status,
                a.auditStatus,
                a.createTime,
-               cu.name as createBy,
-               ifnull(au.loginAccount,au.name) as auditBy,
+               cu.name                          as createBy,
+               ifnull(au.loginAccount, au.name) as auditBy,
                a.auditTime,
                a.invalidReason
         from cm_brand_auth a
@@ -340,23 +502,28 @@
                authImageType,
                status,
                auditStatus,
+               relationId,
+               relationName,
                if(shopAuditStatus = 0, shopInvalidReason, invalidReason)                    as invalidReason
         from cm_brand_auth a
                  left join province p on a.provinceId = p.provinceID
                  left join city c on a.cityId = c.cityID
                  left join town t on a.townId = t.townID
-        where id = #{authId} and a.delFlag = 0
+        where id = #{authId}
+          and a.delFlag = 0
     </select>
     <select id="getTownNames" resultType="java.lang.String">
-        select name from town
+        select name
+        from town
     </select>
     <select id="getProvinceNames" resultType="java.lang.String">
-        SELECT NAME FROM province
+        SELECT NAME
+        FROM province
     </select>
     <select id="getCityNames" resultType="java.lang.String">
         select name from city
         <if test="ProvinceId !=null">
-        where provinceID = #{ProvinceId}
+            where provinceID = #{ProvinceId}
         </if>
     </select>
     <select id="getCityIdByProvinceId" resultType="java.lang.Integer">
@@ -368,32 +535,36 @@
         limit 1
     </select>
     <select id="getProvinceNameById" resultType="java.lang.String">
-        select name from province
+        select name
+        from province
         where provinceID = #{provinceId}
     </select>
     <select id="getCityNameByCityId" resultType="java.lang.String">
-        select name from city
+        select name
+        from city
         where cityID = #{cityId}
     </select>
     <select id="getTownNameById" resultType="java.lang.String">
-        select name from town
+        select name
+        from town
         where townID = #{townId}
     </select>
     <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
-        select id as authId from cm_brand_auth
-        where authParty like concat('%',#{authParty},'%') and address like concat('%',#{address},'%')
-        and delFlag = 0
+        select id as authId
+        from cm_brand_auth
+        where authParty like concat('%', #{authParty}, '%')
+          and address like concat('%', #{address}, '%')
+          and delFlag = 0
     </select>
     <select id="getAdminUserId" resultType="java.lang.Integer">
         select authUserId
         from cm_brand_auth_user
-        where userIdentity = 1
-        limit 1
+        where userIdentity = 1 limit 1
     </select>
     <select id="getAuthTemplate" resultType="com.caimei.model.vo.TemplateVo">
         select at.id as templateId, templateImage, qrPosition, qrSize
         from cm_brand_auth_template at
-            left join cm_brand_auth a on at.authUserId = a.authUserId and a.delFlag = 0
+        left join cm_brand_auth a on at.authUserId = a.authUserId and a.delFlag = 0
         where at.status = 1
         <if test="templateType == 1">
             and at.authFlag = 1
@@ -415,4 +586,41 @@
         where authUserId = #{authUserId}
           and delFlag = 0
     </select>
+    <select id="getAuthIdList" resultType="com.caimei.model.vo.AuthFormVo">
+        select id as authId,authParty from cm_brand_auth where
+        id in
+        <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
+            #{reId,jdbcType=VARCHAR}
+        </foreach>
+    </select>
+    <select id="getRelationgInfo" resultType="com.caimei.model.vo.AuthFormVo">
+        select relationId, relationName
+        from cm_brand_auth
+        where authUserId = #{authUserId}
+          and id = #{authId}
+          and delFlag = 0
+    </select>
+
+    <select id="getClubBindAuth" resultType="com.caimei.model.vo.AuthFormVo">
+        select au.id as authId,au.authParty
+        from cm_brand_auth au
+        where au.id not in (
+            select cu.authId
+
+            from cm_brand_auth a
+                     left join cm_brand_club_user cu on cu.authId = a.id
+            where cu.authUserId = #{authUserId}
+              and cu.delFlag = 0
+              and (a.id is null || a.delFlag = 0))
+          and au.delFlag = 0 and au.authUserId = #{authUserId}
+    </select>
+
+
+    <select id="getRelationgList" resultType="com.caimei.model.vo.ProductFormVo">
+        select DISTINCT r.authId as relationId
+        from cm_brand_product_relation r
+                 LEFT JOIN cm_brand_auth_product a on r.productId = a.id
+        where snCode =#{snCode}
+    </select>
+
 </mapper>

+ 68 - 0
src/main/resources/mapper/AuthProductMapper.xml

@@ -493,6 +493,34 @@
                  left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_auth a on a.id = r.authId
         where a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) ) and p.auditStatus = 1
+        <if test="snCodeList != null and snCodeList.size>0">
+            and p.snCode not in
+            <foreach collection="snCodeList" open="(" separator="," close=")" item="sn">
+                #{sn,jdbcType=VARCHAR}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSnCodeList1" resultType="java.lang.String">
+        select DISTINCT snCode,p.id,p.name
+        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
+        where
+        a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) ) and p.auditStatus = 1
+        <if test="snCodeList != null and snCodeList.size>0">
+            and p.snCode not in
+            <foreach collection="snCodeList" open="(" separator="," close=")" item="sn">
+                #{sn,jdbcType=VARCHAR}
+            </foreach>
+        </if>
+        <if test="relationIdList != null and relationIdList.length>0">
+            and   a.id in
+            <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
+                #{reId,jdbcType=VARCHAR}
+            </foreach>
+        </if>
+
     </select>
     <select id="getProductClubList" resultType="com.caimei.model.vo.WxClubListVo">
         select a.id as authId, a.authParty, a.logo
@@ -500,4 +528,44 @@
                  left join cm_brand_product_relation r on a.id = r.authId
         where r.productId = #{productId} and a.delFlag = 0
     </select>
+    <select id="getRelationId" resultType="java.lang.String">
+        select a.relationId
+        from cm_brand_auth a
+        where a.id=#{authId}
+    </select>
+    <select id="getSnList" resultType="com.caimei.model.po.ProductPo">
+        select a.id as productId,a.authId1 as authId
+        from cm_brand_auth_product a
+        where a.snCode=#{sn}
+    </select>
+    <select id="getAllSn"  resultType="java.lang.Integer">
+        select a.productId
+        from cm_brand_product_relation a
+        where a.authId=#{authId}
+    </select>
+    <select id="getAllSnlist"  resultType="java.lang.String">
+        select a.snCode
+        from cm_brand_auth_product a where a.id in
+        <foreach collection="productIdList" open="(" separator="," close=")" item="reId">
+            #{reId,jdbcType=VARCHAR}
+        </foreach>
+    </select>
+    <select id="getPronductInfo" resultType="com.caimei.model.vo.ProductListVo">
+        select r.id as relationId,p.id as productId,a.authUserId, if(p.productTypeId is null,p.name,t.name) as
+                       productName,t.image,
+               snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
+               if(p.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu.mobile) as createBy,
+               ifnull(au.loginAccount,au.name) as
+                   auditBy,p.auditTime,p.invalidReason,ifnull(p.shopInvalidReason,p.invalidReason) as shopInvalidReason,
+               ifnull(au1.loginAccount,au1.name) as shopAuditBy, p.shopAuditTime, p.checkFlag, p.scanCount
+        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 r.authId = a.id and a.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 au on p.auditBy = au.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 and cbcu.delFlag = 0
+        where a.id = #{authId} and a.authUserId=#{authUserId} and p.shopAuditStatus=1
+    </select>
 </mapper>

+ 14 - 2
src/main/resources/mapper/ClubMapper.xml

@@ -111,7 +111,7 @@
         where cu.mobile = #{mobile} and au.appId = #{appId} and cu.delFlag = 0 limit 1
     </select>
     <select id="getWxClubUser" resultType="com.caimei.model.vo.WxClubUserVo">
-        select cu.id as clubUserId, cu.authId as authId, cu.authUserId, cu.mobile, cu.status
+        select cu.id as clubUserId, cu.authId as authId, cu.authUserId, cu.mobile, cu.status,a.authParty,a.logo
         from cm_brand_club_user cu
                  left join cm_brand_auth a on cu.authId = a.id and a.delFlag = 0
                  left join cm_brand_auth_user au on a.authUserId = au.authUserId
@@ -141,6 +141,12 @@
                a.mobile,
                a.logo,
                a.authImage,
+               a.linkMan,
+               a.linkMobile,
+               a.medicalLicenseImage,
+               a.firstClubType,
+               a.secondClubType,
+               a.empNum,
                concat(a.lng,',',a.lat) as lngAndLat,
                if(a.customFlag = 1,a.remarks,null) as remarks
         from cm_brand_auth a
@@ -174,6 +180,12 @@
         and a.delFlag = 0
         and au.status = 1
         and a.starFlag = 1
-        order by rand()
+        order by a.starnum,a.createTime desc
     </select>
+    <update id="saveBindAuth">
+        update cm_brand_club_user
+        set authId = #{authId},
+            name=#{authParty}
+        where id = #{clubUserId} and authUserId=#{authUserId}
+    </update>
 </mapper>