记得上下班打卡 | git大法好,push需谨慎

Commit 4c3030d9 authored by zhanggb's avatar zhanggb

~api:正在下单:活动订单数据导出-周焕;

parent 67484de3
...@@ -76,6 +76,13 @@ public abstract class DateUtil { ...@@ -76,6 +76,13 @@ public abstract class DateUtil {
return LocalDateTime.parse(str, formatter); return LocalDateTime.parse(str, formatter);
} }
public LocalDate parse2LocalDate(String str) {
if (null == str || str.trim().length() <= 0) {
return null;
}
return LocalDate.parse(str, formatter);
}
} }
/** /**
......
...@@ -5,6 +5,8 @@ import lombok.Getter; ...@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/** /**
* select gso.order_id '订单ID', * select gso.order_id '订单ID',
...@@ -57,19 +59,19 @@ public class GoblinZhengzaiMarketOrderExcelDto implements Serializable, Cloneabl ...@@ -57,19 +59,19 @@ public class GoblinZhengzaiMarketOrderExcelDto implements Serializable, Cloneabl
@ExcelProperty("订单状态") @ExcelProperty("订单状态")
private String orderStatus; private String orderStatus;
@ExcelProperty("订单创建时间") @ExcelProperty("订单创建时间")
private Integer createdAt; private LocalDateTime createdAt;
@ExcelProperty("核销时间") @ExcelProperty("核销时间")
private String pushTime; private LocalDateTime pushTime;
@ExcelProperty("支付来源") @ExcelProperty("支付来源")
private String deviceFrom; private String deviceFrom;
@ExcelProperty("支付类型") @ExcelProperty("支付类型")
private String payType; private String payType;
@ExcelProperty("购买数量") @ExcelProperty("购买数量")
private String nums; private Integer nums;
@ExcelProperty("商品单价") @ExcelProperty("商品单价")
private String skuPrice; private BigDecimal skuPrice;
@ExcelProperty("实际支付价格") @ExcelProperty("实际支付价格")
private String priceActual; private BigDecimal priceActual;
@ExcelProperty("优惠金额") @ExcelProperty("优惠金额")
private Integer priceVoucher; private BigDecimal priceVoucher;
} }
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
inner join goblin_store_info gsi on gsi.store_id = gso.store_id inner join goblin_store_info gsi on gsi.store_id = gso.store_id
inner join goblin_self_marketing gsm on gsm.self_market_id = SUBSTRING_INDEX(gso.market_id, 'ZZ', -1) inner join goblin_self_marketing gsm on gsm.self_market_id = SUBSTRING_INDEX(gso.market_id, 'ZZ', -1)
<where> <where>
gso.status not in (0, 5) and gso.store_id = #{orderNo,jdbcType=VARCHAR} and gso.market_id = #{orderNo,jdbcType=VARCHAR} gso.status not in (0, 5) and gso.store_id = #{storeId,jdbcType=VARCHAR} and gso.market_id = #{marketId,jdbcType=VARCHAR}
<if test="beginTime != null"> <if test="beginTime != null">
and gso.created_at <![CDATA[>=]]> #{beginTime,jdbcType=TIMESTAMP} and gso.created_at <![CDATA[>=]]> #{beginTime,jdbcType=TIMESTAMP}
</if> </if>
......
...@@ -2,6 +2,7 @@ package com.liquidnet.service.platform.controller.goblin; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.platform.controller.goblin;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.support.ExcelTypeEnum;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.constant.LnsRegex; import com.liquidnet.commons.lang.constant.LnsRegex;
import com.liquidnet.commons.lang.util.CollectionUtil; import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil; import com.liquidnet.commons.lang.util.CurrentUtil;
...@@ -31,7 +32,9 @@ import javax.servlet.http.HttpServletResponse; ...@@ -31,7 +32,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -73,18 +76,19 @@ public class GoblinExportDataController { ...@@ -73,18 +76,19 @@ public class GoblinExportDataController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动ID"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动ID"),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "bTime", value = "开始时间[yyyy-MM-dd]"), @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "bDate", value = "开始时间[yyyy-MM-dd]"),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "eTime", value = "结束时间[yyyy-MM-dd]"), @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "eDate", value = "结束时间[yyyy-MM-dd]"),
}) })
public ResponseDto<String> exportZhengzaiMarketOrder(@RequestParam(required = false, name = "bTime") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "开始时间格式有误") String beginTime, public void exportZhengzaiMarketOrder(@RequestParam(required = false, name = "bDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "开始日期格式有误") String beginDate,
@RequestParam(required = false, name = "eTime") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "结束时间格式有误") String endTime, @RequestParam(required = false, name = "eDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "结束日期格式有误") String endDate,
@RequestParam String marketId, @RequestParam String storeId, HttpServletResponse response) { @RequestParam String marketId, @RequestParam String storeId, HttpServletResponse response) {
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
ServletOutputStream servletOutputStream = null; ServletOutputStream servletOutputStream = null;
try { try {
log.debug("数据导出:正在下单-销售数据:[uid:{},storeId:{},marketId:{},time:{}~{}]", currentUid, storeId, marketId, beginTime, endTime); log.debug("数据导出:正在下单-销售数据:[uid:{},storeId:{},marketId:{},date:{}~{}]", currentUid, storeId, marketId, beginDate, endDate);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=".concat(DateUtil.Formatter.ddHHmmssTrim.format(LocalDateTime.now())) String fileName = DateUtil.Formatter.ddHHmmssTrim.format(LocalDateTime.now())
.concat(new String(("正在下单-销售数据").getBytes("gb2312"), StandardCharsets.ISO_8859_1)).concat(ExcelTypeEnum.XLSX.getValue())); .concat(new String(("正在下单-销售数据").getBytes("gb2312"), StandardCharsets.ISO_8859_1));
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=".concat(fileName).concat(ExcelTypeEnum.XLSX.getValue()));
response.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE); response.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name()); response.setCharacterEncoding(StandardCharsets.UTF_8.name());
servletOutputStream = response.getOutputStream(); servletOutputStream = response.getOutputStream();
...@@ -92,22 +96,23 @@ public class GoblinExportDataController { ...@@ -92,22 +96,23 @@ public class GoblinExportDataController {
HashMap<String, Object> paramMap = CollectionUtil.mapStringObject(); HashMap<String, Object> paramMap = CollectionUtil.mapStringObject();
paramMap.put("storeId", storeId); paramMap.put("storeId", storeId);
paramMap.put("marketId", marketId); paramMap.put("marketId", marketId);
LocalDateTime beginDateTime = DateUtil.Formatter.yyyy_MM_dd.parse(beginTime); LocalDate beginLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(beginDate);
LocalDateTime endDateTime = DateUtil.Formatter.yyyy_MM_dd.parse(endTime); LocalDate endLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(endDate);
paramMap.put("beginTime", beginDateTime); paramMap.put("beginTime", null == beginLocalDate ? beginLocalDate : LocalDateTime.of(beginLocalDate, LocalTime.MIN));
paramMap.put("endTime", null == endDateTime ? endDateTime : endDateTime.withHour(23).withMinute(59).withSecond(59)); paramMap.put("endTime", null == endLocalDate ? endLocalDate : LocalDateTime.of(endLocalDate, LocalTime.MAX));
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("数据导出:正在下单-销售数据:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap)); log.debug("数据导出:正在下单-销售数据:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
} }
List<GoblinZhengzaiMarketOrderExcelDto> excelDtos = iGoblinExportService.exportZhengzaiMarketOrder(paramMap); List<GoblinZhengzaiMarketOrderExcelDto> excelDtos = iGoblinExportService.exportZhengzaiMarketOrder(paramMap);
if (CollectionUtils.isEmpty(excelDtos)) { if (CollectionUtils.isEmpty(excelDtos)) {
return ResponseDto.failure("无数据,请核实"); throw new LiquidnetServiceException("-1","无数据,请核实");
} }
EasyExcel.write(servletOutputStream, GoblinZhengzaiMarketOrderExcelDto.class).sheet("销售数据").doWrite(excelDtos); EasyExcel.write(servletOutputStream, GoblinZhengzaiMarketOrderExcelDto.class).sheet("销售数据").doWrite(excelDtos);
} catch (IOException e) { } catch (IOException e) {
log.error("数据导出:正在下单-销售数据:异常[UID={},ex.msg={}]", currentUid, e.getLocalizedMessage()); log.error("数据导出:正在下单-销售数据:异常[uid:{},storeId:{},marketId:{},date:{}~{},ex.msg={}]",
return ResponseDto.failure("导出失败,请联系网站管理员"); currentUid, storeId, marketId, beginDate, endDate, e.getLocalizedMessage());
throw new LiquidnetServiceException("-1","导出失败,请联系网站管理员");
} finally { } finally {
if (null != servletOutputStream) { if (null != servletOutputStream) {
try { try {
...@@ -116,6 +121,5 @@ public class GoblinExportDataController { ...@@ -116,6 +121,5 @@ public class GoblinExportDataController {
} }
} }
} }
return ResponseDto.success();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment