From 88b6b96038e46c3f6439ac0b12724686ed8c7e1c Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 1 Nov 2022 10:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C=E9=80=81?= =?UTF-8?q?=E5=88=B8=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OutRechargeOrderController.java | 7 ++ .../business/OrderThirdPartyController.java | 101 ++++++++++++++++++ .../src/main/resources/dev/config.properties | 4 +- .../com/hai/enum_type/OrderPayTypeEnum.java | 9 ++ .../hai/order/model/OrderThirdPartyModel.java | 71 ++++++++++++ 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java index 1d771bb4..fc21bde0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -48,6 +48,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; @@ -254,6 +255,12 @@ public class OutRechargeOrderController { String name = "/outRechargeOrder/充值订单" + System.currentTimeMillis() + ".xlsx"; String fileName = SysConst.getSysConfig().getFileUrl() + name; + String fileUrl = SysConst.getSysConfig().getFileUrl() + "outRechargeOrder/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } EasyExcel.write(fileName, ExportOutRechargeOrder.class).sheet("充值订单").doWrite(list); return ResponseMsgUtil.success(name); } catch (Exception e) { diff --git a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java index ccd91aee..0522ebef 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java @@ -1,5 +1,6 @@ package com.web.controller.business; +import com.alibaba.excel.EasyExcel; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -7,10 +8,18 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighGasOrder; +import com.hai.entity.HighOrder; +import com.hai.enum_type.OrderPayTypeEnum; +import com.hai.enum_type.OrderStatusEnum; import com.hai.enum_type.UserObjectTypeEnum; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.order.model.ExportGasOrderModel; +import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderService; +import com.hai.order.type.OrderOilStatus; +import com.web.config.SysConst; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -23,8 +32,12 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -112,4 +125,92 @@ public class OrderThirdPartyController { } } + + @RequestMapping(value = "/exportThirdPartyOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出第三方订单列表") + public ResponseData exportThirdPartyOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "memCardNo", required = false) String memCardNo, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, + @RequestParam(name = "finishTimeE", required = false) Long finishTimeE) { + try { + + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + Map map = new HashMap<>(); + if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type0.getType())) { + map.put("companyId" , companyId); + } else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type1.getType())) { + map.put("companyId", userInfoModel.getBsCompany().getId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + map.put("createTimeS", createTimeS); + map.put("createTimeE", createTimeE); + map.put("payTimeS", payTimeS); + map.put("payTimeE", payTimeE); + map.put("finishTimeS", finishTimeS); + map.put("finishTimeE", finishTimeE); + map.put("orderNo", orderNo); + map.put("memPhone", memPhone); + map.put("memCardNo", memCardNo); + map.put("productType", productType); + map.put("status", status); + map.put("payType", payType); + + // 查询数据 + List orderList = orderService.getOrderList(map); + + List dataList = new ArrayList<>(); + OrderThirdPartyModel model; + + for (HighOrder thirdPartyModel : orderList) { + model = new OrderThirdPartyModel(); + + model.setOrderNo(thirdPartyModel.getOrderNo()); + model.setMemPhone(thirdPartyModel.getMemPhone()); + model.setTitle(thirdPartyModel.getTitle()); + model.setTotalPrice(thirdPartyModel.getTotalPrice()); + model.setTotalDeductionPrice(thirdPartyModel.getTotalDeductionPrice()); + model.setDeductionProductPrice(thirdPartyModel.getDeductionProductPrice()); + model.setPayablePrice(thirdPartyModel.getPayablePrice()); + model.setPayPrice(thirdPartyModel.getPayPrice()); + model.setPayType(OrderPayTypeEnum.getNameByType(thirdPartyModel.getPayType())); + model.setOrderStatus(OrderStatusEnum.getNameByType(thirdPartyModel.getOrderStatus())); + model.setCreateTime(thirdPartyModel.getCreateTime()); + model.setPayTime(thirdPartyModel.getPayTime()); + dataList.add(model); + } + + 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(ExportGasOrderModel.class) + .sheet("交易订单") + .doWrite(dataList); + return ResponseMsgUtil.success(pathName); + + } catch (Exception e) { + log.error("OrderCouponController --> getOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-order/src/main/resources/dev/config.properties b/hai-order/src/main/resources/dev/config.properties index 21943d95..e7a650a2 100644 --- a/hai-order/src/main/resources/dev/config.properties +++ b/hai-order/src/main/resources/dev/config.properties @@ -9,5 +9,5 @@ wxPayUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder wxPayNotifyUrl=https://hsgcs.dctpay.com/order/payNotify/wechatPay unionPayNotifyUrl=https://hsgcs.dctpay.com/order/payNotify/unionPay -fileUrl=F:/hurui_probject/filesystem -cmsPath=F:/hurui_probject/filesystem +fileUrl=/Volumes/work/code/filesystem/ +cmsPath=/Volumes/work/code/filesystem/ diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java index c7879e90..08df3c4c 100644 --- a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java @@ -1,5 +1,7 @@ package com.hai.enum_type; +import java.util.Objects; + /** * 支付方式 * @author hurui @@ -22,6 +24,13 @@ public enum OrderPayTypeEnum { this.name = name; } + public static String getNameByType(Integer type) { + for (OrderPayTypeEnum ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + public Integer getType() { return type; } diff --git a/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java new file mode 100644 index 00000000..05561532 --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java @@ -0,0 +1,71 @@ +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: OrderThirdPartyModel + * @author: HuRui + * @date: 2022/9/30 + **/ +@Data +public class OrderThirdPartyModel { + + @ColumnWidth(25) + @ExcelProperty(value = "交易订单号") + private String orderNo; + + @ColumnWidth(15) + @ExcelProperty(value = "客户电话") + private String memPhone; + + @ColumnWidth(15) + @ExcelProperty(value = "订单标题") + private String title; + + @ColumnWidth(13) + @ExcelProperty(value = "订单总额") + private BigDecimal totalPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "总优惠金额") + private BigDecimal totalDeductionPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "优惠券优惠金额") + private BigDecimal deductionCouponPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "产品优惠金额") + private BigDecimal deductionProductPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "应付金额") + private BigDecimal payablePrice; + + @ColumnWidth(13) + @ExcelProperty(value = "实付金额") + private BigDecimal payPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "支付方式") + private String payType; + + @ColumnWidth(13) + @ExcelProperty(value = "订单状态") + private String orderStatus; + + @ColumnWidth(20) + @ExcelProperty(value = "创建时间") + private Date createTime; + + @ColumnWidth(20) + @ExcelProperty(value = "支付时间") + private Date payTime; + +}