Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
72e4725b
Commit
72e4725b
authored
Aug 25, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改优惠券接口字端名称
parent
f3ce3d10
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
63 deletions
+32
-63
OrderConfirmCommodityListAdapter.kt
...uoquan/border/adapter/OrderConfirmCommodityListAdapter.kt
+3
-3
OrderConfirmDto.kt
...ava/com/yidian/shenghuoquan/border/dto/OrderConfirmDto.kt
+14
-42
OrderRemoteDataSource.kt
.../yidian/shenghuoquan/border/http/OrderRemoteDataSource.kt
+1
-1
ConfirmOrderActivity.kt
...com/yidian/shenghuoquan/border/ui/ConfirmOrderActivity.kt
+2
-2
ConfirmOrderViewModel.kt
...om/yidian/shenghuoquan/border/ui/ConfirmOrderViewModel.kt
+12
-15
No files found.
Components/BOrder/src/main/java/com/yidian/shenghuoquan/border/adapter/OrderConfirmCommodityListAdapter.kt
View file @
72e4725b
...
...
@@ -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.Goods
List
import
com.yidian.shenghuoquan.border.dto.Goods
Dto
/**
* 确认订单页面商品列表适配器
*/
class
OrderConfirmCommodityListAdapter
:
BaseQuickAdapter
<
Goods
List
,
BaseViewHolder
>(
R
.
layout
.
border_item_order_confirm_commodity_list
)
{
class
OrderConfirmCommodityListAdapter
:
BaseQuickAdapter
<
Goods
Dto
,
BaseViewHolder
>(
R
.
layout
.
border_item_order_confirm_commodity_list
)
{
@SuppressLint
(
"SetTextI18n"
)
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
Goods
List
)
{
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
Goods
Dto
)
{
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
...
...
Components/BOrder/src/main/java/com/yidian/shenghuoquan/border/dto/OrderConfirmDto.kt
View file @
72e4725b
...
...
@@ -7,54 +7,38 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class
OrderConfirmResDto
(
@SerializedName
(
"coupon_list"
)
val
coupon
List
:
List
<
CouponList
>?
=
null
,
val
coupon
Dto
:
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
Goods
List
(
data class
Goods
Dto
(
@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
Components/BOrder/src/main/java/com/yidian/shenghuoquan/border/http/OrderRemoteDataSource.kt
View file @
72e4725b
...
...
@@ -88,7 +88,7 @@ object OrderRemoteDataSource {
val
publicParamsMap
=
HttpParamsUtils
.
getPublicParamsMap
(
timeStamp
)
val
privateParamsMap
=
HttpParamsUtils
.
getPrivateParamsMap
(
requestParams
,
timeStamp
)
ServiceFactory
.
getInstance
().
createService
(
OrderApiService
::
class
.
java
)
.
request
OrderPay
(
publicParamsMap
,
privateParamsMap
)
.
request
CreateOrder
(
publicParamsMap
,
privateParamsMap
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
CreateOrderResDto
?>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
CreateOrderResDto
?
>?)
{
...
...
Components/BOrder/src/main/java/com/yidian/shenghuoquan/border/ui/ConfirmOrderActivity.kt
View file @
72e4725b
...
...
@@ -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.Coupon
List
import
com.yidian.shenghuoquan.border.dto.Coupon
Dto
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
Coupon
List
val
coupon
=
event
.
body
as
Coupon
Dto
vm
.
chooseVoucherSuccess
(
coupon
)
}
}
...
...
Components/BOrder/src/main/java/com/yidian/shenghuoquan/border/ui/ConfirmOrderViewModel.kt
View file @
72e4725b
...
...
@@ -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.Coupon
List
import
com.yidian.shenghuoquan.border.dto.Goods
List
import
com.yidian.shenghuoquan.border.dto.Coupon
Dto
import
com.yidian.shenghuoquan.border.dto.Goods
Dto
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
<
Coupon
List
>()
// 选中的优惠券
var
selectedCoupon
=
MutableLiveData
<
Coupon
Dto
>()
// 选中的优惠券
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
<
Goods
List
>?>()
val
goodsSuccessEvent
:
LiveData
<
List
<
Goods
List
>?>
=
_goodsSuccessEvent
private
val
_goodsSuccessEvent
=
MutableLiveData
<
List
<
Goods
Dto
>?>()
val
goodsSuccessEvent
:
LiveData
<
List
<
Goods
Dto
>?>
=
_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
.
goods
List
calculateOriginalAmount
(
it
.
goods
List
)
couponsAvailableNum
.
value
=
it
.
coupon
List
?.
size
?:
0
// 显示0张便于查看不能使用的优惠券
_goodsSuccessEvent
.
value
=
it
.
goods
Dto
calculateOriginalAmount
(
it
.
goods
Dto
)
couponsAvailableNum
.
value
=
it
.
coupon
Dto
?.
size
?:
0
// 显示0张便于查看不能使用的优惠券
}
}
...
...
@@ -52,11 +49,11 @@ class ConfirmOrderViewModel : BaseViewModel() {
/**
* 计算商品原价 = 数量 * 单价
*/
private
fun
calculateOriginalAmount
(
goods
List
:
List
<
GoodsList
>?)
{
if
(
goods
List
.
isNullOrEmpty
())
{
private
fun
calculateOriginalAmount
(
goods
Dto
:
List
<
GoodsDto
>?)
{
if
(
goods
Dto
.
isNullOrEmpty
())
{
return
}
goods
List
.
forEach
{
goods
Dto
.
forEach
{
originalAmount
=
originalAmount
.
plus
(
it
.
price
*
it
.
goodsNum
)
}
// 计算出合计
...
...
@@ -91,7 +88,7 @@ class ConfirmOrderViewModel : BaseViewModel() {
ToastUtils
.
showLongSafe
(
"去选择优惠券"
)
}
fun
chooseVoucherSuccess
(
coupon
:
Coupon
List
)
{
fun
chooseVoucherSuccess
(
coupon
:
Coupon
Dto
)
{
selectedCoupon
.
value
=
coupon
couponAmount
=
coupon
.
amount
?.
toDouble
()
?:
0.00
// 重新计算相关金额
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment