18034727885
2026-07-02 eb6124e310ae8875a0150ee5d2edd52d5a579d87
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package com.driver.igotrip.ui.main.small_cargo
 
import android.os.Looper
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import cn.sinata.xldutils.utils.*
import com.driver.igotrip.R
import com.driver.igotrip.base.BaseEvent
import com.driver.igotrip.base.MyApplication
import com.driver.igotrip.base.MyApplication.Companion.appContext
import com.driver.igotrip.base.MyBaseActivity
import com.driver.igotrip.bean.OrderBean
import com.driver.igotrip.bean.OrderSimpleData
import com.driver.igotrip.netUtls.Api
import com.driver.igotrip.netUtls.callNet
import com.driver.igotrip.netUtls.getMapByAny
import com.driver.igotrip.ui.UiUtil
import com.driver.igotrip.ui.main.major.MajorMoneyDetailActivity
import com.driver.igotrip.utils.MyUtils
import com.driver.igotrip.utils.view.SlidingButton
import com.google.gson.Gson
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity
 
class SmallOverActivity : MyBaseActivity(), MyApplication.OrderStatueView {
 
    private val orderBean by lazy { intent.getSerializableExtra("orderBean") as OrderBean.DataBean }
 
    override fun setContentView() {
        setContentView(R.layout.activity_order_over_small)
 
    }
 
    private val ll_order_cancel by lazy { find<View>(R.id.ll_order_cancel) }
    private val iv_phone by lazy { find<View>(R.id.iv_phone) }
    private val tv_show_pay_over by lazy { find<TextView>(R.id.tv_show_pay_over) }
    private val tv_name by lazy { find<TextView>(R.id.tv_name) }
    private val tv_car_num by lazy { find<TextView>(R.id.tv_car_num) }
    private val tv_time by lazy { find<TextView>(R.id.tv_time) }
    private val tv_start_address by lazy { find<TextView>(R.id.tv_start_address) }
    private val tv_end_address by lazy { find<TextView>(R.id.tv_end_address) }
    private val tv_money_cargo by lazy { find<TextView>(R.id.tv_money_cargo) }
    private val tv_remark by lazy { find<TextView>(R.id.tv_remark) }
    private val ll_order_money by lazy { find<LinearLayout>(R.id.ll_order_money) }
    private val tv_order_money by lazy { find<TextView>(R.id.tv_order_money) }
    private val ll_service_money by lazy { find<LinearLayout>(R.id.ll_service_money) }
    private val tv_service_money by lazy { find<TextView>(R.id.tv_service_money) }
    private val ll_real_income by lazy { find<LinearLayout>(R.id.ll_real_income) }
    private val tv_real_income by lazy { find<TextView>(R.id.tv_real_income) }
    private val tv_pay_result_small_money by lazy { find<TextView>(R.id.tv_pay_result_small_money) }
    private val tv_tv_num_cargo by lazy { find<TextView>(R.id.tv_tv_num_cargo) }
    private val tv_people_cargo by lazy { find<TextView>(R.id.tv_people_cargo) }
    private val tv_pay_result_money by lazy { find<TextView>(R.id.tv_pay_result_money) }
    private val tv_pay_result_title by lazy { find<TextView>(R.id.tv_pay_result_title) }
    private val tv_cancel_to by lazy { find<TextView>(R.id.tv_cancel_to) }
    private val tv_cancel_money by lazy { find<TextView>(R.id.tv_cancel_money) }
    private val tv_cancel_result by lazy { find<TextView>(R.id.tv_cancel_result) }
    private val tv_cancel_s by lazy { find<TextView>(R.id.tv_cancel_s) }
    private val ll_pay_result by lazy { find<LinearLayout>(R.id.ll_pay_result) }
    private val view_line_money_detail by lazy { find<View>(R.id.view_line_money_detail) }
    private val tv_frozen by lazy { find<TextView>(R.id.tv_frozen) }
 
    override fun initView() {
        setTitleText(getString(R.string.已送达))
        ll_order_cancel.gone()
        MyApplication.currentOrderType = ""
        MyApplication.currentOrderId = ""
        tv_show_pay_over.gone()
        ll_pay_result.gone()
        tv_show_pay_over.text = getString(R.string.客户已支付)
//        callOrder()
        addSocketLisener()
        showUi(orderBean)
    }
 
 
    private fun showUi(orderBean: OrderBean.DataBean) {
        orderBean?.let {
            setTitleText(getString(R.string.交货))
            tv_name.text = it.userName
            tv_car_num.text = getString(R.string.次寄物, it.historyNum.toString())
            iv_phone.visible()
            iv_phone.clickDelay {
                MyUtils.getInstans().CallPhone(this, it.userPhone)
            }
            tv_time.text = it.travelTime_
            tv_start_address.text = it.startAddress
            tv_end_address.text = it.endAddress
            tv_money_cargo.text = getString(R.string.元加急费, doubleTwo(it.tipMoney))
            tv_remark.text = it.remark
            if (it.tipMoney == null || it.tipMoney <= 0.0) {
                tv_money_cargo.gone()
                tv_pay_result_small_money.gone()
            }
            var cargoStrType =
                if (it.cargoType == "1") getString(R.string.普通小件X) else getString(
                    R.string.贵重物品X
                )
            tv_tv_num_cargo.text = cargoStrType + it.peopleNumber
            tv_people_cargo.text = it.nickName + "-" + it.phone
            tv_pay_result_money.text =
                "FCFA" + if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString()
            tv_pay_result_small_money.text =
                getString(R.string.其中含加急费用) + it.tipMoney.toString()
            setTitleText(getSmallStatue(it.orderState))
            tv_pay_result_title.text = getString(R.string.订单) + getSmallStatue(it.orderState)
            tv_order_money.text = getString(R.string.money) + it.orderMoney
            tv_service_money.text = getString(R.string.money) + it.platformServerMoney
            tv_real_income.text = getString(R.string.money) + it.driverServerMoney
            ll_pay_result.visible()
            if (it.orderState in 6..7) {
                tv_pay_result_title.text = getString(R.string.待乘客支付)
            } else if (it.orderState == 8) {
                tv_pay_result_title.text = getString(R.string.订单待评价)
            } else if (it.orderState == 9) {
                tv_pay_result_title.text = getString(R.string.订单已完成)
            } else if (it.orderState == 10 || it.orderState == 12) {
                ll_order_cancel.visible()
                iv_phone.gone()
                ll_pay_result.gone()
                tv_cancel_to.text = it.cancelUser
                tv_cancel_money.text =
                    getString(R.string.money) + " " + doubleOne(it.cancelPayMoney)
                tv_cancel_result.text = it.cancelReason
                tv_cancel_s.text = it.cancelRemark
                if (it.cancelRemark.isNullOrEmpty()) {
                    tv_cancel_s.text = ""
                }
            }
 
            if (it.orderState in 6..9) {
                tv_pay_result_small_money.text = getString(R.string.查看收费明细)
                tv_pay_result_small_money.visible()
                view_line_money_detail.visible()
                tv_pay_result_small_money.clickDelay {
                    startActivity<MajorMoneyDetailActivity>(
                        "orderId" to orderBean.orderId.toString(),
                        "orderType" to "4"
                    )
                }
            }
            if (it.isFrozen == 2) {
                tv_frozen.visible()
                tv_frozen.setCompoundDrawablesRelativeWithIntrinsicBounds(
                    0,
                    UiUtil.getFrozenBitmap(), 0, 0
                )
            }
        }
    }
 
    private fun getSmallStatue(state: Int): String? {
        when (state) {
            1 -> return getString(R.string.待接单)
            2 -> return getString(R.string.待出发)
            3 -> return getString(R.string.待到达预约地点)
            4 -> return getString(R.string.待取货)
            5 -> return getString(R.string.送货中)
            6 -> return getString(R.string.已送达)
            7 -> return getString(R.string.待支付)
            8 -> return getString(R.string.待评价)
            9 -> return getString(R.string.已完成)
            10 -> return getString(R.string.cancel_ed)
            11 -> return getString(R.string.改派中)
            12 -> return getString(R.string.取消待支付)
            13 -> return getString(R.string.需补差价)
        }
        return ""
    }
 
    private fun addSocketLisener() {
        MyApplication.addOrderView(this)
 
//        if (handler == null) {
//            handler = android.os.Handler(mainLooper)
//            handler!!.postDelayed({
//                checkOrderStatue()
//            }, 3000)
//        }
    }
 
    var handler: android.os.Handler? = null
    fun checkOrderStatue() {
        var map = getMapByAny()
        map["orderId"] = orderBean.orderId
        map["orderType"] = "4"
        callNet(false, Api.orderStateSocket, map) {
            val orderSimpleData =
                Gson().fromJson(
                    it,
                    OrderSimpleData::class.java
                )
            orderSimpleData?.let {
                if (orderSimpleData.status == 8) {
                    orderBean.orderState = 8
                    showUi(orderBean)
                }
            }
        }
        handler?.postDelayed({ checkOrderStatue() }, 3000)
    }
 
    override fun onDestroy() {
        super.onDestroy()
        handler?.removeCallbacksAndMessages(null)
        MyApplication.removeOrderView(this)
    }
 
    override fun onBackPressed() {
        super.onBackPressed()
        EventBus.getDefault().post(BaseEvent(BaseEvent.CALL_NUM_MAIN))
        EventBus.getDefault().post(BaseEvent(BaseEvent.BACK_CAR_OVER))
    }
 
    override fun setOnclick() {
 
    }
 
    override fun orderInfo(data: OrderSimpleData?) {
        data?.let {
            if (it.status == 8) {
                android.os.Handler(Looper.getMainLooper()).post {
                    orderBean.orderState = 8
                    showUi(orderBean)
                }
            }
        }
    }
}