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

Commit 4c3030d9 authored by zhanggb's avatar zhanggb

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

parent 67484de3
......@@ -76,6 +76,13 @@ public abstract class DateUtil {
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;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* select gso.order_id '订单ID',
......@@ -57,19 +59,19 @@ public class GoblinZhengzaiMarketOrderExcelDto implements Serializable, Cloneabl
@ExcelProperty("订单状态")
private String orderStatus;
@ExcelProperty("订单创建时间")
private Integer createdAt;
private LocalDateTime createdAt;
@ExcelProperty("核销时间")
private String pushTime;
private LocalDateTime pushTime;
@ExcelProperty("支付来源")
private String deviceFrom;
@ExcelProperty("支付类型")
private String payType;
@ExcelProperty("购买数量")
private String nums;
private Integer nums;
@ExcelProperty("商品单价")
private String skuPrice;
private BigDecimal skuPrice;
@ExcelProperty("实际支付价格")
private String priceActual;
private BigDecimal priceActual;
@ExcelProperty("优惠金额")
private Integer priceVoucher;
private BigDecimal priceVoucher;
}
......@@ -108,7 +108,7 @@
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)
<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">
and gso.created_at <![CDATA[>=]]> #{beginTime,jdbcType=TIMESTAMP}
</if>
......
......@@ -2,6 +2,7 @@ package com.liquidnet.service.platform.controller.goblin;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.constant.LnsRegex;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
......@@ -31,7 +32,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Pattern;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.List;
......@@ -73,18 +76,19 @@ public class GoblinExportDataController {
@ApiImplicitParams({
@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 = false, dataType = "String", name = "bTime", 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 = "bDate", 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,
@RequestParam(required = false, name = "eTime") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "结束时间格式有误") String endTime,
public void exportZhengzaiMarketOrder(@RequestParam(required = false, name = "bDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "开始日期格式有误") String beginDate,
@RequestParam(required = false, name = "eDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "结束日期格式有误") String endDate,
@RequestParam String marketId, @RequestParam String storeId, HttpServletResponse response) {
String currentUid = CurrentUtil.getCurrentUid();
ServletOutputStream servletOutputStream = null;
try {
log.debug("数据导出:正在下单-销售数据:[uid:{},storeId:{},marketId:{},time:{}~{}]", currentUid, storeId, marketId, beginTime, endTime);
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=".concat(DateUtil.Formatter.ddHHmmssTrim.format(LocalDateTime.now()))
.concat(new String(("正在下单-销售数据").getBytes("gb2312"), StandardCharsets.ISO_8859_1)).concat(ExcelTypeEnum.XLSX.getValue()));
log.debug("数据导出:正在下单-销售数据:[uid:{},storeId:{},marketId:{},date:{}~{}]", currentUid, storeId, marketId, beginDate, endDate);
String fileName = DateUtil.Formatter.ddHHmmssTrim.format(LocalDateTime.now())
.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.setCharacterEncoding(StandardCharsets.UTF_8.name());
servletOutputStream = response.getOutputStream();
......@@ -92,22 +96,23 @@ public class GoblinExportDataController {
HashMap<String, Object> paramMap = CollectionUtil.mapStringObject();
paramMap.put("storeId", storeId);
paramMap.put("marketId", marketId);
LocalDateTime beginDateTime = DateUtil.Formatter.yyyy_MM_dd.parse(beginTime);
LocalDateTime endDateTime = DateUtil.Formatter.yyyy_MM_dd.parse(endTime);
paramMap.put("beginTime", beginDateTime);
paramMap.put("endTime", null == endDateTime ? endDateTime : endDateTime.withHour(23).withMinute(59).withSecond(59));
LocalDate beginLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(beginDate);
LocalDate endLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(endDate);
paramMap.put("beginTime", null == beginLocalDate ? beginLocalDate : LocalDateTime.of(beginLocalDate, LocalTime.MIN));
paramMap.put("endTime", null == endLocalDate ? endLocalDate : LocalDateTime.of(endLocalDate, LocalTime.MAX));
if (log.isDebugEnabled()) {
log.debug("数据导出:正在下单-销售数据:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
}
List<GoblinZhengzaiMarketOrderExcelDto> excelDtos = iGoblinExportService.exportZhengzaiMarketOrder(paramMap);
if (CollectionUtils.isEmpty(excelDtos)) {
return ResponseDto.failure("无数据,请核实");
throw new LiquidnetServiceException("-1","无数据,请核实");
}
EasyExcel.write(servletOutputStream, GoblinZhengzaiMarketOrderExcelDto.class).sheet("销售数据").doWrite(excelDtos);
} catch (IOException e) {
log.error("数据导出:正在下单-销售数据:异常[UID={},ex.msg={}]", currentUid, e.getLocalizedMessage());
return ResponseDto.failure("导出失败,请联系网站管理员");
log.error("数据导出:正在下单-销售数据:异常[uid:{},storeId:{},marketId:{},date:{}~{},ex.msg={}]",
currentUid, storeId, marketId, beginDate, endDate, e.getLocalizedMessage());
throw new LiquidnetServiceException("-1","导出失败,请联系网站管理员");
} finally {
if (null != servletOutputStream) {
try {
......@@ -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