深圳停车平台

This commit is contained in:
Guoqs
2025-02-14 14:09:48 +08:00
parent fbbab3019d
commit eec3b20393
7 changed files with 120 additions and 23 deletions

View File

@@ -233,4 +233,17 @@ alipay:
# AES密钥 # AES密钥
encryptKey: 0TOgnthQKQtoXJaSn5Bbhg== encryptKey: 0TOgnthQKQtoXJaSn5Bbhg==
charset: utf-8 charset: utf-8
signType: RSA2 signType: RSA2
# 停车道闸配置
parking:
# 深圳停车道闸
qcyuns:
# 车场接口地址
url: http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1
# 车场密钥(分配)
secretKey: K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F
# 车场ID(分配)
parkId: 61578
# 机构ID(分配)
orgId: BTTEST01

View File

@@ -228,4 +228,17 @@ alipay:
# AES密钥 # AES密钥
encryptKey: 0TOgnthQKQtoXJaSn5Bbhg== encryptKey: 0TOgnthQKQtoXJaSn5Bbhg==
charset: utf-8 charset: utf-8
signType: RSA2 signType: RSA2
# 停车道闸配置
parking:
# 深圳停车道闸
qcyuns:
# 车场接口地址
url: https://g.qcyuns.com/park-data-api/data/centre/api/v1
# 车场密钥(分配)
secretKey: 9C7D1BD0D5CA141B2EBB6BBE5F9E188D
# 车场ID(分配)
parkId: 66291
# 机构ID(分配)
orgId: DCWYPROD20250210

View File

@@ -228,4 +228,17 @@ alipay:
# AES密钥 # AES密钥
encryptKey: 0TOgnthQKQtoXJaSn5Bbhg== encryptKey: 0TOgnthQKQtoXJaSn5Bbhg==
charset: utf-8 charset: utf-8
signType: RSA2 signType: RSA2
# 停车道闸配置
parking:
# 深圳停车道闸
qcyuns:
# 车场接口地址
url: http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1
# 车场密钥(分配)
secretKey: K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F
# 车场ID(分配)
parkId: 61578
# 机构ID(分配)
orgId: BTTEST01

View File

@@ -231,4 +231,17 @@ alipay:
# AES密钥 # AES密钥
encryptKey: 0TOgnthQKQtoXJaSn5Bbhg== encryptKey: 0TOgnthQKQtoXJaSn5Bbhg==
charset: utf-8 charset: utf-8
signType: RSA2 signType: RSA2
# 停车道闸配置
parking:
# 深圳停车道闸
qcyuns:
# 车场接口地址
url: http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1
# 车场密钥(分配)
secretKey: K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F
# 车场ID(分配)
parkId: 61578
# 机构ID(分配)
orgId: BTTEST01

View File

@@ -304,19 +304,19 @@ public class SpringBootTestController {
@Test @Test
public void issuanceOfParkingTicketsTest() { public void issuanceOfParkingTicketsTest() {
QcyunParkCouponDTO dto = QcyunParkCouponDTO.builder() QcyunParkCouponDTO dto = QcyunParkCouponDTO.builder()
.plateNumber("QWE443") .plateNumber("B99614")
.stationId("") .stationId("")
.stationName("测试站点") .stationName("测试站点")
.orgId("BTTEST01") .orgId("BTTEST01")
.parkId("") .parkId("61578")
.build(); .build();
qcyunsService.issuanceOfParkingTickets(dto); qcyunsService.issuanceOfParkingTickets(dto);
} }
@Test @Test
public void getCarInfoTest() { public void getCarInfoTest() {
String parkId = "11609"; String parkId = "61578";
String plateNumber = "QWE443"; String plateNumber = "B99613";
String URL = "http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1"; String URL = "http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1";
String secretKey = "K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F"; String secretKey = "K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F";

View File

@@ -14,9 +14,10 @@ public interface ServiceApiCmd {
public final static String LaneInfoList = "LaneInfoList"; public final static String LaneInfoList = "LaneInfoList";
//扫码入场码or出场码 //扫码入场码or出场码
public final static String scanLaneQr = "scanLaneQrCode"; public final static String scanLaneQr = "scanLaneQrCode";
//商圈优惠
public final static String DiscountCreate = "DiscountCreate"; public final static String DiscountCreate = "DiscountCreate";
//商圈优惠 //商圈优惠
public final static String DiscountDestory = "DiscountDestory"; public final static String DiscountDestory = "DiscountDestory";
// 车辆优惠
public final static String CarInfoDiscountDestory = "CarInfoDiscountDestory";
} }

View File

@@ -3,6 +3,7 @@ package com.jsowell.thirdparty.parking.service.impl;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.jsowell.common.core.domain.parking.ParkingCommonParam; import com.jsowell.common.core.domain.parking.ParkingCommonParam;
import com.jsowell.common.util.ParkingUtil; import com.jsowell.common.util.ParkingUtil;
@@ -14,6 +15,7 @@ import com.jsowell.thirdparty.parking.common.bean.TempCarInfo;
import com.jsowell.thirdparty.parking.common.response.DataResponse; import com.jsowell.thirdparty.parking.common.response.DataResponse;
import com.jsowell.thirdparty.parking.service.QcyunsService; import com.jsowell.thirdparty.parking.service.QcyunsService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
@@ -25,21 +27,34 @@ import java.util.Map;
@Service @Service
public class QcyunsServiceImpl implements QcyunsService { public class QcyunsServiceImpl implements QcyunsService {
final static String URL = "http://test-gateway.qcyuns.com/park-data-api/data/centre/api/v1"; @Value("${parking.qcyuns.url}")
private String URL;
final static String secretKey = "K9OGNA7CIY8N5GXD8HF3WVDMEZNFKL3F"; @Value("${parking.qcyuns.secretKey}")
private String secretKey;
@Value("${parking.qcyuns.parkId}")
private String parkId;
@Value("${parking.qcyuns.parkId}")
private String orgId;
/** /**
* 发放停车券 * 发放停车券
* dto中只需要传入车牌号, 其他参数取配置文件中的参数
* 现在只有一家车场, parkId在配置文件中, 以后多家车场改为数据库配置
*/ */
@Override @Override
public String issuanceOfParkingTickets(QcyunParkCouponDTO dto) { public String issuanceOfParkingTickets(QcyunParkCouponDTO dto) {
dto.setParkId(parkId);
// 1. 查询车辆信息 // 1. 查询车辆信息
String carInfo = getCarInfo(dto); String carInfo = getCarInfo(dto);
if (StringUtils.isBlank(carInfo)) { if (StringUtils.isBlank(carInfo)) {
return null; return null;
} }
TempCarInfo tempCarInfo = JSON.parseObject(carInfo, TempCarInfo.class); // carInfo转为json, 提取carInfo
JSONObject jsonObject = JSON.parseObject(carInfo);
TempCarInfo tempCarInfo = JSON.parseObject(jsonObject.getString("carInfo"), TempCarInfo.class);
if (tempCarInfo == null) { if (tempCarInfo == null) {
return null; return null;
} }
@@ -55,10 +70,7 @@ public class QcyunsServiceImpl implements QcyunsService {
* 根据车牌号获取车辆信息(临时车,月租车,储值车) * 根据车牌号获取车辆信息(临时车,月租车,储值车)
*/ */
private String getCarInfo(QcyunParkCouponDTO dto) { private String getCarInfo(QcyunParkCouponDTO dto) {
String parkId = dto.getStationId(); String parkId = dto.getParkId(); // 使用dto中传入的parkId(写在配置文件中), 也许以后有多家车场改为数据库配置
if (StringUtils.isBlank(parkId)) {
parkId = "11609";
}
// 业务参数 // 业务参数
Map<String, String> data = Maps.newHashMap(); Map<String, String> data = Maps.newHashMap();
data.put("parkId", parkId); data.put("parkId", parkId);
@@ -68,7 +80,8 @@ public class QcyunsServiceImpl implements QcyunsService {
param.setService(ServiceApiCmd.CarInfo); param.setService(ServiceApiCmd.CarInfo);
param.setVersion("01"); param.setVersion("01");
param.setMsgId(UUID.randomUUID().toString()); param.setMsgId(UUID.randomUUID().toString());
param.setOrgId(dto.getOrgId()); // param.setOrgId(dto.getOrgId());
param.setOrgId(orgId);
param.setData(data); param.setData(data);
// 生成sign // 生成sign
ParkingUtil.generateAndSetSign(param, secretKey); ParkingUtil.generateAndSetSign(param, secretKey);
@@ -94,12 +107,46 @@ public class QcyunsServiceImpl implements QcyunsService {
data.put("storeName", dto.getStationName()); // 商家名称 data.put("storeName", dto.getStationName()); // 商家名称
data.put("type", "1"); // 优惠类型: 1.金额, 2.时长, 3.全免 data.put("type", "1"); // 优惠类型: 1.金额, 2.时长, 3.全免
data.put("value", String.valueOf(10 * 100)); // 当type=1时单位为分;当type=2时单位为分钟 data.put("value", String.valueOf(10 * 100)); // 当type=1时单位为分;当type=2时单位为分钟
data.put("parkId", dto.getParkId()); // data.put("parkId", dto.getParkId()); // 车场id
// 组装请求体 // 组装请求体
ParkingCommonParam param = new ParkingCommonParam(); ParkingCommonParam param = new ParkingCommonParam();
param.setService(ServiceApiCmd.DiscountCreate); param.setService(ServiceApiCmd.DiscountCreate);
param.setVersion("01"); param.setVersion("01");
param.setMsgId(UUID.randomUUID().toString()); param.setMsgId(UUID.randomUUID().toString());
// param.setOrgId(dto.getOrgId());
param.setOrgId(orgId);
param.setData(data);
// 生成sign
ParkingUtil.generateAndSetSign(param, secretKey);
// 发送请求
String result = HttpUtil.post(URL, JSON.toJSONString(param));
DataResponse dataResponse = JSONUtil.toBean(result, DataResponse.class);
log.info("创建优惠券成功, response:{}", JSON.toJSONString(dataResponse));
queryCarInfoDiscountDestory(dto);
if (dataResponse.getRetCode() == 0 && StringUtils.equals("减免成功", dataResponse.getRetData().toString())) {
return true;
}
return false;
}
/**
* 查询优惠抵扣金额
*/
private void queryCarInfoDiscountDestory(QcyunParkCouponDTO dto) {
// 业务参数
Map<String, String> data = Maps.newHashMap();
data.put("parkingSerial", dto.getParkingSerial());
data.put("grantSerial", dto.getGrantSerial()); // 对接方唯一id
data.put("plate", dto.getPlateNumber()); // 车牌号
data.put("storeName", dto.getStationName()); // 商家名称
data.put("type", "1"); // 优惠类型: 1.金额, 2.时长, 3.全免
data.put("value", String.valueOf(10 * 100)); // 当type=1时单位为分;当type=2时单位为分钟
data.put("parkId", dto.getParkId()); //
// 组装请求体
ParkingCommonParam param = new ParkingCommonParam();
param.setService(ServiceApiCmd.CarInfoDiscountDestory);
param.setVersion("01");
param.setMsgId(UUID.randomUUID().toString());
param.setOrgId(dto.getOrgId()); param.setOrgId(dto.getOrgId());
param.setData(data); param.setData(data);
// 生成sign // 生成sign
@@ -107,10 +154,7 @@ public class QcyunsServiceImpl implements QcyunsService {
// 发送请求 // 发送请求
String result = HttpUtil.post(URL, JSON.toJSONString(param)); String result = HttpUtil.post(URL, JSON.toJSONString(param));
DataResponse dataResponse = JSONUtil.toBean(result, DataResponse.class); DataResponse dataResponse = JSONUtil.toBean(result, DataResponse.class);
log.info("创建优惠券成功, response:{}", JSON.toJSONString(dataResponse)); log.info("查询优惠抵扣金额, response:{}", JSON.toJSONString(dataResponse));
if (dataResponse.getRetCode() == 0) {
}
return false;
} }
} }