套餐优化
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.abbidot.tracker.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Paint
|
||||
import android.view.View
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.list.RecyclerViewHolder
|
||||
@@ -9,7 +8,6 @@ import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.bean.PackageBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2024/8/6/006.
|
||||
@@ -32,49 +30,31 @@ class ChoosePlanAdapter(
|
||||
|
||||
setText(R.id.tv_choose_plan_item_name, item.planName)
|
||||
|
||||
val price = if (item.discountedPrice > 0) item.discountedPrice else item.planPrice
|
||||
// val price = if (item.discountedPrice > 0) item.discountedPrice else item.planPrice
|
||||
getTextView(R.id.tv_choose_plan_item_money).apply {
|
||||
text = if (item.mealUnit == ConstantString.PackageUnitMonth) {
|
||||
String.format(
|
||||
mContext.getString(R.string.txt_money_unit), Utils.formatDecimal(price, 2)
|
||||
)
|
||||
} else {
|
||||
val monthPrice = Utils.formatDecimal(price / (item.period * 12), 2)
|
||||
String.format(mContext.getString(R.string.txt_money_unit), monthPrice)
|
||||
}
|
||||
}
|
||||
|
||||
getTextView(R.id.tv_choose_plan_item_year_money).let {
|
||||
it.text = String.format(
|
||||
text = String.format(
|
||||
mContext.getString(R.string.txt_money_unit),
|
||||
Utils.formatDecimal(item.discountedPrice, 2)
|
||||
Utils.formatDecimal(item.planPrice / item.planTimeMonthsCount, 1)
|
||||
)
|
||||
|
||||
it.visibility = if (item.discount > 0) View.VISIBLE
|
||||
else View.GONE
|
||||
}
|
||||
|
||||
getTextView(R.id.tv_choose_plan_item_discount_money).let {
|
||||
it.text = String.format(
|
||||
mContext.getString(R.string.txt_money_unit),
|
||||
Utils.formatDecimal(item.planPrice, 2)
|
||||
)
|
||||
it.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
|
||||
it.visibility = if (item.discount > 0) View.VISIBLE
|
||||
else View.GONE
|
||||
}
|
||||
getTextView(R.id.tv_choose_plan_item_plan_money).text = String.format(
|
||||
mContext.getString(R.string.txt_money_unit), "${item.planPrice}"
|
||||
)
|
||||
|
||||
getTextView(R.id.tv_choose_plan_item_billed_money).text = item.billedMode
|
||||
|
||||
|
||||
getView(R.id.ll_choose_plan_item_discount_percent).let {
|
||||
it.visibility = if (item.discount > 0) View.VISIBLE
|
||||
else View.GONE
|
||||
}
|
||||
getTextView(R.id.tv_choose_plan_item_discount_percent).let {
|
||||
it.text = "${item.discount}%"
|
||||
it.visibility = if (item.popularType == ConstantInt.Type1) View.VISIBLE
|
||||
else View.INVISIBLE
|
||||
}
|
||||
// getTextView(R.id.tv_choose_plan_item_discount_percent).let {
|
||||
// it.text = "${item.discount}%"
|
||||
// }
|
||||
|
||||
getView(R.id.cv_choose_plan_item_popular).let {
|
||||
if (item.popularType == ConstantInt.Type1) it.visibility = View.VISIBLE
|
||||
if (item.popularType == ConstantInt.Type1) it.visibility = View.GONE
|
||||
else it.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.content.Context
|
||||
import android.widget.RelativeLayout
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.list.RecyclerViewHolder
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.bean.PackageTypeBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2024/3/19/019.
|
||||
@@ -32,10 +32,16 @@ class SubscriptionPlanAdapter(
|
||||
relativeLayout.setBackgroundResource(0)
|
||||
// popularCardView.visibility = View.GONE
|
||||
}
|
||||
holder.setText(R.id.tv_subscribe_plan_item_name, item.name)
|
||||
|
||||
val packageName = when (item.nameCode) {
|
||||
ConstantInt.Type1 -> mContext.getString(R.string.txt_basic)
|
||||
ConstantInt.Type2 -> mContext.getString(R.string.txt_premium)
|
||||
else -> item.name
|
||||
}
|
||||
holder.setText(R.id.tv_subscribe_plan_item_name, packageName)
|
||||
holder.setText(
|
||||
R.id.tv_subscribe_plan_item_money,
|
||||
String.format(mContext.getString(R.string.txt_money_unit), Utils.formatDecimal( item.price, 2))
|
||||
String.format(mContext.getString(R.string.txt_money_unit), "${item.price}")
|
||||
)
|
||||
// subscription.text =
|
||||
// String.format(mContext.getString(R.string.txt_per_year_money), item.subscriptionFee)
|
||||
|
||||
@@ -25,7 +25,19 @@ class SubscriptionPlanDetailAdapter(
|
||||
checkBox.setOnClickListener {
|
||||
checkBox.isChecked = !checkBox.isChecked
|
||||
}
|
||||
holder.setText(R.id.tv_subscribe_plan_detail_name, item.title)
|
||||
val titleName = when (item.titleCode) {
|
||||
ConstantInt.Type1 -> mContext.getString(R.string.txt_real_time_tracking)
|
||||
ConstantInt.Type2 -> mContext.getString(R.string.txt_activity_logs)
|
||||
ConstantInt.Type3 -> mContext.getString(R.string.txt_notifications_emergencies)
|
||||
ConstantInt.Type4 -> mContext.getString(R.string.txt_customized_led)
|
||||
5 -> mContext.getString(R.string.txt_bluetooth_radar)
|
||||
6 -> mContext.getString(R.string.txt_geofencing)
|
||||
7 -> mContext.getString(R.string.txt_route_records)
|
||||
8 -> mContext.getString(R.string.txt_family_sharing)
|
||||
9 -> mContext.getString(R.string.txt_customer_support)
|
||||
else -> item.title
|
||||
}
|
||||
holder.setText(R.id.tv_subscribe_plan_detail_name, titleName)
|
||||
checkBox.isChecked = item.status == ConstantInt.Open
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,8 @@ data class PackageBean(
|
||||
var planPrice: Double,
|
||||
var discount: Int,
|
||||
var active: Int,
|
||||
var planTimeMonthsCount: Int,
|
||||
var everyMonthSafeFee: Double,
|
||||
var billedMode: String,
|
||||
var selected: Boolean
|
||||
) : Parcelable
|
||||
|
||||
@@ -5,4 +5,4 @@ package com.abbidot.tracker.bean
|
||||
* @link
|
||||
* @description:
|
||||
*/
|
||||
data class PackageBenefitsBean(var title: String, var status: Int)
|
||||
data class PackageBenefitsBean(var title: String, var status: Int, var titleCode: Int)
|
||||
|
||||
@@ -10,5 +10,6 @@ data class PackageTypeBean(
|
||||
var name: String,
|
||||
var packageId: String,
|
||||
var list: MutableList<PackageBenefitsBean>?,
|
||||
var selected: Boolean
|
||||
var selected: Boolean,
|
||||
val nameCode: Int,
|
||||
)
|
||||
|
||||
@@ -50,6 +50,7 @@ data class SubscriptionsOrderBean(
|
||||
var username: String,
|
||||
var iccid: String,
|
||||
var endTime: Long,
|
||||
var planTimeMonthsCount: Int,
|
||||
var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否
|
||||
) : Parcelable {
|
||||
constructor() : this(
|
||||
@@ -93,6 +94,7 @@ data class SubscriptionsOrderBean(
|
||||
"",
|
||||
"",
|
||||
0L,
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1302,6 +1302,7 @@ interface INetworkService {
|
||||
@Field("customerId") customerId: String,
|
||||
@Field("orderNum") orderNum: String,
|
||||
@Field("isUpdateOrder") isUpdateOrder: Int,
|
||||
@Field("planTimeMonthsCount") planTimeMonthsCount: Int,
|
||||
@Field("subscriptionId") subscriptionId: String
|
||||
): BaseResponse<PayResultBean>
|
||||
|
||||
@@ -1338,6 +1339,7 @@ interface INetworkService {
|
||||
@Field("customerId") customerId: String,
|
||||
@Field("orderNum") orderNum: String,
|
||||
@Field("isUpdateOrder") isUpdateOrder: Int,
|
||||
@Field("planTimeMonthsCount") planTimeMonthsCount: Int,
|
||||
@Field("subscriptionId") subscriptionId: String
|
||||
): BaseResponse<PayResultBean>
|
||||
|
||||
|
||||
@@ -1185,6 +1185,7 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
customerId,
|
||||
orderNum,
|
||||
isUpdateOrder,
|
||||
planTimeMonthsCount,
|
||||
subscriptionId
|
||||
)
|
||||
}
|
||||
@@ -1226,6 +1227,7 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
"",
|
||||
orderNum,
|
||||
isUpdateOrder,
|
||||
planTimeMonthsCount,
|
||||
subscriptionId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,21 +9,30 @@ import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.SubscriptionsOrderBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityAddPairedSuccessBinding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.AddTrackerDeviceViewModel
|
||||
import com.abbidot.tracker.ui.activity.pet.first.FirstSetPetTypeActivity
|
||||
import com.abbidot.tracker.ui.activity.device.wifi.AddWifiPowerZone1Activity
|
||||
import com.abbidot.tracker.ui.activity.subscribe.SubscriptionPlanActivity
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.vm.PetInfoViewModel
|
||||
import com.abbidot.tracker.vm.PetRelationViewModel
|
||||
import com.abbidot.tracker.vm.UserProfileViewModel
|
||||
|
||||
class AddPairedSuccessActivity :
|
||||
BaseActivity<ActivityAddPairedSuccessBinding>(ActivityAddPairedSuccessBinding::inflate) {
|
||||
|
||||
private val mAddTrackerViewModel: AddTrackerDeviceViewModel by viewModels()
|
||||
private val mPetViewModel: PetInfoViewModel by viewModels()
|
||||
private val mUserProfileViewModel: UserProfileViewModel by viewModels()
|
||||
private val mPetRelationViewModel: PetRelationViewModel by viewModels()
|
||||
|
||||
private lateinit var mSubscriptionsOrderBean: SubscriptionsOrderBean
|
||||
|
||||
@@ -31,6 +40,7 @@ class AddPairedSuccessActivity :
|
||||
private var mDeviceOutId = ""
|
||||
private var mDeviceId = ""
|
||||
private var mMac = ""
|
||||
private var mPetBean: PetBean? = null
|
||||
|
||||
override fun getTopBar() = mViewBinding.ilAddPairedSuccessTopBar.titleTopBar
|
||||
|
||||
@@ -111,17 +121,18 @@ class AddPairedSuccessActivity :
|
||||
|
||||
//更新设备绑定状态
|
||||
mUpdatePayDeviceStateLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
MMKVUtil.putInt(MMKVKey.isBindDevice, ConstantInt.isBind)
|
||||
XEventBus.post(EventName.RefreshDevice)
|
||||
if (isFirstBind) {
|
||||
val intent = Intent(mContext, FirstSetPetTypeActivity::class.java)
|
||||
intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
startActivityFinish(intent)
|
||||
}
|
||||
finish()
|
||||
mUserProfileViewModel.updateMeasureUnit(
|
||||
this@AddPairedSuccessActivity, ConstantInt.Type1
|
||||
)
|
||||
// val intent = Intent(mContext, FirstSetPetTypeActivity::class.java)
|
||||
// intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
// startActivityFinish(intent)
|
||||
} else finish()
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
@@ -136,6 +147,78 @@ class AddPairedSuccessActivity :
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//默认单位设置
|
||||
mUserProfileViewModel.mUpdateMeasureUnitLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
MMKVUtil.putInt(MMKVKey.MeasureUnit, ConstantInt.Type1)
|
||||
PetBean().let { pet ->
|
||||
pet.petName = "My Pet"
|
||||
pet.deviceId = mDeviceId
|
||||
pet.petType = ConstantInt.DogPetType
|
||||
pet.gender = ConstantInt.WoMan
|
||||
pet.macID = mMac
|
||||
pet.birthdayDate = "2024-01-01"
|
||||
pet.height = Utils.formatDecimal(Util.inToCm(20.0), 1).toFloat()
|
||||
pet.weight = Utils.formatDecimal(Util.lbsToKg(25.0), 1).toFloat()
|
||||
mPetBean = pet
|
||||
mPetViewModel.addPet(this@AddPairedSuccessActivity, pet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
}
|
||||
})
|
||||
}
|
||||
//添加默认宠物
|
||||
mPetViewModel.mAddPetLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.let { pet ->
|
||||
mPetBean?.let { petBean ->
|
||||
petBean.petId = pet.petId
|
||||
mPetRelationViewModel.bindPet(
|
||||
this@AddPairedSuccessActivity, petBean.deviceId, petBean.petId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
}
|
||||
})
|
||||
}
|
||||
//绑定默认宠物
|
||||
mPetRelationViewModel.mBindPetLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
XEventBus.post(EventName.RefreshPet)
|
||||
showToast(R.string.txt_bind_success, isFinish = true)
|
||||
mViewBinding.root.postDelayed({
|
||||
MMKVUtil.putInt(MMKVKey.isBindPet, ConstantInt.isBind)
|
||||
mPetBean?.apply {
|
||||
val intent = Intent(mContext, AddWifiPowerZone1Activity::class.java)
|
||||
intent.putExtra(ConstantString.Pet, this)
|
||||
intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
startActivity(intent)
|
||||
}
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,13 @@ class ChoosePlanActivity :
|
||||
if (isUpgrade) {
|
||||
mRechargeType = ConstantInt.Type2
|
||||
setTopBarTitle(R.string.txt_upgrade_plan)
|
||||
} else setTopBarTitle(R.string.txt_choose_your_plan)
|
||||
} else {
|
||||
if (packageTypeName == "Basic") {
|
||||
setTopBarTitle(R.string.txt_basic_plan)
|
||||
} else {
|
||||
setTopBarTitle(R.string.txt_premium_plan)
|
||||
}
|
||||
}
|
||||
setLeftBackImage(R.drawable.icon_white_back_svg)
|
||||
|
||||
mViewBinding.apply {
|
||||
|
||||
@@ -18,18 +18,22 @@ import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.BleTrackDeviceBean
|
||||
import com.abbidot.tracker.bean.PayResultBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityPaymentSuccessBinding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.AddTrackerDeviceViewModel
|
||||
import com.abbidot.tracker.ui.activity.pet.first.FirstSetPetTypeActivity
|
||||
import com.abbidot.tracker.ui.activity.device.wifi.AddWifiPowerZone1Activity
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.ConnectionDeviceViewModel
|
||||
import com.abbidot.tracker.vm.PetInfoViewModel
|
||||
import com.abbidot.tracker.vm.PetRelationViewModel
|
||||
import com.abbidot.tracker.vm.UserProfileViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
|
||||
class PaymentSuccessActivity :
|
||||
@@ -37,9 +41,13 @@ class PaymentSuccessActivity :
|
||||
|
||||
private val mAddTrackerViewModel: AddTrackerDeviceViewModel by viewModels()
|
||||
private val mConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels()
|
||||
private val mUserProfileViewModel: UserProfileViewModel by viewModels()
|
||||
private val mPetRelationViewModel: PetRelationViewModel by viewModels()
|
||||
private val mPetViewModel: PetInfoViewModel by viewModels()
|
||||
|
||||
private var mPayResult: PayResultBean? = null
|
||||
private var mMac = ""
|
||||
private var mPetBean: PetBean? = null
|
||||
|
||||
override fun getTopBar() = null
|
||||
|
||||
@@ -158,6 +166,61 @@ class PaymentSuccessActivity :
|
||||
}
|
||||
})
|
||||
}
|
||||
//默认单位设置
|
||||
mUserProfileViewModel.mUpdateMeasureUnitLiveData.observe(this@PaymentSuccessActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
MMKVUtil.putInt(MMKVKey.MeasureUnit, ConstantInt.Type1)
|
||||
PetBean().let { pet ->
|
||||
pet.petName = "My Pet"
|
||||
pet.deviceId = mPayResult!!.deviceId
|
||||
pet.petType = ConstantInt.DogPetType
|
||||
pet.gender = ConstantInt.WoMan
|
||||
pet.macID=mMac
|
||||
pet.birthdayDate = "2024-01-01"
|
||||
pet.height = Utils.formatDecimal(Util.inToCm(20.0), 1).toFloat()
|
||||
pet.weight = Utils.formatDecimal(Util.lbsToKg(25.0), 1).toFloat()
|
||||
mPetBean = pet
|
||||
mPetViewModel.addPet(this@PaymentSuccessActivity, pet)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//添加默认宠物
|
||||
mPetViewModel.mAddPetLiveData.observe(this@PaymentSuccessActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.let { pet ->
|
||||
mPetBean?.let { petBean ->
|
||||
petBean.petId = pet.petId
|
||||
mPetRelationViewModel.bindPet(
|
||||
this@PaymentSuccessActivity, petBean.deviceId, petBean.petId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//绑定默认宠物
|
||||
mPetRelationViewModel.mBindPetLiveData.observe(this@PaymentSuccessActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
XEventBus.post(EventName.RefreshPet)
|
||||
showToast(R.string.txt_bind_success, isFinish = true)
|
||||
mViewBinding.root.postDelayed({
|
||||
MMKVUtil.putInt(MMKVKey.isBindPet, ConstantInt.isBind)
|
||||
mPetBean?.apply {
|
||||
val intent = Intent(mContext, AddWifiPowerZone1Activity::class.java)
|
||||
intent.putExtra(ConstantString.Pet, this)
|
||||
intent.putExtra(ConstantString.isFirstBind, true)
|
||||
startActivity(intent)
|
||||
}
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,12 +235,15 @@ class PaymentSuccessActivity :
|
||||
XEventBus.post(EventName.PayBack)
|
||||
mPayResult?.let {
|
||||
if (it.rechargeType == ConstantInt.Type0) {
|
||||
val intent = Intent(mContext, FirstSetPetTypeActivity::class.java)
|
||||
intent.putExtra(ConstantString.isFirstBind, true)
|
||||
startActivity(intent)
|
||||
}
|
||||
mUserProfileViewModel.updateMeasureUnit(
|
||||
this@PaymentSuccessActivity, ConstantInt.Type1
|
||||
)
|
||||
|
||||
// val intent = Intent(mContext, FirstSetPetTypeActivity::class.java)
|
||||
// intent.putExtra(ConstantString.isFirstBind, true)
|
||||
// startActivity(intent)
|
||||
} else finish()
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class SubscriptionPlanActivity :
|
||||
mPlanAdapter,
|
||||
2,
|
||||
AppUtils.dpToPx(140),
|
||||
offset = AppUtils.dpToPx(44)
|
||||
offset = AppUtils.dpToPx(66)
|
||||
)
|
||||
|
||||
ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
|
||||
|
||||
@@ -37,7 +37,7 @@ class SureSubscriptionPlanActivity :
|
||||
private var mOrderBean: SubscriptionsOrderBean? = null
|
||||
|
||||
//每年的保险服务费用
|
||||
private val mInsuranceMoney = 12.90
|
||||
// private val mInsuranceMoney = 12.90
|
||||
|
||||
//保险总费用
|
||||
private var mSumInsuranceMoney = 0.0
|
||||
@@ -88,7 +88,7 @@ class SureSubscriptionPlanActivity :
|
||||
val totalDay = if (it.mealUnit == ConstantString.PackageUnitYear) {
|
||||
it.mealPeriod * 365
|
||||
} else {
|
||||
30
|
||||
30 * it.planTimeMonthsCount
|
||||
}
|
||||
mResidualMoney =
|
||||
((it.totalAmountWithTax - it.tax - it.reactivatePrice) / totalDay) * it.surplusDays
|
||||
@@ -110,68 +110,94 @@ class SureSubscriptionPlanActivity :
|
||||
val nowTimestamp = System.currentTimeMillis()
|
||||
|
||||
mPackageBean?.let { p ->
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanPer.text = String.format(
|
||||
getString(R.string.txt_month_unit), "${p.planTimeMonthsCount}"
|
||||
)
|
||||
val renewalString = if (p.mealUnit == ConstantString.PackageUnitYear) {
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanPer.text =
|
||||
String.format(getString(R.string.txt_year_unit), p.period)
|
||||
// ilSubscribePlanDetail.tvSureSubscribePlanPer.text =
|
||||
// String.format(getString(R.string.txt_year_unit), p.period)
|
||||
val renewalTimestamp =
|
||||
Utils.getAfterHowTimestamp(nowTimestamp, p.period * 365L)
|
||||
val renewalDate =
|
||||
Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7)
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_year),
|
||||
Utils.formatDecimal(p.autoRenewPrice, 2),
|
||||
renewalDate
|
||||
)
|
||||
if (p.period > 1) {
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_years),
|
||||
"${p.autoRenewPrice}",
|
||||
"${p.period}",
|
||||
renewalDate
|
||||
)
|
||||
} else {
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_year),
|
||||
"${p.autoRenewPrice}",
|
||||
renewalDate
|
||||
)
|
||||
}
|
||||
} else {
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanPer.text =
|
||||
String.format(getString(R.string.txt_month_unit), p.period)
|
||||
val renewalTimestamp = Utils.getAfterHowTimestamp(nowTimestamp, 30L)
|
||||
val renewalTimestamp =
|
||||
Utils.getAfterHowTimestamp(nowTimestamp, 30L * p.planTimeMonthsCount)
|
||||
val renewalDate =
|
||||
Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7)
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_month),
|
||||
Utils.formatDecimal(p.autoRenewPrice, 2),
|
||||
renewalDate
|
||||
)
|
||||
if (p.planTimeMonthsCount > 1) {
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_months),
|
||||
"${p.autoRenewPrice}",
|
||||
"${p.planTimeMonthsCount}",
|
||||
renewalDate
|
||||
)
|
||||
} else {
|
||||
String.format(
|
||||
getString(R.string.txt_renewal_month),
|
||||
"${p.autoRenewPrice}",
|
||||
renewalDate
|
||||
)
|
||||
}
|
||||
}
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanUnderused.text = renewalString
|
||||
|
||||
val insuranceMoneyString =
|
||||
"${p.period} x $${Utils.formatDecimal(mInsuranceMoney, 2)}"
|
||||
ilSubscribePlanInsurance.tvSureSubscribePlanInsurancePer.text =
|
||||
insuranceMoneyString
|
||||
|
||||
val packageName = "${p.planName}(${p.planCategory})"
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanName.text = packageName
|
||||
val price = if (p.discountedPrice > 0.0) p.discountedPrice else p.planPrice
|
||||
val price = p.planPrice
|
||||
// val price = if (p.discountedPrice > 0.0) p.discountedPrice else p.planPrice
|
||||
val priceString = String.format(
|
||||
getString(R.string.txt_money_unit), Utils.formatDecimal(price, 2)
|
||||
getString(R.string.txt_money_unit),
|
||||
Utils.formatDecimal(price / p.planTimeMonthsCount, 1)
|
||||
)
|
||||
ilSubscribePlanDetail.tvSureSubscribePlanMoney.text = priceString
|
||||
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mSummaryAdapter.getData(),
|
||||
p.planName,
|
||||
Utils.formatDecimal(price, 2),
|
||||
"$price",
|
||||
colorRedId = R.color.data_black_color
|
||||
)
|
||||
mTotalMoney += price
|
||||
mSumInsuranceMoney =
|
||||
Utils.formatDecimal(mInsuranceMoney * p.period, 2).toDouble()
|
||||
Utils.formatDecimal(p.everyMonthSafeFee * p.period * 12, 1).toDouble()
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mSummaryAdapter.getData(),
|
||||
getString(R.string.txt_annual_care_text),
|
||||
Utils.formatDecimal(mSumInsuranceMoney, 2),
|
||||
"$mSumInsuranceMoney",
|
||||
colorRedId = R.color.data_black_color
|
||||
)
|
||||
mTotalMoney += mSumInsuranceMoney
|
||||
|
||||
val insuranceMoneyString =
|
||||
String.format(getString(R.string.txt_month_unit), "${p.period * 12}")
|
||||
ilSubscribePlanInsurance.tvSureSubscribePlanInsurancePer.text =
|
||||
insuranceMoneyString
|
||||
ilSubscribePlanInsurance.tvSureSubscribePlanInsurancePerMoney.text =
|
||||
String.format(getString(R.string.txt_money_unit), "${p.everyMonthSafeFee}")
|
||||
ilSubscribePlanInsurance.tvSureSubscribePlanInsuranceMoney.text =
|
||||
String.format(getString(R.string.txt_money_unit), "$mSumInsuranceMoney")
|
||||
|
||||
if (isUpgrade) {
|
||||
mTotalMoney -= mResidualMoney
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mSummaryAdapter.getData(),
|
||||
getString(R.string.txt_residual_value),
|
||||
Utils.formatDecimal(mResidualMoney, 2),
|
||||
Utils.formatDecimal(mResidualMoney, 1),
|
||||
colorRedId = R.color.red_color5,
|
||||
isSwitch = true
|
||||
)
|
||||
@@ -209,8 +235,7 @@ class SureSubscriptionPlanActivity :
|
||||
val list = mSummaryAdapter.getData()
|
||||
if (isChecked) {
|
||||
MenuTxtBean(
|
||||
getString(R.string.txt_annual_care_text),
|
||||
Utils.formatDecimal(mSumInsuranceMoney, 2)
|
||||
getString(R.string.txt_annual_care_text), "$mSumInsuranceMoney"
|
||||
).let {
|
||||
it.colorRedId = R.color.data_black_color
|
||||
list.add(1, it)
|
||||
@@ -245,15 +270,16 @@ class SureSubscriptionPlanActivity :
|
||||
mSubscriptionViewModel.mReactivationFeeLiveData.observe(this) {
|
||||
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, 2)
|
||||
).apply {
|
||||
colorRedId = R.color.data_black_color
|
||||
})
|
||||
mTotalMoney += this
|
||||
}
|
||||
// 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
|
||||
// }
|
||||
updateMoney()
|
||||
}
|
||||
})
|
||||
@@ -263,14 +289,14 @@ class SureSubscriptionPlanActivity :
|
||||
private fun updateMoney() {
|
||||
mViewBinding.apply {
|
||||
val list = mSummaryAdapter.getData()
|
||||
val taxMoney = Utils.formatDecimal(mTaxRate * mTotalMoney, 2).toDouble()
|
||||
val taxMoney = Utils.formatDecimal(mTaxRate * mTotalMoney, 1).toDouble()
|
||||
mOrderBean?.tax = taxMoney
|
||||
list[list.size - 1].menuValue = taxMoney.toString()
|
||||
mTotalWithTaxMoney = taxMoney + mTotalMoney
|
||||
mTotalWithTaxMoney = abs(mTotalWithTaxMoney)
|
||||
ilSubscribePlanSummary.ilSureSubscribePlanTotalLayout.tvSubscribeSummaryItemMoney.text =
|
||||
String.format(
|
||||
getString(R.string.txt_money_unit), Utils.formatDecimal(mTotalWithTaxMoney, 2)
|
||||
getString(R.string.txt_money_unit), Utils.formatDecimal(mTotalWithTaxMoney, 1)
|
||||
)
|
||||
mSummaryAdapter.notifyItemRangeChanged(0, list.size)
|
||||
|
||||
@@ -303,14 +329,15 @@ class SureSubscriptionPlanActivity :
|
||||
mealName = cPlan.planName
|
||||
mealId = cPlan.mealId
|
||||
mealPeriod = cPlan.period
|
||||
planTimeMonthsCount = cPlan.planTimeMonthsCount
|
||||
mealUnit = cPlan.mealUnit
|
||||
planCategory = cPlan.planCategory
|
||||
// autoRenewPrice = Utils.formatDecimal(cPlan.autoRenewPrice * mTaxRate, 2).toDouble()
|
||||
// autoRenewPrice = Utils.formatDecimal(cPlan.autoRenewPrice * mTaxRate, 1).toDouble()
|
||||
autoRenewPrice = cPlan.autoRenewPrice
|
||||
mealDesc =
|
||||
mViewBinding.ilSubscribePlanDetail.tvSureSubscribePlanMoney.text.toString() + mViewBinding.ilSubscribePlanDetail.tvSureSubscribePlanPer.text.toString()
|
||||
}
|
||||
totalAmountWithTax = Utils.formatDecimal(mTotalWithTaxMoney, 2).toDouble()
|
||||
totalAmountWithTax = Utils.formatDecimal(mTotalWithTaxMoney, 1).toDouble()
|
||||
Intent(mContext, PaymentMethodActivity::class.java).let {
|
||||
it.putExtra(ConstantString.LkSetMeal, this)
|
||||
it.putExtra(ConstantString.RechargeType, mRechargeType)
|
||||
|
||||
@@ -157,7 +157,7 @@ class Util {
|
||||
return value * 0.3937
|
||||
}
|
||||
|
||||
private fun inToCm(value: Double): Double {
|
||||
fun inToCm(value: Double): Double {
|
||||
return value * 2.54
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ class Util {
|
||||
return value * 2.2065
|
||||
}
|
||||
|
||||
private fun lbsToKg(value: Double): Double {
|
||||
fun lbsToKg(value: Double): Double {
|
||||
return value * 0.4532
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user