From 38c053689d6c6835904d8f3ddb0a542fe00b42ad Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Fri, 20 Sep 2024 17:26:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BC=80=E7=A5=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BsGasOrderReceiptController.java | 73 +++++++++++++++++++ .../order/ExportGasOrderReceiptModel.java | 59 +++++++++++++++ .../impl/BsGasOrderReceiptServiceImpl.java | 3 +- .../service/order/OrderRefundBusiness.java | 18 +++++ .../gas/GasOrderReceiptStatusEnum.java | 16 ++++ 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 service/src/main/java/com/hfkj/model/order/ExportGasOrderReceiptModel.java diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOrderReceiptController.java b/bweb/src/main/java/com/bweb/controller/BsGasOrderReceiptController.java index 2677b1c..8a81c9f 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasOrderReceiptController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasOrderReceiptController.java @@ -1,5 +1,6 @@ package com.bweb.controller; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -8,14 +9,19 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsAgentMer; +import com.hfkj.entity.BsGasOrderReceipt; import com.hfkj.model.AgentMerAllot; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.UserSessionObject; +import com.hfkj.model.order.ExportGasOrderModel; +import com.hfkj.model.order.ExportGasOrderReceiptModel; import com.hfkj.service.agent.BsAgentMerService; import com.hfkj.service.gas.BsGasOrderReceiptService; import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.gas.GasOrderReceiptStatusEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; @@ -26,6 +32,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.io.File; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -127,4 +134,70 @@ public class BsGasOrderReceiptController { } + @RequestMapping(value="/export",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出") + public ResponseData export(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "merName", required = false) String merName, + @RequestParam(name = "contactsPhone", required = false) String contactsPhone, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE) { + try { + Map param = new HashMap<>(); + SecUserSessionObject sessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + + } else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type4.getCode())) { + param.put("agentId", sessionObject.getAccount().getObjectId()); + + } else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type5.getCode())) { + param.put("agentStaffId", sessionObject.getAccount().getObjectId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); + } + param.put("orderNo", orderNo); + param.put("merName", merName); + param.put("contactsPhone", contactsPhone); + param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + + // 查询数据 + List dataList = gasOrderReceiptService.getList(param); + List exportList = new ArrayList<>(); + ExportGasOrderReceiptModel exportModel; + for (BsGasOrderReceipt data : dataList) { + exportModel = new ExportGasOrderReceiptModel(); + exportModel.setOrderNo(data.getOrderNo()); + exportModel.setMerName(data.getMerName()); + exportModel.setOilNo(data.getOilNo()); + exportModel.setCompanyName(data.getCompanyName()); + exportModel.setTaxNo(data.getTaxNo()); + exportModel.setAmount(data.getAmount()); + exportModel.setContactsPhone(data.getContactsPhone()); + exportModel.setEmail(data.getEmail()); + exportModel.setCreateTime(data.getCreateTime()); + exportModel.setStatus(GasOrderReceiptStatusEnum.getNameByType(data.getStatus()).getManageName()); + exportList.add(exportModel); + } + String fileUrl = CommonSysConst.getSysConfig().getFilesystem() + "/temporary/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } + EasyExcel.write(fileUrl+pathName) + .head(ExportGasOrderReceiptModel.class) + .sheet("加油订单开票") + .doWrite(exportList); + return ResponseMsgUtil.success(pathName); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/service/src/main/java/com/hfkj/model/order/ExportGasOrderReceiptModel.java b/service/src/main/java/com/hfkj/model/order/ExportGasOrderReceiptModel.java new file mode 100644 index 0000000..994f1c7 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/order/ExportGasOrderReceiptModel.java @@ -0,0 +1,59 @@ +package com.hfkj.model.order; + +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/9/20 + **/ +@Data +public class ExportGasOrderReceiptModel { + + @ColumnWidth(20) + @ExcelProperty("交易单号") + private String orderNo; + + @ColumnWidth(30) + @ExcelProperty("加油站") + private String merName; + + @ColumnWidth(20) + @ExcelProperty("油号") + private String oilNo; + + @ColumnWidth(30) + @ExcelProperty("开票公司") + private String companyName; + + @ColumnWidth(25) + @ExcelProperty("开票税号") + private String taxNo; + + @ColumnWidth(25) + @ExcelProperty("开票金额") + private BigDecimal amount; + + @ColumnWidth(25) + @ExcelProperty("联系电话") + private String contactsPhone; + + @ColumnWidth(25) + @ExcelProperty("邮箱") + private String email;; + + @ColumnWidth(25) + @ExcelProperty("申请时间") + private Date createTime; + + @ColumnWidth(20) + @ExcelProperty("开票状态") + private String status; + +} diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderReceiptServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderReceiptServiceImpl.java index 4193752..1630eff 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderReceiptServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderReceiptServiceImpl.java @@ -159,7 +159,8 @@ public class BsGasOrderReceiptServiceImpl implements BsGasOrderReceiptService { @Override public List getList(Map param) { BsGasOrderReceiptExample example = new BsGasOrderReceiptExample(); - BsGasOrderReceiptExample.Criteria criteria = example.createCriteria(); + BsGasOrderReceiptExample.Criteria criteria = example.createCriteria() + .andStatusNotEqualTo(GasOrderReceiptStatusEnum.status99.getStatus()); if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) { criteria.andOrderNoLike("%"+MapUtils.getString(param, "orderNo")+"%"); diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java index 6459d6f..04914be 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java @@ -8,14 +8,17 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.entity.BsGasOrder; +import com.hfkj.entity.BsGasOrderReceipt; import com.hfkj.entity.BsMerchant; import com.hfkj.entity.BsOrderRefund; import com.hfkj.model.order.OrderChildModel; import com.hfkj.service.agent.BsAgentMerAccountService; +import com.hfkj.service.gas.BsGasOrderReceiptService; import com.hfkj.service.gas.BsGasOrderService; import com.hfkj.service.merchant.BsMerchantAccountService; import com.hfkj.service.merchant.BsMerchantChainBrandAccountService; import com.hfkj.service.merchant.BsMerchantService; +import com.hfkj.sysenum.gas.GasOrderReceiptStatusEnum; import com.hfkj.sysenum.merchant.MerchantChainBrandSettleTypeEnum; import com.hfkj.sysenum.merchant.MerchantSourceTypeEnum; import com.hfkj.sysenum.gas.OrderOilStatus; @@ -23,6 +26,9 @@ import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 退款业务 @@ -43,6 +49,8 @@ public class OrderRefundBusiness { @Resource private BsMerchantChainBrandAccountService merchantChainBrandAccountService; @Resource + private BsGasOrderReceiptService gasOrderReceiptService; + @Resource private BsAgentMerAccountService agentMerAccountService; /** @@ -92,6 +100,16 @@ public class OrderRefundBusiness { gasOrder.setRefundRemarks(refund.getRefundRemark()); gasOrderService.updateGasOrder(gasOrder); + // 撤回开票记录 + Map param = new HashMap<>(); + param.put("orderNo", gasOrder.getOrderNo()); + param.put("status", GasOrderReceiptStatusEnum.status1.getStatus()); + List orderReceiptList = gasOrderReceiptService.getList(param); + for (BsGasOrderReceipt receipt : orderReceiptList) { + receipt.setStatus(GasOrderReceiptStatusEnum.status99.getStatus()); + gasOrderReceiptService.editData(receipt); + } + if (gasOrder.getAgentId() != null && MerchantSourceTypeEnum.type1.getNumber().equals(gasOrder.getChannelType())) { try { // 代理商商户账户退款 diff --git a/service/src/main/java/com/hfkj/sysenum/gas/GasOrderReceiptStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/gas/GasOrderReceiptStatusEnum.java index ef18e0b..05464d3 100644 --- a/service/src/main/java/com/hfkj/sysenum/gas/GasOrderReceiptStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/gas/GasOrderReceiptStatusEnum.java @@ -2,6 +2,8 @@ package com.hfkj.sysenum.gas; import lombok.Getter; +import java.util.Objects; + /** * 加油站价格任务 * @author hurui @@ -24,6 +26,11 @@ public enum GasOrderReceiptStatusEnum { * 开票失败 */ status3(3 , "开票失败", "开票失败"), + + /** + * 删除 + */ + status99(99 , "删除", "删除"), ; private Integer status; @@ -36,4 +43,13 @@ public enum GasOrderReceiptStatusEnum { this.manageName = manageName; } + public static GasOrderReceiptStatusEnum getNameByType(Integer type) { + for (GasOrderReceiptStatusEnum ele : values()) { + if (Objects.equals(type,ele.getStatus())) { + return ele; + } + } + return null; + } + }