feat: 订单导出
parent
06a36c6668
commit
3efa1384c8
|
@ -1,5 +1,9 @@
|
||||||
package cn.iocoder.yudao.module.shop.controller.admin.recharge;
|
package cn.iocoder.yudao.module.shop.controller.admin.recharge;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.method.Excel;
|
||||||
|
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderInfoConvert;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderInfoService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -36,6 +40,8 @@ public class RechargeOrderController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RechargeOrderService rechargeOrderService;
|
private RechargeOrderService rechargeOrderService;
|
||||||
|
@Resource
|
||||||
|
private RechargeOrderInfoService rechargeOrderInfoService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建订单")
|
@Operation(summary = "创建订单")
|
||||||
|
@ -87,6 +93,7 @@ public class RechargeOrderController {
|
||||||
return success(RechargeOrderConvert.INSTANCE.convertPage(pageResult));
|
return success(RechargeOrderConvert.INSTANCE.convertPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出订单 Excel")
|
@Operation(summary = "导出订单 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('shop:recharge-order:export')")
|
@PreAuthorize("@ss.hasPermission('shop:recharge-order:export')")
|
||||||
|
@ -94,9 +101,15 @@ public class RechargeOrderController {
|
||||||
public void exportRechargeOrderExcel(@Valid RechargeOrderExportReqVO exportReqVO,
|
public void exportRechargeOrderExcel(@Valid RechargeOrderExportReqVO exportReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
List<RechargeOrderDO> list = rechargeOrderService.getRechargeOrderList(exportReqVO);
|
List<RechargeOrderDO> list = rechargeOrderService.getRechargeOrderList(exportReqVO);
|
||||||
|
ArrayList<String> s = new ArrayList<>();
|
||||||
|
list.forEach(x -> {
|
||||||
|
s.add(x.getOrderId());
|
||||||
|
});
|
||||||
|
List<RechargeOrderInfoDO> infoList = rechargeOrderInfoService.getRechargeOrderInfoList(s);
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
List<RechargeOrderExcelVO> datas = RechargeOrderConvert.INSTANCE.convertList02(list);
|
List<RechargeOrderExcelVO> datas = RechargeOrderConvert.INSTANCE.convertList02(list);
|
||||||
ExcelUtils.write(response, "订单.xls", "数据", RechargeOrderExcelVO.class, datas);
|
List<RechargeOrderInfoExcelVO> infoDatas = RechargeOrderInfoConvert.INSTANCE.convertList02(infoList);
|
||||||
}
|
|
||||||
|
|
||||||
|
Excel.orderExport(response, datas, infoDatas);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package cn.iocoder.yudao.module.shop.controller.admin.recharge.method;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderExcelVO;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderInfoExcelVO;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.ExcelWriter;
|
||||||
|
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
|
||||||
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||||
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||||
|
import com.google.common.net.HttpHeaders;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: ignite
|
||||||
|
* @Date: 2023/5/16 18:25
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class Excel {
|
||||||
|
|
||||||
|
public static ExcelWriter orderExport(HttpServletResponse response, List<RechargeOrderExcelVO> z, List<RechargeOrderInfoExcelVO> x) throws IOException {
|
||||||
|
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
// 这里URLEncoder.encode可以防止中文乱码
|
||||||
|
String encodedFileName = URLEncoder.encode(System.currentTimeMillis() + "", StandardCharsets.UTF_8.name()).replaceAll("\\+", "%20");
|
||||||
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename*=utf-8''" + encodedFileName + ".xlsx");
|
||||||
|
|
||||||
|
|
||||||
|
ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream())
|
||||||
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy());
|
||||||
|
ExcelWriter excelWriter = writerBuilder.build();
|
||||||
|
|
||||||
|
WriteSheet writeSheet1 = EasyExcel.writerSheet(0, "订单列表").head(RechargeOrderExcelVO.class).build();
|
||||||
|
WriteSheet writeSheet2 = EasyExcel.writerSheet(1, "订单明细表").head(RechargeOrderInfoExcelVO.class).build();
|
||||||
|
|
||||||
|
excelWriter.write(z, writeSheet1);
|
||||||
|
excelWriter.write(x, writeSheet2);
|
||||||
|
|
||||||
|
excelWriter.finish();
|
||||||
|
return excelWriter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +1,10 @@
|
||||||
package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo;
|
package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单 Excel VO
|
* 订单 Excel VO
|
||||||
|
@ -25,14 +14,23 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
@Data
|
@Data
|
||||||
public class RechargeOrderExcelVO {
|
public class RechargeOrderExcelVO {
|
||||||
|
|
||||||
@ExcelProperty("订单ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@ExcelProperty("订单号")
|
@ExcelProperty("订单号")
|
||||||
private String orderId;
|
private String orderId;
|
||||||
|
|
||||||
@ExcelProperty("用户id")
|
@ExcelProperty("第三方支付流水号")
|
||||||
private Integer uid;
|
private String paySerialNumber;
|
||||||
|
|
||||||
|
@ExcelProperty("支付时间")
|
||||||
|
private LocalDateTime payTime;
|
||||||
|
//:0-普通订单,1-视频号订单
|
||||||
|
@ExcelProperty("订单类型")
|
||||||
|
private Integer type;
|
||||||
|
//(0:待发货;1:待收货;2:已收货,待评价;3:已完成;)
|
||||||
|
@ExcelProperty("订单状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ExcelProperty("配送方式")
|
||||||
|
private String deliveryType;
|
||||||
|
|
||||||
@ExcelProperty("用户姓名")
|
@ExcelProperty("用户姓名")
|
||||||
private String realName;
|
private String realName;
|
||||||
|
@ -42,89 +40,40 @@ public class RechargeOrderExcelVO {
|
||||||
|
|
||||||
@ExcelProperty("确认手机号")
|
@ExcelProperty("确认手机号")
|
||||||
private String confirmPhone;
|
private String confirmPhone;
|
||||||
|
@ExcelProperty("地址")
|
||||||
@ExcelProperty("订单商品总数")
|
private String address;
|
||||||
private Integer totalNum;
|
|
||||||
|
|
||||||
@ExcelProperty("订单总价")
|
|
||||||
private BigDecimal totalPrice;
|
|
||||||
|
|
||||||
@ExcelProperty("实际支付金额")
|
|
||||||
private BigDecimal payPrice;
|
|
||||||
|
|
||||||
@ExcelProperty("支付状态")
|
|
||||||
private Byte paid;
|
|
||||||
|
|
||||||
@ExcelProperty("支付截止时间")
|
|
||||||
private LocalDateTime payTime;
|
|
||||||
|
|
||||||
@ExcelProperty("支付截止时间")
|
|
||||||
private LocalDateTime payEndTime;
|
|
||||||
|
|
||||||
@ExcelProperty("支付方式")
|
|
||||||
private String payType;
|
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@ExcelProperty("订单状态(0:待发货;1:待收货;2:已收货,待评价;3:已完成;)")
|
|
||||||
private Boolean status;
|
|
||||||
|
|
||||||
@ExcelProperty("0 未退款 1 申请中 2 已退款 3 退款中")
|
|
||||||
private Byte refundStatus;
|
|
||||||
|
|
||||||
@ExcelProperty("退款图片")
|
|
||||||
private String refundReasonWapImg;
|
|
||||||
|
|
||||||
@ExcelProperty("退款用户说明")
|
|
||||||
private String refundReasonWapExplain;
|
|
||||||
|
|
||||||
@ExcelProperty("前台退款原因")
|
|
||||||
private String refundReasonWap;
|
|
||||||
|
|
||||||
@ExcelProperty("不退款的理由")
|
|
||||||
private String refundReason;
|
|
||||||
|
|
||||||
@ExcelProperty("退款时间")
|
|
||||||
private LocalDateTime refundReasonTime;
|
|
||||||
|
|
||||||
@ExcelProperty("退款金额")
|
|
||||||
private BigDecimal refundPrice;
|
|
||||||
|
|
||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
private String mark;
|
private String mark;
|
||||||
|
|
||||||
@ExcelProperty("管理员备注")
|
@ExcelProperty("取货地址")
|
||||||
|
private String pickUpAddr;
|
||||||
|
|
||||||
|
@ExcelProperty("自提地址")
|
||||||
|
private String SelfPickupAddr;
|
||||||
|
|
||||||
|
@ExcelProperty("支付方式")
|
||||||
|
private String payType;
|
||||||
|
|
||||||
|
@ExcelProperty("订单备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ExcelProperty("成本价")
|
@ExcelProperty("产品合计金额")
|
||||||
private BigDecimal cost;
|
|
||||||
|
|
||||||
@ExcelProperty("支付渠道(0微信公众号1微信小程序2余额)")
|
|
||||||
private Byte isChannel;
|
|
||||||
|
|
||||||
@ExcelProperty("消息提醒")
|
|
||||||
private Byte isRemind;
|
|
||||||
|
|
||||||
@ExcelProperty("后台是否删除")
|
|
||||||
private Boolean isSystemDel;
|
|
||||||
|
|
||||||
@ExcelProperty("订单类型:0-普通订单,1-视频号订单")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@ExcelProperty("商品总价")
|
|
||||||
private BigDecimal proTotalPrice;
|
private BigDecimal proTotalPrice;
|
||||||
|
|
||||||
@ExcelProperty("改价前支付金额")
|
@ExcelProperty("运费")
|
||||||
private BigDecimal beforePayPrice;
|
private BigDecimal shipPrice;
|
||||||
|
|
||||||
@ExcelProperty("是否改价,0-否,1-是")
|
@ExcelProperty("会员账号")
|
||||||
private Boolean isAlterPrice;
|
private String vipAccount;
|
||||||
|
|
||||||
@ExcelProperty("商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号")
|
@ExcelProperty("会员姓名")
|
||||||
private String outTradeNo;
|
private String vipName;
|
||||||
|
|
||||||
@ExcelProperty("第三方支付流水号")
|
@ExcelProperty("推广员")
|
||||||
private String paySerialNumber;
|
private String promoter;
|
||||||
|
|
||||||
|
@ExcelProperty("组织名称")
|
||||||
|
private Integer depName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,30 +18,59 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
@Data
|
@Data
|
||||||
public class RechargeOrderInfoExcelVO {
|
public class RechargeOrderInfoExcelVO {
|
||||||
|
|
||||||
@ExcelProperty("主键")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@ExcelProperty("充值订单id")
|
|
||||||
private Integer rechargeOrderId;
|
|
||||||
|
|
||||||
@ExcelProperty("充值档位")
|
|
||||||
private Integer rechargeGearId;
|
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
@ExcelProperty("订单号")
|
@ExcelProperty("订单号")
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
|
||||||
@ExcelProperty("商品名称")
|
@ExcelProperty("商户名称")
|
||||||
|
private String shopName;
|
||||||
|
|
||||||
|
@ExcelProperty("产品名称")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
||||||
@ExcelProperty("商品价格")
|
@ExcelProperty("购物选项")
|
||||||
|
private String shopOption;
|
||||||
|
|
||||||
|
@ExcelProperty("产品分类")
|
||||||
|
private String productCategory;
|
||||||
|
|
||||||
|
@ExcelProperty("产品价格")
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
@ExcelProperty("购买数量")
|
@ExcelProperty("产品数量")
|
||||||
private Integer payNum;
|
private Integer payNum;
|
||||||
|
|
||||||
|
@ExcelProperty("合计金额")
|
||||||
|
private BigDecimal proTotalPrice;
|
||||||
|
|
||||||
|
@ExcelProperty("支付金额")
|
||||||
|
private BigDecimal payPrice;
|
||||||
|
|
||||||
|
@ExcelProperty("售后状态")
|
||||||
|
private String afterStatus;
|
||||||
|
|
||||||
|
@ExcelProperty("退款金额")
|
||||||
|
private BigDecimal refundPrice;
|
||||||
|
|
||||||
|
@ExcelProperty("会员账号")
|
||||||
|
private String vipAccount;
|
||||||
|
|
||||||
|
@ExcelProperty("会员姓名")
|
||||||
|
private String vipName;
|
||||||
|
//(0:待发货;1:待收货;2:已收货,待评价;3:已完成;)
|
||||||
|
@ExcelProperty("订单状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ExcelProperty("地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@ExcelProperty("订单备注")
|
||||||
|
private String mark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ExcelProperty("赠送积分")
|
@ExcelProperty("赠送积分")
|
||||||
private Integer giveIntegral;
|
private Integer giveIntegral;
|
||||||
|
|
||||||
|
|
|
@ -165,4 +165,8 @@ public class RechargeOrderDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private String paySerialNumber;
|
private String paySerialNumber;
|
||||||
|
|
||||||
|
private String creator;
|
||||||
|
private String updater;
|
||||||
|
private Boolean deleted;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,4 +70,9 @@ public class RechargeOrderInfoDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Integer productType;
|
private Integer productType;
|
||||||
|
|
||||||
|
private String creator;
|
||||||
|
private String updater;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,4 +49,9 @@ public interface RechargeOrderInfoMapper extends BaseMapperX<RechargeOrderInfoDO
|
||||||
.orderByDesc(RechargeOrderInfoDO::getId));
|
.orderByDesc(RechargeOrderInfoDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<RechargeOrderInfoDO> selectList(List<String> s) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<RechargeOrderInfoDO>().in(RechargeOrderInfoDO::getOrderNo, s));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,4 +67,6 @@ public interface RechargeOrderInfoService {
|
||||||
*/
|
*/
|
||||||
List<RechargeOrderInfoDO> getRechargeOrderInfoList(RechargeOrderInfoExportReqVO exportReqVO);
|
List<RechargeOrderInfoDO> getRechargeOrderInfoList(RechargeOrderInfoExportReqVO exportReqVO);
|
||||||
|
|
||||||
|
List<RechargeOrderInfoDO> getRechargeOrderInfoList(List<String> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.shop.service.recharge;
|
package cn.iocoder.yudao.module.shop.service.recharge;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -79,4 +80,9 @@ public class RechargeOrderInfoServiceImpl implements RechargeOrderInfoService {
|
||||||
return rechargeOrderInfoMapper.selectList(exportReqVO);
|
return rechargeOrderInfoMapper.selectList(exportReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RechargeOrderInfoDO> getRechargeOrderInfoList(List<String> s) {
|
||||||
|
return rechargeOrderInfoMapper.selectList(s);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue