From d6d1ad93f2d03c90ec6e67cde9deddfe323fe33c Mon Sep 17 00:00:00 2001 From: yezhiqiu <983577727@qq.com> Date: Wed, 21 Jan 2026 17:40:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=A5=97=E9=A4=90=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E7=BB=AD=E8=B4=B9=E8=AE=A1=E7=AE=97=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug=202.=E4=BC=98=E5=8C=96=E5=A5=97?= =?UTF-8?q?=E9=A4=90=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BA=9A?= =?UTF-8?q?=E9=A9=AC=E9=80=8A=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E5=BD=93=E5=89=8D=E6=97=B6=E5=8C=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tracker/adapter/MySubscriptionAdapter.kt | 20 ++++++---- .../tracker/adapter/NotificationV2Adapter.kt | 11 ++++-- .../adapter/SubscriptionHistoryAdapter.kt | 21 ++++++---- .../tracker/bean/SubscriptionsOrderBean.kt | 9 +++-- .../subscribe/PaymentSuccessActivity.kt | 9 ++--- .../subscribe/SureSubscriptionPlanActivity.kt | 38 ++++++++----------- .../item_subscription_history_layout.xml | 4 +- .../com/abbidot/baselibrary/util/Utils.kt | 36 +++++++++++++----- 8 files changed, 87 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/com/abbidot/tracker/adapter/MySubscriptionAdapter.kt b/app/src/main/java/com/abbidot/tracker/adapter/MySubscriptionAdapter.kt index 7c19bed..923b2b3 100644 --- a/app/src/main/java/com/abbidot/tracker/adapter/MySubscriptionAdapter.kt +++ b/app/src/main/java/com/abbidot/tracker/adapter/MySubscriptionAdapter.kt @@ -65,7 +65,7 @@ class MySubscriptionAdapter( } holder.setText( R.id.tv_my_subscription_active_time, - Utils.stringToDate(item.updateTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN6) + Utils.formatTime(item.payTime, Utils.DATE_FORMAT_PATTERN_EN6) ) holder.getTextView(R.id.tv_my_subscription_annual_care).apply { @@ -74,13 +74,17 @@ class MySubscriptionAdapter( else mContext.getString(R.string.txt_no) } -// val timestamp = getAfterHowTimestamp( -// Utils.stringToTimestamp(item.currentTime), item.surplusDays -// ) - holder.setText( - R.id.tv_my_subscription_expires_on, - Utils.formatTime(item.endTime, Utils.DATE_FORMAT_PATTERN_EN7) - ) + holder.getTextView(R.id.tv_my_subscription_expires_on).apply { + if (item.orderStatus == 6 && item.refundTime > 0L) { + text = Utils.formatTime(item.refundTime, Utils.DATE_FORMAT_PATTERN_EN6) + } else { + text = Utils.formatTime( + Utils.timestampAddHowTimestamp( + item.payTime, item.mealPeriod, item.mealUnit + ), Utils.DATE_FORMAT_PATTERN_EN7 + ) + } + } if (item.subscriptionStatus == ConstantInt.Close) { holder.setText( diff --git a/app/src/main/java/com/abbidot/tracker/adapter/NotificationV2Adapter.kt b/app/src/main/java/com/abbidot/tracker/adapter/NotificationV2Adapter.kt index 1c20cea..78f4a5f 100644 --- a/app/src/main/java/com/abbidot/tracker/adapter/NotificationV2Adapter.kt +++ b/app/src/main/java/com/abbidot/tracker/adapter/NotificationV2Adapter.kt @@ -51,24 +51,27 @@ class NotificationV2Adapter( setTextColor(ContextCompat.getColor(mContext, textColor)) } holder.getTextView(R.id.tv_home_route_notification_date).apply { - text = getRelativeTimeString(Utils.stringToTimestamp(item.sendTime)) + text = getRelativeTimeString(item.sendTime) setTextColor(ContextCompat.getColor(mContext, textColor)) } } - private fun getRelativeTimeString(time: Long): String { + private fun getRelativeTimeString(sendTime: String): String { var formatDateStr = "" + val time = Utils.stringToTimestamp(sendTime) val now = System.currentTimeMillis() formatDateStr = if (DateUtils.isToday(time)) { mContext.getString(R.string.txt_today) + " " + Utils.formatTime( time, Utils.DATE_FORMAT_PATTERN_EN8 ) } else if (now - time < (48 * 60 * 60 * 1000)) { - mContext.getString(R.string.txt_yesterday)+ " " + Utils.formatTime( + mContext.getString(R.string.txt_yesterday) + " " + Utils.formatTime( time, Utils.DATE_FORMAT_PATTERN_EN8 ) } else { - Utils.formatTime(time, Utils.DATE_FORMAT_PATTERN_EN9) + Utils.formatTime( + Utils.stringToTimestamp(sendTime, isUtc = true), Utils.DATE_FORMAT_PATTERN_EN9 + ) } return formatDateStr } diff --git a/app/src/main/java/com/abbidot/tracker/adapter/SubscriptionHistoryAdapter.kt b/app/src/main/java/com/abbidot/tracker/adapter/SubscriptionHistoryAdapter.kt index 8ac6e71..a887d17 100644 --- a/app/src/main/java/com/abbidot/tracker/adapter/SubscriptionHistoryAdapter.kt +++ b/app/src/main/java/com/abbidot/tracker/adapter/SubscriptionHistoryAdapter.kt @@ -59,16 +59,17 @@ class SubscriptionHistoryAdapter( } holder.setText(R.id.tv_subscription_annual_care_state, state) holder.setText( - R.id.tv_subscription_annual_care_active_time, - Utils.stringToDate(item.createTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN7) + R.id.tv_subscription_annual_care_active_time, Utils.formatTime( + item.payTime, Utils.DATE_FORMAT_PATTERN_EN7 + ) ) //保险时长,不足一年按12个月算 val insuranceTime = if (item.mealUnit == ConstantString.PackageUnitYear) item.mealPeriod else 1 holder.setText( R.id.tv_subscription_annual_care_expiry_time, Utils.formatTime( - Utils.getAfterHowTimestamp( - Utils.stringToTimestamp(item.createTime), insuranceTime * 365L + Utils.timestampAddHowTimestamp( + item.payTime, insuranceTime, ConstantString.PackageUnitYear ), Utils.DATE_FORMAT_PATTERN_EN7 ) ) @@ -89,7 +90,7 @@ class SubscriptionHistoryAdapter( ) holder.setText( R.id.tv_subscription_history_order_time, - Utils.stringToDate(item.createTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN10) + Utils.formatTime(item.payTime, Utils.DATE_FORMAT_PATTERN_EN10) ) holder.setText(R.id.tv_subscription_history_package_name, item.mealName) holder.setText( @@ -109,8 +110,14 @@ class SubscriptionHistoryAdapter( 1 -> { val updateTimestamp = Utils.stringToTimestamp(item.updateTime) val nowTimestamp = System.currentTimeMillis() -// val nowTimestamp = Utils.stringToTimestamp(item.currentTime) - if (item.mealUnit == ConstantString.PackageUnitMonth) { + if (item.mealUnit == ConstantString.PackageUnitDay) { + if (item.enabled == ConstantInt.Type0 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) { + visibility = View.GONE + } else { + visibility = View.VISIBLE + setText(R.string.txt_refund) + } + } else if (item.mealUnit == ConstantString.PackageUnitMonth) { val day7Timestamp = 7 * 24 * 60 * 60 * 1000L //套餐超出7天不能退款 if (nowTimestamp - updateTimestamp <= day7Timestamp) { diff --git a/app/src/main/java/com/abbidot/tracker/bean/SubscriptionsOrderBean.kt b/app/src/main/java/com/abbidot/tracker/bean/SubscriptionsOrderBean.kt index f6fefc0..96bdbfc 100644 --- a/app/src/main/java/com/abbidot/tracker/bean/SubscriptionsOrderBean.kt +++ b/app/src/main/java/com/abbidot/tracker/bean/SubscriptionsOrderBean.kt @@ -31,7 +31,7 @@ data class SubscriptionsOrderBean( var mealDiscountPrice: Double, var orderNum: String, var orderStatus: Int,//0支付取消 1支付成功 2支付失败 3待支付 4申请审核中 5退款中 6退款成功 7退款失败 8审核失败 - var payTime: String, + var payTime: Long, var payType: Int, var planCategory: String, var planId: String, @@ -53,6 +53,7 @@ data class SubscriptionsOrderBean( var username: String, var iccid: String, var endTime: Long, + var refundTime: Long, var planTimeMonthsCount: Int, @MultipleEntity var menuType: Int, var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否 @@ -76,7 +77,7 @@ data class SubscriptionsOrderBean( 0.0, "", 0, - "", + 0L, 0, "", "", @@ -98,6 +99,7 @@ data class SubscriptionsOrderBean( "", "", 0L, + 0L, 0, menuType, 0 @@ -122,7 +124,7 @@ data class SubscriptionsOrderBean( 0.0, "", 0, - "", + 0L, 0, "", "", @@ -144,6 +146,7 @@ data class SubscriptionsOrderBean( "", "", 0L, + 0L, 0, MultipleEntity.TEXT, 0 diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/PaymentSuccessActivity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/PaymentSuccessActivity.kt index ab64c39..6d0913e 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/PaymentSuccessActivity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/PaymentSuccessActivity.kt @@ -63,13 +63,12 @@ class PaymentSuccessActivity : ivPaymentSuccessAnim.load(R.drawable.pwd_reset_successful_done) mPayResult?.let { LogUtil.e("充值类型rechargeType=${it.rechargeType}") -// if (it.rechargeType == ConstantInt.Type0) { -// btnPaymentSuccessContinue.setText(R.string.txt_continue) -// } tvPaymentSuccessDeviceId.text = it.deviceOutId - tvPaymentSuccessExpiresOnDate.text = Utils.stringToDate( - it.expirationTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN7 + tvPaymentSuccessExpiresOnDate.text = Utils.formatTime( + Utils.stringToTimestamp( + it.expirationTime, isUtc = true + ), Utils.DATE_FORMAT_PATTERN_EN6 ) val times = Utils.differYear( System.currentTimeMillis(), Utils.stringToTimestamp(it.expirationTime) diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/SureSubscriptionPlanActivity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/SureSubscriptionPlanActivity.kt index 03b43ad..d6dcf1e 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/SureSubscriptionPlanActivity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/subscribe/SureSubscriptionPlanActivity.kt @@ -2,7 +2,6 @@ package com.abbidot.tracker.ui.activity.subscribe import android.content.Intent import android.graphics.Paint -import android.text.TextUtils import android.view.Gravity import android.view.View import androidx.activity.viewModels @@ -294,20 +293,23 @@ class SureSubscriptionPlanActivity : } //判断套餐是否过期 或者套餐没退款 - if (!TextUtils.isEmpty(it.orderNum) && it.orderStatus != 6 && it.surplusDays == 0L && it.subscriptionStatus == ConstantInt.Close) { -// mOrderBean?.reactivation = 1 - mSubscriptionViewModel.getReactivationFee(it.orderNum) - } else { - if (isUpgrade) mSubscriptionViewModel.getReactivationFee(it.orderNum) - else { - mOrderBean?.reactivation = 0 - mOrderBean?.reactivatePrice = 0.0 - updateMoney() - } - } +// if (!TextUtils.isEmpty(it.orderNum) && it.orderStatus != 6 && it.surplusDays == 0L && it.subscriptionStatus == ConstantInt.Close) { +//// mOrderBean?.reactivation = 1 +// mSubscriptionViewModel.getReactivationFee(it.orderNum) +// } else { +// if (isUpgrade) mSubscriptionViewModel.getReactivationFee(it.orderNum) +// else { +// mOrderBean?.reactivation = 0 +// mOrderBean?.reactivatePrice = 0.0 +// updateMoney() +// } +// } + mOrderBean?.reactivation = 0 + mOrderBean?.reactivatePrice = 0.0 + updateMoney() //隐藏保险 - mViewBinding.ilSubscribePlanInsurance.cbSureSubscribeInsureSwitch.isChecked=false + mViewBinding.ilSubscribePlanInsurance.cbSureSubscribeInsureSwitch.isChecked = false } } @@ -327,16 +329,6 @@ class SureSubscriptionPlanActivity : mReactivationFeeLiveData.observe(this@SureSubscriptionPlanActivity) { dealRequestResult(it, object : GetResultCallback { override fun onResult(any: Any) { -// it.getOrNull()?.apply { -// mOrderBean?.reactivatePrice = this -// mSummaryAdapter.getData().add( -// 2, MenuTxtBean( -// getString(R.string.txt_reactivation), Utils.formatDecimal(this, 1) -// ).apply { -// colorRedId = R.color.data_black_color -// }) -// mTotalMoney += this -// } it.getOrNull()?.apply { mPackageBean?.let { p -> mTotalMoney -= mSumInsuranceMoney diff --git a/app/src/main/res/layout/item_subscription_history_layout.xml b/app/src/main/res/layout/item_subscription_history_layout.xml index 1bd390b..6747585 100644 --- a/app/src/main/res/layout/item_subscription_history_layout.xml +++ b/app/src/main/res/layout/item_subscription_history_layout.xml @@ -38,6 +38,7 @@ style="@style/my_TextView_style_v2" android:layout_below="@id/tv_subscription_history_order_time" android:text="@string/txt_annual_care_text1" + android:visibility="gone" android:layout_marginTop="@dimen/dp_4" android:textSize="@dimen/textSize14" android:textStyle="bold" /> @@ -49,13 +50,14 @@ android:layout_marginStart="@dimen/dp_4" android:layout_toEndOf="@id/tv_subscription_history_annual_care_title" android:text="@string/app_name" + android:visibility="gone" android:textSize="@dimen/textSize14" app:typeface="@string/roboto_regular_font" /> calendar.add(Calendar.DAY_OF_MONTH, period) + "MONTH" -> calendar.add(Calendar.MONTH, period) + "YEAR" -> calendar.add(Calendar.YEAR, period) + } + return calendar.timeInMillis + } + /** * 获取这个时间戳的,前几天13位时间戳 */ @@ -134,7 +150,7 @@ class Utils { val period = Period.between(LocalDate.parse(startDate), LocalDate.parse(endDate)) result[0] = "${period.years}" result[1] = "${period.months}" - result[2] = "${if(period.days<0) 0 else period.days}" + result[2] = "${if (period.days < 0) 0 else period.days}" } else { val dfs = SimpleDateFormat(DATE_FORMAT_PATTERN_CN, Locale.getDefault()) val sDate = dfs.parse(startDate)!! @@ -162,7 +178,7 @@ class Utils { } result[0] = "$years" result[1] = "$months" - result[2] = "${if(days<0) 0 else days}" + result[2] = "${if (days < 0) 0 else days}" } return result }