update 绑定车辆优惠券

This commit is contained in:
Lemon
2024-10-21 13:48:15 +08:00
parent f0ce2a1393
commit 962d128882
3 changed files with 35 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package com.jsowell.netty.handler.yunkuaichong;
import com.alibaba.fastjson2.JSON;
import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
@@ -645,14 +646,20 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
// 异步绑定第三方平台优惠券
OrderBasicInfo finalOrderBasicInfo = orderBasicInfo;
CompletableFuture.runAsync(() -> {
try {
String bindResult = commonService.bindCoupon(finalOrderBasicInfo);
log.info("绑定优惠券 订单信息:{}, result:{}", finalOrderBasicInfo, bindResult);
} catch (Exception e) {
log.error("绑定优惠券 error,", e);
}
}, executor);
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderBasicInfo.getOrderCode();
Object cacheObject = redisCache.getCacheObject(redisKey);
if (cacheObject == null) {
CompletableFuture.runAsync(() -> {
try {
String bindResult = commonService.bindCoupon(finalOrderBasicInfo);
log.info("绑定优惠券 订单信息:{}, result:{}", finalOrderBasicInfo, bindResult);
// 删除绑定优惠券缓存
redisCache.deleteObject(redisKey);
} catch (Exception e) {
log.error("绑定优惠券 error,", e);
}
}, executor);
}
// // 给车辆绑定优惠券
// try {

View File

@@ -323,6 +323,21 @@ public class UploadRealTimeMonitorHandler extends AbstractYkcHandler {
if (saveRedisFlag) {
pileBasicInfoService.saveRealTimeMonitorData2Redis(realTimeMonitorData);
}
// 判断该订单是否需要下发优惠券
String redisKey = CacheConstants.CAR_BIND_COUPON_BY_ORDER_CODE + orderInfo.getOrderCode();
Object cacheObject = redisCache.getCacheObject(redisKey);
if (cacheObject == null && sumChargingTime >= 10) {
// 异步绑定优惠券并设置缓存
CompletableFuture.runAsync(() -> {
try {
commonService.bindCoupon(orderInfo);
redisCache.setCacheObject(redisKey, Boolean.TRUE);
} catch (Exception e) {
log.error("异步绑定车辆优惠券 error,", e);
}
}, executor);
}
}
// 异步推送第三方平台实时数据