From f22e34bbf2e7865d37bf29de76bdfc1b9f0db509 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 28 Oct 2022 15:13:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4diam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/OrderRefundController.java | 91 +++++++++++++++++++ .../order/model/ExportOrderRefundModel.java | 74 +++++++++++++++ .../service/impl/OrderRefundServiceImpl.java | 19 +++- 3 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/order/model/ExportOrderRefundModel.java diff --git a/hai-order/src/main/java/com/web/controller/OrderRefundController.java b/hai-order/src/main/java/com/web/controller/OrderRefundController.java index 32e33a50..cf53a0d2 100644 --- a/hai-order/src/main/java/com/web/controller/OrderRefundController.java +++ b/hai-order/src/main/java/com/web/controller/OrderRefundController.java @@ -1,5 +1,6 @@ package com.web.controller; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -10,17 +11,22 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; +import com.hai.entity.HighOrderRefund; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderModel; +import com.hai.order.model.ExportGasOrderModel; +import com.hai.order.model.ExportOrderRefundModel; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildGoodsType; import com.hai.order.type.OrderChildStatus; import com.hai.order.type.OrderPayType; +import com.hai.order.type.OrderRefundStatus; import com.hai.order.utils.OrderUtil; +import com.web.config.SysConst; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -32,8 +38,11 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.io.File; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -160,16 +169,27 @@ public class OrderRefundController { @RequestParam(name = "refundOrderNo", required = false) String refundOrderNo, @RequestParam(name = "memPhone", required = false) String memPhone, @RequestParam(name = "goodsType", required = false) Integer goodsType, + @RequestParam(name = "goodsName", required = false) String goodsName, @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { Map param = new HashMap<>(); param.put("orderNo", orderNo); param.put("orderChildNo", orderChildNo); + param.put("refundOrderNo", refundOrderNo); param.put("memPhone", memPhone); param.put("goodsType", goodsType); + param.put("goodsName", goodsName); param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + param.put("refundTimeS", refundTimeS); + param.put("refundTimeE", refundTimeE); PageHelper.startPage(pageNum, pageSize); return ResponseMsgUtil.success(new PageInfo<>(orderRefundService.getRefundOrderList(param))); @@ -180,4 +200,75 @@ public class OrderRefundController { } } + @RequestMapping(value="/excelRefund",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出退款") + public ResponseData excelRefund(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "orderChildNo", required = false) String orderChildNo, + @RequestParam(name = "refundOrderNo", required = false) String refundOrderNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "goodsType", required = false) Integer goodsType, + @RequestParam(name = "goodsName", required = false) String goodsName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE) { + try { + Map param = new HashMap<>(); + param.put("orderNo", orderNo); + param.put("orderChildNo", orderChildNo); + param.put("refundOrderNo", refundOrderNo); + param.put("memPhone", memPhone); + param.put("goodsType", goodsType); + param.put("goodsName", goodsName); + param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + param.put("refundTimeS", refundTimeS); + param.put("refundTimeE", refundTimeE); + + List list = orderRefundService.getRefundOrderList(param); + + List orderRefundModelList = new ArrayList<>(); + ExportOrderRefundModel orderRefundModel; + + for (HighOrderRefund orderRefund : list) { + orderRefundModel = new ExportOrderRefundModel(); + orderRefundModel.setOrderNo(orderRefund.getOrderNo()); + orderRefundModel.setChildOrderNo(orderRefund.getOrderChildNo()); + orderRefundModel.setMemPhone(orderRefund.getMemPhone()); + orderRefundModel.setGoodsType(OrderChildGoodsType.getDataByType(orderRefund.getGoodsType()).getName()); + orderRefundModel.setGoodsName(orderRefund.getGoodsName()); + orderRefundModel.setRefundOrderNo(orderRefund.getRefundOrderNo()); + orderRefundModel.setRefundGoodsNum(orderRefund.getRefundGoodsNum()); + orderRefundModel.setReturnTotalPrice(orderRefund.getReturnTotalPrice()); + orderRefundModel.setRefundPrice(orderRefund.getRefundPrice()); + orderRefundModel.setRefundIntegral(orderRefund.getRefundIntegral()); + orderRefundModel.setRefundStatus(OrderRefundStatus.getDataByType(orderRefund.getRefundStatus()).getName()); + orderRefundModel.setCreateTime(orderRefund.getCreateTime()); + orderRefundModel.setRefundTime(orderRefund.getRefundTime()); + orderRefundModel.setRefundRemark(orderRefund.getRefundRemark()); + orderRefundModelList.add(orderRefundModel); + } + + String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } + EasyExcel.write(fileUrl+pathName) + .head(ExportOrderRefundModel.class) + .sheet("交易退款记录") + .doWrite(orderRefundModelList); + + return ResponseMsgUtil.success(fileUrl+pathName); + + } catch (Exception e) { + log.error("OrderRefundController -> excelRefund() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/order/model/ExportOrderRefundModel.java b/hai-service/src/main/java/com/hai/order/model/ExportOrderRefundModel.java new file mode 100644 index 00000000..870f2416 --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/model/ExportOrderRefundModel.java @@ -0,0 +1,74 @@ +package com.hai.order.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单退款模型 + * @className: ExportGasOrderModel + * @author: HuRui + * @date: 2022/10/28 + **/ +@Data +public class ExportOrderRefundModel { + + @ColumnWidth(25) + @ExcelProperty("交易单号") + private String orderNo; + + @ColumnWidth(25) + @ExcelProperty("产品单号") + private String childOrderNo; + + @ColumnWidth(15) + @ExcelProperty("客户电话") + private String memPhone; + + @ColumnWidth(15) + @ExcelProperty("产品类型") + private String goodsType; + + @ColumnWidth(30) + @ExcelProperty("产品名称") + private String goodsName; + + @ColumnWidth(25) + @ExcelProperty("退款单号") + private String refundOrderNo; + + @ColumnWidth(15) + @ExcelProperty("退款数量") + private Integer refundGoodsNum; + + @ColumnWidth(15) + @ExcelProperty("退款总额") + private BigDecimal returnTotalPrice; + + @ColumnWidth(15) + @ExcelProperty("退款金额") + private BigDecimal refundPrice; + + @ColumnWidth(15) + @ExcelProperty("退款积分") + private Integer refundIntegral; + + @ColumnWidth(15) + @ExcelProperty("退款状态") + private String refundStatus; + + @ColumnWidth(15) + @ExcelProperty("创建时间") + private Date createTime; + + @ColumnWidth(15) + @ExcelProperty("退款时间") + private Date refundTime; + + @ColumnWidth(50) + @ExcelProperty("退款备注") + private String refundRemark; +} diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java index 9e2a3c15..5e3bb0ba 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java @@ -147,8 +147,23 @@ public class OrderRefundServiceImpl implements OrderRefundService { criteria.andGoodsNameLike("%"+MapUtils.getString(param, "goodsName")+"%"); } - if (StringUtils.isNotBlank(MapUtils.getString(param, "goodsName"))) { - criteria.andGoodsNameLike("%"+MapUtils.getString(param, "goodsName")+"%"); + if (MapUtils.getInteger(param, "status") != null) { + criteria.andRefundStatusEqualTo(MapUtils.getInteger(param, "status")); + } + + if (MapUtils.getLong(param, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS"))); + } + + if (MapUtils.getLong(param, "createTimeE") != null) { + criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeE"))); + } + + if (MapUtils.getLong(param, "refundTimeS") != null) { + criteria.andRefundTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeS"))); + } + if (MapUtils.getLong(param, "refundTimeE") != null) { + criteria.andRefundTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeE"))); } example.setOrderByClause("create_time desc");