浏览代码

子账户管理功能

chenlei1231 1 月之前
父节点
当前提交
c24e65f55e

+ 75 - 68
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebEnquiryMapper.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.adweb.enquiry.mapper;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
@@ -16,82 +17,88 @@ import java.util.Date;
 import java.util.List;
 
 /**
- * @Description: 询盘信息存储表单
- * @Author: jeecg-boot
- * @Date: 2024-10-12
- * @Version: V1.0
+ * @Description: 询盘信息存储表单 @Author: jeecg-boot @Date: 2024-10-12 @Version: V1.0
  */
 public interface AdwebEnquiryMapper extends BaseMapper<AdwebEnquiry> {
 
-    /**
-     * @param page
-     * @param userEffective
-     * @param searchText
-     * @param ctimeBegin
-     * @param ctimeEnd
-     * @return
-     */
-    IPage<EnquiryListDto> selectEnquiryList(IPage<EnquirySearchDto> page,
-                                            @Param("codeList") List<String> codeList,
-                                            @Param("userEffective") String userEffective,
-                                            @Param("wasteEnquiryType") String wasteEnquiryType,
-                                            @Param("searchText") String searchText,
-                                            @Param("searchContent") String searchContent,
-                                            @Param("ctimeBegin") Date ctimeBegin,
-                                            @Param("ctimeEnd") Date ctimeEnd,
-                                            @Param("whatsApp") String whatsApp,
-                                            @Param("readStatus") Integer readStatus,
-                                            @Param("principalUid") String principalUid,
-                                            @Param("selfPrincipalUid") String selfPrincipalUid);
+  /**
+   * @param page
+   * @param userEffective
+   * @param searchText
+   * @param ctimeBegin
+   * @param ctimeEnd
+   * @return
+   */
+  IPage<EnquiryListDto> selectEnquiryList(
+      IPage<EnquirySearchDto> page,
+      @Param("codeList") List<String> codeList,
+      @Param("userEffective") String userEffective,
+      @Param("wasteEnquiryType") String wasteEnquiryType,
+      @Param("searchText") String searchText,
+      @Param("searchContent") String searchContent,
+      @Param("ctimeBegin") Date ctimeBegin,
+      @Param("ctimeEnd") Date ctimeEnd,
+      @Param("whatsApp") String whatsApp,
+      @Param("readStatus") Integer readStatus,
+      @Param("principalUid") String principalUid,
+      @Param("selfPrincipalUid") String selfPrincipalUid);
 
-    /**
-     * 根据地区更新询盘跟进人
-     */
-    void updatePrincipalUidByRegion(Integer siteId, List<Integer> siteIds);
+  /** 根据地区更新询盘跟进人 */
+  void updatePrincipalUidByRegion(Integer siteId, List<Integer> siteIds);
 
-    /**
-     * @param page
-     * @param siteId
-     * @param userEffective
-     * @param searchText
-     * @param ctimeBegin
-     * @param ctimeEnd
-     * @return
-     */
-    IPage<EnquiryListDto> queryWasteEnquiryList(IPage<EnquirySearchDto> page,
-                                                @Param("codeList") List<String> codeList,
-                                                @Param("siteId") String siteId,
-                                                @Param("userEffective") String userEffective,
-                                                @Param("searchText") String searchText,
-                                                @Param("ctimeBegin") String ctimeBegin,
-                                                @Param("ctimeEnd") String ctimeEnd,
-                                                @Param("whatsApp") String whatsApp,
-                                                @Param("principalUid") String principalUid);
+  /**
+   * @param page
+   * @param siteId
+   * @param userEffective
+   * @param searchText
+   * @param ctimeBegin
+   * @param ctimeEnd
+   * @return
+   */
+  IPage<EnquiryListDto> queryWasteEnquiryList(
+      IPage<EnquirySearchDto> page,
+      @Param("codeList") List<String> codeList,
+      @Param("siteId") String siteId,
+      @Param("userEffective") String userEffective,
+      @Param("searchText") String searchText,
+      @Param("ctimeBegin") String ctimeBegin,
+      @Param("ctimeEnd") String ctimeEnd,
+      @Param("whatsApp") String whatsApp,
+      @Param("principalUid") String principalUid);
 
-    List<EnquiryListDto> getWastedEnquiry(String wasteEnquiryType, String ip, String email, String keyword, String searchText, String type, Integer siteId);
+  List<EnquiryListDto> getWastedEnquiry(
+      String wasteEnquiryType,
+      String ip,
+      String email,
+      String keyword,
+      String searchText,
+      String type,
+      Integer siteId);
 
-    /**
-     * 获取每日询盘数量及未读询盘数量
-     *
-     * @param siteCode
-     * @param start
-     * @param end
-     * @return List<ImmutableTriple < String, Long, Long>> -- MyBatis COUNT()方法默认类型为Long
-     */
-    List<ImmutableTriple<String, Long, Long>> getEnquiryDailyCounts(String siteCode, Date start, Date end);
+  /**
+   * 获取每日询盘数量及未读询盘数量
+   *
+   * @param siteCode
+   * @param start
+   * @param end
+   * @return List<ImmutableTriple < String, Long, Long>> -- MyBatis COUNT()方法默认类型为Long
+   */
+  List<ImmutableTriple<String, Long, Long>> getEnquiryDailyCounts(
+      String siteCode, Date start, Date end);
 
-    /**
-     * 获取分时间段的询盘数量 - 今天,昨天,本周,上周,本月,上月,全部
-     *
-     * @param siteCode
-     * @return List<Pair < String, Long>> -- MyBatis COUNT()方法默认类型为Long
-     */
-    List<ImmutablePair<String, Long>> getEnquiryPeriodicCounts(String siteCode);
+  /**
+   * 获取分时间段的询盘数量 - 今天,昨天,本周,上周,本月,上月,全部
+   *
+   * @param siteCode
+   * @return List<Pair < String, Long>> -- MyBatis COUNT()方法默认类型为Long
+   */
+  List<ImmutablePair<String, Long>> getEnquiryPeriodicCounts(String siteCode);
 
-    /**
-     * 获取按国家分布的询盘数量
-     */
-    List<EnquiryCountryStatsVO> getEnquiryCountryStats(String siteCode, Date start, Date end);
+  /** 获取按国家分布的询盘数量 */
+  List<EnquiryCountryStatsVO> getEnquiryCountryStats(String siteCode, Date start, Date end);
 
-    List<EnquiryDTO> getEnquiryList(String siteCode, String startTime, String endTime);
+  List<EnquiryDTO> getEnquiryList(String siteCode, String startTime, String endTime);
+
+  /** 统计管理的询盘数量 */
+  List<JSONObject> getEnquiryCount(List<String> uids);
 }

+ 16 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquiryMapper.xml

@@ -410,4 +410,20 @@
         </if>
     </select>
 
+    <select id="getEnquiryCount" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        principal_uid uid,
+        count(1) enquiryCount
+        FROM
+        adweb_enquiry
+        WHERE
+        `status` = 1
+        AND principal_uid IN
+        <foreach collection="uids" item="uid" open="(" close=")" separator=",">
+            #{uid}
+        </foreach>
+        GROUP BY
+        principal_uid
+    </select>
+
 </mapper>

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebEnquiryService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.adweb.enquiry.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import java.util.List;
+import java.util.Map;
 import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
 import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
 import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;
@@ -12,6 +13,14 @@ import org.jeecg.modules.adweb.site.entity.AdwebSite;
  */
 public interface IAdwebEnquiryService extends IService<AdwebEnquiry> {
 
+  /** 统计管理的询盘数量 */
+  Map<String, Integer> getEnquiryCount(List<String> uids);
+
+  /**
+   * 统计管理的询盘数量
+   */
+  int getEnquiryCount(String uid);
+  
   void addEnquiry(EnquiryDTO enquiryDTO, String plugin, AdwebSite adwebSite);
 
   /** 返回用户名称 */

+ 25 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebEnquiryServiceImpl.java

@@ -40,6 +40,7 @@ import org.jeecg.modules.adweb.enquiry.mapper.AdwebEnquiryMapper;
 import org.jeecg.modules.adweb.enquiry.service.*;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
 import org.jeecg.modules.adweb.system.entity.SysException;
 import org.jeecg.modules.adweb.system.service.IMasterSubAccountRelationService;
 import org.jeecg.modules.adweb.system.service.ISysExceptionService;
@@ -97,6 +98,8 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
 
   @Resource private IAdwebSiteEnquiryRuleService adwebSiteEnquiryRuleService;
 
+  @Resource private ISiteUserPermissionService siteUserPermissionService;
+
   @Resource private IEnquiryEmailMessageService enquiryEmailMessageService;
 
   @Resource private IAdwebSiteService adwebSiteService;
@@ -223,6 +226,28 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
     return blackWordList;
   }
 
+  /** 统计管理的询盘数量 */
+  @Override
+  public Map<String, Integer> getEnquiryCount(List<String> uids) {
+    Map<String, Integer> map = new HashMap<>();
+    List<JSONObject> list = adwebEnquiryMapper.getEnquiryCount(uids);
+    if (CollectionUtils.isNotEmpty(list))
+      for (JSONObject object : list) {
+        map.put(object.getString("uid"), object.getInteger("enquiryCount"));
+      }
+    return map;
+  }
+
+  /** 统计管理的询盘数量 */
+  @Override
+  public int getEnquiryCount(String uid) {
+    List<String> codeList = siteUserPermissionService.getSiteCodeList(uid);
+    QueryWrapper<AdwebEnquiry> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("status", 1);
+    queryWrapper.in("site_code", codeList);
+    return (int) this.count(queryWrapper);
+  }
+
   /**
    * 添加询盘
    *

+ 38 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseRoleManageController.java

@@ -0,0 +1,38 @@
+package org.jeecg.modules.adweb.enterprise.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.util.*;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.system.entity.SysRole;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Description: 企业角色管理 @Author: jeecg-boot @Date: 2022-06-13 @Version: V1.0
+ */
+@Tag(name = "企业角色管理")
+@RestController
+@RequestMapping("/enterprise/role")
+@Slf4j
+public class EnterpriseRoleManageController {
+  @Autowired private ISysRoleService sysRoleService;
+
+  @RequestMapping(value = "/queryall", method = RequestMethod.GET)
+  public Result<List<SysRole>> queryall(SysUser user) {
+    Result<List<SysRole>> result = new Result<>();
+    QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("role_code", "adweb_sub_vip").or().eq("create_by", user.getUsername());
+    List<SysRole> list = sysRoleService.list(queryWrapper);
+    if (list == null || list.size() <= 0) {
+      result.error500("未找到角色信息");
+    } else {
+      result.setResult(list);
+      result.setSuccess(true);
+    }
+    return result;
+  }
+}

+ 62 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseUserManageController.java

@@ -64,6 +64,68 @@ public class EnterpriseUserManageController {
 
   @Autowired private ISubUserEmailService subUserEmailService;
 
+  @AutoLog(value = "企业用户管理-分页列表查询")
+  @Operation(summary = "企业用户管理-分页列表查询")
+  @GetMapping(value = "/list")
+  public Result<IPage<User>> queryPageList(
+      SysUser user,
+      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+      HttpServletRequest req) {
+    Map<String, String[]> map = new HashMap(req.getParameterMap());
+    map.put("order", new String[] {"asc"});
+
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<String> idList =
+        masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
+    idList.add(loginUser.getId());
+
+    if (CollectionUtils.isEmpty(idList)) {
+      return Result.OK();
+    }
+
+    QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, map);
+    queryWrapper.ne("username", "_reserve_user_external");
+    queryWrapper.in("id", idList);
+    queryWrapper.eq("status", 1);
+    String queryCondition = req.getParameter("queryCondition");
+    if (StringUtils.isNotBlank(queryCondition)) {
+      queryWrapper.and(
+          wrapper ->
+              wrapper
+                  .like("username", queryCondition)
+                  .or()
+                  .like("realname", queryCondition)
+                  .or()
+                  .like("phone", queryCondition));
+    }
+    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
+    IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
+    // 类型转换
+    IPage<User> pageList2 = converseType(pageList);
+    // 序号
+    this.addSeqNumber(pageList2.getRecords(), pageNo, pageSize);
+    // 统计管理的询盘和产品数量
+    Map<String, Integer> map1 = adwebEnquiryService.getEnquiryCount(idList);
+    //    Map<String, Integer> map2 = adwebMaterialProductService.getProductCount(idList);
+    for (User user1 : pageList2.getRecords()) {
+      if (map1.get(user1.getId()) != null) {
+        user1.setEnquiryNum(map1.get(user1.getId()));
+      }
+      //      if (map2.get(user1.getId()) != null) {
+      //        user1.setProductNum(map2.get(user1.getId()));
+      //      }
+    }
+    // 主账户产品和询盘数量统计规则不同
+    if (pageNo == 1) {
+      User user1 = pageList2.getRecords().get(0);
+      user1.setPrimaryAccount(true);
+      user1.setEnquiryNum(adwebEnquiryService.getEnquiryCount(user1.getId()));
+      //      user1.setProductNum(adwebMaterialProductService.getProductCount(user1.getId()));
+    }
+    return Result.OK(pageList2);
+  }
+
   /**
    * 子账户分页列表查询
    *