123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643 |
- package com.ruixuan.isc.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.kuaishou.merchant.open.api.KsMerchantApiException;
- import com.kuaishou.merchant.open.api.common.utils.PlatformEventSecurityUtil;
- import com.ruixuan.common.core.controller.BaseController;
- import com.ruixuan.common.core.page.TableDataInfo;
- import com.ruixuan.common.utils.Check;
- import com.ruixuan.common.utils.DateUtils;
- import com.ruixuan.data.utils.ExportExcelUtils;
- import com.ruixuan.isc.service.IKuaishouPromoterService;
- import com.ruixuan.isc.service.ISupplyChainService;
- import com.ruixuan.system.service.ISysDeptService;
- import com.ruixuan.system.service.ISysUserService;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import lombok.SneakyThrows;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.io.UnsupportedEncodingException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @RestController
- @RequestMapping("/isv/supply_chain")
- public class SupplyChainController extends BaseController {
- @Autowired
- private ISupplyChainService supplyChainService;
- @Autowired
- private IKuaishouPromoterService promoterService;
- @Value("${accept.ruiXuanPrivateKey}")
- private String ruiXuanPrivateKey;
- @Value("${accept.mgsPrivateKey}")
- private String mgsPrivateKey;
- @Value("${accept.rocketPrivateKey}")
- private String rocketPrivateKey;
- @Value("${accept.dfcPrivateKey}")
- private String dfcPrivateKey;
- @Value("${accept.mgsPrivateKey2}")
- private String mgsPrivateKey2;
- @Value("${accept.yufuPrivateKey}")
- private String yufuPrivateKey;
- @Value("${ownership.id}")
- private String ownershipId;
- @GetMapping("/privateKey")
- @ApiOperation(value = "达人订单")
- public String privateKey() {
- return ruiXuanPrivateKey;
- }
- /**
- * 达人订单
- *
- * @param orderStartDate
- * @param orderEndDate
- * @param promoterNickName
- * @param promoterId
- * @return
- */
- @GetMapping("/orderList")
- @ApiOperation(value = "达人订单")
- public TableDataInfo orderList(@ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
- @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(promoterNickName)) {
- requestMap.put("promoterNickName", promoterNickName);
- }
- if (!Check.isNull(promoterId)) {
- requestMap.put("promoterId", promoterId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.getOrderList(requestMap);
- return getDataTable(list);
- }
- /**
- * 达人带货详情
- *
- * @param promoterId
- * @param orderStartDate
- * @param orderEndDate
- * @param itemTitle
- * @param itemId
- * @return
- */
- @GetMapping("/anchorOrderDetail")
- @ApiOperation(value = "达人带货详情")
- public TableDataInfo anchorOrderDetail(
- @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
- @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
- @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(promoterId)) {
- requestMap.put("promoterId", promoterId);
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.anchorOrderDetail(requestMap);
- return getDataTable(list);
- }
- /**
- * 订单统计
- *
- * @param promoterId
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/orderStatistics")
- @ApiOperation(value = "订单统计")
- public JSONObject orderStatistics(
- @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
- @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(promoterId)) {
- requestMap.put("promoterId", promoterId);
- }
- JSONObject returnJson = new JSONObject();
- if (Check.isNullMap(requestMap)) {
- returnJson.put("code", -1);
- returnJson.put("message", "入参不能为空");
- return returnJson;
- }
- List<JSONObject> list = supplyChainService.orderStatistics(requestMap);
- returnJson.put("code", 0);
- returnJson.put("data", list);
- return returnJson;
- }
- /**
- * 商品列表
- *
- * @param itemId
- * @param itemTitle
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/itemList")
- @ApiOperation(value = "商品列表")
- public TableDataInfo itemList(
- @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
- @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("开始时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
- @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
- @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
- @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort,
- @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- requestMap.put("start", DateUtils.strDateToInt(bindStartDate));
- requestMap.put("bindStartDate", bindStartDate);
- requestMap.put("end", DateUtils.strDateToInt(bindEndDate));
- requestMap.put("bindEndDate", bindEndDate);
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- requestMap.put("fieId", fieId);
- requestMap.put("sort", sort);
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
- list = supplyChainService.itemList(requestMap);
- } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- list = supplyChainService.itemBindList(requestMap);
- }
- return getDataTable(list);
- }
- @PostMapping("/exportOrder")
- @ApiOperation(value = "exportOrder")
- @ResponseBody
- public void exportOrder(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate"));
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(requestJson.getString("bindStartDate"))) {
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("bindStartDate")));
- requestMap.put("bindStartDate", requestJson.getString("bindStartDate"));
- }
- if (!Check.isNull(requestJson.getString("bindEndDate"))) {
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("bindEndDate")));
- requestMap.put("bindEndDate", requestJson.getString("bindEndDate"));
- }
- if (!Check.isNull(requestJson.getString("promoterNickName"))) {
- requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
- }
- if (!Check.isNull(requestJson.getLong("promoterId"))) {
- requestMap.put("promoterId", requestJson.getLong("promoterId"));
- }
- if (!Check.isNull(requestJson.getLong("itemId"))) {
- requestMap.put("itemId", requestJson.getLong("itemId"));
- }
- if (!Check.isNull(requestJson.getString("itemTitle"))) {
- requestMap.put("itemTitle", requestJson.getString("itemTitle"));
- }
- if (!Check.isNull(requestJson.getLong("userId"))) {
- requestMap.put("userId", requestJson.getLong("userId"));
- }
- String[] headers = null;
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- list = supplyChainService.exportOrder(requestMap);
- headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "订单数环比", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
- } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
- list = supplyChainService.exportBindOrder(requestMap);
- headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
- }
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("userName"));
- export.add(date.getLong("itemId"));
- export.add(date.getString("itemTitle"));
- export.add(date.getString("isPresale"));
- export.add(date.getString("imageUrl"));
- export.add(date.getString("itemCommissionRate"));
- export.add(date.getInteger("orderNum"));
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- export.add(date.getString("orderNumRoi"));
- }
- export.add(date.getInteger("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("notDeliveryNum"));
- export.add(date.getString("ccrValue"));
- export.add(date.getString("shopStar"));
- export.add(date.getString("mallLogisticsScore"));
- export.add(date.getString("shopScore"));
- export.add(date.getString("mallServiceScore"));
- export.add(date.getString("mallQualityScore"));
- exportList.add(export);
- }
- }
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
- this.setResponseHeader(response, "订单信息.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- /**
- * 根据商品id获取top达人
- *
- * @param itemId
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/getTopPromoterByItemId")
- @ApiOperation(value = "商品列表")
- public TableDataInfo getTopPromoterByItemId(
- @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- List<JSONObject> list = supplyChainService.getTopPromoterByItemId(requestMap);
- return getDataTable(list);
- }
- /**
- * 商品详情
- *
- * @param itemId
- * @param orderStartDate
- * @param orderEndDate
- * @param promoterId
- * @param promoterNickName
- * @return
- */
- @GetMapping("/itemDetail")
- @ApiOperation(value = "商品详情")
- public TableDataInfo itemDetail(
- @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId,
- @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
- @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
- @ApiParam("渠道名称") @RequestParam(value = "userId", required = false) Integer userId
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(promoterId)) {
- requestMap.put("promoterId", promoterId);
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(promoterNickName)) {
- requestMap.put("itemTitle", promoterNickName);
- }
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.itemDetail(requestMap);
- return getDataTable(list);
- }
- @PostMapping("/exportItemDetail")
- @ResponseBody
- public void exportItemDetail(
- HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson
- ) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
- }
- if (!Check.isNull(requestJson.getLong("promoterId"))) {
- requestMap.put("promoterId", requestJson.getLong("promoterId"));
- }
- if (!Check.isNull(requestJson.getLong("itemId"))) {
- requestMap.put("itemId", requestJson.getLong("itemId"));
- }
- if (!Check.isNull(requestJson.getString("promoterNickName"))) {
- requestMap.put("itemTitle", requestJson.getString("promoterNickName"));
- }
- if (!Check.isNull(requestJson.getLong("userId"))) {
- requestMap.put("userId", requestJson.getLong("userId"));
- }
- List<JSONObject> list = supplyChainService.exportItemDetail(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject data = list.get(i);
- List<Object> export = new ArrayList();
- export.add(data.getString("userName"));
- String promoterNickName = data.getString("promoterNickName");
- String promoterId = data.getString("promoterId");
- String name = promoterNickName + "(" + promoterId + ")";
- export.add(name);
- export.add(data.getInteger("orderNum"));
- export.add(data.getString("validOrderNUm"));
- export.add(data.getString("validRadio"));
- export.add(data.getString("deliveryNum"));
- export.add(data.getString("shippingGreen"));
- export.add(data.getString("effDeliveryNum"));
- export.add(data.getString("deliveryRadio"));
- export.add(data.getString("notDeliveryNum"));
- export.add(data.getInteger("payAmount"));
- export.add(data.getString("regimentalPromotionRate"));
- exportList.add(export);
- }
- String[] headers = {"绑定人", "达人信息", "单量", "有效订单数", "有效率", "发货数", "发货率", "有效发货数", "有效发货率", "未发货数", "付款金额", "服务费率"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "商品出单详情", headers, exportList);
- this.setResponseHeader(response, "商品出单详情.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- }
- /**
- * 产品服务费
- *
- * @param itemId
- * @param itemTitle
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/itemServiceCharge")
- @ApiOperation(value = "产品服务费")
- public TableDataInfo itemServiceCharge(
- @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
- @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.itemServiceCharge(requestMap);
- return getDataTable(list);
- }
- /**
- * 首页-订单数据
- *
- * @param dateType
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/indexOrderInfo")
- @ApiOperation(value = "首页-订单数据")
- public JSONObject orderTotal(
- @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- if (dateType == 0) {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
- returnJson.put("orderTotal", orderTotal);
- Integer hour = DateUtils.getNowHour(); // 当前小时
- if (hour >= 0) {
- JSONObject ratioJson = new JSONObject();
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
- // Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳
- // Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳
- Map<String, Object> ratioMap = new HashMap<>();
- ratioMap.put("nowStartHourTemp", nowStartHourTemp);
- ratioMap.put("hour", hour);
- ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- Double ringRatio = supplyChainService.getOrderTotalRatio(ratioMap); //环比
- ratioJson.put("ringRatio", ringRatio);
- String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
- Long yearStartHourTemp = DateUtils.strDateToInt(yearDay); //前7日开始时间戳
- // Long yearEndHourTemp = DateUtils.getNowEndHourTemp(yearDay, hour);//前7日结束时间戳
- ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
- Double yearRatio = supplyChainService.getOrderTotalRatio(ratioMap); //同比
- ratioJson.put("yearRatio", yearRatio);
- returnJson.put("ratio", ratioJson);
- }
- } else {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
- returnJson.put("orderTotal", orderTotal);
- }
- return returnJson;
- }
- /**
- * 首页-金额数据
- *
- * @param dateType
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/indexAmountInfo")
- @ApiOperation(value = "首页-金额数据")
- public JSONObject indexAmountInfo(
- @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- if (dateType == 0) {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
- returnJson.put("amountTotal", amountTotal);
- Integer hour = DateUtils.getNowHour(); // 当前小时
- if (hour >= 0) {
- JSONObject amountRatioJson = new JSONObject();
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
- Map<String, Object> ratioMap = new HashMap<>();
- ratioMap.put("nowStartHourTemp", nowStartHourTemp);
- ratioMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- ratioMap.put("hour", hour);
- Double amountRingRatio = supplyChainService.getAmountTotalRatio(ratioMap); //环比
- amountRatioJson.put("amountRingRatio", amountRingRatio);
- String yearDay = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6); // 昨日日期
- Long yearStartHourTemp = DateUtils.strDateToInt(yearDay); //前7日开始时间
- ratioMap.put("yesterdayStartHourTemp", yearStartHourTemp);
- Double amountYearRatio = supplyChainService.getAmountTotalRatio(ratioMap); //同比
- amountRatioJson.put("amountYearRatio", amountYearRatio);
- returnJson.put("amountRatio", amountRatioJson);
- }
- } else {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
- returnJson.put("amountTotal", amountTotal);
- }
- return returnJson;
- }
- /**
- * 首页-服务费数据
- *
- * @param dateType
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/indexServiceAmountInfo")
- @ApiOperation(value = "首页-服务费数据")
- public JSONObject indexServiceAmountInfo(
- @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- JSONObject serviceAmountTotal = supplyChainService.getServiceAmountTotal(requestMap);
- returnJson.put("serviceAmountTotal", serviceAmountTotal);
- return returnJson;
- }
- /**
- * 首页-商品排行
- *
- * @param dateType
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/indexOrderRank")
- @ApiOperation(value = "首页-商品排行")
- public TableDataInfo indexOrderRank(
- @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
- @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (dateType == 0) {
- if ("1".equals(mediaId)) {
- return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
- } else {
- Integer hour = DateUtils.getNowHour(); // 当前小时
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
- requestMap.put("nowStartHourTemp", nowStartHourTemp);
- requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- requestMap.put("hour", hour);
- startPage();
- List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioList(requestMap);
- return getDataTable(orderRankRatioList);
- }
- } else {
- if ("1".equals(mediaId)) {
- return indexOrderRankBytedance(dateType, orderStartDate, orderEndDate);
- } else {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- startPage();
- List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankList(requestMap);
- return getDataTable(orderRankRatioList);
- }
- }
- }
- private TableDataInfo indexOrderRankBytedance(Integer dateType, String orderStartDate, String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- if (dateType == 0) {
- Integer hour = DateUtils.getNowHour(); // 当前小时
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate);
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日时间
- requestMap.put("nowStartHourTemp", nowStartHourTemp);
- requestMap.put("nowEndHourTemp", nowStartHourTemp);
- requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
- requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
- requestMap.put("hour", hour);
- startPage();
- List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankRatioListBytedance(requestMap);
- return getDataTable(orderRankRatioList);
- } else {
- if (!Check.isNull(orderStartDate)) {
- Long start = DateUtils.strDateToInt(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Long end = DateUtils.strDateToInt(orderEndDate);
- requestMap.put("end", end);
- }
- startPage();
- List<JSONObject> orderRankRatioList = supplyChainService.getOrderRankListBytedance(requestMap);
- return getDataTable(orderRankRatioList);
- }
- }
- @GetMapping("/indexPromoterRank")
- @ApiOperation(value = "首页-达人排行")
- public TableDataInfo indexPromoterRank(
- @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
- @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (dateType == 0) {
- if ("1".equals(mediaId)) {
- return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
- } else {
- if (Check.isNotNull(userId)) {
- List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), mediaId);
- if (Check.isNull(promoterIds)) {
- return getDataTable(null);
- }
- requestMap.put("promoterIds", promoterIds);
- }
- if (!Check.isNull(orderStartDate)) {
- Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Long end = DateUtils.getEndLongTime(orderEndDate); // 当天结束时间
- requestMap.put("end", end);
- }
- Integer hour = DateUtils.getNowHour(); // 当前小时
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间
- requestMap.put("nowStartHourTemp", nowStartHourTemp);
- requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- requestMap.put("hour", hour);
- startPage();
- List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioList(requestMap);
- return getDataTable(promoterRankRatioList);
- }
- } else {
- if ("1".equals(mediaId)) {
- return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId);
- } else {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- startPage();
- List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioList(requestMap);
- return getDataTable(orderRatioList);
- }
- }
- }
- public TableDataInfo indexPromoterRankBytedance(Integer dateType, String orderStartDate, String orderEndDate, Long userId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (dateType == 0) {
- if (Check.isNotNull(userId)) {
- List<String> promoterIds = promoterService.selectPromoterIdList(Arrays.asList(userId), "1");
- if (Check.isNull(promoterIds)) {
- return getDataTable(null);
- }
- requestMap.put("promoterIds", promoterIds);
- }
- Integer hour = DateUtils.getNowHour(); // 当前小时
- Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
- String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期
- Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳
- requestMap.put("nowStartHourTemp", nowStartHourTemp);
- requestMap.put("nowEndHourTemp", nowStartHourTemp);
- requestMap.put("yesterdayStartHourTemp", yesterdayStartHourTemp);
- requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
- requestMap.put("yesterdayEndHourTemp", yesterdayStartHourTemp);
- requestMap.put("hour", hour);
- startPage();
- List<JSONObject> promoterRankRatioList = supplyChainService.getPromoterRankRatioListBytedance(requestMap);
- return getDataTable(promoterRankRatioList);
- } else {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- startPage();
- List<JSONObject> orderRatioList = supplyChainService.getPromoterRatioListBytedance(requestMap);
- return getDataTable(orderRatioList);
- }
- }
- @PostMapping("/exportPromoterTotal")
- @ApiOperation(value = "exportPromoterTotal")
- @ResponseBody
- public void exportPromoterTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate"));
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(requestJson.getString("promoterNickName"))) {
- requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
- }
- if (!Check.isNull(requestJson.getLong("promoterId"))) {
- requestMap.put("promoterId", requestJson.getLong("promoterId"));
- }
- if (!Check.isNull(requestJson.getLong("itemId"))) {
- requestMap.put("itemId", requestJson.getLong("itemId"));
- }
- if (!Check.isNull(requestJson.getString("itemTitle"))) {
- requestMap.put("itemTitle", requestJson.getString("itemTitle"));
- }
- List<JSONObject> list = supplyChainService.exportPromoterTotal(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) {
- Long promoterId = date.getLong("promoterId");
- export.add(promoterId);
- String promoterNickName = date.getString("promoterNickName");
- export.add(promoterNickName);
- } else {
- Long promoterId = date.getLong("promoterId");
- String promoterNickName = date.getString("promoterNickName");
- String name = promoterNickName + "(" + promoterId + ")";
- export.add(name);
- }
- export.add(date.getInteger("orderNum"));
- export.add(date.getString("orderNumRoi"));
- export.add(date.getInteger("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("payAmount"));
- export.add(date.getString("validPayAmount"));
- // export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("notDeliveryNum"));
- String userName = supplyChainService.getUserName(date.getLong("promoterId"));
- if (!Check.isNull(userName)) {
- export.add(userName);
- }
- /* Map<String, Object> map = new HashMap<>();
- map.put("promoterId", promoterId);
- map.put("start", DateUtils.getStartLongTime(requestJson.getString("orderStartDate")));
- map.put("end", DateUtils.getEndLongTime(requestJson.getString("orderEndDate")));
- List<JSONObject> topOrders = supplyChainService.getTopOrders(map);
- if (!Check.isNull(topOrders)) {
- JSONObject top1 = topOrders.get(0);
- StringBuffer top1StringBuffer = new StringBuffer();
- top1StringBuffer.append("商品ID:").append(top1.getString("itemId")).append(String.valueOf((char) 10))
- .append("出单量:").append(top1.getString("orderNum")).append(String.valueOf((char) 10))
- .append("标题:").append(top1.getString("itemTitle")).append(String.valueOf((char) 10))
- .append("链接:").append(top1.getString("imageUrl"));
- export.add(top1StringBuffer);
- }
- if (!Check.isNull(topOrders) && topOrders.size() >= 2) {
- JSONObject top2 = topOrders.get(1);
- if (!Check.isNull(top2)) {
- StringBuffer top2StringBuffer = new StringBuffer();
- top2StringBuffer.append("商品ID:").append(top2.getString("itemId")).append(String.valueOf((char) 10))
- .append("出单量:").append(top2.getString("orderNum")).append(String.valueOf((char) 10))
- .append("标题:").append(top2.getString("itemTitle")).append(String.valueOf((char) 10))
- .append("链接:").append(top2.getString("imageUrl"));
- export.add(top2StringBuffer);
- }
- }
- if (!Check.isNull(topOrders) && topOrders.size() >= 3) {
- JSONObject top3 = topOrders.get(2);
- if (!Check.isNull(top3)) {
- StringBuffer top3StringBuffer = new StringBuffer();
- top3StringBuffer.append("商品ID:").append(top3.getString("itemId")).append(String.valueOf((char) 10))
- .append("出单量:").append(top3.getString("orderNum")).append(String.valueOf((char) 10))
- .append("标题:").append(top3.getString("itemTitle")).append(String.valueOf((char) 10))
- .append("链接:").append(top3.getString("imageUrl"));
- export.add(top3StringBuffer);
- }
- }*/
- exportList.add(export);
- }
- }
- String[] headers = {};
- if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) {
- headers = new String[]{"达人ID", "达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
- } else {
- headers = new String[]{"达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
- }
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
- this.setResponseHeader(response, "达人信息.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- @RequestMapping(value = "/exportPromoter")
- @ResponseBody
- public void exportPromoter(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
- }
- if (!Check.isNull(requestJson.getString("promoterNickName"))) {
- requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
- }
- if (!Check.isNull(requestJson.getLong("promoterId"))) {
- requestMap.put("promoterId", requestJson.getLong("promoterId"));
- }
- if (!Check.isNull(requestJson.getLong("itemId"))) {
- requestMap.put("itemId", requestJson.getLong("itemId"));
- }
- if (!Check.isNull(requestJson.getString("itemTitle"))) {
- requestMap.put("itemTitle", requestJson.getString("itemTitle"));
- }
- List<JSONObject> list = supplyChainService.exportPromoter(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- String promoterNickName = date.getString("promoterNickName");
- Long promoterId = date.getLong("promoterId");
- Long itemId = date.getLong("itemId");
- String itemTitle = date.getString("itemTitle");
- if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) {
- export.add(promoterNickName);
- export.add(promoterId);
- export.add(itemTitle);
- export.add(itemId);
- } else {
- String promoter = promoterNickName + "(" + promoterId + ")";
- export.add(promoter);
- String item = itemTitle + "(" + itemId + ")";
- export.add(item);
- }
- export.add(date.getString("imageUrl"));
- export.add(date.getInteger("orderNum"));
- export.add(date.getInteger("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("activityItemStatus"));
- exportList.add(export);
- }
- }
- String[] headers = {};
- if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) {
- headers = new String[]{"达人名称", "达人id", "商品名称", "商品id", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
- } else {
- headers = new String[]{"达人", "商品", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
- }
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "达人信息", headers, exportList);
- this.setResponseHeader(response, "达人信息.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- /**
- * 获取供应链人员列表
- *
- * @return
- */
- @GetMapping("/getSupplyChainUserList")
- @ApiOperation(value = "获取供应链成员列表")
- public TableDataInfo getSupplyChainUserList() {
- List<JSONObject> list = supplyChainService.getSupplyChainUserList();
- return getDataTable(list);
- }
- @GetMapping("/getSupplyChainCourtshipUserList")
- @ApiOperation(value = "获取供应链成员列表")
- public TableDataInfo getSupplyChainCourtshipUserList() {
- List<JSONObject> list = supplyChainService.getSupplyChainCourtshipUserList();
- return getDataTable(list);
- }
- /**
- * 获取商品绑定人员列表
- *
- * @param status
- * @param userId
- * @param itemId
- * @param itemTitle
- * @param activityId
- * @return
- */
- @GetMapping("/bindUserItemList")
- @ApiOperation(value = "商品认领列表")
- public TableDataInfo bindUserItemList(
- @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status,
- @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId,
- @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
- @ApiParam("活动ID") @RequestParam(value = "activityId", required = false) Long activityId
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(status)) {
- requestMap.put("status", status);
- }
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- if (!Check.isNull(activityId)) {
- requestMap.put("activityId", activityId);
- }
- startPage();
- List<JSONObject> list = supplyChainService.bindUserItemList(requestMap);
- return getDataTable(list);
- }
- /**
- * 商品解绑
- *
- * @param itemId
- * @return
- */
- @GetMapping("/unbindUser")
- @ApiOperation(value = "商品解绑")
- public JSONObject unbindUser(
- @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId) {
- JSONObject returnJson = new JSONObject();
- if (Check.isNull(itemId)) {
- returnJson.put("code", -1);
- returnJson.put("message", "请传入商品ID");
- return returnJson;
- }
- boolean isTrueOrFalse = supplyChainService.unbindUser(itemId);
- if (isTrueOrFalse) {
- returnJson.put("code", 0);
- returnJson.put("message", "解绑成功");
- return returnJson;
- } else {
- returnJson.put("code", -1);
- returnJson.put("message", "解绑失败");
- return returnJson;
- }
- }
- /**
- * 绑定商品
- *
- * @param itemId
- * @return
- */
- @GetMapping("/bindUser")
- @ApiOperation(value = "绑定商品")
- public JSONObject bindUser(
- @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
- @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("用户名称") @RequestParam(value = "nikeName", required = false) String nikeName) {
- JSONObject returnJson = new JSONObject();
- if (Check.isNull(itemId)) {
- returnJson.put("code", -1);
- returnJson.put("message", "请传入商品ID");
- return returnJson;
- }
- if (Check.isNull("userId")) {
- returnJson.put("code", -1);
- returnJson.put("message", "请传入用户ID");
- return returnJson;
- }
- if (Check.isNull("nikeName")) {
- returnJson.put("code", -1);
- returnJson.put("message", "请传入用户名称");
- return returnJson;
- }
- boolean isTrueOrFalse = supplyChainService.bindUser(itemId, userId, nikeName);
- if (isTrueOrFalse) {
- returnJson.put("code", 0);
- returnJson.put("message", "认领成功");
- return returnJson;
- } else {
- returnJson.put("code", -1);
- returnJson.put("message", "认领失败");
- return returnJson;
- }
- }
- /**
- * 供应链管理员统计列表
- *
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @GetMapping("/adminReportList")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo adminReportList(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
- @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
- @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(orderStartDate, orderEndDate);
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- requestMap.put("startDate", bindStartDate);
- requestMap.put("endDate", bindEndDate + " 23:59:59");
- }
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- List<JSONObject> list = new ArrayList<>();
- startPage();
- if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
- list = supplyChainService.adminReportList(requestMap);
- } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- list = supplyChainService.adminReportListByBind(requestMap);
- }
- return getDataTable(list);
- }
- @PostMapping("/exportAdminReportList")
- @ApiOperation(value = "供应链管理员统计列表")
- public void exportAdminReportList(
- HttpServletRequest request, HttpServletResponse response,
- @RequestBody JSONObject requestJson
- ) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- requestMap.put("startDate", requestJson.getString("orderStartDate"));
- requestMap.put("endDate", requestJson.getString("orderEndDate") + " 23:59:59");
- //根据本阶段日期 获取上阶段 开始 和 截至 日期
- Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderStartDate"));
- //下个周期的开始时间
- String lastTimeStart = map.get("lastTimeStart");
- //下个周期的结束时间
- String lastTimeEnd = map.get("lastTimeEnd");
- //当前小时
- Integer hour = DateUtils.getNowHour();
- //当天 yyyy-MM-dd
- String today = DateUtils.getNowDateStr();
- if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderStartDate")) && requestJson.getString("orderStartDate").equals(today))) {
- hour = 23;
- }
- requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
- requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
- requestMap.put("hour", hour);
- }
- if (!Check.isNull(requestJson.getString("bindStartDate"))) {
- Long start = DateUtils.getStartLongTime(requestJson.getString("bindStartDate"));
- requestMap.put("start", start);
- requestMap.put("startDate", requestJson.getString("bindStartDate"));
- }
- if (!Check.isNull(requestJson.getString("bindEndDate"))) {
- Long end = DateUtils.getEndLongTime(requestJson.getString("bindEndDate"));
- requestMap.put("end", end);
- requestMap.put("endDate", requestJson.getString("bindEndDate") + " 23:59:59");
- }
- if (!Check.isNull(requestJson.getString("userId"))) {
- requestMap.put("userId", requestJson.getString("userId"));
- }
- String[] headers = null;
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- list = supplyChainService.exportAdminReportList(requestMap);
- headers = new String[]{"招商", "商品数", "发样数", "订单数", "订单数环比", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
- } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
- list = supplyChainService.exportAdminReportListByBind(requestMap);
- headers = new String[]{"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
- }
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("userName"));
- export.add(date.getString("itemCount"));
- export.add(date.getString("sendSampleCount"));
- export.add(date.getString("orderNum"));
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- export.add(date.getString("orderNumRoi"));
- }
- export.add(date.getString("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("notDeliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("payAmount"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- export.add(date.getString("avgServiceRate"));
- exportList.add(export);
- }
- }
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
- this.setResponseHeader(response, "订单信息.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- /**
- * 认领商品列表
- *
- * @param userId
- * @param orderStartDate
- * @param orderEndDate
- * @param itemId
- * @param itemTitle
- * @return
- */
- @GetMapping("/userItemDetail")
- @ApiOperation(value = "认领商品列表")
- public TableDataInfo userItemDetail(
- @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) Long itemId,
- @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
- @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
- @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- requestMap.put("fieId", fieId);
- requestMap.put("sort", sort);
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.userItemDetail(requestMap);
- return getDataTable(list);
- }
- /**
- * 认领商品列表导出
- *
- * @return
- */
- @PostMapping("/exportUserItemDetail")
- @ApiOperation(value = "认领商品列表")
- @ResponseBody
- public void exportUserItemDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getLong("userId"))) {
- requestMap.put("userId", requestJson.getLong("userId"));
- }
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- Long start = DateUtils.strDateToInt(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Long end = DateUtils.strDateToInt(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- }
- if (!Check.isNull(requestJson.getLong("itemId"))) {
- requestMap.put("itemId", requestJson.getLong("itemId"));
- }
- if (!Check.isNull(requestJson.getString("itemTitle"))) {
- requestMap.put("itemTitle", requestJson.getString("itemTitle"));
- }
- List<JSONObject> list = supplyChainService.exportUserItemDetail(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("userName"));
- export.add(date.getLong("itemId"));
- export.add(date.getString("itemTitle"));
- export.add(date.getString("reservePrice"));
- export.add(date.getString("itemCommissionRate"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("invalidOrderNUm"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("notDeliveryNum"));
- export.add(date.getString("payAmount"));
- export.add(date.getString("regimentalPromotionRate"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- export.add(date.getString("imageUrl"));
- export.add(date.getString("ccrValue"));
- exportList.add(export);
- }
- }
- String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "结算服务费收入", "商品封面", "ccr"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "认领列表", headers, exportList);
- this.setResponseHeader(response, "认领列表.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- @GetMapping("/userItemTotal")
- @ApiOperation(value = "认领商品列表汇总")
- public JSONObject userItemTotal(
- @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate
- ) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(userId)) {
- requestMap.put("userId", userId);
- }
- if (!Check.isNull(orderStartDate)) {
- Long start = DateUtils.strDateToInt(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Long end = DateUtils.strDateToInt(orderEndDate);
- requestMap.put("end", end);
- }
- JSONObject returnJson = supplyChainService.userItemTotal(requestMap);
- return returnJson;
- }
- /**
- * 商品认领汇总
- *
- * @return
- */
- @GetMapping("/itemBindSummary")
- @ApiOperation(value = "商品认领汇总")
- public JSONObject itemBindSummary() {
- JSONObject json = supplyChainService.itemBindSummary();
- return json;
- }
- /**
- * 首页-时段对比
- *
- * @param orderStartDate
- * @param orderEndDate
- * @return
- */
- @SneakyThrows
- @GetMapping("/indexTimeIntervalRatio")
- @ApiOperation(value = "首页-时段对比")
- public JSONObject indexTimeIntervalRatio(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
- Map<String, Object> requestMap = new HashMap<>();
- String nowDate = DateUtils.getNowDateStr();
- String thisCycleEnd = null; // 当前时段结束日期
- String thisCycleStart = null; // 当前时段开始日期
- String lastCycleEnd = null; // 上一时段结束日期
- String lastCycleStart = null; // 上一时段开始日期
- if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
- thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
- thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6);
- lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1);
- lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6);
- } else {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate));
- thisCycleEnd = orderEndDate;
- thisCycleStart = orderStartDate;
- lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1);
- lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay);
- }
- if (!Check.isNull(thisCycleStart)) {
- Long thisCycleStartTemp = DateUtils.strDateToInt(thisCycleStart);
- requestMap.put("thisCycleStartTemp", thisCycleStartTemp);
- }
- if (!Check.isNull(thisCycleEnd)) {
- Long thisCycleEndTemp = DateUtils.strDateToInt(thisCycleEnd);
- requestMap.put("thisCycleEndTemp", thisCycleEndTemp);
- }
- if (!Check.isNull(lastCycleStart)) {
- Long lastCycleStartTemp = DateUtils.strDateToInt(lastCycleStart);
- requestMap.put("lastCycleStartTemp", lastCycleStartTemp);
- }
- if (!Check.isNull(lastCycleEnd)) {
- Long lastCycleEndTemp = DateUtils.strDateToInt(lastCycleEnd);
- requestMap.put("lastCycleEndTemp", lastCycleEndTemp);
- }
- JSONObject timeIntervalRatioJson = supplyChainService.getTimeIntervalRatio(requestMap);
- return timeIntervalRatioJson;
- }
- /**
- * 首页-统计图
- *
- * @param orderStartDate
- * @param orderEndDate
- * @param type
- * @return
- */
- @GetMapping("/indexStatistics")
- @ApiOperation(value = "首页-统计图")
- public List<JSONObject> indexStatistics(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("类型") @RequestParam(value = "type", required = false) String type) {
- Map<String, Object> requestMap = new HashMap<>();
- String nowDate = DateUtils.getNowDateStr();
- String start = null;
- String end = null;
- if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
- end = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
- start = DateUtils.getAnotherDay("yyyy-MM-dd", end, -6);
- } else {
- start = orderStartDate;
- end = orderEndDate;
- }
- if (!Check.isNull(start)) {
- Long startTemp = DateUtils.strDateToInt(start);
- requestMap.put("startTemp", startTemp);
- }
- if (!Check.isNull(end)) {
- Long endTemp = DateUtils.strDateToInt(end);
- requestMap.put("endTemp", endTemp);
- }
- if (!Check.isNull(type)) {
- requestMap.put("type", type);
- }
- List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
- return list;
- }
- //发送响应流方法
- public void setResponseHeader(HttpServletResponse response, String fileName) {
- try {
- try {
- fileName = new String(fileName.getBytes(), "ISO8859-1");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- response.setContentType("application/octet-stream;charset=ISO8859-1");
- response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
- response.addHeader("Pargam", "no-cache");
- response.addHeader("Cache-Control", "no-cache");
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- @GetMapping("/bdReportList")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdReportList(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.bdReportList(requestMap);
- return getDataTable(list);
- }
- @PostMapping("/exportBdReportList")
- @ApiOperation(value = "供应链管理员统计列表")
- @ResponseBody
- public void exportBdReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- }
- if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
- requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
- }
- List<JSONObject> list = supplyChainService.exportBdReportList(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("collectSampleId"));
- export.add(date.getString("collectSampleName"));
- export.add(date.getString("promoterCount"));
- export.add(date.getString("sampleCount"));
- export.add(date.getString("sampleRate"));
- export.add(date.getString("notSampleCount"));
- export.add(date.getString("sendTotalCount"));
- export.add(date.getString("sendPromoterCount"));
- export.add(date.getString("sendItemCount"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("voucherOrderNum"));
- export.add(date.getString("validOrderNum"));
- export.add(date.getString("voucherValidOrderNum"));
- export.add(date.getString("validOrderRate"));
- export.add(date.getString("orderAmount"));
- export.add(date.getString("voucherOrderAmount"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("voucherRegimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- export.add(date.getString("voucherTotalRegimentalSettleAmount"));
- exportList.add(export);
- }
- }
- String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "(凭)订单数", "有效订单数", "(凭)有效订单数", "有效订单率", "订单金额", "凭(订单金额)", "预估服务费", "(凭)预估服务费", "结算服务费", "(凭)结算服务费"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "bd业绩汇总", headers, exportList);
- this.setResponseHeader(response, "bd业绩汇总.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- @GetMapping("/bdDetailList")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdDetailList(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
- @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
- @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- requestMap.put("fieId", fieId);
- requestMap.put("sort", sort);
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.bdDetailList(requestMap);
- return getDataTable(list);
- }
- @GetMapping("/bdTotal")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdTotal(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.bdTotal(requestMap);
- return getDataTable(list);
- }
- @PostMapping("/exportBdDetail")
- @ApiOperation(value = "认领商品列表")
- @ResponseBody
- public void exportBdDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- }
- if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
- requestMap.put("collectSampleId", (requestJson.getLong("collectSampleId")));
- }
- List<JSONObject> list = supplyChainService.exportBdDetail(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("promoterId"));
- export.add(date.getString("promoterName"));
- export.add(date.getString("sampleCount"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNum"));
- export.add(date.getString("validOrderRate"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- export.add(date.getString("promoterUrl"));
- exportList.add(export);
- }
- }
- String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
- this.setResponseHeader(response, "bd业绩.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- @GetMapping("/bdReportListV2")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdReportListV2(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
- @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- if (!Check.isNull(bindStartDate)) {
- Integer start = DateUtils.getIntegerTime(bindStartDate);
- requestMap.put("bindStartDate", start);
- }
- if (!Check.isNull(bindEndDate)) {
- Integer end = DateUtils.getIntegerTime(bindEndDate);
- requestMap.put("bindEndDate", end);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
- list = supplyChainService.bdReportListV2(requestMap);
- } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- list = supplyChainService.bdReportListV2ByBind(requestMap);
- }
- return getDataTable(list);
- }
- @PostMapping("/exportBdReportListV2")
- @ApiOperation(value = "供应链管理员统计列表")
- @ResponseBody
- public void exportBdReportListV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- }
- if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
- requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
- }
- if (!Check.isNull(requestJson.getString("bindStartDate"))) {
- Integer start = DateUtils.getIntegerTime(requestJson.getString("bindStartDate"));
- requestMap.put("bindStartDate", start);
- }
- if (!Check.isNull(requestJson.getString("bindEndDate"))) {
- Integer end = DateUtils.getIntegerTime(requestJson.getString("bindEndDate"));
- requestMap.put("bindEndDate", end);
- }
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- list = supplyChainService.bdReportListV2(requestMap);
- } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
- list = supplyChainService.bdReportListV2ByBind(requestMap);
- }
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("collectSampleId"));
- export.add(date.getString("collectSampleName"));
- export.add(date.getString("promoterCount"));
- export.add(date.getString("sampleCount"));
- export.add(date.getString("sampleRate"));
- export.add(date.getString("notSampleCount"));
- export.add(date.getString("sendTotalCount"));
- export.add(date.getString("sendPromoterCount"));
- export.add(date.getString("sendItemCount"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNum"));
- export.add(date.getString("validOrderRate"));
- export.add(date.getString("orderAmount"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- exportList.add(export);
- }
- }
- String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "有效订单数", "有效订单率", "订单金额", "预估服务费", "结算服务费"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "bd业绩汇总V2", headers, exportList);
- this.setResponseHeader(response, "bd业绩汇总V2.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- @GetMapping("/bdTotalV2")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdTotalV2(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.bdTotalV2(requestMap);
- return getDataTable(list);
- }
- @GetMapping("/bdDetailListV2")
- @ApiOperation(value = "供应链管理员统计列表")
- public TableDataInfo bdDetailListV2(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
- @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
- @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(orderStartDate)) {
- Integer start = DateUtils.getIntegerTime(orderStartDate);
- requestMap.put("start", start);
- }
- if (!Check.isNull(orderEndDate)) {
- Integer end = DateUtils.getIntegerTime(orderEndDate);
- requestMap.put("end", end);
- }
- if (!Check.isNull(collectSampleId)) {
- requestMap.put("collectSampleId", collectSampleId);
- }
- requestMap.put("fieId", fieId);
- requestMap.put("sort", sort);
- TableDataInfo dataInfo = new TableDataInfo();
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(500);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
- return getDataTable(list);
- }
- @PostMapping("/exportBdDetailV2")
- @ApiOperation(value = "认领商品列表")
- @ResponseBody
- public void exportBdDetailV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- Map<String, Object> requestMap = new HashMap<>();
- if (!Check.isNull(requestJson.getString("orderStartDate"))) {
- Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- }
- if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
- requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
- }
- requestMap.put("fieId", "orderNum");
- requestMap.put("sort", "desc");
- List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("promoterId"));
- export.add(date.getString("promoterName"));
- export.add(date.getString("sampleCount"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNum"));
- export.add(date.getString("validOrderRate"));
- export.add(date.getString("regimentalPromotionAmount"));
- export.add(date.getString("totalRegimentalSettleAmount"));
- export.add(date.getString("promoterUrl"));
- exportList.add(export);
- }
- }
- String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
- this.setResponseHeader(response, "bd业绩.xls");
- workbook.write(os);
- os.flush();
- os.close();
- }
- static ExecutorService addListCService = Executors.newFixedThreadPool(5);
- /**
- * 接口链接:
- * https://open.kwaixiaodian.com/zone/new/docs/api?name=open.distribution.investment.activity.open.close&version=1
- */
- @GetMapping("/addList")
- @ApiOperation(value = "分销团长订单列表(游标方式)")
- public void addList(String beginDate, String endDate) {
- List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(beginDate, endDate);
- allDatesOfTwoTimes.forEach(date -> addListCService.submit(() -> {
- try {
- supplyChainService.addList(date, date, "");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }));
- }
- @GetMapping("/addListC")
- @ApiOperation(value = "多日期本地调试---分销团长订单列表")
- public void addListC(String beginDate, String endDate) {
- List<String> allDatesOfTwoTimes = DateUtils.getAllDatesOfTwoTimes(beginDate, endDate);
- allDatesOfTwoTimes.forEach(date -> addListCService.submit(() -> {
- try {
- long currentTimeMillis = System.currentTimeMillis();
- System.out.println(date + "开始执行ing...");
- supplyChainService.addList(date, date, "");
- System.out.println(date + "用时:" + (System.currentTimeMillis() - currentTimeMillis) / 60000 + "分");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }));
- }
- static ExecutorService fxNowService = Executors.newFixedThreadPool(3);
- @PostMapping(value = "/ruixuanAccept")
- public Map<String, Object> ruixuanAccept(@RequestBody String eventsEncoded) {
- try {
- logger.info("567睿选消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, ruiXuanPrivateKey);
- JSONObject eventJSon = JSONObject.parseObject(events);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @PostMapping(value = "/mgsAccept")
- public Map<String, Object> mgsAccept(@RequestBody String eventsEncoded) {
- try {
- logger.info("RX食品消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, mgsPrivateKey);
- JSONObject eventJSon = JSONObject.parseObject(events);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @PostMapping(value = "/rocketAccept")
- public Map<String, Object> rocketAccept(@RequestBody String eventsEncoded) {
- try {
- logger.info("王炸睿选消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, rocketPrivateKey);
- JSONObject eventJSon = JSONObject.parseObject(events);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @PostMapping(value = "/dfcAccept")
- public Map<String, Object> dfcAccept(@RequestBody String eventsEncoded) {
- try {
- logger.info("大风车严选消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, dfcPrivateKey);
- JSONObject eventJSon = JSONObject.parseObject(events);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @PostMapping(value = "/mgsAccept2")
- public Map<String, Object> mgsAccept2(@RequestBody String eventsEncoded) {
- try {
- logger.info("RX食品-二团严选消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, mgsPrivateKey2);
- JSONObject eventJSon = JSONObject.parseObject(events);
- logger.info("二团返回信息:{}", eventJSon);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @PostMapping(value = "/yufuAccept")
- public Map<String, Object> yufuAccept(@RequestBody String eventsEncoded) {
- try {
- logger.info("渔夫睿选消息订阅");
- String events = PlatformEventSecurityUtil.decode(eventsEncoded, yufuPrivateKey);
- JSONObject eventJSon = JSONObject.parseObject(events);
- logger.info("渔夫睿选返回信息:{}", eventJSon);
- fxNowService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- if (!Check.isNull(eventJSon)) {
- String event = eventJSon.getString("event");
- if ("kwaishop_distribute_order_change_notify".equals(event)) {
- supplyChainService.updateOrder(eventJSon);
- } else if ("kwaishop_distribute_activity_item_change".equals(event)) {
- supplyChainService.updateItem(eventJSon);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- //返回成功
- Map<String, Object> result = new HashMap<>();
- result.put("result", 1);
- return result;
- }
- @GetMapping("/addListKuaishouActivityInfo")
- @ApiOperation(value = "团长查询招商活动列表")
- public void addListKuaishouActivityInfo() {
- try {
- supplyChainService.addListKuaishouActivityInfo();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- @Autowired
- private ISysUserService sysUserService;
- @Autowired
- private ISysDeptService deptService;
- @GetMapping("/shopList")
- @ApiOperation(value = "商品列表")
- public TableDataInfo shopList(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("结束时间") @RequestParam(value = "sellerId", required = false) Long sellerId,
- @ApiParam("结束时间") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
- @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort) {
- TableDataInfo dataInfo = new TableDataInfo();
- try {
- if (Check.isNull(orderStartDate) || Check.isNull(orderEndDate)) {
- throw new Exception("请输入开始时间和结束时间");
- }
- if (Check.isNull(userId)) {
- throw new Exception("请输入用户id");
- }
- Map<String, Object> requestMap = new HashMap<>();
- String roleKey = sysUserService.getRoleKeyByUserId(userId);
- if (roleKey.equals("courtship")) {
- List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
- requestMap.put("itemIds", itemIds);
- }
- if (roleKey.equals("courtshipManager")) {
- Long deptId = deptService.getDeptIdByUserId(userId);
- List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
- requestMap.put("itemIds", itemIds);
- }
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- if (!Check.isNull(sellerId)) {
- requestMap.put("sellerId", sellerId);
- }
- requestMap.put("fieId", fieId);
- requestMap.put("sort", sort);
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.shopList(requestMap);
- return getDataTable(list);
- } catch (Exception e) {
- e.printStackTrace();
- dataInfo.setCode(-1);
- dataInfo.setMsg(e.getMessage());
- return dataInfo;
- }
- }
- @GetMapping("/shopDetail")
- @ApiOperation(value = "商品列表")
- public TableDataInfo shopDetail(
- @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
- @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
- @ApiParam("店铺Id") @RequestParam(value = "sellerId", required = false) Long sellerId,
- @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
- @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
- @ApiParam("商品名") @RequestParam(value = "itemTitle", required = false) String itemTitle
- ) {
- TableDataInfo dataInfo = new TableDataInfo();
- try {
- if (Check.isNull(orderStartDate) || Check.isNull(orderEndDate)) {
- throw new Exception("请输入开始时间和结束时间");
- }
- if (Check.isNull(sellerId)) {
- throw new Exception("请输入店铺Id");
- }
- Map<String, Object> requestMap = new HashMap<>();
- String roleKey = sysUserService.getRoleKeyByUserId(userId);
- if (roleKey.equals("courtship")) {
- List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
- requestMap.put("itemIds", itemIds);
- }
- if (roleKey.equals("courtshipManager")) {
- Long deptId = deptService.getDeptIdByUserId(userId);
- List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
- requestMap.put("itemIds", itemIds);
- }
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- requestMap.put("sellerId", sellerId);
- if (!Check.isNull(itemId)) {
- requestMap.put("itemId", itemId);
- }
- if (!Check.isNull(itemTitle)) {
- requestMap.put("itemTitle", itemTitle);
- }
- if (Check.isNullMap(requestMap)) {
- dataInfo.setCode(-1);
- dataInfo.setMsg("入参不能为空");
- return dataInfo;
- }
- startPage();
- List<JSONObject> list = supplyChainService.shopDetail(requestMap);
- return getDataTable(list);
- } catch (Exception e) {
- e.printStackTrace();
- dataInfo.setCode(-1);
- dataInfo.setMsg(e.getMessage());
- return dataInfo;
- }
- }
- @PostMapping("/exportShopDetail")
- @ResponseBody
- public void exportShopDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- try {
- if (Check.isNull(requestJson.getString("orderStartDate")) || Check.isNull(requestJson.getString("orderEndDate"))) {
- throw new Exception("请输入开始时间和结束时间");
- }
- if (Check.isNull(requestJson.getLong("sellerId"))) {
- throw new Exception("请输入店铺Id");
- }
- Long userId = requestJson.getLong("userId");
- if (Check.isNull(userId)) {
- throw new Exception("请输入用户ID");
- }
- Map<String, Object> requestMap = new HashMap<>();
- requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
- requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
- requestMap.put("sellerId", requestJson.getLong("sellerId"));
- String roleKey = sysUserService.getRoleKeyByUserId(userId);
- if (roleKey.equals("courtship")) {
- List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
- requestMap.put("itemIds", itemIds);
- }
- if (roleKey.equals("courtshipManager")) {
- Long deptId = deptService.getDeptIdByUserId(userId);
- List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
- requestMap.put("itemIds", itemIds);
- }
- List<JSONObject> list = supplyChainService.shopDetail(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("itemId"));
- export.add(date.getString("itemTitle"));
- export.add(date.getString("reservePrice"));
- export.add(date.getString("userName"));
- export.add(date.getString("ccrValue"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("payAmount"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("shippingGreen"));
- export.add(date.getString("effDeliveryNum"));
- export.add(date.getString("notDeliveryNum"));
- export.add(date.getString("deliveryRadio"));
- export.add(date.getString("regimentalPromotionRate"));
- exportList.add(export);
- }
- }
- String[] headers = {"商品ID", "商品名称", "单价", "归属人", "ccr", "单量", "有效单量", "有效率", "付款金额", "发货数", "发货率", "有效发货数", "未发货数", "有效发货率", "服务费率"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "店铺详情", headers, exportList);
- this.setResponseHeader(response, "店铺详情.xls");
- workbook.write(os);
- os.flush();
- os.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @PostMapping("/exportShopList")
- @ResponseBody
- public void exportShopList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
- try {
- if (Check.isNull(requestJson.getString("orderStartDate")) || Check.isNull(requestJson.getString("orderEndDate"))) {
- throw new Exception("请输入开始时间和结束时间");
- }
- Long userId = requestJson.getLong("userId");
- if (Check.isNull(userId)) {
- throw new Exception("请输入用户ID");
- }
- Map<String, Object> requestMap = new HashMap<>();
- requestMap.put("start", requestJson.getString("orderStartDate"));
- requestMap.put("end", requestJson.getString("orderEndDate"));
- requestMap.put("fieId", "orderNum");
- requestMap.put("sort", "desc");
- String roleKey = sysUserService.getRoleKeyByUserId(userId);
- if (roleKey.equals("courtship")) {
- List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
- requestMap.put("itemIds", itemIds);
- }
- if (roleKey.equals("courtshipManager")) {
- Long deptId = deptService.getDeptIdByUserId(userId);
- List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
- requestMap.put("itemIds", itemIds);
- }
- List<JSONObject> list = supplyChainService.shopList(requestMap);
- List<List<Object>> exportList = new ArrayList<>();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject date = list.get(i);
- List<Object> export = new ArrayList();
- export.add(date.getString("sellerId"));
- export.add(date.getString("sellerName"));
- export.add(date.getString("orderNum"));
- export.add(date.getString("validOrderNUm"));
- export.add(date.getString("validRadio"));
- export.add(date.getString("payAmount"));
- export.add(date.getString("deliveryNum"));
- export.add(date.getString("shippingGreen"));
- export.add(date.getString("effDeliveryNum"));
- export.add(date.getString("notDeliveryNum"));
- export.add(date.getString("deliveryRadio"));
- exportList.add(export);
- }
- }
- String[] headers = {"店铺ID", "店铺名称", "单量", "有效单量", "有效率", "付款金额", "发货数", "发货率", "有效发货数", "未发货数", "有效发货率"};
- OutputStream os = response.getOutputStream();
- ExportExcelUtils eeu = new ExportExcelUtils();
- XSSFWorkbook workbook = new XSSFWorkbook();
- eeu.exportExcel(workbook, 0, "店铺列表", headers, exportList);
- this.setResponseHeader(response, "店铺列表.xls");
- workbook.write(os);
- os.flush();
- os.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * open.distribution.investment.activity.open.item.list
- * 团长招商活动已报名商品列表
- */
- @GetMapping("/addKuaishouActivityOpenItemList")
- @ApiOperation(value = "团长招商活动已报名商品列表")
- public void addKuaishouActivityOpenItemList() {
- try {
- supplyChainService.addKuaishouActivityOpenItemList();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
|