Commit 72e4725b authored by shiyl's avatar shiyl

修改优惠券接口字端名称

parent f3ce3d10
......@@ -11,15 +11,15 @@ import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yidian.news.util.DensityUtil
import com.yidian.shenghuoquan.border.R
import com.yidian.shenghuoquan.border.dto.GoodsList
import com.yidian.shenghuoquan.border.dto.GoodsDto
/**
* 确认订单页面商品列表适配器
*/
class OrderConfirmCommodityListAdapter : BaseQuickAdapter<GoodsList, BaseViewHolder>(R.layout.border_item_order_confirm_commodity_list) {
class OrderConfirmCommodityListAdapter : BaseQuickAdapter<GoodsDto, BaseViewHolder>(R.layout.border_item_order_confirm_commodity_list) {
@SuppressLint("SetTextI18n")
override fun convert(holder: BaseViewHolder, item: GoodsList) {
override fun convert(holder: BaseViewHolder, item: GoodsDto) {
holder.getView<TextView>(R.id.tv_commodity_name).text = item.goodsName
holder.getView<TextView>(R.id.tv_commodity_count).text = "共" + item.goodsNum + "件"
holder.getView<TextView>(R.id.tv_commodity_amount).text = "¥" + item.price
......
......@@ -7,54 +7,38 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class OrderConfirmResDto(
@SerializedName("coupon_list")
val couponList: List<CouponList>? = null,
val couponDto: List<CouponDto>? = null,
@SerializedName("goods_list")
val goodsList: List<GoodsList>? = null,
// @SerializedName("price")
// val price: Int? = null,
val goodsDto: List<GoodsDto>? = null,
@SerializedName("shipping")
val shipping: Shipping? = null,
// @SerializedName("take_place_list")
// val takePlaceList: List<TakePlaceList>? = null
) : Parcelable
@Parcelize
data class CouponList(
data class CouponDto(
@SerializedName("coupon_id")
val couponId: String? = null,// 优惠券id
@SerializedName("name")
val name: String? = null,// 优惠券名称
@SerializedName("amount")
val amount: String? = null,// 优惠券金额
@SerializedName("desc")
val desc: String? = null,
@SerializedName("end_time")
val endTime: String? = null,// 有效期结束时间
@SerializedName("id")
val id: String? = null,// 优惠券id
@SerializedName("jump_url")
val jumpUrl: String? = null,
@SerializedName("name")
val name: String? = null,// 优惠券名称
val desc: String? = null,// 优惠券描述
// @SerializedName("desc")
// val desc: String? = null,// 优惠券使用门槛
@SerializedName("start_time")
val startTime: String? = null,// 有效期开始时间
@SerializedName("end_time")
val endTime: String? = null,// 有效期结束时间
@SerializedName("status")
val status: Int? = null,
@SerializedName("thumbnail")
val thumbnail: String? = null,
@SerializedName("type")
val type: Int? = null,
@SerializedName("use_activity_type")
val useActivityType: Int? = null,
@SerializedName("use_amount_min")
val useAmountMin: Int? = null,
@SerializedName("use_amount_type")
val useAmountType: Int? = null,
@SerializedName("use_shop_type")
val useShopType: Int? = null
val status: Int? = null,// 优惠券状态
) : Parcelable
/**
* 商品列表
*/
@Parcelize
data class GoodsList(
data class GoodsDto(
@SerializedName("goods_name")// 商品名称
val goodsName: String? = null,
@SerializedName("price") // 商品价格
......@@ -91,15 +75,3 @@ data class Shipping(
@SerializedName("user_id")
val userId: String? = null
) : Parcelable
///**
// * 自提点列表
// */
//@Parcelize
//data class TakePlaceList(
// @SerializedName("take_place_id")
// val takePlaceId: Int? = null,// 自提点id
// @SerializedName("take_place_name")
// val takePlaceName: String? = null,// 自提点名称
//) : Parcelable
......@@ -88,7 +88,7 @@ object OrderRemoteDataSource {
val publicParamsMap = HttpParamsUtils.getPublicParamsMap(timeStamp)
val privateParamsMap = HttpParamsUtils.getPrivateParamsMap(requestParams, timeStamp)
ServiceFactory.getInstance().createService(OrderApiService::class.java)
.requestOrderPay(publicParamsMap, privateParamsMap)
.requestCreateOrder(publicParamsMap, privateParamsMap)
.compose(TransformUtil.defaultSchedulers())
.subscribe(object : HttpResultSubscriber<CreateOrderResDto?>() {
override fun onSuccess(result: HttpResult<CreateOrderResDto?>?) {
......
......@@ -8,7 +8,7 @@ import com.yidian.bcommon.mvvm.BaseMvvmActivity
import com.yidian.shenghuoquan.border.R
import com.yidian.shenghuoquan.border.adapter.OrderConfirmCommodityListAdapter
import com.yidian.shenghuoquan.border.databinding.BorderActivityConfirmOrderBinding
import com.yidian.shenghuoquan.border.dto.CouponList
import com.yidian.shenghuoquan.border.dto.CouponDto
import com.yidian.shenghuoquan.border.dto.Shipping
import com.yidian.xarc.xevent.XBaseEvent
import com.yidian.xarc.xevent.XEventManager
......@@ -67,7 +67,7 @@ class ConfirmOrderActivity : BaseMvvmActivity<BorderActivityConfirmOrderBinding,
}
XEventConfig.CONFIRM_ORDER_CHOOSE_COUPON_SUCCESS -> {
// 选择优惠券成功
val coupon = event.body as CouponList
val coupon = event.body as CouponDto
vm.chooseVoucherSuccess(coupon)
}
}
......
......@@ -4,8 +4,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yidian.bcommon.mvvm.BaseViewModel
import com.yidian.bcommon.utils.ToastUtils
import com.yidian.shenghuoquan.border.dto.CouponList
import com.yidian.shenghuoquan.border.dto.GoodsList
import com.yidian.shenghuoquan.border.dto.CouponDto
import com.yidian.shenghuoquan.border.dto.GoodsDto
import com.yidian.shenghuoquan.border.dto.Shipping
import com.yidian.shenghuoquan.border.http.OrderRemoteDataSource
......@@ -17,7 +17,7 @@ class ConfirmOrderViewModel : BaseViewModel() {
var selectedPickUpPoint = MutableLiveData<Shipping?>()// 自提点
var receivingName = MutableLiveData<String>()// 收货人姓名
var receivingPhone = MutableLiveData<String>()//收货人电话
var selectedCoupon = MutableLiveData<CouponList>()// 选中的优惠券
var selectedCoupon = MutableLiveData<CouponDto>()// 选中的优惠券
var couponsAvailableNum = MutableLiveData<Int>()// 可用优惠券数量
var totalAmount = MutableLiveData(0.00)// 合计金额 = 原价 - 优惠
var remark = MutableLiveData<String>()
......@@ -25,16 +25,13 @@ class ConfirmOrderViewModel : BaseViewModel() {
/**
* 商品列表成功 Event
*/
private val _goodsSuccessEvent = MutableLiveData<List<GoodsList>?>()
val goodsSuccessEvent: LiveData<List<GoodsList>?> = _goodsSuccessEvent
private val _goodsSuccessEvent = MutableLiveData<List<GoodsDto>?>()
val goodsSuccessEvent: LiveData<List<GoodsDto>?> = _goodsSuccessEvent
/**
* 请求订单信息
*/
fun requestConfirmOrderInfo(paramsMap: HashMap<String, String?>) {
// val paramsMap = HashMap<String, String?>()
// paramsMap["business_from"] = "2"
// paramsMap["marketing_id"] = marketingId.toString()
OrderRemoteDataSource.requestOrderConfirm(paramsMap) {
if (it == null) {
return@requestOrderConfirm
......@@ -42,9 +39,9 @@ class ConfirmOrderViewModel : BaseViewModel() {
selectedPickUpPoint.value = it.shipping
receivingName.value = it.shipping?.receiverName ?: ""
receivingPhone.value = it.shipping?.receiverMobile ?: ""
_goodsSuccessEvent.value = it.goodsList
calculateOriginalAmount(it.goodsList)
couponsAvailableNum.value = it.couponList?.size ?: 0 // 显示0张便于查看不能使用的优惠券
_goodsSuccessEvent.value = it.goodsDto
calculateOriginalAmount(it.goodsDto)
couponsAvailableNum.value = it.couponDto?.size ?: 0 // 显示0张便于查看不能使用的优惠券
}
}
......@@ -52,11 +49,11 @@ class ConfirmOrderViewModel : BaseViewModel() {
/**
* 计算商品原价 = 数量 * 单价
*/
private fun calculateOriginalAmount(goodsList: List<GoodsList>?) {
if (goodsList.isNullOrEmpty()) {
private fun calculateOriginalAmount(goodsDto: List<GoodsDto>?) {
if (goodsDto.isNullOrEmpty()) {
return
}
goodsList.forEach {
goodsDto.forEach {
originalAmount = originalAmount.plus(it.price * it.goodsNum)
}
// 计算出合计
......@@ -91,7 +88,7 @@ class ConfirmOrderViewModel : BaseViewModel() {
ToastUtils.showLongSafe("去选择优惠券")
}
fun chooseVoucherSuccess(coupon: CouponList) {
fun chooseVoucherSuccess(coupon: CouponDto) {
selectedCoupon.value = coupon
couponAmount = coupon.amount?.toDouble() ?: 0.00
// 重新计算相关金额
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment