SupplyChainController.java 121 KB

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