赠送幸运礼物任务修改
This commit is contained in:
parent
f0719b2d54
commit
eacce3cacf
@ -115,7 +115,7 @@ public class TaskListener implements MessageListener {
|
||||
handleTask7(eventBody);
|
||||
break;
|
||||
case 8:
|
||||
// 处理任务-8 的逻辑 发送10个幸运礼物
|
||||
// 处理任务-8 的逻辑 发送1个幸运礼物
|
||||
handleTask8(eventBody);
|
||||
break;
|
||||
case 9:
|
||||
@ -276,27 +276,10 @@ public class TaskListener implements MessageListener {
|
||||
}
|
||||
|
||||
private void handleTask8(TaskApprovalEvent eventBody) {
|
||||
log.warn("处理任务-8 发送10个幸运礼物: {}", eventBody);
|
||||
|
||||
String redisKey = "task:lucky-gift:count:" + eventBody.getUserId();
|
||||
int num = eventBody.getQuantity() == null ? 1 : eventBody.getQuantity();
|
||||
|
||||
// 获取当前计数
|
||||
String countStr = redisService.getString(redisKey);
|
||||
int currentCount = StringUtils.isEmpty(countStr) ? 0 : Integer.parseInt(countStr);
|
||||
|
||||
// 计算新的计数值
|
||||
int newCount = currentCount + num;
|
||||
|
||||
// 更新任务进度
|
||||
eventBody.setTargetValue(10);
|
||||
eventBody.setCompleteValue(Math.min(newCount, 10));
|
||||
boolean updated = updateTaskStatus(eventBody);
|
||||
|
||||
// 只有任务状态更新成功才更新 Redis
|
||||
if (updated) {
|
||||
redisService.increment(redisKey, num);
|
||||
}
|
||||
log.warn("处理任务-8 发送1个幸运礼物: {}", eventBody);
|
||||
eventBody.setTargetValue(1);
|
||||
eventBody.setCompleteValue(1);
|
||||
updateTaskStatus(eventBody);
|
||||
}
|
||||
|
||||
private void handleTask9(TaskApprovalEvent eventBody) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user