uniapp广告完播规则修改

This commit is contained in:
张松
2025-01-16 14:38:14 +08:00
parent d5aa722bf0
commit 2dd2641bef
3 changed files with 15 additions and 5 deletions

View File

@@ -4,25 +4,35 @@ import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.service.AdService;
import com.sqx.modules.callback.service.UniAdCallbackRecordService;
import com.sqx.modules.redisService.RedisService;
import com.sqx.modules.sys.controller.AbstractController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@RestController
@RequestMapping("/app/ad")
public class AdController extends AbstractController {
private final UniAdCallbackRecordService callbackRecordService;
private final AdService adService;
private final RedisService redisService;
public AdController(UniAdCallbackRecordService callbackRecordService, AdService adService) {
public AdController(UniAdCallbackRecordService callbackRecordService, AdService adService, RedisService redisService) {
this.callbackRecordService = callbackRecordService;
this.adService = adService;
this.redisService = redisService;
}
@Login
@GetMapping("/state")
public Result getAdState(@RequestParam String extraKey, @RequestAttribute Long userId) {
return Result.success(callbackRecordService.getStateByExtraKey(userId, extraKey));
HashMap<String, Integer> info = callbackRecordService.getStateByExtraKey(userId, extraKey);
if (info.get("isEnded") == 0 && !redisService.isCanCash(userId)) {
redisService.setCanCashFlag(userId, -1L);
info.put("isEnded", 1);
}
return Result.success();
}
@Login

View File

@@ -16,5 +16,5 @@ public interface UniAdCallbackRecordService extends IService<UniAdCallbackRecord
Map<String, Object> adCallBack(UniAdCallBackDTO callBackDTO);
HashMap<String, Object> getStateByExtraKey(Long userId, String extraKey);
HashMap<String, Integer> getStateByExtraKey(Long userId, String extraKey);
}

View File

@@ -129,10 +129,10 @@ public class UniAdCallbackRecordServiceImpl extends ServiceImpl<UniAdCallbackRec
}
@Override
public HashMap<String, Object> getStateByExtraKey(Long userId, String extraKey) {
public HashMap<String, Integer> getStateByExtraKey(Long userId, String extraKey) {
UniAdCallbackRecord one = getOne(new LambdaQueryWrapper<UniAdCallbackRecord>().eq(UniAdCallbackRecord::getUserId, userId)
.eq(UniAdCallbackRecord::getExtra, extraKey));
return new HashMap<String, Object>(){{
return new HashMap<String, Integer>(){{
put("isEnded", one == null ? 0 : 1);
}};
}