瀏覽代碼

工作台数据查询,添加权限 添加查询商品列表接口

zhaoxian 2 年之前
父節點
當前提交
7039dff117

+ 35 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemCollectSamplesController.java

@@ -566,6 +566,41 @@ public class KuaishouItemCollectSamplesController extends BaseController {
         }
         return returnJson;
     }
+
+    @GetMapping("/queryProductList")
+    @ApiOperation(value = "查询商品列表")
+    public TableDataInfo queryProductList(
+            @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
+            @ApiParam("商品标题") @RequestParam(value = "itemTitle", required = false) String itemTitle,
+            @ApiParam("达人id") @RequestParam(value = "promoterId", required = false) Long promoterId,
+            @ApiParam("达人昵称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
+            @ApiParam("商品单价起始价") @RequestParam(value = "reservePriceStart", required = false) Double reservePriceStart,
+            @ApiParam("商品单价结束价") @RequestParam(value = "reservePriceEnd", required = false) Double reservePriceEnd,
+            @ApiParam("有效订单数起始数") @RequestParam(value = "validorderStart", required = false) Double validorderStart,
+            @ApiParam("有效订单数结束数") @RequestParam(value = "validorderEnd", required = false) Double validorderEnd,
+            @ApiParam("起始时间") @RequestParam(value = "startDate", required = true) String startDate,
+            @ApiParam("结束时间") @RequestParam(value = "EndDate", required = true) String EndDate
+    ) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("itemId", itemId);
+        map.put("itemTitle", itemTitle);
+        map.put("promoterId", promoterId);
+        map.put("promoterNickName", promoterNickName);
+        map.put("reservePriceStart", reservePriceStart);
+        map.put("reservePriceEnd", reservePriceEnd);
+        map.put("validorderStart", validorderStart);
+        map.put("validorderEnd", validorderEnd);
+        map.put("startDate", startDate);
+        map.put("EndDate", EndDate);
+        JSONObject returnJson = new JSONObject();
+        try {
+            List<JSONObject> list = kuaishouItemCollectSamplesService.queryProductList(map);
+            return getDataTable(list);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }
 
 

+ 2 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -28,6 +28,7 @@ import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -584,7 +585,7 @@ public class SupplyChainController extends BaseController {
         Map<String, Object> requestMap = new HashMap<>();
         if (dateType == 0) {
             if (Check.isNotNull(userId)) {
-                requestMap.put("promoterIds", promoterService.selectPromoterIdList(userId));
+                requestMap.put("promoterIds", promoterService.selectPromoterIdList(Arrays.asList(userId)));
             }
             if (!Check.isNull(orderStartDate)) {
                 Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间

+ 4 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouItemCollectSamplesMapper.java

@@ -101,12 +101,14 @@ public interface KuaishouItemCollectSamplesMapper {
 
     Long getItemIdById(@Param("id") Long id);
 
-    Integer getSampleCountByUserId(@Param("collectSampleId") Long collectSampleId, @Param("itemCreateId") Long itemCreateId, @Param("status") Integer status);
+    Integer getSampleCountByUserId(@Param("userList")  List<Long> userList, @Param("userType") Integer userType, @Param("status") Integer status);
 
     JSONObject queryTheNumberOfCompletedJobs(@Param("promoterIds") List<Long> promoterIds, @Param("startDate") String startDate,@Param("endDate")  String endDate);
 
     List<JSONObject> selectPromoterInfo(@Param("map") Map<Long, Long> map);
 
-    List<Long> getItemIdsByCreateId(@Param("itemCreateId")  Long itemCreateId);
+    List<Long> getItemIdsByCreateId(@Param("userList") List<Long> userList);
+
+    List<JSONObject> queryProductList(Map<String, Object> map);
 }
 

+ 2 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouPromoterMapper.java

@@ -61,7 +61,7 @@ public interface KuaishouPromoterMapper {
 
     void insertKuaishouPromoterRecord(JSONObject record);
 
-    List<Long> selectPromoterIdList(@Param("userId") Long userId);
+    List<Long> selectPromoterIdList(@Param("userList") List<Long> userList);
 
-    JSONObject getgetMonthPromoterTotal(@Param("userId") Long userId, @Param("start") String start, @Param("end") String end);
+    JSONObject getgetMonthPromoterTotal(@Param("userList") List<Long> userList, @Param("start") String start, @Param("end") String end);
 }

+ 1 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouItemCollectSamplesService.java

@@ -100,5 +100,6 @@ public interface IKuaishouItemCollectSamplesService {
 
     JSONObject getDataAnalysis(Long userId, String type);
 
+    List<JSONObject> queryProductList(Map<String, Object> map);
 }
 

+ 2 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -57,7 +57,7 @@ public interface IKuaishouPromoterService {
 
     KuaishouPromoter getOnlyPromoterInfo(Long promoterId);
 
-    List<Long> selectPromoterIdList(Long userId);
+    List<Long> selectPromoterIdList(List<Long> userList);
 
-    JSONObject getgetMonthPromoterTotal(Long userId, String start, String end);
+    JSONObject getgetMonthPromoterTotal(List<Long> userList, String start, String end);
 }

+ 70 - 24
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -13,6 +13,7 @@ import com.kuaidi100.sdk.request.SubscribeReq;
 import com.ruixuan.common.core.domain.entity.SysUser;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.common.utils.PageUtils;
 import com.ruixuan.isc.entity.KuaishouItemCollectSampleExpress;
 import com.ruixuan.isc.entity.KuaishouItemCollectSampleLog;
 import com.ruixuan.isc.entity.KuaishouItemCollectSamples;
@@ -20,6 +21,7 @@ import com.ruixuan.isc.mapper.KuaishouItemCollectSamplesMapper;
 import com.ruixuan.isc.service.IKuaishouItemCollectSamplesService;
 import com.ruixuan.isc.service.IKuaishouPromoterService;
 import com.ruixuan.isc.service.ISupplyChainService;
+import com.ruixuan.system.service.ISysDeptService;
 import com.ruixuan.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,6 +29,7 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
@@ -55,6 +58,9 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
     @Autowired
     private ISupplyChainService supplyChainService;
 
+    @Autowired
+    private ISysDeptService deptService;
+
     /**
      * 查询【请填写功能名称】
      *
@@ -351,12 +357,21 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
     @Override
     public JSONObject getPersonalInfo(Long userId, String type) {
-        Long collectSampleId = null;
-        Long itemCreateId = null;
-        if ("1".equals(type)) {
-            collectSampleId = userId;
+        String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
+        List<Long> userList = null;
+        if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
+            Long deptId = deptService.getDeptIdByUserId(userId);
+            userList = deptService.getDeptUserListByDeptId(deptId);
         } else {
-            itemCreateId = userId;
+            userList = Arrays.asList(userId);
+        }
+        int userType = 1;
+        if (!"1".equals(type)) {
+            userType = 2;
+            if ("supplyChainAdmin".equals(roleKey)) {
+                //供应链管理员查看 招商人员数据
+                userList = deptService.getDeptUserListByDeptId(150200L);
+            }
         }
 
         JSONObject returnJson = new JSONObject();
@@ -366,11 +381,11 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             data.put("userName", sysUser.getNickName());
         }
         Integer status = 1; //待审核领样数
-        data.put("toBeReviewed", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
+        data.put("toBeReviewed", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
         status = 3;//待发货领样数
-        data.put("toBeShipped", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
-        status = 5;//待上传作业数
-        data.put("toBeUploaded", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
+        data.put("toBeShipped", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
+        status = 6;//作业上传成功待招商审核
+        data.put("toBeUploaded", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
         returnJson.put("code", 0);
         returnJson.put("message", "调用成功");
         returnJson.put("data", data);
@@ -379,21 +394,34 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
     @Override
     public JSONObject getOrderData(Long userId, String startDate, String endDate, String type) {
+        String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
+        List<Long> userList = null;
+        if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
+            Long deptId = deptService.getDeptIdByUserId(userId);
+            userList = deptService.getDeptUserListByDeptId(deptId);
+        } else {
+            userList = Arrays.asList(userId);
+        }
+
         JSONObject returnJson = new JSONObject();
         returnJson.put("code", 0);
         returnJson.put("message", "调用成功");
         if ("1".equals(type)) {
-            returnJson.put("data", getgetOrderDataByChannel(userId, startDate, endDate));
+            returnJson.put("data", getgetOrderDataByChannel(userList, startDate, endDate));
         } else {
-            returnJson.put("data", getgetOrderDataByAttractInvestment(userId, startDate, endDate));
+            if ("supplyChainAdmin".equals(roleKey)) {
+                //供应链管理员查看 招商人员数据
+                userList = deptService.getDeptUserListByDeptId(150200L);
+            }
+            returnJson.put("data", getgetOrderDataByAttractInvestment(userList, startDate, endDate));
         }
         return returnJson;
     }
 
     //渠道数据
-    private JSONObject getgetOrderDataByChannel(Long userId, String startDate, String endDate) {
+    private JSONObject getgetOrderDataByChannel(List<Long> userList, String startDate, String endDate) {
         JSONObject data = new JSONObject();
-        List<Long> promoterIds = promoterService.selectPromoterIdList(userId);
+        List<Long> promoterIds = promoterService.selectPromoterIdList(userList);
         if (Check.isNotNull(promoterIds)) {
             data.put("promoterCount", promoterIds.size());//达人总数
             JSONObject Sample = kuaishouItemCollectSamplesMapper.queryTheNumberOfCompletedJobs(promoterIds, startDate, endDate);
@@ -449,14 +477,14 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
 
     //招商数据
-    private JSONObject getgetOrderDataByAttractInvestment(Long userId, String startDate, String endDate) {
+    private JSONObject getgetOrderDataByAttractInvestment(List<Long> userList, String startDate, String endDate) {
         JSONObject data = new JSONObject();
         List<Long> promoterIds = promoterService.selectPromoterIdList(null);
         if (Check.isNotNull(promoterIds)) {
             data.put("promoterCount", promoterIds.size());//达人总数
         }
         //查询登录人(创建人)的所有商品
-        List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userId);
+        List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userList);
         if (Check.isNotNull(itemIds)) {
             JSONObject order = supplyChainService.selectOrderInfoByItemIds(itemIds, startDate, endDate);
             data.put("sendCount", order.getInteger("sendCount"));//发货数
@@ -511,21 +539,40 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
     @Override
     public JSONObject getDataAnalysis(Long userId, String type) {
+        String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
+        List<Long> userList = null;
+        if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
+            Long deptId = deptService.getDeptIdByUserId(userId);
+            userList = deptService.getDeptUserListByDeptId(deptId);
+        } else {
+            userList = Arrays.asList(userId);
+        }
+
         JSONObject returnJson = new JSONObject();
         returnJson.put("code", 0);
         returnJson.put("message", "调用成功");
         if ("1".equals(type)) {
-            returnJson.put("data", getDataAnalysisByChannel(userId));
+            returnJson.put("data", getDataAnalysisByChannel(userList));
         } else {
-            returnJson.put("data", getDataAnalysisByAttractInvestment(userId));
+            if ("supplyChainAdmin".equals(roleKey)) {
+                //供应链管理员查看 招商人员数据
+                userList = deptService.getDeptUserListByDeptId(150200L);
+            }
+            returnJson.put("data", getDataAnalysisByAttractInvestment(userList));
         }
         return returnJson;
     }
 
+    @Override
+    public List<JSONObject> queryProductList(Map<String, Object> map) {
+        PageUtils.startPage();
+        return kuaishouItemCollectSamplesMapper.queryProductList(map);
+    }
+
     // 渠道—数据分析
-    private JSONObject getDataAnalysisByChannel(Long userId) {
+    private JSONObject getDataAnalysisByChannel(List<Long> userList) {
         JSONObject data = new JSONObject();
-        List<Long> promoterIds = promoterService.selectPromoterIdList(userId);
+        List<Long> promoterIds = promoterService.selectPromoterIdList(userList);
         if (Check.isNotNull(promoterIds)) {
             //当天
             String end = DateUtils.getNowDateStr();
@@ -534,7 +581,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             Map<String, Object> map = new HashMap<>();
             map.put("start", start);
             map.put("end", end);
-            map.put("userId", userId);
+            map.put("userId", userList);
             map.put("promoterIds", promoterIds);
             map.put("startLong", DateUtils.getStartLongTime(start));
             map.put("endLong", DateUtils.getEndLongTime(end));
@@ -569,7 +616,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
                 data.put("orderAmountRate", amount.getString("orderAmountRate"));
                 data.put("totalRegimentalSettleAmountRate", amount.getString("totalRegimentalSettleAmountRate"));
             }
-            JSONObject promoter = promoterService.getgetMonthPromoterTotal(userId, start, end);
+            JSONObject promoter = promoterService.getgetMonthPromoterTotal(userList, start, end);
             if (Check.isNotNull(promoter)) {
                 data.put("promoterCount", promoter.getString("count"));
                 data.put("promoterRate", promoter.getString("rate"));
@@ -579,10 +626,10 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
     }
 
     // 招商—数据分析
-    private JSONObject getDataAnalysisByAttractInvestment(Long userId) {
+    private JSONObject getDataAnalysisByAttractInvestment(List<Long> userList) {
         JSONObject data = new JSONObject();
         //查询登录人(创建人)的所有商品
-        List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userId);
+        List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userList);
         if (Check.isNotNull(itemIds)) {
             //当天
             String end = DateUtils.getNowDateStr();
@@ -591,7 +638,6 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             Map<String, Object> map = new HashMap<>();
             map.put("start", start);
             map.put("end", end);
-            map.put("userId", userId);
             map.put("itemIds", itemIds);
             map.put("startLong", DateUtils.getStartLongTime(start));
             map.put("toStartLong", DateUtils.getStartLongTime(end));

+ 4 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -267,12 +267,12 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     }
 
     @Override
-    public List<Long> selectPromoterIdList(Long userId) {
-        return kuaishouPromoterMapper.selectPromoterIdList(userId);
+    public List<Long> selectPromoterIdList(List<Long> userList) {
+        return kuaishouPromoterMapper.selectPromoterIdList(userList);
     }
 
     @Override
-    public JSONObject getgetMonthPromoterTotal(Long userId, String start, String end) {
-        return kuaishouPromoterMapper.getgetMonthPromoterTotal(userId, start, end);
+    public JSONObject getgetMonthPromoterTotal(List<Long> userList, String start, String end) {
+        return kuaishouPromoterMapper.getgetMonthPromoterTotal(userList, start, end);
     }
 }

+ 60 - 6
ruixuan-live/src/main/resources/mapper/isc/KuaishouItemCollectSamplesMapper.xml

@@ -481,14 +481,22 @@
 
 
     <select id="getSampleCountByUserId" resultType="java.lang.Integer">
-        select IFNULL(SUM(sample_count), 0) as 'sampleCount'
+        select count(1) as 'sampleCount'
         from kuaishou_item_collect_samples
         where collect_sample_status = #{status}
-        <if test="collectSampleId != null and collectSampleId != ''">
-            AND collect_sample_id = #{collectSampleId}
+        <if test="userType == 1">
+            AND collect_sample_id in
+            <foreach collection="userList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
-        <if test="itemCreateId != null and itemCreateId != ''">
-            AND item_create_id = #{itemCreateId}
+        <if test="userType == 2">
+            AND item_create_id in
+            <foreach collection="userList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
     </select>
 
@@ -534,7 +542,53 @@
     <select id="getItemIdsByCreateId" resultType="Long">
         select item_id
         from kuaishou_item_collect_samples
-        where item_create_id = #{itemCreateId}
+        where item_create_id in
+        <foreach collection="userList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="queryProductList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT * from (SELECT
+        promoter_id as 'promoterId',
+        promoter_nick_name as 'promoterNickName',
+        item_id as 'itemId',
+        item_title as 'itemTitle',
+        reserve_price as 'reservePrice',
+        SUM(order_amount) as 'orderAmount',
+        COUNT(case WHEN order_status!=80 then 1 ELSE null END) as 'validorder',
+        regimental_promotion_amount as 'regimentalPromotionAmount'
+        FROM kuaishou_supply_chain
+        <where>
+            <if test="startDate != null and EndDate != null">
+                AND stat_date >= #{startDate}
+                AND stat_date &lt;= #{EndDate}
+            </if>
+            <if test="itemId != null and itemId != ''">
+                AND item_id = #{itemId}
+            </if>
+            <if test="itemTitle != null and itemTitle != ''">
+                AND item_title LIKE CONCAT('%', #{itemTitle}, '%')
+            </if>
+            <if test="promoterNickName != null and promoterNickName != ''">
+                AND promoter_nick_name LIKE CONCAT('%', #{promoterNickName}, '%')
+            </if>
+            <if test="promoterId != null and promoterId != ''">
+                AND promoter_id = #{promoterId}
+            </if>
+            <if test="reservePriceStart != null and reservePriceEnd != null">
+                AND reserve_price >= #{reservePriceStart}
+                AND reserve_price &lt;= #{reservePriceEnd}
+            </if>
+        </where>
+        GROUP BY item_id
+        )t
+        where 1=1
+        <if test="validorderStart != null and validorderEnd != null">
+            AND validorder >= #{validorderStart}
+            AND validorder &lt;= #{validorderEnd}
+        </if>
     </select>
 
 

+ 28 - 13
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -73,8 +73,12 @@
         select promoter_id
         from kuaishou_promoter
         <where>
-            <if test="userId != null ">
-                AND user_id = #{userId}
+            <if test="userList != null ">
+                AND user_id in
+                <foreach collection="userList" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
             </if>
         </where>
     </select>
@@ -91,17 +95,28 @@
 
     <select id="getgetMonthPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.count,
-               CONCAT(ROUND(t2.count / t1.count * 100, 2), '%') as 'rate'
-        FROM (SELECT count(promoter_id) as 'count'
-              FROM kuaishou_promoter
-              WHERE user_id = #{userId}
-                AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
-                AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}) t1
-                 LEFT JOIN
-             (SELECT count(promoter_id) as 'count'
-              FROM kuaishou_promoter
-              WHERE user_id = #{userId}
-                AND DATE_FORMAT(create_time, '%Y-%m-%d') = #{end}) t2 ON 1 = 1
+        CONCAT(ROUND(t2.count / t1.count * 100, 2), '%') as 'rate'
+        FROM
+        (
+        SELECT count(promoter_id) as 'count'
+        FROM kuaishou_promoter
+        WHERE user_id in
+        <foreach collection="userList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
+        AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
+        ) t1
+        LEFT JOIN
+        (SELECT count(promoter_id) as 'count'
+        FROM kuaishou_promoter
+        WHERE user_id in
+        <foreach collection="userList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        AND DATE_FORMAT(create_time, '%Y-%m-%d') = #{end}) t2 ON 1 = 1
     </select>