|
|
@@ -1,10 +1,16 @@
|
|
|
package cn.muchinfo.rma.view.base.platinumtreasure.trade
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.content.Intent
|
|
|
+import android.graphics.Color
|
|
|
import android.view.Gravity
|
|
|
import android.view.View
|
|
|
+import android.widget.TextView
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
import cn.muchinfo.rma.global.data.ContractTradeOrderDetailData
|
|
|
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
|
|
|
import cn.muchinfo.rma.global.database.AppDatabase
|
|
|
import cn.muchinfo.rma.global.database.DataBase
|
|
|
import cn.muchinfo.rma.global.isBlankString
|
|
|
@@ -16,10 +22,17 @@ import cn.muchinfo.rma.view.autoWidget.view.MangeNumberEditText2
|
|
|
import cn.muchinfo.rma.view.base.app.FutureConstent
|
|
|
import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.main.castsurely.AddCastSurelyActivity
|
|
|
import cn.muchinfo.rma.view.base.main.castsurely.MyCastSurelyViewHolder
|
|
|
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
|
|
|
+import com.blankj.utilcode.util.ActivityUtils
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
-import mtp.polymer.com.autowidget.dialog.SelectData
|
|
|
-import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.*
|
|
|
+import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
import org.jetbrains.anko.*
|
|
|
|
|
|
/**
|
|
|
@@ -39,7 +52,7 @@ class PlatinumBuyOrSellUI(
|
|
|
private val type: String
|
|
|
) {
|
|
|
|
|
|
- //选择的交易类型 金额或者数量
|
|
|
+ //选择的交易类型 金额或者数量 1 是数量 2 是金额
|
|
|
val selectPayType : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
|
|
|
// 下拉刷新
|
|
|
@@ -52,6 +65,12 @@ class PlatinumBuyOrSellUI(
|
|
|
//输入的数量或者金额
|
|
|
lateinit var trade_number_or_amount: MangeNumberEditText2
|
|
|
|
|
|
+ //销售价
|
|
|
+ lateinit var sell_price : TextView
|
|
|
+
|
|
|
+ //回购价
|
|
|
+ lateinit var buy_price : TextView
|
|
|
+
|
|
|
/**
|
|
|
* 交易下持仓
|
|
|
*/
|
|
|
@@ -68,17 +87,37 @@ class PlatinumBuyOrSellUI(
|
|
|
viewModel.goodsInfoData.postValue(DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId.toInt()))//获取商品详情
|
|
|
viewModel.queryQuoteDay(tag = thisTag,goodsCodes = outGoodsCode,isShowLoading = isShowLoading)//请求盘面
|
|
|
viewModel.queryContractTradePosition()
|
|
|
+ viewModel.queryGoodsEx(goodsid = goodsId)
|
|
|
}
|
|
|
|
|
|
+ //行情推送通知
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
|
|
|
+ val goodsids = quoteMessageEvent.goodsid
|
|
|
+ //如果推送的goodsid包含当前页面的goodsid,则进行页面刷新
|
|
|
+ if (goodsids.contains(goodsId?.toInt())){
|
|
|
+ LogUtils.eTag("dasjhdkjagfkask","行情推送" + goodsId)
|
|
|
+ val goodsInfo = DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0)
|
|
|
+ val quote = GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find { goodsInfo?.outgoodscode == it.outgoodscode }?.quoteDayData
|
|
|
+ if (quote != null){
|
|
|
+ viewModel.quoteDayData.postValue(quote)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
val root = _FrameLayout(activity).apply {
|
|
|
|
|
|
verticalLayout {
|
|
|
+ activity.createLoadingDialog(hintStr = "请求中...").bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
initData(goodsId = goodsId,outGoodsCode = outGoodsCode,isShowLoading = false)
|
|
|
background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
linearLayout {
|
|
|
background = resources.getDrawable(R.color.white)
|
|
|
onThrottleFirstClick {
|
|
|
-
|
|
|
+ activity.creatGoodsInfoBottomSheetDialog("请选择商品",viewModel.getGoodsInfoList()){
|
|
|
+ initData(goodsId = this.goodsid.toString(),outGoodsCode = this.outgoodscode,isShowLoading = false)
|
|
|
+ }
|
|
|
}
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
textView {
|
|
|
@@ -128,6 +167,33 @@ class PlatinumBuyOrSellUI(
|
|
|
setOnTextChangeListener { view, value ->
|
|
|
|
|
|
}
|
|
|
+ //拿到商品信息后对输入框进行初始化
|
|
|
+ viewModel.goodsInfoData.bindOptional(context) {data ->
|
|
|
+// val goodsExData = GlobalDataCollection.instance?.goodsExInfoDataArrayList?.find { it.goodsid == data?.goodsid.toString()}
|
|
|
+// if (goodsExData?.goodsid?.isNotEmpty() == true){
|
|
|
+//
|
|
|
+// }
|
|
|
+ setDecimal(data?.decimalplace ?: 2)
|
|
|
+ val limitRangeMin = if (data?.decimalplace == 0) {
|
|
|
+ 1.0
|
|
|
+ } else {
|
|
|
+ Math.pow(10.0, -data?.decimalplace?.toDouble()!!)
|
|
|
+ }//限价范围最小值
|
|
|
+ val limitRangeMax =
|
|
|
+ 1000000000 - limitRangeMin // 限价范围最大值
|
|
|
+ setMax(limitRangeMax)
|
|
|
+ setMin(limitRangeMin)
|
|
|
+ setStep(Math.pow(10.0, -data.decimalplace.toDouble()))
|
|
|
+ }
|
|
|
+
|
|
|
+ //行情变化后根据不同的价格类型分别对赋值
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ if (type == "1"){
|
|
|
+ setText(NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.ask.toString()),2))
|
|
|
+ }else{
|
|
|
+ setText(NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.bid.toString()),2))
|
|
|
+ }
|
|
|
+ }
|
|
|
}.lparams(matchParent, autoSize(88)) {
|
|
|
marginStart = autoSize(30)
|
|
|
marginEnd = autoSize(18)
|
|
|
@@ -143,6 +209,7 @@ class PlatinumBuyOrSellUI(
|
|
|
SelectData(id = "2",value = "金额"))
|
|
|
activity.creatBottomSheetDialog("请选择方式", selectDataList) {
|
|
|
selectPayType.postValue(this)
|
|
|
+ viewModel.goodsInfoData.postValue(viewModel.goodsInfoData.value)
|
|
|
}
|
|
|
}
|
|
|
textView {
|
|
|
@@ -167,6 +234,22 @@ class PlatinumBuyOrSellUI(
|
|
|
setOnTextChangeListener { view, value ->
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ //拿到商品信息后对输入框进行初始化
|
|
|
+ viewModel.goodsInfoData.bindOptional(context) {data ->
|
|
|
+ val goodsExData = GlobalDataCollection.instance?.goodsExInfoDataArrayList?.find { it.goodsid == data?.goodsid.toString()}
|
|
|
+ if (goodsExData?.goodsid?.isNotEmpty() == true){
|
|
|
+ if (selectPayType.value?.id == "1"){//按数量
|
|
|
+ setMin(goodsExData.regularlybuyminqty?.toDouble() ?: 0.0)
|
|
|
+ setStep(goodsExData.regularlybuyminqty?.toDouble() ?: 0.01)
|
|
|
+ setText(goodsExData.regularlybuyminqty)
|
|
|
+ }else{//按金额
|
|
|
+ setMin(goodsExData.regularlybuyminamount?.toDouble() ?: 0.0)
|
|
|
+ setStep(goodsExData.regularlybuyminamount?.toDouble() ?: 0.01)
|
|
|
+ setText(goodsExData.regularlybuyminamount)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}.lparams(matchParent, autoSize(88)) {
|
|
|
marginStart = autoSize(8)
|
|
|
marginEnd = autoSize(18)
|
|
|
@@ -195,6 +278,7 @@ class PlatinumBuyOrSellUI(
|
|
|
emptyView()
|
|
|
|
|
|
textView {
|
|
|
+ sell_price = this
|
|
|
viewModel.quoteDayData.bindOptional(context){
|
|
|
text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.ask.toString()),2)//卖一
|
|
|
}
|
|
|
@@ -218,6 +302,7 @@ class PlatinumBuyOrSellUI(
|
|
|
emptyView()
|
|
|
|
|
|
textView {
|
|
|
+ buy_price = this
|
|
|
viewModel.quoteDayData.bindOptional(context){
|
|
|
text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.bid.toString()),2)//买一
|
|
|
}
|
|
|
@@ -243,6 +328,9 @@ class PlatinumBuyOrSellUI(
|
|
|
visibility = View.GONE
|
|
|
}
|
|
|
textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ creatOrderDetailsDialog(type = "1",orderPrice = trade_price_edittext.text.toString(),goodsInfo = viewModel.goodsInfoData.value ?: GoodsInfo(),selectPayType = selectPayType.value?.id ?: "1")
|
|
|
+ }
|
|
|
gravity = Gravity.CENTER
|
|
|
text = "买入"
|
|
|
textSizeAuto = 36
|
|
|
@@ -254,6 +342,19 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
|
|
|
verticalLayout {
|
|
|
+ viewModel.goodsExData.bindOptional(context){
|
|
|
+ if (it?.canfinance == "0"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }else if(it?.canfinance == "1"){
|
|
|
+ val userinfo = GlobalDataCollection.instance?.loginQueryData?.userInfo?.userinfotype
|
|
|
+ if (userinfo == 2){
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }else{
|
|
|
+ visibility = View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.GONE
|
|
|
backgroundDrawable = createRoundRectDrawable("#FF9536", 15)
|
|
|
gravity = Gravity.CENTER_HORIZONTAL
|
|
|
textView {
|
|
|
@@ -274,6 +375,21 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
|
|
|
textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("goodsId",goodsId)
|
|
|
+ intent.putExtra("outGoodsCode",outGoodsCode)
|
|
|
+ intent.setClass(context,AddCastSurelyActivity::class.java)
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ viewModel.goodsExData.bindOptional(context){
|
|
|
+ if (it?.canregularlybuy == "0"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }else if(it?.canregularlybuy == "1"){
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.GONE
|
|
|
gravity = Gravity.CENTER
|
|
|
text = "定投"
|
|
|
textSizeAuto = 36
|
|
|
@@ -402,4 +518,182 @@ class PlatinumBuyOrSellUI(
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 订单详情弹出提示
|
|
|
+ * type : 1 买 2 卖 3 融资买
|
|
|
+ * orderPrice 价格
|
|
|
+ * goodsName 商品名称
|
|
|
+ * selectPayType 1 按数量 2 按金额
|
|
|
+ */
|
|
|
+
|
|
|
+ fun creatOrderDetailsDialog(type: String, orderPrice: String, goodsInfo : GoodsInfo, selectPayType : String) {
|
|
|
+ activity.createCustomDialog(cancelable = false) { dialog ->
|
|
|
+ backgroundColor = Color.parseColor("#5f000000")
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ backgroundDrawable = createRoundRectDrawable("#ffffff", 24)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "订单详情"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ itemView()
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ emptyView()
|
|
|
+ textView {
|
|
|
+ text = "账户:"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 28
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 2f)
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = GlobalDataCollection.instance?.accountId.toString()
|
|
|
+ textSizeAuto = 28
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 5f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ emptyView()
|
|
|
+ textView {
|
|
|
+ text = "类型:"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 28
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 2f)
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ if (type == "1") {
|
|
|
+ text = "买入"
|
|
|
+ } else if (type == "2") {
|
|
|
+ text = "融资买入"
|
|
|
+ } else if (type == "3") {
|
|
|
+ text = "卖出"
|
|
|
+ }
|
|
|
+ textSizeAuto = 28
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 5f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ emptyView()
|
|
|
+ textView {
|
|
|
+ text = "名称代码:"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 28
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 2f)
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = goodsInfo.goodsname
|
|
|
+ textSizeAuto = 28
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 5f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ emptyView()
|
|
|
+ textView {
|
|
|
+ text = "价格:"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 28
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 2f)
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = orderPrice
|
|
|
+ textSizeAuto = 28
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 5f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ emptyView()
|
|
|
+ textView {
|
|
|
+ if (selectPayType == "1"){
|
|
|
+ text = "数量:"
|
|
|
+ }else{
|
|
|
+ text = "金额:"
|
|
|
+ }
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 28
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 2f)
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = trade_number_or_amount.text.toString()
|
|
|
+ textSizeAuto = 28
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, wrapContent, 5f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ onThrottleFirstClick {
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "取消"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_title_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(100), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ onThrottleFirstClick {
|
|
|
+ var orderQtyOrAmount = 0.0
|
|
|
+ if (selectPayType == "1"){//数量
|
|
|
+ orderQtyOrAmount = trade_number_or_amount.text.toString().toDouble().times(Math.pow(10.0,goodsInfo.decimalplace.toDouble()))
|
|
|
+ }else{
|
|
|
+ orderQtyOrAmount = trade_number_or_amount.text.toString().toDouble()
|
|
|
+ }
|
|
|
+ viewModel.commit(goodsInfo = goodsInfo,type = type,orderPrice = orderPrice,orderQtyOrAmount = orderQtyOrAmount.toString(),selectPayType = selectPayType){
|
|
|
+ viewModel.loadingDialogStatus.postValue(TaskUiModel.success(msg = "下单成功"))
|
|
|
+ }
|
|
|
+// commitDealData(
|
|
|
+// buyOrSell = buyOrSell,
|
|
|
+// isClose = isClose,
|
|
|
+// orderPrice = orderPrice
|
|
|
+// )
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "确定"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_yellow_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(100), 1f)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
+ topMargin = autoSize(450)
|
|
|
+ marginStart = autoSize(100)
|
|
|
+ marginEnd = autoSize(100)
|
|
|
+ }
|
|
|
+ }.show()
|
|
|
+ }
|
|
|
+
|
|
|
}
|