| | |
| | | import android.os.Looper |
| | | import cn.sinata.xldutils.netstatus.NetUtils |
| | | import cn.sinata.xldutils.utils.toast |
| | | import com.google.gson.Gson |
| | | import com.okgoincar.bean.LocalOrderBean |
| | | import com.okgoincar.bean.OrderBean |
| | | import com.okgoincar.netUtls.Api |
| | | import com.okgoincar.netUtls.callNet |
| | | import com.okgoincar.netUtls.getMapByAny |
| | |
| | | var bean = LocalOrderBean() |
| | | bean.orderId = MyApplication.currentOrderId |
| | | bean.endTime = System.currentTimeMillis() |
| | | bean.money = travelFee |
| | | CacheKey.saveLocalOrderBean(bean) |
| | | } |
| | | } else { //有数据存着,并且有网络上传异常订单 如果没有网络就不处理,这个肯定是线下的单 |
| | |
| | | bean.endTime = System.currentTimeMillis() |
| | | CacheKey.saveLocalOrderBean(bean) |
| | | } |
| | | // callEndOrder(contexts, travelFee) |
| | | callErrorOrder(contexts) |
| | | } |
| | | } else { |
| | |
| | | fun callErrorOrder(contexts: Context) { |
| | | var bean = CacheKey.getLocalOrderBean() |
| | | bean?.let { |
| | | if (bean.money <= 0.0) { |
| | | if (bean.endTime <= 0L){ |
| | | return@let |
| | | } |
| | | CacheKey.saveLocalOrderBeanNull() |
| | | 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)) |
| | | if (bean.startTime <= 0L) { |
| | | if (NetUtils.isNetworkConnected(MyApplication.getInstance())){ |
| | | CacheKey.saveLocalOrderBeanNull() |
| | | callEndOrder(contexts,bean.money) |
| | | } |
| | | }else{ |
| | | if (NetUtils.isNetworkConnected(MyApplication.getInstance())){ |
| | | CacheKey.saveLocalOrderBeanNull() |
| | | 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)) |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private fun callEndOrder(contexts: Context, travelFee: Double) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = MyApplication.currentOrderId |
| | |
| | | map["lon"] = MyApplication.getLocation().longitude |
| | | map["type"] = 1 |
| | | callNet(contexts, Api.confirmFees_, map) { |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.SURE_MONEY)) |
| | | var mapOrder = getMapByAny() |
| | | mapOrder["orderId"] = MyApplication.currentOrderId |
| | | mapOrder["orderType"] = MyApplication.currentOrderType |
| | | callNet(contexts, Api.queryOrderInfo, mapOrder) { |
| | | var orderBean = Gson().fromJson(it, OrderBean::class.java) |
| | | if (orderBean.data.orderState == 7){ |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.SURE_MONEY)) |
| | | } |
| | | if (orderBean.data.orderState == 2 ||orderBean.data.orderState == 3 || orderBean.data.orderState == 4 ){ |
| | | Handler(Looper.getMainLooper()).postDelayed({ |
| | | toast("发送网约") |
| | | var intent = Intent(); |
| | | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; |
| | | intent.action = "wisdom.intent.action.topLight"; |
| | | intent.putExtra("state", 0) |
| | | contexts.sendBroadcast(intent) |
| | | },10000) |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |