提交 0705f230 authored 作者: liuhaiquan's avatar liuhaiquan

增加结算单支付锁

上级 cbff55b4
......@@ -6,4 +6,9 @@ public class RedissonConstants {
public static final String ORDER_CHILD_SAVE_USER_TRUCK_LOCK = "clx-performance:orderChild:save:userTruck:";
public static final String ORDER_CHILD_SAVE_ORDER_GOODS_NO_LOCK = "clx-performance:orderChild:save:orderGoodsNo:";
//货主结算单支付锁
public static final String SETTLEMENT_OWNER_BATCH_PAY_ID_LOCK = "clx-performance:settlementOwner:batchPay:id:";
//货主违约结算单支付锁
public static final String BREAK_CONTRACT_SETTLEMENT_OWNER_BATCH_PAY_ID_LOCK = "clx-performance:breakContractSettlementOwner:batchPay:id:";
}
package com.clx.performance.service.impl.settle;
import com.clx.performance.config.MslPaymentConfig;
import com.clx.performance.constant.RedissonConstants;
import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.settle.SettlementDriverDao;
......@@ -31,11 +32,13 @@ import com.clx.performance.service.settle.SettlementLogService;
import com.clx.performance.service.settle.SettlementMqHandlerService;
import com.clx.performance.service.settle.SettlementService;
import com.clx.performance.utils.LocalDateTimeUtils;
import com.clx.performance.utils.RedisUtil;
import com.clx.performance.vo.mq.SettlementDetailAddMqParam;
import com.clx.performance.vo.mq.SettlementDetailInvoiceTypeSyncMqParam;
import com.clx.user.vo.feign.DriverInfoFeignVo;
import com.clx.user.vo.feign.OwnerInfoFeignVO;
import com.msl.common.enums.ResultCodeEnum;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,6 +49,7 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@Slf4j
@Service
......@@ -91,6 +95,9 @@ public class SettlementMqHandlerServiceImpl implements SettlementMqHandlerServic
@Autowired
private OrderChildLogService orderChildLogService;
@Autowired
RedisUtil redisUtil;
@Override
......@@ -206,6 +213,14 @@ public class SettlementMqHandlerServiceImpl implements SettlementMqHandlerServic
* 车主结算单自动支付
*/
public String paySettlementDriver(SettlementDriverDetail detail){
String uuid = UUID.randomUUID().toString();
String key = RedissonConstants.SETTLEMENT_OWNER_BATCH_PAY_ID_LOCK + detail.getId();
try{
boolean flag = redisUtil.lock(key, uuid);
if(!flag){
return "获取支付锁失败,操作频繁,请稍后重试";
}
DriverInfoFeignVo driverInfoFeignVo = driverService.getDriverInfo(detail.getDriverUserNo()).orElseThrow(ResultCodeEnum.FAIL);
PayParam noCheckPwd = null ;
if(detail.getSettlementFreight().compareTo(BigDecimal.ZERO) > 0){
......@@ -241,6 +256,11 @@ public class SettlementMqHandlerServiceImpl implements SettlementMqHandlerServic
settlementDriverNotify(detail.getChildNo(),0,result.getMsg());
}
return msg;
}catch (Exception e){
//解锁
redisUtil.unlock(key,uuid);
throw new ServiceSystemException(PerformanceResultEnum.DATA_REPEAT);
}
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论