mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
配置充电停车优惠
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -728,14 +728,12 @@ public class CommonService {
|
||||
return;
|
||||
}
|
||||
// 是否已经发券
|
||||
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderBasicInfo.getOrderCode();
|
||||
Object cacheObject = redisCache.getCacheObject(redisKey);
|
||||
if (cacheObject != null) {
|
||||
CarCouponRecord carCouponRecord = carCouponRecordService.selectCarCouponRecord(orderBasicInfo.getOrderCode());
|
||||
if (carCouponRecord != null) {
|
||||
log.info("{}该订单已经发券", orderBasicInfo.getOrderCode());
|
||||
return;
|
||||
}
|
||||
// 绑定停车券
|
||||
// PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
|
||||
String parkingPlatformId = chargeParkingDiscount.getParkingPlatformId() + "";
|
||||
boolean discountFlag = false;
|
||||
if (StringUtils.equals(ParkingPlatformEnum.LU_TONG_YUN_TING_PLATFORM.getCode(), parkingPlatformId)) {
|
||||
@@ -760,10 +758,8 @@ public class CommonService {
|
||||
|
||||
if (discountFlag) {
|
||||
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.setReturnCode("200");
|
||||
carCouponRecord.setReturnMsg("ok");
|
||||
|
||||
Reference in New Issue
Block a user