修复企业会员价格显示错误的问题,2.8.0/280
This commit is contained in:
parent
3fa6df53bf
commit
9dda10f1d4
|
|
@ -227,11 +227,15 @@ MineFragment : BaseFragment<FragmentMineBinding, MineViewModel>() {
|
|||
error(R.mipmap.ic_default_avatar)
|
||||
}
|
||||
|
||||
if (userInfo?.vip == "1" || userInfo?.vip == "10") {
|
||||
if (userInfo?.vip == "1") {
|
||||
isEnterprise = false
|
||||
|
||||
binding.tvVipName.text = "开通会员"
|
||||
if (!TextUtils.isEmpty(userInfo!!.vip_expire)) {
|
||||
binding.tvExpireTime.text = "已于 ${userInfo!!.vip_expire} 过期"
|
||||
} else {
|
||||
binding.tvExpireTime.text = "开通会员,查看海量商机"
|
||||
}
|
||||
|
||||
binding.tvVipName.setTextColor(getColor(R.color.color_fbcd8c))
|
||||
binding.tvExpireTime.setTextColor(getColor(R.color.color_bcac8e))
|
||||
|
|
@ -269,6 +273,24 @@ MineFragment : BaseFragment<FragmentMineBinding, MineViewModel>() {
|
|||
val vipBgLp = binding.ivVipBg.layoutParams as ConstraintLayout.LayoutParams
|
||||
vipBgLp.dimensionRatio = "h,1029:342"
|
||||
binding.ivVipBg.layoutParams = vipBgLp
|
||||
} else if (userInfo?.vip == "10") {
|
||||
isEnterprise = false
|
||||
|
||||
binding.tvVipName.text = "开通会员"
|
||||
if (!TextUtils.isEmpty(userInfo!!.vip_expire)) {
|
||||
binding.tvExpireTime.text = "已于 ${userInfo!!.vip_expire} 过期"
|
||||
} else {
|
||||
binding.tvExpireTime.text = "开通会员,查看海量商机"
|
||||
}
|
||||
|
||||
binding.tvVipName.setTextColor(getColor(R.color.color_c5ffe1))
|
||||
binding.tvExpireTime.setTextColor(getColor(R.color.color_a6c8ba))
|
||||
binding.tvExpireTime.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.mipmap.ic_mine_arrow2, 0)
|
||||
binding.ivVipBg.setImageResource(R.mipmap.ic_mine_vip_bg2)
|
||||
|
||||
val vipBgLp = binding.ivVipBg.layoutParams as ConstraintLayout.LayoutParams
|
||||
vipBgLp.dimensionRatio = "h,1029:309"
|
||||
binding.ivVipBg.layoutParams = vipBgLp
|
||||
} else if (userInfo?.vip == "12") {
|
||||
isEnterprise = true
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import com.cheng.blzb.manager.DialogEnum
|
|||
import com.cheng.blzb.manager.EventReportManager
|
||||
import com.cheng.blzb.manager.LoginManager
|
||||
import com.cheng.blzb.manager.UserConfigManager
|
||||
import com.cheng.blzb.ui.activity.MainActivity
|
||||
import com.cheng.blzb.ui.activity.PublicActivity
|
||||
import com.cheng.blzb.ui.dialog.CouponActivityDialog
|
||||
import com.cheng.blzb.ui.dialog.GoodsPromotionDialog
|
||||
|
|
@ -165,6 +164,8 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
}
|
||||
|
||||
goodsAdapter.setOnItemClickListener { _, _, i ->
|
||||
selectedCoupon = null
|
||||
|
||||
val item = goodsAdapter.getItem(i)
|
||||
if (item.goods_id == goodsEntity?.goods_id) return@setOnItemClickListener
|
||||
goodsAdapter.data.forEach { it.checked = it.goods_id == item.goods_id }
|
||||
|
|
@ -179,16 +180,15 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
.append("(原¥${DecimalFormat("0.##").format(goodsEntity!!.origin_member_price.toFloat())})")
|
||||
.setStrikethrough()
|
||||
.create()
|
||||
setSeatCount()
|
||||
|
||||
seatPrice = (seatCount - seatCountLimit) * (goodsEntity?.member_price?.toFloat() ?: 0f)
|
||||
setPrice(goodsEntity!!.price.toFloat() + seatPrice)
|
||||
setSeatCount()
|
||||
setPriceWithCoupon()
|
||||
|
||||
binding.ivSubtract.setImageResource(if (seatCount > seatCountLimit) R.mipmap.ic_subtract_count_enable else R.mipmap.ic_subtract_count_disable)
|
||||
} else {
|
||||
setPrice(goodsEntity!!.price.toFloat())
|
||||
setPriceWithCoupon()
|
||||
}
|
||||
releasePayType()
|
||||
selectedCoupon = null
|
||||
setCoupon()
|
||||
}
|
||||
|
||||
binding.btnTab1.onClick {
|
||||
|
|
@ -206,22 +206,20 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
}
|
||||
|
||||
binding.ivAdd.onClick {
|
||||
if (goodsEntity == null) return@onClick
|
||||
seatCount++
|
||||
setSeatCount()
|
||||
|
||||
seatPrice = (seatCount - seatCountLimit) * goodsEntity!!.member_price.toFloat()
|
||||
setPrice(goodsEntity!!.price.toFloat() + seatPrice)
|
||||
setPriceWithCoupon()
|
||||
|
||||
binding.ivSubtract.setImageResource(R.mipmap.ic_subtract_count_enable)
|
||||
}
|
||||
|
||||
binding.ivSubtract.onClick {
|
||||
if (goodsEntity == null) return@onClick
|
||||
if (seatCount > seatCountLimit) {
|
||||
seatCount--
|
||||
setSeatCount()
|
||||
|
||||
seatPrice = (seatCount - seatCountLimit) * goodsEntity!!.member_price.toFloat()
|
||||
setPrice(goodsEntity!!.price.toFloat() + seatPrice)
|
||||
setPriceWithCoupon()
|
||||
|
||||
binding.ivSubtract.setImageResource(if (seatCount > seatCountLimit) R.mipmap.ic_subtract_count_enable else R.mipmap.ic_subtract_count_disable)
|
||||
}
|
||||
|
|
@ -236,7 +234,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
f.setOnBackListener {
|
||||
selectedCoupon = it
|
||||
checkCouponValid()
|
||||
setCoupon()
|
||||
setPriceWithCoupon()
|
||||
EventReportManager.eventReport(EventConstants.COUPON_DIALOG_CHECK, "选择优惠券切换", Gson().toJson(selectedCoupon))
|
||||
}
|
||||
f.show(childFragmentManager, SelectCouponDialog::class.java.simpleName)
|
||||
|
|
@ -284,7 +282,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
f.setOnSelectListener {
|
||||
binding.cbAgree.isChecked = true
|
||||
if (!checkCouponValid()) {
|
||||
setCoupon()
|
||||
setPriceWithCoupon()
|
||||
return@setOnSelectListener
|
||||
}
|
||||
createOrder()
|
||||
|
|
@ -292,7 +290,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
f.show(childFragmentManager, PayTipDialog::class.java.simpleName)
|
||||
} else {
|
||||
if (!checkCouponValid()) {
|
||||
setCoupon()
|
||||
setPriceWithCoupon()
|
||||
return@onClick
|
||||
}
|
||||
createOrder()
|
||||
|
|
@ -319,6 +317,8 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
}
|
||||
|
||||
mViewModel.goodsListLiveData.observe(this) { list ->
|
||||
selectedCoupon = null
|
||||
|
||||
goodsAdapter.data.forEach { _ ->
|
||||
if (binding.rvGoods.itemDecorationCount > 0) {
|
||||
binding.rvGoods.removeItemDecorationAt(0)
|
||||
|
|
@ -348,16 +348,12 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
.setStrikethrough()
|
||||
.create()
|
||||
setSeatCount()
|
||||
|
||||
seatPrice = (seatCount - seatCountLimit) * (goodsEntity?.member_price?.toFloat() ?: 0f)
|
||||
setPrice(goodsEntity!!.price.toFloat() + seatPrice)
|
||||
setPriceWithCoupon()
|
||||
} else {
|
||||
setPrice(goodsEntity!!.price.toFloat())
|
||||
setPriceWithCoupon()
|
||||
}
|
||||
releasePayType()
|
||||
}
|
||||
selectedCoupon = null
|
||||
setCoupon()
|
||||
setCouponCount()
|
||||
initPrivacyTv()
|
||||
|
||||
|
|
@ -379,7 +375,6 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
if (!TextUtils.isEmpty(it.sub_user_limit)) {
|
||||
seatCount = corpInfo!!.sub_user_limit.toInt()
|
||||
}
|
||||
setSeatCount()
|
||||
}
|
||||
|
||||
mViewModel.createOrderLiveData.observe(this) {
|
||||
|
|
@ -593,7 +588,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setPrice(price: Float) {
|
||||
private fun startPriceAnim(price: Float) {
|
||||
lastGoodsPrice = totalPrice
|
||||
totalPrice = if (price < 0) 0f else price
|
||||
|
||||
|
|
@ -724,24 +719,40 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
|||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setCoupon() {
|
||||
private fun setPriceWithCoupon() {
|
||||
if (selectedCoupon != null) {
|
||||
when (selectedCoupon!!.coupon_type) {
|
||||
CouponEntity.TYPE_CASH -> {
|
||||
binding.tvCoupon.text = "-¥${DecimalFormat("0.##").format(selectedCoupon!!.coupon_value.toFloat() / 100)}"
|
||||
val endPrice = goodsEntity!!.price.toFloat() - selectedCoupon!!.coupon_value.toFloat() / 100
|
||||
setPrice(endPrice)
|
||||
val endPrice = if (vipType == 0) {
|
||||
goodsEntity!!.price.toFloat() - selectedCoupon!!.coupon_value.toFloat() / 100
|
||||
} else {
|
||||
seatPrice = (seatCount - seatCountLimit) * goodsEntity!!.member_price.toFloat()
|
||||
goodsEntity!!.price.toFloat() + seatPrice - selectedCoupon!!.coupon_value.toFloat() / 100
|
||||
}
|
||||
startPriceAnim(endPrice)
|
||||
}
|
||||
|
||||
CouponEntity.TYPE_DISCOUNT -> {
|
||||
binding.tvCoupon.text = "${DecimalFormat("0.##").format(selectedCoupon!!.coupon_value.toFloat() * 10)}折"
|
||||
val endPrice = goodsEntity!!.price.toFloat() * selectedCoupon!!.coupon_value.toFloat()
|
||||
setPrice(endPrice)
|
||||
val endPrice = if (vipType == 0) {
|
||||
goodsEntity!!.price.toFloat() * selectedCoupon!!.coupon_value.toFloat()
|
||||
} else {
|
||||
seatPrice = (seatCount - seatCountLimit) * goodsEntity!!.member_price.toFloat()
|
||||
(goodsEntity!!.price.toFloat() + seatPrice) * selectedCoupon!!.coupon_value.toFloat()
|
||||
}
|
||||
startPriceAnim(endPrice)
|
||||
}
|
||||
}
|
||||
binding.tvCoupon.setTextColor(getColor(R.color.color_f0365e))
|
||||
} else {
|
||||
setPrice(goodsEntity!!.price.toFloat())
|
||||
val endPrice = if (vipType == 0) {
|
||||
goodsEntity!!.price.toFloat()
|
||||
} else {
|
||||
seatPrice = (seatCount - seatCountLimit) * goodsEntity!!.member_price.toFloat()
|
||||
goodsEntity!!.price.toFloat() + seatPrice
|
||||
}
|
||||
startPriceAnim(endPrice)
|
||||
setCouponCount()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue