diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java index e3d48c8e..cda2f8a3 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java @@ -18,6 +18,8 @@ import com.red.circle.other.app.dto.clientobject.activity.*; import com.red.circle.other.app.dto.cmd.activity.*; import java.util.List; + +import com.red.circle.other.app.util.DistributedLockUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -43,6 +45,8 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic private final LotteryWithdrawApplyExe lotteryWithdrawApplyExe; private final LotteryWithdrawQryExe lotteryWithdrawQryExe; private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe; + private final DistributedLockUtil distributedLockUtil; + private static final String LOCK_KEY_PREFIX = "activity:lottery:draw:lock"; @Override public List listValidActivities(AppExtCommand cmd) { @@ -56,12 +60,16 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic @Override public LotteryDrawResultCO draw(LotteryDrawCmd cmd) { - return lotteryDrawExe.execute(cmd); + return distributedLockUtil.executeWithLock( + DistributedLockUtil.buildLockKey(LOCK_KEY_PREFIX, cmd.requiredReqUserId()), + () -> lotteryDrawExe.execute(cmd)); } @Override public LotteryMultiDrawResultCO multiDraw(LotteryMultiDrawCmd cmd) { - return lotteryMultiDrawExe.execute(cmd); + return distributedLockUtil.executeWithLock( + DistributedLockUtil.buildLockKey(LOCK_KEY_PREFIX, cmd.requiredReqUserId()), + () -> lotteryMultiDrawExe.execute(cmd)); } @Override