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