1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557 |
- 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));
- }
- 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)) {
- if (!Check.isNull(orderStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(orderStartDate));
- }
- if (!Check.isNull(orderEndDate)) {
- requestMap.put("end", DateUtils.strDateToInt(orderEndDate));
- }
- }
- if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
- if (!Check.isNull(bindStartDate)) {
- requestMap.put("start", DateUtils.strDateToInt(bindStartDate));
- requestMap.put("bindStartDate", bindStartDate);
- }
- if (!Check.isNull(bindEndDate)) {
- 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);
- }
- @RequestMapping(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"))) {
- 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("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"));
- }
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- list = supplyChainService.exportOrder(requestMap);
- } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
- list = supplyChainService.exportBindOrder(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("isPresale"));
- export.add(date.getString("imageUrl"));
- export.add(date.getString("itemCommissionRate"));
- 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("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);
- }
- }
- 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();
- }
- /**
- * 根据商品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() - 1; // 当前小时
- 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() - 1; // 当前小时
- 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);
- }
- }
- @RequestMapping(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"))) {
- 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.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")) {
- 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.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")) {
- headers = new String[]{"达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
- } else {
- headers = new String[]{"达人ID", "达人名称", "订单数", "有效订单数", "有效订单率", "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)) {
- 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)) {
- headers = new String[]{"达人", "商品", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"};
- } else {
- headers = new String[]{"达人名称", "达人id", "商品名称", "商品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();
- }
- /**
- * 获取供应链人员列表
- *
- * @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)) {
- Long start = DateUtils.getStartLongTime(orderStartDate);
- requestMap.put("start", start);
- requestMap.put("startDate", orderStartDate);
- }
- if (!Check.isNull(orderEndDate)) {
- Long end = DateUtils.getEndLongTime(orderEndDate);
- requestMap.put("end", end);
- requestMap.put("endDate", orderEndDate + " 23:59:59");
- }
- if (!Check.isNull(bindStartDate)) {
- Long start = DateUtils.getStartLongTime(bindStartDate);
- requestMap.put("start", start);
- requestMap.put("startDate", bindStartDate);
- }
- if (!Check.isNull(bindEndDate)) {
- Long end = DateUtils.getEndLongTime(bindEndDate);
- requestMap.put("end", end);
- 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"))) {
- Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
- requestMap.put("start", start);
- requestMap.put("startDate", requestJson.getString("orderStartDate"));
- }
- if (!Check.isNull(requestJson.getString("orderEndDate"))) {
- Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
- requestMap.put("end", end);
- requestMap.put("endDate", requestJson.getString("orderEndDate")+" 23:59:59");
- }
- 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"));
- }
- List<JSONObject> list = new ArrayList<>();
- if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
- list = supplyChainService.exportAdminReportList(requestMap);
- } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
- list = supplyChainService.exportAdminReportListByBind(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.getString("itemCount"));
- export.add(date.getString("sendSampleCount"));
- export.add(date.getString("orderNum"));
- 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);
- }
- }
- 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 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();
- }
- }
- }
|