| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| @@ -9,6 +10,7 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCouponCarVo; | |||
| import com.iformall.enums.EnumCarVendor; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.enums.EnumETCPCode; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.ETCPUtil; | |||
| import com.iformall.utils.TJDCarUtil; | |||
| @@ -334,5 +336,58 @@ public class WxCarController extends BaseController { | |||
| } | |||
| @ApiOperation(value = "停车场状态") | |||
| @GetMapping("/getParkStatus") | |||
| public ResultData getParkStatus() { | |||
| MallUserInfo user = getUser(); | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(user); | |||
| if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | |||
| String params = park.getVendorParams(); | |||
| JSONObject objParams = JSON.parseObject(params); | |||
| String url = objParams.getString("url"); | |||
| String merchantNo = objParams.getString("merchantNo"); | |||
| String merchantKey = objParams.getString("merchantKey"); | |||
| String version = objParams.getString("version"); | |||
| if (park.getParkingId() == null) { | |||
| String lat = objParams.getString("lat"); | |||
| String lon = objParams.getString("lon"); | |||
| String radius = objParams.getString("radius"); | |||
| String ret = etcp.parkingInfo(url, merchantNo, merchantKey, version, lat, lon, radius); | |||
| logger.info(ret); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| JSONObject retData = retObj.getJSONObject("data"); | |||
| if (retData != null) { | |||
| JSONArray retDataList = retData.getJSONArray("list"); | |||
| if (retDataList != null) { | |||
| JSONObject parkData = retDataList.getJSONObject(0); | |||
| if (parkData != null) { | |||
| String parkId = parkData.getString("id"); | |||
| objParams.put("parkId", parkId); | |||
| params = JSON.toJSONString(objParams); | |||
| park.setVendorParams(params); | |||
| park.setParkingId(parkId); | |||
| wxParkService.saveOrUpdate(park); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (park.getParkingId() != null) { | |||
| String ret = etcp.parkingStatus(url, merchantNo, merchantKey, version, park.getParkingId()); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { | |||
| if (retObj.get("data") != null) { | |||
| return new ResultData(retObj.getJSONObject("data")); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "车场不支持"); | |||
| } | |||
| } | |||