| @@ -186,13 +186,48 @@ public class HaiKangWeiShiParkService extends BaseParkService implements ParkAda | |||
| if (null == valueMap) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置。"+coupon.getTitle()); | |||
| } | |||
| String orderNo = paramMap.get("parkOrderId"); | |||
| String planNo = valueMap.get("couponNo"); | |||
| if (StringUtils.isBlank(planNo)) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置[ruleId]。"+coupon.getTitle()); | |||
| } | |||
| //查询临停信息,判断缓存是否已经存在 | |||
| String inRecordSyscode = ""; | |||
| JSONObject stopInfo = haikang.getCarStopInfo(park, getCacheToken(park), haikang.getAuthorization(park,getCacheToken(park)), carNumber); | |||
| if (stopInfo.getString("code").equals("0")){ | |||
| JSONObject dataobject = stopInfo.getJSONObject("data"); | |||
| if (null == dataobject) { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "当前未查询海康威视临停信息["+carNumber+"]"); | |||
| } | |||
| JSONArray listobject = dataobject.getJSONArray("list"); | |||
| if (null == listobject || listobject.size() <= 0 ) { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "当前未查询海康威视临停信息["+carNumber+"]"); | |||
| } | |||
| JSONObject currentStopInfo = listobject.getJSONObject(0); | |||
| inRecordSyscode = currentStopInfo.getString("inRecordSyscode"); | |||
| if (StringUtils.isBlank(inRecordSyscode)) { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "当前未查询海康威视临停信息["+carNumber+"]"); | |||
| } | |||
| Integer used = RedisCacheUtils.getCacheInteger(redisTemplate, "carStop:haikangStopInfoUseCoupon:"+carNumber+":"+inRecordSyscode); | |||
| if (null == used || (null != used && used.intValue() < 1) ) { | |||
| //do nothing | |||
| }else { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "已经使用过优惠券, 不能重复使用."); | |||
| } | |||
| }else { | |||
| logger.error("haikangweishi stopInfo error. paramMap: {} . haikangResult: {}",JSON.toJSONString(paramMap),stopInfo); | |||
| String msg = stopInfo.getString("msg"); | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "当前查询海康威视临停信息失败:["+stopInfo.getString("code")+"]"+msg); | |||
| } | |||
| JSONObject retObj = haikang.useCoupon(park,planNo,carNumber,orderNo, getCacheToken(park),haikang.getAuthorization(park,getCacheToken(park))); | |||
| if (retObj.getString("code").equals("0")){ | |||
| RedisCacheUtils.cache(redisTemplate, "carStop:haikangStopInfoUseCoupon:"+carNumber+":"+inRecordSyscode, 1, 12*3600); | |||
| return new ResultData(); | |||
| }else { | |||
| logger.error("haikangweishi useCoupon error. paramMap: {} . haikangResult: {}",JSON.toJSONString(paramMap),retObj); | |||
| @@ -61,6 +61,7 @@ public class HaiKangWeiShiUtil { | |||
| public static final String GET_FEE = "https://open.hikyun.com/artemis/api/pmsc/v1/pay/quickGetVehicleBill"; | |||
| public static final String COUPON_USE = "https://open.hikyun.com/artemis/api/pmsc/v1/coupon/addition"; | |||
| public static final String SUBSCRIPTION = "https://open.hikyun.com/artemis/api/pmsc/v1/sub/subscription"; | |||
| public static final String CAR_STOP_INFO = "https://open.hikyun.com/artemis/api/pmsc/v1/tempCarInRecords/page"; | |||
| /** | |||
| @@ -212,7 +213,43 @@ public class HaiKangWeiShiUtil { | |||
| } | |||
| /** | |||
| * 3.5.7 查询停车信息 | |||
| * | |||
| * "inRecordSyscode": "h45h45h45ghhn45tg245g45r", | |||
| "parkId": "6534543543554", | |||
| "parkName": "停车库 1", | |||
| "plateNo": "浙 A12345", | |||
| "plateNoPicId": "hj53h4h45t45t45t3t234t2t2t45t45t", | |||
| "vehiclePicId": "u65h45g45yh56y54y34y34y345y3" | |||
| "inTime": "2018-07-26T15:00:00+08:00", | |||
| "parkTime": "3 小时 10 分钟" | |||
| */ | |||
| public JSONObject getCarStopInfo(WxPark wxPark,String token,String Authrozitaion,String carNumber) { | |||
| String vendroParams = wxPark.getVendorParams(); | |||
| JSONObject vp = JSON.parseObject(vendroParams); | |||
| Map<String,Object> params = new HashMap<String,Object>(); | |||
| params.put("pageNo", 1); | |||
| params.put("pageSize", 1); | |||
| params.put("parkId", wxPark.getParkingId());//商户编号 | |||
| params.put("plateNo", carNumber); | |||
| String retCode = ProcBussiness(CAR_STOP_INFO, params,token,Authrozitaion); | |||
| if (StringUtils.isBlank(retCode)) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikang getCarStopInfo error. has no result"); | |||
| } | |||
| JSONObject result = JSON.parseObject(retCode); | |||
| Integer errStatus = result.getInteger("status"); | |||
| if (null != errStatus) { | |||
| throw new MallinkException(errStatus,"haikang getCarStopInfo error.["+result.getString("error")+"]"+result.getString("message")); | |||
| } | |||
| if (!result.getString("code").equals("0") ) { | |||
| String message = result.getString("msg"); | |||
| throw new MallinkException(result.getInteger("code"), "haikang getCarStopInfo error."+message); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * 2、有优惠券方式 | |||
| @@ -226,6 +263,7 @@ public class HaiKangWeiShiUtil { | |||
| public JSONObject useCoupon(WxPark wxPark,String couponNo,String carNumber,String orderNo,String token,String Authrozitaion){ | |||
| String vendroParams = wxPark.getVendorParams(); | |||
| JSONObject vp = JSON.parseObject(vendroParams); | |||
| Map<String,Object> params = new HashMap<String,Object>(); | |||
| Map couponmap = new HashMap(); | |||
| couponmap.put("plateNo", carNumber); | |||