NTP-54466 | Divyesh | orderTimestamp format and reward status consistency handling in tstore db (#15972)
This commit is contained in:
@@ -38,6 +38,7 @@ import com.navi.pay.common.theme.color.NaviPayColor
|
||||
import com.navi.pay.common.usecase.NaviPayConfigUseCase
|
||||
import com.navi.pay.common.usecase.RefreshGenericOffersUseCase
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils.getDateTimeObjectFromEpochString
|
||||
import com.navi.pay.common.utils.getMetricInfo
|
||||
import com.navi.pay.common.viewmodel.NaviPayBaseVM
|
||||
import com.navi.pay.common.widget.NaviPayWidgetManager
|
||||
@@ -58,6 +59,8 @@ import com.navi.pay.management.mandate.model.view.MandateStatus
|
||||
import com.navi.pay.management.transactionhistory.model.view.TransactionEntity
|
||||
import com.navi.pay.management.transactionhistory.repository.TransactionRepository
|
||||
import com.navi.pay.network.di.NaviPayGsonBuilder
|
||||
import com.navi.pay.tstore.details.model.view.RewardStatus
|
||||
import com.navi.pay.tstore.details.repository.OrderDetailsRepository
|
||||
import com.navi.pay.tstore.list.repository.OrderRepository
|
||||
import com.navi.pay.tstore.list.usecase.SyncOrderHistoryUseCase
|
||||
import com.navi.pay.utils.BUTLER_VPA_TRANSACTIONS_INFO_MAX_SIZE
|
||||
@@ -114,6 +117,7 @@ constructor(
|
||||
private val naviPayConfigUseCase: NaviPayConfigUseCase,
|
||||
private val transactionRepository: TransactionRepository,
|
||||
private val orderRepository: OrderRepository,
|
||||
private val orderDetailsRepository: OrderDetailsRepository,
|
||||
val festiveThemeHelper: FestiveThemeHelper,
|
||||
private val refreshGenericOffersUseCase: RefreshGenericOffersUseCase,
|
||||
private val resourceProvider: ResourceProvider,
|
||||
@@ -589,6 +593,7 @@ constructor(
|
||||
rewardsGratificationUIState =
|
||||
PaymentSummaryRewardsGratificationUIState.NoReward
|
||||
)
|
||||
updateOrderEntityRewardStatusInOrderHistoryTable()
|
||||
naviPayAnalytics.onRewardsScratchCardClosed(
|
||||
upiRequestId = upiRequestId,
|
||||
rewardEarned = "N",
|
||||
@@ -601,6 +606,7 @@ constructor(
|
||||
amount = it.data.reward ?: ""
|
||||
)
|
||||
)
|
||||
updateOrderEntityRewardStatusInOrderHistoryTable()
|
||||
naviPayAnalytics.onRewardsScratchCardClosed(
|
||||
upiRequestId = upiRequestId,
|
||||
rewardEarned = "Y",
|
||||
@@ -676,6 +682,37 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateOrderEntityRewardStatusInOrderHistoryTable() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val orderEntity = orderDetailsRepository.getOrderEntity(orderId = orderReferenceId)
|
||||
orderEntity?.let { currentOrder ->
|
||||
val updateOrderEntity =
|
||||
currentOrder.copy(
|
||||
orderDetails =
|
||||
currentOrder.orderDetails.let { currentOrderDetails ->
|
||||
currentOrderDetails.copy(
|
||||
rewardList =
|
||||
currentOrderDetails.rewardList?.map { reward ->
|
||||
if (reward.isArcReward != true) {
|
||||
reward.copy(status = RewardStatus.COMPLETE.name)
|
||||
} else {
|
||||
reward
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
orderTimestamp =
|
||||
getDateTimeObjectFromEpochString(
|
||||
epochMillis = currentOrder.orderTimestamp.millis
|
||||
),
|
||||
// updating timestamp here to maintain consistent format in
|
||||
// local db if the db entry is not updated by api response
|
||||
)
|
||||
orderDetailsRepository.updateOrder(orderEntity = updateOrderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initScratchCardLoadingProgress() {
|
||||
viewModelScope.safeLaunch(Dispatchers.IO) {
|
||||
while (scratchCardLoadingProgress.value < 0.65f) {
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.navi.pay.common.usecase.LiteAccountSyncUseCase
|
||||
import com.navi.pay.common.usecase.NaviPayConfigUseCase
|
||||
import com.navi.pay.common.utils.DeviceInfoProvider
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils.getDateTimeObjectFromEpochString
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils.getHelpCtaData
|
||||
import com.navi.pay.common.utils.getBankNameAccountNumberText
|
||||
import com.navi.pay.common.utils.getMetricInfo
|
||||
@@ -452,8 +453,6 @@ constructor(
|
||||
|
||||
updateOrderEntity(orderEntity = orderDetails)
|
||||
|
||||
updateScratchCardExpiryDate()
|
||||
|
||||
_otherUserVpa.update { orderEntity.value?.otherUserInfo.orEmpty() }
|
||||
|
||||
_orderDetailsMetadataProvider.update {
|
||||
@@ -1732,6 +1731,7 @@ constructor(
|
||||
|
||||
private fun getScratchCardStatus() {
|
||||
if (orderEntity.value?.isScratchCardPending.orFalse()) {
|
||||
updateScratchCardExpiryDate()
|
||||
pollForRewardsGratification()
|
||||
} else {
|
||||
updateScratchCardStatus(
|
||||
@@ -1786,7 +1786,13 @@ constructor(
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
orderTimestamp =
|
||||
getDateTimeObjectFromEpochString(
|
||||
epochMillis = currentOrder.orderTimestamp.millis
|
||||
),
|
||||
// updating timestamp here to maintain consistent format in
|
||||
// local db if the db entry is not updated by api response
|
||||
)
|
||||
updateOrderEntity(updatedOrder)
|
||||
}
|
||||
@@ -1836,7 +1842,13 @@ constructor(
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
orderTimestamp =
|
||||
getDateTimeObjectFromEpochString(
|
||||
epochMillis = currentOrder.orderTimestamp.millis
|
||||
),
|
||||
// updating timestamp here to maintain consistent format in
|
||||
// local db if the db entry is not updated by api response
|
||||
)
|
||||
updateOrderEntity(updatedOrder)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user