Kaynağa Gözat

骄阳盯盘

yumeng 1 yıl önce
ebeveyn
işleme
99aaabd665

+ 614 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/controller/JiaoYangDingPanController.java

@@ -0,0 +1,614 @@
+package com.ruixuan.jiaoyang.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.core.controller.BaseController;
+import com.ruixuan.common.core.page.TableDataInfo;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.jiaoyang.service.IJiaoYangDingPanService;
+import com.ruixuan.system.service.ISysDeptService;
+import com.ruixuan.system.service.ISysRoleService;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static com.ruixuan.common.utils.PageUtils.startPage;
+
+@RestController
+@RequestMapping("/jy/dingpan")
+public class JiaoYangDingPanController extends BaseController {
+    @Autowired
+    private IJiaoYangDingPanService jiaoYangDingPanService;
+    @Autowired
+    private ISysRoleService sysRoleService;
+
+    @Autowired
+    private ISysDeptService sysDeptService;
+
+    @GetMapping("/getSumInfo")
+    @ApiOperation(value = "切片盯盘-汇总数据")
+    public JSONObject getSumInfo(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            JSONObject date = jiaoYangDingPanService.getSumInfo(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", date);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getMonthInfo")
+    @ApiOperation(value = "切片盯盘-当月数据数据")
+    public JSONObject getMonthInfo(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String monthEndDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String monthStartDay = DateUtils.getMonthStartDay(monthEndDate);
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long monthStart = DateUtils.strDateToInt(monthStartDay);
+            Long monthEnd = DateUtils.strDateToInt(monthEndDate);
+            requestMap.put("monthStart", monthStart);
+            requestMap.put("monthEnd", monthEnd);
+            String lastMonthFirstDate = DateUtils.getLastMonthFirstDayByDate(monthEndDate);// 上个月开始时间
+            String lastMonthEndDate = DateUtils.getLastMonthNowDay(monthEndDate);// 上个月结束时间
+            requestMap.put("lastMonthStart", DateUtils.strDateToInt(lastMonthFirstDate));
+            requestMap.put("lastMonthEnd", DateUtils.strDateToInt(lastMonthEndDate));
+            JSONObject monthDate = jiaoYangDingPanService.getMonthInfo(requestMap);
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) { // 如果传入时间为当天,取当前月的数据
+                requestMap.put("echartStart", monthStart);
+                requestMap.put("echartEnd", monthEnd);
+            } else {
+                requestMap.put("echartStart", start);
+                requestMap.put("echartEnd", end);
+            }
+            List<JSONObject> list = jiaoYangDingPanService.getEchartData(requestMap);
+            monthDate.put("list", list);
+            returnJson.put("code", 200);
+            returnJson.put("data", monthDate);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getGmvHours")
+    @ApiOperation(value = "切片盯盘-当月数据数据")
+    public JSONObject getGmvHours(Long userId) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            requestMap.put("date", DateUtils.strDateToInt(nowDate));
+            List<JSONObject> today = jiaoYangDingPanService.getGmvHours(requestMap);
+            String lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);  //  日期 -1
+            requestMap.put("date", DateUtils.strDateToInt(lastDate));
+            List<JSONObject> yesterday = jiaoYangDingPanService.getGmvHours(requestMap);
+            JSONObject data = new JSONObject();
+            data.put("today", today);
+            data.put("yesterday", yesterday);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 分团队数据
+     *
+     * @param userId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @GetMapping("/getTeamList")
+    @ApiOperation(value = "切片盯盘-分团队数据")
+    public JSONObject getTeamList(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            List<JSONObject> data = jiaoYangDingPanService.getTeamList(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 新增商品
+     *
+     * @param deptId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @GetMapping("/getAddItemList")
+    @ApiOperation(value = "切片盯盘-新增商品")
+    public JSONObject getAddItemList(Long deptId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(deptId)) {
+                throw new Exception("请传入部门id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            requestMap.put("deptId", deptId);
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            List<JSONObject> data = jiaoYangDingPanService.getAddItemList(requestMap);
+            returnJson.put("data", data);
+            returnJson.put("code", 200);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("success", false);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 分成员数据
+     *
+     * @param userId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @GetMapping("/getPeopleList")
+    @ApiOperation(value = "切片盯盘-成员数据")
+    public JSONObject getPeopleList(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            List<JSONObject> data = jiaoYangDingPanService.getPeopleList(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getAddItemListByUserId")
+    @ApiOperation(value = "切片盯盘-新增商品")
+    public JSONObject getAddItemListByUserId(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            requestMap.put("userId", userId);
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            List<JSONObject> data = jiaoYangDingPanService.getAddItemListByUserId(requestMap);
+            returnJson.put("data", data);
+            returnJson.put("code", 200);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("success", false);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    // 分达人数据
+    @GetMapping("/getPromoterList")
+    @ApiOperation(value = "切片盯盘-成员数据")
+    public JSONObject getPromoterList(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            List<JSONObject> data = jiaoYangDingPanService.getPromoterList(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+
+    @GetMapping("/getDingPanItemList")
+    @ApiOperation(value = "切片盯盘")
+    public JSONObject getItemList(Long userId, String startDate, String endDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户id");
+            }
+            if (Check.isNull(startDate)) {
+                throw new Exception("请传入开始日期");
+            }
+            if (Check.isNull(endDate)) {
+                throw new Exception("请传入结束日期");
+            }
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            // 剪手经理,渠道经理 查询部门下所有成员数据
+            List<Long> promoterIds = new ArrayList<>();
+            if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
+                List<Long> userIds = new ArrayList<>();
+                if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
+                    Long deptId = sysDeptService.getDeptIdByUserId(userId);
+                    userIds = sysDeptService.getDeptUserListByDeptId(deptId);
+                } else {
+                    userIds.add(userId);
+                }
+                promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
+            } else if ("jy_expert_business".equals(roleId) || "jy_expert_mentor".equals(roleId)) {
+                if ("jy_expert_business".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
+                }
+                if ("jy_expert_mentor".equals(roleId)) {
+                    promoterIds = jiaoYangDingPanService.getPromoterIdsByMentorId(userId);
+                }
+            }
+            if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId)) {
+                if (Check.isNull(promoterIds)) {
+                    throw new Exception("该用户下未查询到绑定达人");
+                }
+            }
+            if (!Check.isNull(promoterIds)) {
+                requestMap.put("promoterIds", promoterIds);
+            }
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            List<JSONObject> data = jiaoYangDingPanService.getItemList(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+}

+ 34 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/mapper/IJiaoYangDingMapper.java

@@ -0,0 +1,34 @@
+package com.ruixuan.jiaoyang.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IJiaoYangDingMapper {
+    List<Long> getPromoterIdsByUserIds();
+
+    List<Long> getPromoterIdsByBusinessId(Long userId);
+
+    List<Long> getPromoterIdsByMentorId(Long userId);
+
+    JSONObject getSumInfo(Map<String, Object> requestMap);
+
+    JSONObject getMonthInfo(Map<String, Object> requestMap);
+
+    List<JSONObject> getEchartData(Map<String, Object> requestMap);
+
+    List<JSONObject> getGmvHours(Map<String, Object> requestMap);
+
+    List<JSONObject> getTeamList(Map<String, Object> requestMap);
+
+    List<JSONObject> getAddItemList(Map<String, Object> requestMap);
+
+    List<JSONObject> getPeopleList(Map<String, Object> requestMap);
+
+    List<JSONObject> getAddItemListByUserId(Map<String, Object> requestMap);
+
+    List<JSONObject> getPromoterList(Map<String, Object> requestMap);
+
+    List<JSONObject> getItemList(Map<String, Object> requestMap);
+}

+ 34 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/IJiaoYangDingPanService.java

@@ -0,0 +1,34 @@
+package com.ruixuan.jiaoyang.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IJiaoYangDingPanService {
+    List<Long> getPromoterIdsByUserIds(List<Long> userIds);
+
+    List<Long> getPromoterIdsByBusinessId(Long userId);
+
+    List<Long> getPromoterIdsByMentorId(Long userId);
+
+    JSONObject getSumInfo(Map<String, Object> requestMap);
+
+    JSONObject getMonthInfo(Map<String, Object> requestMap);
+
+    List<JSONObject> getEchartData(Map<String, Object> requestMap);
+
+    List<JSONObject> getGmvHours(Map<String, Object> requestMap);
+
+    List<JSONObject> getTeamList(Map<String, Object> requestMap);
+
+    List<JSONObject> getAddItemList(Map<String, Object> requestMap);
+
+    List<JSONObject> getPeopleList(Map<String, Object> requestMap);
+
+    List<JSONObject> getAddItemListByUserId(Map<String, Object> requestMap);
+
+    List<JSONObject> getPromoterList(Map<String, Object> requestMap);
+
+    List<JSONObject> getItemList(Map<String, Object> requestMap);
+}

+ 81 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/impl/JiaoYangDingPanServiceImpl.java

@@ -0,0 +1,81 @@
+package com.ruixuan.jiaoyang.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.jiaoyang.mapper.IJiaoYangDingMapper;
+import com.ruixuan.jiaoyang.service.IJiaoYangDingPanService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class JiaoYangDingPanServiceImpl implements IJiaoYangDingPanService {
+    @Autowired
+    private IJiaoYangDingMapper jiaoYangDingMapper;
+
+    @Override
+    public List<Long> getPromoterIdsByUserIds(List<Long> userIds) {
+        return jiaoYangDingMapper.getPromoterIdsByUserIds();
+    }
+
+    @Override
+    public List<Long> getPromoterIdsByBusinessId(Long userId) {
+        return jiaoYangDingMapper.getPromoterIdsByBusinessId(userId);
+    }
+
+    @Override
+    public List<Long> getPromoterIdsByMentorId(Long userId) {
+        return jiaoYangDingMapper.getPromoterIdsByMentorId(userId);
+    }
+
+    @Override
+    public JSONObject getSumInfo(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getSumInfo(requestMap);
+    }
+
+    @Override
+    public JSONObject getMonthInfo(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getMonthInfo(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getEchartData(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getEchartData(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getGmvHours(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getGmvHours(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getTeamList(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getTeamList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getAddItemList(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getAddItemList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getPeopleList(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getPeopleList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getAddItemListByUserId(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getAddItemListByUserId(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getPromoterList(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getPromoterList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getItemList(Map<String, Object> requestMap) {
+        return jiaoYangDingMapper.getItemList(requestMap);
+    }
+}

+ 555 - 0
ruixuan-live/src/main/resources/mapper/jiaoyang/JiaoYangDingPanMapper.xml

@@ -0,0 +1,555 @@
+<?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.ruixuan.jiaoyang.mapper.IJiaoYangDingMapper">
+
+
+    <select id="getPromoterIdsByUserIds" resultType="java.lang.Long">
+        select promoter_id from jy_kuaishou_promoter where
+        1 = 1
+        and user_id in
+        <foreach collection="userIds" item="userId" separator="," open="(" close=")">
+            #{userId}
+        </foreach>
+        group by promoter_id
+    </select>
+    <select id="getPromoterIdsByBusinessId" resultType="java.lang.Long" parameterType="java.lang.Long">
+        SELECT promoter_id
+        FROM jy_kuaishou_promoter
+        WHERE expert_business_id = #{userId}
+        GROUP BY promoter_id
+    </select>
+    <select id="getPromoterIdsByMentorId" resultType="java.lang.Long" parameterType="java.lang.Long">
+        SELECT promoter_id
+        FROM jy_kuaishou_promoter
+        WHERE expert_mentor_id = #{userId}
+        GROUP BY promoter_id
+    </select>
+    <select id="getSumInfo" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
+        round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate',
+        round((t.regimentalPromotionAmount - tt.regimentalPromotionAmount) / tt.regimentalPromotionAmount *100,2) as
+        'regimentalPromotionAmountRate',
+        round((t.grossMargin - tt.grossMargin) / tt.grossMargin * 100, 2) as 'grossMarginRate'
+        from (
+        select count(t1.oid) as 'orderNum',
+        sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
+        sum(case when t2.type = 1 then 1 else 0 end) as 'zyOrderNUm',
+        sum(case when t2.type = 2 then
+        1 else 0 end) as 'fxOrderNUm',
+        round(sum(t1.pay_amount) / 100, 2) as 'payAmount',
+        round(sum(case when order_status
+        != 80 then t1.pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) /
+        sum(t1.pay_amount) * 100,
+        2) as 'validPayAmountRadio',
+        round(sum(case when t2.type = 1 then t1.pay_amount else 0 end) / 1000000, 2) as 'zyPayAmount',
+        round(sum(case when t2.type = 2 then t1.pay_amount else 0 end) / 1000000, 2) as 'fxPayAmount',
+        sum(case when
+        t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when t1.send_status = 1 and
+        t1.order_status != 80 then 1 else 0 end) /
+        sum(case
+        when order_status != 80
+        then 1
+        else 0 end) *
+        100,
+        2) as 'deliveryRadio',
+        count(distinct t1.clip_user_id) as 'promoterCount',
+        count( distinct t3.promoter_id ) as 'addPromoterCount',
+        count(distinct t1.item_id) as 'itemCount',
+        count(distinct t4.item_id) as 'addItemCount',
+        round(sum(case when t1.order_status != 80 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
+        'regimentalPromotionAmount',
+        round(sum(case when t1.order_status != 80 and t2.type = 1 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
+        'zyRegimentalPromotionAmount',
+        round(sum(case when t1.order_status != 80 and t2.type = 2 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
+        'fxRegimentalPromotionAmount',
+        round(sum(t1.mcn_promotion_amount) / sum(t1.pay_amount) * 100, 2) as 'grossMargin',
+        round(sum(case when t2.type = 1 then t1.mcn_promotion_amount else 0 end) / sum(case when t2.type = 1 then
+        t1.pay_amount else 0 end) * 100, 2) as 'zyGrossMargin',
+        round(sum(case when t2.type = 2 then t1.mcn_promotion_amount else 0 end) /
+        sum(case when t2.type = 2 then t1.pay_amount else 0 end) * 100, 2) as 'fxGrossMargin'
+        from jy_order_list t1
+        left join jy_kuaishou_promoter t2
+        on t1.clip_user_id = t2.promoter_id
+        left join (select *
+        from jy_promoter_frist_order_date
+        where frist_order_time &gt;= #{start}
+        and frist_order_time &lt;= #{end}) t3 on t1.clip_user_id = t3.promoter_id
+        left join (select *
+        from jy_order_item_list
+        where first_order_time &gt;=#{start}
+        and first_order_time &lt;= #{end}) t4
+        on t1.item_id = t4.item_id
+        where t1.stat_date &gt;= #{start}
+        and t1.stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND t1.clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t
+        join (select count(oid) as 'orderNum', round(sum(pay_amount) / 100, 2) as 'payAmount', round(sum(case when
+        order_status != 80 then mcn_promotion_amount else 0 end) / 100,
+        2) as 'regimentalPromotionAmount', round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
+        from jy_order_list
+        where stat_date &gt;= #{lastStart}
+        and stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+           and  stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) tt
+    </select>
+    <select id="getMonthInfo" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.*,
+        round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate',
+        round((t1.payAmount - t2.payAmount) / t2.payAmount * 100, 2) as 'payAmountRate'
+        from (select count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
+        2) as 'validRadio',
+        round(sum(pay_amount) / 100, 2) as 'payAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
+        2) as 'validPayAmountRadio',
+        count(distinct clip_user_id) as 'promoterCount',
+        count(distinct item_id) as 'itemCount',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum'
+        from jy_order_list
+        where stat_date &gt;= #{monthStart}
+        and stat_date &lt;= #{monthEnd}
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t1
+
+        join (
+        select count(oid) as 'orderNum',
+        round(sum(pay_amount) / 100, 2) as 'payAmount'
+        from jy_order_list
+        where stat_date &gt;= #{lastMonthStart}
+        and stat_date &lt;= #{lastMonthEnd}
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t2
+    </select>
+    <select id="getEchartData" resultType="com.alibaba.fastjson.JSONObject">
+        select date_format(stat_date,'%m-%d') as 'date',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        count(distinct clip_user_id) as 'promoterCount',
+        count(distinct item_id) as 'itemCount'
+        from jy_order_list
+        where stat_date &gt;= #{echartStart}
+        and stat_date &lt;= #{echartEnd}
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by stat_date
+        order by stat_date asc
+    </select>
+    <select id="getGmvHours" resultType="com.alibaba.fastjson.JSONObject">
+        select stat_hour as 'time', round(sum(order_amount) / 100, 2) as 'charge'
+        from jy_order_list
+        where stat_date = #{date}
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by stat_hour
+        order by stat_hour
+    </select>
+    <select id="getTeamList" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        (select user.nick_name
+        from sys_user user
+        left join sys_user_role userRole on user.user_id = userRole.user_id
+        left join sys_role role on userRole.role_id = role.role_id
+        where user.dept_id = t.deptId
+        and role.role_key in (
+        'jy_bd_manage', 'jy_scissors_manage', 'jy_out_operation_manager'
+        )
+        and user.status = 0
+        limit 1) as 'leaderName',
+
+        (select count(user.user_id)
+        from sys_user user
+        left join sys_user_role userRole on user.user_id = userRole.user_id
+        left join sys_role role on userRole.role_id = role.role_id
+        where user.dept_id = t.deptId
+        and role.role_key not in (
+        'jy_expert_business', 'jy_expert_mentor'
+        )
+        and user.status = 0) as 'teamMember',
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
+        round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
+
+        from (select t4.dept_id as 'deptId',
+        t4.dept_name as 'deptName',
+        count(t1.oid) as 'orderNum',
+        round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100,
+        2) as 'validRadio', -- 有效率
+
+        round(sum(pay_amount) / 100, 2) as 'payAmount', -- gmv
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
+        2) as 'validPayAmount', -- 有效gmv
+        round(sum(case when t1.order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
+        2) as 'validPayAmountRadio', -- gmv有效率
+        sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum', -- 未发货数
+        round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case
+        when order_status != 80
+        then 1
+        else 0 end) *
+        100,
+        2) as 'deliveryRadio', -- 发货率
+        count(distinct t1.clip_user_id) as 'promoterCount', -- 达人数
+        count(
+        distinct t5.promoter_id
+        ) as 'addPromoterCount', -- 新增达人数
+        count(distinct t1.item_id) as 'itemCount', -- 商品数
+        count(distinct t6.item_id) as 'addItemCount' -- 新增商品数
+        from jy_order_list t1
+        left join jy_kuaishou_promoter t2
+        on t1.clip_user_id = t2.promoter_id
+        left join sys_user t3 on t2.user_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        left join (select *
+        from jy_promoter_frist_order_date
+        where frist_order_time &gt;= #{start}
+        and frist_order_time &lt;= #{end}) t5 on t1.clip_user_id = t5.promoter_id
+        left join (select *
+        from jy_order_item_list
+        where first_order_time &gt;= #{start}
+        and first_order_time &lt;= #{end}) t6
+        on t1.item_id = t6.item_id
+        where t1.stat_date &gt;= #{start}
+        and t1.stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND t1.clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t4.dept_id) t
+        join (select t4.dept_id as 'deptId',
+        count(t1.oid) as 'orderNum',
+        round(sum(pay_amount) / 100, 2) as 'payAmount'
+        from jy_order_list t1
+        left join jy_kuaishou_promoter t2
+        on t1.clip_user_id = t2.promoter_id
+        left join sys_user t3 on t2.user_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        where t1.stat_date &gt;= #{lastStart}
+        and t1.stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND t1.clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t4.dept_id) tt on t.deptId = tt.deptId
+        order by t.orderNum desc
+
+    </select>
+    <select id="getAddItemList" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT t1.item_id AS 'itemId', t1.item_title AS 'itemTitle', t1.image_url AS 'image_url', round(t1.reserve_price / 100, 2) AS 'reserve_price', t1.first_order_time AS 'firstOrderTime'
+        FROM jy_order_item_list t1
+                 INNER JOIN (SELECT item_id
+                             FROM jy_order_list
+                             WHERE stat_date &gt;= #{start}
+                               AND stat_date &lt;= #{end}
+                               AND clip_user_id IN (SELECT promoter_id
+                                                    FROM jy_kuaishou_promoter
+                                                    WHERE user_id IN (SELECT user_id
+                                                                      FROM sys_user
+                                                                      WHERE dept_id = #{deptId})
+                                                    GROUP BY promoter_id)
+                             GROUP BY item_id) t2 ON t1.item_id = t2.item_id
+        WHERE t1.first_order_time &gt;= #{start}
+          AND t1.first_order_time &lt;= #{end}
+
+    </select>
+    <select id="getPeopleList" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
+        round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
+        from (select t2.user_id as 'userId',
+        t2.user_name as 'userName',
+        (select deap.dept_name
+        from sys_user user
+        left join sys_dept deap on user.dept_id = deap.dept_id
+        where user.user_id = t2.user_id) as 'deapName',
+        (select user.nick_name
+        from sys_user user
+        left join sys_user_role userrole on user.user_id
+        = userrole.user_id
+        left join sys_role role on userrole.role_id = role.role_id
+        where user.dept_id = (select dept_id from sys_user where user_id = t2.user_id limit 1)
+        and role.role_key in (
+        'jy_bd_manage', 'jy_scissors_manage', 'jy_out_operation_manager'
+        )
+        and user.status = 0
+        limit 1) as 'leaderName',
+        count(t1.oid) as 'orderNum',
+        round(
+        sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100,
+        2) as 'validRadio',
+        round(sum(pay_amount) / 100, 2) as 'payAmount',
+        round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) / sum(t1.pay_amount) * 100,
+        2) as 'validPayAmountRadio',
+        sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case
+        when t1.order_status != 80
+        then 1
+        else 0 end) *
+        100,
+        2) as 'deliveryRadio',
+        count(distinct t1.clip_user_id) as 'promoterCount',
+        count(
+        distinct t3.promoter_id
+        ) as 'addPromoterCount',
+        count(distinct t1.item_id) as 'itemCount',
+        count(distinct t4.item_id) as 'addItemCount'
+        from jy_order_list t1
+        left join jy_kuaishou_promoter t2
+        on t1.clip_user_id = t2.promoter_id
+        left join (select *
+        from jy_promoter_frist_order_date
+        where frist_order_time &gt;= #{start}
+        and frist_order_time &lt;= #{end}) t3 on t1.clip_user_id = t3.promoter_id
+        left join (select *
+        from jy_order_item_list
+        where first_order_time &gt;= #{start}
+        and first_order_time &lt;= #{end}) t4
+        on t1.item_id = t4.item_id
+        where t1.stat_date &gt;= #{start}
+        and t1.stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND t1.clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t2.user_id) t
+        left join (select t2.user_id as 'userId',
+        count(t1.oid) as 'orderNum',
+        round(sum(pay_amount) / 100, 2) as 'payAmount'
+        from jy_order_list t1
+        left join jy_kuaishou_promoter t2
+        on t1.clip_user_id = t2.promoter_id
+        where t1.stat_date &gt;= #{lastStart}
+        and t1.stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND t1.clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        group by t2.user_id) tt on t.userId = tt.userId
+        order by t.orderNum desc
+    </select>
+    <select id="getAddItemListByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.item_id AS 'itemId', t1.item_title AS 'itemTitle', t1.image_url AS 'image_url', round(t1.reserve_price / 100, 2) AS 'reserve_price', t1.first_order_time AS 'firstOrderTime'
+        FROM jy_order_item_list t1
+                 INNER JOIN (SELECT item_id
+                             FROM jy_order_list
+                             WHERE stat_date &gt;= #{start}
+                               AND stat_date &lt;= #{end}
+                               AND clip_user_id IN (SELECT promoter_id
+                                                    FROM jy_kuaishou_promoter
+                                                    WHERE user_id = #{userId}
+                                                    GROUP BY promoter_id)
+                             GROUP BY item_id) t2 ON t1.item_id = t2.item_id
+        WHERE t1.first_order_time &gt;= #{start}
+          AND t1.first_order_time &lt;= #{end}
+    </select>
+    <select id="getPromoterList" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.*,
+        t2.user_name as 'userName',
+        (case
+        when t2.type = 1 then '自营'
+        when t2.type = 2 then '分销'
+        else '-'
+        end
+        ) as 'promoterType',
+        t2.promoter_url as 'promoterUrl',
+        t3.videoCount as 'videoCount',
+        round((t1.orderNum - t4.orderNum) / t4.orderNum * 100, 2) as 'orderNumRate',
+        round((t1.payAmount - t4.payAmount) / t4.payAmount * 100, 2) as 'payAmountRate'
+        from (select clip_user_id as 'clipUserId',
+        clip_nick_name as 'clipNickName',
+        count(oid) as 'orderNum',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
+        2) as 'validRadio',
+
+        round(sum(pay_amount) / 100, 2) as 'payAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
+        2) as 'validPayAmountRadio',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
+        when order_status != 80
+        then 1
+        else 0 end) *
+        100,
+        2) as 'deliveryRadio',
+        count(distinct item_id) as 'itemCount'
+        from jy_order_list
+        where stat_date &gt;= #{start}
+        and stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by clip_user_id) t1
+        left join jy_kuaishou_promoter t2
+        on t1.clipUserId = t2.promoter_id
+        left join (select promoter_id as 'promoterId', count(photo_id) as 'videoCount'
+        from kuaishou_open_photo_list
+        where photo_create_time &gt;= #{start}
+        and photo_create_time &lt;= #{end}
+        group by promoter_id) t3 on t1.clipUserId = t3.promoterId
+        join (select clip_user_id as 'clipUserId',
+        count(oid) as 'orderNum',
+        round(sum(pay_amount) / 100, 2) as 'payAmount'
+        from jy_order_list
+        where stat_date &gt;= #{lastStart}
+        and stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+            and stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by clip_user_id) t4 on t1.clipUserId = t4.clipUserId
+        order by t1.orderNum desc
+    </select>
+    <select id="getItemList" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.*,
+        round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate',
+        round((t1.payAmount - t2.payAmount) / t2.payAmount * 100, 2) as 'payAmountRate'
+        from (select item_id as 'itemId',
+        item_title as 'itemTitle',
+        image_url as 'imageUrl',
+        count(oid) as 'orderNum',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
+        2) as 'validRadio',
+        round(sum(pay_amount) / 100, 2) as 'payAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
+        2) as 'validPayAmount',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
+        2) as 'validPayAmountRadio',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
+        when order_status != 80
+        then 1
+        else 0 end) *
+        100,
+        2) as 'deliveryRadio',
+        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin',
+        count(distinct clip_user_id) as 'promoterCount'
+        from jy_order_list
+        where stat_date &gt;= #{start}
+        and stat_date &lt;= #{end}
+        <if test="nowHour != null and nowHour != ''">
+            and stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by item_id) t1
+         join (select item_id as 'itemId',
+        image_url as 'imageUrl',
+        count(oid) as 'orderNum',
+        round(sum(pay_amount) / 100, 2) as 'payAmount'
+        from jy_order_list
+        where stat_date &gt;= #{lastStart}
+        and stat_date &lt;= #{lastEnd}
+        <if test="nowHour != null and nowHour != ''">
+            and stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND clip_user_id in
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by item_id
+        ) t2 on t1.itemId = t2.itemId
+        order by t1.orderNum desc
+    </select>
+</mapper>