Merge branch 'feat/GHZSCY-7955' into 'dev'

feat: CPM微信小游戏推荐优化 https://jira.shanqu.cc/browse/GHZSCY-7954

See merge request halo/android/assistant-android!2204
This commit is contained in:
陈君陶
2025-05-22 16:40:44 +08:00
11 changed files with 104 additions and 59 deletions

View File

@ -122,7 +122,9 @@ data class SubjectEntity(
@SerializedName("column_type")
private val _columnType: String? = null,
@SerializedName("size")
private val _size: Size? = null
private val _size: Size? = null,
@SerializedName("onlyFee")
private val _onlyFee: Boolean? = false,
) : Parcelable {
@IgnoredOnParcel
@ -161,6 +163,9 @@ data class SubjectEntity(
val size: Size
get() = _size ?: Size()
val onlyFee: Boolean
get() = _onlyFee ?: false
var isDspSubject: Boolean = false
companion object {
@ -173,9 +178,13 @@ data class SubjectEntity(
@Parcelize
data class Size(
@SerializedName("index")
private val _index: Int? = null
private val _index: Int? = null,
@SerializedName("limit")
private val _limit: Int? = null,
) : Parcelable {
val index: Int
get() = _index ?: 0
val limit: Int
get() = _limit ?: -1
}
}

View File

@ -411,7 +411,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
if (gameList != null) {// 直接读取缓存数据
notifyWGameCPMABatchChanged(gameList, subjectId, page)
} else {
repository.loadChangeSubjectWGameCPM(page)
repository.loadChangeSubjectWGameCPM(page, subjectEntity.size.limit, subjectEntity.onlyFee)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<GameEntity>>() {

View File

@ -367,7 +367,7 @@ class CustomPageRepository private constructor(
pageInfo.componentPosition
)
)
wGameSubjectCPMListUseCase.getWechatMiniGameCPMList(subject.id)
wGameSubjectCPMListUseCase.getWechatMiniGameCPMList(subject.id, subject.size.limit, subject.onlyFee)
pageInfo.positionIncrement()
pageInfo.componentPositionIncrement()
}
@ -903,8 +903,8 @@ class CustomPageRepository private constructor(
.map(RegionSettingHelper.filterGame)
.map(ApkActiveUtils.filterMapperList)
fun loadChangeSubjectWGameCPM(page: Int): Observable<MutableList<GameEntity>> =
wGameSubjectCPMRemoteDataSource.getEditorRecommendCPMList(page, 10)// 微信小游戏CPM专题的“换一批”接口
fun loadChangeSubjectWGameCPM(page: Int, minimumSize: Int, onlyFee: Boolean): Observable<MutableList<GameEntity>> =
wGameSubjectCPMRemoteDataSource.getEditorRecommendCPMList(page = page, minimumSize = minimumSize, onlyFee = onlyFee)// 微信小游戏CPM专题的“换一批”接口
.toObservable()
.map(RegionSettingHelper.filterGame)
.map(ApkActiveUtils.filterMapperList)

View File

@ -9,15 +9,19 @@ import io.reactivex.Observable
import io.reactivex.Single
class QGameSubjectListRepository(
private val api: ApiService = RetrofitManager.getInstance().newApi
private val api: ApiService = RetrofitManager.getInstance().newApi,
) : ISubjectListRepository {
override fun getColumn(column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?): Single<MutableList<GameEntity>> {
override fun getColumn(
column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?,
minimumSize: Int,
onlyFee: Boolean,
): Single<MutableList<GameEntity>> {
return api.getQGameColumn(column_id, order, page, 20)
}

View File

@ -10,13 +10,17 @@ class WGameSubjectCPMListRepository(
private val dataSource: WGameSubjectCPMRemoteDataSource = WGameSubjectCPMRemoteDataSource()
) : ISubjectListRepository {
override fun getColumn(column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?): Single<MutableList<GameEntity>> {
return dataSource.getEditorRecommendCPMList(page)
override fun getColumn(
column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?,
minimumSize: Int,
onlyFee: Boolean
): Single<MutableList<GameEntity>> {
return dataSource.getEditorRecommendCPMList(page = page, minimumSize = minimumSize, onlyFee = onlyFee)
}
override fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity> {

View File

@ -27,13 +27,13 @@ class WGameSubjectCPMListUseCase(
val wechatMiniGameCPMListLiveData: LiveData<Pair<String, List<GameEntity>>> = _wechatMiniGameCPMListLiveData
@SuppressLint("CheckResult")
fun getWechatMiniGameCPMList(subjectId: String?) {
fun getWechatMiniGameCPMList(subjectId: String?, minimumSize: Int, onlyFee: Boolean) {
if (subjectId.isNullOrEmpty() || requestKeyList.contains(subjectId)) {
return
}
requestKeyList.add(subjectId)
repository.getColumn(null, 1, null, null, null, null)
repository.getColumn(null, 1, null, null, null, null, minimumSize, onlyFee)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<List<GameEntity>>() {

View File

@ -14,7 +14,12 @@ class WGameSubjectCPMRemoteDataSource(
private val api: WGameCPMApiService = RetrofitManager.getInstance().wGameCPMApi
) {
fun getEditorRecommendCPMList(page: Int, pageSize: Int = 10): Single<MutableList<GameEntity>> {
fun getEditorRecommendCPMList(
page: Int,
pageSize: Int = 10,
minimumSize: Int,
onlyFee: Boolean
): Single<MutableList<GameEntity>> {
val meta = MetaUtil.getMeta()
val request = mapOf(
"head" to mapOf(
@ -28,38 +33,44 @@ class WGameSubjectCPMRemoteDataSource(
"body" to mapOf(
"page" to page - 1,
"pageSize" to pageSize,
"onlyFee" to if (onlyFee) 1 else 0,
)
)
return api.getEditorRecommendList(request.toRequestBody())
.map {
if (it.ret == 0) {
it.appInfoList.map { info ->
GameEntity(
mName = info.appName,
mIcon = info.logo,
mBrief = info.briefIntro,
miniGameUid = info.appID,
miniGameAppId = info.userName,
miniGameCategory = Constants.WECHAT_MINI_GAME,
profit = Constants.WECHAT_MINI_GAME_PROFIT_CPM,
miniGameAppStatus = 2,
miniGameAppPath = info.wechatAppPath,
miniGameExtData = info.extData,
miniGameRecommendId = info.recommendID,
mTagStyle = arrayListOf(
TagStyleEntity(
name = info.categoryName,
color = TAG_COLOR,
background = TAG_BACKGROUND
),
TagStyleEntity(
name = info.subcategoryName,
color = TAG_COLOR,
background = TAG_BACKGROUND
// 数量不满足最小值时直接返回空
if (onlyFee && minimumSize > 0 && it.appInfoList.size < minimumSize) {
mutableListOf()
} else {
it.appInfoList.map { info ->
GameEntity(
mName = info.appName,
mIcon = info.logo,
mBrief = info.briefIntro,
miniGameUid = info.appID,
miniGameAppId = info.userName,
miniGameCategory = Constants.WECHAT_MINI_GAME,
profit = Constants.WECHAT_MINI_GAME_PROFIT_CPM,
miniGameAppStatus = 2,
miniGameAppPath = info.wechatAppPath,
miniGameExtData = info.extData,
miniGameRecommendId = info.recommendID,
mTagStyle = arrayListOf(
TagStyleEntity(
name = info.categoryName,
color = TAG_COLOR,
background = TAG_BACKGROUND
),
TagStyleEntity(
name = info.subcategoryName,
color = TAG_COLOR,
background = TAG_BACKGROUND
)
)
)
)
}.toMutableList()
}.toMutableList()
}
} else {
mutableListOf()
}

View File

@ -9,15 +9,19 @@ import io.reactivex.Observable
import io.reactivex.Single
class WGameSubjectListRepository(
private val api: ApiService = RetrofitManager.getInstance().newApi
private val api: ApiService = RetrofitManager.getInstance().newApi,
) : ISubjectListRepository {
override fun getColumn(column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?): Single<MutableList<GameEntity>> {
override fun getColumn(
column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?,
minimumSize: Int,
onlyFee: Boolean,
): Single<MutableList<GameEntity>> {
return api.getWGameColumn(column_id, order, page, 20)
}

View File

@ -13,7 +13,9 @@ interface ISubjectListRepository {
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?
columnCollectionId: String?,
minimumSize: Int,
onlyFee: Boolean
): Single<MutableList<GameEntity>>
fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity>

View File

@ -8,10 +8,19 @@ import io.reactivex.Observable
import io.reactivex.Single
class SubjectListRepository(
private val api: ApiService = RetrofitManager.getInstance().api
private val api: ApiService = RetrofitManager.getInstance().api,
) : ISubjectListRepository {
override fun getColumn(column_id: String?, page: Int, sort: String?, order: String?, ad: String?, columnCollectionId: String?): Single<MutableList<GameEntity>> {
override fun getColumn(
column_id: String?,
page: Int,
sort: String?,
order: String?,
ad: String?,
columnCollectionId: String?,
minimumSize: Int,
onlyFee: Boolean,
): Single<MutableList<GameEntity>> {
return api.getColumn(column_id, sort, order, ad, columnCollectionId, page)
}

View File

@ -49,7 +49,9 @@ open class SubjectListViewModel(
subjectData.sort,
subjectData.filter.ifEmpty { "type:全部" },
AdHelper.getIdfaString(),
columnCollectionId
columnCollectionId,
-1,
false
)
}