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 d6bf5eda6..c25ddf56c 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)); + JSONObject attribute = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); String appId = ""; String parkOrderId = attribute.getString("billSyscode"); @@ -190,16 +190,12 @@ public class HaiKangWeiShiV3ParkService extends BaseParkService implements ParkA if (null == valueMap) { return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置。"+coupon.getTitle()); } - //String ruleSyscode = valueMap.get("ruleSyscode"); - //if (StringUtils.isBlank(ruleSyscode)) { - // return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置[ruleSyscode]。"+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)); + JSONObject stopInfo = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); String inRecordSyscode = stopInfo.getString("inRecordSyscode"); Integer used = RedisCacheUtils.getCacheInteger(redisTemplate, "carStop:haikangv3StopInfoUseCoupon:"+carNumber+":"+inRecordSyscode); if (null == used || (null != used && used.intValue() < 1) ) { @@ -208,9 +204,10 @@ 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); + //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); RedisCacheUtils.cache(redisTemplate, "carStop:haikangv3StopInfoUseCoupon:"+carNumber+":"+inRecordSyscode, 1, 24*3600); return new ResultData(); @@ -218,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)); + JSONObject result = haikangV3.getCarStopFee(park, carNumber, getConfig(park),null); 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 71161eb30..a0da34a86 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,14 +123,23 @@ public class HaiKangWeiShiV3Util { /** * 查询停车费 **/ - public JSONObject getCarStopFee(WxPark wxPark,String carNumber,ArtemisConfig config){ + public JSONObject getCarStopFee(WxPark wxPark,String carNumber,ArtemisConfig config,WxCoupon coupon){ String vendroParams = wxPark.getVendorParams(); JSONObject vp = JSON.parseObject(vendroParams); - Map params = new HashMap(); - params.put("plateNo", carNumber); - params.put("parkSyscode", wxPark.getParkingId()); + 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 = callPostApiWithMap(config,QUERY_PRICE, params); + String retCode = callPostApi(config,QUERY_PRICE, JSON.toJSONString(ob)); if (StringUtils.isBlank(retCode)) { throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "haikangv3 getCarStopInfo error. has no result"); } @@ -151,49 +160,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) {