uniapp广告完播规则修改
This commit is contained in:
@@ -4,25 +4,35 @@ import com.sqx.common.utils.Result;
|
|||||||
import com.sqx.modules.app.annotation.Login;
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.app.service.AdService;
|
import com.sqx.modules.app.service.AdService;
|
||||||
import com.sqx.modules.callback.service.UniAdCallbackRecordService;
|
import com.sqx.modules.callback.service.UniAdCallbackRecordService;
|
||||||
|
import com.sqx.modules.redisService.RedisService;
|
||||||
import com.sqx.modules.sys.controller.AbstractController;
|
import com.sqx.modules.sys.controller.AbstractController;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/app/ad")
|
@RequestMapping("/app/ad")
|
||||||
public class AdController extends AbstractController {
|
public class AdController extends AbstractController {
|
||||||
|
|
||||||
private final UniAdCallbackRecordService callbackRecordService;
|
private final UniAdCallbackRecordService callbackRecordService;
|
||||||
private final AdService adService;
|
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.callbackRecordService = callbackRecordService;
|
||||||
this.adService = adService;
|
this.adService = adService;
|
||||||
|
this.redisService = redisService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@GetMapping("/state")
|
@GetMapping("/state")
|
||||||
public Result getAdState(@RequestParam String extraKey, @RequestAttribute Long userId) {
|
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
|
@Login
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ public interface UniAdCallbackRecordService extends IService<UniAdCallbackRecord
|
|||||||
|
|
||||||
Map<String, Object> adCallBack(UniAdCallBackDTO callBackDTO);
|
Map<String, Object> adCallBack(UniAdCallBackDTO callBackDTO);
|
||||||
|
|
||||||
HashMap<String, Object> getStateByExtraKey(Long userId, String extraKey);
|
HashMap<String, Integer> getStateByExtraKey(Long userId, String extraKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,10 +129,10 @@ public class UniAdCallbackRecordServiceImpl extends ServiceImpl<UniAdCallbackRec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
UniAdCallbackRecord one = getOne(new LambdaQueryWrapper<UniAdCallbackRecord>().eq(UniAdCallbackRecord::getUserId, userId)
|
||||||
.eq(UniAdCallbackRecord::getExtra, extraKey));
|
.eq(UniAdCallbackRecord::getExtra, extraKey));
|
||||||
return new HashMap<String, Object>(){{
|
return new HashMap<String, Integer>(){{
|
||||||
put("isEnded", one == null ? 0 : 1);
|
put("isEnded", one == null ? 0 : 1);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user