SupplyChainController.java 86 KB

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