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 requestMap = new HashMap<>(); if (!Check.isNull(orderStartDate)) { requestMap.put("start", DateUtils.strDateToInt(orderStartDate)); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(orderStartDate, orderEndDate); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(orderEndDate)) { requestMap.put("end", DateUtils.strDateToInt(orderEndDate)); } if (!Check.isNull(promoterNickName)) { requestMap.put("promoterNickName", promoterNickName); } if (!Check.isNull(promoterId)) { requestMap.put("promoterId", promoterId); } TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List 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 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 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 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 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 requestMap = new HashMap<>(); if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) { requestMap.put("start", DateUtils.strDateToInt(orderStartDate)); requestMap.put("end", DateUtils.strDateToInt(orderEndDate)); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(orderStartDate, orderEndDate); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) { requestMap.put("start", DateUtils.strDateToInt(bindStartDate)); requestMap.put("bindStartDate", bindStartDate); requestMap.put("end", DateUtils.strDateToInt(bindEndDate)); requestMap.put("bindEndDate", bindEndDate); } if (!Check.isNull(itemId)) { requestMap.put("itemId", itemId); } if (!Check.isNull(itemTitle)) { requestMap.put("itemTitle", itemTitle); } if (!Check.isNull(userId)) { requestMap.put("userId", userId); } requestMap.put("fieId", fieId); requestMap.put("sort", sort); TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List list = new ArrayList<>(); if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) { list = supplyChainService.itemList(requestMap); } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) { list = supplyChainService.itemBindList(requestMap); } return getDataTable(list); } @PostMapping("/exportOrder") @ApiOperation(value = "exportOrder") @ResponseBody public void exportOrder(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception { Map requestMap = new HashMap<>(); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate"))); requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate"))); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate")); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(requestJson.getString("bindStartDate"))) { requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("bindStartDate"))); requestMap.put("bindStartDate", requestJson.getString("bindStartDate")); } if (!Check.isNull(requestJson.getString("bindEndDate"))) { requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("bindEndDate"))); requestMap.put("bindEndDate", requestJson.getString("bindEndDate")); } if (!Check.isNull(requestJson.getString("promoterNickName"))) { requestMap.put("promoterNickName", requestJson.getString("promoterNickName")); } if (!Check.isNull(requestJson.getLong("promoterId"))) { requestMap.put("promoterId", requestJson.getLong("promoterId")); } if (!Check.isNull(requestJson.getLong("itemId"))) { requestMap.put("itemId", requestJson.getLong("itemId")); } if (!Check.isNull(requestJson.getString("itemTitle"))) { requestMap.put("itemTitle", requestJson.getString("itemTitle")); } if (!Check.isNull(requestJson.getLong("userId"))) { requestMap.put("userId", requestJson.getLong("userId")); } String[] headers = null; List list = new ArrayList<>(); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { list = supplyChainService.exportOrder(requestMap); headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "订单数环比", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"}; } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) { list = supplyChainService.exportBindOrder(requestMap); headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"}; } List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List export = new ArrayList(); export.add(date.getString("userName")); export.add(date.getLong("itemId")); export.add(date.getString("itemTitle")); export.add(date.getString("isPresale")); export.add(date.getString("imageUrl")); export.add(date.getString("itemCommissionRate")); export.add(date.getInteger("orderNum")); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { export.add(date.getString("orderNumRoi")); } export.add(date.getInteger("validOrderNUm")); export.add(date.getString("validRadio")); export.add(date.getString("deliveryNum")); export.add(date.getString("deliveryRadio")); export.add(date.getString("notDeliveryNum")); export.add(date.getString("ccrValue")); export.add(date.getString("shopStar")); export.add(date.getString("mallLogisticsScore")); export.add(date.getString("shopScore")); export.add(date.getString("mallServiceScore")); export.add(date.getString("mallQualityScore")); exportList.add(export); } } OutputStream os = response.getOutputStream(); ExportExcelUtils eeu = new ExportExcelUtils(); XSSFWorkbook workbook = new XSSFWorkbook(); eeu.exportExcel(workbook, 0, "订单信息", headers, exportList); this.setResponseHeader(response, "订单信息.xls"); workbook.write(os); os.flush(); os.close(); } /** * 根据商品id获取top达人 * * @param itemId * @param orderStartDate * @param orderEndDate * @return */ @GetMapping("/getTopPromoterByItemId") @ApiOperation(value = "商品列表") public TableDataInfo getTopPromoterByItemId( @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) { Map 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 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 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 list = supplyChainService.itemDetail(requestMap); return getDataTable(list); } @PostMapping("/exportItemDetail") @ResponseBody public void exportItemDetail( HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson ) throws IOException { Map 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 list = supplyChainService.exportItemDetail(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject data = list.get(i); List 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 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 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 requestMap = new HashMap<>(); JSONObject returnJson = new JSONObject(); if (dateType == 0) { if (!Check.isNull(orderStartDate)) { requestMap.put("start", DateUtils.strDateToInt(orderStartDate)); } if (!Check.isNull(orderEndDate)) { requestMap.put("end", DateUtils.strDateToInt(orderEndDate)); } JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap); returnJson.put("orderTotal", orderTotal); Integer hour = DateUtils.getNowHour(); // 当前小时 if (hour >= 0) { JSONObject ratioJson = new JSONObject(); Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳 // Long nowEndHourTemp = DateUtils.getNowEndHourTemp(orderStartDate, hour); // 当前结束时间戳 String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期 Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间戳 // Long yesterdayEndHourTemp = DateUtils.getNowEndHourTemp(yesterday, hour); // 昨日结束时间戳 Map 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 requestMap = new HashMap<>(); JSONObject returnJson = new JSONObject(); if (dateType == 0) { if (!Check.isNull(orderStartDate)) { requestMap.put("start", DateUtils.strDateToInt(orderStartDate)); } if (!Check.isNull(orderEndDate)) { requestMap.put("end", DateUtils.strDateToInt(orderEndDate)); } JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap); returnJson.put("amountTotal", amountTotal); Integer hour = DateUtils.getNowHour(); // 当前小时 if (hour >= 0) { JSONObject amountRatioJson = new JSONObject(); Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间 String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); // 昨日日期 Long yesterdayStartHourTemp = DateUtils.strDateToInt(yesterday); //昨日开始时间 Map 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 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 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 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 orderRankRatioList = supplyChainService.getOrderRankList(requestMap); return getDataTable(orderRankRatioList); } } } private TableDataInfo indexOrderRankBytedance(Integer dateType, String orderStartDate, String orderEndDate) { Map 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 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 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 requestMap = new HashMap<>(); if (dateType == 0) { if ("1".equals(mediaId)) { return indexPromoterRankBytedance(dateType, orderStartDate, orderEndDate, userId); } else { if (Check.isNotNull(userId)) { List 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 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 orderRatioList = supplyChainService.getPromoterRatioList(requestMap); return getDataTable(orderRatioList); } } } public TableDataInfo indexPromoterRankBytedance(Integer dateType, String orderStartDate, String orderEndDate, Long userId) { Map requestMap = new HashMap<>(); if (dateType == 0) { if (Check.isNotNull(userId)) { List 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 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 orderRatioList = supplyChainService.getPromoterRatioListBytedance(requestMap); return getDataTable(orderRatioList); } } @PostMapping("/exportPromoterTotal") @ApiOperation(value = "exportPromoterTotal") @ResponseBody public void exportPromoterTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception { Map requestMap = new HashMap<>(); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate"))); requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate"))); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate")); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(requestJson.getString("promoterNickName"))) { requestMap.put("promoterNickName", requestJson.getString("promoterNickName")); } if (!Check.isNull(requestJson.getLong("promoterId"))) { requestMap.put("promoterId", requestJson.getLong("promoterId")); } if (!Check.isNull(requestJson.getLong("itemId"))) { requestMap.put("itemId", requestJson.getLong("itemId")); } if (!Check.isNull(requestJson.getString("itemTitle"))) { requestMap.put("itemTitle", requestJson.getString("itemTitle")); } List list = supplyChainService.exportPromoterTotal(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List export = new ArrayList(); if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) { Long promoterId = date.getLong("promoterId"); export.add(promoterId); String promoterNickName = date.getString("promoterNickName"); export.add(promoterNickName); } else { Long promoterId = date.getLong("promoterId"); String promoterNickName = date.getString("promoterNickName"); String name = promoterNickName + "(" + promoterId + ")"; export.add(name); } export.add(date.getInteger("orderNum")); export.add(date.getString("orderNumRoi")); export.add(date.getInteger("validOrderNUm")); export.add(date.getString("validRadio")); export.add(date.getString("payAmount")); export.add(date.getString("validPayAmount")); // export.add(date.getString("regimentalPromotionAmount")); export.add(date.getString("deliveryNum")); export.add(date.getString("deliveryRadio")); export.add(date.getString("notDeliveryNum")); String userName = supplyChainService.getUserName(date.getLong("promoterId")); if (!Check.isNull(userName)) { export.add(userName); } /* Map map = new HashMap<>(); map.put("promoterId", promoterId); map.put("start", DateUtils.getStartLongTime(requestJson.getString("orderStartDate"))); map.put("end", DateUtils.getEndLongTime(requestJson.getString("orderEndDate"))); List topOrders = supplyChainService.getTopOrders(map); if (!Check.isNull(topOrders)) { JSONObject top1 = topOrders.get(0); StringBuffer top1StringBuffer = new StringBuffer(); top1StringBuffer.append("商品ID:").append(top1.getString("itemId")).append(String.valueOf((char) 10)) .append("出单量:").append(top1.getString("orderNum")).append(String.valueOf((char) 10)) .append("标题:").append(top1.getString("itemTitle")).append(String.valueOf((char) 10)) .append("链接:").append(top1.getString("imageUrl")); export.add(top1StringBuffer); } if (!Check.isNull(topOrders) && topOrders.size() >= 2) { JSONObject top2 = topOrders.get(1); if (!Check.isNull(top2)) { StringBuffer top2StringBuffer = new StringBuffer(); top2StringBuffer.append("商品ID:").append(top2.getString("itemId")).append(String.valueOf((char) 10)) .append("出单量:").append(top2.getString("orderNum")).append(String.valueOf((char) 10)) .append("标题:").append(top2.getString("itemTitle")).append(String.valueOf((char) 10)) .append("链接:").append(top2.getString("imageUrl")); export.add(top2StringBuffer); } } if (!Check.isNull(topOrders) && topOrders.size() >= 3) { JSONObject top3 = topOrders.get(2); if (!Check.isNull(top3)) { StringBuffer top3StringBuffer = new StringBuffer(); top3StringBuffer.append("商品ID:").append(top3.getString("itemId")).append(String.valueOf((char) 10)) .append("出单量:").append(top3.getString("orderNum")).append(String.valueOf((char) 10)) .append("标题:").append(top3.getString("itemTitle")).append(String.valueOf((char) 10)) .append("链接:").append(top3.getString("imageUrl")); export.add(top3StringBuffer); } }*/ exportList.add(export); } } String[] headers = {}; if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) { headers = new String[]{"达人ID", "达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"}; } else { headers = new String[]{"达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"}; } OutputStream os = response.getOutputStream(); ExportExcelUtils eeu = new ExportExcelUtils(); XSSFWorkbook workbook = new XSSFWorkbook(); eeu.exportExcel(workbook, 0, "达人信息", headers, exportList); this.setResponseHeader(response, "达人信息.xls"); workbook.write(os); os.flush(); os.close(); } @RequestMapping(value = "/exportPromoter") @ResponseBody public void exportPromoter(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception { Map 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 list = supplyChainService.exportPromoter(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List export = new ArrayList(); String promoterNickName = date.getString("promoterNickName"); Long promoterId = date.getLong("promoterId"); Long itemId = date.getLong("itemId"); String itemTitle = date.getString("itemTitle"); if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) { export.add(promoterNickName); export.add(promoterId); export.add(itemTitle); export.add(itemId); } else { String promoter = promoterNickName + "(" + promoterId + ")"; export.add(promoter); String item = itemTitle + "(" + itemId + ")"; export.add(item); } export.add(date.getString("imageUrl")); export.add(date.getInteger("orderNum")); export.add(date.getInteger("validOrderNUm")); export.add(date.getString("validRadio")); export.add(date.getString("deliveryNum")); export.add(date.getString("deliveryRadio")); export.add(date.getString("activityItemStatus")); exportList.add(export); } } String[] headers = {}; if ("miaogousi".equals(ownershipId) || "yufu".equals(ownershipId)) { headers = new String[]{"达人名称", "达人id", "商品名称", "商品id", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"}; } else { headers = new String[]{"达人", "商品", "商品封面", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "商品状态"}; } OutputStream os = response.getOutputStream(); ExportExcelUtils eeu = new ExportExcelUtils(); XSSFWorkbook workbook = new XSSFWorkbook(); eeu.exportExcel(workbook, 0, "达人信息", headers, exportList); this.setResponseHeader(response, "达人信息.xls"); workbook.write(os); os.flush(); os.close(); } /** * 获取供应链人员列表 * * @return */ @GetMapping("/getSupplyChainUserList") @ApiOperation(value = "获取供应链成员列表") public TableDataInfo getSupplyChainUserList() { List list = supplyChainService.getSupplyChainUserList(); return getDataTable(list); } @GetMapping("/getSupplyChainCourtshipUserList") @ApiOperation(value = "获取供应链成员列表") public TableDataInfo getSupplyChainCourtshipUserList() { List 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 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 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 requestMap = new HashMap<>(); if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) { requestMap.put("start", DateUtils.strDateToInt(orderStartDate)); requestMap.put("end", DateUtils.strDateToInt(orderEndDate)); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(orderStartDate, orderEndDate); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) { requestMap.put("startDate", bindStartDate); requestMap.put("endDate", bindEndDate + " 23:59:59"); } if (!Check.isNull(userId)) { requestMap.put("userId", userId); } TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } List 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 requestMap = new HashMap<>(); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { requestMap.put("startDate", requestJson.getString("orderStartDate")); requestMap.put("endDate", requestJson.getString("orderEndDate") + " 23:59:59"); //根据本阶段日期 获取上阶段 开始 和 截至 日期 Map map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderStartDate")); //下个周期的开始时间 String lastTimeStart = map.get("lastTimeStart"); //下个周期的结束时间 String lastTimeEnd = map.get("lastTimeEnd"); //当前小时 Integer hour = DateUtils.getNowHour(); //当天 yyyy-MM-dd String today = DateUtils.getNowDateStr(); if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderStartDate")) && requestJson.getString("orderStartDate").equals(today))) { hour = 23; } requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart)); requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd)); requestMap.put("hour", hour); } if (!Check.isNull(requestJson.getString("bindStartDate"))) { Long start = DateUtils.getStartLongTime(requestJson.getString("bindStartDate")); requestMap.put("start", start); requestMap.put("startDate", requestJson.getString("bindStartDate")); } if (!Check.isNull(requestJson.getString("bindEndDate"))) { Long end = DateUtils.getEndLongTime(requestJson.getString("bindEndDate")); requestMap.put("end", end); requestMap.put("endDate", requestJson.getString("bindEndDate") + " 23:59:59"); } if (!Check.isNull(requestJson.getString("userId"))) { requestMap.put("userId", requestJson.getString("userId")); } String[] headers = null; List list = new ArrayList<>(); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { list = supplyChainService.exportAdminReportList(requestMap); headers = new String[]{"招商", "商品数", "发样数", "订单数", "订单数环比", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"}; } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) { list = supplyChainService.exportAdminReportListByBind(requestMap); headers = new String[]{"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"}; } List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List export = new ArrayList(); export.add(date.getString("userName")); export.add(date.getString("itemCount")); export.add(date.getString("sendSampleCount")); export.add(date.getString("orderNum")); if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) { export.add(date.getString("orderNumRoi")); } export.add(date.getString("validOrderNUm")); export.add(date.getString("validRadio")); export.add(date.getString("deliveryNum")); export.add(date.getString("notDeliveryNum")); export.add(date.getString("deliveryRadio")); export.add(date.getString("payAmount")); export.add(date.getString("regimentalPromotionAmount")); export.add(date.getString("totalRegimentalSettleAmount")); export.add(date.getString("avgServiceRate")); exportList.add(export); } } OutputStream os = response.getOutputStream(); ExportExcelUtils eeu = new ExportExcelUtils(); XSSFWorkbook workbook = new XSSFWorkbook(); eeu.exportExcel(workbook, 0, "订单信息", headers, exportList); this.setResponseHeader(response, "订单信息.xls"); workbook.write(os); os.flush(); os.close(); } /** * 认领商品列表 * * @param userId * @param orderStartDate * @param orderEndDate * @param itemId * @param itemTitle * @return */ @GetMapping("/userItemDetail") @ApiOperation(value = "认领商品列表") public TableDataInfo userItemDetail( @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) Long itemId, @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle, @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId, @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort ) { Map 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 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 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 list = supplyChainService.exportUserItemDetail(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 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 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 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 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 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 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 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 list = supplyChainService.exportBdReportList(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 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 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 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 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 list = supplyChainService.exportBdDetail(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 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 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 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> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 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 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 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 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 list = supplyChainService.bdDetailListV2(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 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 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 result = new HashMap<>(); result.put("result", 1); return result; } @PostMapping(value = "/mgsAccept") public Map 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 result = new HashMap<>(); result.put("result", 1); return result; } @PostMapping(value = "/rocketAccept") public Map 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 result = new HashMap<>(); result.put("result", 1); return result; } @PostMapping(value = "/dfcAccept") public Map 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 result = new HashMap<>(); result.put("result", 1); return result; } @PostMapping(value = "/mgsAccept2") public Map 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 result = new HashMap<>(); result.put("result", 1); return result; } @PostMapping(value = "/yufuAccept") public Map 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 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 requestMap = new HashMap<>(); String roleKey = sysUserService.getRoleKeyByUserId(userId); if (roleKey.equals("courtship")) { List itemIds = supplyChainService.getItemIdsByUserId(userId); requestMap.put("itemIds", itemIds); } if (roleKey.equals("courtshipManager")) { Long deptId = deptService.getDeptIdByUserId(userId); List 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 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 requestMap = new HashMap<>(); String roleKey = sysUserService.getRoleKeyByUserId(userId); if (roleKey.equals("courtship")) { List itemIds = supplyChainService.getItemIdsByUserId(userId); requestMap.put("itemIds", itemIds); } if (roleKey.equals("courtshipManager")) { Long deptId = deptService.getDeptIdByUserId(userId); List 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 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 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 itemIds = supplyChainService.getItemIdsByUserId(userId); requestMap.put("itemIds", itemIds); } if (roleKey.equals("courtshipManager")) { Long deptId = deptService.getDeptIdByUserId(userId); List itemIds = supplyChainService.getItemIdsByDeptId(deptId); requestMap.put("itemIds", itemIds); } List list = supplyChainService.shopDetail(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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 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 itemIds = supplyChainService.getItemIdsByUserId(userId); requestMap.put("itemIds", itemIds); } if (roleKey.equals("courtshipManager")) { Long deptId = deptService.getDeptIdByUserId(userId); List itemIds = supplyChainService.getItemIdsByDeptId(deptId); requestMap.put("itemIds", itemIds); } List list = supplyChainService.shopList(requestMap); List> exportList = new ArrayList<>(); if (!Check.isNull(list)) { for (int i = 0; i < list.size(); i++) { JSONObject date = list.get(i); List 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(); } } }