Browse Source

风险率以及平仓页面浮动盈亏刷新问题

yu.jie 3 years ago
parent
commit
2667c46ff8

+ 37 - 42
RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/account/RydzAccountActivity.kt

@@ -624,54 +624,49 @@ class MoneyInfoUI(
                      * 风险率
                      */
                     viewModel.usedAccountData.bindOptional(context) {
-                        ///// 0 - 占用/净值  1 - 净值/占用
-                        val parmasvalue =
-                            GlobalDataCollection.instance?.getSystemParamsValue(
-                                "087"
-                            )
-//                        var worth = 0.0
-//                        if (parmasvalue == "1") {//1.风险净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
-//                            worth = it?.currentbalance?.plus(
-//                                it.valueOfposition
-//                            )?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-//                                ?.minus(it.otherfreezemargin)
-//                                ?.minus(it.outamountfreeze) ?: 0.0
-//
-//
-//                        } else {//0.净值=期末余额+浮动盈亏(收益权)-其他冻结-出金冻结
-//                            worth = it?.currentbalance?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-//                                ?.minus(it.otherfreezemargin)
-//                                ?.minus(it.outamountfreeze) ?: 1.0
-//                        }
-                        val worth: Double
-                        worth =
-                            if (parmasvalue == "1") {//1.风险净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
-                                it?.currentbalance?.plus(
-                                    it.valueOfposition
-                                )
-                                    ?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-                                    ?.minus(it.otherfreezemargin)
-                                    ?.minus(it.outamountfreeze) ?: 0.0
-
 
-                            } else {//0.净值=期末余额+浮动盈亏(收益权)-其他冻结-出金冻结
-                                it?.currentbalance?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-                                    ?.minus(it.otherfreezemargin)
-                                    ?.minus(it.outamountfreeze) ?: 1.0
-                            }
+                        if (it != null) {
+                            it!!.postValueOfPosition.bindOptional(context) { its ->
+                                if (its != null) {
+                                    ///// 0 - 占用/净值  1 - 净值/占用
+                                    val parmasvalue =
+                                        GlobalDataCollection.instance?.getSystemParamsValue(
+                                            "087"
+                                        )
 
-                        var risk = 0.0
-                        if (worth != 0.0) {
-                            risk = it?.usedmargin?.div(worth) ?: 0.0
-                        }
+                                    val worth: Double
+                                    worth =
+                                        if (parmasvalue == "1") {//1.风险净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
+                                            it?.currentbalance?.plus(
+                                                it.valueOfposition
+                                            )
+                                                ?.plus(its)
+                                                ?.minus(it.otherfreezemargin)
+                                                ?.minus(it.outamountfreeze) ?: 0.0
+
+
+                                        } else {//0.净值=期末余额+浮动盈亏(收益权)-其他冻结-出金冻结
+                                            it?.currentbalance?.plus(its)
+                                                ?.minus(it.otherfreezemargin)
+                                                ?.minus(it.outamountfreeze) ?: 1.0
+                                        }
+
+                                    var risk = 0.0
+                                    if (worth != 0.0) {
+                                        risk = it?.usedmargin?.div(worth) ?: 0.0
+                                    }
 //                        text =
 //                            NumberUtils.roundNum(NumberUtils.doubleDistortion(risk.toString()), 4)
 //                                .toPercentage()
 
-                        text = risk.toString().toPercentage2()
-                    }
-                    textSizeAuto = 36
-                    textColorInt = R.color.rma_black_33
+                                    text = risk.toString().toPercentage2()
+                                }
+                            }
+                            textSizeAuto = 36
+                            textColorInt = R.color.rma_black_33
+                            }
+                        }
+
                 }.lparams(wrapContent, wrapContent)
 
             }.lparams(matchParent, autoSize(100))

+ 17 - 6
RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/contractorders/unwind/ContractUnWindActivity.kt

@@ -66,14 +66,25 @@ class ContractUnWindActivity : BaseActivity<ContractUnWindViewModel>(){
         /** 行情推送过来的goodsid **/
         quoteMessageEvent.goodsid.forEach { goodid ->
             LogUtils.eTag("dadafafsjhdkjahkjdhak", goodid)
-            //找到相应商品信息
-            val goodsInfo =
-                viewModel.agreementDataList.value?.find { it.refgoodsid?.toInt() == goodid }
-            viewModel.agreementDataList.value?.indexOf(goodsInfo)?.let {
-                if (it != -1) {//刷新相应item
-                    agreement_recyclerView.adapter?.notifyItemChanged(it)
+            // 找到对应的商品列表
+            val goodsInfoList = viewModel.agreementDataList.value?.filter { it.refgoodsid?.toInt() == goodid }
+
+            goodsInfoList?.forEach {
+                viewModel.agreementDataList.value?.indexOf(it)?.let {
+                    if (it != -1) {//刷新相应item
+                        agreement_recyclerView.adapter?.notifyItemChanged(it)
+                    }
                 }
             }
+
+//            //找到相应商品信息
+//            val goodsInfo =
+//                viewModel.agreementDataList.value?.find { it.refgoodsid?.toInt() == goodid }
+//            viewModel.agreementDataList.value?.indexOf(goodsInfo)?.let {
+//                if (it != -1) {//刷新相应item
+//                    agreement_recyclerView.adapter?.notifyItemChanged(it)
+//                }
+//            }
             //选择了相应的单据
             if (viewModel.agreementData.value?.refgoodsid.isNullOrEmpty().not()){
                 if (goodid == viewModel.agreementData.value?.refgoodsid?.toInt()){