Explorar o código

解决部分bug:可用计算显示问题

yu.jie %!s(int64=3) %!d(string=hai) anos
pai
achega
4906dfc0c4

+ 48 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingActivity.kt

@@ -28,6 +28,7 @@ import cn.muchinfo.rma.view.base.BaseActivity
 import cn.muchinfo.rma.view.base.future.trade.itemView
 import cn.muchinfo.rma.view.base.home.contract.emptyView
 import cn.muchinfo.rma.view.base.home.contract.verticalEmptyView
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
 import com.blankj.utilcode.util.ToastUtils
 import com.desfate.chart.util.LogUtils
 import com.desfate.chart.util.MathUtil
@@ -35,6 +36,8 @@ import kotlinx.android.synthetic.main.list_head.view.*
 import mtp.polymer.com.autowidget.dialog.creatAccountDataSheetDialog
 import mtp.polymer.com.autowidget.dialog.createLoadingDialog
 import mtp.polymer.com.autowidget.utils.bindTaskStatus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
 import org.jetbrains.anko.*
 
 /**
@@ -117,6 +120,22 @@ class SwapsDelistingActivity : BaseActivity<SwapsDelistingViewModel>(){
         viewModel.resetAccountData()
     }
 
+    //行情推送通知
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
+        /** 行情推送过来的goodsid **/
+        quoteMessageEvent.goodsid.forEach { goodid ->
+            //找到相应商品信息
+            val goodsInfo =
+                GlobalDataCollection.instance?.contractTradePositionDataArrayList?.find { it.goodsid?.toInt() == goodid }
+            if (goodsInfo?.goodsid.isNullOrEmpty().not()) {
+                // resolve bug  #3429
+                viewModel.resetAccountData()
+//                viewModel.getTaAccounts()
+            }
+        }
+    }
+
     @SuppressLint("SetTextI18n")
     @RequiresApi(Build.VERSION_CODES.O)
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -586,7 +605,35 @@ class SwapsDelistingActivity : BaseActivity<SwapsDelistingViewModel>(){
                 gravity = Gravity.CENTER_VERTICAL
                 textView {
                 viewModel.usedAccountData.bindOptional(context) {
-                    text = "可用资金" + NumberUtils.roundNum(it?.canUserAmount.toString(), 2)
+                    if (it?.valueOfposition_keep_watch_profit_and_loss ?: 0.0 > 0) {
+                        val parmasvalue =
+                            GlobalDataCollection.instance?.getSystemParamsValue(
+                                "113"
+                            )
+                        if (parmasvalue == "1") {
+                            text = "可用资金"+NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(
+                                    it?.canUserAmount?.plus(
+                                        it.valueOfposition_keep_watch_profit_and_loss
+                                    )?.toString()
+                                ), 2
+                            )
+                        } else if (parmasvalue == "0") {
+                            text = "可用资金"+ NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(it?.canUserAmount?.toString()),
+                                2
+                            )
+                        }
+                    } else {
+                        text = "可用资金"+ NumberUtils.roundNum(
+                            NumberUtils.doubleDistortion(
+                                it?.canUserAmount?.plus(
+                                    it.valueOfposition_keep_watch_profit_and_loss
+                                )?.toString()
+                            ), 2
+                        )
+                    }
+//                    text = "可用资金" + NumberUtils.roundNum(it?.canUserAmount.toString(), 2)
                 }
                 textSizeAuto = 29
                 textColorInt = R.color.rma_black_33

+ 56 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/listed/SwapsListedActivity.kt

@@ -686,7 +686,34 @@ class SellListedUI(
 
             textView {
                 viewModel.usedAccountData.bindOptional(context) {
-                    text = "可用资金" + NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.canUserAmount.toString()), 2)
+                    if (it?.valueOfposition_keep_watch_profit_and_loss ?: 0.0 > 0) {
+                        val parmasvalue =
+                            GlobalDataCollection.instance?.getSystemParamsValue(
+                                "113"
+                            )
+                        if (parmasvalue == "1") {
+                            text = "可用资金"+NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(
+                                    it?.canUserAmount?.plus(
+                                        it.valueOfposition_keep_watch_profit_and_loss
+                                    )?.toString()
+                                ), 2
+                            )
+                        } else if (parmasvalue == "0") {
+                            text = "可用资金"+ NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(it?.canUserAmount?.toString()),
+                                2
+                            )
+                        }
+                    } else {
+                        text = "可用资金"+ NumberUtils.roundNum(
+                            NumberUtils.doubleDistortion(
+                                it?.canUserAmount?.plus(
+                                    it.valueOfposition_keep_watch_profit_and_loss
+                                )?.toString()
+                            ), 2
+                        )
+                    }
                 }
                 textSizeAuto = 29
                 textColorInt = R.color.rma_black_33
@@ -1236,7 +1263,34 @@ class BuyListedUI(
 
             textView {
                 viewModel.usedAccountData.bindOptional(context) {
-                    text = "可用资金" + NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.canUserAmount.toString()), 2)
+                    if (it?.valueOfposition_keep_watch_profit_and_loss ?: 0.0 > 0) {
+                        val parmasvalue =
+                            GlobalDataCollection.instance?.getSystemParamsValue(
+                                "113"
+                            )
+                        if (parmasvalue == "1") {
+                            text = "可用资金"+NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(
+                                    it?.canUserAmount?.plus(
+                                        it.valueOfposition_keep_watch_profit_and_loss
+                                    )?.toString()
+                                ), 2
+                            )
+                        } else if (parmasvalue == "0") {
+                            text = "可用资金"+ NumberUtils.roundNum(
+                                NumberUtils.doubleDistortion(it?.canUserAmount?.toString()),
+                                2
+                            )
+                        }
+                    } else {
+                        text = "可用资金"+ NumberUtils.roundNum(
+                            NumberUtils.doubleDistortion(
+                                it?.canUserAmount?.plus(
+                                    it.valueOfposition_keep_watch_profit_and_loss
+                                )?.toString()
+                            ), 2
+                        )
+                    }
                 }
                 textSizeAuto = 29
                 textColorInt = R.color.rma_black_33