diff --git a/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3ParkService.java b/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3ParkService.java index 9caeafe7d..440e37e54 100644 --- a/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3ParkService.java +++ b/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3ParkService.java @@ -133,7 +133,7 @@ public class HaiKangWeiShiV3ParkService extends BaseParkService implements ParkA throw new MallinkException(21000,"车辆未入场"); } - JSONObject attribute = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); + JSONObject attribute = haikangV3.getCarStopFee(park, carNumber, getConfig(park)); String appId = ""; String parkOrderId = attribute.getString("billSyscode"); @@ -186,8 +186,17 @@ public class HaiKangWeiShiV3ParkService extends BaseParkService implements ParkA return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(),"当前用户未查询到手机号!"+userCar.getcUserId()); } + Map valueMap = WxParkCouponConfig.parseValue(userCar.getVendorParams()); + if (null == valueMap) { + return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置。"+coupon.getTitle()); + } + String couponCode = valueMap.get("couponCode"); + if (StringUtils.isBlank(couponCode)) { + return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置[couponCode]。"+coupon.getTitle()); + } + //查询临停信息,判断缓存是否已经存在 - JSONObject stopInfo = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); + JSONObject stopInfo = haikangV3.getCarStopFee(park, carNumber, getConfig(park)); String inRecordSyscode = stopInfo.getString("inRecordSyscode"); Integer used = RedisCacheUtils.getCacheInteger(redisTemplate, "carStop:haikangv3StopInfoUseCoupon:"+carNumber+":"+inRecordSyscode); if (null == used || (null != used && used.intValue() < 1) ) { @@ -196,10 +205,9 @@ public class HaiKangWeiShiV3ParkService extends BaseParkService implements ParkA return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(), "已经使用过优惠券, 不能重复使用."); } - //String couponStart = dateToISO8601Time(coupon.getValidStartDate()); - //String couponEnd = dateToISO8601Time(coupon.getValidEndDate()); - //JSONObject retObj = haikangV3.useCoupon(park,getConfig(park),carNumber,couponCode,couponStart,couponEnd,coupon); - JSONObject retObj = haikangV3.getCarStopFee(park, carNumber, getConfig(park),coupon); + String couponStart = dateToISO8601Time(coupon.getValidStartDate()); + String couponEnd = dateToISO8601Time(coupon.getValidEndDate()); + JSONObject retObj = haikangV3.useCoupon(park,getConfig(park),carNumber,couponCode,couponStart,couponEnd,coupon); RedisCacheUtils.cache(redisTemplate, "carStop:haikangv3StopInfoUseCoupon:"+carNumber+":"+inRecordSyscode, 1, 24*3600); return new ResultData(); @@ -207,7 +215,7 @@ public class HaiKangWeiShiV3ParkService extends BaseParkService implements ParkA @Override public ParkCreatePayOrder createPayOrder(Map paramMap, WxPark park, String carNumber) throws Exception { - JSONObject result = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); + JSONObject result = haikangV3.getCarStopFee(park, carNumber, getConfig(park)); String parkOrderId = result.getString("billSyscode"); Double needfee = 0.00; String neddfeestr = result.getString("supposeCost"); diff --git a/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3Util.java b/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3Util.java index a0da34a86..3abc43f9b 100644 --- a/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3Util.java +++ b/mallinkService/src/main/java/com/iformall/service/park/impl/haikangweishiv3/HaiKangWeiShiV3Util.java @@ -61,7 +61,7 @@ public class HaiKangWeiShiV3Util { public static final String QUERY_PRICE = "/api/pms/v1/pay/preBill"; - //public static final String COUPON_USE = "/api/pms/v1/coupon/addition"; + public static final String COUPON_USE = "/api/pms/v1/coupon/addition"; public static final String NOTIFY_PAID = "/api/pms/v2/pay/receipt"; @@ -123,21 +123,12 @@ public class HaiKangWeiShiV3Util { /** * 查询停车费 **/ - public JSONObject getCarStopFee(WxPark wxPark,String carNumber,ArtemisConfig config,WxCoupon coupon){ + public JSONObject getCarStopFee(WxPark wxPark,String carNumber,ArtemisConfig config){ String vendroParams = wxPark.getVendorParams(); JSONObject vp = JSON.parseObject(vendroParams); JSONObject ob = new JSONObject(); ob.put("plateNo", carNumber); ob.put("parkSyscode", wxPark.getParkingId()); - if (null != coupon) { - if (coupon.getUnit().intValue() == EnumCouponUnit.MONEY.getCode().intValue()) { - ob.put("deductRuleType", 0); - ob.put("deductContent", new BigDecimal(coupon.getPrice()).intValue()); - }else { - ob.put("deductRuleType", 4); - ob.put("deductContent", new BigDecimal(coupon.getPrice()).divide(new BigDecimal(100)).multiply(new BigDecimal(60)).intValue()); - } - } try { String retCode = callPostApi(config,QUERY_PRICE, JSON.toJSONString(ob)); if (StringUtils.isBlank(retCode)) { @@ -160,49 +151,49 @@ public class HaiKangWeiShiV3Util { /** * 使用优惠券 **/ -// public JSONObject useCoupon(WxPark wxPark,ArtemisConfig config,String carNumber,String couponCode,String start,String end,WxCoupon coupon){ -// String vendroParams = wxPark.getVendorParams(); -// JSONObject vp = JSON.parseObject(vendroParams); -// -// String merchantSysCode = vp.getString("merchantSyscode"); -// -// JSONArray array = new JSONArray(); -// JSONObject ob = new JSONObject(); -// //ob.put("ruleSyscode", ruleSyscode); -// ob.put("merchantSyscode", merchantSysCode); -// ob.put("couponCode", couponCode); -// ob.put("plateNo", carNumber); -// ob.put("parkSyscode", wxPark.getParkingId()); -// if (coupon.getUnit().intValue() == EnumCouponUnit.MONEY.getCode().intValue()) { -// ob.put("deductRuleType", 0); -// ob.put("deductContent", new BigDecimal(coupon.getPrice()).intValue()); -// }else { -// ob.put("deductRuleType", 4); -// ob.put("deductContent", new BigDecimal(coupon.getPrice()).divide(new BigDecimal(100)).multiply(new BigDecimal(60)).intValue()); -// } -// ob.put("startTime", start); -// ob.put("endTime", end); -// array.add(ob); -// -// Map param = new HashMap(); -// param.put("coupons", array); -// try { -// String retCode = callPostApi(config,COUPON_USE, JSON.toJSONString(param)); -// if (StringUtils.isBlank(retCode)) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error. has no result"); -// } -// JSONObject result = JSON.parseObject(retCode); -// String code = result.getString("code"); -// if (!code.equals("0") ) { -// String message = result.getString("msg"); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error.["+code+"]"+message); -// } -// return result; -// } catch (Exception e) { -// log.error("haikangweishiv3 useCoupon error.",e); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error."+e.getMessage()); -// } -// } + public JSONObject useCoupon(WxPark wxPark,ArtemisConfig config,String carNumber,String couponCode,String start,String end,WxCoupon coupon){ + String vendroParams = wxPark.getVendorParams(); + JSONObject vp = JSON.parseObject(vendroParams); + + String merchantSysCode = vp.getString("merchantSyscode"); + + JSONArray array = new JSONArray(); + JSONObject ob = new JSONObject(); + //ob.put("ruleSyscode", ruleSyscode); + ob.put("merchantSyscode", merchantSysCode); + ob.put("couponCode", couponCode); + ob.put("plateNo", carNumber); + ob.put("parkSyscode", wxPark.getParkingId()); + if (coupon.getUnit().intValue() == EnumCouponUnit.MONEY.getCode().intValue()) { + ob.put("deductRuleType", 0); + ob.put("deductContent", new BigDecimal(coupon.getPrice()).intValue()); + }else { + ob.put("deductRuleType", 4); + ob.put("deductContent", new BigDecimal(coupon.getPrice()).divide(new BigDecimal(100)).multiply(new BigDecimal(60)).intValue()); + } + ob.put("startTime", start); + ob.put("endTime", end); + array.add(ob); + + Map param = new HashMap(); + param.put("coupons", array); + try { + String retCode = callPostApi(config,COUPON_USE, JSON.toJSONString(param)); + if (StringUtils.isBlank(retCode)) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error. has no result"); + } + JSONObject result = JSON.parseObject(retCode); + String code = result.getString("code"); + if (!code.equals("0") ) { + String message = result.getString("msg"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error.["+code+"]"+message); + } + return result; + } catch (Exception e) { + log.error("haikangweishiv3 useCoupon error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 useCoupon error."+e.getMessage()); + } + } //查询车场列表 public String queryParkList(ArtemisConfig config) {