|
|
@@ -315,5 +315,25 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
|
|
|
public List<StationTrendVo> stationTrend(StatQueryParam params) {
|
|
|
return baseMapper.StationTrend(params);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String checkParkingCoupon(String mobilePhone) {
|
|
|
+ // 查询xx时间内该用户的是否有满足消费金额的订单,如果有,取最近一条的场站
|
|
|
+ var user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getMobilePhone, mobilePhone));
|
|
|
+ if (user == null) {
|
|
|
+ throw new BusinessException("请输入注册洗车小程序使用的手机号码!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优惠券有效期2小时
|
|
|
+ var orderList = lambdaQuery()
|
|
|
+ .eq(WashOrder::getUserId, user.getId())
|
|
|
+ .ge(WashOrder::getEndTime, LocalDateTime.now().minusHours(2))
|
|
|
+ .eq(WashOrder::getPayStatus, WashOrder.PAY_STATUS_已支付)
|
|
|
+ .orderByDesc(WashOrder::getId).list();
|
|
|
+ if(orderList.isEmpty() || (orderList.stream().collect(Collectors.summarizingInt(WashOrder::getAmount)).getSum() < WashOrder.PARKING_COUPON_MIN_AMOUNT)){
|
|
|
+ throw new BusinessException("不符合优惠条件:订单完成超过2小时或洗车金额不足6元。");
|
|
|
+ }
|
|
|
+ return KymCache.INSTANCE.getParkingQrCodeUrlByStationId(orderList.get(0).getStationId());
|
|
|
+ }
|
|
|
//endregion
|
|
|
}
|