赠送幸运礼物任务修改
This commit is contained in:
parent
f0719b2d54
commit
eacce3cacf
@ -115,7 +115,7 @@ public class TaskListener implements MessageListener {
|
|||||||
handleTask7(eventBody);
|
handleTask7(eventBody);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
// 处理任务-8 的逻辑 发送10个幸运礼物
|
// 处理任务-8 的逻辑 发送1个幸运礼物
|
||||||
handleTask8(eventBody);
|
handleTask8(eventBody);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
@ -276,27 +276,10 @@ public class TaskListener implements MessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleTask8(TaskApprovalEvent eventBody) {
|
private void handleTask8(TaskApprovalEvent eventBody) {
|
||||||
log.warn("处理任务-8 发送10个幸运礼物: {}", eventBody);
|
log.warn("处理任务-8 发送1个幸运礼物: {}", eventBody);
|
||||||
|
eventBody.setTargetValue(1);
|
||||||
String redisKey = "task:lucky-gift:count:" + eventBody.getUserId();
|
eventBody.setCompleteValue(1);
|
||||||
int num = eventBody.getQuantity() == null ? 1 : eventBody.getQuantity();
|
updateTaskStatus(eventBody);
|
||||||
|
|
||||||
// 获取当前计数
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTask9(TaskApprovalEvent eventBody) {
|
private void handleTask9(TaskApprovalEvent eventBody) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user