配置充电停车优惠

This commit is contained in:
Guoqs
2025-02-19 13:23:49 +08:00
parent 116b122e61
commit 1ccd62735e
5 changed files with 59 additions and 16 deletions

View File

@@ -1,10 +1,11 @@
package com.jsowell.pile.mapper; package com.jsowell.pile.mapper;
import java.util.List;
import com.jsowell.pile.domain.CarCouponRecord; import com.jsowell.pile.domain.CarCouponRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* 车辆绑定优惠券记录Mapper接口 * 车辆绑定优惠券记录Mapper接口
* *
@@ -60,4 +61,11 @@ public interface CarCouponRecordMapper {
* @return 结果 * @return 结果
*/ */
public int deleteCarCouponRecordByIds(Long[] ids); public int deleteCarCouponRecordByIds(Long[] ids);
/**
* 根据订单号和车牌号查询车辆绑定优惠券记录(发券成功记录)
* @param orderCode
* @return
*/
CarCouponRecord selectCarCouponRecord(@Param("orderCode") String orderCode);
} }

View File

@@ -1,9 +1,9 @@
package com.jsowell.pile.service; package com.jsowell.pile.service;
import java.util.List;
import com.jsowell.pile.domain.CarCouponRecord; import com.jsowell.pile.domain.CarCouponRecord;
import java.util.List;
/** /**
* 车辆绑定优惠券记录Service接口 * 车辆绑定优惠券记录Service接口
* *
@@ -58,4 +58,9 @@ public interface CarCouponRecordService {
* @return 结果 * @return 结果
*/ */
public int deleteCarCouponRecordById(Long id); public int deleteCarCouponRecordById(Long id);
/**
* 根据订单号与车牌号查询发券成功的记录
*/
public CarCouponRecord selectCarCouponRecord(String orderCode);
} }

View File

@@ -1,13 +1,16 @@
package com.jsowell.pile.service.impl; package com.jsowell.pile.service.impl;
import java.util.List; import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.domain.CarCouponRecord;
import com.jsowell.pile.mapper.CarCouponRecordMapper;
import com.jsowell.pile.service.CarCouponRecordService; import com.jsowell.pile.service.CarCouponRecordService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.jsowell.pile.mapper.CarCouponRecordMapper;
import com.jsowell.pile.domain.CarCouponRecord; import java.util.List;
import java.util.concurrent.TimeUnit;
/** /**
* 车辆绑定优惠券记录Service业务层处理 * 车辆绑定优惠券记录Service业务层处理
@@ -20,6 +23,9 @@ public class CarCouponRecordServiceImpl implements CarCouponRecordService {
@Autowired @Autowired
private CarCouponRecordMapper carCouponRecordMapper; private CarCouponRecordMapper carCouponRecordMapper;
@Autowired
private RedisCache redisCache;
/** /**
* 查询车辆绑定优惠券记录 * 查询车辆绑定优惠券记录
* *
@@ -51,7 +57,13 @@ public class CarCouponRecordServiceImpl implements CarCouponRecordService {
@Override @Override
public int insertCarCouponRecord(CarCouponRecord carCouponRecord) { public int insertCarCouponRecord(CarCouponRecord carCouponRecord) {
carCouponRecord.setCreateTime(DateUtils.getNowDate()); carCouponRecord.setCreateTime(DateUtils.getNowDate());
return carCouponRecordMapper.insertCarCouponRecord(carCouponRecord); int i = carCouponRecordMapper.insertCarCouponRecord(carCouponRecord);
if (i > 0) {
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + carCouponRecord.getOrderCode();
//发券成功保存到redis
redisCache.setCacheObject(redisKey, carCouponRecord, 24, TimeUnit.HOURS);
}
return i;
} }
/** /**
@@ -86,4 +98,17 @@ public class CarCouponRecordServiceImpl implements CarCouponRecordService {
public int deleteCarCouponRecordById(Long id) { public int deleteCarCouponRecordById(Long id) {
return carCouponRecordMapper.deleteCarCouponRecordById(id); return carCouponRecordMapper.deleteCarCouponRecordById(id);
} }
@Override
public CarCouponRecord selectCarCouponRecord(String orderCode) {
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderCode;
CarCouponRecord carCouponRecord = redisCache.getCacheObject(redisKey);
if (carCouponRecord == null) {
carCouponRecord = carCouponRecordMapper.selectCarCouponRecord(orderCode);
if (carCouponRecord != null) {
redisCache.setCacheObject(redisKey, carCouponRecord, CacheConstants.cache_expire_time_1d);
}
}
return carCouponRecord;
}
} }

View File

@@ -81,4 +81,13 @@
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectCarCouponRecord" resultMap="CarCouponRecordResult">
<include refid="selectCarCouponRecordVo"/>
where del_flag = '0'
and return_code = '200'
and order_code = #{orderCode,jdbcType=VARCHAR}
order by create_time desc
limit 1
</select>
</mapper> </mapper>

View File

@@ -728,14 +728,12 @@ public class CommonService {
return; return;
} }
// 是否已经发券 // 是否已经发券
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderBasicInfo.getOrderCode(); CarCouponRecord carCouponRecord = carCouponRecordService.selectCarCouponRecord(orderBasicInfo.getOrderCode());
Object cacheObject = redisCache.getCacheObject(redisKey); if (carCouponRecord != null) {
if (cacheObject != null) {
log.info("{}该订单已经发券", orderBasicInfo.getOrderCode()); log.info("{}该订单已经发券", orderBasicInfo.getOrderCode());
return; return;
} }
// 绑定停车券 // 绑定停车券
// PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
String parkingPlatformId = chargeParkingDiscount.getParkingPlatformId() + ""; String parkingPlatformId = chargeParkingDiscount.getParkingPlatformId() + "";
boolean discountFlag = false; boolean discountFlag = false;
if (StringUtils.equals(ParkingPlatformEnum.LU_TONG_YUN_TING_PLATFORM.getCode(), parkingPlatformId)) { if (StringUtils.equals(ParkingPlatformEnum.LU_TONG_YUN_TING_PLATFORM.getCode(), parkingPlatformId)) {
@@ -760,10 +758,8 @@ public class CommonService {
if (discountFlag) { if (discountFlag) {
log.info("订单号:{}, 车牌号:{}, 发券成功", orderBasicInfo.getOrderCode(), orderBasicInfo.getPlateNumber()); log.info("订单号:{}, 车牌号:{}, 发券成功", orderBasicInfo.getOrderCode(), orderBasicInfo.getPlateNumber());
//发券成功保存到redis
redisCache.setCacheObject(redisKey, Boolean.TRUE, 24, TimeUnit.HOURS);
// 将下发优惠券信息存入表 // 将下发优惠券信息存入表
CarCouponRecord carCouponRecord = new CarCouponRecord(); carCouponRecord = new CarCouponRecord();
carCouponRecord.setOrderCode(orderBasicInfo.getOrderCode()); carCouponRecord.setOrderCode(orderBasicInfo.getOrderCode());
carCouponRecord.setReturnCode("200"); carCouponRecord.setReturnCode("200");
carCouponRecord.setReturnMsg("ok"); carCouponRecord.setReturnMsg("ok");