选装售后
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.6KB

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