mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-18 13:08:04 +08:00
新增 发票导出接口
This commit is contained in:
@@ -10,6 +10,7 @@ import com.jsowell.pile.domain.OrderInvoiceRecord;
|
||||
import com.jsowell.pile.dto.GetInvoiceInfoDTO;
|
||||
import com.jsowell.pile.service.OrderInvoiceRecordService;
|
||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -64,6 +66,18 @@ public class OrderInvoiceRecordController extends BaseController {
|
||||
util.exportExcel(response, list, "申请开票数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出所选申请开票详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:invoice:export')")
|
||||
@Log(title = "申请开票", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export/selected")
|
||||
public void exportSelected(HttpServletResponse response, @RequestParam("ids") Integer[] ids) {
|
||||
List<OrderInvoiceExportVO> list = orderInvoiceRecordService.selectInvoiceExportList(ids);
|
||||
ExcelUtil<OrderInvoiceExportVO> util = new ExcelUtil<OrderInvoiceExportVO>(OrderInvoiceExportVO.class);
|
||||
util.exportExcel(response, list, "所选申请开票详情数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申请开票详细信息
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.jsowell.pile.domain.OrderInvoiceRecord;
|
||||
import com.jsowell.pile.dto.GetInvoiceInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryInvoiceRecordDTO;
|
||||
import com.jsowell.pile.vo.web.InvoiceRecordVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -26,6 +27,8 @@ public interface OrderInvoiceRecordService {
|
||||
|
||||
InvoiceRecordVO selectInvoiceTitleVO(Integer id);
|
||||
|
||||
List<OrderInvoiceExportVO> selectInvoiceExportList(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 查询申请开票列表
|
||||
*
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.base.OrderAmountDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO;
|
||||
import com.jsowell.pile.vo.web.InvoiceRecordVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceOrderExportVO;
|
||||
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,7 +22,11 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 申请开票Service业务层处理
|
||||
@@ -76,6 +82,82 @@ public class OrderInvoiceRecordServiceImpl implements OrderInvoiceRecordService
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderInvoiceExportVO> selectInvoiceExportList(Integer[] ids) {
|
||||
if (ids == null || ids.length == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(ids)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(this::selectInvoiceTitleVO)
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::buildOrderInvoiceExportVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private OrderInvoiceExportVO buildOrderInvoiceExportVO(InvoiceRecordVO invoiceRecordVO) {
|
||||
InvoiceTitleVO invoiceTitle = invoiceRecordVO.getInvoiceTitle();
|
||||
return OrderInvoiceExportVO.builder()
|
||||
.id(invoiceRecordVO.getId())
|
||||
.memberId(invoiceRecordVO.getMemberId())
|
||||
.phoneNumber(invoiceRecordVO.getPhoneNumber())
|
||||
.status(invoiceRecordVO.getStatus())
|
||||
.createTime(invoiceRecordVO.getCreateTime())
|
||||
.updateTime(invoiceRecordVO.getUpdateTime())
|
||||
.titleId(invoiceTitle == null ? null : invoiceTitle.getTitleId())
|
||||
.titleName(invoiceTitle == null ? null : invoiceTitle.getTitleName())
|
||||
.titleType(invoiceTitle == null ? null : invoiceTitle.getTitleType())
|
||||
.taxId(invoiceTitle == null ? null : invoiceTitle.getTaxId())
|
||||
.unitAddress(invoiceTitle == null ? null : invoiceTitle.getUnitAddress())
|
||||
.email(invoiceTitle == null ? null : invoiceTitle.getEmail())
|
||||
.reception(invoiceTitle == null ? null : invoiceTitle.getReception())
|
||||
.titlePhoneNumber(invoiceTitle == null ? null : invoiceTitle.getPhoneNumber())
|
||||
.bankName(invoiceTitle == null ? null : invoiceTitle.getBankName())
|
||||
.bankAccountNumber(invoiceTitle == null ? null : invoiceTitle.getBankAccountNumber())
|
||||
.defaultFlag(invoiceTitle == null ? null : invoiceTitle.getDefaultFlag())
|
||||
.orderList(buildOrderExportList(invoiceRecordVO.getOrderList()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<OrderInvoiceOrderExportVO> buildOrderExportList(List<OrderAmountDetailVO> orderList) {
|
||||
if (CollectionUtils.isEmpty(orderList)) {
|
||||
List<OrderInvoiceOrderExportVO> emptyOrderList = new ArrayList<>();
|
||||
emptyOrderList.add(new OrderInvoiceOrderExportVO());
|
||||
return emptyOrderList;
|
||||
}
|
||||
List<OrderInvoiceOrderExportVO> exportList = orderList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::buildOrderInvoiceOrderExportVO)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(exportList)) {
|
||||
exportList.add(new OrderInvoiceOrderExportVO());
|
||||
}
|
||||
return exportList;
|
||||
}
|
||||
|
||||
private OrderInvoiceOrderExportVO buildOrderInvoiceOrderExportVO(OrderAmountDetailVO orderAmountDetailVO) {
|
||||
return OrderInvoiceOrderExportVO.builder()
|
||||
.orderCode(orderAmountDetailVO.getOrderCode())
|
||||
.totalUsedElectricity(orderAmountDetailVO.getTotalUsedElectricity())
|
||||
.totalOrderAmount(orderAmountDetailVO.getTotalOrderAmount())
|
||||
.totalElectricityAmount(orderAmountDetailVO.getTotalElectricityAmount())
|
||||
.totalServiceAmount(orderAmountDetailVO.getTotalServiceAmount())
|
||||
.sharpUsedElectricity(orderAmountDetailVO.getSharpUsedElectricity())
|
||||
.sharpElectricityPrice(orderAmountDetailVO.getSharpElectricityPrice())
|
||||
.sharpServicePrice(orderAmountDetailVO.getSharpServicePrice())
|
||||
.peakUsedElectricity(orderAmountDetailVO.getPeakUsedElectricity())
|
||||
.peakElectricityPrice(orderAmountDetailVO.getPeakElectricityPrice())
|
||||
.peakServicePrice(orderAmountDetailVO.getPeakServicePrice())
|
||||
.flatUsedElectricity(orderAmountDetailVO.getFlatUsedElectricity())
|
||||
.flatElectricityPrice(orderAmountDetailVO.getFlatElectricityPrice())
|
||||
.flatServicePrice(orderAmountDetailVO.getFlatServicePrice())
|
||||
.valleyUsedElectricity(orderAmountDetailVO.getValleyUsedElectricity())
|
||||
.valleyElectricityPrice(orderAmountDetailVO.getValleyElectricityPrice())
|
||||
.valleyServicePrice(orderAmountDetailVO.getValleyServicePrice())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询申请开票列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发票详情导出数据
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class OrderInvoiceExportVO {
|
||||
@Excel(name = "申请记录ID", sort = 1, needMerge = true)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "会员ID", sort = 2, needMerge = true, width = 20)
|
||||
private String memberId;
|
||||
|
||||
@Excel(name = "申请人电话", sort = 3, needMerge = true, width = 18)
|
||||
private String phoneNumber;
|
||||
|
||||
@Excel(name = "状态", sort = 4, needMerge = true, readConverterExp = "0=未开票,1=已开票")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "申请时间", sort = 5, needMerge = true, width = 20)
|
||||
private String createTime;
|
||||
|
||||
@Excel(name = "开票时间", sort = 6, needMerge = true, width = 20)
|
||||
private String updateTime;
|
||||
|
||||
@Excel(name = "抬头ID", sort = 7, needMerge = true)
|
||||
private String titleId;
|
||||
|
||||
@Excel(name = "抬头名称", sort = 8, needMerge = true, width = 30)
|
||||
private String titleName;
|
||||
|
||||
@Excel(name = "抬头类型", sort = 9, needMerge = true)
|
||||
private String titleType;
|
||||
|
||||
@Excel(name = "税号", sort = 10, needMerge = true, width = 24)
|
||||
private String taxId;
|
||||
|
||||
@Excel(name = "单位地址", sort = 11, needMerge = true, width = 30)
|
||||
private String unitAddress;
|
||||
|
||||
@Excel(name = "抬头邮箱", sort = 12, needMerge = true, width = 24)
|
||||
private String email;
|
||||
|
||||
@Excel(name = "接收方式", sort = 13, needMerge = true)
|
||||
private String reception;
|
||||
|
||||
@Excel(name = "抬头电话", sort = 14, needMerge = true, width = 18)
|
||||
private String titlePhoneNumber;
|
||||
|
||||
@Excel(name = "开户银行", sort = 15, needMerge = true, width = 24)
|
||||
private String bankName;
|
||||
|
||||
@Excel(name = "银行账户", sort = 16, needMerge = true, width = 24)
|
||||
private String bankAccountNumber;
|
||||
|
||||
@Excel(name = "默认抬头", sort = 17, needMerge = true, readConverterExp = "0=否,1=是")
|
||||
private String defaultFlag;
|
||||
|
||||
@Excel(name = "订单明细", sort = 18)
|
||||
private List<OrderInvoiceOrderExportVO> orderList;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 发票关联订单导出明细
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class OrderInvoiceOrderExportVO {
|
||||
@Excel(name = "订单号", sort = 1, width = 24)
|
||||
private String orderCode;
|
||||
|
||||
@Excel(name = "总用电量", sort = 2)
|
||||
private BigDecimal totalUsedElectricity;
|
||||
|
||||
@Excel(name = "订单总金额", sort = 3)
|
||||
private BigDecimal totalOrderAmount;
|
||||
|
||||
@Excel(name = "电费总金额", sort = 4)
|
||||
private BigDecimal totalElectricityAmount;
|
||||
|
||||
@Excel(name = "服务费总金额", sort = 5)
|
||||
private BigDecimal totalServiceAmount;
|
||||
|
||||
@Excel(name = "尖时段用电量", sort = 6)
|
||||
private BigDecimal sharpUsedElectricity;
|
||||
|
||||
@Excel(name = "尖时段电费单价", sort = 7)
|
||||
private BigDecimal sharpElectricityPrice;
|
||||
|
||||
@Excel(name = "尖时段服务费单价", sort = 8)
|
||||
private BigDecimal sharpServicePrice;
|
||||
|
||||
@Excel(name = "峰时段用电量", sort = 9)
|
||||
private BigDecimal peakUsedElectricity;
|
||||
|
||||
@Excel(name = "峰时段电费单价", sort = 10)
|
||||
private BigDecimal peakElectricityPrice;
|
||||
|
||||
@Excel(name = "峰时段服务费单价", sort = 11)
|
||||
private BigDecimal peakServicePrice;
|
||||
|
||||
@Excel(name = "平时段用电量", sort = 12)
|
||||
private BigDecimal flatUsedElectricity;
|
||||
|
||||
@Excel(name = "平时段电费单价", sort = 13)
|
||||
private BigDecimal flatElectricityPrice;
|
||||
|
||||
@Excel(name = "平时段服务费单价", sort = 14)
|
||||
private BigDecimal flatServicePrice;
|
||||
|
||||
@Excel(name = "谷时段用电量", sort = 15)
|
||||
private BigDecimal valleyUsedElectricity;
|
||||
|
||||
@Excel(name = "谷时段电费单价", sort = 16)
|
||||
private BigDecimal valleyElectricityPrice;
|
||||
|
||||
@Excel(name = "谷时段服务费单价", sort = 17)
|
||||
private BigDecimal valleyServicePrice;
|
||||
}
|
||||
Reference in New Issue
Block a user