| | |
| | | if (NetUtils.isNetworkConnected(MyApplication.getInstance())) { //有网络直接处理 |
| | | callStartOrder(contexts, i) |
| | | } else { //无网络 存本地 |
| | | toast("当前没有网络,订单将保存在本地") |
| | | var bean = LocalOrderBean() |
| | | bean.orderId = MyApplication.currentOrderId |
| | | bean.startTime = System.currentTimeMillis() |
| | |
| | | } |
| | | } else { //有数据存着,并且有网络上传异常订单 如果没有网络就不处理,这个肯定是线下的单 |
| | | if (NetUtils.isNetworkConnected(MyApplication.getInstance())) { |
| | | callErrorOrder(contexts) |
| | | toast("有网络,有异常数据,此次数据不受理") |
| | | // callErrorOrder(contexts) |
| | | } |
| | | } |
| | | } |
| | |
| | | if (NetUtils.isNetworkConnected(MyApplication.getInstance())) { //有网络直接处理 |
| | | callEndOrder(contexts, travelFee) |
| | | } else { //无网络 存本地 |
| | | toast("当前没有网络,订单将保存在本地") |
| | | var bean = LocalOrderBean() |
| | | bean.orderId = MyApplication.currentOrderId |
| | | bean.endTime = System.currentTimeMillis() |
| | |
| | | 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 |
| | | callNet(contexts, "api/order/confirmFees$", map) { |
| | | CacheKey.saveLocalOrderBeanNull() |
| | | toast("调用异常结束,在异常订单中 id==="+bean.orderId) |
| | | callNet(contexts, "api/order/confirmFees$", map,{ |
| | | MyApplication.currentOrderId = "" |
| | | toast("上传异常订单成功") |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.ERROR_INFO)) |
| | | }) { |
| | | toast("上传异常订单失败") |
| | | CacheKey.saveLocalOrderBean(bean) |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | private fun callStartOrder(contexts: Context, i: Int) { |
| | | fun callStartOrder(contexts: Context, i: Int) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = MyApplication.currentOrderId |
| | | map["orderType"] = MyApplication.currentOrderType |
| | |
| | | } |
| | | |
| | | private fun callEndOrder(contexts: Context, travelFee: Double) { |
| | | if (MyApplication.getLocation().latitude == 0.0){ |
| | | Handler(Looper.getMainLooper()).post { |
| | | toast("结束时的位置为空,停止结束") |
| | | } |
| | | return |
| | | } |
| | | var map = getMapByAny() |
| | | map["orderId"] = MyApplication.currentOrderId |
| | | map["orderType"] = MyApplication.currentOrderType |
| | |
| | | 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("发送网约") |