lmw
2024-05-21 0af0750101f969b6ff18d7ade37354b4bcdccd03
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
package com.future.dispatch.ui.order.change_order
 
import com.example.oktrip.netUtls.callNet
import com.future.dispatch.R
import com.future.dispatch.base.BaseEvent
import com.future.dispatch.base.MyBaseActivity
import com.future.dispatch.bean.ReassignDetailBean
import com.future.dispatch.netUtls.Api
import com.future.dispatch.utils.clickDelay
import com.future.dispatch.utils.getMapByAny
import com.future.dispatch.utils.gone
import com.future.dispatch.utils.visible
import kotlinx.android.synthetic.main.activity_right_away.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
 
/**
 * @ClassName RightAwayActivity
 * @Description 立即处理
 * @Author Administrator
 * @Date 2020/10/9 14:56
 * @Version 1.0
 */
class RightAwayActivity: MyBaseActivity() {
 
    val id by lazy {
        intent.getStringExtra("id")
    }
 
    val type by lazy {
        intent.getStringExtra("type")
    }
 
    override fun setContentView() {
        setContentView(R.layout.activity_right_away)
    }
 
    override fun initView() {
        ll_ressign_people.gone()
        ll_ressign_new.gone()
        if (type == "2"){
            ll_bottom.gone()
            setTitleText("改派详情")
        }else{
            ll_bottom.visible()
            setTitleText("立即处理")
        }
        callDetail()
    }
 
    private fun callDetail() {
        var map = getMapByAny()
        map["id"] = id
        callNet(Api.queryReassignInfo,map){
            var bean = gson.fromJson<ReassignDetailBean>(it,ReassignDetailBean::class.java)
            tv_time.text = bean.data.applyTime
            tv_driver.text = bean.data.applyDriver
            tv_reason.text = bean.data.reason
            tv_in_order_name.text = bean.data.user
            tv_to_time.text = bean.data.travelTime
            tv_start_address.text = bean.data.startAddress
            tv_end_address.text = bean.data.endAddress
            tv_statue.text = getStateStr(bean.data.state)
            tv_ressign_statue.text = getStatue(bean.data.status)
            tv_ressign_people.text = bean.data.reviewer
            tv_ressign_new.text = bean.data.nowDriver
            if (bean.data.status == 3){
                ll_ressign_people.visible()
                ll_ressign_new.visible()
            }
            if (bean.data.status in 1..2){
                ll_bottom.visible()
            }else{
                ll_bottom.gone()
            }
            tv_ressign_new_type.text = getOrderType(bean.data.orderType)
        }
    }
 
    private fun getStatue(status: Int): String {
        when(status){
            1 -> return "提交申请"
            2 -> return "已支付"
            3 -> return "已改派"
            4 -> return "已取消"
            5 -> return "已拒绝"
        }
        return ""
    }
 
    private fun getOrderType(orderType: Int): String {
        when(orderType){
            1 -> {
                return "专车订单"
            }
            2 -> {
                return "出租车订单"
            }
            3 -> {
                return "跨城订单"
            }
            4 -> {
                return "同城小件订单"
            }
            5 -> {
                return "跨城小件订单"
            }
            7 -> {
                return "接送机/站订单"
            }
        }
        return ""
    }
 
 
    fun getStateStr(state:Int): String? {
        when (state) {
            1 -> return "待接单"
            2, 3, 4, 5, 12 -> return "司机已接单"
            6, 7, 8, 9 -> return "已完成"
            10 -> return "已取消"
            11 -> return "改派中"
        }
        return ""
    }
 
    override fun setOnclick() {
 
        tv_now_change.clickDelay {
            startActivity<ChangeNowActivity>("reassignId" to id)
        }
 
        tv_cancel.clickDelay {
            cancelOrder()
        }
 
        tv_none.clickDelay {
            noneRessage()
        }
    }
 
    private fun noneRessage() {
        var map = getMapByAny()
        map["id"] = id
        callNet(Api.refuseReassign,map){
            toast("拒绝成功")
            callDetail()
        }
    }
 
    private fun cancelOrder() {
        var map = getMapByAny()
        map["id"] = id
        callNet(Api.cancelReassign,map){
            toast("取消成功")
            callDetail()
        }
    }
 
    override fun onEventMainThread(event: BaseEvent?) {
        super.onEventMainThread(event)
        when(event!!.code){
            BaseEvent.FILTER_CHANGE_ORDER -> {
                finish()
            }
        }
    }
}