From 3efa1384c8419c2afd16828a9586d95036d36012 Mon Sep 17 00:00:00 2001 From: luli <3280552144@qq.com> Date: Wed, 17 May 2023 10:36:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recharge/RechargeOrderController.java | 17 ++- .../admin/recharge/method/Excel.java | 47 ++++++ .../recharge/vo/RechargeOrderExcelVO.java | 135 ++++++------------ .../recharge/vo/RechargeOrderInfoExcelVO.java | 59 ++++++-- .../dataobject/recharge/RechargeOrderDO.java | 4 + .../recharge/RechargeOrderInfoDO.java | 5 + .../recharge/RechargeOrderInfoMapper.java | 5 + .../recharge/RechargeOrderInfoService.java | 2 + .../RechargeOrderInfoServiceImpl.java | 6 + 9 files changed, 170 insertions(+), 110 deletions(-) create mode 100644 yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/method/Excel.java diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java index 875832e69..0c4f5a820 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java @@ -1,5 +1,9 @@ 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 javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -36,6 +40,8 @@ public class RechargeOrderController { @Resource private RechargeOrderService rechargeOrderService; + @Resource + private RechargeOrderInfoService rechargeOrderInfoService; @PostMapping("/create") @Operation(summary = "创建订单") @@ -87,6 +93,7 @@ public class RechargeOrderController { return success(RechargeOrderConvert.INSTANCE.convertPage(pageResult)); } + @GetMapping("/export-excel") @Operation(summary = "导出订单 Excel") @PreAuthorize("@ss.hasPermission('shop:recharge-order:export')") @@ -94,9 +101,15 @@ public class RechargeOrderController { public void exportRechargeOrderExcel(@Valid RechargeOrderExportReqVO exportReqVO, HttpServletResponse response) throws IOException { List list = rechargeOrderService.getRechargeOrderList(exportReqVO); + ArrayList s = new ArrayList<>(); + list.forEach(x -> { + s.add(x.getOrderId()); + }); + List infoList = rechargeOrderInfoService.getRechargeOrderInfoList(s); // 导出 Excel List datas = RechargeOrderConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "订单.xls", "数据", RechargeOrderExcelVO.class, datas); - } + List infoDatas = RechargeOrderInfoConvert.INSTANCE.convertList02(infoList); + Excel.orderExport(response, datas, infoDatas); + } } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/method/Excel.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/method/Excel.java new file mode 100644 index 000000000..0b9ebffdd --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/method/Excel.java @@ -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 z, List 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; + } +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExcelVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExcelVO.java index 5d80cd479..de6e69d19 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExcelVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExcelVO.java @@ -1,21 +1,10 @@ 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 lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; /** * 订单 Excel VO @@ -25,14 +14,23 @@ import com.alibaba.excel.annotation.ExcelProperty; @Data public class RechargeOrderExcelVO { - @ExcelProperty("订单ID") - private Integer id; - @ExcelProperty("订单号") private String orderId; - @ExcelProperty("用户id") - private Integer uid; + @ExcelProperty("第三方支付流水号") + 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("用户姓名") private String realName; @@ -42,89 +40,40 @@ public class RechargeOrderExcelVO { @ExcelProperty("确认手机号") private String confirmPhone; - - @ExcelProperty("订单商品总数") - 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("地址") + private String address; @ExcelProperty("备注") private String mark; - @ExcelProperty("管理员备注") + @ExcelProperty("取货地址") + private String pickUpAddr; + + @ExcelProperty("自提地址") + private String SelfPickupAddr; + + @ExcelProperty("支付方式") + private String payType; + + @ExcelProperty("订单备注") private String remark; - @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("商品总价") + @ExcelProperty("产品合计金额") private BigDecimal proTotalPrice; - @ExcelProperty("改价前支付金额") - private BigDecimal beforePayPrice; + @ExcelProperty("运费") + private BigDecimal shipPrice; - @ExcelProperty("是否改价,0-否,1-是") - private Boolean isAlterPrice; + @ExcelProperty("会员账号") + private String vipAccount; - @ExcelProperty("商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号") - private String outTradeNo; + @ExcelProperty("会员姓名") + private String vipName; - @ExcelProperty("第三方支付流水号") - private String paySerialNumber; + @ExcelProperty("推广员") + private String promoter; + + @ExcelProperty("组织名称") + private Integer depName; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderInfoExcelVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderInfoExcelVO.java index 9662629ae..e5908d7e0 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderInfoExcelVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderInfoExcelVO.java @@ -18,30 +18,59 @@ import com.alibaba.excel.annotation.ExcelProperty; @Data public class RechargeOrderInfoExcelVO { - @ExcelProperty("主键") - private Integer id; - - @ExcelProperty("充值订单id") - private Integer rechargeOrderId; - - @ExcelProperty("充值档位") - private Integer rechargeGearId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - @ExcelProperty("订单号") private String orderNo; - @ExcelProperty("商品名称") + @ExcelProperty("商户名称") + private String shopName; + + @ExcelProperty("产品名称") private String productName; - @ExcelProperty("商品价格") + @ExcelProperty("购物选项") + private String shopOption; + + @ExcelProperty("产品分类") + private String productCategory; + + @ExcelProperty("产品价格") private BigDecimal price; - @ExcelProperty("购买数量") + @ExcelProperty("产品数量") 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("赠送积分") private Integer giveIntegral; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderDO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderDO.java index 4db369218..6ad3696b0 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderDO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderDO.java @@ -165,4 +165,8 @@ public class RechargeOrderDO extends BaseDO { */ private String paySerialNumber; + private String creator; + private String updater; + private Boolean deleted; + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderInfoDO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderInfoDO.java index 5afe858d6..9abb9b89c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderInfoDO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/recharge/RechargeOrderInfoDO.java @@ -70,4 +70,9 @@ public class RechargeOrderInfoDO extends BaseDO { */ private Integer productType; + private String creator; + private String updater; + private LocalDateTime createTime; + private LocalDateTime updateTime; + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderInfoMapper.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderInfoMapper.java index 185710d14..83e868442 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderInfoMapper.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/recharge/RechargeOrderInfoMapper.java @@ -49,4 +49,9 @@ public interface RechargeOrderInfoMapper extends BaseMapperX selectList(List s) { + return selectList(new LambdaQueryWrapperX().in(RechargeOrderInfoDO::getOrderNo, s)); + + } + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoService.java index d34582d5e..07247bf0c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoService.java @@ -67,4 +67,6 @@ public interface RechargeOrderInfoService { */ List getRechargeOrderInfoList(RechargeOrderInfoExportReqVO exportReqVO); + List getRechargeOrderInfoList(List ids); + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoServiceImpl.java index 833d1c99b..16a7e0063 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderInfoServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.shop.service.recharge; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -79,4 +80,9 @@ public class RechargeOrderInfoServiceImpl implements RechargeOrderInfoService { return rechargeOrderInfoMapper.selectList(exportReqVO); } + @Override + public List getRechargeOrderInfoList(List s) { + return rechargeOrderInfoMapper.selectList(s); + } + }