123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package com.qtzl.alterSales.manager.service;
-
- import cn.com.taiji.common.manager.net.http.ServiceHandleException;
- import com.google.common.collect.Lists;
- import com.qtzl.alterSales.dao.entity.primary.AflSupplementaryPayOrder;
- import com.qtzl.alterSales.dao.entity.primary.FssPaccountPay;
- import com.qtzl.alterSales.dao.entity.primary.WechatBillPayApply;
- import com.qtzl.alterSales.dao.repo.jpa.primary.AflSupplementaryPayOrderRepo;
- import com.qtzl.alterSales.dao.repo.jpa.primary.FssPaccountPayRepo;
- import com.qtzl.alterSales.dao.repo.jpa.primary.WechatBillPayApplyRepo;
- import com.qtzl.alterSales.manager.enums.VehiclePlateColorEnum;
- import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
- import com.qtzl.alterSales.manager.vo.VehicleAgreementNumBillsVo;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.data.domain.Page;
- import org.springframework.data.domain.PageRequest;
- import org.springframework.data.domain.Sort;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
-
- import javax.annotation.Resource;
- import java.time.LocalDateTime;
- import java.util.List;
-
- /***
- * <p>
- * 选装-原始流水 service
- * </p>
- * @author hou yi
- * {@code @date} 2023/10/12 11:43
- **/
- @Service
- public class FssPaccountPayServiceImpl implements FssPaccountPayService {
-
- @Resource
- private FssPaccountPayRepo paccountPayRepo;
- @Resource
- private AflSupplementaryPayOrderRepo supplementaryPayOrderRepo;
- @Resource
- private WechatBillPayApplyRepo wechatBillPayApplyRepo;
-
- @Override
- public List<VehicleAgreementNumBillsVo> getAgreementBills(String plateNumber, Integer plateColor) throws ServiceHandleException {
- if (StringUtils.isEmpty(plateNumber) || null == plateColor) {
- throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定车牌号、车牌颜色");
- }
- List<FssPaccountPay> agreementBills = paccountPayRepo.findByVehicleId(plateNumber + "_" + plateColor);
- if (CollectionUtils.isEmpty(agreementBills)) {
- return Lists.newArrayList();
- }
- /* // 过滤掉已生成补缴单的流水
- final List<String> payIds = agreementBills.stream().map(FssPaccountPay::getPayId).toList();
- final List<AflSupplementaryPayOrder> orders = supplementaryPayOrderRepo.findAll((root, query, cb) -> query.where(
- root.<String>get("payId").in(payIds)
- ).getRestriction());
- if (!CollectionUtils.isEmpty(orders)) {
- final List<String> orderPayIds = orders.stream().map(AflSupplementaryPayOrder::getPayId).toList();
- agreementBills = agreementBills.stream().filter(vo -> !orderPayIds.contains(vo.getPayId())).toList();
- }*/
- return toVo(agreementBills);
- }
-
- @Override
- public List<VehicleAgreementNumBillsVo> findByPayId(List<String> payIds) {
- if (CollectionUtils.isEmpty(payIds)) {
- return Lists.newArrayList();
- }
- return toVo(paccountPayRepo.findByPayIdIn(payIds));
- }
-
- private List<VehicleAgreementNumBillsVo> toVo(List<FssPaccountPay> payList) {
- if (CollectionUtils.isEmpty(payList)) {
- return Lists.newArrayList();
- }
- List<VehicleAgreementNumBillsVo> billsVos = Lists.newArrayList();
- VehicleAgreementNumBillsVo billsVo;
- for (FssPaccountPay bill : payList) {
- final LocalDateTime firstInsertTime = wechatBillPayApplyRepo.getFirstInsertTime(bill.getPayId());
- if (null == firstInsertTime) {
- // 过滤掉没有// 过滤掉没有轮扣过的流水
- continue;
- }
- billsVo = new VehicleAgreementNumBillsVo(bill.getPayId(), bill.getSceneTp(), bill.getReceiptAmt(), bill.getChargeTime());
- // 处理车牌号、车牌颜色
- if (!StringUtils.isEmpty(bill.getVehicleId()) && bill.getVehicleId().contains("_")) {
- final String[] vehicle = bill.getVehicleId().split("_");
- billsVo.setPlateNumber(vehicle[0]);
- billsVo.setPlateNumberColor(VehiclePlateColorEnum.find(Integer.parseInt(vehicle[1])).getColor());
- }
- // 处理出入口站名、停车场名称
- if (!StringUtils.isEmpty(bill.getTitle()) && null != bill.getSceneTp()) {
- final String[] titleSplit = bill.getTitle().split("[,,]");
- if (titleSplit.length != 5) {
- continue;
- }
- if (bill.getSceneTp().equals(2)) {
- // 停车场流水
- billsVo.setParkingLotName(titleSplit[3]);
- } else {
- // 非停车场流水的, 按照通行流水处理
- billsVo.setInboundName(titleSplit[2]);
- billsVo.setOutboundName(titleSplit[3]);
- }
- }
- billsVos.add(billsVo);
- }
- return billsVos;
- }
- }
|