mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
修改接口文档,申请开票接口
This commit is contained in:
@@ -275,6 +275,7 @@ public class OrderController extends BaseController {
|
||||
/**
|
||||
* 申请开票接口
|
||||
*/
|
||||
@PostMapping("/applyOrderInvoice")
|
||||
public RestApiResponse<?> applyOrderInvoice(HttpServletRequest request, @RequestBody ApplyOrderInvoiceDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
@@ -82,12 +83,14 @@ import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -1011,11 +1014,10 @@ public class OrderService {
|
||||
}
|
||||
|
||||
// 排除掉已经申请过的订单
|
||||
List<String> orderCodeList = Lists.newArrayList();
|
||||
for (OrderInvoiceRecord orderInvoiceRecord : orderInvoiceRecords) {
|
||||
String orderCodes = orderInvoiceRecord.getOrderCodes();
|
||||
orderCodeList.addAll(Lists.newArrayList(StringUtils.split(orderCodes, ",")));
|
||||
}
|
||||
List<String> orderCodeList = orderInvoiceRecords.stream() // 转化为 Stream
|
||||
.map(OrderInvoiceRecord::getOrderCodes) // 获取 OrderInvoiceRecord 中的 orderCodes 字符串
|
||||
.flatMap(str -> Arrays.stream(str.split(","))) // 分隔逗号并转化为 Stream
|
||||
.collect(Collectors.toList()); // 收集为 List<String>
|
||||
|
||||
orderList = orderList.stream()
|
||||
.filter(x -> !orderCodeList.contains(x.getOrderCode()))
|
||||
@@ -1029,11 +1031,47 @@ public class OrderService {
|
||||
* @param dto
|
||||
*/
|
||||
public void applyOrderInvoice(ApplyOrderInvoiceDTO dto) {
|
||||
// 校验订单是否已经开票
|
||||
int i = 60;
|
||||
// 查询最近60天完成的订单
|
||||
LocalDateTime dateTime = LocalDateTime.now().plusDays(-i);
|
||||
// 查询最近60天申请开票记录
|
||||
QueryInvoiceRecordDTO build = QueryInvoiceRecordDTO.builder()
|
||||
.memberId(dto.getMemberId())
|
||||
.startTime(dateTime)
|
||||
.build();
|
||||
List<OrderInvoiceRecord> orderInvoiceRecords = orderInvoiceRecordService.selectInvoiceRecordList(build);
|
||||
List<String> orderCodeList = orderInvoiceRecords.stream() // 转化为 Stream
|
||||
.map(OrderInvoiceRecord::getOrderCodes) // 获取 OrderInvoiceRecord 中的 orderCodes 字符串
|
||||
.flatMap(str -> Arrays.stream(str.split(","))) // 分隔逗号并转化为 Stream
|
||||
.collect(Collectors.toList()); // 收集为 List<String>
|
||||
|
||||
// 取交集 校验订单是否已经开票
|
||||
Set<String> intersection = Sets.intersection(Sets.newHashSet(orderCodeList), Sets.newHashSet(dto.getOrderCodes()));
|
||||
if (CollectionUtils.isNotEmpty(intersection)) {
|
||||
log.info("申请开票前端传的:{}订单号list, 包含已经申请的订单:{}", dto.getOrderCodes(), intersection);
|
||||
return;
|
||||
}
|
||||
|
||||
// 整理数据
|
||||
List<OrderVO> orderVOList = orderBasicInfoService.getListByOrderCodes(dto.getOrderCodes());
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalElecAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalServiceAmount = BigDecimal.ZERO;
|
||||
for (OrderVO orderVO : orderVOList) {
|
||||
totalAmount = totalAmount.add(orderVO.getOrderAmount());
|
||||
totalElecAmount = totalElecAmount.add(orderVO.getTotalElectricityAmount());
|
||||
totalServiceAmount = totalServiceAmount.add(orderVO.getTotalServiceAmount());
|
||||
}
|
||||
|
||||
// 入库
|
||||
OrderInvoiceRecord orderInvoiceRecord = new OrderInvoiceRecord();
|
||||
orderInvoiceRecord.setStatus("0");
|
||||
orderInvoiceRecord.setMemberId(dto.getMemberId());
|
||||
orderInvoiceRecord.setTitleId(dto.getTitleId());
|
||||
orderInvoiceRecord.setOrderCodes(String.join(",", dto.getOrderCodes()));
|
||||
orderInvoiceRecord.setTotalAmount(totalAmount);
|
||||
orderInvoiceRecord.setTotalElecAmount(totalElecAmount);
|
||||
orderInvoiceRecord.setTotalServiceAmount(totalServiceAmount);
|
||||
orderInvoiceRecordService.insertOrderInvoiceRecord(orderInvoiceRecord);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user