SupplyChainController.java 116 KB

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