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