lmw
2023-06-21 bd6a8872438a35d47821c5d5da7fe149e5fed3ab
app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
@@ -5,6 +5,7 @@
import android.content.Intent
import android.os.Handler
import android.os.Looper
import android.util.Log
import cn.sinata.xldutils.netstatus.NetUtils
import cn.sinata.xldutils.utils.toast
import com.google.gson.Gson
@@ -40,6 +41,8 @@
 */
class MoneyBroadCastReceiver : BroadcastReceiver() {
    override fun onReceive(contexts: Context?, intent: Intent?) {
        MyApplication.upLog("收到广播,Action:${intent?.action}")
        Log.e("MoneyBroadCastReceiver","收到广播,Action:${intent?.action}")
        if (intent == null && contexts == null) {
            toast("内容获取为空,广播接收消息错误")
            return
@@ -49,6 +52,7 @@
                when (intent!!.action) {
                    "wisdom.intent.action.ledLight" -> {
                        val isHeavy = intent!!.getBooleanExtra("isHeavy", true)
                        MyApplication.upLog("广播内容,isHeavy:${isHeavy}")
                        if (isHeavy) {
                            callStatue(contexts!!, 5) //代表让订单到进行中
                        }
@@ -69,6 +73,7 @@
    companion object {
        fun callStatue(contexts: Context, i: Int) {
            if (MyApplication.currentOrderId.isEmpty()) {
                MyApplication.upLog("callStatue error,MyApplication.currentOrderId.isEmpty")
                toast("没有进行中的订单,无法开始")
                return
            }
@@ -146,19 +151,20 @@
                if (bean.startTime <= 0L) {
                    if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                        CacheKey.saveLocalOrderBeanNull()
                        MyApplication.currentOrderId = ""
                        toast("调用正常结束,在异常订单中")
                        callEndOrder(contexts,bean.money)
                    }
                }else{
                    if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                        CacheKey.saveLocalOrderBeanNull()
                        MyApplication.currentOrderId = ""
                        val map = getMapByAny()
                        map["orderId"] = bean.orderId
                        map["orderType"] = bean.orderType
                        map["type"] = "1"
                        map["travelFee"] = bean.money
                        CacheKey.saveLocalOrderBeanNull()
                        toast("调用异常结束,在异常订单中 id==="+bean.orderId)
                        callNet(contexts, "api/order/confirmFees$", map,{
                            MyApplication.currentOrderId = ""
                            toast("上传异常订单成功")
                            EventBus.getDefault().post(BaseEvent(BaseEvent.ERROR_INFO))
                        }) {
@@ -167,7 +173,6 @@
                        }
                    }
                }
            }
        }
@@ -203,9 +208,11 @@
                mapOrder["orderType"] = MyApplication.currentOrderType
                callNet(contexts, Api.queryOrderInfo, mapOrder) {
                    var orderBean = Gson().fromJson(it, OrderBean::class.java)
                    EventBus.getDefault().post(BaseEvent(BaseEvent.UPDATA_MAIN_CAR))
                    if (orderBean.data.orderState == 7){
                        EventBus.getDefault().post(BaseEvent(BaseEvent.SURE_MONEY))
                    }
                    MyApplication.currentOrderId = ""
                    if (orderBean.data.orderState == 2 ||orderBean.data.orderState == 3 || orderBean.data.orderState == 4 ){
                        Handler(Looper.getMainLooper()).postDelayed({
                            toast("发送网约")