8.7
liugl
2020-08-07 386c12bc80d17252ea05b7bf1cb2e85db2e46767
app/src/main/java/com/okgoincar/base/MoneyBroadCastReceiver.kt
@@ -12,6 +12,7 @@
import com.okgoincar.netUtls.Api
import com.okgoincar.netUtls.callNet
import com.okgoincar.netUtls.getMapByAny
import com.okgoincar.slab.util.DialogUtil
import com.okgoincar.utils.Cache.CacheKey
import io.netty.util.NetUtil
import org.greenrobot.eventbus.EventBus
@@ -38,22 +39,22 @@
                        var mileage = intent.getDoubleExtra("mileage", 0.0) //里程,单位为km
                        callOver(contexts!!, price)
                    }
                    ConnectivityManager.CONNECTIVITY_ACTION -> {
                    "android.net.conn.CONNECTIVITY_SUCCESS", "android.net.conn.CONNECTIVITY_FAILURE", "android.net.conn.CONNECTIVITY_CHANGE" -> {
                        toast("收到网络变化")
                        if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                            callErrorOrder()
                            callErrorOrder(contexts!!)
                        }
                    }
                }
            }
        } catch (e: Exception) {
        }
    }
    private fun callStatue(contexts: Context, i: Int) {
    companion object {
        fun callStatue(contexts: Context, i: Int) {
        if (MyApplication.currentOrderId.isEmpty()) {
            toast("没有进行中的订单,无法开始")
            return
@@ -69,13 +70,13 @@
            }
        } else { //有数据存着,并且有网络上传异常订单 如果没有网络就不处理,这个肯定是线下的单
            if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                callErrorOrder()
                    callErrorOrder(contexts)
            }
        }
    }
    private fun callOver(contexts: Context, travelFee: Double) {
        fun callOver(contexts: Context, travelFee: Double) {
        if (MyApplication.currentOrderId.isEmpty()) {
            toast("没有进行中的订单,无法结束")
            return
@@ -91,10 +92,22 @@
            }
        } else { //有数据存着,并且有网络上传异常订单 如果没有网络就不处理,这个肯定是线下的单
            if (NetUtils.isNetworkConnected(MyApplication.getInstance())){
                callErrorOrder()
                    var bean = CacheKey.getLocalOrderBean()
                    bean?.let {
                        if (bean.money <= 0.0) {
                            bean.money = travelFee
                            bean.orderId = MyApplication.currentOrderId
                            bean.endTime = System.currentTimeMillis()
                            CacheKey.saveLocalOrderBean(bean)
                        }
                        callErrorOrder(contexts)
                    }
            }else{
               val bean =  CacheKey.getLocalOrderBean()
                bean?.let {
                        if (bean.money >= 0.0) {
                            return@callOver
                        }
                    bean.endTime = System.currentTimeMillis()
                    bean.money = travelFee
                    bean.orderId = MyApplication.currentOrderId
@@ -107,11 +120,26 @@
    /***
     * 上传异常订单
     */
    private fun callErrorOrder() {
        private fun callErrorOrder(contexts: Context) {
            var bean = CacheKey.getLocalOrderBean()
            bean?.let {
                if (bean.money <= 0.0) {
                    return@let
                }
                val map = getMapByAny()
                map["orderId"] = bean.orderId
                map["orderType"] = bean.orderType
                map["type"] = "1"
                map["travelFee"] = bean.money
                callNet(contexts, "api/order/confirmFees$", map) {
                    toast("上传异常订单成功")
                    EventBus.getDefault().post(BaseEvent(BaseEvent.ERROR_INFO))
                }
            }
    }
    fun callStartOrder(contexts: Context, i: Int) {
        private fun callStartOrder(contexts: Context, i: Int) {
        var map = getMapByAny()
        map["orderId"] = MyApplication.currentOrderId
        map["orderType"] = MyApplication.currentOrderType
@@ -124,8 +152,7 @@
    }
    fun callEndOrder(contexts: Context, travelFee: Double) {
        private fun callEndOrder(contexts: Context, travelFee: Double) {
        var map = getMapByAny()
        map["orderId"] = MyApplication.currentOrderId
        map["orderType"] = MyApplication.currentOrderType
@@ -139,3 +166,6 @@
    }
}
}