选装售后
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FssPaccountPayServiceImpl.java 4.9KB

1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package com.qtzl.alterSales.manager.service;
  2. import cn.com.taiji.common.manager.net.http.ServiceHandleException;
  3. import com.google.common.collect.Lists;
  4. import com.qtzl.alterSales.dao.entity.primary.AflSupplementaryPayOrder;
  5. import com.qtzl.alterSales.dao.entity.primary.FssPaccountPay;
  6. import com.qtzl.alterSales.dao.entity.primary.WechatBillPayApply;
  7. import com.qtzl.alterSales.dao.repo.jpa.primary.AflSupplementaryPayOrderRepo;
  8. import com.qtzl.alterSales.dao.repo.jpa.primary.FssPaccountPayRepo;
  9. import com.qtzl.alterSales.dao.repo.jpa.primary.WechatBillPayApplyRepo;
  10. import com.qtzl.alterSales.manager.enums.VehiclePlateColorEnum;
  11. import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
  12. import com.qtzl.alterSales.manager.vo.VehicleAgreementNumBillsVo;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.data.domain.Page;
  15. import org.springframework.data.domain.PageRequest;
  16. import org.springframework.data.domain.Sort;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.util.CollectionUtils;
  19. import javax.annotation.Resource;
  20. import java.time.LocalDateTime;
  21. import java.util.List;
  22. /***
  23. * <p>
  24. * 选装-原始流水 service
  25. * </p>
  26. * @author hou yi
  27. * {@code @date} 2023/10/12 11:43
  28. **/
  29. @Service
  30. public class FssPaccountPayServiceImpl implements FssPaccountPayService {
  31. @Resource
  32. private FssPaccountPayRepo paccountPayRepo;
  33. @Resource
  34. private AflSupplementaryPayOrderRepo supplementaryPayOrderRepo;
  35. @Resource
  36. private WechatBillPayApplyRepo wechatBillPayApplyRepo;
  37. @Override
  38. public List<VehicleAgreementNumBillsVo> getAgreementBills(String plateNumber, Integer plateColor) throws ServiceHandleException {
  39. if (StringUtils.isEmpty(plateNumber) || null == plateColor) {
  40. throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请指定车牌号、车牌颜色");
  41. }
  42. List<FssPaccountPay> agreementBills = paccountPayRepo.findByVehicleId(plateNumber + "_" + plateColor);
  43. if (CollectionUtils.isEmpty(agreementBills)) {
  44. return Lists.newArrayList();
  45. }
  46. /* // 过滤掉已生成补缴单的流水
  47. final List<String> payIds = agreementBills.stream().map(FssPaccountPay::getPayId).toList();
  48. final List<AflSupplementaryPayOrder> orders = supplementaryPayOrderRepo.findAll((root, query, cb) -> query.where(
  49. root.<String>get("payId").in(payIds)
  50. ).getRestriction());
  51. if (!CollectionUtils.isEmpty(orders)) {
  52. final List<String> orderPayIds = orders.stream().map(AflSupplementaryPayOrder::getPayId).toList();
  53. agreementBills = agreementBills.stream().filter(vo -> !orderPayIds.contains(vo.getPayId())).toList();
  54. }*/
  55. return toVo(agreementBills);
  56. }
  57. @Override
  58. public List<VehicleAgreementNumBillsVo> findByPayId(List<String> payIds) {
  59. if (CollectionUtils.isEmpty(payIds)) {
  60. return Lists.newArrayList();
  61. }
  62. return toVo(paccountPayRepo.findByPayIdIn(payIds));
  63. }
  64. private List<VehicleAgreementNumBillsVo> toVo(List<FssPaccountPay> payList) {
  65. if (CollectionUtils.isEmpty(payList)) {
  66. return Lists.newArrayList();
  67. }
  68. List<VehicleAgreementNumBillsVo> billsVos = Lists.newArrayList();
  69. VehicleAgreementNumBillsVo billsVo;
  70. for (FssPaccountPay bill : payList) {
  71. final LocalDateTime firstInsertTime = wechatBillPayApplyRepo.getFirstInsertTime(bill.getPayId());
  72. if (null == firstInsertTime) {
  73. // 过滤掉没有// 过滤掉没有轮扣过的流水
  74. continue;
  75. }
  76. billsVo = new VehicleAgreementNumBillsVo(bill.getPayId(), bill.getSceneTp(), bill.getReceiptAmt(), bill.getChargeTime());
  77. // 处理车牌号、车牌颜色
  78. if (!StringUtils.isEmpty(bill.getVehicleId()) && bill.getVehicleId().contains("_")) {
  79. final String[] vehicle = bill.getVehicleId().split("_");
  80. billsVo.setPlateNumber(vehicle[0]);
  81. billsVo.setPlateNumberColor(VehiclePlateColorEnum.find(Integer.parseInt(vehicle[1])).getColor());
  82. }
  83. // 处理出入口站名、停车场名称
  84. if (!StringUtils.isEmpty(bill.getTitle()) && null != bill.getSceneTp()) {
  85. final String[] titleSplit = bill.getTitle().split("[,,]");
  86. if (titleSplit.length != 5) {
  87. continue;
  88. }
  89. if (bill.getSceneTp().equals(2)) {
  90. // 停车场流水
  91. billsVo.setParkingLotName(titleSplit[3]);
  92. } else {
  93. // 非停车场流水的, 按照通行流水处理
  94. billsVo.setInboundName(titleSplit[2]);
  95. billsVo.setOutboundName(titleSplit[3]);
  96. }
  97. }
  98. billsVos.add(billsVo);
  99. }
  100. return billsVos;
  101. }
  102. }