深圳停车平台

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

@@ -14,9 +14,10 @@ public interface ServiceApiCmd {
public final static String LaneInfoList = "LaneInfoList";
//扫码入场码or出场码
public final static String scanLaneQr = "scanLaneQrCode";
//商圈优惠
public final static String DiscountCreate = "DiscountCreate";
//商圈优惠
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.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Maps;
import com.jsowell.common.core.domain.parking.ParkingCommonParam;
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.service.QcyunsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
@@ -25,21 +27,34 @@ import java.util.Map;
@Service
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
public String issuanceOfParkingTickets(QcyunParkCouponDTO dto) {
dto.setParkId(parkId);
// 1. 查询车辆信息
String carInfo = getCarInfo(dto);
if (StringUtils.isBlank(carInfo)) {
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) {
return null;
}
@@ -55,10 +70,7 @@ public class QcyunsServiceImpl implements QcyunsService {
* 根据车牌号获取车辆信息(临时车,月租车,储值车)
*/
private String getCarInfo(QcyunParkCouponDTO dto) {
String parkId = dto.getStationId();
if (StringUtils.isBlank(parkId)) {
parkId = "11609";
}
String parkId = dto.getParkId(); // 使用dto中传入的parkId(写在配置文件中), 也许以后有多家车场改为数据库配置
// 业务参数
Map<String, String> data = Maps.newHashMap();
data.put("parkId", parkId);
@@ -68,7 +80,8 @@ public class QcyunsServiceImpl implements QcyunsService {
param.setService(ServiceApiCmd.CarInfo);
param.setVersion("01");
param.setMsgId(UUID.randomUUID().toString());
param.setOrgId(dto.getOrgId());
// param.setOrgId(dto.getOrgId());
param.setOrgId(orgId);
param.setData(data);
// 生成sign
ParkingUtil.generateAndSetSign(param, secretKey);
@@ -94,12 +107,46 @@ public class QcyunsServiceImpl implements QcyunsService {
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()); //
data.put("parkId", dto.getParkId()); // 车场id
// 组装请求体
ParkingCommonParam param = new ParkingCommonParam();
param.setService(ServiceApiCmd.DiscountCreate);
param.setVersion("01");
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.setData(data);
// 生成sign
@@ -107,10 +154,7 @@ public class QcyunsServiceImpl implements QcyunsService {
// 发送请求
String result = HttpUtil.post(URL, JSON.toJSONString(param));
DataResponse dataResponse = JSONUtil.toBean(result, DataResponse.class);
log.info("创建优惠券成功, response:{}", JSON.toJSONString(dataResponse));
if (dataResponse.getRetCode() == 0) {
}
return false;
log.info("查询优惠抵扣金额, response:{}", JSON.toJSONString(dataResponse));
}
}