SupplyChainController.java 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840
  1. package com.ruixuan.isc.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.data.utils.ExportExcelUtils;
  8. import com.ruixuan.isc.service.IKuaishouPromoterService;
  9. import com.ruixuan.isc.service.ISupplyChainService;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import lombok.SneakyThrows;
  13. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.GetMapping;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestParam;
  20. import org.springframework.web.bind.annotation.ResponseBody;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.io.IOException;
  25. import java.io.OutputStream;
  26. import java.io.UnsupportedEncodingException;
  27. import java.text.SimpleDateFormat;
  28. import java.util.ArrayList;
  29. import java.util.Arrays;
  30. import java.util.HashMap;
  31. import java.util.List;
  32. import java.util.Map;
  33. @RestController
  34. @RequestMapping("/isv/supply_chain")
  35. public class SupplyChainController extends BaseController {
  36. @Autowired
  37. private ISupplyChainService supplyChainService;
  38. @Autowired
  39. private IKuaishouPromoterService promoterService;
  40. /**
  41. * 达人订单
  42. *
  43. * @param orderStartDate
  44. * @param orderEndDate
  45. * @param promoterNickName
  46. * @param promoterId
  47. * @return
  48. */
  49. @GetMapping("/orderList")
  50. @ApiOperation(value = "达人订单")
  51. public TableDataInfo orderList(@ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  52. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  53. @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
  54. @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId) {
  55. Map<String, Object> requestMap = new HashMap<>();
  56. if (!Check.isNull(orderStartDate)) {
  57. Long start = DateUtils.getStartLongTime(orderStartDate);
  58. requestMap.put("start", start);
  59. }
  60. if (!Check.isNull(orderEndDate)) {
  61. Long end = DateUtils.getEndLongTime(orderEndDate);
  62. requestMap.put("end", end);
  63. }
  64. if (!Check.isNull(promoterNickName)) {
  65. requestMap.put("promoterNickName", promoterNickName);
  66. }
  67. if (!Check.isNull(promoterId)) {
  68. requestMap.put("promoterId", promoterId);
  69. }
  70. TableDataInfo dataInfo = new TableDataInfo();
  71. if (Check.isNullMap(requestMap)) {
  72. dataInfo.setCode(-1);
  73. dataInfo.setMsg("入参不能为空");
  74. return dataInfo;
  75. }
  76. startPage();
  77. List<JSONObject> list = supplyChainService.getOrderList(requestMap);
  78. return getDataTable(list);
  79. }
  80. /**
  81. * 达人带货详情
  82. *
  83. * @param promoterId
  84. * @param orderStartDate
  85. * @param orderEndDate
  86. * @param itemTitle
  87. * @param itemId
  88. * @return
  89. */
  90. @GetMapping("/anchorOrderDetail")
  91. @ApiOperation(value = "达人带货详情")
  92. public TableDataInfo anchorOrderDetail(
  93. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  94. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  95. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  96. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  97. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId) {
  98. Map<String, Object> requestMap = new HashMap<>();
  99. if (!Check.isNull(orderStartDate)) {
  100. Long start = DateUtils.getStartLongTime(orderStartDate);
  101. requestMap.put("start", start);
  102. }
  103. if (!Check.isNull(orderEndDate)) {
  104. Long end = DateUtils.getEndLongTime(orderEndDate);
  105. requestMap.put("end", end);
  106. }
  107. if (!Check.isNull(promoterId)) {
  108. requestMap.put("promoterId", promoterId);
  109. }
  110. if (!Check.isNull(itemId)) {
  111. requestMap.put("itemId", itemId);
  112. }
  113. if (!Check.isNull(itemTitle)) {
  114. requestMap.put("itemTitle", itemTitle);
  115. }
  116. TableDataInfo dataInfo = new TableDataInfo();
  117. if (Check.isNullMap(requestMap)) {
  118. dataInfo.setCode(-1);
  119. dataInfo.setMsg("入参不能为空");
  120. return dataInfo;
  121. }
  122. startPage();
  123. List<JSONObject> list = supplyChainService.anchorOrderDetail(requestMap);
  124. return getDataTable(list);
  125. }
  126. /**
  127. * 订单统计
  128. *
  129. * @param promoterId
  130. * @param orderStartDate
  131. * @param orderEndDate
  132. * @return
  133. */
  134. @GetMapping("/orderStatistics")
  135. @ApiOperation(value = "订单统计")
  136. public JSONObject orderStatistics(
  137. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  138. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  139. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  140. Map<String, Object> requestMap = new HashMap<>();
  141. if (!Check.isNull(orderStartDate)) {
  142. Long start = DateUtils.getStartLongTime(orderStartDate);
  143. requestMap.put("start", start);
  144. }
  145. if (!Check.isNull(orderEndDate)) {
  146. Long end = DateUtils.getEndLongTime(orderEndDate);
  147. requestMap.put("end", end);
  148. }
  149. if (!Check.isNull(promoterId)) {
  150. requestMap.put("promoterId", promoterId);
  151. }
  152. JSONObject returnJson = new JSONObject();
  153. if (Check.isNullMap(requestMap)) {
  154. returnJson.put("code", -1);
  155. returnJson.put("message", "入参不能为空");
  156. return returnJson;
  157. }
  158. List<JSONObject> list = supplyChainService.orderStatistics(requestMap);
  159. returnJson.put("code", 0);
  160. returnJson.put("data", list);
  161. return returnJson;
  162. }
  163. /**
  164. * 商品列表
  165. *
  166. * @param itemId
  167. * @param itemTitle
  168. * @param orderStartDate
  169. * @param orderEndDate
  170. * @return
  171. */
  172. @GetMapping("/itemList")
  173. @ApiOperation(value = "商品列表")
  174. public TableDataInfo itemList(
  175. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  176. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  177. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  178. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  179. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  180. @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort,
  181. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId
  182. ) {
  183. Map<String, Object> requestMap = new HashMap<>();
  184. if (!Check.isNull(orderStartDate)) {
  185. Long start = DateUtils.getStartLongTime(orderStartDate);
  186. requestMap.put("start", start);
  187. }
  188. if (!Check.isNull(orderEndDate)) {
  189. Long end = DateUtils.getEndLongTime(orderEndDate);
  190. requestMap.put("end", end);
  191. }
  192. if (!Check.isNull(itemId)) {
  193. requestMap.put("itemId", itemId);
  194. }
  195. if (!Check.isNull(itemTitle)) {
  196. requestMap.put("itemTitle", itemTitle);
  197. }
  198. if (!Check.isNull(userId)) {
  199. requestMap.put("userId", userId);
  200. }
  201. requestMap.put("fieId", fieId);
  202. requestMap.put("sort", sort);
  203. TableDataInfo dataInfo = new TableDataInfo();
  204. if (Check.isNullMap(requestMap)) {
  205. dataInfo.setCode(-1);
  206. dataInfo.setMsg("入参不能为空");
  207. return dataInfo;
  208. }
  209. startPage();
  210. List<JSONObject> list = supplyChainService.itemList(requestMap);
  211. return getDataTable(list);
  212. }
  213. /**
  214. * 根据商品id获取top达人
  215. *
  216. * @param itemId
  217. * @param orderStartDate
  218. * @param orderEndDate
  219. * @return
  220. */
  221. @GetMapping("/getTopPromoterByItemId")
  222. @ApiOperation(value = "商品列表")
  223. public TableDataInfo getTopPromoterByItemId(
  224. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  225. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  226. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  227. Map<String, Object> requestMap = new HashMap<>();
  228. if (!Check.isNull(orderStartDate)) {
  229. Long start = DateUtils.getStartLongTime(orderStartDate);
  230. requestMap.put("start", start);
  231. }
  232. if (!Check.isNull(orderEndDate)) {
  233. Long end = DateUtils.getEndLongTime(orderEndDate);
  234. requestMap.put("end", end);
  235. }
  236. if (!Check.isNull(itemId)) {
  237. requestMap.put("itemId", itemId);
  238. }
  239. List<JSONObject> list = supplyChainService.getTopPromoterByItemId(requestMap);
  240. return getDataTable(list);
  241. }
  242. /**
  243. * 商品详情
  244. *
  245. * @param itemId
  246. * @param orderStartDate
  247. * @param orderEndDate
  248. * @param promoterId
  249. * @param promoterNickName
  250. * @return
  251. */
  252. @GetMapping("/itemDetail")
  253. @ApiOperation(value = "商品详情")
  254. public TableDataInfo itemDetail(
  255. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId,
  256. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  257. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  258. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  259. @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName) {
  260. Map<String, Object> requestMap = new HashMap<>();
  261. if (!Check.isNull(orderStartDate)) {
  262. Long start = DateUtils.getStartLongTime(orderStartDate);
  263. requestMap.put("start", start);
  264. }
  265. if (!Check.isNull(orderEndDate)) {
  266. Long end = DateUtils.getEndLongTime(orderEndDate);
  267. requestMap.put("end", end);
  268. }
  269. if (!Check.isNull(promoterId)) {
  270. requestMap.put("promoterId", promoterId);
  271. }
  272. if (!Check.isNull(itemId)) {
  273. requestMap.put("itemId", itemId);
  274. }
  275. if (!Check.isNull(promoterNickName)) {
  276. requestMap.put("itemTitle", promoterNickName);
  277. }
  278. TableDataInfo dataInfo = new TableDataInfo();
  279. if (Check.isNullMap(requestMap)) {
  280. dataInfo.setCode(-1);
  281. dataInfo.setMsg("入参不能为空");
  282. return dataInfo;
  283. }
  284. startPage();
  285. List<JSONObject> list = supplyChainService.itemDetail(requestMap);
  286. return getDataTable(list);
  287. }
  288. /**
  289. * 产品服务费
  290. *
  291. * @param itemId
  292. * @param itemTitle
  293. * @param orderStartDate
  294. * @param orderEndDate
  295. * @return
  296. */
  297. @GetMapping("/itemServiceCharge")
  298. @ApiOperation(value = "产品服务费")
  299. public TableDataInfo itemServiceCharge(
  300. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  301. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  302. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  303. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  304. Map<String, Object> requestMap = new HashMap<>();
  305. if (!Check.isNull(orderStartDate)) {
  306. Long start = DateUtils.getStartLongTime(orderStartDate);
  307. requestMap.put("start", start);
  308. }
  309. if (!Check.isNull(orderEndDate)) {
  310. Long end = DateUtils.getEndLongTime(orderEndDate);
  311. requestMap.put("end", end);
  312. }
  313. if (!Check.isNull(itemId)) {
  314. requestMap.put("itemId", itemId);
  315. }
  316. if (!Check.isNull(itemTitle)) {
  317. requestMap.put("itemTitle", itemTitle);
  318. }
  319. TableDataInfo dataInfo = new TableDataInfo();
  320. if (Check.isNullMap(requestMap)) {
  321. dataInfo.setCode(-1);
  322. dataInfo.setMsg("入参不能为空");
  323. return dataInfo;
  324. }
  325. startPage();
  326. List<JSONObject> list = supplyChainService.itemServiceCharge(requestMap);
  327. return getDataTable(list);
  328. }
  329. /**
  330. * 首页-订单数据
  331. *
  332. * @param dateType
  333. * @param orderStartDate
  334. * @param orderEndDate
  335. * @return
  336. */
  337. @GetMapping("/indexOrderInfo")
  338. @ApiOperation(value = "首页-订单数据")
  339. public JSONObject orderTotal(
  340. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  341. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  342. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  343. Map<String, Object> requestMap = new HashMap<>();
  344. JSONObject returnJson = new JSONObject();
  345. if (dateType == 0) {
  346. if (!Check.isNull(orderStartDate)) {
  347. Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
  348. requestMap.put("start", start);
  349. }
  350. if (!Check.isNull(orderEndDate)) {
  351. Long end = DateUtils.getEndLongTime(orderEndDate); // 当天结束时间
  352. requestMap.put("end", end);
  353. }
  354. JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
  355. returnJson.put("orderTotal", orderTotal);
  356. Integer hour = DateUtils.getNowHour() - 1; // 当前小时
  357. if (hour >= 0) {
  358. JSONObject ratioJson = new JSONObject();
  359. Long nowStartHourTemp = DateUtils.getStartLongTime(orderStartDate); // 当天开始时间戳
  360. Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
  361. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  362. Long yesterdayStartHourTemp = DateUtils.getStartLongTime(yesterday); //昨日开始时间戳
  363. Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
  364. Map<String, Object> ratioMap = new HashMap<>();
  365. ratioMap.put("nowStartHourTemp", nowStartHourTemp);
  366. ratioMap.put("nowEndHourTemp", nowEndHourTemp);
  367. ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  368. ratioMap.put("yesterdayEndHourTemp", yesterdayEndHourTemp);
  369. Double ringRatio = supplyChainService.getOrderTotalRatio(ratioMap); //环比
  370. ratioJson.put("ringRatio", ringRatio);
  371. String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
  372. Long yearStartHourTemp = DateUtils.getStartLongTime(yearDay); //前7日开始时间戳
  373. Long yearEndHourTemp = DateUtils.getNowEndHourTemp(yearDay, hour);//前7日结束时间戳
  374. ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
  375. ratioMap.put("yesterdayEndHourTemp", yearEndHourTemp);
  376. Double yearRatio = supplyChainService.getOrderTotalRatio(ratioMap); //同比
  377. ratioJson.put("yearRatio", yearRatio);
  378. returnJson.put("ratio", ratioJson);
  379. }
  380. } else {
  381. if (!Check.isNull(orderStartDate)) {
  382. Long start = DateUtils.getStartLongTime(orderStartDate); //昨日开始时间
  383. requestMap.put("start", start);
  384. }
  385. if (!Check.isNull(orderEndDate)) {
  386. Long end = DateUtils.getEndLongTime(orderEndDate); // 前日开始时间
  387. requestMap.put("end", end);
  388. }
  389. JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
  390. returnJson.put("orderTotal", orderTotal);
  391. }
  392. return returnJson;
  393. }
  394. /**
  395. * 首页-金额数据
  396. *
  397. * @param dateType
  398. * @param orderStartDate
  399. * @param orderEndDate
  400. * @return
  401. */
  402. @GetMapping("/indexAmountInfo")
  403. @ApiOperation(value = "首页-金额数据")
  404. public JSONObject indexAmountInfo(
  405. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  406. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  407. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  408. Map<String, Object> requestMap = new HashMap<>();
  409. JSONObject returnJson = new JSONObject();
  410. if (dateType == 0) {
  411. if (!Check.isNull(orderStartDate)) {
  412. Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
  413. requestMap.put("start", start);
  414. }
  415. if (!Check.isNull(orderEndDate)) {
  416. Long end = DateUtils.getEndLongTime(orderEndDate); // 当天结束时间
  417. requestMap.put("end", end);
  418. }
  419. JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
  420. returnJson.put("amountTotal", amountTotal);
  421. Integer hour = DateUtils.getNowHour() - 1; // 当前小时
  422. if (hour >= 0) {
  423. JSONObject amountRatioJson = new JSONObject();
  424. Long nowStartHourTemp = DateUtils.getStartLongTime(orderStartDate); // 当天开始时间戳
  425. Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
  426. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  427. Long yesterdayStartHourTemp = DateUtils.getStartLongTime(yesterday); //昨日开始时间戳
  428. Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
  429. Map<String, Object> ratioMap = new HashMap<>();
  430. ratioMap.put("nowStartHourTemp", nowStartHourTemp);
  431. ratioMap.put("nowEndHourTemp", nowEndHourTemp);
  432. ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  433. ratioMap.put("yesterdayEndHourTemp", yesterdayEndHourTemp);
  434. Double amountRingRatio = supplyChainService.getAmountTotalRatio(ratioMap); //环比
  435. amountRatioJson.put("amountRingRatio", amountRingRatio);
  436. String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
  437. Long yearStartHourTemp = DateUtils.getStartLongTime(yearDay); //前7日开始时间戳
  438. Long yearEndHourTemp = DateUtils.getNowEndHourTemp(yearDay, hour);//前7日结束时间戳
  439. ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
  440. ratioMap.put("yesterdayEndHourTemp", yearEndHourTemp);
  441. Double amountYearRatio = supplyChainService.getAmountTotalRatio(ratioMap); //同比
  442. amountRatioJson.put("amountYearRatio", amountYearRatio);
  443. returnJson.put("amountRatio", amountRatioJson);
  444. }
  445. } else {
  446. if (!Check.isNull(orderStartDate)) {
  447. Long start = DateUtils.getStartLongTime(orderStartDate); //昨日开始时间
  448. requestMap.put("start", start);
  449. }
  450. if (!Check.isNull(orderEndDate)) {
  451. Long end = DateUtils.getEndLongTime(orderEndDate); // 前日开始时间
  452. requestMap.put("end", end);
  453. }
  454. JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
  455. returnJson.put("amountTotal", amountTotal);
  456. }
  457. return returnJson;
  458. }
  459. /**
  460. * 首页-服务费数据
  461. *
  462. * @param dateType
  463. * @param orderStartDate
  464. * @param orderEndDate
  465. * @return
  466. */
  467. @GetMapping("/indexServiceAmountInfo")
  468. @ApiOperation(value = "首页-服务费数据")
  469. public JSONObject indexServiceAmountInfo(
  470. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  471. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  472. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  473. Map<String, Object> requestMap = new HashMap<>();
  474. JSONObject returnJson = new JSONObject();
  475. if (!Check.isNull(orderStartDate)) {
  476. Long start = DateUtils.getStartLongTime(orderStartDate); //昨日开始时间
  477. requestMap.put("start", start);
  478. }
  479. if (!Check.isNull(orderEndDate)) {
  480. Long end = DateUtils.getEndLongTime(orderEndDate); // 前日开始时间
  481. requestMap.put("end", end);
  482. }
  483. JSONObject serviceAmountTotal = supplyChainService.getServiceAmountTotal(requestMap);
  484. returnJson.put("serviceAmountTotal", serviceAmountTotal);
  485. return returnJson;
  486. }
  487. /**
  488. * 首页-商品排行
  489. *
  490. * @param dateType
  491. * @param orderStartDate
  492. * @param orderEndDate
  493. * @return
  494. */
  495. @GetMapping("/indexOrderRank")
  496. @ApiOperation(value = "首页-商品排行")
  497. public TableDataInfo indexOrderRank(
  498. @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
  499. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
  500. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
  501. @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId) {
  502. Map<String, Object> requestMap = new HashMap<>();
  503. if (dateType == 0) {
  504. if ("1".equals(mediaId)) {
  505. return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
  506. } else {
  507. Integer hour = DateUtils.getNowHour(); // 当前小时
  508. Long nowStartHourTemp = DateUtils.getStartLongTime(orderStartDate); // 当天开始时间戳
  509. Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
  510. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  511. Long yesterdayStartHourTemp = DateUtils.getStartLongTime(yesterday); //昨日开始时间戳
  512. Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
  513. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  514. requestMap.put("nowEndHourTemp", nowEndHourTemp);
  515. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  516. requestMap.put("yesterdayEndHourTemp", yesterdayEndHourTemp);
  517. startPage();
  518. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioList(requestMap);
  519. return getDataTable(orderRankRatioList);
  520. }
  521. } else {
  522. if ("1".equals(mediaId)) {
  523. return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
  524. } else {
  525. if (!Check.isNull(orderStartDate)) {
  526. Long start = DateUtils.getStartLongTime(orderStartDate);
  527. requestMap.put("start", start);
  528. }
  529. if (!Check.isNull(orderEndDate)) {
  530. Long end = DateUtils.getEndLongTime(orderEndDate);
  531. requestMap.put("end", end);
  532. }
  533. startPage();
  534. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankList(requestMap);
  535. return getDataTable(orderRankRatioList);
  536. }
  537. }
  538. }
  539. private TableDataInfo indexOrderRankBytedance(Integer dateType, String orderStartDate, String orderEndDate) {
  540. Map<String, Object> requestMap = new HashMap<>();
  541. if (dateType == 0) {
  542. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate);
  543. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  544. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日时间
  545. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  546. requestMap.put("nowEndHourTemp", nowStartHourTemp);
  547. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  548. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  549. startPage();
  550. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioListBytedance(requestMap);
  551. return getDataTable(orderRankRatioList);
  552. } else {
  553. if (!Check.isNull(orderStartDate)) {
  554. Long start = DateUtils.strDateToInt(orderStartDate);
  555. requestMap.put("start", start);
  556. }
  557. if (!Check.isNull(orderEndDate)) {
  558. Long end = DateUtils.strDateToInt(orderEndDate);
  559. requestMap.put("end", end);
  560. }
  561. startPage();
  562. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankListBytedance(requestMap);
  563. return getDataTable(orderRankRatioList);
  564. }
  565. }
  566. @GetMapping("/indexPromoterRank")
  567. @ApiOperation(value = "首页-达人排行")
  568. public TableDataInfo indexPromoterRank(
  569. @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
  570. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
  571. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
  572. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  573. @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId
  574. ) {
  575. Map<String, Object> requestMap = new HashMap<>();
  576. if (dateType == 0) {
  577. if ("1".equals(mediaId)) {
  578. return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
  579. } else {
  580. if (Check.isNotNull(userId)) {
  581. List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), mediaId);
  582. if (Check.isNull(promoterIds)) {
  583. return getDataTable(null);
  584. }
  585. requestMap.put("promoterIds", promoterIds);
  586. }
  587. if (!Check.isNull(orderStartDate)) {
  588. Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
  589. requestMap.put("start", start);
  590. }
  591. if (!Check.isNull(orderEndDate)) {
  592. Long end = DateUtils.getEndLongTime(orderEndDate); // 当天结束时间
  593. requestMap.put("end", end);
  594. }
  595. Integer hour = DateUtils.getNowHour(); // 当前小时
  596. Long nowStartHourTemp = DateUtils.getStartLongTime(orderStartDate); // 当天开始时间戳
  597. Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
  598. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  599. Long yesterdayStartHourTemp = DateUtils.getStartLongTime(yesterday); //昨日开始时间戳
  600. Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
  601. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  602. requestMap.put("nowEndHourTemp", nowEndHourTemp);
  603. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  604. requestMap.put("yesterdayEndHourTemp", yesterdayEndHourTemp);
  605. startPage();
  606. List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioList(requestMap);
  607. return getDataTable(promoterRankRatioList);
  608. }
  609. } else {
  610. if ("1".equals(mediaId)) {
  611. return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
  612. } else {
  613. if (!Check.isNull(orderStartDate)) {
  614. Long start = DateUtils.getStartLongTime(orderStartDate);
  615. requestMap.put("start", start);
  616. }
  617. if (!Check.isNull(orderEndDate)) {
  618. Long end = DateUtils.getEndLongTime(orderEndDate);
  619. requestMap.put("end", end);
  620. }
  621. startPage();
  622. List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioList(requestMap);
  623. return getDataTable(orderRatioList);
  624. }
  625. }
  626. }
  627. public TableDataInfo indexPromoterRankBytedance(Integer dateType, String orderStartDate, String orderEndDate, Long userId) {
  628. Map<String, Object> requestMap = new HashMap<>();
  629. if (dateType == 0) {
  630. if (Check.isNotNull(userId)) {
  631. List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), "1");
  632. if (Check.isNull(promoterIds)) {
  633. return getDataTable(null);
  634. }
  635. requestMap.put("promoterIds", promoterIds);
  636. }
  637. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
  638. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  639. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳
  640. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  641. requestMap.put("nowEndHourTemp", nowStartHourTemp);
  642. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  643. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  644. startPage();
  645. List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioListBytedance(requestMap);
  646. return getDataTable(promoterRankRatioList);
  647. } else {
  648. if (!Check.isNull(orderStartDate)) {
  649. Long start = DateUtils.strDateToInt(orderStartDate); //当天开始时间
  650. requestMap.put("start", start);
  651. }
  652. if (!Check.isNull(orderEndDate)) {
  653. Long end = DateUtils.strDateToInt(orderEndDate); // 当天结束时间
  654. requestMap.put("end", end);
  655. }
  656. startPage();
  657. List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioListBytedance(requestMap);
  658. return getDataTable(orderRatioList);
  659. }
  660. }
  661. @RequestMapping(value = "/exportPromoterTotal")
  662. @ResponseBody
  663. public void exportPromoterTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  664. Map<String, Object> requestMap = new HashMap<>();
  665. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  666. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  667. requestMap.put("start", start);
  668. }
  669. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  670. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  671. requestMap.put("end", end);
  672. }
  673. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  674. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  675. }
  676. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  677. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  678. }
  679. if (!Check.isNull(requestJson.getLong("itemId"))) {
  680. requestMap.put("itemId", requestJson.getLong("itemId"));
  681. }
  682. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  683. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  684. }
  685. List<JSONObject> list = supplyChainService.exportPromoterTotal(requestMap);
  686. List<List<Object>> exportList = new ArrayList<>();
  687. if (!Check.isNull(list)) {
  688. for (int i = 0; i < list.size(); i++) {
  689. JSONObject date = list.get(i);
  690. List<Object> export = new ArrayList();
  691. Long promoterId = date.getLong("promoterId");
  692. String promoterNickName = date.getString("promoterNickName");
  693. String name = promoterNickName + "(" + promoterId + ")";
  694. export.add(name);
  695. export.add(date.getInteger("orderNum"));
  696. export.add(date.getInteger("validOrderNUm"));
  697. export.add(date.getString("validRadio"));
  698. export.add(date.getString("payAmount"));
  699. export.add(date.getString("validPayAmount"));
  700. // export.add(date.getString("regimentalPromotionAmount"));
  701. export.add(date.getString("deliveryNum"));
  702. export.add(date.getString("deliveryRadio"));
  703. export.add(date.getString("notDeliveryNum"));
  704. String userName = supplyChainService.getUserName(date.getLong("promoterId"));
  705. if (!Check.isNull(userName)) {
  706. export.add(userName);
  707. }
  708. exportList.add(export);
  709. }
  710. }
  711. String[] headers = {"达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
  712. OutputStream os = response.getOutputStream();
  713. ExportExcelUtils eeu = new ExportExcelUtils();
  714. XSSFWorkbook workbook = new XSSFWorkbook();
  715. eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
  716. this.setResponseHeader(response, "达人信息.xls");
  717. workbook.write(os);
  718. os.flush();
  719. os.close();
  720. }
  721. @RequestMapping(value = "/exportPromoter")
  722. @ResponseBody
  723. public void exportPromoter(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  724. Map<String, Object> requestMap = new HashMap<>();
  725. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  726. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  727. requestMap.put("start", start);
  728. }
  729. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  730. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  731. requestMap.put("end", end);
  732. }
  733. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  734. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  735. }
  736. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  737. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  738. }
  739. if (!Check.isNull(requestJson.getLong("itemId"))) {
  740. requestMap.put("itemId", requestJson.getLong("itemId"));
  741. }
  742. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  743. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  744. }
  745. List<JSONObject> list = supplyChainService.exportPromoter(requestMap);
  746. List<List<Object>> exportList = new ArrayList<>();
  747. if (!Check.isNull(list)) {
  748. for (int i = 0; i < list.size(); i++) {
  749. JSONObject date = list.get(i);
  750. List<Object> export = new ArrayList();
  751. String promoterNickName = date.getString("promoterNickName");
  752. Long promoterId = date.getLong("promoterId");
  753. String promoter = promoterNickName + "(" + promoterId + ")";
  754. export.add(promoter);
  755. Long itemId = date.getLong("itemId");
  756. String itemTitle = date.getString("itemTitle");
  757. String item = itemTitle + "(" + itemId + ")";
  758. export.add(item);
  759. export.add(date.getString("imageUrl"));
  760. export.add(date.getInteger("orderNum"));
  761. export.add(date.getInteger("validOrderNUm"));
  762. export.add(date.getString("validRadio"));
  763. export.add(date.getString("deliveryNum"));
  764. export.add(date.getString("deliveryRadio"));
  765. export.add(date.getString("activityItemStatus"));
  766. exportList.add(export);
  767. }
  768. }
  769. String[] headers = {"达人", "商品", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
  770. OutputStream os = response.getOutputStream();
  771. ExportExcelUtils eeu = new ExportExcelUtils();
  772. XSSFWorkbook workbook = new XSSFWorkbook();
  773. eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
  774. this.setResponseHeader(response, "达人信息.xls");
  775. workbook.write(os);
  776. os.flush();
  777. os.close();
  778. }
  779. @RequestMapping(value = "/exportOrder")
  780. @ResponseBody
  781. public void exportOrder(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  782. Map<String, Object> requestMap = new HashMap<>();
  783. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  784. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  785. requestMap.put("start", start);
  786. }
  787. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  788. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  789. requestMap.put("end", end);
  790. }
  791. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  792. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  793. }
  794. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  795. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  796. }
  797. if (!Check.isNull(requestJson.getLong("itemId"))) {
  798. requestMap.put("itemId", requestJson.getLong("itemId"));
  799. }
  800. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  801. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  802. }
  803. if (!Check.isNull(requestJson.getLong("userId"))) {
  804. requestMap.put("userId", requestJson.getLong("userId"));
  805. }
  806. List<JSONObject> list = supplyChainService.exportOrder(requestMap);
  807. List<List<Object>> exportList = new ArrayList<>();
  808. if (!Check.isNull(list)) {
  809. for (int i = 0; i < list.size(); i++) {
  810. JSONObject date = list.get(i);
  811. List<Object> export = new ArrayList();
  812. export.add(date.getString("userName"));
  813. export.add(date.getLong("itemId"));
  814. export.add(date.getString("itemTitle"));
  815. export.add(date.getString("imageUrl"));
  816. export.add(date.getString("itemCommissionRate"));
  817. export.add(date.getInteger("orderNum"));
  818. export.add(date.getInteger("validOrderNUm"));
  819. export.add(date.getString("validRadio"));
  820. export.add(date.getString("deliveryNum"));
  821. export.add(date.getString("deliveryRadio"));
  822. export.add(date.getString("notDeliveryNum"));
  823. exportList.add(export);
  824. }
  825. }
  826. String[] headers = {"所属人", "商品ID", "商品名称", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数"};
  827. OutputStream os = response.getOutputStream();
  828. ExportExcelUtils eeu = new ExportExcelUtils();
  829. XSSFWorkbook workbook = new XSSFWorkbook();
  830. eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
  831. this.setResponseHeader(response, "订单信息.xls");
  832. workbook.write(os);
  833. os.flush();
  834. os.close();
  835. }
  836. /**
  837. * 获取供应链人员列表
  838. *
  839. * @return
  840. */
  841. @GetMapping("/getSupplyChainUserList")
  842. @ApiOperation(value = "获取供应链成员列表")
  843. public TableDataInfo getSupplyChainUserList() {
  844. List<JSONObject> list = supplyChainService.getSupplyChainUserList();
  845. return getDataTable(list);
  846. }
  847. @GetMapping("/getSupplyChainCourtshipUserList")
  848. @ApiOperation(value = "获取供应链成员列表")
  849. public TableDataInfo getSupplyChainCourtshipUserList() {
  850. List<JSONObject> list = supplyChainService.getSupplyChainCourtshipUserList();
  851. return getDataTable(list);
  852. }
  853. /**
  854. * 获取商品绑定人员列表
  855. *
  856. * @param status
  857. * @param userId
  858. * @param itemId
  859. * @param itemTitle
  860. * @param activityId
  861. * @return
  862. */
  863. @GetMapping("/bindUserItemList")
  864. @ApiOperation(value = "商品认领列表")
  865. public TableDataInfo bindUserItemList(
  866. @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status,
  867. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  868. @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId,
  869. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  870. @ApiParam("活动ID") @RequestParam(value = "activityId", required = false) Long activityId
  871. ) {
  872. Map<String, Object> requestMap = new HashMap<>();
  873. if (!Check.isNull(status)) {
  874. requestMap.put("status", status);
  875. }
  876. if (!Check.isNull(userId)) {
  877. requestMap.put("userId", userId);
  878. }
  879. if (!Check.isNull(itemId)) {
  880. requestMap.put("itemId", itemId);
  881. }
  882. if (!Check.isNull(itemTitle)) {
  883. requestMap.put("itemTitle", itemTitle);
  884. }
  885. if (!Check.isNull(activityId)) {
  886. requestMap.put("activityId", activityId);
  887. }
  888. startPage();
  889. List<JSONObject> list = supplyChainService.bindUserItemList(requestMap);
  890. return getDataTable(list);
  891. }
  892. /**
  893. * 商品解绑
  894. *
  895. * @param itemId
  896. * @return
  897. */
  898. @GetMapping("/unbindUser")
  899. @ApiOperation(value = "商品解绑")
  900. public JSONObject unbindUser(
  901. @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId) {
  902. JSONObject returnJson = new JSONObject();
  903. if (Check.isNull(itemId)) {
  904. returnJson.put("code", -1);
  905. returnJson.put("message", "请传入商品ID");
  906. return returnJson;
  907. }
  908. boolean isTrueOrFalse = supplyChainService.unbindUser(itemId);
  909. if (isTrueOrFalse) {
  910. returnJson.put("code", 0);
  911. returnJson.put("message", "解绑成功");
  912. return returnJson;
  913. } else {
  914. returnJson.put("code", -1);
  915. returnJson.put("message", "解绑失败");
  916. return returnJson;
  917. }
  918. }
  919. /**
  920. * 绑定商品
  921. *
  922. * @param itemId
  923. * @return
  924. */
  925. @GetMapping("/bindUser")
  926. @ApiOperation(value = "绑定商品")
  927. public JSONObject bindUser(
  928. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
  929. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
  930. @ApiParam("用户名称") @RequestParam(value = "nikeName", required = false) String nikeName) {
  931. JSONObject returnJson = new JSONObject();
  932. if (Check.isNull(itemId)) {
  933. returnJson.put("code", -1);
  934. returnJson.put("message", "请传入商品ID");
  935. return returnJson;
  936. }
  937. if (Check.isNull("userId")) {
  938. returnJson.put("code", -1);
  939. returnJson.put("message", "请传入用户ID");
  940. return returnJson;
  941. }
  942. if (Check.isNull("nikeName")) {
  943. returnJson.put("code", -1);
  944. returnJson.put("message", "请传入用户名称");
  945. return returnJson;
  946. }
  947. boolean isTrueOrFalse = supplyChainService.bindUser(itemId, userId, nikeName);
  948. if (isTrueOrFalse) {
  949. returnJson.put("code", 0);
  950. returnJson.put("message", "认领成功");
  951. return returnJson;
  952. } else {
  953. returnJson.put("code", -1);
  954. returnJson.put("message", "认领失败");
  955. return returnJson;
  956. }
  957. }
  958. /**
  959. * 供应链管理员统计列表
  960. *
  961. * @param orderStartDate
  962. * @param orderEndDate
  963. * @return
  964. */
  965. @GetMapping("/adminReportList")
  966. @ApiOperation(value = "供应链管理员统计列表")
  967. public TableDataInfo adminReportList(
  968. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  969. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  970. @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
  971. @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
  972. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId
  973. ) {
  974. Map<String, Object> requestMap = new HashMap<>();
  975. if (!Check.isNull(orderStartDate)) {
  976. Long start = DateUtils.getStartLongTime(orderStartDate);
  977. requestMap.put("start", start);
  978. }
  979. if (!Check.isNull(orderEndDate)) {
  980. Long end = DateUtils.getEndLongTime(orderEndDate);
  981. requestMap.put("end", end);
  982. }
  983. if (!Check.isNull(bindStartDate)) {
  984. Long start = DateUtils.getStartLongTime(bindStartDate);
  985. requestMap.put("start", start);
  986. }
  987. if (!Check.isNull(bindEndDate)) {
  988. Long end = DateUtils.getEndLongTime(bindEndDate);
  989. requestMap.put("end", end);
  990. }
  991. if (!Check.isNull(userId)) {
  992. requestMap.put("userId", userId);
  993. }
  994. TableDataInfo dataInfo = new TableDataInfo();
  995. if (Check.isNullMap(requestMap)) {
  996. dataInfo.setCode(-1);
  997. dataInfo.setMsg("入参不能为空");
  998. return dataInfo;
  999. }
  1000. List<JSONObject> list = new ArrayList<>();
  1001. startPage();
  1002. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  1003. list = supplyChainService.adminReportList(requestMap);
  1004. } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  1005. list = supplyChainService.adminReportListByBind(requestMap);
  1006. }
  1007. return getDataTable(list);
  1008. }
  1009. @PostMapping("/exportAdminReportList")
  1010. @ApiOperation(value = "供应链管理员统计列表")
  1011. public void exportAdminReportList(
  1012. HttpServletRequest request, HttpServletResponse response,
  1013. @RequestBody JSONObject requestJson
  1014. ) throws IOException {
  1015. Map<String, Object> requestMap = new HashMap<>();
  1016. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1017. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  1018. requestMap.put("start", start);
  1019. }
  1020. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1021. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  1022. requestMap.put("end", end);
  1023. }
  1024. if (!Check.isNull(requestJson.getString("bindStartDate"))) {
  1025. Long start = DateUtils.getStartLongTime(requestJson.getString("bindStartDate"));
  1026. requestMap.put("start", start);
  1027. }
  1028. if (!Check.isNull(requestJson.getString("bindEndDate"))) {
  1029. Long end = DateUtils.getEndLongTime(requestJson.getString("bindEndDate"));
  1030. requestMap.put("end", end);
  1031. }
  1032. if (!Check.isNull(requestJson.getString("userId"))) {
  1033. requestMap.put("userId", requestJson.getString("userId"));
  1034. }
  1035. List<JSONObject> list = new ArrayList<>();
  1036. if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
  1037. list = supplyChainService.exportAdminReportList(requestMap);
  1038. } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
  1039. list = supplyChainService.exportAdminReportListByBind(requestMap);
  1040. }
  1041. List<List<Object>> exportList = new ArrayList<>();
  1042. if (!Check.isNull(list)) {
  1043. for (int i = 0; i < list.size(); i++) {
  1044. JSONObject date = list.get(i);
  1045. List<Object> export = new ArrayList();
  1046. export.add(date.getString("userName"));
  1047. export.add(date.getString("itemCount"));
  1048. export.add(date.getString("sendSampleCount"));
  1049. export.add(date.getString("orderNum"));
  1050. export.add(date.getString("validOrderNUm"));
  1051. export.add(date.getString("validRadio"));
  1052. export.add(date.getString("deliveryNum"));
  1053. export.add(date.getString("notDeliveryNum"));
  1054. export.add(date.getString("deliveryRadio"));
  1055. export.add(date.getString("payAmount"));
  1056. export.add(date.getString("regimentalPromotionAmount"));
  1057. export.add(date.getString("totalRegimentalSettleAmount"));
  1058. exportList.add(export);
  1059. }
  1060. }
  1061. String[] headers = {"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入"};
  1062. OutputStream os = response.getOutputStream();
  1063. ExportExcelUtils eeu = new ExportExcelUtils();
  1064. XSSFWorkbook workbook = new XSSFWorkbook();
  1065. eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
  1066. this.setResponseHeader(response, "订单信息.xls");
  1067. workbook.write(os);
  1068. os.flush();
  1069. os.close();
  1070. }
  1071. /**
  1072. * 认领商品列表
  1073. *
  1074. * @param userId
  1075. * @param orderStartDate
  1076. * @param orderEndDate
  1077. * @param itemId
  1078. * @param itemTitle
  1079. * @return
  1080. */
  1081. @GetMapping("/userItemDetail")
  1082. @ApiOperation(value = "认领商品列表")
  1083. public TableDataInfo userItemDetail(
  1084. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  1085. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1086. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1087. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) Long itemId,
  1088. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  1089. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1090. @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort
  1091. ) {
  1092. Map<String, Object> requestMap = new HashMap<>();
  1093. if (!Check.isNull(userId)) {
  1094. requestMap.put("userId", userId);
  1095. }
  1096. if (!Check.isNull(orderStartDate)) {
  1097. Long start = DateUtils.getStartLongTime(orderStartDate);
  1098. requestMap.put("start", start);
  1099. }
  1100. if (!Check.isNull(orderEndDate)) {
  1101. Long end = DateUtils.getEndLongTime(orderEndDate);
  1102. requestMap.put("end", end);
  1103. }
  1104. if (!Check.isNull(itemId)) {
  1105. requestMap.put("itemId", itemId);
  1106. }
  1107. if (!Check.isNull(itemTitle)) {
  1108. requestMap.put("itemTitle", itemTitle);
  1109. }
  1110. requestMap.put("fieId", fieId);
  1111. requestMap.put("sort", sort);
  1112. TableDataInfo dataInfo = new TableDataInfo();
  1113. if (Check.isNullMap(requestMap)) {
  1114. dataInfo.setCode(-1);
  1115. dataInfo.setMsg("入参不能为空");
  1116. return dataInfo;
  1117. }
  1118. startPage();
  1119. List<JSONObject> list = supplyChainService.userItemDetail(requestMap);
  1120. return getDataTable(list);
  1121. }
  1122. /**
  1123. * 认领商品列表导出
  1124. *
  1125. * @return
  1126. */
  1127. @PostMapping("/exportUserItemDetail")
  1128. @ApiOperation(value = "认领商品列表")
  1129. @ResponseBody
  1130. public void exportUserItemDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1131. Map<String, Object> requestMap = new HashMap<>();
  1132. if (!Check.isNull(requestJson.getLong("userId"))) {
  1133. requestMap.put("userId", requestJson.getLong("userId"));
  1134. }
  1135. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1136. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  1137. requestMap.put("start", start);
  1138. }
  1139. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1140. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  1141. requestMap.put("end", end);
  1142. }
  1143. if (!Check.isNull(requestJson.getLong("itemId"))) {
  1144. requestMap.put("itemId", requestJson.getLong("itemId"));
  1145. }
  1146. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  1147. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  1148. }
  1149. List<JSONObject> list = supplyChainService.exportUserItemDetail(requestMap);
  1150. List<List<Object>> exportList = new ArrayList<>();
  1151. if (!Check.isNull(list)) {
  1152. for (int i = 0; i < list.size(); i++) {
  1153. JSONObject date = list.get(i);
  1154. List<Object> export = new ArrayList();
  1155. export.add(date.getString("userName"));
  1156. export.add(date.getLong("itemId"));
  1157. export.add(date.getString("itemTitle"));
  1158. export.add(date.getString("reservePrice"));
  1159. export.add(date.getString("itemCommissionRate"));
  1160. export.add(date.getString("orderNum"));
  1161. export.add(date.getString("validOrderNUm"));
  1162. export.add(date.getString("validRadio"));
  1163. export.add(date.getString("invalidOrderNUm"));
  1164. export.add(date.getString("deliveryNum"));
  1165. export.add(date.getString("deliveryRadio"));
  1166. export.add(date.getString("notDeliveryNum"));
  1167. export.add(date.getString("payAmount"));
  1168. export.add(date.getString("regimentalPromotionRate"));
  1169. export.add(date.getString("regimentalPromotionAmount"));
  1170. export.add(date.getString("totalRegimentalSettleAmount"));
  1171. export.add(date.getString("imageUrl"));
  1172. exportList.add(export);
  1173. }
  1174. }
  1175. String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "结算服务费收入", "商品封面"};
  1176. OutputStream os = response.getOutputStream();
  1177. ExportExcelUtils eeu = new ExportExcelUtils();
  1178. XSSFWorkbook workbook = new XSSFWorkbook();
  1179. eeu.exportExcel(workbook, 0, "认领列表", headers, exportList);
  1180. this.setResponseHeader(response, "认领列表.xls");
  1181. workbook.write(os);
  1182. os.flush();
  1183. os.close();
  1184. }
  1185. @GetMapping("/userItemTotal")
  1186. @ApiOperation(value = "认领商品列表汇总")
  1187. public JSONObject userItemTotal(
  1188. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  1189. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1190. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate
  1191. ) {
  1192. Map<String, Object> requestMap = new HashMap<>();
  1193. if (!Check.isNull(userId)) {
  1194. requestMap.put("userId", userId);
  1195. }
  1196. if (!Check.isNull(orderStartDate)) {
  1197. Long start = DateUtils.getStartLongTime(orderStartDate);
  1198. requestMap.put("start", start);
  1199. }
  1200. if (!Check.isNull(orderEndDate)) {
  1201. Long end = DateUtils.getEndLongTime(orderEndDate);
  1202. requestMap.put("end", end);
  1203. }
  1204. JSONObject returnJson = supplyChainService.userItemTotal(requestMap);
  1205. return returnJson;
  1206. }
  1207. /**
  1208. * 商品认领汇总
  1209. *
  1210. * @return
  1211. */
  1212. @GetMapping("/itemBindSummary")
  1213. @ApiOperation(value = "商品认领汇总")
  1214. public JSONObject itemBindSummary() {
  1215. JSONObject json = supplyChainService.itemBindSummary();
  1216. return json;
  1217. }
  1218. /**
  1219. * 首页-时段对比
  1220. *
  1221. * @param orderStartDate
  1222. * @param orderEndDate
  1223. * @return
  1224. */
  1225. @SneakyThrows
  1226. @GetMapping("/indexTimeIntervalRatio")
  1227. @ApiOperation(value = "首页-时段对比")
  1228. public JSONObject indexTimeIntervalRatio(
  1229. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1230. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  1231. Map<String, Object> requestMap = new HashMap<>();
  1232. String nowDate = DateUtils.getNowDateStr();
  1233. String thisCycleEnd = null; // 当前时段结束日期
  1234. String thisCycleStart = null; // 当前时段开始日期
  1235. String lastCycleEnd = null; // 上一时段结束日期
  1236. String lastCycleStart = null; // 上一时段开始日期
  1237. if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
  1238. thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
  1239. thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6);
  1240. lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1);
  1241. lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6);
  1242. } else {
  1243. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  1244. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate));
  1245. thisCycleEnd = orderEndDate;
  1246. thisCycleStart = orderStartDate;
  1247. lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1);
  1248. lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay);
  1249. }
  1250. if (!Check.isNull(thisCycleStart)) {
  1251. Long thisCycleStartTemp = DateUtils.getStartLongTime(thisCycleStart);
  1252. requestMap.put("thisCycleStartTemp", thisCycleStartTemp);
  1253. }
  1254. if (!Check.isNull(thisCycleEnd)) {
  1255. Long thisCycleEndTemp = DateUtils.getEndLongTime(thisCycleEnd);
  1256. requestMap.put("thisCycleEndTemp", thisCycleEndTemp);
  1257. }
  1258. if (!Check.isNull(lastCycleStart)) {
  1259. Long lastCycleStartTemp = DateUtils.getStartLongTime(lastCycleStart);
  1260. requestMap.put("lastCycleStartTemp", lastCycleStartTemp);
  1261. }
  1262. if (!Check.isNull(lastCycleEnd)) {
  1263. Long lastCycleEndTemp = DateUtils.getEndLongTime(lastCycleEnd);
  1264. requestMap.put("lastCycleEndTemp", lastCycleEndTemp);
  1265. }
  1266. JSONObject timeIntervalRatioJson = supplyChainService.getTimeIntervalRatio(requestMap);
  1267. return timeIntervalRatioJson;
  1268. }
  1269. /**
  1270. * 首页-统计图
  1271. *
  1272. * @param orderStartDate
  1273. * @param orderEndDate
  1274. * @param type
  1275. * @return
  1276. */
  1277. @GetMapping("/indexStatistics")
  1278. @ApiOperation(value = "首页-统计图")
  1279. public List<JSONObject> indexStatistics(
  1280. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1281. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1282. @ApiParam("类型") @RequestParam(value = "type", required = false) String type) {
  1283. Map<String, Object> requestMap = new HashMap<>();
  1284. String nowDate = DateUtils.getNowDateStr();
  1285. String start = null;
  1286. String end = null;
  1287. if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
  1288. end = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
  1289. start = DateUtils.getAnotherDay("yyyy-MM-dd", end, -6);
  1290. } else {
  1291. start = orderStartDate;
  1292. end = orderEndDate;
  1293. }
  1294. if (!Check.isNull(start)) {
  1295. Long startTemp = DateUtils.getStartLongTime(start);
  1296. requestMap.put("startTemp", startTemp);
  1297. }
  1298. if (!Check.isNull(end)) {
  1299. Long endTemp = DateUtils.getEndLongTime(end);
  1300. requestMap.put("endTemp", endTemp);
  1301. }
  1302. if (!Check.isNull(type)) {
  1303. requestMap.put("type", type);
  1304. }
  1305. List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
  1306. return list;
  1307. }
  1308. //发送响应流方法
  1309. public void setResponseHeader(HttpServletResponse response, String fileName) {
  1310. try {
  1311. try {
  1312. fileName = new String(fileName.getBytes(), "ISO8859-1");
  1313. } catch (UnsupportedEncodingException e) {
  1314. e.printStackTrace();
  1315. }
  1316. response.setContentType("application/octet-stream;charset=ISO8859-1");
  1317. response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
  1318. response.addHeader("Pargam", "no-cache");
  1319. response.addHeader("Cache-Control", "no-cache");
  1320. } catch (Exception ex) {
  1321. ex.printStackTrace();
  1322. }
  1323. }
  1324. @GetMapping("/bdReportList")
  1325. @ApiOperation(value = "供应链管理员统计列表")
  1326. public TableDataInfo bdReportList(
  1327. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1328. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1329. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1330. Map<String, Object> requestMap = new HashMap<>();
  1331. if (!Check.isNull(orderStartDate)) {
  1332. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1333. requestMap.put("start", start);
  1334. }
  1335. if (!Check.isNull(orderEndDate)) {
  1336. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1337. requestMap.put("end", end);
  1338. }
  1339. if (!Check.isNull(collectSampleId)) {
  1340. requestMap.put("collectSampleId", collectSampleId);
  1341. }
  1342. TableDataInfo dataInfo = new TableDataInfo();
  1343. if (Check.isNullMap(requestMap)) {
  1344. dataInfo.setCode(500);
  1345. dataInfo.setMsg("入参不能为空");
  1346. return dataInfo;
  1347. }
  1348. startPage();
  1349. List<JSONObject> list = supplyChainService.bdReportList(requestMap);
  1350. return getDataTable(list);
  1351. }
  1352. @PostMapping("/exportBdReportList")
  1353. @ApiOperation(value = "供应链管理员统计列表")
  1354. @ResponseBody
  1355. public void exportBdReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1356. Map<String, Object> requestMap = new HashMap<>();
  1357. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1358. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1359. requestMap.put("start", start);
  1360. }
  1361. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1362. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1363. requestMap.put("end", end);
  1364. }
  1365. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1366. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1367. }
  1368. List<JSONObject> list = supplyChainService.exportBdReportList(requestMap);
  1369. List<List<Object>> exportList = new ArrayList<>();
  1370. if (!Check.isNull(list)) {
  1371. for (int i = 0; i < list.size(); i++) {
  1372. JSONObject date = list.get(i);
  1373. List<Object> export = new ArrayList();
  1374. export.add(date.getString("collectSampleId"));
  1375. export.add(date.getString("collectSampleName"));
  1376. export.add(date.getString("promoterCount"));
  1377. export.add(date.getString("sampleCount"));
  1378. export.add(date.getString("sampleRate"));
  1379. export.add(date.getString("notSampleCount"));
  1380. export.add(date.getString("sendTotalCount"));
  1381. export.add(date.getString("sendPromoterCount"));
  1382. export.add(date.getString("sendItemCount"));
  1383. export.add(date.getString("orderNum"));
  1384. export.add(date.getString("voucherOrderNum"));
  1385. export.add(date.getString("validOrderNum"));
  1386. export.add(date.getString("voucherValidOrderNum"));
  1387. export.add(date.getString("validOrderRate"));
  1388. export.add(date.getString("orderAmount"));
  1389. export.add(date.getString("voucherOrderAmount"));
  1390. export.add(date.getString("regimentalPromotionAmount"));
  1391. export.add(date.getString("voucherRegimentalPromotionAmount"));
  1392. export.add(date.getString("totalRegimentalSettleAmount"));
  1393. export.add(date.getString("voucherTotalRegimentalSettleAmount"));
  1394. exportList.add(export);
  1395. }
  1396. }
  1397. String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "(凭)订单数", "有效订单数", "(凭)有效订单数", "有效订单率", "订单金额", "凭(订单金额)", "预估服务费", "(凭)预估服务费", "结算服务费", "(凭)结算服务费"};
  1398. OutputStream os = response.getOutputStream();
  1399. ExportExcelUtils eeu = new ExportExcelUtils();
  1400. XSSFWorkbook workbook = new XSSFWorkbook();
  1401. eeu.exportExcel(workbook, 0, "bd业绩汇总", headers, exportList);
  1402. this.setResponseHeader(response, "bd业绩汇总.xls");
  1403. workbook.write(os);
  1404. os.flush();
  1405. os.close();
  1406. }
  1407. @GetMapping("/bdDetailList")
  1408. @ApiOperation(value = "供应链管理员统计列表")
  1409. public TableDataInfo bdDetailList(
  1410. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1411. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1412. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
  1413. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1414. @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
  1415. Map<String, Object> requestMap = new HashMap<>();
  1416. if (!Check.isNull(orderStartDate)) {
  1417. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1418. requestMap.put("start", start);
  1419. }
  1420. if (!Check.isNull(orderEndDate)) {
  1421. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1422. requestMap.put("end", end);
  1423. }
  1424. if (!Check.isNull(collectSampleId)) {
  1425. requestMap.put("collectSampleId", collectSampleId);
  1426. }
  1427. requestMap.put("fieId", fieId);
  1428. requestMap.put("sort", sort);
  1429. TableDataInfo dataInfo = new TableDataInfo();
  1430. if (Check.isNullMap(requestMap)) {
  1431. dataInfo.setCode(500);
  1432. dataInfo.setMsg("入参不能为空");
  1433. return dataInfo;
  1434. }
  1435. startPage();
  1436. List<JSONObject> list = supplyChainService.bdDetailList(requestMap);
  1437. return getDataTable(list);
  1438. }
  1439. @GetMapping("/bdTotal")
  1440. @ApiOperation(value = "供应链管理员统计列表")
  1441. public TableDataInfo bdTotal(
  1442. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1443. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1444. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1445. Map<String, Object> requestMap = new HashMap<>();
  1446. if (!Check.isNull(orderStartDate)) {
  1447. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1448. requestMap.put("start", start);
  1449. }
  1450. if (!Check.isNull(orderEndDate)) {
  1451. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1452. requestMap.put("end", end);
  1453. }
  1454. if (!Check.isNull(collectSampleId)) {
  1455. requestMap.put("collectSampleId", collectSampleId);
  1456. }
  1457. TableDataInfo dataInfo = new TableDataInfo();
  1458. if (Check.isNullMap(requestMap)) {
  1459. dataInfo.setCode(500);
  1460. dataInfo.setMsg("入参不能为空");
  1461. return dataInfo;
  1462. }
  1463. startPage();
  1464. List<JSONObject> list = supplyChainService.bdTotal(requestMap);
  1465. return getDataTable(list);
  1466. }
  1467. @PostMapping("/exportBdDetail")
  1468. @ApiOperation(value = "认领商品列表")
  1469. @ResponseBody
  1470. public void exportBdDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1471. Map<String, Object> requestMap = new HashMap<>();
  1472. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1473. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1474. requestMap.put("start", start);
  1475. }
  1476. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1477. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1478. requestMap.put("end", end);
  1479. }
  1480. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1481. requestMap.put("collectSampleId", (requestJson.getLong("collectSampleId")));
  1482. }
  1483. List<JSONObject> list = supplyChainService.exportBdDetail(requestMap);
  1484. List<List<Object>> exportList = new ArrayList<>();
  1485. if (!Check.isNull(list)) {
  1486. for (int i = 0; i < list.size(); i++) {
  1487. JSONObject date = list.get(i);
  1488. List<Object> export = new ArrayList();
  1489. export.add(date.getString("promoterId"));
  1490. export.add(date.getString("promoterName"));
  1491. export.add(date.getString("sampleCount"));
  1492. export.add(date.getString("orderNum"));
  1493. export.add(date.getString("validOrderNum"));
  1494. export.add(date.getString("validOrderRate"));
  1495. export.add(date.getString("regimentalPromotionAmount"));
  1496. export.add(date.getString("totalRegimentalSettleAmount"));
  1497. export.add(date.getString("promoterUrl"));
  1498. exportList.add(export);
  1499. }
  1500. }
  1501. String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
  1502. OutputStream os = response.getOutputStream();
  1503. ExportExcelUtils eeu = new ExportExcelUtils();
  1504. XSSFWorkbook workbook = new XSSFWorkbook();
  1505. eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
  1506. this.setResponseHeader(response, "bd业绩.xls");
  1507. workbook.write(os);
  1508. os.flush();
  1509. os.close();
  1510. }
  1511. @GetMapping("/bdReportListV2")
  1512. @ApiOperation(value = "供应链管理员统计列表")
  1513. public TableDataInfo bdReportListV2(
  1514. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1515. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1516. @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
  1517. @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
  1518. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1519. Map<String, Object> requestMap = new HashMap<>();
  1520. if (!Check.isNull(orderStartDate)) {
  1521. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1522. requestMap.put("start", start);
  1523. }
  1524. if (!Check.isNull(orderEndDate)) {
  1525. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1526. requestMap.put("end", end);
  1527. }
  1528. if (!Check.isNull(collectSampleId)) {
  1529. requestMap.put("collectSampleId", collectSampleId);
  1530. }
  1531. if (!Check.isNull(bindStartDate)) {
  1532. Integer start = DateUtils.getIntegerTime(bindStartDate);
  1533. requestMap.put("bindStartDate", start);
  1534. }
  1535. if (!Check.isNull(bindEndDate)) {
  1536. Integer end = DateUtils.getIntegerTime(bindEndDate);
  1537. requestMap.put("bindEndDate", end);
  1538. }
  1539. TableDataInfo dataInfo = new TableDataInfo();
  1540. if (Check.isNullMap(requestMap)) {
  1541. dataInfo.setCode(500);
  1542. dataInfo.setMsg("入参不能为空");
  1543. return dataInfo;
  1544. }
  1545. startPage();
  1546. List<JSONObject> list = new ArrayList<>();
  1547. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  1548. list = supplyChainService.bdReportListV2(requestMap);
  1549. } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  1550. list = supplyChainService.bdReportListV2ByBind(requestMap);
  1551. }
  1552. return getDataTable(list);
  1553. }
  1554. @PostMapping("/exportBdReportListV2")
  1555. @ApiOperation(value = "供应链管理员统计列表")
  1556. @ResponseBody
  1557. public void exportBdReportListV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1558. Map<String, Object> requestMap = new HashMap<>();
  1559. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1560. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1561. requestMap.put("start", start);
  1562. }
  1563. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1564. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1565. requestMap.put("end", end);
  1566. }
  1567. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1568. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1569. }
  1570. if (!Check.isNull(requestJson.getString("bindStartDate"))) {
  1571. Integer start = DateUtils.getIntegerTime(requestJson.getString("bindStartDate"));
  1572. requestMap.put("bindStartDate", start);
  1573. }
  1574. if (!Check.isNull(requestJson.getString("bindEndDate"))) {
  1575. Integer end = DateUtils.getIntegerTime(requestJson.getString("bindEndDate"));
  1576. requestMap.put("bindEndDate", end);
  1577. }
  1578. List<JSONObject> list = new ArrayList<>();
  1579. if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
  1580. list = supplyChainService.bdReportListV2(requestMap);
  1581. } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
  1582. list = supplyChainService.bdReportListV2ByBind(requestMap);
  1583. }
  1584. List<List<Object>> exportList = new ArrayList<>();
  1585. if (!Check.isNull(list)) {
  1586. for (int i = 0; i < list.size(); i++) {
  1587. JSONObject date = list.get(i);
  1588. List<Object> export = new ArrayList();
  1589. export.add(date.getString("collectSampleId"));
  1590. export.add(date.getString("collectSampleName"));
  1591. export.add(date.getString("promoterCount"));
  1592. export.add(date.getString("sampleCount"));
  1593. export.add(date.getString("sampleRate"));
  1594. export.add(date.getString("notSampleCount"));
  1595. export.add(date.getString("sendTotalCount"));
  1596. export.add(date.getString("sendPromoterCount"));
  1597. export.add(date.getString("sendItemCount"));
  1598. export.add(date.getString("orderNum"));
  1599. export.add(date.getString("validOrderNum"));
  1600. export.add(date.getString("validOrderRate"));
  1601. export.add(date.getString("orderAmount"));
  1602. export.add(date.getString("regimentalPromotionAmount"));
  1603. export.add(date.getString("totalRegimentalSettleAmount"));
  1604. exportList.add(export);
  1605. }
  1606. }
  1607. String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "有效订单数", "有效订单率", "订单金额", "预估服务费", "结算服务费"};
  1608. OutputStream os = response.getOutputStream();
  1609. ExportExcelUtils eeu = new ExportExcelUtils();
  1610. XSSFWorkbook workbook = new XSSFWorkbook();
  1611. eeu.exportExcel(workbook, 0, "bd业绩汇总V2", headers, exportList);
  1612. this.setResponseHeader(response, "bd业绩汇总V2.xls");
  1613. workbook.write(os);
  1614. os.flush();
  1615. os.close();
  1616. }
  1617. @GetMapping("/bdTotalV2")
  1618. @ApiOperation(value = "供应链管理员统计列表")
  1619. public TableDataInfo bdTotalV2(
  1620. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1621. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1622. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1623. Map<String, Object> requestMap = new HashMap<>();
  1624. if (!Check.isNull(orderStartDate)) {
  1625. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1626. requestMap.put("start", start);
  1627. }
  1628. if (!Check.isNull(orderEndDate)) {
  1629. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1630. requestMap.put("end", end);
  1631. }
  1632. if (!Check.isNull(collectSampleId)) {
  1633. requestMap.put("collectSampleId", collectSampleId);
  1634. }
  1635. TableDataInfo dataInfo = new TableDataInfo();
  1636. if (Check.isNullMap(requestMap)) {
  1637. dataInfo.setCode(500);
  1638. dataInfo.setMsg("入参不能为空");
  1639. return dataInfo;
  1640. }
  1641. startPage();
  1642. List<JSONObject> list = supplyChainService.bdTotalV2(requestMap);
  1643. return getDataTable(list);
  1644. }
  1645. @GetMapping("/bdDetailListV2")
  1646. @ApiOperation(value = "供应链管理员统计列表")
  1647. public TableDataInfo bdDetailListV2(
  1648. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1649. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1650. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
  1651. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1652. @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
  1653. Map<String, Object> requestMap = new HashMap<>();
  1654. if (!Check.isNull(orderStartDate)) {
  1655. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1656. requestMap.put("start", start);
  1657. }
  1658. if (!Check.isNull(orderEndDate)) {
  1659. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1660. requestMap.put("end", end);
  1661. }
  1662. if (!Check.isNull(collectSampleId)) {
  1663. requestMap.put("collectSampleId", collectSampleId);
  1664. }
  1665. requestMap.put("fieId", fieId);
  1666. requestMap.put("sort", sort);
  1667. TableDataInfo dataInfo = new TableDataInfo();
  1668. if (Check.isNullMap(requestMap)) {
  1669. dataInfo.setCode(500);
  1670. dataInfo.setMsg("入参不能为空");
  1671. return dataInfo;
  1672. }
  1673. startPage();
  1674. List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
  1675. return getDataTable(list);
  1676. }
  1677. @PostMapping("/exportBdDetailV2")
  1678. @ApiOperation(value = "认领商品列表")
  1679. @ResponseBody
  1680. public void exportBdDetailV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1681. Map<String, Object> requestMap = new HashMap<>();
  1682. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1683. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1684. requestMap.put("start", start);
  1685. }
  1686. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1687. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1688. requestMap.put("end", end);
  1689. }
  1690. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1691. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1692. }
  1693. requestMap.put("fieId", "orderNum");
  1694. requestMap.put("sort", "desc");
  1695. List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
  1696. List<List<Object>> exportList = new ArrayList<>();
  1697. if (!Check.isNull(list)) {
  1698. for (int i = 0; i < list.size(); i++) {
  1699. JSONObject date = list.get(i);
  1700. List<Object> export = new ArrayList();
  1701. export.add(date.getString("promoterId"));
  1702. export.add(date.getString("promoterName"));
  1703. export.add(date.getString("sampleCount"));
  1704. export.add(date.getString("orderNum"));
  1705. export.add(date.getString("validOrderNum"));
  1706. export.add(date.getString("validOrderRate"));
  1707. export.add(date.getString("regimentalPromotionAmount"));
  1708. export.add(date.getString("totalRegimentalSettleAmount"));
  1709. export.add(date.getString("promoterUrl"));
  1710. exportList.add(export);
  1711. }
  1712. }
  1713. String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
  1714. OutputStream os = response.getOutputStream();
  1715. ExportExcelUtils eeu = new ExportExcelUtils();
  1716. XSSFWorkbook workbook = new XSSFWorkbook();
  1717. eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
  1718. this.setResponseHeader(response, "bd业绩.xls");
  1719. workbook.write(os);
  1720. os.flush();
  1721. os.close();
  1722. }
  1723. }