SupplyChainController.java 103 KB

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