|
|
|
@@ -11,10 +11,15 @@ import com.iformall.enums.EnumCarVendor; |
|
|
|
import com.iformall.enums.EnumCouponSendSendType; |
|
|
|
import com.iformall.enums.EnumETCPCode; |
|
|
|
import com.iformall.enums.EnumPayWay; |
|
|
|
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.utils.DateUtils; |
|
|
|
import com.iformall.utils.car.CYFUtil; |
|
|
|
import com.iformall.utils.car.ETCPUtil; |
|
|
|
import com.iformall.utils.car.TJDUtil; |
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
@@ -65,75 +70,169 @@ public class WxParkCallBackBaseController extends BaseController { |
|
|
|
@Autowired |
|
|
|
ParkFactory parkFactory; |
|
|
|
|
|
|
|
protected Result parkInCallBack(EnumCarVendor vendor,Map paramMap) { |
|
|
|
return null; |
|
|
|
private WxCarCmdLog saveWxCarCmdLog(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam,ParkNotifyParam param) throws MallinkException { |
|
|
|
Date currentDate = new Date(); |
|
|
|
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); |
|
|
|
wxCarCmdLog.setVendorType(vendor.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(cmdType.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(sourceParam)); |
|
|
|
wxCarCmdLog.setCreateDate(currentDate); |
|
|
|
wxCarCmdLog.setUpdateDate(currentDate); |
|
|
|
|
|
|
|
String parkId = param.getParkId(); |
|
|
|
WxPark parkQ = new WxPark(); |
|
|
|
parkQ.setVendorType(vendor.getCode()); |
|
|
|
parkQ.setParkingId(parkId); |
|
|
|
WxPark park = wxParkService.getByObj(parkQ); |
|
|
|
if (park == null) { |
|
|
|
logger.error(parkId+"车场未找到"); |
|
|
|
throw new MallinkException(Result.ERROR,parkId+"车场未找到"); |
|
|
|
} else { |
|
|
|
wxCarCmdLog.updateTenantInfo(park); |
|
|
|
} |
|
|
|
// Object synId = paramMap.get(synIdkey); |
|
|
|
// // 检查是否有重复数据 |
|
|
|
// HashMap<String, Object> map = new HashMap<String, Object>(); |
|
|
|
// map.put("synId", synId); |
|
|
|
// map.put("cmdType", cmdType.getCode()); |
|
|
|
// if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { |
|
|
|
// map.put("tenantId", wxCarCmdLog.getTenantId()); |
|
|
|
// } |
|
|
|
// if (StringUtils.isNotBlank(wxCarCmdLog.getParentTenantId())) { |
|
|
|
// map.put("parentTenantId", wxCarCmdLog.getParentTenantId()); |
|
|
|
// } |
|
|
|
// WxCarCmdLog carCmdLog = wxCarCmdLogService.getBySynId(map); |
|
|
|
// if(carCmdLog != null) { |
|
|
|
// logger.error("par WxCarCmdLog synId已入库: " + paramMap.toString()); |
|
|
|
// } |
|
|
|
|
|
|
|
try { |
|
|
|
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("parkInCallBack: 入库错误 " + e.getMessage() ,e); |
|
|
|
throw new MallinkException(Result.ERROR,parkId+", WxCarCmdLog入库错误"); |
|
|
|
} |
|
|
|
return wxCarCmdLog; |
|
|
|
} |
|
|
|
|
|
|
|
public Result etcpParkInCallback(@RequestBody Map paramMap) { |
|
|
|
logger.info("["+getIpAddr()+"] etcpParkInCallback: " + paramMap.toString()); |
|
|
|
|
|
|
|
doEtcpParkIn(paramMap); |
|
|
|
private WxCarPayRecord saveWxCarPayRecord(Object sourceParam,ParkNotifyParam param,WxCarCmdLog wxCarCmdLog,String phone) throws MallinkException { |
|
|
|
try { |
|
|
|
String parkName = param.getParkName(); |
|
|
|
// 保存WxCarPayRecord |
|
|
|
WxCarPayRecord record = new WxCarPayRecord(); |
|
|
|
record.updateTenantInfo(wxCarCmdLog); |
|
|
|
record.setVendorType(wxCarCmdLog.getVendorType()); |
|
|
|
record.setSynId(param.getSynId()); |
|
|
|
record.setParkId(param.getParkId()); |
|
|
|
record.setParkName(parkName); |
|
|
|
//record.setUserType(userType); |
|
|
|
record.setPlateNumber(param.getCarNumber()); |
|
|
|
record.setEntranceTime(param.getEntranceTime()); |
|
|
|
record.setExitTime(param.getOutTime()); |
|
|
|
if (null != record.getEntranceTime() && null != record.getExitTime()) { |
|
|
|
Long stayedTime = (record.getExitTime().getTime() - record.getEntranceTime().getTime())/ 1000; |
|
|
|
record.setStayedTime(stayedTime); |
|
|
|
} |
|
|
|
record.setFee(param.getFee()); |
|
|
|
//record.setFixParkingId(fixParkingId); |
|
|
|
//record.setRemainingDays(remainingDays); |
|
|
|
record.setPhone(phone); |
|
|
|
record.updateTenantInfo(wxCarCmdLog); |
|
|
|
|
|
|
|
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); |
|
|
|
WxCarPayRecord query = new WxCarPayRecord(); |
|
|
|
//query.updateTenantInfo(park); |
|
|
|
//query.setParkId(etcpParkId.toString()); |
|
|
|
query.setSynId(param.getSynId()); |
|
|
|
PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); |
|
|
|
if(page != null && CollectionUtils.isNotEmpty(page.getList())){ |
|
|
|
record.setId(page.getList().get(0).getId()); |
|
|
|
} |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
return record; |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("WxCarPayRecord: 入库错误",e); |
|
|
|
throw new MallinkException(Result.ERROR,param.getParkId()+"parkInCallBack: WxCarPayRecord入库错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* ETCP 车辆出场通知 |
|
|
|
* { |
|
|
|
* "synId": "fd92f645-880e-4c2a-9d7d-7081a2488181", |
|
|
|
* "plateNumber": "渝 ATX061", |
|
|
|
* "parkName": "ETCP 智慧停车场", |
|
|
|
* "parkId": "1", |
|
|
|
* "entranceTime": "2017-08-17 18:44:19", |
|
|
|
* "userType": "76", |
|
|
|
* "pushTime": "2017-08-20 11:57:51", |
|
|
|
* "exitTime": "2017-08-19 12:07:19", |
|
|
|
* "stayedTime": 148980, |
|
|
|
* "receivableFee": 0, |
|
|
|
* "paidServiceFee": 0, |
|
|
|
* "fixParkingId": "U7", |
|
|
|
* "remainingDays": "12" |
|
|
|
* } |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/etcpParkOutCallback") |
|
|
|
public Result etcpParkOutCallback(@RequestBody Map<String, String> paramMap) { |
|
|
|
logger.info("["+getIpAddr()+"etcpParkOutCallback: " + paramMap.toString()); |
|
|
|
|
|
|
|
doEtcpParkOut(paramMap); |
|
|
|
|
|
|
|
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
protected Result parkInCallBack(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { |
|
|
|
|
|
|
|
ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parseInNoticyParam(sourceParam); |
|
|
|
//添加wxCarCmdLog |
|
|
|
WxCarCmdLog wxCarCmdLog = null; |
|
|
|
try { |
|
|
|
wxCarCmdLog = saveWxCarCmdLog(vendor, cmdType, sourceParam, param); |
|
|
|
}catch(MallinkException e) { |
|
|
|
return new Result(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String carNumber = param.getCarNumber(); |
|
|
|
String phoneStrs = ""; |
|
|
|
// 停车发券 |
|
|
|
if (!StringUtils.isBlank(carNumber)) { |
|
|
|
// 根据车牌查找用户 |
|
|
|
WxCUserCar userCarQ = new WxCUserCar(); |
|
|
|
if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { |
|
|
|
userCarQ.setTenantId(wxCarCmdLog.getTenantId()); |
|
|
|
} |
|
|
|
userCarQ.setCarNumber(carNumber); |
|
|
|
userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
// TODO 可能多用户关联同一张车牌 |
|
|
|
List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); |
|
|
|
boolean bFirst = true; |
|
|
|
for (WxCUserCar userCar : userCarList) { |
|
|
|
userCar.setParentTenantId(wxCarCmdLog.getParentTenantId()); |
|
|
|
wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar,EnumPayWay.PAY_WAY_NOT_UNPAY_CAR_STOP); |
|
|
|
WxCUserBasicInfo cUser = wxCUserBasicInfoService.getById(userCar.getCUserId()); |
|
|
|
if(cUser != null){ |
|
|
|
if(bFirst) { |
|
|
|
phoneStrs = cUser.getPhone(); |
|
|
|
bFirst = false; |
|
|
|
} else { |
|
|
|
phoneStrs += "," + cUser.getPhone(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
saveWxCarPayRecord(sourceParam, param, wxCarCmdLog, phoneStrs); |
|
|
|
}catch(MallinkException e) { |
|
|
|
return new Result(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* ETCP 车辆解绑通知 |
|
|
|
* { |
|
|
|
* "plateNumber": "渝 ATX061", |
|
|
|
* "time": "2017-08-20 11:57:51" |
|
|
|
* } |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/etcpUnbindCarCallBack") |
|
|
|
public Result etcpUnbindCarCallBack(@RequestBody Map<String, String> paramMap) { |
|
|
|
logger.info("["+getIpAddr()+"etcpUnbindCarCallBack: " + paramMap.toString()); |
|
|
|
String carNumber = paramMap.get("plateNumber"); |
|
|
|
|
|
|
|
// TODO how to get the parkId |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); |
|
|
|
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_UNBIND.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); |
|
|
|
wxCarCmdLog.setCreateDate(currentDate); |
|
|
|
wxCarCmdLog.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("etcpUnbindCarCallBack: 入库错误 " + paramMap.toString()); |
|
|
|
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString()); |
|
|
|
protected Result parkOutCallBack(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { |
|
|
|
ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parseOutNoticyParam(sourceParam); |
|
|
|
WxCarCmdLog wxCarCmdLog = null; |
|
|
|
try { |
|
|
|
wxCarCmdLog = saveWxCarCmdLog(vendor, cmdType, sourceParam, param); |
|
|
|
}catch(MallinkException e) { |
|
|
|
return new Result(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
saveWxCarPayRecord(sourceParam,param, wxCarCmdLog, null); |
|
|
|
}catch(MallinkException e) { |
|
|
|
return new Result(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
protected Result unbindCarCallBack(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { |
|
|
|
ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parseUnbindNoticyParam(sourceParam); |
|
|
|
WxCarCmdLog wxCarCmdLog = null; |
|
|
|
try { |
|
|
|
wxCarCmdLog = saveWxCarCmdLog(vendor, cmdType, sourceParam, param); |
|
|
|
}catch(MallinkException e) { |
|
|
|
return new Result(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String carNumber = param.getCarNumber(); |
|
|
|
|
|
|
|
WxCUserCar userCarQ = new WxCUserCar(); |
|
|
|
userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
userCarQ.setVendorType(vendor.getCode()); |
|
|
|
userCarQ.setCarNumber(carNumber); |
|
|
|
// 数据库里删除,保持同步 |
|
|
|
try { |
|
|
|
@@ -145,114 +244,71 @@ public class WxParkCallBackBaseController extends BaseController { |
|
|
|
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* ETCP 主动支付结果通知 |
|
|
|
* { |
|
|
|
* "signment":"B8534D2E8FA2074C216CCEF087AA9954", |
|
|
|
* "payWayDesc":"微信", |
|
|
|
* "plateNumber": "渝 ATX061", |
|
|
|
* "orderId": "fd92f645-880e-4c2a-9d7d-7081a2488181", |
|
|
|
* "fee": 7.65, |
|
|
|
* "paidServiceFee": 0.07, |
|
|
|
* "coupon": 0, |
|
|
|
* "time": "2017-08-20 11:57:51" |
|
|
|
* "discountAmount":0, |
|
|
|
* "onceServiceFeePaid":0.0, |
|
|
|
* "couponCode":"" |
|
|
|
* } |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/etcpPaidCallback") |
|
|
|
public Result etcpPaidCallback(@RequestBody Map<String, String> paramMap) { |
|
|
|
logger.info("["+getIpAddr()+"etcpPaidCallback: " + paramMap.toString()); |
|
|
|
String carNumber = paramMap.get("plateNumber"); |
|
|
|
|
|
|
|
// 根据orderId获取入场信息,确定租户ID |
|
|
|
String orderId = paramMap.get(ETCPUtil.ETCP_ORDER_ID); |
|
|
|
String etcpTime = paramMap.get(ETCPUtil.ETCP_TIME); |
|
|
|
protected Result paidCallback(EnumCarVendor vendor,EnumCarCmd cmdType,Object sourceParam) { |
|
|
|
ParkNotifyParam param = parkFactory.getParkCallbackService(vendor.getCode()).parsePaidNoticyParam(sourceParam); |
|
|
|
|
|
|
|
WxCarCmdLog carCmdLogQ = new WxCarCmdLog(); |
|
|
|
carCmdLogQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
carCmdLogQ.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); |
|
|
|
carCmdLogQ.setSynId(orderId); |
|
|
|
carCmdLogQ.setPlateNumber(carNumber); |
|
|
|
WxCarCmdLog tenantInfo = wxCarCmdLogService.getTenantInfoBySynId(carCmdLogQ); |
|
|
|
String tenantId = null; |
|
|
|
/// if not found syn_id, maybe use user_car to get tenantId |
|
|
|
if(tenantInfo == null) { |
|
|
|
WxCUserCar queryOne = new WxCUserCar(); |
|
|
|
queryOne.setCarNumber(carNumber); |
|
|
|
WxCUserCar userCar = wxCUserCarService.getOnlyOne(queryOne); |
|
|
|
if(userCar != null) { |
|
|
|
tenantId = userCar.getTenantId(); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(tenantId)) { |
|
|
|
carCmdLogQ.setTenantId(tenantId); |
|
|
|
} |
|
|
|
String parkId = param.getParkId(); |
|
|
|
WxPark parkQ = new WxPark(); |
|
|
|
parkQ.setVendorType(vendor.getCode()); |
|
|
|
parkQ.setParkingId(parkId); |
|
|
|
WxPark park = wxParkService.getByObj(parkQ); |
|
|
|
if (park == null) { |
|
|
|
logger.error(parkId+"车场未找到"); |
|
|
|
throw new MallinkException(Result.ERROR,parkId+"车场未找到"); |
|
|
|
} else { |
|
|
|
carCmdLogQ.updateTenantInfo(tenantInfo); |
|
|
|
carCmdLogQ.updateTenantInfo(park); |
|
|
|
} |
|
|
|
|
|
|
|
carCmdLogQ.setVendorType(vendor.getCode()); |
|
|
|
carCmdLogQ.setCmdType(cmdType.getCode()); |
|
|
|
carCmdLogQ.setSynId(param.getParkOrderId()); |
|
|
|
carCmdLogQ.setPlateNumber(param.getCarNumber()); |
|
|
|
// 检查是否有重复数据 |
|
|
|
|
|
|
|
String paidServiceFee = paramMap.get(ETCPUtil.ETCP_PAID_SERVICE_FEE); |
|
|
|
String fee = paramMap.get(ETCPUtil.ETCP_FEE); |
|
|
|
Date feeTime = null; |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(etcpTime)) { |
|
|
|
try { |
|
|
|
feeTime = dateFormat.parse(etcpTime); |
|
|
|
} catch (ParseException e) { |
|
|
|
logger.error("解析fee time出错" + etcpTime); |
|
|
|
} |
|
|
|
} |
|
|
|
carCmdLogQ.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PAY_MANUAL.getCode()); |
|
|
|
carCmdLogQ.setPlateNumber(carNumber); |
|
|
|
carCmdLogQ.setOrderId(orderId); |
|
|
|
String paidServiceFee = param.getPaidServiceFee(); |
|
|
|
String fee = param.getFee(); |
|
|
|
carCmdLogQ.setCmdType(cmdType.getCode()); |
|
|
|
carCmdLogQ.setPlateNumber(param.getCarNumber()); |
|
|
|
carCmdLogQ.setOrderId(param.getParkOrderId()); |
|
|
|
carCmdLogQ.setFee(fee); |
|
|
|
carCmdLogQ.setFeeTime(etcpTime); |
|
|
|
carCmdLogQ.setFeeTime(dateFormat.format(param.getPayTime())); |
|
|
|
WxCarCmdLog carCmdLog = wxCarCmdLogService.getByOrderId(carCmdLogQ); |
|
|
|
if(carCmdLog != null) { |
|
|
|
logger.error("ETCP order paid 已入库: " + orderId); |
|
|
|
logger.error("ETCP order paid 已入库: " + param.getParkOrderId()); |
|
|
|
} |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); |
|
|
|
if (tenantInfo != null) { |
|
|
|
wxCarCmdLog.updateTenantInfo(tenantInfo); |
|
|
|
} else { |
|
|
|
if (StringUtils.isNotBlank(tenantId)) { |
|
|
|
wxCarCmdLog.setTenantId(tenantId); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCarCmdLog.updateTenantInfo(park); |
|
|
|
if(carCmdLog != null) { |
|
|
|
// 如果有15分钟的已支付的数据,自动覆盖 |
|
|
|
wxCarCmdLog.setId(carCmdLog.getId()); |
|
|
|
} |
|
|
|
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PAY_MANUAL.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); |
|
|
|
wxCarCmdLog.setVendorType(vendor.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(cmdType.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(sourceParam)); |
|
|
|
wxCarCmdLog.setCreateDate(currentDate); |
|
|
|
wxCarCmdLog.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("etcpPaidCallback: 入库错误 " + paramMap.toString()); |
|
|
|
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString()); |
|
|
|
logger.error("etcpPaidCallback: 入库错误 ",e); |
|
|
|
return new Result(ErrorCode.DB_FAIL.getCode(), "wxCarCmdLog入库错误"); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
// 保存WxCarPayRecord |
|
|
|
WxCarPayRecord record = new WxCarPayRecord(); |
|
|
|
record.setSynId(orderId); |
|
|
|
record.setSynId(param.getParkOrderId()); |
|
|
|
record.setFee(fee); |
|
|
|
if(feeTime != null) { |
|
|
|
record.setFeeTime(feeTime); |
|
|
|
} |
|
|
|
record.setFeeTime(param.getPayTime()); |
|
|
|
record.setPaidServiceFee(paidServiceFee); |
|
|
|
record.setVendorType(wxCarCmdLog.getVendorType()); |
|
|
|
record.setPlateNumber(carNumber); |
|
|
|
record.setTenantId(tenantId); |
|
|
|
record.setPlateNumber(param.getCarNumber()); |
|
|
|
record.updateTenantInfo(park); |
|
|
|
|
|
|
|
WxCarPayRecord query = new WxCarPayRecord(); |
|
|
|
query.setSynId(orderId); |
|
|
|
query.setSynId(param.getParkOrderId()); |
|
|
|
PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,2); |
|
|
|
if(page != null && page.getList().size() > 0){ |
|
|
|
|
|
|
|
@@ -266,7 +322,7 @@ public class WxParkCallBackBaseController extends BaseController { |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
} else { |
|
|
|
// 缴费时间在15分钟以内,更新之前的数据, ETCP会把之前的缴费自动退款 |
|
|
|
if(DateUtils.isInDate15Mins(feeTime, r.getFeeTime())) { |
|
|
|
if(DateUtils.isInDate15Mins(param.getPayTime(), r.getFeeTime())) { |
|
|
|
record.setId(r.getId()); |
|
|
|
} |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
@@ -276,7 +332,8 @@ public class WxParkCallBackBaseController extends BaseController { |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("WxCarPayRecord: 缴费更新错误 " +e.getMessage()+", "+ paramMap.toString()); |
|
|
|
logger.error("WxCarPayRecord: 缴费更新错误 " +e.getMessage(),e); |
|
|
|
return new Result(ErrorCode.DB_FAIL.getCode(), "WxCarPayRecord入库错误"); |
|
|
|
//return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -284,198 +341,5 @@ public class WxParkCallBackBaseController extends BaseController { |
|
|
|
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
// @Async |
|
|
|
private boolean doEtcpParkIn(@RequestBody Map<String, String> paramMap) { |
|
|
|
Date currentDate = new Date(); |
|
|
|
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); |
|
|
|
|
|
|
|
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); |
|
|
|
wxCarCmdLog.setCreateDate(currentDate); |
|
|
|
wxCarCmdLog.setUpdateDate(currentDate); |
|
|
|
|
|
|
|
String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); |
|
|
|
WxPark parkQ = new WxPark(); |
|
|
|
parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
parkQ.setParkingId(etcpParkId); |
|
|
|
WxPark park = wxParkService.getByObj(parkQ); |
|
|
|
if (park == null) { |
|
|
|
logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId); |
|
|
|
//return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); |
|
|
|
} else { |
|
|
|
wxCarCmdLog.updateTenantInfo(park); |
|
|
|
} |
|
|
|
|
|
|
|
String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); |
|
|
|
String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); |
|
|
|
String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); |
|
|
|
String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); |
|
|
|
String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); |
|
|
|
String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); |
|
|
|
String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); |
|
|
|
|
|
|
|
// 检查是否有重复数据 |
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>(); |
|
|
|
map.put("synId", synId); |
|
|
|
map.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); |
|
|
|
if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { |
|
|
|
map.put("tenantId", wxCarCmdLog.getTenantId()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(wxCarCmdLog.getParentTenantId())) { |
|
|
|
map.put("parentTenantId", wxCarCmdLog.getParentTenantId()); |
|
|
|
} |
|
|
|
WxCarCmdLog carCmdLog = wxCarCmdLogService.getBySynId(map); |
|
|
|
if(carCmdLog != null) { |
|
|
|
logger.error("ETCP synId已入库: " + paramMap.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("etcpParkInCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
String phoneStrs = ""; |
|
|
|
|
|
|
|
// 停车发券 |
|
|
|
if (!StringUtils.isBlank(carNumber)) { |
|
|
|
// 根据车牌查找用户 |
|
|
|
WxCUserCar userCarQ = new WxCUserCar(); |
|
|
|
if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { |
|
|
|
userCarQ.setTenantId(wxCarCmdLog.getTenantId()); |
|
|
|
} |
|
|
|
userCarQ.setCarNumber(carNumber); |
|
|
|
userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
// TODO 可能多用户关联同一张车牌 |
|
|
|
List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ); |
|
|
|
boolean bFirst = true; |
|
|
|
for (WxCUserCar userCar : userCarList) { |
|
|
|
userCar.setParentTenantId(park.getParentTenantId()); |
|
|
|
wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar,EnumPayWay.PAY_WAY_NOT_UNPAY_CAR_STOP); |
|
|
|
WxCUserBasicInfo cUser = wxCUserBasicInfoService.getById(userCar.getCUserId()); |
|
|
|
if(cUser != null){ |
|
|
|
if(bFirst) { |
|
|
|
phoneStrs = cUser.getPhone(); |
|
|
|
bFirst = false; |
|
|
|
} else { |
|
|
|
phoneStrs += "," + cUser.getPhone(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
// 保存WxCarPayRecord |
|
|
|
WxCarPayRecord record = new WxCarPayRecord(); |
|
|
|
record.setVendorType(wxCarCmdLog.getVendorType()); |
|
|
|
record.setSynId(synId); |
|
|
|
record.setParkId(etcpParkId); |
|
|
|
record.setParkName(parkName); |
|
|
|
record.setUserType(userType); |
|
|
|
record.setPlateNumber(carNumber); |
|
|
|
if(StringUtils.isNotBlank(entranceTime)) { |
|
|
|
record.setEntranceTime(dateFormat.parse(entranceTime)); |
|
|
|
} |
|
|
|
record.setFixParkingId(fixParkingId); |
|
|
|
record.setRemainingDays(remainingDays); |
|
|
|
record.setPhone(phoneStrs); |
|
|
|
record.updateTenantInfo(wxCarCmdLog); |
|
|
|
|
|
|
|
WxCarPayRecord query = new WxCarPayRecord(); |
|
|
|
query.setSynId(synId); |
|
|
|
PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); |
|
|
|
if(page != null && CollectionUtils.isNotEmpty(page.getList())){ |
|
|
|
record.setId(page.getList().get(0).getId()); |
|
|
|
} |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
logger.error("WxCarPayRecord: 入库错误 ",e); |
|
|
|
logger.error("WxCarPayRecord: 入库错误 "+e.getMessage()+"," + paramMap.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean doEtcpParkOut(@RequestBody Map<String, String> paramMap) { |
|
|
|
Date currentDate = new Date(); |
|
|
|
|
|
|
|
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); |
|
|
|
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); |
|
|
|
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); |
|
|
|
wxCarCmdLog.setCreateDate(currentDate); |
|
|
|
wxCarCmdLog.setUpdateDate(currentDate); |
|
|
|
|
|
|
|
String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); |
|
|
|
String tenantId = null; |
|
|
|
WxPark parkQ = new WxPark(); |
|
|
|
parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); |
|
|
|
parkQ.setParkingId(etcpParkId); |
|
|
|
WxPark park = wxParkService.getByObj(parkQ); |
|
|
|
if (park == null) { |
|
|
|
logger.error("etcpParkOutCallback: ETCP车场未找到 " + etcpParkId); |
|
|
|
// return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); |
|
|
|
} else { |
|
|
|
tenantId = park.getTenantId(); |
|
|
|
wxCarCmdLog.updateTenantInfo(park); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("etcpParkOutCallback: 入库错误 " + e.getMessage() + "\n" + paramMap.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); |
|
|
|
String exitTime = paramMap.get(ETCPUtil.ETCP_EXIT_TIME); |
|
|
|
String stayedTime = paramMap.get(ETCPUtil.ETCP_STAYED_TIME); |
|
|
|
String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); |
|
|
|
String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); |
|
|
|
String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); |
|
|
|
String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); |
|
|
|
String fixParkingId = paramMap.get(ETCPUtil.ETCP_FIX_PARKING_ID); |
|
|
|
String remainingDays = paramMap.get(ETCPUtil.ETCP_REMAINING_DAYS); |
|
|
|
|
|
|
|
try { |
|
|
|
// 保存WxCarPayRecord |
|
|
|
WxCarPayRecord record = new WxCarPayRecord(); |
|
|
|
record.setSynId(synId); |
|
|
|
if(StringUtils.isNotBlank(exitTime)) { |
|
|
|
record.setExitTime(dateFormat.parse(exitTime)); |
|
|
|
} |
|
|
|
if(StringUtils.isNotBlank(stayedTime)) { |
|
|
|
record.setStayedTime(Long.parseLong(stayedTime)); |
|
|
|
} |
|
|
|
record.setVendorType(wxCarCmdLog.getVendorType()); |
|
|
|
record.setSynId(synId); |
|
|
|
record.setParkId(etcpParkId); |
|
|
|
record.setParkName(parkName); |
|
|
|
record.setUserType(userType); |
|
|
|
record.setPlateNumber(carNumber); |
|
|
|
if(StringUtils.isNotBlank(entranceTime)) { |
|
|
|
record.setEntranceTime(dateFormat.parse(entranceTime)); |
|
|
|
} |
|
|
|
record.setFixParkingId(fixParkingId); |
|
|
|
record.setRemainingDays(remainingDays); |
|
|
|
//record.setPhone(phoneStrs); |
|
|
|
record.setTenantId(tenantId); |
|
|
|
|
|
|
|
WxCarPayRecord query = new WxCarPayRecord(); |
|
|
|
query.setSynId(synId); |
|
|
|
PageInfo<WxCarPayRecord> page = wxCarPayRecordService.findCarPayListByPage(query,1,1); |
|
|
|
if(page != null && CollectionUtils.isNotEmpty(page.getList())){ |
|
|
|
record.setId(page.getList().get(0).getId()); |
|
|
|
} |
|
|
|
wxCarPayRecordService.saveOrUpdate(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("WxCarPayRecord: 出场更新错误 " +e.getMessage()+", " +paramMap.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |