| @@ -327,29 +327,36 @@ public class WxCarController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "广场停车场类型非法."); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "广场停车场类型非法."); | ||||
| } | } | ||||
| // Integer used = ParkCacheUtils.getCarCouponUseCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| // if (null != used && 1 == used.intValue()) { | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已经使用过停车券,不能叠加使用."); | |||||
| // } | |||||
| Integer used = ParkCacheUtils.getCarCouponUseCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { | if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { | ||||
| ResultData result = etcpHelper.getCoupon(paramMap, park, userCar,carNumber); | |||||
| ParkCacheUtils.setCarCouponUsedCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| return result; | |||||
| if (null != used && used.intValue() < 1) { | |||||
| ResultData result = etcpHelper.getCoupon(paramMap, park, userCar,carNumber); | |||||
| if (result.code == Result.SUCCESS) { | |||||
| ParkCacheUtils.setCarCouponUsedCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| return new ResultData(Result.SUCCESS,"已经使用过优惠券, 不能重复使用."); | |||||
| } else { | } else { | ||||
| WxCoupon coupon = couponService.getById(userCar.getCouponId()); | WxCoupon coupon = couponService.getById(userCar.getCouponId()); | ||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空"); | ||||
| } | } | ||||
| try { | try { | ||||
| ResultData rs = parkFactory.getParkService(park.getVendorType()).useCoupon(paramMap, park, userCar, coupon, carNumber); | |||||
| if (rs.code == Result.SUCCESS) { | |||||
| etcpHelper.updateWxCouponOrderUsed(userCar, park); | |||||
| ParkCacheUtils.setCarCouponUsedCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| return new ResultData(); | |||||
| }else { | |||||
| return new ResultData(rs.code,rs.message); | |||||
| } | |||||
| if (null != used && used.intValue() < 1) { | |||||
| ResultData rs = parkFactory.getParkService(park.getVendorType()).useCoupon(paramMap, park, userCar, coupon, carNumber); | |||||
| if (rs.code == Result.SUCCESS) { | |||||
| etcpHelper.updateWxCouponOrderUsed(userCar, park); | |||||
| ParkCacheUtils.setCarCouponUsedCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||||
| return new ResultData(); | |||||
| }else { | |||||
| return new ResultData(rs.code,rs.message); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS,"已经使用过优惠券, 不能重复使用."); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("park getCoupon error",e); | logger.error("park getCoupon error",e); | ||||
| return new ResultData(Result.ERROR,e.getMessage()); | return new ResultData(Result.ERROR,e.getMessage()); | ||||