mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 绑定车辆优惠券
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 异步推送第三方平台实时数据
|
||||
|
||||
Reference in New Issue
Block a user