SupplyChainController.java 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581
  1. package com.ruixuan.isc.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.kuaishou.merchant.open.api.KsMerchantApiException;
  4. import com.kuaishou.merchant.open.api.common.utils.PlatformEventSecurityUtil;
  5. import com.ruixuan.common.core.controller.BaseController;
  6. import com.ruixuan.common.core.page.TableDataInfo;
  7. import com.ruixuan.common.utils.Check;
  8. import com.ruixuan.common.utils.DateUtils;
  9. import com.ruixuan.data.utils.ExportExcelUtils;
  10. import com.ruixuan.isc.service.IKuaishouPromoterService;
  11. import com.ruixuan.isc.service.ISupplyChainService;
  12. import com.ruixuan.system.service.ISysDeptService;
  13. import com.ruixuan.system.service.ISysUserService;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.annotations.ApiParam;
  16. import lombok.SneakyThrows;
  17. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.web.bind.annotation.GetMapping;
  21. import org.springframework.web.bind.annotation.PostMapping;
  22. import org.springframework.web.bind.annotation.RequestBody;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestParam;
  25. import org.springframework.web.bind.annotation.ResponseBody;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import javax.servlet.http.HttpServletRequest;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.IOException;
  30. import java.io.OutputStream;
  31. import java.io.UnsupportedEncodingException;
  32. import java.text.SimpleDateFormat;
  33. import java.util.ArrayList;
  34. import java.util.Arrays;
  35. import java.util.HashMap;
  36. import java.util.List;
  37. import java.util.Map;
  38. import java.util.concurrent.ExecutorService;
  39. import java.util.concurrent.Executors;
  40. @RestController
  41. @RequestMapping("/isv/supply_chain")
  42. public class SupplyChainController extends BaseController {
  43. @Autowired
  44. private ISupplyChainService supplyChainService;
  45. @Autowired
  46. private IKuaishouPromoterService promoterService;
  47. @Value("${accept.ruiXuanPrivateKey}")
  48. private String ruiXuanPrivateKey;
  49. @Value("${accept.mgsPrivateKey}")
  50. private String mgsPrivateKey;
  51. @Value("${accept.rocketPrivateKey}")
  52. private String rocketPrivateKey;
  53. @Value("${accept.dfcPrivateKey}")
  54. private String dfcPrivateKey;
  55. @Value("${accept.mgsPrivateKey2}")
  56. private String mgsPrivateKey2;
  57. @Value("${accept.yufuPrivateKey}")
  58. private String yufuPrivateKey;
  59. @Value("${ownership.id}")
  60. private String ownershipId;
  61. @GetMapping("/privateKey")
  62. @ApiOperation(value = "达人订单")
  63. public String privateKey() {
  64. return ruiXuanPrivateKey;
  65. }
  66. /**
  67. * 达人订单
  68. *
  69. * @param orderStartDate
  70. * @param orderEndDate
  71. * @param promoterNickName
  72. * @param promoterId
  73. * @return
  74. */
  75. @GetMapping("/orderList")
  76. @ApiOperation(value = "达人订单")
  77. public TableDataInfo orderList(@ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  78. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  79. @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
  80. @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId) {
  81. Map<String, Object> requestMap = new HashMap<>();
  82. if (!Check.isNull(orderStartDate)) {
  83. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  84. //根据本阶段日期 获取上阶段 开始 和 截至 日期
  85. Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
  86. //下个周期的开始时间
  87. String lastTimeStart = map.get("lastTimeStart");
  88. //下个周期的结束时间
  89. String lastTimeEnd = map.get("lastTimeEnd");
  90. //当前小时
  91. Integer hour = DateUtils.getNowHour() - 1;
  92. //当天 yyyy-MM-dd
  93. String today = DateUtils.getNowDateStr();
  94. if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
  95. hour = 23;
  96. }
  97. requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
  98. requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
  99. requestMap.put("hour", hour);
  100. }
  101. if (!Check.isNull(orderEndDate)) {
  102. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  103. }
  104. if (!Check.isNull(promoterNickName)) {
  105. requestMap.put("promoterNickName", promoterNickName);
  106. }
  107. if (!Check.isNull(promoterId)) {
  108. requestMap.put("promoterId", promoterId);
  109. }
  110. TableDataInfo dataInfo = new TableDataInfo();
  111. if (Check.isNullMap(requestMap)) {
  112. dataInfo.setCode(-1);
  113. dataInfo.setMsg("入参不能为空");
  114. return dataInfo;
  115. }
  116. startPage();
  117. List<JSONObject> list = supplyChainService.getOrderList(requestMap);
  118. return getDataTable(list);
  119. }
  120. /**
  121. * 达人带货详情
  122. *
  123. * @param promoterId
  124. * @param orderStartDate
  125. * @param orderEndDate
  126. * @param itemTitle
  127. * @param itemId
  128. * @return
  129. */
  130. @GetMapping("/anchorOrderDetail")
  131. @ApiOperation(value = "达人带货详情")
  132. public TableDataInfo anchorOrderDetail(
  133. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  134. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  135. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  136. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  137. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId) {
  138. Map<String, Object> requestMap = new HashMap<>();
  139. if (!Check.isNull(orderStartDate)) {
  140. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  141. }
  142. if (!Check.isNull(orderEndDate)) {
  143. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  144. }
  145. if (!Check.isNull(promoterId)) {
  146. requestMap.put("promoterId", promoterId);
  147. }
  148. if (!Check.isNull(itemId)) {
  149. requestMap.put("itemId", itemId);
  150. }
  151. if (!Check.isNull(itemTitle)) {
  152. requestMap.put("itemTitle", itemTitle);
  153. }
  154. TableDataInfo dataInfo = new TableDataInfo();
  155. if (Check.isNullMap(requestMap)) {
  156. dataInfo.setCode(-1);
  157. dataInfo.setMsg("入参不能为空");
  158. return dataInfo;
  159. }
  160. startPage();
  161. List<JSONObject> list = supplyChainService.anchorOrderDetail(requestMap);
  162. return getDataTable(list);
  163. }
  164. /**
  165. * 订单统计
  166. *
  167. * @param promoterId
  168. * @param orderStartDate
  169. * @param orderEndDate
  170. * @return
  171. */
  172. @GetMapping("/orderStatistics")
  173. @ApiOperation(value = "订单统计")
  174. public JSONObject orderStatistics(
  175. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  176. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  177. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  178. Map<String, Object> requestMap = new HashMap<>();
  179. if (!Check.isNull(orderStartDate)) {
  180. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  181. }
  182. if (!Check.isNull(orderEndDate)) {
  183. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  184. }
  185. if (!Check.isNull(promoterId)) {
  186. requestMap.put("promoterId", promoterId);
  187. }
  188. JSONObject returnJson = new JSONObject();
  189. if (Check.isNullMap(requestMap)) {
  190. returnJson.put("code", -1);
  191. returnJson.put("message", "入参不能为空");
  192. return returnJson;
  193. }
  194. List<JSONObject> list = supplyChainService.orderStatistics(requestMap);
  195. returnJson.put("code", 0);
  196. returnJson.put("data", list);
  197. return returnJson;
  198. }
  199. /**
  200. * 商品列表
  201. *
  202. * @param itemId
  203. * @param itemTitle
  204. * @param orderStartDate
  205. * @param orderEndDate
  206. * @return
  207. */
  208. @GetMapping("/itemList")
  209. @ApiOperation(value = "商品列表")
  210. public TableDataInfo itemList(
  211. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  212. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  213. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  214. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  215. @ApiParam("开始时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
  216. @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
  217. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  218. @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort,
  219. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId) {
  220. Map<String, Object> requestMap = new HashMap<>();
  221. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  222. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  223. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  224. //根据本阶段日期 获取上阶段 开始 和 截至 日期
  225. Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
  226. //下个周期的开始时间
  227. String lastTimeStart = map.get("lastTimeStart");
  228. //下个周期的结束时间
  229. String lastTimeEnd = map.get("lastTimeEnd");
  230. //当前小时
  231. Integer hour = DateUtils.getNowHour() - 1;
  232. //当天 yyyy-MM-dd
  233. String today = DateUtils.getNowDateStr();
  234. if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
  235. hour = 23;
  236. }
  237. requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
  238. requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
  239. requestMap.put("hour", hour);
  240. }
  241. if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  242. requestMap.put("start", DateUtils.strDateToInt(bindStartDate));
  243. requestMap.put("bindStartDate", bindStartDate);
  244. requestMap.put("end", DateUtils.strDateToInt(bindEndDate));
  245. requestMap.put("bindEndDate", bindEndDate);
  246. }
  247. if (!Check.isNull(itemId)) {
  248. requestMap.put("itemId", itemId);
  249. }
  250. if (!Check.isNull(itemTitle)) {
  251. requestMap.put("itemTitle", itemTitle);
  252. }
  253. if (!Check.isNull(userId)) {
  254. requestMap.put("userId", userId);
  255. }
  256. requestMap.put("fieId", fieId);
  257. requestMap.put("sort", sort);
  258. TableDataInfo dataInfo = new TableDataInfo();
  259. if (Check.isNullMap(requestMap)) {
  260. dataInfo.setCode(-1);
  261. dataInfo.setMsg("入参不能为空");
  262. return dataInfo;
  263. }
  264. startPage();
  265. List<JSONObject> list = new ArrayList<>();
  266. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  267. list = supplyChainService.itemList(requestMap);
  268. } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  269. list = supplyChainService.itemBindList(requestMap);
  270. }
  271. return getDataTable(list);
  272. }
  273. @RequestMapping(value = "/exportOrder")
  274. @ResponseBody
  275. public void exportOrder(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  276. Map<String, Object> requestMap = new HashMap<>();
  277. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  278. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
  279. }
  280. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  281. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
  282. }
  283. if (!Check.isNull(requestJson.getString("bindStartDate"))) {
  284. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("bindStartDate")));
  285. requestMap.put("bindStartDate", requestJson.getString("bindStartDate"));
  286. }
  287. if (!Check.isNull(requestJson.getString("bindEndDate"))) {
  288. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("bindEndDate")));
  289. requestMap.put("bindEndDate", requestJson.getString("bindEndDate"));
  290. }
  291. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  292. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  293. }
  294. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  295. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  296. }
  297. if (!Check.isNull(requestJson.getLong("itemId"))) {
  298. requestMap.put("itemId", requestJson.getLong("itemId"));
  299. }
  300. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  301. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  302. }
  303. if (!Check.isNull(requestJson.getLong("userId"))) {
  304. requestMap.put("userId", requestJson.getLong("userId"));
  305. }
  306. List<JSONObject> list = new ArrayList<>();
  307. if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
  308. list = supplyChainService.exportOrder(requestMap);
  309. } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
  310. list = supplyChainService.exportBindOrder(requestMap);
  311. }
  312. List<List<Object>> exportList = new ArrayList<>();
  313. if (!Check.isNull(list)) {
  314. for (int i = 0; i < list.size(); i++) {
  315. JSONObject date = list.get(i);
  316. List<Object> export = new ArrayList();
  317. export.add(date.getString("userName"));
  318. export.add(date.getLong("itemId"));
  319. export.add(date.getString("itemTitle"));
  320. export.add(date.getString("isPresale"));
  321. export.add(date.getString("imageUrl"));
  322. export.add(date.getString("itemCommissionRate"));
  323. export.add(date.getInteger("orderNum"));
  324. export.add(date.getInteger("validOrderNUm"));
  325. export.add(date.getString("validRadio"));
  326. export.add(date.getString("deliveryNum"));
  327. export.add(date.getString("deliveryRadio"));
  328. export.add(date.getString("notDeliveryNum"));
  329. export.add(date.getString("ccrValue"));
  330. export.add(date.getString("shopStar"));
  331. export.add(date.getString("mallLogisticsScore"));
  332. export.add(date.getString("shopScore"));
  333. export.add(date.getString("mallServiceScore"));
  334. export.add(date.getString("mallQualityScore"));
  335. exportList.add(export);
  336. }
  337. }
  338. String[] headers = {"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
  339. OutputStream os = response.getOutputStream();
  340. ExportExcelUtils eeu = new ExportExcelUtils();
  341. XSSFWorkbook workbook = new XSSFWorkbook();
  342. eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
  343. this.setResponseHeader(response, "订单信息.xls");
  344. workbook.write(os);
  345. os.flush();
  346. os.close();
  347. }
  348. /**
  349. * 根据商品id获取top达人
  350. *
  351. * @param itemId
  352. * @param orderStartDate
  353. * @param orderEndDate
  354. * @return
  355. */
  356. @GetMapping("/getTopPromoterByItemId")
  357. @ApiOperation(value = "商品列表")
  358. public TableDataInfo getTopPromoterByItemId(
  359. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  360. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  361. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  362. Map<String, Object> requestMap = new HashMap<>();
  363. if (!Check.isNull(orderStartDate)) {
  364. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  365. }
  366. if (!Check.isNull(orderEndDate)) {
  367. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  368. }
  369. if (!Check.isNull(itemId)) {
  370. requestMap.put("itemId", itemId);
  371. }
  372. List<JSONObject> list = supplyChainService.getTopPromoterByItemId(requestMap);
  373. return getDataTable(list);
  374. }
  375. /**
  376. * 商品详情
  377. *
  378. * @param itemId
  379. * @param orderStartDate
  380. * @param orderEndDate
  381. * @param promoterId
  382. * @param promoterNickName
  383. * @return
  384. */
  385. @GetMapping("/itemDetail")
  386. @ApiOperation(value = "商品详情")
  387. public TableDataInfo itemDetail(
  388. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId,
  389. @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  390. @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  391. @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
  392. @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
  393. @ApiParam("渠道名称") @RequestParam(value = "userId", required = false) Integer userId
  394. ) {
  395. Map<String, Object> requestMap = new HashMap<>();
  396. if (!Check.isNull(orderStartDate)) {
  397. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  398. }
  399. if (!Check.isNull(orderEndDate)) {
  400. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  401. }
  402. if (!Check.isNull(promoterId)) {
  403. requestMap.put("promoterId", promoterId);
  404. }
  405. if (!Check.isNull(itemId)) {
  406. requestMap.put("itemId", itemId);
  407. }
  408. if (!Check.isNull(promoterNickName)) {
  409. requestMap.put("itemTitle", promoterNickName);
  410. }
  411. if (!Check.isNull(userId)) {
  412. requestMap.put("userId", userId);
  413. }
  414. TableDataInfo dataInfo = new TableDataInfo();
  415. if (Check.isNullMap(requestMap)) {
  416. dataInfo.setCode(-1);
  417. dataInfo.setMsg("入参不能为空");
  418. return dataInfo;
  419. }
  420. startPage();
  421. List<JSONObject> list = supplyChainService.itemDetail(requestMap);
  422. return getDataTable(list);
  423. }
  424. @PostMapping("/exportItemDetail")
  425. @ResponseBody
  426. public void exportItemDetail(
  427. HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson
  428. ) throws IOException {
  429. Map<String, Object> requestMap = new HashMap<>();
  430. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  431. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
  432. }
  433. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  434. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
  435. }
  436. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  437. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  438. }
  439. if (!Check.isNull(requestJson.getLong("itemId"))) {
  440. requestMap.put("itemId", requestJson.getLong("itemId"));
  441. }
  442. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  443. requestMap.put("itemTitle", requestJson.getString("promoterNickName"));
  444. }
  445. if (!Check.isNull(requestJson.getLong("userId"))) {
  446. requestMap.put("userId", requestJson.getLong("userId"));
  447. }
  448. List<JSONObject> list = supplyChainService.exportItemDetail(requestMap);
  449. List<List<Object>> exportList = new ArrayList<>();
  450. if (!Check.isNull(list)) {
  451. for (int i = 0; i < list.size(); i++) {
  452. JSONObject data = list.get(i);
  453. List<Object> export = new ArrayList();
  454. export.add(data.getString("userName"));
  455. String promoterNickName = data.getString("promoterNickName");
  456. String promoterId = data.getString("promoterId");
  457. String name = promoterNickName + "(" + promoterId + ")";
  458. export.add(name);
  459. export.add(data.getInteger("orderNum"));
  460. export.add(data.getString("validOrderNUm"));
  461. export.add(data.getString("validRadio"));
  462. export.add(data.getString("deliveryNum"));
  463. export.add(data.getString("shippingGreen"));
  464. export.add(data.getString("effDeliveryNum"));
  465. export.add(data.getString("deliveryRadio"));
  466. export.add(data.getString("notDeliveryNum"));
  467. export.add(data.getInteger("payAmount"));
  468. export.add(data.getString("regimentalPromotionRate"));
  469. exportList.add(export);
  470. }
  471. String[] headers = {"绑定人", "达人信息", "单量", "有效订单数", "有效率", "发货数", "发货率", "有效发货数", "有效发货率", "未发货数", "付款金额", "服务费率"};
  472. OutputStream os = response.getOutputStream();
  473. ExportExcelUtils eeu = new ExportExcelUtils();
  474. XSSFWorkbook workbook = new XSSFWorkbook();
  475. eeu.exportExcel(workbook, 0, "商品出单详情", headers, exportList);
  476. this.setResponseHeader(response, "商品出单详情.xls");
  477. workbook.write(os);
  478. os.flush();
  479. os.close();
  480. }
  481. }
  482. /**
  483. * 产品服务费
  484. *
  485. * @param itemId
  486. * @param itemTitle
  487. * @param orderStartDate
  488. * @param orderEndDate
  489. * @return
  490. */
  491. @GetMapping("/itemServiceCharge")
  492. @ApiOperation(value = "产品服务费")
  493. public TableDataInfo itemServiceCharge(
  494. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
  495. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  496. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  497. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  498. Map<String, Object> requestMap = new HashMap<>();
  499. if (!Check.isNull(orderStartDate)) {
  500. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  501. }
  502. if (!Check.isNull(orderEndDate)) {
  503. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  504. }
  505. if (!Check.isNull(itemId)) {
  506. requestMap.put("itemId", itemId);
  507. }
  508. if (!Check.isNull(itemTitle)) {
  509. requestMap.put("itemTitle", itemTitle);
  510. }
  511. TableDataInfo dataInfo = new TableDataInfo();
  512. if (Check.isNullMap(requestMap)) {
  513. dataInfo.setCode(-1);
  514. dataInfo.setMsg("入参不能为空");
  515. return dataInfo;
  516. }
  517. startPage();
  518. List<JSONObject> list = supplyChainService.itemServiceCharge(requestMap);
  519. return getDataTable(list);
  520. }
  521. /**
  522. * 首页-订单数据
  523. *
  524. * @param dateType
  525. * @param orderStartDate
  526. * @param orderEndDate
  527. * @return
  528. */
  529. @GetMapping("/indexOrderInfo")
  530. @ApiOperation(value = "首页-订单数据")
  531. public JSONObject orderTotal(
  532. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  533. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  534. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  535. Map<String, Object> requestMap = new HashMap<>();
  536. JSONObject returnJson = new JSONObject();
  537. if (dateType == 0) {
  538. if (!Check.isNull(orderStartDate)) {
  539. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  540. }
  541. if (!Check.isNull(orderEndDate)) {
  542. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  543. }
  544. JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
  545. returnJson.put("orderTotal", orderTotal);
  546. Integer hour = DateUtils.getNowHour() - 1; // 当前小时
  547. if (hour >= 0) {
  548. JSONObject ratioJson = new JSONObject();
  549. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
  550. // Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
  551. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  552. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳
  553. // Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
  554. Map<String, Object> ratioMap = new HashMap<>();
  555. ratioMap.put("nowStartHourTemp", nowStartHourTemp);
  556. ratioMap.put("hour", hour);
  557. ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  558. Double ringRatio = supplyChainService.getOrderTotalRatio(ratioMap); //环比
  559. ratioJson.put("ringRatio", ringRatio);
  560. String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
  561. Long yearStartHourTemp = DateUtils.strDateToInt(yearDay); //前7日开始时间戳
  562. // Long yearEndHourTemp = DateUtils.getNowEndHourTemp(yearDay, hour);//前7日结束时间戳
  563. ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
  564. Double yearRatio = supplyChainService.getOrderTotalRatio(ratioMap); //同比
  565. ratioJson.put("yearRatio", yearRatio);
  566. returnJson.put("ratio", ratioJson);
  567. }
  568. } else {
  569. if (!Check.isNull(orderStartDate)) {
  570. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  571. }
  572. if (!Check.isNull(orderEndDate)) {
  573. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  574. }
  575. JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
  576. returnJson.put("orderTotal", orderTotal);
  577. }
  578. return returnJson;
  579. }
  580. /**
  581. * 首页-金额数据
  582. *
  583. * @param dateType
  584. * @param orderStartDate
  585. * @param orderEndDate
  586. * @return
  587. */
  588. @GetMapping("/indexAmountInfo")
  589. @ApiOperation(value = "首页-金额数据")
  590. public JSONObject indexAmountInfo(
  591. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  592. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  593. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  594. Map<String, Object> requestMap = new HashMap<>();
  595. JSONObject returnJson = new JSONObject();
  596. if (dateType == 0) {
  597. if (!Check.isNull(orderStartDate)) {
  598. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  599. }
  600. if (!Check.isNull(orderEndDate)) {
  601. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  602. }
  603. JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
  604. returnJson.put("amountTotal", amountTotal);
  605. Integer hour = DateUtils.getNowHour() - 1; // 当前小时
  606. if (hour >= 0) {
  607. JSONObject amountRatioJson = new JSONObject();
  608. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
  609. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  610. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
  611. Map<String, Object> ratioMap = new HashMap<>();
  612. ratioMap.put("nowStartHourTemp", nowStartHourTemp);
  613. ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  614. ratioMap.put("hour", hour);
  615. Double amountRingRatio = supplyChainService.getAmountTotalRatio(ratioMap); //环比
  616. amountRatioJson.put("amountRingRatio", amountRingRatio);
  617. String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
  618. Long yearStartHourTemp = DateUtils.strDateToInt(yearDay); //前7日开始时间
  619. ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
  620. Double amountYearRatio = supplyChainService.getAmountTotalRatio(ratioMap); //同比
  621. amountRatioJson.put("amountYearRatio", amountYearRatio);
  622. returnJson.put("amountRatio", amountRatioJson);
  623. }
  624. } else {
  625. if (!Check.isNull(orderStartDate)) {
  626. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  627. }
  628. if (!Check.isNull(orderEndDate)) {
  629. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  630. }
  631. JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
  632. returnJson.put("amountTotal", amountTotal);
  633. }
  634. return returnJson;
  635. }
  636. /**
  637. * 首页-服务费数据
  638. *
  639. * @param dateType
  640. * @param orderStartDate
  641. * @param orderEndDate
  642. * @return
  643. */
  644. @GetMapping("/indexServiceAmountInfo")
  645. @ApiOperation(value = "首页-服务费数据")
  646. public JSONObject indexServiceAmountInfo(
  647. @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
  648. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  649. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  650. Map<String, Object> requestMap = new HashMap<>();
  651. JSONObject returnJson = new JSONObject();
  652. if (!Check.isNull(orderStartDate)) {
  653. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  654. }
  655. if (!Check.isNull(orderEndDate)) {
  656. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  657. }
  658. JSONObject serviceAmountTotal = supplyChainService.getServiceAmountTotal(requestMap);
  659. returnJson.put("serviceAmountTotal", serviceAmountTotal);
  660. return returnJson;
  661. }
  662. /**
  663. * 首页-商品排行
  664. *
  665. * @param dateType
  666. * @param orderStartDate
  667. * @param orderEndDate
  668. * @return
  669. */
  670. @GetMapping("/indexOrderRank")
  671. @ApiOperation(value = "首页-商品排行")
  672. public TableDataInfo indexOrderRank(
  673. @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
  674. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
  675. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
  676. @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId) {
  677. Map<String, Object> requestMap = new HashMap<>();
  678. if (dateType == 0) {
  679. if ("1".equals(mediaId)) {
  680. return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
  681. } else {
  682. Integer hour = DateUtils.getNowHour(); // 当前小时
  683. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
  684. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  685. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
  686. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  687. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  688. requestMap.put("hour", hour);
  689. startPage();
  690. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioList(requestMap);
  691. return getDataTable(orderRankRatioList);
  692. }
  693. } else {
  694. if ("1".equals(mediaId)) {
  695. return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
  696. } else {
  697. if (!Check.isNull(orderStartDate)) {
  698. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  699. }
  700. if (!Check.isNull(orderEndDate)) {
  701. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  702. }
  703. startPage();
  704. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankList(requestMap);
  705. return getDataTable(orderRankRatioList);
  706. }
  707. }
  708. }
  709. private TableDataInfo indexOrderRankBytedance(Integer dateType, String orderStartDate, String orderEndDate) {
  710. Map<String, Object> requestMap = new HashMap<>();
  711. if (dateType == 0) {
  712. Integer hour = DateUtils.getNowHour(); // 当前小时
  713. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate);
  714. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  715. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日时间
  716. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  717. requestMap.put("nowEndHourTemp", nowStartHourTemp);
  718. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  719. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  720. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  721. requestMap.put("hour", hour);
  722. startPage();
  723. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioListBytedance(requestMap);
  724. return getDataTable(orderRankRatioList);
  725. } else {
  726. if (!Check.isNull(orderStartDate)) {
  727. Long start = DateUtils.strDateToInt(orderStartDate);
  728. requestMap.put("start", start);
  729. }
  730. if (!Check.isNull(orderEndDate)) {
  731. Long end = DateUtils.strDateToInt(orderEndDate);
  732. requestMap.put("end", end);
  733. }
  734. startPage();
  735. List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankListBytedance(requestMap);
  736. return getDataTable(orderRankRatioList);
  737. }
  738. }
  739. @GetMapping("/indexPromoterRank")
  740. @ApiOperation(value = "首页-达人排行")
  741. public TableDataInfo indexPromoterRank(
  742. @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
  743. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
  744. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
  745. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  746. @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId
  747. ) {
  748. Map<String, Object> requestMap = new HashMap<>();
  749. if (dateType == 0) {
  750. if ("1".equals(mediaId)) {
  751. return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
  752. } else {
  753. if (Check.isNotNull(userId)) {
  754. List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), mediaId);
  755. if (Check.isNull(promoterIds)) {
  756. return getDataTable(null);
  757. }
  758. requestMap.put("promoterIds", promoterIds);
  759. }
  760. if (!Check.isNull(orderStartDate)) {
  761. Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
  762. requestMap.put("start", start);
  763. }
  764. if (!Check.isNull(orderEndDate)) {
  765. Long end = DateUtils.getEndLongTime(orderEndDate); // 当天结束时间
  766. requestMap.put("end", end);
  767. }
  768. Integer hour = DateUtils.getNowHour(); // 当前小时
  769. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
  770. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  771. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
  772. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  773. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  774. requestMap.put("hour", hour);
  775. startPage();
  776. List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioList(requestMap);
  777. return getDataTable(promoterRankRatioList);
  778. }
  779. } else {
  780. if ("1".equals(mediaId)) {
  781. return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
  782. } else {
  783. if (!Check.isNull(orderStartDate)) {
  784. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  785. }
  786. if (!Check.isNull(orderEndDate)) {
  787. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  788. }
  789. startPage();
  790. List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioList(requestMap);
  791. return getDataTable(orderRatioList);
  792. }
  793. }
  794. }
  795. public TableDataInfo indexPromoterRankBytedance(Integer dateType, String orderStartDate, String orderEndDate, Long userId) {
  796. Map<String, Object> requestMap = new HashMap<>();
  797. if (dateType == 0) {
  798. if (Check.isNotNull(userId)) {
  799. List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), "1");
  800. if (Check.isNull(promoterIds)) {
  801. return getDataTable(null);
  802. }
  803. requestMap.put("promoterIds", promoterIds);
  804. }
  805. Integer hour = DateUtils.getNowHour(); // 当前小时
  806. Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
  807. String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
  808. Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳
  809. requestMap.put("nowStartHourTemp", nowStartHourTemp);
  810. requestMap.put("nowEndHourTemp", nowStartHourTemp);
  811. requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
  812. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  813. requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
  814. requestMap.put("hour", hour);
  815. startPage();
  816. List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioListBytedance(requestMap);
  817. return getDataTable(promoterRankRatioList);
  818. } else {
  819. if (!Check.isNull(orderStartDate)) {
  820. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  821. }
  822. if (!Check.isNull(orderEndDate)) {
  823. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  824. }
  825. startPage();
  826. List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioListBytedance(requestMap);
  827. return getDataTable(orderRatioList);
  828. }
  829. }
  830. @RequestMapping(value = "/exportPromoterTotal")
  831. @ResponseBody
  832. public void exportPromoterTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  833. Map<String, Object> requestMap = new HashMap<>();
  834. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  835. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
  836. }
  837. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  838. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
  839. }
  840. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  841. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  842. }
  843. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  844. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  845. }
  846. if (!Check.isNull(requestJson.getLong("itemId"))) {
  847. requestMap.put("itemId", requestJson.getLong("itemId"));
  848. }
  849. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  850. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  851. }
  852. List<JSONObject> list = supplyChainService.exportPromoterTotal(requestMap);
  853. List<List<Object>> exportList = new ArrayList<>();
  854. if (!Check.isNull(list)) {
  855. for (int i = 0; i < list.size(); i++) {
  856. JSONObject date = list.get(i);
  857. List<Object> export = new ArrayList();
  858. if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) {
  859. Long promoterId = date.getLong("promoterId");
  860. export.add(promoterId);
  861. String promoterNickName = date.getString("promoterNickName");
  862. export.add(promoterNickName);
  863. } else {
  864. Long promoterId = date.getLong("promoterId");
  865. String promoterNickName = date.getString("promoterNickName");
  866. String name = promoterNickName + "(" + promoterId + ")";
  867. export.add(name);
  868. }
  869. export.add(date.getInteger("orderNum"));
  870. export.add(date.getInteger("validOrderNUm"));
  871. export.add(date.getString("validRadio"));
  872. export.add(date.getString("payAmount"));
  873. export.add(date.getString("validPayAmount"));
  874. // export.add(date.getString("regimentalPromotionAmount"));
  875. export.add(date.getString("deliveryNum"));
  876. export.add(date.getString("deliveryRadio"));
  877. export.add(date.getString("notDeliveryNum"));
  878. String userName = supplyChainService.getUserName(date.getLong("promoterId"));
  879. if (!Check.isNull(userName)) {
  880. export.add(userName);
  881. }
  882. /* Map<String, Object> map = new HashMap<>();
  883. map.put("promoterId", promoterId);
  884. map.put("start", DateUtils.getStartLongTime(requestJson.getString("orderStartDate")));
  885. map.put("end", DateUtils.getEndLongTime(requestJson.getString("orderEndDate")));
  886. List<JSONObject> topOrders = supplyChainService.getTopOrders(map);
  887. if (!Check.isNull(topOrders)) {
  888. JSONObject top1 = topOrders.get(0);
  889. StringBuffer top1StringBuffer = new StringBuffer();
  890. top1StringBuffer.append("商品ID:").append(top1.getString("itemId")).append(String.valueOf((char) 10))
  891. .append("出单量:").append(top1.getString("orderNum")).append(String.valueOf((char) 10))
  892. .append("标题:").append(top1.getString("itemTitle")).append(String.valueOf((char) 10))
  893. .append("链接:").append(top1.getString("imageUrl"));
  894. export.add(top1StringBuffer);
  895. }
  896. if (!Check.isNull(topOrders) && topOrders.size() >= 2) {
  897. JSONObject top2 = topOrders.get(1);
  898. if (!Check.isNull(top2)) {
  899. StringBuffer top2StringBuffer = new StringBuffer();
  900. top2StringBuffer.append("商品ID:").append(top2.getString("itemId")).append(String.valueOf((char) 10))
  901. .append("出单量:").append(top2.getString("orderNum")).append(String.valueOf((char) 10))
  902. .append("标题:").append(top2.getString("itemTitle")).append(String.valueOf((char) 10))
  903. .append("链接:").append(top2.getString("imageUrl"));
  904. export.add(top2StringBuffer);
  905. }
  906. }
  907. if (!Check.isNull(topOrders) && topOrders.size() >= 3) {
  908. JSONObject top3 = topOrders.get(2);
  909. if (!Check.isNull(top3)) {
  910. StringBuffer top3StringBuffer = new StringBuffer();
  911. top3StringBuffer.append("商品ID:").append(top3.getString("itemId")).append(String.valueOf((char) 10))
  912. .append("出单量:").append(top3.getString("orderNum")).append(String.valueOf((char) 10))
  913. .append("标题:").append(top3.getString("itemTitle")).append(String.valueOf((char) 10))
  914. .append("链接:").append(top3.getString("imageUrl"));
  915. export.add(top3StringBuffer);
  916. }
  917. }*/
  918. exportList.add(export);
  919. }
  920. }
  921. String[] headers = {};
  922. if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) {
  923. headers = new String[]{"达人ID", "达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
  924. } else {
  925. headers = new String[]{"达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
  926. }
  927. OutputStream os = response.getOutputStream();
  928. ExportExcelUtils eeu = new ExportExcelUtils();
  929. XSSFWorkbook workbook = new XSSFWorkbook();
  930. eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
  931. this.setResponseHeader(response, "达人信息.xls");
  932. workbook.write(os);
  933. os.flush();
  934. os.close();
  935. }
  936. @RequestMapping(value = "/exportPromoter")
  937. @ResponseBody
  938. public void exportPromoter(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
  939. Map<String, Object> requestMap = new HashMap<>();
  940. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  941. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
  942. }
  943. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  944. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
  945. }
  946. if (!Check.isNull(requestJson.getString("promoterNickName"))) {
  947. requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
  948. }
  949. if (!Check.isNull(requestJson.getLong("promoterId"))) {
  950. requestMap.put("promoterId", requestJson.getLong("promoterId"));
  951. }
  952. if (!Check.isNull(requestJson.getLong("itemId"))) {
  953. requestMap.put("itemId", requestJson.getLong("itemId"));
  954. }
  955. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  956. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  957. }
  958. List<JSONObject> list = supplyChainService.exportPromoter(requestMap);
  959. List<List<Object>> exportList = new ArrayList<>();
  960. if (!Check.isNull(list)) {
  961. for (int i = 0; i < list.size(); i++) {
  962. JSONObject date = list.get(i);
  963. List<Object> export = new ArrayList();
  964. String promoterNickName = date.getString("promoterNickName");
  965. Long promoterId = date.getLong("promoterId");
  966. Long itemId = date.getLong("itemId");
  967. String itemTitle = date.getString("itemTitle");
  968. if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) {
  969. export.add(promoterNickName);
  970. export.add(promoterId);
  971. export.add(itemTitle);
  972. export.add(itemId);
  973. } else {
  974. String promoter = promoterNickName + "(" + promoterId + ")";
  975. export.add(promoter);
  976. String item = itemTitle + "(" + itemId + ")";
  977. export.add(item);
  978. }
  979. export.add(date.getString("imageUrl"));
  980. export.add(date.getInteger("orderNum"));
  981. export.add(date.getInteger("validOrderNUm"));
  982. export.add(date.getString("validRadio"));
  983. export.add(date.getString("deliveryNum"));
  984. export.add(date.getString("deliveryRadio"));
  985. export.add(date.getString("activityItemStatus"));
  986. exportList.add(export);
  987. }
  988. }
  989. String[] headers = {};
  990. if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) {
  991. headers = new String[]{"达人名称", "达人id", "商品名称", "商品id", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
  992. } else {
  993. headers = new String[]{"达人", "商品", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
  994. }
  995. OutputStream os = response.getOutputStream();
  996. ExportExcelUtils eeu = new ExportExcelUtils();
  997. XSSFWorkbook workbook = new XSSFWorkbook();
  998. eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
  999. this.setResponseHeader(response, "达人信息.xls");
  1000. workbook.write(os);
  1001. os.flush();
  1002. os.close();
  1003. }
  1004. /**
  1005. * 获取供应链人员列表
  1006. *
  1007. * @return
  1008. */
  1009. @GetMapping("/getSupplyChainUserList")
  1010. @ApiOperation(value = "获取供应链成员列表")
  1011. public TableDataInfo getSupplyChainUserList() {
  1012. List<JSONObject> list = supplyChainService.getSupplyChainUserList();
  1013. return getDataTable(list);
  1014. }
  1015. @GetMapping("/getSupplyChainCourtshipUserList")
  1016. @ApiOperation(value = "获取供应链成员列表")
  1017. public TableDataInfo getSupplyChainCourtshipUserList() {
  1018. List<JSONObject> list = supplyChainService.getSupplyChainCourtshipUserList();
  1019. return getDataTable(list);
  1020. }
  1021. /**
  1022. * 获取商品绑定人员列表
  1023. *
  1024. * @param status
  1025. * @param userId
  1026. * @param itemId
  1027. * @param itemTitle
  1028. * @param activityId
  1029. * @return
  1030. */
  1031. @GetMapping("/bindUserItemList")
  1032. @ApiOperation(value = "商品认领列表")
  1033. public TableDataInfo bindUserItemList(
  1034. @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status,
  1035. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  1036. @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId,
  1037. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  1038. @ApiParam("活动ID") @RequestParam(value = "activityId", required = false) Long activityId
  1039. ) {
  1040. Map<String, Object> requestMap = new HashMap<>();
  1041. if (!Check.isNull(status)) {
  1042. requestMap.put("status", status);
  1043. }
  1044. if (!Check.isNull(userId)) {
  1045. requestMap.put("userId", userId);
  1046. }
  1047. if (!Check.isNull(itemId)) {
  1048. requestMap.put("itemId", itemId);
  1049. }
  1050. if (!Check.isNull(itemTitle)) {
  1051. requestMap.put("itemTitle", itemTitle);
  1052. }
  1053. if (!Check.isNull(activityId)) {
  1054. requestMap.put("activityId", activityId);
  1055. }
  1056. startPage();
  1057. List<JSONObject> list = supplyChainService.bindUserItemList(requestMap);
  1058. return getDataTable(list);
  1059. }
  1060. /**
  1061. * 商品解绑
  1062. *
  1063. * @param itemId
  1064. * @return
  1065. */
  1066. @GetMapping("/unbindUser")
  1067. @ApiOperation(value = "商品解绑")
  1068. public JSONObject unbindUser(
  1069. @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId) {
  1070. JSONObject returnJson = new JSONObject();
  1071. if (Check.isNull(itemId)) {
  1072. returnJson.put("code", -1);
  1073. returnJson.put("message", "请传入商品ID");
  1074. return returnJson;
  1075. }
  1076. boolean isTrueOrFalse = supplyChainService.unbindUser(itemId);
  1077. if (isTrueOrFalse) {
  1078. returnJson.put("code", 0);
  1079. returnJson.put("message", "解绑成功");
  1080. return returnJson;
  1081. } else {
  1082. returnJson.put("code", -1);
  1083. returnJson.put("message", "解绑失败");
  1084. return returnJson;
  1085. }
  1086. }
  1087. /**
  1088. * 绑定商品
  1089. *
  1090. * @param itemId
  1091. * @return
  1092. */
  1093. @GetMapping("/bindUser")
  1094. @ApiOperation(value = "绑定商品")
  1095. public JSONObject bindUser(
  1096. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
  1097. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
  1098. @ApiParam("用户名称") @RequestParam(value = "nikeName", required = false) String nikeName) {
  1099. JSONObject returnJson = new JSONObject();
  1100. if (Check.isNull(itemId)) {
  1101. returnJson.put("code", -1);
  1102. returnJson.put("message", "请传入商品ID");
  1103. return returnJson;
  1104. }
  1105. if (Check.isNull("userId")) {
  1106. returnJson.put("code", -1);
  1107. returnJson.put("message", "请传入用户ID");
  1108. return returnJson;
  1109. }
  1110. if (Check.isNull("nikeName")) {
  1111. returnJson.put("code", -1);
  1112. returnJson.put("message", "请传入用户名称");
  1113. return returnJson;
  1114. }
  1115. boolean isTrueOrFalse = supplyChainService.bindUser(itemId, userId, nikeName);
  1116. if (isTrueOrFalse) {
  1117. returnJson.put("code", 0);
  1118. returnJson.put("message", "认领成功");
  1119. return returnJson;
  1120. } else {
  1121. returnJson.put("code", -1);
  1122. returnJson.put("message", "认领失败");
  1123. return returnJson;
  1124. }
  1125. }
  1126. /**
  1127. * 供应链管理员统计列表
  1128. *
  1129. * @param orderStartDate
  1130. * @param orderEndDate
  1131. * @return
  1132. */
  1133. @GetMapping("/adminReportList")
  1134. @ApiOperation(value = "供应链管理员统计列表")
  1135. public TableDataInfo adminReportList(
  1136. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1137. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1138. @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
  1139. @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
  1140. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId
  1141. ) {
  1142. Map<String, Object> requestMap = new HashMap<>();
  1143. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  1144. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  1145. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  1146. //根据本阶段日期 获取上阶段 开始 和 截至 日期
  1147. Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
  1148. //下个周期的开始时间
  1149. String lastTimeStart = map.get("lastTimeStart");
  1150. //下个周期的结束时间
  1151. String lastTimeEnd = map.get("lastTimeEnd");
  1152. //当前小时
  1153. Integer hour = DateUtils.getNowHour() - 1;
  1154. //当天 yyyy-MM-dd
  1155. String today = DateUtils.getNowDateStr();
  1156. if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
  1157. hour = 23;
  1158. }
  1159. requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
  1160. requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
  1161. requestMap.put("hour", hour);
  1162. }
  1163. if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  1164. requestMap.put("startDate", bindStartDate);
  1165. requestMap.put("endDate", bindEndDate + " 23:59:59");
  1166. }
  1167. if (!Check.isNull(userId)) {
  1168. requestMap.put("userId", userId);
  1169. }
  1170. TableDataInfo dataInfo = new TableDataInfo();
  1171. if (Check.isNullMap(requestMap)) {
  1172. dataInfo.setCode(-1);
  1173. dataInfo.setMsg("入参不能为空");
  1174. return dataInfo;
  1175. }
  1176. List<JSONObject> list = new ArrayList<>();
  1177. startPage();
  1178. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  1179. list = supplyChainService.adminReportList(requestMap);
  1180. } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  1181. list = supplyChainService.adminReportListByBind(requestMap);
  1182. }
  1183. return getDataTable(list);
  1184. }
  1185. @PostMapping("/exportAdminReportList")
  1186. @ApiOperation(value = "供应链管理员统计列表")
  1187. public void exportAdminReportList(
  1188. HttpServletRequest request, HttpServletResponse response,
  1189. @RequestBody JSONObject requestJson
  1190. ) throws IOException {
  1191. Map<String, Object> requestMap = new HashMap<>();
  1192. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1193. Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
  1194. requestMap.put("start", start);
  1195. requestMap.put("startDate", requestJson.getString("orderStartDate"));
  1196. }
  1197. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1198. Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
  1199. requestMap.put("end", end);
  1200. requestMap.put("endDate", requestJson.getString("orderEndDate") + " 23:59:59");
  1201. }
  1202. if (!Check.isNull(requestJson.getString("bindStartDate"))) {
  1203. Long start = DateUtils.getStartLongTime(requestJson.getString("bindStartDate"));
  1204. requestMap.put("start", start);
  1205. requestMap.put("startDate", requestJson.getString("bindStartDate"));
  1206. }
  1207. if (!Check.isNull(requestJson.getString("bindEndDate"))) {
  1208. Long end = DateUtils.getEndLongTime(requestJson.getString("bindEndDate"));
  1209. requestMap.put("end", end);
  1210. requestMap.put("endDate", requestJson.getString("bindEndDate") + " 23:59:59");
  1211. }
  1212. if (!Check.isNull(requestJson.getString("userId"))) {
  1213. requestMap.put("userId", requestJson.getString("userId"));
  1214. }
  1215. List<JSONObject> list = new ArrayList<>();
  1216. if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
  1217. list = supplyChainService.exportAdminReportList(requestMap);
  1218. } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
  1219. list = supplyChainService.exportAdminReportListByBind(requestMap);
  1220. }
  1221. List<List<Object>> exportList = new ArrayList<>();
  1222. if (!Check.isNull(list)) {
  1223. for (int i = 0; i < list.size(); i++) {
  1224. JSONObject date = list.get(i);
  1225. List<Object> export = new ArrayList();
  1226. export.add(date.getString("userName"));
  1227. export.add(date.getString("itemCount"));
  1228. export.add(date.getString("sendSampleCount"));
  1229. export.add(date.getString("orderNum"));
  1230. export.add(date.getString("validOrderNUm"));
  1231. export.add(date.getString("validRadio"));
  1232. export.add(date.getString("deliveryNum"));
  1233. export.add(date.getString("notDeliveryNum"));
  1234. export.add(date.getString("deliveryRadio"));
  1235. export.add(date.getString("payAmount"));
  1236. export.add(date.getString("regimentalPromotionAmount"));
  1237. export.add(date.getString("totalRegimentalSettleAmount"));
  1238. export.add(date.getString("avgServiceRate"));
  1239. exportList.add(export);
  1240. }
  1241. }
  1242. String[] headers = {"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
  1243. OutputStream os = response.getOutputStream();
  1244. ExportExcelUtils eeu = new ExportExcelUtils();
  1245. XSSFWorkbook workbook = new XSSFWorkbook();
  1246. eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
  1247. this.setResponseHeader(response, "订单信息.xls");
  1248. workbook.write(os);
  1249. os.flush();
  1250. os.close();
  1251. }
  1252. /**
  1253. * 认领商品列表
  1254. *
  1255. * @param userId
  1256. * @param orderStartDate
  1257. * @param orderEndDate
  1258. * @param itemId
  1259. * @param itemTitle
  1260. * @return
  1261. */
  1262. @GetMapping("/userItemDetail")
  1263. @ApiOperation(value = "认领商品列表")
  1264. public TableDataInfo userItemDetail(
  1265. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  1266. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1267. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1268. @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) Long itemId,
  1269. @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
  1270. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1271. @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort
  1272. ) {
  1273. Map<String, Object> requestMap = new HashMap<>();
  1274. if (!Check.isNull(userId)) {
  1275. requestMap.put("userId", userId);
  1276. }
  1277. if (!Check.isNull(orderStartDate)) {
  1278. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  1279. }
  1280. if (!Check.isNull(orderEndDate)) {
  1281. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  1282. }
  1283. if (!Check.isNull(itemId)) {
  1284. requestMap.put("itemId", itemId);
  1285. }
  1286. if (!Check.isNull(itemTitle)) {
  1287. requestMap.put("itemTitle", itemTitle);
  1288. }
  1289. requestMap.put("fieId", fieId);
  1290. requestMap.put("sort", sort);
  1291. TableDataInfo dataInfo = new TableDataInfo();
  1292. if (Check.isNullMap(requestMap)) {
  1293. dataInfo.setCode(-1);
  1294. dataInfo.setMsg("入参不能为空");
  1295. return dataInfo;
  1296. }
  1297. startPage();
  1298. List<JSONObject> list = supplyChainService.userItemDetail(requestMap);
  1299. return getDataTable(list);
  1300. }
  1301. /**
  1302. * 认领商品列表导出
  1303. *
  1304. * @return
  1305. */
  1306. @PostMapping("/exportUserItemDetail")
  1307. @ApiOperation(value = "认领商品列表")
  1308. @ResponseBody
  1309. public void exportUserItemDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1310. Map<String, Object> requestMap = new HashMap<>();
  1311. if (!Check.isNull(requestJson.getLong("userId"))) {
  1312. requestMap.put("userId", requestJson.getLong("userId"));
  1313. }
  1314. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1315. Long start = DateUtils.strDateToInt(requestJson.getString("orderStartDate"));
  1316. requestMap.put("start", start);
  1317. }
  1318. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1319. Long end = DateUtils.strDateToInt(requestJson.getString("orderEndDate"));
  1320. requestMap.put("end", end);
  1321. }
  1322. if (!Check.isNull(requestJson.getLong("itemId"))) {
  1323. requestMap.put("itemId", requestJson.getLong("itemId"));
  1324. }
  1325. if (!Check.isNull(requestJson.getString("itemTitle"))) {
  1326. requestMap.put("itemTitle", requestJson.getString("itemTitle"));
  1327. }
  1328. List<JSONObject> list = supplyChainService.exportUserItemDetail(requestMap);
  1329. List<List<Object>> exportList = new ArrayList<>();
  1330. if (!Check.isNull(list)) {
  1331. for (int i = 0; i < list.size(); i++) {
  1332. JSONObject date = list.get(i);
  1333. List<Object> export = new ArrayList();
  1334. export.add(date.getString("userName"));
  1335. export.add(date.getLong("itemId"));
  1336. export.add(date.getString("itemTitle"));
  1337. export.add(date.getString("reservePrice"));
  1338. export.add(date.getString("itemCommissionRate"));
  1339. export.add(date.getString("orderNum"));
  1340. export.add(date.getString("validOrderNUm"));
  1341. export.add(date.getString("validRadio"));
  1342. export.add(date.getString("invalidOrderNUm"));
  1343. export.add(date.getString("deliveryNum"));
  1344. export.add(date.getString("deliveryRadio"));
  1345. export.add(date.getString("notDeliveryNum"));
  1346. export.add(date.getString("payAmount"));
  1347. export.add(date.getString("regimentalPromotionRate"));
  1348. export.add(date.getString("regimentalPromotionAmount"));
  1349. export.add(date.getString("totalRegimentalSettleAmount"));
  1350. export.add(date.getString("imageUrl"));
  1351. export.add(date.getString("ccrValue"));
  1352. exportList.add(export);
  1353. }
  1354. }
  1355. String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "结算服务费收入", "商品封面", "ccr"};
  1356. OutputStream os = response.getOutputStream();
  1357. ExportExcelUtils eeu = new ExportExcelUtils();
  1358. XSSFWorkbook workbook = new XSSFWorkbook();
  1359. eeu.exportExcel(workbook, 0, "认领列表", headers, exportList);
  1360. this.setResponseHeader(response, "认领列表.xls");
  1361. workbook.write(os);
  1362. os.flush();
  1363. os.close();
  1364. }
  1365. @GetMapping("/userItemTotal")
  1366. @ApiOperation(value = "认领商品列表汇总")
  1367. public JSONObject userItemTotal(
  1368. @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
  1369. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1370. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate
  1371. ) {
  1372. Map<String, Object> requestMap = new HashMap<>();
  1373. if (!Check.isNull(userId)) {
  1374. requestMap.put("userId", userId);
  1375. }
  1376. if (!Check.isNull(orderStartDate)) {
  1377. Long start = DateUtils.strDateToInt(orderStartDate);
  1378. requestMap.put("start", start);
  1379. }
  1380. if (!Check.isNull(orderEndDate)) {
  1381. Long end = DateUtils.strDateToInt(orderEndDate);
  1382. requestMap.put("end", end);
  1383. }
  1384. JSONObject returnJson = supplyChainService.userItemTotal(requestMap);
  1385. return returnJson;
  1386. }
  1387. /**
  1388. * 商品认领汇总
  1389. *
  1390. * @return
  1391. */
  1392. @GetMapping("/itemBindSummary")
  1393. @ApiOperation(value = "商品认领汇总")
  1394. public JSONObject itemBindSummary() {
  1395. JSONObject json = supplyChainService.itemBindSummary();
  1396. return json;
  1397. }
  1398. /**
  1399. * 首页-时段对比
  1400. *
  1401. * @param orderStartDate
  1402. * @param orderEndDate
  1403. * @return
  1404. */
  1405. @SneakyThrows
  1406. @GetMapping("/indexTimeIntervalRatio")
  1407. @ApiOperation(value = "首页-时段对比")
  1408. public JSONObject indexTimeIntervalRatio(
  1409. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1410. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
  1411. Map<String, Object> requestMap = new HashMap<>();
  1412. String nowDate = DateUtils.getNowDateStr();
  1413. String thisCycleEnd = null; // 当前时段结束日期
  1414. String thisCycleStart = null; // 当前时段开始日期
  1415. String lastCycleEnd = null; // 上一时段结束日期
  1416. String lastCycleStart = null; // 上一时段开始日期
  1417. if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
  1418. thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
  1419. thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6);
  1420. lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1);
  1421. lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6);
  1422. } else {
  1423. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  1424. int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate));
  1425. thisCycleEnd = orderEndDate;
  1426. thisCycleStart = orderStartDate;
  1427. lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1);
  1428. lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay);
  1429. }
  1430. if (!Check.isNull(thisCycleStart)) {
  1431. Long thisCycleStartTemp = DateUtils.strDateToInt(thisCycleStart);
  1432. requestMap.put("thisCycleStartTemp", thisCycleStartTemp);
  1433. }
  1434. if (!Check.isNull(thisCycleEnd)) {
  1435. Long thisCycleEndTemp = DateUtils.strDateToInt(thisCycleEnd);
  1436. requestMap.put("thisCycleEndTemp", thisCycleEndTemp);
  1437. }
  1438. if (!Check.isNull(lastCycleStart)) {
  1439. Long lastCycleStartTemp = DateUtils.strDateToInt(lastCycleStart);
  1440. requestMap.put("lastCycleStartTemp", lastCycleStartTemp);
  1441. }
  1442. if (!Check.isNull(lastCycleEnd)) {
  1443. Long lastCycleEndTemp = DateUtils.strDateToInt(lastCycleEnd);
  1444. requestMap.put("lastCycleEndTemp", lastCycleEndTemp);
  1445. }
  1446. JSONObject timeIntervalRatioJson = supplyChainService.getTimeIntervalRatio(requestMap);
  1447. return timeIntervalRatioJson;
  1448. }
  1449. /**
  1450. * 首页-统计图
  1451. *
  1452. * @param orderStartDate
  1453. * @param orderEndDate
  1454. * @param type
  1455. * @return
  1456. */
  1457. @GetMapping("/indexStatistics")
  1458. @ApiOperation(value = "首页-统计图")
  1459. public List<JSONObject> indexStatistics(
  1460. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1461. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1462. @ApiParam("类型") @RequestParam(value = "type", required = false) String type) {
  1463. Map<String, Object> requestMap = new HashMap<>();
  1464. String nowDate = DateUtils.getNowDateStr();
  1465. String start = null;
  1466. String end = null;
  1467. if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
  1468. end = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
  1469. start = DateUtils.getAnotherDay("yyyy-MM-dd", end, -6);
  1470. } else {
  1471. start = orderStartDate;
  1472. end = orderEndDate;
  1473. }
  1474. if (!Check.isNull(start)) {
  1475. Long startTemp = DateUtils.strDateToInt(start);
  1476. requestMap.put("startTemp", startTemp);
  1477. }
  1478. if (!Check.isNull(end)) {
  1479. Long endTemp = DateUtils.strDateToInt(end);
  1480. requestMap.put("endTemp", endTemp);
  1481. }
  1482. if (!Check.isNull(type)) {
  1483. requestMap.put("type", type);
  1484. }
  1485. List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
  1486. return list;
  1487. }
  1488. //发送响应流方法
  1489. public void setResponseHeader(HttpServletResponse response, String fileName) {
  1490. try {
  1491. try {
  1492. fileName = new String(fileName.getBytes(), "ISO8859-1");
  1493. } catch (UnsupportedEncodingException e) {
  1494. e.printStackTrace();
  1495. }
  1496. response.setContentType("application/octet-stream;charset=ISO8859-1");
  1497. response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
  1498. response.addHeader("Pargam", "no-cache");
  1499. response.addHeader("Cache-Control", "no-cache");
  1500. } catch (Exception ex) {
  1501. ex.printStackTrace();
  1502. }
  1503. }
  1504. @GetMapping("/bdReportList")
  1505. @ApiOperation(value = "供应链管理员统计列表")
  1506. public TableDataInfo bdReportList(
  1507. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1508. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1509. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1510. Map<String, Object> requestMap = new HashMap<>();
  1511. if (!Check.isNull(orderStartDate)) {
  1512. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1513. requestMap.put("start", start);
  1514. }
  1515. if (!Check.isNull(orderEndDate)) {
  1516. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1517. requestMap.put("end", end);
  1518. }
  1519. if (!Check.isNull(collectSampleId)) {
  1520. requestMap.put("collectSampleId", collectSampleId);
  1521. }
  1522. TableDataInfo dataInfo = new TableDataInfo();
  1523. if (Check.isNullMap(requestMap)) {
  1524. dataInfo.setCode(500);
  1525. dataInfo.setMsg("入参不能为空");
  1526. return dataInfo;
  1527. }
  1528. startPage();
  1529. List<JSONObject> list = supplyChainService.bdReportList(requestMap);
  1530. return getDataTable(list);
  1531. }
  1532. @PostMapping("/exportBdReportList")
  1533. @ApiOperation(value = "供应链管理员统计列表")
  1534. @ResponseBody
  1535. public void exportBdReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1536. Map<String, Object> requestMap = new HashMap<>();
  1537. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1538. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1539. requestMap.put("start", start);
  1540. }
  1541. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1542. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1543. requestMap.put("end", end);
  1544. }
  1545. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1546. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1547. }
  1548. List<JSONObject> list = supplyChainService.exportBdReportList(requestMap);
  1549. List<List<Object>> exportList = new ArrayList<>();
  1550. if (!Check.isNull(list)) {
  1551. for (int i = 0; i < list.size(); i++) {
  1552. JSONObject date = list.get(i);
  1553. List<Object> export = new ArrayList();
  1554. export.add(date.getString("collectSampleId"));
  1555. export.add(date.getString("collectSampleName"));
  1556. export.add(date.getString("promoterCount"));
  1557. export.add(date.getString("sampleCount"));
  1558. export.add(date.getString("sampleRate"));
  1559. export.add(date.getString("notSampleCount"));
  1560. export.add(date.getString("sendTotalCount"));
  1561. export.add(date.getString("sendPromoterCount"));
  1562. export.add(date.getString("sendItemCount"));
  1563. export.add(date.getString("orderNum"));
  1564. export.add(date.getString("voucherOrderNum"));
  1565. export.add(date.getString("validOrderNum"));
  1566. export.add(date.getString("voucherValidOrderNum"));
  1567. export.add(date.getString("validOrderRate"));
  1568. export.add(date.getString("orderAmount"));
  1569. export.add(date.getString("voucherOrderAmount"));
  1570. export.add(date.getString("regimentalPromotionAmount"));
  1571. export.add(date.getString("voucherRegimentalPromotionAmount"));
  1572. export.add(date.getString("totalRegimentalSettleAmount"));
  1573. export.add(date.getString("voucherTotalRegimentalSettleAmount"));
  1574. exportList.add(export);
  1575. }
  1576. }
  1577. String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "(凭)订单数", "有效订单数", "(凭)有效订单数", "有效订单率", "订单金额", "凭(订单金额)", "预估服务费", "(凭)预估服务费", "结算服务费", "(凭)结算服务费"};
  1578. OutputStream os = response.getOutputStream();
  1579. ExportExcelUtils eeu = new ExportExcelUtils();
  1580. XSSFWorkbook workbook = new XSSFWorkbook();
  1581. eeu.exportExcel(workbook, 0, "bd业绩汇总", headers, exportList);
  1582. this.setResponseHeader(response, "bd业绩汇总.xls");
  1583. workbook.write(os);
  1584. os.flush();
  1585. os.close();
  1586. }
  1587. @GetMapping("/bdDetailList")
  1588. @ApiOperation(value = "供应链管理员统计列表")
  1589. public TableDataInfo bdDetailList(
  1590. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1591. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1592. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
  1593. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1594. @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
  1595. Map<String, Object> requestMap = new HashMap<>();
  1596. if (!Check.isNull(orderStartDate)) {
  1597. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1598. requestMap.put("start", start);
  1599. }
  1600. if (!Check.isNull(orderEndDate)) {
  1601. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1602. requestMap.put("end", end);
  1603. }
  1604. if (!Check.isNull(collectSampleId)) {
  1605. requestMap.put("collectSampleId", collectSampleId);
  1606. }
  1607. requestMap.put("fieId", fieId);
  1608. requestMap.put("sort", sort);
  1609. TableDataInfo dataInfo = new TableDataInfo();
  1610. if (Check.isNullMap(requestMap)) {
  1611. dataInfo.setCode(500);
  1612. dataInfo.setMsg("入参不能为空");
  1613. return dataInfo;
  1614. }
  1615. startPage();
  1616. List<JSONObject> list = supplyChainService.bdDetailList(requestMap);
  1617. return getDataTable(list);
  1618. }
  1619. @GetMapping("/bdTotal")
  1620. @ApiOperation(value = "供应链管理员统计列表")
  1621. public TableDataInfo bdTotal(
  1622. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1623. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1624. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1625. Map<String, Object> requestMap = new HashMap<>();
  1626. if (!Check.isNull(orderStartDate)) {
  1627. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1628. requestMap.put("start", start);
  1629. }
  1630. if (!Check.isNull(orderEndDate)) {
  1631. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1632. requestMap.put("end", end);
  1633. }
  1634. if (!Check.isNull(collectSampleId)) {
  1635. requestMap.put("collectSampleId", collectSampleId);
  1636. }
  1637. TableDataInfo dataInfo = new TableDataInfo();
  1638. if (Check.isNullMap(requestMap)) {
  1639. dataInfo.setCode(500);
  1640. dataInfo.setMsg("入参不能为空");
  1641. return dataInfo;
  1642. }
  1643. startPage();
  1644. List<JSONObject> list = supplyChainService.bdTotal(requestMap);
  1645. return getDataTable(list);
  1646. }
  1647. @PostMapping("/exportBdDetail")
  1648. @ApiOperation(value = "认领商品列表")
  1649. @ResponseBody
  1650. public void exportBdDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1651. Map<String, Object> requestMap = new HashMap<>();
  1652. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1653. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1654. requestMap.put("start", start);
  1655. }
  1656. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1657. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1658. requestMap.put("end", end);
  1659. }
  1660. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1661. requestMap.put("collectSampleId", (requestJson.getLong("collectSampleId")));
  1662. }
  1663. List<JSONObject> list = supplyChainService.exportBdDetail(requestMap);
  1664. List<List<Object>> exportList = new ArrayList<>();
  1665. if (!Check.isNull(list)) {
  1666. for (int i = 0; i < list.size(); i++) {
  1667. JSONObject date = list.get(i);
  1668. List<Object> export = new ArrayList();
  1669. export.add(date.getString("promoterId"));
  1670. export.add(date.getString("promoterName"));
  1671. export.add(date.getString("sampleCount"));
  1672. export.add(date.getString("orderNum"));
  1673. export.add(date.getString("validOrderNum"));
  1674. export.add(date.getString("validOrderRate"));
  1675. export.add(date.getString("regimentalPromotionAmount"));
  1676. export.add(date.getString("totalRegimentalSettleAmount"));
  1677. export.add(date.getString("promoterUrl"));
  1678. exportList.add(export);
  1679. }
  1680. }
  1681. String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
  1682. OutputStream os = response.getOutputStream();
  1683. ExportExcelUtils eeu = new ExportExcelUtils();
  1684. XSSFWorkbook workbook = new XSSFWorkbook();
  1685. eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
  1686. this.setResponseHeader(response, "bd业绩.xls");
  1687. workbook.write(os);
  1688. os.flush();
  1689. os.close();
  1690. }
  1691. @GetMapping("/bdReportListV2")
  1692. @ApiOperation(value = "供应链管理员统计列表")
  1693. public TableDataInfo bdReportListV2(
  1694. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1695. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1696. @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
  1697. @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
  1698. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1699. Map<String, Object> requestMap = new HashMap<>();
  1700. if (!Check.isNull(orderStartDate)) {
  1701. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1702. requestMap.put("start", start);
  1703. }
  1704. if (!Check.isNull(collectSampleId)) {
  1705. requestMap.put("collectSampleId", collectSampleId);
  1706. }
  1707. if (!Check.isNull(bindStartDate)) {
  1708. Integer start = DateUtils.getIntegerTime(bindStartDate);
  1709. requestMap.put("bindStartDate", start);
  1710. }
  1711. if (!Check.isNull(bindEndDate)) {
  1712. Integer end = DateUtils.getIntegerTime(bindEndDate);
  1713. requestMap.put("bindEndDate", end);
  1714. }
  1715. TableDataInfo dataInfo = new TableDataInfo();
  1716. if (Check.isNullMap(requestMap)) {
  1717. dataInfo.setCode(500);
  1718. dataInfo.setMsg("入参不能为空");
  1719. return dataInfo;
  1720. }
  1721. startPage();
  1722. List<JSONObject> list = new ArrayList<>();
  1723. if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
  1724. list = supplyChainService.bdReportListV2(requestMap);
  1725. } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
  1726. list = supplyChainService.bdReportListV2ByBind(requestMap);
  1727. }
  1728. return getDataTable(list);
  1729. }
  1730. @PostMapping("/exportBdReportListV2")
  1731. @ApiOperation(value = "供应链管理员统计列表")
  1732. @ResponseBody
  1733. public void exportBdReportListV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1734. Map<String, Object> requestMap = new HashMap<>();
  1735. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1736. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1737. requestMap.put("start", start);
  1738. }
  1739. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1740. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1741. requestMap.put("end", end);
  1742. }
  1743. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1744. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1745. }
  1746. if (!Check.isNull(requestJson.getString("bindStartDate"))) {
  1747. Integer start = DateUtils.getIntegerTime(requestJson.getString("bindStartDate"));
  1748. requestMap.put("bindStartDate", start);
  1749. }
  1750. if (!Check.isNull(requestJson.getString("bindEndDate"))) {
  1751. Integer end = DateUtils.getIntegerTime(requestJson.getString("bindEndDate"));
  1752. requestMap.put("bindEndDate", end);
  1753. }
  1754. List<JSONObject> list = new ArrayList<>();
  1755. if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
  1756. list = supplyChainService.bdReportListV2(requestMap);
  1757. } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
  1758. list = supplyChainService.bdReportListV2ByBind(requestMap);
  1759. }
  1760. List<List<Object>> exportList = new ArrayList<>();
  1761. if (!Check.isNull(list)) {
  1762. for (int i = 0; i < list.size(); i++) {
  1763. JSONObject date = list.get(i);
  1764. List<Object> export = new ArrayList();
  1765. export.add(date.getString("collectSampleId"));
  1766. export.add(date.getString("collectSampleName"));
  1767. export.add(date.getString("promoterCount"));
  1768. export.add(date.getString("sampleCount"));
  1769. export.add(date.getString("sampleRate"));
  1770. export.add(date.getString("notSampleCount"));
  1771. export.add(date.getString("sendTotalCount"));
  1772. export.add(date.getString("sendPromoterCount"));
  1773. export.add(date.getString("sendItemCount"));
  1774. export.add(date.getString("orderNum"));
  1775. export.add(date.getString("validOrderNum"));
  1776. export.add(date.getString("validOrderRate"));
  1777. export.add(date.getString("orderAmount"));
  1778. export.add(date.getString("regimentalPromotionAmount"));
  1779. export.add(date.getString("totalRegimentalSettleAmount"));
  1780. exportList.add(export);
  1781. }
  1782. }
  1783. String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "有效订单数", "有效订单率", "订单金额", "预估服务费", "结算服务费"};
  1784. OutputStream os = response.getOutputStream();
  1785. ExportExcelUtils eeu = new ExportExcelUtils();
  1786. XSSFWorkbook workbook = new XSSFWorkbook();
  1787. eeu.exportExcel(workbook, 0, "bd业绩汇总V2", headers, exportList);
  1788. this.setResponseHeader(response, "bd业绩汇总V2.xls");
  1789. workbook.write(os);
  1790. os.flush();
  1791. os.close();
  1792. }
  1793. @GetMapping("/bdTotalV2")
  1794. @ApiOperation(value = "供应链管理员统计列表")
  1795. public TableDataInfo bdTotalV2(
  1796. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1797. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1798. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
  1799. Map<String, Object> requestMap = new HashMap<>();
  1800. if (!Check.isNull(orderStartDate)) {
  1801. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1802. requestMap.put("start", start);
  1803. }
  1804. if (!Check.isNull(orderEndDate)) {
  1805. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1806. requestMap.put("end", end);
  1807. }
  1808. if (!Check.isNull(collectSampleId)) {
  1809. requestMap.put("collectSampleId", collectSampleId);
  1810. }
  1811. TableDataInfo dataInfo = new TableDataInfo();
  1812. if (Check.isNullMap(requestMap)) {
  1813. dataInfo.setCode(500);
  1814. dataInfo.setMsg("入参不能为空");
  1815. return dataInfo;
  1816. }
  1817. startPage();
  1818. List<JSONObject> list = supplyChainService.bdTotalV2(requestMap);
  1819. return getDataTable(list);
  1820. }
  1821. @GetMapping("/bdDetailListV2")
  1822. @ApiOperation(value = "供应链管理员统计列表")
  1823. public TableDataInfo bdDetailListV2(
  1824. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  1825. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  1826. @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
  1827. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  1828. @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
  1829. Map<String, Object> requestMap = new HashMap<>();
  1830. if (!Check.isNull(orderStartDate)) {
  1831. Integer start = DateUtils.getIntegerTime(orderStartDate);
  1832. requestMap.put("start", start);
  1833. }
  1834. if (!Check.isNull(orderEndDate)) {
  1835. Integer end = DateUtils.getIntegerTime(orderEndDate);
  1836. requestMap.put("end", end);
  1837. }
  1838. if (!Check.isNull(collectSampleId)) {
  1839. requestMap.put("collectSampleId", collectSampleId);
  1840. }
  1841. requestMap.put("fieId", fieId);
  1842. requestMap.put("sort", sort);
  1843. TableDataInfo dataInfo = new TableDataInfo();
  1844. if (Check.isNullMap(requestMap)) {
  1845. dataInfo.setCode(500);
  1846. dataInfo.setMsg("入参不能为空");
  1847. return dataInfo;
  1848. }
  1849. startPage();
  1850. List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
  1851. return getDataTable(list);
  1852. }
  1853. @PostMapping("/exportBdDetailV2")
  1854. @ApiOperation(value = "认领商品列表")
  1855. @ResponseBody
  1856. public void exportBdDetailV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  1857. Map<String, Object> requestMap = new HashMap<>();
  1858. if (!Check.isNull(requestJson.getString("orderStartDate"))) {
  1859. Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
  1860. requestMap.put("start", start);
  1861. }
  1862. if (!Check.isNull(requestJson.getString("orderEndDate"))) {
  1863. Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
  1864. requestMap.put("end", end);
  1865. }
  1866. if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
  1867. requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
  1868. }
  1869. requestMap.put("fieId", "orderNum");
  1870. requestMap.put("sort", "desc");
  1871. List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
  1872. List<List<Object>> exportList = new ArrayList<>();
  1873. if (!Check.isNull(list)) {
  1874. for (int i = 0; i < list.size(); i++) {
  1875. JSONObject date = list.get(i);
  1876. List<Object> export = new ArrayList();
  1877. export.add(date.getString("promoterId"));
  1878. export.add(date.getString("promoterName"));
  1879. export.add(date.getString("sampleCount"));
  1880. export.add(date.getString("orderNum"));
  1881. export.add(date.getString("validOrderNum"));
  1882. export.add(date.getString("validOrderRate"));
  1883. export.add(date.getString("regimentalPromotionAmount"));
  1884. export.add(date.getString("totalRegimentalSettleAmount"));
  1885. export.add(date.getString("promoterUrl"));
  1886. exportList.add(export);
  1887. }
  1888. }
  1889. String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
  1890. OutputStream os = response.getOutputStream();
  1891. ExportExcelUtils eeu = new ExportExcelUtils();
  1892. XSSFWorkbook workbook = new XSSFWorkbook();
  1893. eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
  1894. this.setResponseHeader(response, "bd业绩.xls");
  1895. workbook.write(os);
  1896. os.flush();
  1897. os.close();
  1898. }
  1899. static ExecutorService addListCService = Executors.newFixedThreadPool(5);
  1900. /**
  1901. * 接口链接:
  1902. * https://open.kwaixiaodian.com/zone/new/docs/api?name=open.distribution.investment.activity.open.close&version=1
  1903. */
  1904. @GetMapping("/addList")
  1905. @ApiOperation(value = "分销团长订单列表(游标方式)")
  1906. public void addList(String beginDate, String endDate) {
  1907. List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(beginDate, endDate);
  1908. allDatesOfTwoTimes.forEach(date -> addListCService.submit(() -> {
  1909. try {
  1910. supplyChainService.addList(date, date, "");
  1911. } catch (InterruptedException e) {
  1912. e.printStackTrace();
  1913. }
  1914. }));
  1915. }
  1916. @GetMapping("/addListC")
  1917. @ApiOperation(value = "多日期本地调试---分销团长订单列表")
  1918. public void addListC(String beginDate, String endDate) {
  1919. List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(beginDate, endDate);
  1920. allDatesOfTwoTimes.forEach(date -> addListCService.submit(() -> {
  1921. try {
  1922. long currentTimeMillis = System.currentTimeMillis();
  1923. System.out.println(date + "开始执行ing...");
  1924. supplyChainService.addList(date, date, "");
  1925. System.out.println(date + "用时:" + (System.currentTimeMillis() - currentTimeMillis) / 60000 + "分");
  1926. } catch (InterruptedException e) {
  1927. e.printStackTrace();
  1928. }
  1929. }));
  1930. }
  1931. static ExecutorService fxNowService = Executors.newFixedThreadPool(3);
  1932. @PostMapping(value = "/ruixuanAccept")
  1933. public Map<String, Object> ruixuanAccept(@RequestBody String eventsEncoded) {
  1934. try {
  1935. logger.info("567睿选消息订阅");
  1936. String events = PlatformEventSecurityUtil.decode(eventsEncoded, ruiXuanPrivateKey);
  1937. JSONObject eventJSon = JSONObject.parseObject(events);
  1938. fxNowService.submit(new Runnable() {
  1939. @Override
  1940. public void run() {
  1941. try {
  1942. if (!Check.isNull(eventJSon)) {
  1943. String event = eventJSon.getString("event");
  1944. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  1945. supplyChainService.updateOrder(eventJSon);
  1946. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  1947. supplyChainService.updateItem(eventJSon);
  1948. }
  1949. }
  1950. } catch (Exception e) {
  1951. e.printStackTrace();
  1952. }
  1953. }
  1954. });
  1955. } catch (KsMerchantApiException e) {
  1956. e.printStackTrace();
  1957. }
  1958. //返回成功
  1959. Map<String, Object> result = new HashMap<>();
  1960. result.put("result", 1);
  1961. return result;
  1962. }
  1963. @PostMapping(value = "/mgsAccept")
  1964. public Map<String, Object> mgsAccept(@RequestBody String eventsEncoded) {
  1965. try {
  1966. logger.info("RX食品消息订阅");
  1967. String events = PlatformEventSecurityUtil.decode(eventsEncoded, mgsPrivateKey);
  1968. JSONObject eventJSon = JSONObject.parseObject(events);
  1969. fxNowService.submit(new Runnable() {
  1970. @Override
  1971. public void run() {
  1972. try {
  1973. if (!Check.isNull(eventJSon)) {
  1974. String event = eventJSon.getString("event");
  1975. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  1976. supplyChainService.updateOrder(eventJSon);
  1977. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  1978. supplyChainService.updateItem(eventJSon);
  1979. }
  1980. }
  1981. } catch (Exception e) {
  1982. e.printStackTrace();
  1983. }
  1984. }
  1985. });
  1986. } catch (KsMerchantApiException e) {
  1987. e.printStackTrace();
  1988. }
  1989. //返回成功
  1990. Map<String, Object> result = new HashMap<>();
  1991. result.put("result", 1);
  1992. return result;
  1993. }
  1994. @PostMapping(value = "/rocketAccept")
  1995. public Map<String, Object> rocketAccept(@RequestBody String eventsEncoded) {
  1996. try {
  1997. logger.info("王炸睿选消息订阅");
  1998. String events = PlatformEventSecurityUtil.decode(eventsEncoded, rocketPrivateKey);
  1999. JSONObject eventJSon = JSONObject.parseObject(events);
  2000. fxNowService.submit(new Runnable() {
  2001. @Override
  2002. public void run() {
  2003. try {
  2004. if (!Check.isNull(eventJSon)) {
  2005. String event = eventJSon.getString("event");
  2006. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  2007. supplyChainService.updateOrder(eventJSon);
  2008. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  2009. supplyChainService.updateItem(eventJSon);
  2010. }
  2011. }
  2012. } catch (Exception e) {
  2013. e.printStackTrace();
  2014. }
  2015. }
  2016. });
  2017. } catch (KsMerchantApiException e) {
  2018. e.printStackTrace();
  2019. }
  2020. //返回成功
  2021. Map<String, Object> result = new HashMap<>();
  2022. result.put("result", 1);
  2023. return result;
  2024. }
  2025. @PostMapping(value = "/dfcAccept")
  2026. public Map<String, Object> dfcAccept(@RequestBody String eventsEncoded) {
  2027. try {
  2028. logger.info("大风车严选消息订阅");
  2029. String events = PlatformEventSecurityUtil.decode(eventsEncoded, dfcPrivateKey);
  2030. JSONObject eventJSon = JSONObject.parseObject(events);
  2031. fxNowService.submit(new Runnable() {
  2032. @Override
  2033. public void run() {
  2034. try {
  2035. if (!Check.isNull(eventJSon)) {
  2036. String event = eventJSon.getString("event");
  2037. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  2038. supplyChainService.updateOrder(eventJSon);
  2039. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  2040. supplyChainService.updateItem(eventJSon);
  2041. }
  2042. }
  2043. } catch (Exception e) {
  2044. e.printStackTrace();
  2045. }
  2046. }
  2047. });
  2048. } catch (KsMerchantApiException e) {
  2049. e.printStackTrace();
  2050. }
  2051. //返回成功
  2052. Map<String, Object> result = new HashMap<>();
  2053. result.put("result", 1);
  2054. return result;
  2055. }
  2056. @PostMapping(value = "/mgsAccept2")
  2057. public Map<String, Object> mgsAccept2(@RequestBody String eventsEncoded) {
  2058. try {
  2059. logger.info("RX食品-二团严选消息订阅");
  2060. String events = PlatformEventSecurityUtil.decode(eventsEncoded, mgsPrivateKey2);
  2061. JSONObject eventJSon = JSONObject.parseObject(events);
  2062. logger.info("二团返回信息:{}", eventJSon);
  2063. fxNowService.submit(new Runnable() {
  2064. @Override
  2065. public void run() {
  2066. try {
  2067. if (!Check.isNull(eventJSon)) {
  2068. String event = eventJSon.getString("event");
  2069. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  2070. supplyChainService.updateOrder(eventJSon);
  2071. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  2072. supplyChainService.updateItem(eventJSon);
  2073. }
  2074. }
  2075. } catch (Exception e) {
  2076. e.printStackTrace();
  2077. }
  2078. }
  2079. });
  2080. } catch (KsMerchantApiException e) {
  2081. e.printStackTrace();
  2082. }
  2083. //返回成功
  2084. Map<String, Object> result = new HashMap<>();
  2085. result.put("result", 1);
  2086. return result;
  2087. }
  2088. @PostMapping(value = "/yufuAccept")
  2089. public Map<String, Object> yufuAccept(@RequestBody String eventsEncoded) {
  2090. try {
  2091. logger.info("渔夫睿选消息订阅");
  2092. String events = PlatformEventSecurityUtil.decode(eventsEncoded, yufuPrivateKey);
  2093. JSONObject eventJSon = JSONObject.parseObject(events);
  2094. logger.info("渔夫睿选返回信息:{}", eventJSon);
  2095. fxNowService.submit(new Runnable() {
  2096. @Override
  2097. public void run() {
  2098. try {
  2099. if (!Check.isNull(eventJSon)) {
  2100. String event = eventJSon.getString("event");
  2101. if ("kwaishop_distribute_order_change_notify".equals(event)) {
  2102. supplyChainService.updateOrder(eventJSon);
  2103. } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
  2104. supplyChainService.updateItem(eventJSon);
  2105. }
  2106. }
  2107. } catch (Exception e) {
  2108. e.printStackTrace();
  2109. }
  2110. }
  2111. });
  2112. } catch (KsMerchantApiException e) {
  2113. e.printStackTrace();
  2114. }
  2115. //返回成功
  2116. Map<String, Object> result = new HashMap<>();
  2117. result.put("result", 1);
  2118. return result;
  2119. }
  2120. @GetMapping("/addListKuaishouActivityInfo")
  2121. @ApiOperation(value = "团长查询招商活动列表")
  2122. public void addListKuaishouActivityInfo() {
  2123. try {
  2124. supplyChainService.addListKuaishouActivityInfo();
  2125. } catch (InterruptedException e) {
  2126. e.printStackTrace();
  2127. }
  2128. }
  2129. @Autowired
  2130. private ISysUserService sysUserService;
  2131. @Autowired
  2132. private ISysDeptService deptService;
  2133. @GetMapping("/shopList")
  2134. @ApiOperation(value = "商品列表")
  2135. public TableDataInfo shopList(
  2136. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  2137. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  2138. @ApiParam("结束时间") @RequestParam(value = "sellerId", required = false) Long sellerId,
  2139. @ApiParam("结束时间") @RequestParam(value = "userId", required = false) Long userId,
  2140. @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
  2141. @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort) {
  2142. TableDataInfo dataInfo = new TableDataInfo();
  2143. try {
  2144. if (Check.isNull(orderStartDate) || Check.isNull(orderEndDate)) {
  2145. throw new Exception("请输入开始时间和结束时间");
  2146. }
  2147. if (Check.isNull(userId)) {
  2148. throw new Exception("请输入用户id");
  2149. }
  2150. Map<String, Object> requestMap = new HashMap<>();
  2151. String roleKey = sysUserService.getRoleKeyByUserId(userId);
  2152. if (roleKey.equals("courtship")) {
  2153. List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
  2154. requestMap.put("itemIds", itemIds);
  2155. }
  2156. if (roleKey.equals("courtshipManager")) {
  2157. Long deptId = deptService.getDeptIdByUserId(userId);
  2158. List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
  2159. requestMap.put("itemIds", itemIds);
  2160. }
  2161. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  2162. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  2163. if (!Check.isNull(sellerId)) {
  2164. requestMap.put("sellerId", sellerId);
  2165. }
  2166. requestMap.put("fieId", fieId);
  2167. requestMap.put("sort", sort);
  2168. if (Check.isNullMap(requestMap)) {
  2169. dataInfo.setCode(-1);
  2170. dataInfo.setMsg("入参不能为空");
  2171. return dataInfo;
  2172. }
  2173. startPage();
  2174. List<JSONObject> list = supplyChainService.shopList(requestMap);
  2175. return getDataTable(list);
  2176. } catch (Exception e) {
  2177. e.printStackTrace();
  2178. dataInfo.setCode(-1);
  2179. dataInfo.setMsg(e.getMessage());
  2180. return dataInfo;
  2181. }
  2182. }
  2183. @GetMapping("/shopDetail")
  2184. @ApiOperation(value = "商品列表")
  2185. public TableDataInfo shopDetail(
  2186. @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
  2187. @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
  2188. @ApiParam("店铺Id") @RequestParam(value = "sellerId", required = false) Long sellerId,
  2189. @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
  2190. @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
  2191. @ApiParam("商品名") @RequestParam(value = "itemTitle", required = false) String itemTitle
  2192. ) {
  2193. TableDataInfo dataInfo = new TableDataInfo();
  2194. try {
  2195. if (Check.isNull(orderStartDate) || Check.isNull(orderEndDate)) {
  2196. throw new Exception("请输入开始时间和结束时间");
  2197. }
  2198. if (Check.isNull(sellerId)) {
  2199. throw new Exception("请输入店铺Id");
  2200. }
  2201. Map<String, Object> requestMap = new HashMap<>();
  2202. String roleKey = sysUserService.getRoleKeyByUserId(userId);
  2203. if (roleKey.equals("courtship")) {
  2204. List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
  2205. requestMap.put("itemIds", itemIds);
  2206. }
  2207. if (roleKey.equals("courtshipManager")) {
  2208. Long deptId = deptService.getDeptIdByUserId(userId);
  2209. List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
  2210. requestMap.put("itemIds", itemIds);
  2211. }
  2212. requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
  2213. requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
  2214. requestMap.put("sellerId", sellerId);
  2215. if (!Check.isNull(itemId)) {
  2216. requestMap.put("itemId", itemId);
  2217. }
  2218. if (!Check.isNull(itemTitle)) {
  2219. requestMap.put("itemTitle", itemTitle);
  2220. }
  2221. if (Check.isNullMap(requestMap)) {
  2222. dataInfo.setCode(-1);
  2223. dataInfo.setMsg("入参不能为空");
  2224. return dataInfo;
  2225. }
  2226. startPage();
  2227. List<JSONObject> list = supplyChainService.shopDetail(requestMap);
  2228. return getDataTable(list);
  2229. } catch (Exception e) {
  2230. e.printStackTrace();
  2231. dataInfo.setCode(-1);
  2232. dataInfo.setMsg(e.getMessage());
  2233. return dataInfo;
  2234. }
  2235. }
  2236. @PostMapping("/exportShopDetail")
  2237. @ResponseBody
  2238. public void exportShopDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  2239. try {
  2240. if (Check.isNull(requestJson.getString("orderStartDate")) || Check.isNull(requestJson.getString("orderEndDate"))) {
  2241. throw new Exception("请输入开始时间和结束时间");
  2242. }
  2243. if (Check.isNull(requestJson.getLong("sellerId"))) {
  2244. throw new Exception("请输入店铺Id");
  2245. }
  2246. Long userId = requestJson.getLong("userId");
  2247. if (Check.isNull(userId)) {
  2248. throw new Exception("请输入用户ID");
  2249. }
  2250. Map<String, Object> requestMap = new HashMap<>();
  2251. requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
  2252. requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
  2253. requestMap.put("sellerId", requestJson.getLong("sellerId"));
  2254. String roleKey = sysUserService.getRoleKeyByUserId(userId);
  2255. if (roleKey.equals("courtship")) {
  2256. List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
  2257. requestMap.put("itemIds", itemIds);
  2258. }
  2259. if (roleKey.equals("courtshipManager")) {
  2260. Long deptId = deptService.getDeptIdByUserId(userId);
  2261. List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
  2262. requestMap.put("itemIds", itemIds);
  2263. }
  2264. List<JSONObject> list = supplyChainService.shopDetail(requestMap);
  2265. List<List<Object>> exportList = new ArrayList<>();
  2266. if (!Check.isNull(list)) {
  2267. for (int i = 0; i < list.size(); i++) {
  2268. JSONObject date = list.get(i);
  2269. List<Object> export = new ArrayList();
  2270. export.add(date.getString("itemId"));
  2271. export.add(date.getString("itemTitle"));
  2272. export.add(date.getString("reservePrice"));
  2273. export.add(date.getString("userName"));
  2274. export.add(date.getString("ccrValue"));
  2275. export.add(date.getString("orderNum"));
  2276. export.add(date.getString("validOrderNUm"));
  2277. export.add(date.getString("validRadio"));
  2278. export.add(date.getString("payAmount"));
  2279. export.add(date.getString("deliveryNum"));
  2280. export.add(date.getString("shippingGreen"));
  2281. export.add(date.getString("effDeliveryNum"));
  2282. export.add(date.getString("notDeliveryNum"));
  2283. export.add(date.getString("deliveryRadio"));
  2284. export.add(date.getString("regimentalPromotionRate"));
  2285. exportList.add(export);
  2286. }
  2287. }
  2288. String[] headers = {"商品ID", "商品名称", "单价", "归属人", "ccr", "单量", "有效单量", "有效率", "付款金额", "发货数", "发货率", "有效发货数", "未发货数", "有效发货率", "服务费率"};
  2289. OutputStream os = response.getOutputStream();
  2290. ExportExcelUtils eeu = new ExportExcelUtils();
  2291. XSSFWorkbook workbook = new XSSFWorkbook();
  2292. eeu.exportExcel(workbook, 0, "店铺详情", headers, exportList);
  2293. this.setResponseHeader(response, "店铺详情.xls");
  2294. workbook.write(os);
  2295. os.flush();
  2296. os.close();
  2297. } catch (Exception e) {
  2298. e.printStackTrace();
  2299. }
  2300. }
  2301. @PostMapping("/exportShopList")
  2302. @ResponseBody
  2303. public void exportShopList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
  2304. try {
  2305. if (Check.isNull(requestJson.getString("orderStartDate")) || Check.isNull(requestJson.getString("orderEndDate"))) {
  2306. throw new Exception("请输入开始时间和结束时间");
  2307. }
  2308. Long userId = requestJson.getLong("userId");
  2309. if (Check.isNull(userId)) {
  2310. throw new Exception("请输入用户ID");
  2311. }
  2312. Map<String, Object> requestMap = new HashMap<>();
  2313. requestMap.put("start", requestJson.getString("orderStartDate"));
  2314. requestMap.put("end", requestJson.getString("orderEndDate"));
  2315. requestMap.put("fieId", "orderNum");
  2316. requestMap.put("sort", "desc");
  2317. String roleKey = sysUserService.getRoleKeyByUserId(userId);
  2318. if (roleKey.equals("courtship")) {
  2319. List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
  2320. requestMap.put("itemIds", itemIds);
  2321. }
  2322. if (roleKey.equals("courtshipManager")) {
  2323. Long deptId = deptService.getDeptIdByUserId(userId);
  2324. List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
  2325. requestMap.put("itemIds", itemIds);
  2326. }
  2327. List<JSONObject> list = supplyChainService.shopList(requestMap);
  2328. List<List<Object>> exportList = new ArrayList<>();
  2329. if (!Check.isNull(list)) {
  2330. for (int i = 0; i < list.size(); i++) {
  2331. JSONObject date = list.get(i);
  2332. List<Object> export = new ArrayList();
  2333. export.add(date.getString("sellerId"));
  2334. export.add(date.getString("sellerName"));
  2335. export.add(date.getString("orderNum"));
  2336. export.add(date.getString("validOrderNUm"));
  2337. export.add(date.getString("validRadio"));
  2338. export.add(date.getString("payAmount"));
  2339. export.add(date.getString("deliveryNum"));
  2340. export.add(date.getString("shippingGreen"));
  2341. export.add(date.getString("effDeliveryNum"));
  2342. export.add(date.getString("notDeliveryNum"));
  2343. export.add(date.getString("deliveryRadio"));
  2344. exportList.add(export);
  2345. }
  2346. }
  2347. String[] headers = {"店铺ID", "店铺名称", "单量", "有效单量", "有效率", "付款金额", "发货数", "发货率", "有效发货数", "未发货数", "有效发货率"};
  2348. OutputStream os = response.getOutputStream();
  2349. ExportExcelUtils eeu = new ExportExcelUtils();
  2350. XSSFWorkbook workbook = new XSSFWorkbook();
  2351. eeu.exportExcel(workbook, 0, "店铺列表", headers, exportList);
  2352. this.setResponseHeader(response, "店铺列表.xls");
  2353. workbook.write(os);
  2354. os.flush();
  2355. os.close();
  2356. } catch (Exception e) {
  2357. e.printStackTrace();
  2358. }
  2359. }
  2360. /**
  2361. * open.distribution.investment.activity.open.item.list
  2362. * 团长招商活动已报名商品列表
  2363. */
  2364. @GetMapping("/addKuaishouActivityOpenItemList")
  2365. @ApiOperation(value = "团长招商活动已报名商品列表")
  2366. public void addKuaishouActivityOpenItemList() {
  2367. try {
  2368. supplyChainService.addKuaishouActivityOpenItemList();
  2369. } catch (InterruptedException e) {
  2370. e.printStackTrace();
  2371. }
  2372. }
  2373. }