完成开票导出

master
胡锐 2 months ago
parent 9bee35a965
commit 38c053689d
  1. 73
      bweb/src/main/java/com/bweb/controller/BsGasOrderReceiptController.java
  2. 59
      service/src/main/java/com/hfkj/model/order/ExportGasOrderReceiptModel.java
  3. 3
      service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderReceiptServiceImpl.java
  4. 18
      service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java
  5. 16
      service/src/main/java/com/hfkj/sysenum/gas/GasOrderReceiptStatusEnum.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<String,Object> 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<BsGasOrderReceipt> dataList = gasOrderReceiptService.getList(param);
List<ExportGasOrderReceiptModel> 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);
}
}
}

@ -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;
}

@ -159,7 +159,8 @@ public class BsGasOrderReceiptServiceImpl implements BsGasOrderReceiptService {
@Override
public List<BsGasOrderReceipt> getList(Map<String, Object> 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")+"%");

@ -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<String,Object> param = new HashMap<>();
param.put("orderNo", gasOrder.getOrderNo());
param.put("status", GasOrderReceiptStatusEnum.status1.getStatus());
List<BsGasOrderReceipt> 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 {
// 代理商商户账户退款

@ -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;
}
}

Loading…
Cancel
Save