JiaoYangDingPanController.java 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. package com.ruixuan.jiaoyang.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ruixuan.common.core.controller.BaseController;
  4. import com.ruixuan.common.core.page.TableDataInfo;
  5. import com.ruixuan.common.utils.Check;
  6. import com.ruixuan.common.utils.DateUtils;
  7. import com.ruixuan.jiaoyang.service.IJiaoYangDingPanService;
  8. import com.ruixuan.system.service.ISysDeptService;
  9. import com.ruixuan.system.service.ISysRoleService;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import java.text.ParseException;
  18. import java.text.SimpleDateFormat;
  19. import java.util.*;
  20. import static com.ruixuan.common.utils.PageUtils.startPage;
  21. @RestController
  22. @RequestMapping("/jy/dingpan")
  23. public class JiaoYangDingPanController extends BaseController {
  24. @Autowired
  25. private IJiaoYangDingPanService jiaoYangDingPanService;
  26. @Autowired
  27. private ISysRoleService sysRoleService;
  28. @Autowired
  29. private ISysDeptService sysDeptService;
  30. @GetMapping("/getSumInfo")
  31. @ApiOperation(value = "切片盯盘-汇总数据")
  32. public JSONObject getSumInfo(Long userId, String startDate, String endDate) {
  33. Map<String, Object> requestMap = new HashMap<>();
  34. JSONObject returnJson = new JSONObject();
  35. try {
  36. if (Check.isNull(userId)) {
  37. throw new Exception("请传入用户id");
  38. }
  39. if (Check.isNull(startDate)) {
  40. throw new Exception("请传入开始日期");
  41. }
  42. if (Check.isNull(endDate)) {
  43. throw new Exception("请传入结束日期");
  44. }
  45. String roleId = sysRoleService.getRoleBYUserId(userId);
  46. // 剪手经理,渠道经理 查询部门下所有成员数据
  47. List<Long> promoterIds = new ArrayList<>();
  48. 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)) {
  49. List<Long> userIds = new ArrayList<>();
  50. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  51. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  52. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  53. } else {
  54. userIds.add(userId);
  55. }
  56. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  57. } else if ("jy_expert_business".equals(roleId)) {
  58. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  59. }
  60. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  61. if (Check.isNull(promoterIds)) {
  62. throw new Exception("该用户下未查询到绑定达人");
  63. }
  64. }
  65. if (!Check.isNull(promoterIds)) {
  66. requestMap.put("promoterIds", promoterIds);
  67. }
  68. Long start = DateUtils.strDateToInt(startDate);
  69. Long end = DateUtils.strDateToInt(endDate);
  70. requestMap.put("start", start);
  71. requestMap.put("end", end);
  72. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  73. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  74. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  75. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  76. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  77. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  78. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  79. if (start.equals(nowDate) && end.equals(nowDate)) {
  80. Integer nowHour = DateUtils.getNowHour();
  81. requestMap.put("nowHour", nowHour);
  82. }
  83. JSONObject date = jiaoYangDingPanService.getSumInfo(requestMap);
  84. returnJson.put("code", 200);
  85. returnJson.put("data", date);
  86. returnJson.put("success", true);
  87. } catch (Exception e) {
  88. e.printStackTrace();
  89. returnJson.put("code", 500);
  90. returnJson.put("message", e.getMessage());
  91. }
  92. return returnJson;
  93. }
  94. @GetMapping("/getMonthInfo")
  95. @ApiOperation(value = "切片盯盘-当月数据数据")
  96. public JSONObject getMonthInfo(Long userId, String startDate, String endDate) {
  97. Map<String, Object> requestMap = new HashMap<>();
  98. JSONObject returnJson = new JSONObject();
  99. try {
  100. if (Check.isNull(userId)) {
  101. throw new Exception("请传入用户id");
  102. }
  103. if (Check.isNull(startDate)) {
  104. throw new Exception("请传入开始日期");
  105. }
  106. if (Check.isNull(endDate)) {
  107. throw new Exception("请传入结束日期");
  108. }
  109. String monthEndDate = DateUtils.getNowDate("yyyy-MM-dd");
  110. String monthStartDay = DateUtils.getMonthStartDay(monthEndDate);
  111. String roleId = sysRoleService.getRoleBYUserId(userId);
  112. // 剪手经理,渠道经理 查询部门下所有成员数据
  113. List<Long> promoterIds = new ArrayList<>();
  114. 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)) {
  115. List<Long> userIds = new ArrayList<>();
  116. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  117. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  118. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  119. } else {
  120. userIds.add(userId);
  121. }
  122. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  123. } else if ("jy_expert_business".equals(roleId)) {
  124. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  125. }
  126. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  127. if (Check.isNull(promoterIds)) {
  128. throw new Exception("该用户下未查询到绑定达人");
  129. }
  130. }
  131. if (!Check.isNull(promoterIds)) {
  132. requestMap.put("promoterIds", promoterIds);
  133. }
  134. Long monthStart = DateUtils.strDateToInt(monthStartDay);
  135. Long monthEnd = DateUtils.strDateToInt(monthEndDate);
  136. requestMap.put("monthStart", monthStart);
  137. requestMap.put("monthEnd", monthEnd);
  138. String lastMonthFirstDate = DateUtils.getLastMonthFirstDayByDate(monthEndDate);// 上个月开始时间
  139. String lastMonthEndDate = DateUtils.getLastMonthNowDay(monthEndDate);// 上个月结束时间
  140. requestMap.put("lastMonthStart", DateUtils.strDateToInt(lastMonthFirstDate));
  141. requestMap.put("lastMonthEnd", DateUtils.strDateToInt(lastMonthEndDate));
  142. JSONObject monthDate = jiaoYangDingPanService.getMonthInfo(requestMap);
  143. Long start = DateUtils.strDateToInt(startDate);
  144. Long end = DateUtils.strDateToInt(endDate);
  145. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  146. if (start.equals(nowDate) && end.equals(nowDate)) { // 如果传入时间为当天,取当前月的数据
  147. requestMap.put("echartStart", monthStart);
  148. requestMap.put("echartEnd", monthEnd);
  149. } else {
  150. requestMap.put("echartStart", start);
  151. requestMap.put("echartEnd", end);
  152. }
  153. List<JSONObject> list = jiaoYangDingPanService.getEchartData(requestMap);
  154. monthDate.put("list", list);
  155. returnJson.put("code", 200);
  156. returnJson.put("data", monthDate);
  157. returnJson.put("success", true);
  158. } catch (Exception e) {
  159. e.printStackTrace();
  160. returnJson.put("code", 500);
  161. returnJson.put("message", e.getMessage());
  162. }
  163. return returnJson;
  164. }
  165. @GetMapping("/getGmvHours")
  166. @ApiOperation(value = "切片盯盘-当月数据数据")
  167. public JSONObject getGmvHours(Long userId) {
  168. Map<String, Object> requestMap = new HashMap<>();
  169. JSONObject returnJson = new JSONObject();
  170. try {
  171. if (Check.isNull(userId)) {
  172. throw new Exception("请传入用户id");
  173. }
  174. String roleId = sysRoleService.getRoleBYUserId(userId);
  175. // 剪手经理,渠道经理 查询部门下所有成员数据
  176. List<Long> promoterIds = new ArrayList<>();
  177. 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)) {
  178. List<Long> userIds = new ArrayList<>();
  179. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  180. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  181. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  182. } else {
  183. userIds.add(userId);
  184. }
  185. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  186. } else if ("jy_expert_business".equals(roleId)) {
  187. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  188. }
  189. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  190. if (Check.isNull(promoterIds)) {
  191. throw new Exception("该用户下未查询到绑定达人");
  192. }
  193. }
  194. if (!Check.isNull(promoterIds)) {
  195. requestMap.put("promoterIds", promoterIds);
  196. }
  197. String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
  198. requestMap.put("date", DateUtils.strDateToInt(nowDate));
  199. List<JSONObject> today = jiaoYangDingPanService.getGmvHours(requestMap);
  200. String lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 日期 -1
  201. requestMap.put("date", DateUtils.strDateToInt(lastDate));
  202. List<JSONObject> yesterday = jiaoYangDingPanService.getGmvHours(requestMap);
  203. JSONObject data = new JSONObject();
  204. data.put("today", today);
  205. data.put("yesterday", yesterday);
  206. returnJson.put("code", 200);
  207. returnJson.put("data", data);
  208. returnJson.put("success", true);
  209. } catch (Exception e) {
  210. e.printStackTrace();
  211. returnJson.put("code", 500);
  212. returnJson.put("message", e.getMessage());
  213. }
  214. return returnJson;
  215. }
  216. /**
  217. * 分团队数据
  218. *
  219. * @param userId
  220. * @param startDate
  221. * @param endDate
  222. * @return
  223. */
  224. @GetMapping("/getTeamList")
  225. @ApiOperation(value = "切片盯盘-分团队数据")
  226. public JSONObject getTeamList(Long userId, String startDate, String endDate) {
  227. Map<String, Object> requestMap = new HashMap<>();
  228. JSONObject returnJson = new JSONObject();
  229. try {
  230. if (Check.isNull(userId)) {
  231. throw new Exception("请传入用户id");
  232. }
  233. if (Check.isNull(startDate)) {
  234. throw new Exception("请传入开始日期");
  235. }
  236. if (Check.isNull(endDate)) {
  237. throw new Exception("请传入结束日期");
  238. }
  239. String roleId = sysRoleService.getRoleBYUserId(userId);
  240. // 剪手经理,渠道经理 查询部门下所有成员数据
  241. List<Long> promoterIds = new ArrayList<>();
  242. 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)) {
  243. List<Long> userIds = new ArrayList<>();
  244. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  245. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  246. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  247. } else {
  248. userIds.add(userId);
  249. }
  250. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  251. } else if ("jy_expert_business".equals(roleId)) {
  252. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  253. }
  254. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  255. if (Check.isNull(promoterIds)) {
  256. throw new Exception("该用户下未查询到绑定达人");
  257. }
  258. }
  259. if (!Check.isNull(promoterIds)) {
  260. requestMap.put("promoterIds", promoterIds);
  261. }
  262. Long start = DateUtils.strDateToInt(startDate);
  263. Long end = DateUtils.strDateToInt(endDate);
  264. requestMap.put("start", start);
  265. requestMap.put("end", end);
  266. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  267. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  268. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  269. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  270. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  271. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  272. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  273. if (start.equals(nowDate) && end.equals(nowDate)) {
  274. Integer nowHour = DateUtils.getNowHour();
  275. requestMap.put("nowHour", nowHour);
  276. }
  277. List<JSONObject> data = jiaoYangDingPanService.getTeamList(requestMap);
  278. returnJson.put("code", 200);
  279. returnJson.put("data", data);
  280. returnJson.put("success", true);
  281. } catch (Exception e) {
  282. e.printStackTrace();
  283. returnJson.put("code", 500);
  284. returnJson.put("message", e.getMessage());
  285. }
  286. return returnJson;
  287. }
  288. /**
  289. * 新增商品
  290. *
  291. * @param deptId
  292. * @param startDate
  293. * @param endDate
  294. * @return
  295. */
  296. @GetMapping("/getAddItemList")
  297. @ApiOperation(value = "切片盯盘-新增商品")
  298. public JSONObject getAddItemList(Long deptId, String startDate, String endDate) {
  299. Map<String, Object> requestMap = new HashMap<>();
  300. JSONObject returnJson = new JSONObject();
  301. try {
  302. if (Check.isNull(deptId)) {
  303. throw new Exception("请传入部门id");
  304. }
  305. if (Check.isNull(startDate)) {
  306. throw new Exception("请传入开始日期");
  307. }
  308. if (Check.isNull(endDate)) {
  309. throw new Exception("请传入结束日期");
  310. }
  311. requestMap.put("deptId", deptId);
  312. Long start = DateUtils.strDateToInt(startDate);
  313. Long end = DateUtils.strDateToInt(endDate);
  314. requestMap.put("start", start);
  315. requestMap.put("end", end);
  316. List<JSONObject> data = jiaoYangDingPanService.getAddItemList(requestMap);
  317. returnJson.put("data", data);
  318. returnJson.put("code", 200);
  319. returnJson.put("success", true);
  320. } catch (Exception e) {
  321. e.printStackTrace();
  322. returnJson.put("code", 500);
  323. returnJson.put("success", false);
  324. returnJson.put("message", e.getMessage());
  325. }
  326. return returnJson;
  327. }
  328. /**
  329. * 分成员数据
  330. *
  331. * @param userId
  332. * @param startDate
  333. * @param endDate
  334. * @return
  335. */
  336. @GetMapping("/getPeopleList")
  337. @ApiOperation(value = "切片盯盘-成员数据")
  338. public JSONObject getPeopleList(Long userId, String startDate, String endDate) {
  339. Map<String, Object> requestMap = new HashMap<>();
  340. JSONObject returnJson = new JSONObject();
  341. try {
  342. if (Check.isNull(userId)) {
  343. throw new Exception("请传入用户id");
  344. }
  345. if (Check.isNull(startDate)) {
  346. throw new Exception("请传入开始日期");
  347. }
  348. if (Check.isNull(endDate)) {
  349. throw new Exception("请传入结束日期");
  350. }
  351. String roleId = sysRoleService.getRoleBYUserId(userId);
  352. // 剪手经理,渠道经理 查询部门下所有成员数据
  353. List<Long> promoterIds = new ArrayList<>();
  354. 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)) {
  355. List<Long> userIds = new ArrayList<>();
  356. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  357. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  358. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  359. } else {
  360. userIds.add(userId);
  361. }
  362. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  363. } else if ("jy_expert_business".equals(roleId)) {
  364. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  365. }
  366. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  367. if (Check.isNull(promoterIds)) {
  368. throw new Exception("该用户下未查询到绑定达人");
  369. }
  370. }
  371. if (!Check.isNull(promoterIds)) {
  372. requestMap.put("promoterIds", promoterIds);
  373. }
  374. Long start = DateUtils.strDateToInt(startDate);
  375. Long end = DateUtils.strDateToInt(endDate);
  376. requestMap.put("start", start);
  377. requestMap.put("end", end);
  378. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  379. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  380. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  381. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  382. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  383. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  384. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  385. if (start.equals(nowDate) && end.equals(nowDate)) {
  386. Integer nowHour = DateUtils.getNowHour();
  387. requestMap.put("nowHour", nowHour);
  388. }
  389. List<JSONObject> data = jiaoYangDingPanService.getPeopleList(requestMap);
  390. returnJson.put("code", 200);
  391. returnJson.put("data", data);
  392. returnJson.put("success", true);
  393. } catch (Exception e) {
  394. e.printStackTrace();
  395. returnJson.put("code", 500);
  396. returnJson.put("message", e.getMessage());
  397. }
  398. return returnJson;
  399. }
  400. @GetMapping("/getAddItemListByUserId")
  401. @ApiOperation(value = "切片盯盘-新增商品")
  402. public JSONObject getAddItemListByUserId(Long userId, String startDate, String endDate) {
  403. Map<String, Object> requestMap = new HashMap<>();
  404. JSONObject returnJson = new JSONObject();
  405. try {
  406. if (Check.isNull(userId)) {
  407. throw new Exception("请传入用户id");
  408. }
  409. if (Check.isNull(startDate)) {
  410. throw new Exception("请传入开始日期");
  411. }
  412. if (Check.isNull(endDate)) {
  413. throw new Exception("请传入结束日期");
  414. }
  415. requestMap.put("userId", userId);
  416. Long start = DateUtils.strDateToInt(startDate);
  417. Long end = DateUtils.strDateToInt(endDate);
  418. requestMap.put("start", start);
  419. requestMap.put("end", end);
  420. List<JSONObject> data = jiaoYangDingPanService.getAddItemListByUserId(requestMap);
  421. returnJson.put("data", data);
  422. returnJson.put("code", 200);
  423. returnJson.put("success", true);
  424. } catch (Exception e) {
  425. e.printStackTrace();
  426. returnJson.put("code", 500);
  427. returnJson.put("success", false);
  428. returnJson.put("message", e.getMessage());
  429. }
  430. return returnJson;
  431. }
  432. // 分达人数据
  433. @GetMapping("/getPromoterList")
  434. @ApiOperation(value = "切片盯盘-成员数据")
  435. public JSONObject getPromoterList(Long userId, String startDate, String endDate) {
  436. Map<String, Object> requestMap = new HashMap<>();
  437. JSONObject returnJson = new JSONObject();
  438. try {
  439. if (Check.isNull(userId)) {
  440. throw new Exception("请传入用户id");
  441. }
  442. if (Check.isNull(startDate)) {
  443. throw new Exception("请传入开始日期");
  444. }
  445. if (Check.isNull(endDate)) {
  446. throw new Exception("请传入结束日期");
  447. }
  448. String roleId = sysRoleService.getRoleBYUserId(userId);
  449. // 剪手经理,渠道经理 查询部门下所有成员数据
  450. List<Long> promoterIds = new ArrayList<>();
  451. 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)) {
  452. List<Long> userIds = new ArrayList<>();
  453. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  454. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  455. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  456. } else {
  457. userIds.add(userId);
  458. }
  459. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  460. } else if ("jy_expert_business".equals(roleId)) {
  461. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  462. }
  463. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  464. if (Check.isNull(promoterIds)) {
  465. throw new Exception("该用户下未查询到绑定达人");
  466. }
  467. }
  468. if (!Check.isNull(promoterIds)) {
  469. requestMap.put("promoterIds", promoterIds);
  470. }
  471. Long start = DateUtils.strDateToInt(startDate);
  472. Long end = DateUtils.strDateToInt(endDate);
  473. requestMap.put("start", start);
  474. requestMap.put("end", end);
  475. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  476. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  477. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  478. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  479. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  480. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  481. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  482. if (start.equals(nowDate) && end.equals(nowDate)) {
  483. Integer nowHour = DateUtils.getNowHour();
  484. requestMap.put("nowHour", nowHour);
  485. }
  486. List<JSONObject> data = jiaoYangDingPanService.getPromoterList(requestMap);
  487. returnJson.put("code", 200);
  488. returnJson.put("data", data);
  489. returnJson.put("success", true);
  490. } catch (Exception e) {
  491. e.printStackTrace();
  492. returnJson.put("code", 500);
  493. returnJson.put("message", e.getMessage());
  494. }
  495. return returnJson;
  496. }
  497. @GetMapping("/getDingPanItemList")
  498. @ApiOperation(value = "切片盯盘")
  499. public JSONObject getItemList(Long userId, String startDate, String endDate) {
  500. Map<String, Object> requestMap = new HashMap<>();
  501. JSONObject returnJson = new JSONObject();
  502. try {
  503. if (Check.isNull(userId)) {
  504. throw new Exception("请传入用户id");
  505. }
  506. if (Check.isNull(startDate)) {
  507. throw new Exception("请传入开始日期");
  508. }
  509. if (Check.isNull(endDate)) {
  510. throw new Exception("请传入结束日期");
  511. }
  512. String roleId = sysRoleService.getRoleBYUserId(userId);
  513. // 剪手经理,渠道经理 查询部门下所有成员数据
  514. List<Long> promoterIds = new ArrayList<>();
  515. 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)) {
  516. List<Long> userIds = new ArrayList<>();
  517. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  518. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  519. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  520. } else {
  521. userIds.add(userId);
  522. }
  523. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  524. } else if ("jy_expert_business".equals(roleId)) {
  525. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  526. }
  527. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  528. if (Check.isNull(promoterIds)) {
  529. throw new Exception("该用户下未查询到绑定达人");
  530. }
  531. }
  532. if (!Check.isNull(promoterIds)) {
  533. requestMap.put("promoterIds", promoterIds);
  534. }
  535. Long start = DateUtils.strDateToInt(startDate);
  536. Long end = DateUtils.strDateToInt(endDate);
  537. requestMap.put("start", start);
  538. requestMap.put("end", end);
  539. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  540. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  541. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  542. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  543. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  544. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  545. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  546. if (start.equals(nowDate) && end.equals(nowDate)) {
  547. Integer nowHour = DateUtils.getNowHour();
  548. requestMap.put("nowHour", nowHour);
  549. }
  550. List<JSONObject> data = jiaoYangDingPanService.getItemList(requestMap);
  551. returnJson.put("code", 200);
  552. returnJson.put("data", data);
  553. returnJson.put("success", true);
  554. } catch (Exception e) {
  555. e.printStackTrace();
  556. returnJson.put("code", 500);
  557. returnJson.put("message", e.getMessage());
  558. }
  559. return returnJson;
  560. }
  561. @GetMapping("/getDingPanTuiGuangUserList")
  562. @ApiOperation(value = "切片盯盘")
  563. public JSONObject getDingPanTuiGuangUserList(Long userId, String startDate, String endDate) {
  564. Map<String, Object> requestMap = new HashMap<>();
  565. JSONObject returnJson = new JSONObject();
  566. try {
  567. if (Check.isNull(userId)) {
  568. throw new Exception("请传入用户id");
  569. }
  570. if (Check.isNull(startDate)) {
  571. throw new Exception("请传入开始日期");
  572. }
  573. if (Check.isNull(endDate)) {
  574. throw new Exception("请传入结束日期");
  575. }
  576. String roleId = sysRoleService.getRoleBYUserId(userId);
  577. // 剪手经理,渠道经理 查询部门下所有成员数据
  578. List<Long> promoterIds = new ArrayList<>();
  579. 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)) {
  580. List<Long> userIds = new ArrayList<>();
  581. if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
  582. Long deptId = sysDeptService.getDeptIdByUserId(userId);
  583. userIds = sysDeptService.getDeptUserListByDeptId(deptId);
  584. } else {
  585. userIds.add(userId);
  586. }
  587. promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
  588. } else if ("jy_expert_business".equals(roleId)) {
  589. promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
  590. }
  591. if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
  592. if (Check.isNull(promoterIds)) {
  593. throw new Exception("该用户下未查询到绑定达人");
  594. }
  595. }
  596. if (!Check.isNull(promoterIds)) {
  597. requestMap.put("promoterIds", promoterIds);
  598. }
  599. Long start = DateUtils.strDateToInt(startDate);
  600. Long end = DateUtils.strDateToInt(endDate);
  601. requestMap.put("start", start);
  602. requestMap.put("end", end);
  603. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  604. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  605. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  606. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  607. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  608. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  609. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  610. if (start.equals(nowDate) && end.equals(nowDate)) {
  611. Integer nowHour = DateUtils.getNowHour();
  612. requestMap.put("nowHour", nowHour);
  613. }
  614. List<JSONObject> data = jiaoYangDingPanService.getDingPanTuiGuangUserList(requestMap);
  615. returnJson.put("code", 200);
  616. returnJson.put("data", data);
  617. returnJson.put("success", true);
  618. } catch (Exception e) {
  619. e.printStackTrace();
  620. returnJson.put("code", 500);
  621. returnJson.put("message", e.getMessage());
  622. }
  623. return returnJson;
  624. }
  625. @GetMapping("/getDingPanMentorBusinessList")
  626. @ApiOperation(value = "切片盯盘")
  627. public JSONObject getDingPanMentorBusinessList(Long userId, String startDate, String endDate) {
  628. Map<String, Object> requestMap = new HashMap<>();
  629. JSONObject returnJson = new JSONObject();
  630. try {
  631. if (Check.isNull(userId)) {
  632. throw new Exception("请传入用户id");
  633. }
  634. if (Check.isNull(startDate)) {
  635. throw new Exception("请传入开始日期");
  636. }
  637. if (Check.isNull(endDate)) {
  638. throw new Exception("请传入结束日期");
  639. }
  640. String roleId = sysRoleService.getRoleBYUserId(userId);
  641. // 剪手经理,渠道经理 查询部门下所有成员数据
  642. if (!roleId.equals("admin") && !roleId.equals("jy_admnin") && !roleId.equals("jy_expert_mentor")) {
  643. returnJson.put("code", 200);
  644. returnJson.put("data", null);
  645. return returnJson;
  646. }
  647. Long start = DateUtils.strDateToInt(startDate);
  648. Long end = DateUtils.strDateToInt(endDate);
  649. requestMap.put("start", start);
  650. requestMap.put("end", end);
  651. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  652. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  653. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  654. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  655. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  656. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  657. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  658. if (start.equals(nowDate) && end.equals(nowDate)) {
  659. Integer nowHour = DateUtils.getNowHour();
  660. requestMap.put("nowHour", nowHour);
  661. }
  662. List<JSONObject> data = jiaoYangDingPanService.getDingPanMentorBusinessList(requestMap);
  663. returnJson.put("code", 200);
  664. returnJson.put("data", data);
  665. returnJson.put("success", true);
  666. } catch (Exception e) {
  667. e.printStackTrace();
  668. returnJson.put("code", 500);
  669. returnJson.put("message", e.getMessage());
  670. }
  671. return returnJson;
  672. }
  673. @GetMapping("/getTeamDetail")
  674. @ApiOperation(value = "切片盯盘")
  675. public JSONObject getTeamDetail(Long deptId, String startDate, String endDate) {
  676. Map<String, Object> requestMap = new HashMap<>();
  677. JSONObject returnJson = new JSONObject();
  678. try {
  679. if (Check.isNull(deptId)) {
  680. throw new Exception("请传入部门id");
  681. }
  682. if (Check.isNull(startDate)) {
  683. throw new Exception("请传入开始日期");
  684. }
  685. if (Check.isNull(endDate)) {
  686. throw new Exception("请传入结束日期");
  687. }
  688. requestMap.put("deptId", deptId);
  689. Long start = DateUtils.strDateToInt(startDate);
  690. Long end = DateUtils.strDateToInt(endDate);
  691. requestMap.put("start", start);
  692. requestMap.put("end", end);
  693. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  694. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
  695. String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
  696. String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
  697. requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
  698. requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
  699. Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
  700. if (start.equals(nowDate) && end.equals(nowDate)) {
  701. Integer nowHour = DateUtils.getNowHour();
  702. requestMap.put("nowHour", nowHour);
  703. }
  704. List<JSONObject> data = jiaoYangDingPanService.getDingPanMentorBusinessList(requestMap);
  705. returnJson.put("code", 200);
  706. returnJson.put("data", data);
  707. returnJson.put("success", true);
  708. } catch (Exception e) {
  709. e.printStackTrace();
  710. returnJson.put("code", 500);
  711. returnJson.put("message", e.getMessage());
  712. }
  713. return returnJson;
  714. }
  715. }