|
@@ -70,6 +70,7 @@ import com.pj.project.tb_unit.TbUnitService;
|
|
|
import com.pj.project4sp.admin.SpAdmin;
|
|
|
import com.pj.project4sp.admin.SpAdminService;
|
|
|
import com.pj.project4sp.global.BusinessException;
|
|
|
+import com.pj.utils.cache.RedisUtil;
|
|
|
import com.pj.utils.sg.AjaxJson;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -162,8 +163,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
@Resource
|
|
|
private TbFeeDetailsService tbFeeDetailsService;
|
|
|
|
|
|
- @Resource
|
|
|
- private TbMildCarService tbMildCarService;
|
|
|
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
@@ -513,14 +512,14 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* 微信端获取缴费信息
|
|
|
*
|
|
|
* @param businessCarId
|
|
|
- * @param state
|
|
|
+ * @param channel
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, Object> getBusinessMoney(String businessCarId, String state) {
|
|
|
+ public Map<String, Object> getBusinessMoney(String businessCarId, String channel) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//对应的业务
|
|
|
List<TbBusiness> businessList = this.findOtherBusinessByCarId(businessCarId);
|
|
|
- Set<TbBusinessCar> cars = new HashSet<>();
|
|
|
+ TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
//越南车是否需要支付
|
|
|
int vietnamCarPay = businessList.stream().anyMatch(tbBusiness -> {
|
|
|
TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
@@ -535,7 +534,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (businessList.isEmpty()) {
|
|
|
vietnamCarPay = 1;
|
|
|
chinaCarPay = 1;
|
|
|
- cars.add(tbBusinessCarService.getById(businessCarId));
|
|
|
}
|
|
|
businessList = businessList.stream().filter(tbBusiness -> {
|
|
|
TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
@@ -545,65 +543,66 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
//或者下单后可缴费
|
|
|
|| TbGoods.PayStep.BEFORE_CONFIRM.getCode().equals(payStep) && tbBusiness.getAdminConfirmInput() >= 0;
|
|
|
}).collect(Collectors.toList());
|
|
|
- businessList.forEach(tbBusiness -> {
|
|
|
- List<TbBusinessCar> businessCars = tbBusinessCarService.findOtherBusinessCar(tbBusiness.getId());
|
|
|
- cars.addAll(businessCars);
|
|
|
- });
|
|
|
+
|
|
|
List<String> businessIdList = businessList.stream().map(TbBusiness::getId).collect(Collectors.toList());
|
|
|
String businessIds = StrUtil.join(",", businessIdList);
|
|
|
-// result.put("type", businessType);
|
|
|
result.put("showPay", true);
|
|
|
result.put("businessId", businessIds);
|
|
|
+ result.put("noJudgeCount", 0);
|
|
|
+ if (TbBusinessCar.BusinessTypeEnum.BUSINESS_CAR.getType().equals(tbBusinessCar.getBusinessType())) {
|
|
|
+ if (tbBusinessCar.getConfirmJudge() != TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
|
|
|
+ result.put("noJudgeCount", 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<TbBusinessItem> items = tbBusinessItemService.findByBusinessIdList(businessIdList);
|
|
|
- Date now = new Date();
|
|
|
- List<Map<String, Object>> carsList = new ArrayList<>();
|
|
|
- for (TbBusinessCar tbBusinessCar : cars) {
|
|
|
- Date inTime = tbBusinessCar.getRealInTime();
|
|
|
- BigDecimal partMoney = new BigDecimal("0");
|
|
|
- String carType = tbBusinessCar.getCarType();
|
|
|
- if (StrUtil.isEmpty(carType)) {
|
|
|
- carType = TbItem.ItemTypeEnum.EMPTY_TYPE.getType();
|
|
|
+ Date inTime = tbBusinessCar.getRealInTime();
|
|
|
+ int pay = tbBusinessCar.getPay();
|
|
|
+ Map<String, Object> carMap = new HashMap<>();
|
|
|
+ carMap.put("price", 0);
|
|
|
+ if (pay == 0 && inTime != null) {
|
|
|
+ Date outTime = tbBusinessCar.getRealOutTime();
|
|
|
+ String cacheCarNo = RedisUtil.get(channel);
|
|
|
+ if (outTime == null && StrUtil.isNotEmpty(cacheCarNo)) {
|
|
|
+ outTime = new Date();
|
|
|
}
|
|
|
- if (inTime != null && tbBusinessCar.getRealOutTime() == null) {
|
|
|
- if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getPayTime() != null) {
|
|
|
- inTime = tbBusinessCar.getPayTime();
|
|
|
+ if (outTime != null) {
|
|
|
+ String carType = tbBusinessCar.getCarType();
|
|
|
+ if (StrUtil.isEmpty(carType)) {
|
|
|
+ carType = TbItem.ItemTypeEnum.EMPTY_TYPE.getType();
|
|
|
}
|
|
|
- partMoney = this.calculationPartMoney(inTime, now, tbBusinessCar.getCarSize());
|
|
|
- }
|
|
|
- if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
|
|
|
- String freeColor = partConfig.getFreeColor();
|
|
|
- //4.2米以下蓝色车辆
|
|
|
- if (tbBusinessCar.getColor().contains(freeColor) && tbBusinessCar.getCarSize() <= partConfig.getFreeCarLength()) {
|
|
|
+ BigDecimal partMoney = calculationPartMoney(inTime, outTime, tbBusinessCar.getCarSize());
|
|
|
+ carMap.put("price", partMoney);
|
|
|
+ if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
|
|
|
+ String freeColor = partConfig.getFreeColor();
|
|
|
+ //4.2米以下蓝色车辆
|
|
|
+ if (tbBusinessCar.getColor().contains(freeColor) && tbBusinessCar.getCarSize() <= partConfig.getFreeCarLength()) {
|
|
|
+ partMoney = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //越南车牌,是否免费
|
|
|
+ if (TbItem.ItemTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0) {
|
|
|
partMoney = new BigDecimal("0");
|
|
|
}
|
|
|
+ //中国车,是否免费
|
|
|
+ if (TbItem.ItemTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0) {
|
|
|
+ partMoney = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ if (TbBusinessCar.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
|
|
|
+ carMap.put("price", 0);
|
|
|
+ }
|
|
|
}
|
|
|
- //越南车牌,是否免费
|
|
|
- if (TbItem.ItemTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0) {
|
|
|
- partMoney = new BigDecimal("0");
|
|
|
- }
|
|
|
- //中国车,是否免费
|
|
|
- if (TbItem.ItemTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0) {
|
|
|
- partMoney = new BigDecimal("0");
|
|
|
- }
|
|
|
- Map<String, Object> carMap = new HashMap<>();
|
|
|
- carMap.put("price", partMoney);
|
|
|
- carMap.put("id", tbBusinessCar.getId());
|
|
|
- carMap.put("carNo", tbBusinessCar.getCarNo());
|
|
|
- carMap.put("pay", tbBusinessCar.getPay());
|
|
|
- carMap.put("no", tbBusinessCar.getNo());
|
|
|
- if (TbBusinessCar.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
|
|
|
- carMap.put("price", 0);
|
|
|
- }
|
|
|
- carsList.add(carMap);
|
|
|
}
|
|
|
- result.put("carList", carsList.stream().sorted(Comparator.comparingDouble(obj -> Double.valueOf(obj.get("price").toString()))).collect(Collectors.toList()));
|
|
|
+ carMap.put("id", tbBusinessCar.getId());
|
|
|
+ carMap.put("carNo", tbBusinessCar.getCarNo());
|
|
|
+ carMap.put("pay", pay);
|
|
|
+ carMap.put("no", tbBusinessCar.getNo());
|
|
|
+ result.put("carList",Collections.singleton(carMap));
|
|
|
BigDecimal itemsPrice = new BigDecimal("0");
|
|
|
List<Map<String, Object>> itemList = new ArrayList<>();
|
|
|
+ //未支付的
|
|
|
+ items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
for (TbBusinessItem item : items) {
|
|
|
BigDecimal itemPrice = item.getItemPrice().multiply(new BigDecimal(item.getNum()));
|
|
|
- if (item.getPayStatus() == 1) {
|
|
|
- continue;
|
|
|
- }
|
|
|
itemsPrice = itemsPrice.add(itemPrice);
|
|
|
Map<String, Object> itemMap = new HashMap<>();
|
|
|
itemMap.put("id", item.getId());
|
|
@@ -626,13 +625,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- result.put("noJudgeCount", 0);
|
|
|
- TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
- if (TbBusinessCar.BusinessTypeEnum.BUSINESS_CAR.getType().equals(tbBusinessCar.getBusinessType())) {
|
|
|
- if (tbBusinessCar.getConfirmJudge() != TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
|
|
|
- result.put("noJudgeCount", 1);
|
|
|
- }
|
|
|
- }
|
|
|
result.put("itemsPrice", itemsPrice);
|
|
|
result.put("itemList", itemList);
|
|
|
result.put("businessNo", businessList.stream().map(TbBusiness::getNo).distinct().collect(Collectors.joining("、")));
|
|
@@ -640,6 +632,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public List<TbBusiness> findOtherBusinessByCarId(String businessCarId) {
|
|
|
return tbBusinessMapper.findOtherBusinessByCarId(businessCarId);
|
|
|
}
|