配置充电停车优惠

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;
import java.util.List;
import com.jsowell.pile.domain.CarCouponRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 车辆绑定优惠券记录Mapper接口
*
@@ -60,4 +61,11 @@ public interface CarCouponRecordMapper {
* @return 结果
*/
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;
import java.util.List;
import com.jsowell.pile.domain.CarCouponRecord;
import java.util.List;
/**
* 车辆绑定优惠券记录Service接口
*
@@ -58,4 +58,9 @@ public interface CarCouponRecordService {
* @return 结果
*/
public int deleteCarCouponRecordById(Long id);
/**
* 根据订单号与车牌号查询发券成功的记录
*/
public CarCouponRecord selectCarCouponRecord(String orderCode);
}

View File

@@ -1,13 +1,16 @@
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.pile.domain.CarCouponRecord;
import com.jsowell.pile.mapper.CarCouponRecordMapper;
import com.jsowell.pile.service.CarCouponRecordService;
import org.springframework.beans.factory.annotation.Autowired;
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业务层处理
@@ -20,6 +23,9 @@ public class CarCouponRecordServiceImpl implements CarCouponRecordService {
@Autowired
private CarCouponRecordMapper carCouponRecordMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询车辆绑定优惠券记录
*
@@ -51,7 +57,13 @@ public class CarCouponRecordServiceImpl implements CarCouponRecordService {
@Override
public int insertCarCouponRecord(CarCouponRecord carCouponRecord) {
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) {
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}
</foreach>
</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>