mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
充电停车优惠
This commit is contained in:
@@ -30,6 +30,7 @@ import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
|
||||
import com.jsowell.pile.vo.huawei.QueryStartChargeVO;
|
||||
import com.jsowell.pile.vo.web.ChargeParkingDiscountVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.huawei.HuaweiServiceV2;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
@@ -674,6 +675,108 @@ public class CommonService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定停车券
|
||||
* @param orderBasicInfo
|
||||
* @return
|
||||
*/
|
||||
public String bindParkingCoupon(RealTimeMonitorData realTimeMonitorData, OrderBasicInfo orderBasicInfo) throws UnsupportedEncodingException {
|
||||
// 判断该订单的站点是否有停车优惠
|
||||
ChargeParkingDiscountVO chargeParkingDiscount = getChargeParkingDiscount(orderBasicInfo.getStationId());
|
||||
if (chargeParkingDiscount == null) {
|
||||
return null;
|
||||
}
|
||||
// 是否满足发券条件
|
||||
String sumChargingTime = realTimeMonitorData.getSumChargingTime(); // 充电时长
|
||||
String chargingDegree = realTimeMonitorData.getChargingDegree(); // 充电度数
|
||||
String conditionType = chargeParkingDiscount.getConditionType();
|
||||
// 如果conditionType为1判断充电度数, 如果为2判断充电时长
|
||||
boolean flag = false;
|
||||
if (StringUtils.equals(conditionType, "1")) {
|
||||
if (Integer.parseInt(chargingDegree) >= Integer.parseInt(chargeParkingDiscount.getConditionValue())) {
|
||||
// 发券
|
||||
flag = true;
|
||||
}
|
||||
} else if (StringUtils.equals(conditionType, "2")) {
|
||||
if (Integer.parseInt(sumChargingTime) >= Integer.parseInt(chargeParkingDiscount.getConditionValue())) {
|
||||
// 发券
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
// 不满足发券条件
|
||||
return orderBasicInfo.getOrderCode() + " 该订单不满足发券条件";
|
||||
}
|
||||
// 是否已经发券
|
||||
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderBasicInfo.getOrderCode();
|
||||
Object cacheObject = redisCache.getCacheObject(redisKey);
|
||||
if (cacheObject != null) {
|
||||
return orderBasicInfo.getOrderCode() + " 该订单已经发券";
|
||||
}
|
||||
// 绑定停车券
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
|
||||
if (StringUtils.equals(ParkingPlatformEnum.LU_TONG_YUN_TING_PLATFORM.getCode(), stationInfo.getParkingId())) {
|
||||
// 路通云停
|
||||
// 查询密钥等配置
|
||||
ThirdpartyParkingConfig parkingInfo = thirdPartyParkingConfigService.selectByPrimaryKey(Integer.parseInt(stationInfo.getParkingId()));
|
||||
if (parkingInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_PARKING_INFO_IS_NULL);
|
||||
}
|
||||
BindCouponDTO dto = BindCouponDTO.builder()
|
||||
.appId(parkingInfo.getAppId())
|
||||
.merchantId(parkingInfo.getParkingMerchantId())
|
||||
.couponId(parkingInfo.getCouponId())
|
||||
.secretKey(parkingInfo.getSecretKey())
|
||||
.plateNumber(orderBasicInfo.getPlateNumber())
|
||||
.plateColor(5) // 5-绿牌车
|
||||
.orderBasicInfo(orderBasicInfo)
|
||||
.build();
|
||||
// 绑定优惠券
|
||||
return ltytService.bindCoupon(dto);
|
||||
} else if (StringUtils.equals(ParkingPlatformEnum.RUAN_JIE_PLATFORM.getCode(), stationInfo.getParkingId())) {
|
||||
// 软杰
|
||||
UseCouponDTO dto = UseCouponDTO.builder()
|
||||
.fCouponCode(orderBasicInfo.getOrderCode()) // 优惠券编号(使用订单编号)
|
||||
.fCouponType("2") // 优惠类型 2-时长
|
||||
.fCouponValue("120") // 优惠券面额 单位:分钟
|
||||
.fPlateCode(orderBasicInfo.getPlateNumber()) // 车牌号
|
||||
.build();
|
||||
return rjService.useCoupon(dto);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 先做个临时方法返回ChargeParkingDiscountVO, 后面改为后面页面配置
|
||||
*
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
private ChargeParkingDiscountVO getChargeParkingDiscount(String stationId) {
|
||||
// 查询该站点的停车优惠信息
|
||||
ChargeParkingDiscountVO discountVO = new ChargeParkingDiscountVO();
|
||||
if (StringUtils.equals(stationId, "")) {
|
||||
discountVO.setStationId(stationId);
|
||||
discountVO.setConditionType("2");
|
||||
discountVO.setConditionValue("10");
|
||||
discountVO.setDiscountType("");
|
||||
discountVO.setDiscountValue("");
|
||||
discountVO.setStartTime("");
|
||||
discountVO.setEndTime("");
|
||||
} else if (StringUtils.equals(stationId, "")) {
|
||||
discountVO.setStationId(stationId);
|
||||
discountVO.setConditionType("");
|
||||
discountVO.setConditionValue("");
|
||||
discountVO.setDiscountType("");
|
||||
discountVO.setDiscountValue("");
|
||||
discountVO.setStartTime("");
|
||||
discountVO.setEndTime("");
|
||||
} else {
|
||||
discountVO = null;
|
||||
}
|
||||
return discountVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一请求启动充电,目前给华为平台用
|
||||
* @param dto
|
||||
|
||||
Reference in New Issue
Block a user