| @@ -18,6 +18,7 @@ import com.iformall.service.*; | |||
| import com.iformall.service.park.ParkFactory; | |||
| import com.iformall.service.park.impl.etcp.EtcpHelper; | |||
| import com.iformall.service.park.impl.util.ParkHelper; | |||
| import com.iformall.service.park.utils.ParkCacheUtils; | |||
| import com.iformall.utils.car.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -27,6 +28,8 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| @@ -78,6 +81,10 @@ public class WxCarController extends BaseController { | |||
| @Autowired | |||
| EtcpHelper etcpHelper; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| private WxPark getCurrentPark(TenantEntity tenantEntity) { | |||
| WxPark parkQ = new WxPark(); | |||
| @@ -285,6 +292,7 @@ public class WxCarController extends BaseController { | |||
| if (StringUtils.isBlank(carNumber)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); | |||
| } | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId为空"); | |||
| } | |||
| @@ -314,8 +322,20 @@ public class WxCarController extends BaseController { | |||
| userCar = list.get(0); | |||
| } | |||
| EnumCarVendor vendor = EnumCarVendor.getEnum(park.getVendorType()); | |||
| if (null == vendor) { | |||
| 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(), "已经使用过停车券,不能叠加使用."); | |||
| } | |||
| if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { | |||
| return etcpHelper.getCoupon(paramMap, park, userCar,carNumber); | |||
| ResultData result = etcpHelper.getCoupon(paramMap, park, userCar,carNumber); | |||
| ParkCacheUtils.setCarCouponUsedCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||
| return result; | |||
| } else { | |||
| WxCoupon coupon = couponService.getById(userCar.getCouponId()); | |||
| if (coupon == null) { | |||
| @@ -325,6 +345,7 @@ public class WxCarController extends BaseController { | |||
| 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); | |||
| @@ -12,13 +12,17 @@ import com.iformall.enums.EnumCouponSendSendType; | |||
| import com.iformall.enums.EnumETCPCode; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.park.utils.ParkCacheUtils; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.iformall.utils.car.ETCPUtil; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| @@ -59,6 +63,10 @@ public class WxCarETCPCallBackController extends BaseController { | |||
| @Autowired | |||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| @@ -79,7 +87,9 @@ public class WxCarETCPCallBackController extends BaseController { | |||
| @PostMapping(value = "/etcpParkInCallback") | |||
| public Result etcpParkInCallback(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("["+getIpAddr()+"] etcpParkInCallback: " + paramMap.toString()); | |||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||
| ParkCacheUtils.removeCache(redisTemplate, "etcp", carNumber); | |||
| ParkCacheUtils.setCarCouponUnUseCacheLock(redisTemplate, "etcp", carNumber); | |||
| doEtcpParkIn(paramMap); | |||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | |||
| @@ -106,7 +116,8 @@ public class WxCarETCPCallBackController extends BaseController { | |||
| @PostMapping(value = "/etcpParkOutCallback") | |||
| public Result etcpParkOutCallback(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("["+getIpAddr()+"etcpParkOutCallback: " + paramMap.toString()); | |||
| String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); | |||
| ParkCacheUtils.removeCache(redisTemplate, "etcp", carNumber); | |||
| doEtcpParkOut(paramMap); | |||
| return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); | |||
| @@ -15,7 +15,9 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.park.ParkFactory; | |||
| import com.iformall.service.park.entity.ParkNotifyParam; | |||
| import com.iformall.service.park.utils.ParkCacheUtils; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.iformall.utils.car.CYFUtil; | |||
| import com.iformall.utils.car.ETCPUtil; | |||
| import com.iformall.utils.car.TJDUtil; | |||
| @@ -25,6 +27,8 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| @@ -66,6 +70,10 @@ public class WxParkCallBackBaseController extends BaseController { | |||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @Autowired | |||
| ParkFactory parkFactory; | |||
| @@ -157,8 +165,12 @@ public class WxParkCallBackBaseController extends BaseController { | |||
| protected Result parkInCallBack(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { | |||
| ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parseInNoticyParam(sourceParam); | |||
| String carNumber = param.getCarNumber(); | |||
| ParkCacheUtils.removeCache(redisTemplate, vendor.getMessage(), carNumber); | |||
| ParkCacheUtils.setCarCouponUnUseCacheLock(redisTemplate, vendor.getMessage(), carNumber); | |||
| //添加wxCarCmdLog | |||
| WxCarCmdLog wxCarCmdLog = null; | |||
| try { | |||
| @@ -167,7 +179,7 @@ public class WxParkCallBackBaseController extends BaseController { | |||
| return new Result(Result.ERROR,e.getMessage()); | |||
| } | |||
| String carNumber = param.getCarNumber(); | |||
| String phoneStrs = ""; | |||
| // 停车发券 | |||
| if (!StringUtils.isBlank(carNumber)) { | |||
| @@ -205,6 +217,9 @@ public class WxParkCallBackBaseController extends BaseController { | |||
| protected Result parkOutCallBack(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { | |||
| ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parseOutNoticyParam(sourceParam); | |||
| ParkCacheUtils.removeCache(redisTemplate, vendor.getMessage(), param.getCarNumber()); | |||
| WxCarCmdLog wxCarCmdLog = null; | |||
| try { | |||
| wxCarCmdLog = saveWxCarCmdLog(vendor, cmdType, sourceParam, param); | |||
| @@ -0,0 +1,29 @@ | |||
| package com.iformall.service.park.utils; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| public class ParkCacheUtils { | |||
| public static void removeCache(RedisTemplate<String, Object> template,String parkVendor,String carNumber) { | |||
| String key = "carStop:"+parkVendor+":"+carNumber; | |||
| RedisCacheUtils.removeCache(template, key); | |||
| } | |||
| public static void setCarCouponUnUseCacheLock(RedisTemplate<String, Object> template,String parkVendor,String carNumber) { | |||
| String key = "carStop:"+parkVendor+":"+carNumber; | |||
| RedisCacheUtils.cache(template, key, 0, 0); | |||
| } | |||
| public static void setCarCouponUsedCacheLock(RedisTemplate<String, Object> template,String parkVendor,String carNumber) { | |||
| String key = "carStop:"+parkVendor+":"+carNumber; | |||
| RedisCacheUtils.cache(template, key, 1, 0); | |||
| } | |||
| public static Integer getCarCouponUseCacheLock(RedisTemplate<String, Object> template,String parkVendor,String carNumber) { | |||
| String key = "carStop:"+parkVendor+":"+carNumber; | |||
| return RedisCacheUtils.getCacheInteger(template, key); | |||
| } | |||
| } | |||