From 40f9ac00ec5e4d6363450d1c8e0b0937cc0b1de4 Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期四, 14 一月 2021 10:50:18 +0800 Subject: [PATCH] 1。4:处理预约单导致串单的问题 隐藏预约单 --- app/src/main/java/com/okgoincar/utils/UtilKt.kt | 72 ++++++++++++++++++++++++++++++----- 1 files changed, 61 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/okgoincar/utils/UtilKt.kt b/app/src/main/java/com/okgoincar/utils/UtilKt.kt index e42e00d..b8c8013 100644 --- a/app/src/main/java/com/okgoincar/utils/UtilKt.kt +++ b/app/src/main/java/com/okgoincar/utils/UtilKt.kt @@ -23,7 +23,13 @@ import cn.sinata.xldutils.utils.ViewClickDelay.hash import cn.sinata.xldutils.utils.ViewClickDelay.lastClickTime import cn.sinata.xldutils.xldUtils +import com.google.gson.Gson import com.okgoincar.base.MyApplication +import com.okgoincar.bean.OrderBean +import com.okgoincar.netUtls.Api +import com.okgoincar.netUtls.callNet +import com.okgoincar.netUtls.getMapByAny +import com.okgoincar.utils.Cache.CacheKey import org.jetbrains.anko.internals.AnkoInternals import java.lang.NumberFormatException import java.util.* @@ -206,6 +212,9 @@ this.visibility = View.GONE } +fun doubleTwo(price: Double): String? { + return String.format("%.2f", price) +} fun View.visible() { this.visibility = View.VISIBLE @@ -293,11 +302,12 @@ Log.e("OkTrip----trip", "--------" + msg) } -fun getFormatOne(value:Double?):String{ - return Formatter().format("%.1f",value).toString() +fun getFormatOne(value: Double?): String { + return Formatter().format("%.1f", value).toString() } -fun getFormatTwo(value:Double?):String{ - return Formatter().format("%.2f",value).toString() + +fun getFormatTwo(value: Double?): String { + return Formatter().format("%.2f", value).toString() } //多个参数 @@ -307,15 +317,55 @@ // } //}) -fun getNowTimeBlack():Boolean{ - var hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) - if (hour < 7 || hour >= 18){ -// if (hour < 7 || hour >= 12){ + +fun getNowTimeBlack(): Boolean { + var hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) //此时的小时 + var dayNow = Calendar.getInstance().get(Calendar.DAY_OF_MONTH)//此时的天数 + var date = CacheKey.getKeyStr("date_mode") //记录为点击切换的时间Long + var mode = CacheKey.getKeyStr("mode_now_time") ///记录为点击切换的颜色 1 白色 2 黑色 + + if (date.isEmpty()) { + if (hour < 7 || hour >= 18) { return true + } + return false + } else { + var time: Long = date.toLong() + var calendar = Calendar.getInstance() + calendar.timeInMillis = time + var day = calendar.get(Calendar.DAY_OF_MONTH) + if (day != dayNow) { + CacheKey.putKeyStr("date_mode", "") + return getNowTimeBlack() + } else { + return mode != "1" + } } - return false } -fun toast(s:String){ - Toast.makeText(MyApplication.appContext,s,Toast.LENGTH_SHORT).show() +interface Isyy{ + fun isYy(b:Boolean) +} + +fun calldetailOrderIsYy(context: Context,orderId:String,orderType:String,isyy: Isyy){ + var map = getMapByAny() + map["orderId"] = orderId + map["orderType"] = orderType + map["lat"] = MyApplication.getLocation().latitude + map["lon"] = MyApplication.getLocation().longitude + callNet(context, Api.queryPushOrder, map) { + val data = Gson().fromJson<OrderBean>(it, OrderBean::class.java).data + data?.let { + if(it.reservation != 2){ + isyy.isYy(true) + }else{ + isyy.isYy(false) + } + + } + } +} + +fun toast(s: String) { + Toast.makeText(MyApplication.appContext, s, Toast.LENGTH_SHORT).show() } \ No newline at end of file -- Gitblit v1.7.1