Explorar el Código

风险管理9月7日提交代码-liu.bolan-天津掉期

Liu.bolan hace 4 años
padre
commit
f496c31029
Se han modificado 25 ficheros con 3404 adiciones y 53 borrados
  1. 10 0
      RMA/app/src/main/AndroidManifest.xml
  2. 0 1
      RMA/app/src/main/java/cn/muchinfo/rma/view/MainActivity.kt
  3. 2 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/app/Constant.kt
  4. 16 17
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/futureset/FutureSetViewModel.kt
  5. 23 3
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/contract/ContractPublicView.kt
  6. 6 8
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/hedge/HedgeDetailsActivity.kt
  7. 119 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingActivity.kt
  8. 50 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingViewHolder.kt
  9. 20 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingViewModel.kt
  10. 57 22
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleActivity.kt
  11. 48 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleFutureSelecViewHolder.kt
  12. 50 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/RoleSetViewModel.kt
  13. 116 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/OperationTradeActivity.kt
  14. 263 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeMainActivity.kt
  15. 28 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeMainViewModel.kt
  16. 121 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeNormalViewHolder.kt
  17. 248 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/GoodsSwapsFragment.kt
  18. 104 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/GoodsSwapsViewModel.kt
  19. 362 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/TransferSwapsAdapter.java
  20. 123 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessBuyHallViewHolder.kt
  21. 632 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallActivity.kt
  22. 229 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallViewModel.kt
  23. 125 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessSellHallViewHolder.kt
  24. 487 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingActivity.kt
  25. 165 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingViewModel.kt

+ 10 - 0
RMA/app/src/main/AndroidManifest.xml

@@ -453,6 +453,16 @@
         <activity android:name=".view.base.hnstmain.spotwarehouse.bargain.BargainActivity"/>
 
         <activity android:name=".view.base.home.yrdz.YrdzNoticeActivity"/>
+
+        <activity android:name=".view.base.home.trademain.TradeMainActivity"/>
+
+        <activity android:name=".view.base.home.trademain.OperationTradeActivity"/>
+
+        <activity android:name=".view.base.home.reviewset.ReviewSettingActivity"/>
+
+        <activity android:name=".view.base.yrdzpurchase.swaps.business.SwapsBusinessHallActivity"/>
+
+        <activity android:name=".view.base.yrdzpurchase.swaps.delisting.SwapsDelistingActivity"/>
     </application>
 
 </manifest>

+ 0 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/MainActivity.kt

@@ -145,7 +145,6 @@ class MainActivity : BaseActivity<MainViewModel>() {
         }else{
             newFragments.add(homeFragment)
         }
-
         newTabText.add("首页")
         newNormalIcon.add(R.mipmap.main_tab_1)
         newSelectIcon.add(R.mipmap.rma_select_main_tab_1)

+ 2 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/app/Constant.kt

@@ -7,7 +7,7 @@ object Constant {
      * 获取基础url的接口
      */
 //    const val baseurl = "http://103.40.249.123:38280/cfg?key=mtp_20" // 天津麦顿
-    const val baseurl = "http://103.40.249.123:28280/cfg?key=mtp_20"//云融大宗
+//    const val baseurl = "http://103.40.249.123:28280/cfg?key=mtp_20"//云融大宗
 //    const val baseurl = "http://103.40.249.123:8280/cfg?key=mtp_20"//千海金外盘
 //    const val baseurl = "http://103.40.249.127:28280/cfg?key=mtp_20"
 
@@ -23,7 +23,7 @@ object Constant {
 //    const val baseurl: String = "http://192.168.31.139:8080/cfg?key=test_139"// 邓工
 //
 //    const val baseurl = "http://192.168.31.176:8080/cfg?key=test_176" // 9999  123123  黄老板千海金
-//    const val baseurl = "http://192.168.31.171:8080/cfg?key=test_171" // 邓工 签约解约环境
+    const val baseurl = "http://192.168.31.171:8080/cfg?key=test_171" // 邓工 签约解约环境
 //    const val baseurl = "http://192.168.21.71:8280/cfg?key=mtp_20"
 
 //    const val baseurl = "http://192.168.31.181:8080/cfg?key=test_181"//黄老板 华南顺通 调试 110010000001/123123  120010000001/123123

+ 16 - 17
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/futureset/FutureSetViewModel.kt

@@ -213,23 +213,6 @@ class FutureSetViewModel : BaseViewModel(){
     }
 
     /**
-     * 新增期货设置账户时修改操作的期货账户的数据回填
-     */
-    fun futureAccountDataBackfill(data : AccMgrBizGroupSetData,oldList : List<AccMgrTaaccountSonData>){
-        val newWrStandList = arrayListOf<AccMgrTaaccountSonData>()
-        oldList.forEach {result ->
-            val haveSelectData = data.acclist?.find { it.accountid == result.accountid }
-            if (haveSelectData?.accountid?.isNotEmpty() == true){
-                newWrStandList.add(result.copy(isSelect = 1))
-            }else{
-                newWrStandList.add(result)
-            }
-        }
-        futureDataList.postValue(newWrStandList)
-    }
-
-
-    /**
      * 对期货账户的主列表和子列表进行合并
      */
     fun resetAccMgrTaaccount(type : String,oldList : List<AccMgrTaaccountData>,data : AccMgrBizGroupSetData = AccMgrBizGroupSetData()){
@@ -245,9 +228,25 @@ class FutureSetViewModel : BaseViewModel(){
         }else{
             futureAccountDataBackfill(data = data,oldList = newDataList)
         }
+    }
 
+    /**
+     * 新增期货设置账户时修改操作的期货账户的数据回填
+     */
+    fun futureAccountDataBackfill(data : AccMgrBizGroupSetData,oldList : List<AccMgrTaaccountSonData>){
+        val newWrStandList = arrayListOf<AccMgrTaaccountSonData>()
+        oldList.forEach {result ->
+            val haveSelectData = data.acclist?.find { it.accountid == result.accountid }
+            if (haveSelectData?.accountid?.isNotEmpty() == true){
+                newWrStandList.add(result.copy(isSelect = 1))
+            }else{
+                newWrStandList.add(result)
+            }
+        }
+        futureDataList.postValue(newWrStandList)
     }
 
+
     /**
      * 新增登录账户中选择期货账户的数据变更
      */

+ 23 - 3
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/contract/ContractPublicView.kt

@@ -265,12 +265,13 @@ fun _LinearLayout.contractDetailTwoView(data: ContractData) {
             }
         }.lparams(matchParent, autoSize(132))
 
+        // FIXME 移除标仓系数 需要新增交易主体
         viewItemUI()
 
         linearLayout {
             gravity = Gravity.CENTER_VERTICAL
             textView {
-                text = "标仓系数"
+                text = "交易主体"
                 textSizeAuto = 31
                 textColorInt = R.color.p_normal_summary_txt_color
             }.lparams(wrapContent, wrapContent) {
@@ -278,7 +279,7 @@ fun _LinearLayout.contractDetailTwoView(data: ContractData) {
             }
 
             textView {
-                text = data.convertfactor
+                text = "交易主体"
                 textColorInt = R.color.rma_black_33
                 textSizeAuto = 31
             }.lparams(wrapContent, wrapContent) {
@@ -286,7 +287,26 @@ fun _LinearLayout.contractDetailTwoView(data: ContractData) {
             }
         }.lparams(matchParent, autoSize(132))
 
-
+//        viewItemUI()
+//
+//        linearLayout {
+//            gravity = Gravity.CENTER_VERTICAL
+//            textView {
+//                text = "标仓系数"
+//                textSizeAuto = 31
+//                textColorInt = R.color.p_normal_summary_txt_color
+//            }.lparams(wrapContent, wrapContent) {
+//                marginStart = autoSize(59)
+//            }
+//
+//            textView {
+//                text = data.convertfactor
+//                textColorInt = R.color.rma_black_33
+//                textSizeAuto = 31
+//            }.lparams(wrapContent, wrapContent) {
+//                marginStart = autoSize(80)
+//            }
+//        }.lparams(matchParent, autoSize(132))
 
         viewItemUI()
 

+ 6 - 8
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/hedge/HedgeDetailsActivity.kt

@@ -146,12 +146,12 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
                                 content = data.wrstandardname.toString().isBlankString()
                             )
 
-                            viewItemUI()
-
-                            creatHedgeItemView(
-                                titleString = "标仓系数",
-                                content = data.convertfactor ?: ""
-                            )
+//                            viewItemUI()
+//
+//                            creatHedgeItemView(
+//                                titleString = "标仓系数",
+//                                content = data.convertfactor ?: ""
+//                            )
 
                             viewItemUI()
 
@@ -161,9 +161,7 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
                             )
 
                             if (type == "2") {
-
                                 viewItemUI()
-
                                 linearLayout {
                                     gravity = Gravity.CENTER_VERTICAL
                                     onThrottleFirstClick {

+ 119 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingActivity.kt

@@ -0,0 +1,119 @@
+package cn.muchinfo.rma.view.base.home.reviewset
+
+import android.os.Bundle
+import android.view.Gravity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.BaseActivity
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import org.jetbrains.anko.*
+
+/**
+ * 审核设置页面
+ */
+class ReviewSettingActivity : BaseActivity<ReviewSettingViewModel>(){
+
+    // 下拉刷新
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    private val tradeNormaladapter: BaseAdapter<String, ReviewSettingViewHolder> =
+        BaseAdapter { _, _ ->
+            ReviewSettingViewHolder(
+                this,
+                viewModel
+            )
+        }
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        verticalLayout {
+            viewModel.getSettingDataList()
+            topBar {
+                commonLeftButton()
+                commonTitle {
+                    text = "审核设置"
+                }
+            }
+
+            frameLayout {
+                scrollView {
+                    verticalLayout {
+                        statusLayout(contentBlock = {
+                            statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                            setRetryAction {
+                                viewModel.getSettingDataList()
+                            }
+                            swipeToLoadLayout {
+                                swipeToLayout = this
+                                setEnableRefresh(true)
+                                setEnableLoadMore(false)
+                                setOnRefreshListener {
+                                    viewModel.getSettingDataList()
+                                }
+                                setEnableScrollContentWhenLoaded(false)
+                                setEnableLoadMoreWhenContentNotFull(false)
+
+                                // 未提交列表
+                                recyclerView {
+                                    background = resources.getDrawable(R.color.white)
+                                    adapter = tradeNormaladapter
+                                }.lparams(matchParent, matchParent)
+                            }
+                        }, emptyBlock = {
+                            emptyView(hint = resources.getString(R.string.now_no_data))
+                        }).lparams(matchParent, matchParent)
+
+                        viewModel.settingDataList.bindOptional(context) {
+                            if (it?.isEmpty() == true || it?.size == 0) {
+                                statusLayout.showEmpty()
+                            } else {
+                                if (swipeToLayout.getIsRefreshing()) {
+                                    swipeToLayout.finishRefresh()
+                                }
+                                statusLayout.showSuccess()
+                                tradeNormaladapter.setNewData(it)
+                            }
+                        }
+                    }
+                }
+
+                linearLayout {
+                    background = resources.getDrawable(R.color.white)
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        onThrottleFirstClick {
+                            finish()
+                        }
+                        gravity = Gravity.CENTER
+                        backgroundResource = R.mipmap.rma_save_info_bg
+                        text = "取消"
+                        textSizeAuto = 38
+                        textColorInt = R.color.rma_star_color
+                    }.lparams(autoSize(419), autoSize(119)) {
+                        marginStart = autoSize(24)
+                    }
+
+                    textView {
+                        onThrottleFirstClick {
+
+                        }
+                        gravity = Gravity.CENTER
+                        backgroundResource = R.mipmap.rma_submit_bg
+                        text = "确定"
+                        textColorInt = R.color.white
+                        textSizeAuto = 38
+                    }.lparams(autoSize(419), autoSize(119)) {
+                        marginStart = autoSize(13)
+                    }
+                }.lparams(matchParent, autoSize(144)){
+                    gravity = Gravity.BOTTOM
+                }
+            }
+        }
+    }
+
+}

+ 50 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingViewHolder.kt

@@ -0,0 +1,50 @@
+package cn.muchinfo.rma.view.base.home.reviewset
+
+import android.view.Gravity
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.base.app.Constant
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import com.blankj.utilcode.util.SPUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+
+/**
+ * 审核设置viewholder
+ * @property activity AppCompatActivity
+ * @property viewModel ReviewSettingViewModel
+ * @constructor
+ */
+class ReviewSettingViewHolder(private val activity : AppCompatActivity,private val viewModel: ReviewSettingViewModel) : BaseViewHolder<String>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+        linearLayout {
+            gravity = Gravity.CENTER_VERTICAL
+            textView {
+                text = "订单审核"
+                textSizeAuto = 31
+                textColorInt = R.color.rma_black_33
+            }.lparams(wrapContent, wrapContent){
+                marginStart = autoSize(36)
+            }
+
+            emptyView()
+
+            checkBox {
+                buttonDrawable = null
+                background = resources.getDrawable(R.drawable.checkbox_switch_selector)
+                setOnCheckedChangeListener { _, b ->
+                    // TODO 对是否进行审核进行数据存储
+                }
+            }.lparams(autoSize(100), autoSize(100)) {
+                marginStart = autoSize(36)
+            }
+        }.lparams(matchParent, autoSize(90))
+    }
+
+}

+ 20 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/reviewset/ReviewSettingViewModel.kt

@@ -0,0 +1,20 @@
+package cn.muchinfo.rma.view.base.home.reviewset
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.view.base.BaseViewModel
+
+/**
+ * 审核设置viewmodel
+ */
+class ReviewSettingViewModel : BaseViewModel(){
+
+    //审核设置页面的审核项
+    val settingDataList : MutableLiveData<List<String>> = MutableLiveData()
+
+    //获取审核设置的页面的数据
+    fun getSettingDataList(){
+        val newDataList = arrayListOf<String>("1","2","3","4")
+        settingDataList.postValue(newDataList)
+    }
+
+}

+ 57 - 22
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleActivity.kt

@@ -8,14 +8,18 @@ import android.widget.EditText
 import androidx.lifecycle.MutableLiveData
 import cn.muchinfo.rma.R
 import cn.muchinfo.rma.global.MTPEnums
+import cn.muchinfo.rma.global.data.AccMgrBizGroupSetData
 import cn.muchinfo.rma.global.data.AccMgrLoginUserData
+import cn.muchinfo.rma.global.data.AccMgrTaaccountSonData
 import cn.muchinfo.rma.global.data.Userlist
 import cn.muchinfo.rma.lifecycle.bindOptional
 import cn.muchinfo.rma.view.autoWidget.*
 import cn.muchinfo.rma.view.base.BaseActivity
 import cn.muchinfo.rma.view.base.future.trade.itemView
+import cn.muchinfo.rma.view.base.home.accountmanager.futureset.AddFutureAccountRoleViewHolder
 import cn.muchinfo.rma.view.base.home.contract.emptyView
 import com.blankj.utilcode.util.ToastUtils
+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.createLoadingDialog
@@ -48,7 +52,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
     /**
      * 当页面是详情 修改 锁定 注销时的数据回填用
      */
-    val data1 by lazy { intent.getParcelableExtra<Userlist>("data1")  as Userlist}
+    val data1 by lazy { intent.getParcelableExtra<Userlist>("data1") as Userlist }
 
     /**
      * 输入的登录账户
@@ -75,6 +79,13 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
      */
     val roleTypeSelectData: MutableLiveData<SelectData> = MutableLiveData()
 
+    /***
+     * 期货账户
+     */
+    private val addFutureAccountRoleAdapter: BaseAdapter<AccMgrTaaccountSonData, AddRoleFutureSelecViewHolder> =
+        BaseAdapter { _, _ -> AddRoleFutureSelecViewHolder(this, viewModel) }
+
+
     /**
      * 页面数据的初始化
      */
@@ -86,6 +97,11 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 value = data1.rolename ?: ""
             )
         )
+        if (type == "1"){//新增
+            viewModel.queryAccMgrTaaccount(type ?: "1")
+        }else{//  TODO 查询时和新增期货账户传入的实体不同,具体做时再做修改
+//            viewModel.queryAccMgrTaaccount(type ?: "1",data ?: AccMgrBizGroupSetData())
+        }
     }
 
 
@@ -99,15 +115,15 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
             topBar {
                 commonLeftButton()
                 commonTitle {
-                    if (type == "1"){
+                    if (type == "1") {
                         text = "新增管理员"
-                    }else if (type == "2"){
+                    } else if (type == "2") {
                         text = "角色详情"
-                    }else if (type == "3"){
+                    } else if (type == "3") {
                         text = "修改"
-                    }else if (type == "4"){
+                    } else if (type == "4") {
                         text = "冻结锁定"
-                    }else if (type == "5"){
+                    } else if (type == "5") {
                         text = "注销"
                     }
                 }
@@ -134,7 +150,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
 
                 editText {
                     isEnabled = type == "1"//登录账号只能在新增时修改
-                    if (type != "1"){
+                    if (type != "1") {
                         setText(data1.rolename)
                     }
                     login_account = this
@@ -174,7 +190,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 editText {
                     account_name = this
                     isEnabled = type == "1" || type == "3"
-                    if (type != "1"){
+                    if (type != "1") {
                         setText(data1.accountname)
                     }
                     hint = "请输入账户名称"
@@ -192,9 +208,9 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
             itemView()
 
             linearLayout {
-                if (type == "1"){
+                if (type == "1") {
                     visibility = View.VISIBLE
-                }else{
+                } else {
                     visibility = View.GONE
                 }
                 background = resources.getDrawable(R.color.white)
@@ -218,7 +234,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 editText {
                     login_password = this
                     isEnabled = type == "1" || type == "3"
-                    if (type != "1"){
+                    if (type != "1") {
                         setText("********")
                     }
                     hint = "请输入登录密码"
@@ -259,9 +275,9 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 editText {
                     phone_number = this
                     isEnabled = type == "1" || type == "3"
-                    if (type == "1"){
+                    if (type == "1") {
                         setText("")
-                    }else{
+                    } else {
                         setText(data1.mobile)
                     }
                     hint = "可用于找回密码"
@@ -282,7 +298,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 background = resources.getDrawable(R.color.white)
                 gravity = Gravity.CENTER_VERTICAL
                 onThrottleFirstClick {
-                    if (type == "2"){
+                    if (type == "2") {
                         return@onThrottleFirstClick
                     }
                     creatBottomSheetDialog("请选择账户权限", getSelectDataList()) {
@@ -319,9 +335,9 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 emptyView()
 
                 imageView {
-                    if (type == "1"){
+                    if (type == "1") {
                         visibility = View.VISIBLE
-                    }else{
+                    } else {
                         visibility = View.GONE
                     }
                     imageResource = R.mipmap.rma_more
@@ -330,6 +346,25 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                 }
             }.lparams(matchParent, autoSize(132))
 
+            // TODO 增加期货账户关联功能
+
+            linearLayout {
+
+            }.lparams(matchParent, wrapContent)
+
+            /**
+             * 期货账户的列表
+             */
+            recyclerView {
+                background = resources.getDrawable(R.color.add_role_bg_color)
+                adapter = addFutureAccountRoleAdapter
+            }.lparams(matchParent, wrapContent)
+
+            viewModel.futureDataList.bindOptional(context) {
+                addFutureAccountRoleAdapter.setNewData(it)
+            }
+
+
             view {
 
             }.lparams(autoSize(1), 0, 1f)
@@ -343,7 +378,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                         if (check().not()) {
                             return@onThrottleFirstClick
                         }
-                        if (type == "1"){// 1 新增 2 详情 3 修改 4 锁定 5 注销
+                        if (type == "1") {// 1 新增 2 详情 3 修改 4 锁定 5 注销
                             viewModel.LoginaccountOperateReq(
                                 operatetype = 3,
                                 logincode = login_account.text.toString(),
@@ -351,10 +386,10 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                                 password = login_password.text.toString(),
                                 mobile = phone_number.text.toString(),
                                 roleids = arrayListOf(roleTypeSelectData.value?.id?.toLong() ?: 0)
-                            ){
+                            ) {
                                 finish()
                             }
-                        }else if (type == "3"){//修改
+                        } else if (type == "3") {//修改
                             viewModel.LoginaccountOperateReq(
                                 operatetype = 4,
                                 userid = data1.userid?.toLong() ?: 0,
@@ -364,7 +399,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
                                 password = login_password.text.toString(),
                                 mobile = phone_number.text.toString(),
                                 roleids = arrayListOf(roleTypeSelectData.value?.id?.toLong() ?: 0)
-                            ){
+                            ) {
                                 finish()
                             }
                         }
@@ -388,7 +423,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
     fun getSelectDataList(): List<SelectData> {
         val selectList = arrayListOf<SelectData>()
         viewModel.roleSetDataList.value?.forEach {
-            selectList.add(SelectData(id = it.autoid ?: "",value = it.rolename ?: ""))
+            selectList.add(SelectData(id = it.autoid ?: "", value = it.rolename ?: ""))
         }
         return selectList
     }
@@ -411,7 +446,7 @@ class AddRoleActivity : BaseActivity<RoleSetViewModel>() {
             return false
         }
 
-        if (login_password.text.toString().length < 6){
+        if (login_password.text.toString().length < 6) {
             ToastUtils.showLong("密码最少为6位")
             return false
         }

+ 48 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleFutureSelecViewHolder.kt

@@ -0,0 +1,48 @@
+package cn.muchinfo.rma.view.base.home.rolemanagement
+
+import android.view.Gravity
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.AccMgrTaaccountSonData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+
+class AddRoleFutureSelecViewHolder(private val activity : AppCompatActivity, private val viewModel: RoleSetViewModel) : BaseViewHolder<AccMgrTaaccountSonData>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+        linearLayout {
+            onThrottleFirstClick {
+                viewModel.setOnClickLoginRoleChange(data.value?.accountid ?: "")
+            }
+            gravity = Gravity.CENTER_VERTICAL
+            imageView {
+                data.bindOptional(context){
+                    if (it?.isSelect == 0){
+                        imageResource = R.mipmap.rma_normal_click
+                    }else{
+                        imageResource = R.mipmap.rma_select_click
+                    }
+                }
+//                imageResource = R.mipmap.rma_select_click
+            }.lparams(autoSize(38), autoSize(38)){
+                marginStart = autoSize(65)
+            }
+            textView {
+                data.bindOptional(context){
+                    text = it?.accountname + "/" + it?.accountid
+                }
+                textSizeAuto = 31
+                textColorInt = R.color.rma_blue_color
+            }.lparams(wrapContent, wrapContent){
+                marginStart = autoSize(16)
+            }
+        }.lparams(matchParent, autoSize(110))
+    }
+
+}

+ 50 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/RoleSetViewModel.kt

@@ -48,6 +48,56 @@ class RoleSetViewModel : BaseViewModel() {
 
     /**
      * 查询账户管理/期货账户
+     * type 1 新增 2 修改
+     */
+    fun queryAccMgrTaaccount(type : String,data : AccMgrBizGroupSetData = AccMgrBizGroupSetData()){
+        val params = mutableMapOf<String, String>().apply {
+            put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
+        }
+        MyApplication.getInstance()?.accountManager?.queryAccMgrTaaccount(params = params){isSuccess, respData, error ->
+            if (isSuccess){
+                resetAccMgrTaaccount(type ,respData ?: arrayListOf(),data)
+            }
+        }
+    }
+
+    /**
+     * 对期货账户的主列表和子列表进行合并
+     */
+    fun resetAccMgrTaaccount(type : String,oldList : List<AccMgrTaaccountData>,data : AccMgrBizGroupSetData = AccMgrBizGroupSetData()){
+        val newDataList = arrayListOf<AccMgrTaaccountSonData>()
+        oldList.forEach {
+            newDataList.add(it.mainAcc ?: AccMgrTaaccountSonData())
+            it.subacclist?.forEach {
+                newDataList.add(it)
+            }
+        }
+        if (type == "1"){
+            futureDataList.postValue(newDataList)
+        }else{
+            futureAccountDataBackfill(data = data,oldList = newDataList)
+        }
+    }
+
+    /**
+     * 新增期货设置账户时修改操作的期货账户的数据回填
+     */
+    fun futureAccountDataBackfill(data : AccMgrBizGroupSetData,oldList : List<AccMgrTaaccountSonData>){
+        val newWrStandList = arrayListOf<AccMgrTaaccountSonData>()
+        oldList.forEach {result ->
+            val haveSelectData = data.acclist?.find { it.accountid == result.accountid }
+            if (haveSelectData?.accountid?.isNotEmpty() == true){
+                newWrStandList.add(result.copy(isSelect = 1))
+            }else{
+                newWrStandList.add(result)
+            }
+        }
+        futureDataList.postValue(newWrStandList)
+    }
+
+
+    /**
+     * 查询账户管理/期货账户
      */
     fun queryAccMgrTaaccount(type: String, data: Userlist, roleid: String = "") {
         val params = mutableMapOf<String, String>().apply {

+ 116 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/OperationTradeActivity.kt

@@ -0,0 +1,116 @@
+package cn.muchinfo.rma.view.base.home.trademain
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.home.contract.verticalEmptyView
+import com.blankj.utilcode.util.ToastUtils
+import org.jetbrains.anko.*
+
+/**
+ * 新增,修改交易主体的页面
+ */
+class OperationTradeActivity : BaseActivity<TradeMainViewModel>(){
+
+    //页面操作类型 1 是新增 2是修改
+    val type by lazy { intent.getStringExtra("type") }
+
+    lateinit var input_trade_main_name : EditText
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        verticalLayout {
+            topBar {
+                commonLeftButton()
+                commonTitle {
+                    if (type == "1"){
+                        text = "新增交易主体"
+                    }else{
+                        text = "交易主体修改"
+                    }
+                }
+            }
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    visibility = View.INVISIBLE
+                    text = "*"
+                    textColorInt = R.color.rma_star_color
+                    textSizeAuto = 31
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(37)
+                }
+
+                textView {
+                    text = "商品规格"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(10)
+                }
+
+                editText {
+                    input_trade_main_name = this
+                    hint = "请输入交易主体名称"
+                    background = null
+                    inputType = EditorInfo.TYPE_CLASS_TEXT
+                    hintColorStr = "#CCCCCC"
+                    textSizeAuto = 31
+                    textColorStr = "#333333"
+                }.lparams(matchParent, autoSize(132)) {
+                    marginStart = autoSize(80)
+                }
+            }.lparams(matchParent, autoSize(132))
+
+            verticalEmptyView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    onThrottleFirstClick {
+                        finish()
+                    }
+                    gravity = Gravity.CENTER
+                    backgroundResource = R.mipmap.rma_save_info_bg
+                    text = "取消"
+                    textSizeAuto = 38
+                    textColorInt = R.color.rma_star_color
+                }.lparams(autoSize(419), autoSize(119)) {
+                    marginStart = autoSize(24)
+                }
+
+                textView {
+                    onThrottleFirstClick {
+                        if (input_trade_main_name.text.toString().isNullOrEmpty()){
+                            ToastUtils.showLong("请输入交易主体")
+                            return@onThrottleFirstClick
+                        }
+                        if (type == "1"){//新增
+                             ToastUtils.showLong("新增交易主体")
+                        }else if (type == "2"){//修改
+                             ToastUtils.showLong("交易主体修改")
+                        }
+
+                    }
+                    gravity = Gravity.CENTER
+                    backgroundResource = R.mipmap.rma_submit_bg
+                    text = "确定"
+                    textColorInt = R.color.white
+                    textSizeAuto = 38
+                }.lparams(autoSize(419), autoSize(119)) {
+                    marginStart = autoSize(13)
+                }
+            }.lparams(matchParent, autoSize(144))
+
+        }
+    }
+
+}

+ 263 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeMainActivity.kt

@@ -0,0 +1,263 @@
+package cn.muchinfo.rma.view.base.home.trademain
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
+import androidx.viewpager.widget.PagerAdapter
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.SpotGoodsPriceData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.home.spotmarket.SpotMarketPriceViewHolder
+import io.reactivex.disposables.Disposable
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import org.jetbrains.anko.*
+
+/**
+ * 交易主体页面
+ */
+class TradeMainActivity : BaseActivity<TradeMainViewModel>(){
+
+    /**
+     * 正常的交易主体ui
+     */
+    private val normalTradeUI by lazy { NormalTradeUI(this,viewModel) }
+
+    /**
+     * 停用的交易主体ui
+     */
+    private val disableTradeUI by lazy { DisableTradeUI(this,viewModel) }
+
+    //viewpager的适配器
+    private var newPagerAdapter : PagerAdapter? = null
+
+    //tabSegment标题
+    private val newTabsArray : ArrayList<String> = arrayListOf()
+
+    //暂存的页面组
+    private val uiList : ArrayList<_FrameLayout> = arrayListOf()
+
+    private lateinit var mdDisposable : Disposable
+
+    fun initMenuData(){
+
+        newTabsArray.add("正常")
+        uiList.add(normalTradeUI.root)
+
+        newTabsArray.add("停用")
+        uiList.add(disableTradeUI.root)
+
+        newPagerAdapter = object : PagerAdapter() {
+
+            override fun getPageTitle(position: Int): CharSequence? = newTabsArray[position]
+
+            override fun instantiateItem(container: ViewGroup, position: Int): Any {
+                return uiList.get(position).apply {
+                    container.addView(
+                        this,
+                        ViewGroup.LayoutParams(matchParent, matchParent)
+                    )
+                }
+            }
+
+            override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
+                (`object` as? View)?.let { container.removeView(it) }
+            }
+
+            override fun isViewFromObject(view: View, `object`: Any): Boolean = view == `object`
+
+            override fun getCount(): Int = newTabsArray.size
+
+        }
+
+    }
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        initMenuData()
+        verticalLayout {
+            val margerding = autoSize(32)
+            background = resources.getDrawable(R.color.segtabment_bg_color)
+            topBar {
+                commonLeftButton()
+                commonTitle {
+                    text = "交易主体"
+                }
+            }
+
+            
+
+        }
+    }
+}
+
+/**
+ * 正常的交易主体ui
+ * @property activity AppCompatActivity
+ * @property viewModel TradeMainViewModel
+ * @constructor
+ */
+class NormalTradeUI(private val activity : AppCompatActivity,private val viewModel: TradeMainViewModel){
+
+    // 下拉刷新
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    private val tradeNormaladapter: BaseAdapter<String, TradeNormalViewHolder> =
+        BaseAdapter { _, _ ->
+            TradeNormalViewHolder(
+                activity,
+                viewModel,
+                "1"
+            )
+        }
+
+    val root = _FrameLayout(activity).apply {
+        verticalLayout {
+            linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "序号"
+                        textSizeAuto = 31
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(200), autoSize(90))
+
+                textView {
+                    text = "交易主体名称"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(90))
+
+            statusLayout(contentBlock = {
+                statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                setRetryAction {
+                     viewModel.getNormalDataList()
+                }
+                swipeToLoadLayout {
+                    swipeToLayout = this
+                    setEnableRefresh(true)
+                    setEnableLoadMore(false)
+                    setOnRefreshListener {
+                        viewModel.getNormalDataList()
+                    }
+                    setEnableScrollContentWhenLoaded(false)
+                    setEnableLoadMoreWhenContentNotFull(false)
+
+                    // 未提交列表
+                    recyclerView {
+                        background = resources.getDrawable(R.color.white)
+                        adapter = tradeNormaladapter
+                    }.lparams(matchParent, matchParent)
+                }
+            }, emptyBlock = {
+                emptyView(hint = resources.getString(R.string.now_no_data))
+            }).lparams(matchParent, matchParent)
+
+            viewModel.normalTradeDataList.bindOptional(context) {
+                if (it?.isEmpty() == true || it?.size == 0) {
+                    statusLayout.showEmpty()
+                } else {
+                    if (swipeToLayout.getIsRefreshing()) {
+                        swipeToLayout.finishRefresh()
+                    }
+                    statusLayout.showSuccess()
+                    tradeNormaladapter.setNewData(it)
+                }
+            }
+        }
+    }
+
+}
+
+/**
+ * 停用的交易主体ui
+ * @property activity AppCompatActivity
+ * @property viewModel TradeMainViewModel
+ * @constructor
+ */
+class DisableTradeUI(private val activity : AppCompatActivity,private val viewModel: TradeMainViewModel){
+    // 下拉刷新
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    private val tradeNormaladapter: BaseAdapter<String, TradeNormalViewHolder> =
+        BaseAdapter { _, _ ->
+            TradeNormalViewHolder(
+                activity,
+                viewModel,
+                "2"
+            )
+        }
+
+    val root = _FrameLayout(activity).apply {
+        verticalLayout {
+            linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "序号"
+                        textSizeAuto = 31
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(200), autoSize(90))
+
+                textView {
+                    text = "交易主体名称"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(90))
+
+            statusLayout(contentBlock = {
+                statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                setRetryAction {
+                    viewModel.getNormalDataList()
+                }
+                swipeToLoadLayout {
+                    swipeToLayout = this
+                    setEnableRefresh(true)
+                    setEnableLoadMore(false)
+                    setOnRefreshListener {
+                        viewModel.getNormalDataList()
+                    }
+                    setEnableScrollContentWhenLoaded(false)
+                    setEnableLoadMoreWhenContentNotFull(false)
+
+                    // 未提交列表
+                    recyclerView {
+                        background = resources.getDrawable(R.color.white)
+                        adapter = tradeNormaladapter
+                    }.lparams(matchParent, matchParent)
+                }
+            }, emptyBlock = {
+                emptyView(hint = resources.getString(R.string.now_no_data))
+            }).lparams(matchParent, matchParent)
+
+            viewModel.disableTradeDataList.bindOptional(context) {
+                if (it?.isEmpty() == true || it?.size == 0) {
+                    statusLayout.showEmpty()
+                } else {
+                    if (swipeToLayout.getIsRefreshing()) {
+                        swipeToLayout.finishRefresh()
+                    }
+                    statusLayout.showSuccess()
+                    tradeNormaladapter.setNewData(it)
+                }
+            }
+        }
+    }
+}

+ 28 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeMainViewModel.kt

@@ -0,0 +1,28 @@
+package cn.muchinfo.rma.view.base.home.trademain
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.view.base.BaseViewModel
+
+/**
+ * 交易主题viewmodel
+ */
+class TradeMainViewModel : BaseViewModel(){
+
+    //交易主体正常的列表
+    val normalTradeDataList : MutableLiveData<List<String>> = MutableLiveData()
+
+    //交易主体停用的列表
+    val disableTradeDataList : MutableLiveData<List<String>> = MutableLiveData()
+
+    //获取交易主体正常的列表
+    fun getNormalDataList(){
+        val dataList = arrayListOf<String>("1","2","3","4")
+        normalTradeDataList.postValue(dataList)
+    }
+
+    //获取交易主体停用的列表
+    fun getDisableDataList(){
+        val dataList = arrayListOf<String>("1","2","3","4")
+        disableTradeDataList.postValue(dataList)
+    }
+}

+ 121 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/trademain/TradeNormalViewHolder.kt

@@ -0,0 +1,121 @@
+package cn.muchinfo.rma.view.base.home.trademain
+
+import android.view.Gravity
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.base.future.trade.itemView
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import mtp.polymer.com.autowidget.dialog.createWarningDialog
+import org.jetbrains.anko.*
+
+/**
+ * 交易主体的viewholder
+ * @property activity AppCompatActivity
+ * @property viewModel TradeMainViewModel
+ * @property type String 1 是正常的列表 2是停用的列表
+ * @property itemSize IntArray
+ * @constructor
+ */
+class TradeNormalViewHolder(private val activity : AppCompatActivity,private val viewModel: TradeMainViewModel,private val type : String) : BaseViewHolder<String>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+        verticalLayout {
+            linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "1"
+                        textSizeAuto = 31
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(200), autoSize(100))
+
+                textView {
+                    text = "无极天下"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(100))
+
+            // 控制区
+            linearLayout {
+                
+                gravity = Gravity.CENTER_VERTICAL
+
+                emptyView()
+
+                textView {
+                    onThrottleFirstClick {
+
+                    }
+                    backgroundResource = R.drawable.rma_item_click_bg
+                    gravity = Gravity.CENTER
+                    text = "修改"
+                    textColorInt = R.color.rma_item_click_color
+                    textSizeAuto = 26
+                }.lparams(autoSize(120), autoSize(48)) {
+                    marginEnd = autoSize(24)
+                }
+
+                textView {
+                    onThrottleFirstClick {
+                        activity.createWarningDialog {
+                            setTitle("温馨提示")
+                            setMessage("是否确认停用交易主体" + "" + "?")
+                            addAction("取消") { dialog, _ ->
+                                dialog.dismiss()
+                            }
+                            addAction("确定") { dialog, _ ->
+                                dialog.dismiss()
+
+                            }
+                        }.show()
+
+                    }
+                    backgroundResource = R.drawable.rma_item_click_bg
+                    gravity = Gravity.CENTER
+                    text = "停用"
+                    textColorInt = R.color.rma_item_click_color
+                    textSizeAuto = 26
+                }.lparams(autoSize(120), autoSize(48)) {
+                    marginEnd = autoSize(36)
+                }
+
+                textView {
+                    onThrottleFirstClick {
+                        activity.createWarningDialog {
+                            setTitle("温馨提示")
+                            setMessage("是否确认恢复交易主体" + "" + "?")
+                            addAction("取消") { dialog, _ ->
+                                dialog.dismiss()
+                            }
+                            addAction("确定") { dialog, _ ->
+                                dialog.dismiss()
+
+                            }
+                        }.show()
+
+                    }
+                    backgroundResource = R.drawable.rma_item_click_bg
+                    gravity = Gravity.CENTER
+                    text = "恢复"
+                    textColorInt = R.color.rma_item_click_color
+                    textSizeAuto = 26
+                }.lparams(autoSize(120), autoSize(48)) {
+                    marginEnd = autoSize(36)
+                }
+            }.lparams(matchParent, autoSize(72))
+            itemView()
+        }.lparams(matchParent, wrapContent)
+    }
+
+}

+ 248 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/GoodsSwapsFragment.kt

@@ -0,0 +1,248 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps
+
+import android.os.Bundle
+import android.view.*
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.BaseFragment
+import cn.muchinfo.rma.view.base.procurement.TopTabYrdzAdpater
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
+import com.blankj.utilcode.util.LogUtils
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
+import org.jetbrains.anko.*
+import org.jetbrains.anko.support.v4.UI
+
+/**
+ * 商品掉期fragment
+ */
+class GoodsSwapsFragment : BaseFragment<GoodsSwapsViewModel>() , TransferSwapsAdapter.OnContentScrollListener{
+
+    companion object {
+        fun getInstance() = GoodsSwapsFragment()
+    }
+
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+    lateinit var horScrollview: CustomHorizontalScrollView
+    lateinit var recyclerView: RecyclerView
+
+    lateinit var dataRecyclerview : RecyclerView
+
+    var fistShow: Int = 0
+    var lastShow: Int = 0
+
+    val thisTag by lazy {
+        this.tag
+    }
+
+    //标题头部
+    val topAdapter by lazy {
+        TopTabYrdzAdpater(activity)
+    }
+
+    val transferSwapsAdapter by lazy {
+        TransferSwapsAdapter(activity)
+    }
+
+    //注册eventbus
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        EventBus.getDefault().register(this)
+    }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        EventBus.getDefault().unregister(this)
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
+        /** 行情推送过来的goodsid **/
+        quoteMessageEvent.goodsid.forEach { goodid ->
+            LogUtils.eTag("dadafafsjhdkjahkjdhak",goodid)
+            //找到相应商品信息
+            val goodsInfo = viewModel.swapsDataList.value?.find { it.goodsid == goodid }
+            viewModel.swapsDataList.value?.indexOf(goodsInfo)?.let {
+                if (it != -1) {//刷新相应item
+                    dataRecyclerview.adapter?.notifyItemChanged(it)
+                }
+            }
+        }
+
+    }
+
+    override fun onCreateView(
+        inflater: LayoutInflater,
+        container: ViewGroup?,
+        savedInstanceState: Bundle?
+    ): View? {
+        return UI {
+            viewModel.initData(tag = thisTag ?: ""){isCompleted, err ->
+                if (isCompleted){
+                    transferSwapsAdapter.notifyDataSetChanged()
+                }
+            }
+            verticalLayout {
+
+                linearLayout {
+                    linearLayout {
+                        gravity = Gravity.CENTER
+                        textView {//待点价头部左侧数据
+//                            viewModel.titleList.bindOptional(context) {
+//                                text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
+//                            }
+                            text = "合约"
+                            textColorStr = "#AAAAAA"
+                            textSizeAuto = 31
+                        }.lparams(wrapContent, wrapContent)
+                    }.lparams(autoSize(250), autoSize(100))
+                    transferSwapsAdapter.setOnContentScrollListener(this@GoodsSwapsFragment)
+                    inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
+                        horScrollview = this
+                        setOnCustomScrollChangeListener { listener, scrollX, scrollY, oldScrollX, oldScrollY -> //代码重复,可以抽取/////
+                            transferSwapsAdapter.offestX = scrollX
+                            val viewHolderCacheList: List<TransferSwapsAdapter.ItemViewHolder> =
+                                transferSwapsAdapter.viewHolderCacheList
+                            if (null != viewHolderCacheList) {
+                                val size = viewHolderCacheList.size
+                                for (i in 0 until size) {
+                                    viewHolderCacheList[i].horItemScrollview.scrollTo(
+                                        scrollX,
+                                        0
+                                    )
+                                }
+                            }
+                        }
+                        relativeLayout {
+                            recyclerView {//待点价头部右侧数据
+                                val linearLayoutManager = LinearLayoutManager(context)
+                                linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
+                                layoutManager = linearLayoutManager
+                                background = resources.getDrawable(R.color.white)
+                                adapter = topAdapter
+                            }
+//                            viewModel.titleList.bindOptional(context) {
+//                                val titleStringList = arrayListOf<String>()
+//                                it?.subList(1, it.size)?.forEach { data ->
+//                                    titleStringList.add(data.columntitle?.replace("\\n", "\n") ?: "")
+//                                }
+//                                topAdapter.setDatas(titleStringList)
+//                            }
+                            topAdapter.setDatas(arrayListOf("卖价","卖量","买价","买量","最新价","涨跌","幅度","今开","昨收","最低","最高"))
+                        }
+                    }.lparams(matchParent, matchParent)
+                }.lparams(matchParent, autoSize(100))
+
+                statusLayout(contentBlock = {
+                    statusLayout = this
+                    setRetryAction {
+
+                    }
+//                bindTaskStatus(viewModule.status)
+                    swipeToLoadLayout {
+                        swipeToLayout = this
+                        setEnableRefresh(true)
+                        setEnableLoadMore(false)
+                        setOnRefreshListener {
+                            viewModel.queryQuoteDay(
+                                tag = thisTag ?: "",
+                                first = fistShow,
+                                last = lastShow,
+                                list = viewModel.swapsDataList.value ?: arrayListOf()
+                            ) { isCompleted, err ->
+                                if (isCompleted) {
+                                    if (swipeToLayout.getIsRefreshing()) {
+                                        swipeToLayout.finishRefresh()
+                                    }
+                                    dataRecyclerview.adapter?.notifyItemRangeChanged(fistShow, lastShow)
+                                }
+                            }
+                        }
+                        setEnableScrollContentWhenLoaded(false)
+                        setEnableLoadMoreWhenContentNotFull(false)
+
+                        recyclerView {//待点价列表
+                            dataRecyclerview = this
+                            background = resources.getDrawable(R.color.white)
+                            adapter = transferSwapsAdapter
+                            addOnScrollListener(object : RecyclerView.OnScrollListener() {
+                                override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
+                                    super.onScrolled(recyclerView, dx, dy)
+                                    val viewHolderCacheList: List<TransferSwapsAdapter.ItemViewHolder> =
+                                        transferSwapsAdapter.viewHolderCacheList
+                                    if (null != viewHolderCacheList) {
+                                        val size = viewHolderCacheList.size
+                                        for (i in 0 until size) {
+                                            viewHolderCacheList[i].horItemScrollview.scrollTo(
+                                                transferSwapsAdapter.getOffestX(),
+                                                0
+                                            )
+                                        }
+                                    }
+                                }
+                            })
+
+                            addOnScrollListener(object : RecyclerView.OnScrollListener() {
+                                override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
+                                    super.onScrollStateChanged(recyclerView, newState)
+                                    // DES: 找出当前可视Item位置
+                                    val linearLayoutManager = dataRecyclerview!!.layoutManager as LinearLayoutManager
+                                    if (newState == RecyclerView.SCROLL_STATE_IDLE) {// 这个判断是当recyclerview不滚动时
+                                        fistShow = linearLayoutManager.findFirstVisibleItemPosition()//获取第一个显示条目
+                                        lastShow = linearLayoutManager.findLastVisibleItemPosition()//获取最后一个显示条目
+                                        if (fistShow != -1 && lastShow != -1) {
+                                            viewModel.queryQuoteDay(
+                                                tag = thisTag ?: "",
+                                                first = fistShow,
+                                                last = lastShow,
+                                                list = viewModel.swapsDataList.value ?: arrayListOf()
+                                            ) { isCompleted, err ->
+                                                if (isCompleted) {
+                                                    dataRecyclerview.adapter?.notifyItemRangeChanged(fistShow, lastShow)
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            })
+                        }
+
+
+                    }
+                }, emptyBlock = {
+                    emptyView(hint = resources.getString(R.string.now_no_data))
+                }).lparams(matchParent, matchParent)
+
+                viewModel.swapsDataList.bindOptional(context) {
+                    if (it?.size ?: 0 > 10){
+                        lastShow = 10
+                    }else{
+                        lastShow = it?.size ?: 0
+                    }
+                    if (it?.isEmpty() == true || it?.size == 0) {
+                        statusLayout.showEmpty()
+                    } else {
+                        if (swipeToLayout.getIsRefreshing()) {
+                            swipeToLayout.finishRefresh()
+//                        mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
+                        }
+                        statusLayout.showSuccess()
+                        transferSwapsAdapter.setDatas(it)
+                    }
+                }
+            }
+        }.view
+    }
+
+    override fun onScroll(event: MotionEvent?) {
+        //处理单个item滚动时,顶部tab需要联动
+        if (null != horScrollview) horScrollview.onTouchEvent(event)
+    }
+
+
+}

+ 104 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/GoodsSwapsViewModel.kt

@@ -0,0 +1,104 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.global.database.DataBase
+import cn.muchinfo.rma.view.MyApplication
+import cn.muchinfo.rma.view.base.BaseViewModel
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+
+/**
+ * 商品掉期viewmodel
+ */
+class GoodsSwapsViewModel : BaseViewModel(){
+
+
+    //掉期数据列表
+    val swapsDataList : MutableLiveData<List<GoodsInfo>> = MutableLiveData()
+
+
+    /**
+     * 初始化列表
+     * @param tag String
+     * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
+     */
+    fun initData(tag: String,callback: (isCompleted: Boolean, err: Error?) -> Unit){
+        val list = arrayListOf<GoodsInfo>()
+        val allList = DataBase.getInstance().goodsInfoDao().all
+        val deliveryRelationList = GlobalDataCollection.instance?.deliveryRelationDataArrayList
+        //需要知道掉期trademodel
+        allList.forEach {data ->
+            if (data.trademode == 16 && data.goodsstatus == 3){
+                list.add(data)
+            }
+        }
+        swapsDataList.postValue(list)
+        if (list.size > 10){
+            queryQuoteDay(tag,0,10,list){isCompleted, err ->
+                callback(isCompleted, err)
+            }
+        }else{
+            queryQuoteDay(tag,0,list.size,list){isCompleted, err ->
+                callback(isCompleted, err)
+            }
+        }
+    }
+
+    /**
+     * 请求盘面信息
+     * @param first Int
+     * @param last Int
+     * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
+     */
+    fun queryQuoteDay(
+        tag: String,
+        first: Int,
+        last: Int,
+        list : List<GoodsInfo> = arrayListOf(),
+        callback: (isCompleted: Boolean, err: Error?) -> Unit
+    ) {
+        val goodsCodes = getgoodsCodes(first, last,list)
+        val params = mutableMapOf<String, String>().apply {
+            put("goodsCodes", goodsCodes)
+        }
+        MyApplication.getInstance()?.futureManager?.queryQuoteDay(params = params) { isSuccess, respData, error ->
+            if (isSuccess) {
+                callback(true, null)
+            } else {
+                callback(false, error)
+            }
+        }
+
+        swapsDataList.value?.subList(first, last)?.let { addSubscriptQuote(tag = tag, goodsInfoList = it) }
+    }
+
+
+    //获取本商品的盘面信息的同时,还要获取关联商品的盘面信息
+    fun getgoodsCodes(first: Int, last: Int,list : List<GoodsInfo>): String {
+        var goodsCodes = ""
+        val newList = list.subList(first, last)
+        newList.forEach {
+            goodsCodes = goodsCodes + it.goodscode + ","
+        }
+        return goodsCodes
+    }
+
+    /**
+     * 订阅行情
+     * @param tag String
+     * @param goodsInfoList List<GoodsInfo>
+     */
+    fun addSubscriptQuote(tag: String, goodsInfoList: List<GoodsInfo>) {
+        GlobalScope.launch {
+            MyApplication.getInstance()?.quoteManager?.addSubscriptQuote(
+                tag = tag, goodsCodeSet = goodsInfoList.map { it.goodscode ?: "" }.toSet()
+            ) { _, _ ->
+
+            }
+        }
+    }
+
+
+}

+ 362 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/TransferSwapsAdapter.java

@@ -0,0 +1,362 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.blankj.utilcode.util.ActivityUtils;
+import com.blankj.utilcode.util.ToastUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.muchinfo.rma.R;
+import cn.muchinfo.rma.global.GlobalDataCollection;
+import cn.muchinfo.rma.global.data.ContractTradePositionData;
+import cn.muchinfo.rma.global.data.DeliveryRelationData;
+import cn.muchinfo.rma.global.data.GoodsInfoAndQuotes;
+import cn.muchinfo.rma.global.data.OrderQuoteData;
+import cn.muchinfo.rma.global.data.QuoteDayData;
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo;
+import cn.muchinfo.rma.global.database.DataBase;
+import cn.muchinfo.rma.view.autoWidget.CustomHorizontalScrollView;
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils;
+import cn.muchinfo.rma.view.base.platinumtreasure.adapter.QHjRightData;
+import cn.muchinfo.rma.view.base.platinumtreasure.adapter.QhjRightScrollAdapter;
+import cn.muchinfo.rma.view.base.warehousereceipt.BusinessHallDetailsActivity;
+import cn.muchinfo.rma.view.base.yrdzpurchase.business.ContractBusinessHallActivity;
+import cn.muchinfo.rma.view.base.yrdzpurchase.chart.YrdzChartActivity;
+
+/**
+ * 掉期adapter
+ */
+public class TransferSwapsAdapter extends RecyclerView.Adapter<TransferSwapsAdapter.ItemViewHolder> {
+
+
+    private Context context;
+    private List<GoodsInfo> datas;
+    private int index = -1;
+    private int position = -1;
+    private List<ItemViewHolder> mViewHolderList = new ArrayList<>();
+    public int offestX = 0;
+    private OnContentScrollListener onContentScrollListener;
+
+
+    public interface OnContentScrollListener {
+        void onScroll(MotionEvent event);
+    }
+
+    public void setOnContentScrollListener(OnContentScrollListener onContentScrollListener) {
+        this.onContentScrollListener = onContentScrollListener;
+    }
+
+    public TransferSwapsAdapter(Context context) {
+        this.context = context;
+    }
+
+    public void setDatas(List<GoodsInfo> datas) {
+        this.datas = datas;
+        notifyDataSetChanged();
+    }
+
+    private void setPosition(int position) {
+        if (this.position == position) {
+            this.position = -1;
+            notifyItemChanged(index);
+        } else {
+            this.position = position;
+            notifyItemChanged(position);
+        }
+    }
+
+    @NonNull
+    @Override
+    public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
+        View view = LayoutInflater.from(context).inflate(R.layout.layout_item_transfer_content, viewGroup, false);
+        return new ItemViewHolder(view);
+    }
+
+    //回购 买一价  销售 卖一价
+    @SuppressLint("SetTextI18n")
+    @Override
+    public void onBindViewHolder(@NonNull final ItemViewHolder itemViewHolder, int i) {
+        this.index = i;
+        GoodsInfo data = datas.get(i);
+        itemViewHolder.tvLeftTitle.setText(datas.get(i).getGoodsname());
+        //右边滑动部分
+        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
+        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        itemViewHolder.rvItemRight.setLayoutManager(linearLayoutManager);
+        itemViewHolder.rvItemRight.setHasFixedSize(true);
+        QhjRightScrollAdapter qhjRightScrollAdapter = new QhjRightScrollAdapter(context);
+        List<QHjRightData> rightData = new ArrayList<>();
+        //获取盘面信息
+        QuoteDayData quoteDayData = null;//当前商品的盘面信息(有用的只有买一卖一价即回购销售价,其他信息用关联商品的)
+
+        GoodsInfo relateGoodsInfo = null;//关联商品实体
+        relateGoodsInfo = DataBase.Companion.getInstance().goodsInfoDao().getGoodsInfo(data.getRelatedgoodsid());//获取关联商品的商品详情
+        List<GoodsInfoAndQuotes> quotesList = GlobalDataCollection.Companion.getInstance().getGoodsInfoAndQuotesList();//获取盘面信息列表
+        for (int j = 0; j < quotesList.size(); j++) {
+            if (quotesList.get(j) != null) {
+                if (data.getGoodscode().equals(quotesList.get(j).getOutgoodscode())) {
+                    quoteDayData = quotesList.get(j).getQuoteDayData();//赋值当前商品的盘面信息
+                }
+            }
+        }
+
+        if (quoteDayData != null) {
+//            // 卖价取卖一价
+//            QHjRightData askData = new QHjRightData();
+//            askData.setValue(NumberUtils.roundNum(NumberUtils.doubleDistortion(String.valueOf(quoteDayData.getAsk())), 2));
+//            askData.setColorType("3");
+//            rightData.add(askData);
+
+
+
+//            //买价取买一价
+//            QHjRightData bidData = new QHjRightData();
+//            bidData.setValue(NumberUtils.roundNum(NumberUtils.doubleDistortion(String.valueOf(quoteDayData.getBid())), 2));
+//            bidData.setColorType("3");
+//            rightData.add(bidData);
+        }
+
+        if (quoteDayData != null) {
+
+            //最新价
+            QHjRightData newPriceData = new QHjRightData();
+            if (quoteDayData.getLast() == 0.0){
+                newPriceData.setValue("--");
+                newPriceData.setColorType("1");
+            }else {
+                newPriceData.setValue(NumberUtils.roundNum(NumberUtils.doubleDistortion(String.valueOf(quoteDayData.getPrice())), 2));
+                newPriceData.setColorType(quoteDayData.getColor());
+            }
+
+            // 卖量取卖一量
+            QHjRightData askNumberData = new QHjRightData();
+            askNumberData.setValue(String.valueOf(quoteDayData.getAskvolume()));
+            askNumberData.setColorType("1");
+
+            //买量取买一量
+            QHjRightData biNumberData = new QHjRightData();
+            biNumberData.setValue(String.valueOf(quoteDayData.getBidvolume()));
+            biNumberData.setColorType("1");
+
+            //涨跌幅
+            QHjRightData appliesData = new QHjRightData();
+            //涨跌
+            QHjRightData riseFallData = new QHjRightData();
+
+            if (quoteDayData.getLast() != 0 && quoteDayData.getPreclose() != 0) {
+                String textApplies = "";
+                String textUpDown = NumberUtils.roundNum(NumberUtils.doubleDistortion(String.valueOf((quoteDayData.getPrice() - quoteDayData.getPresettle()))), 2);//涨跌
+                if (quoteDayData.getPresettle() == 0) {
+                    textApplies = "--";
+                } else {
+                    textApplies = NumberUtils.roundNum(String.valueOf((((quoteDayData.getPrice() - quoteDayData.getPresettle()) / quoteDayData.getPresettle()) * 100)), 2);//涨跌幅
+                }
+                riseFallData.setValue(textUpDown);
+                appliesData.setValue(textApplies + "%");
+                if (Double.valueOf(textUpDown) > 0) {
+                    riseFallData.setColorType("3");
+                    appliesData.setColorType("3");
+                } else if (Double.valueOf(textUpDown) < 0) {
+                    riseFallData.setColorType("2");
+                    appliesData.setColorType("2");
+                } else {
+                    riseFallData.setColorType("1");
+                    appliesData.setColorType("1");
+                }
+            } else {
+                appliesData.setValue("--");
+                appliesData.setColorType("1");
+                riseFallData.setValue("--");
+                riseFallData.setColorType("1");
+            }
+            rightData.add(newPriceData);//当前价
+            rightData.add(riseFallData);//涨跌
+            rightData.add(appliesData);//涨跌幅
+            rightData.add(askNumberData);//卖量
+            rightData.add(biNumberData);//买量
+        }
+        ContractTradePositionData positionData = null;
+        List<ContractTradePositionData> positionDataList = GlobalDataCollection.Companion.getInstance().getContractTradePositionDataArrayList();
+        for (int j = 0; j < positionDataList.size(); j++) {
+            if (String.valueOf(data.getGoodsid()).equals(positionDataList.get(j).getGoodsid())) {
+                positionData = positionDataList.get(j);
+            }
+        }
+
+        DeliveryRelationData deliveryData = null;
+        List<DeliveryRelationData> deliveryRelationDataList = GlobalDataCollection.Companion.getInstance().getDeliveryRelationDataArrayList();
+        for (int j = 0; j < deliveryRelationDataList.size(); j++) {
+            if (String.valueOf(data.getGoodsid()).equals(deliveryRelationDataList.get(j).getGoodsid())) {
+                deliveryData = deliveryRelationDataList.get(j);
+            }
+        }
+        if (deliveryData == null){
+            itemViewHolder.platnum_details.setVisibility(View.GONE);
+        }else {
+            itemViewHolder.platnum_details.setVisibility(View.VISIBLE);
+        }
+
+        qhjRightScrollAdapter.setDatas(rightData);
+        itemViewHolder.rvItemRight.setAdapter(qhjRightScrollAdapter);
+        //缓存当前holder
+        if (!mViewHolderList.contains(itemViewHolder)) {
+            mViewHolderList.add(itemViewHolder);
+        }
+        if (i == this.position) {
+            itemViewHolder.roots_view.setBackgroundColor(context.getResources().getColor(R.color.qhj_click_bg));
+            itemViewHolder.allView.setVisibility(View.VISIBLE);
+        } else {
+            itemViewHolder.roots_view.setBackgroundColor(context.getResources().getColor(R.color.white));
+            itemViewHolder.allView.setVisibility(View.GONE);
+        }
+
+        itemViewHolder.all_click_View.setOnClickListener(view -> setPosition(i));
+        itemViewHolder.horItemScrollview.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                setPosition(i);
+            }
+        });
+        //买入点击
+        itemViewHolder.transfer_buy.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Intent intent = new Intent();
+                intent.putExtra("goodsId", String.valueOf(data.getGoodsid()));
+                intent.putExtra("goodsCode", data.getGoodscode());
+                intent.setClass(context, ContractBusinessHallActivity.class);
+                ActivityUtils.startActivity(intent);
+            }
+        });
+        itemViewHolder.platnum_chart.setVisibility(View.GONE);
+        //图表点击
+        itemViewHolder.platnum_chart.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Intent intent = new Intent();
+                intent.putExtra("outGoodsCode", data.getOutgoodscode());
+                intent.putExtra("goodsCode", data.getGoodscode());
+                intent.putExtra("goodsId", String.valueOf(data.getGoodsid()));
+                intent.putExtra("type", "1");
+                intent.putExtra("marketId", data.getMarketid());
+                intent.setClass(context, YrdzChartActivity.class);
+                ActivityUtils.startActivity(intent);
+            }
+        });
+
+
+        itemViewHolder.platnum_details.setVisibility(View.GONE);
+        //详情点击
+        itemViewHolder.platnum_details.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Intent intent = new Intent();
+                intent.putExtra("data", new OrderQuoteData());
+                intent.putExtra("type", "3");
+                intent.putExtra("isCircle","0");
+                intent.putExtra("goodsId", String.valueOf(data.getGoodsid()));
+                intent.setClass(context, BusinessHallDetailsActivity.class);
+                ActivityUtils.startActivity(intent);
+            }
+        });
+        itemViewHolder.rvItemRight.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                ToastUtils.showLong("ahhahahha");
+            }
+        });
+
+
+        itemViewHolder.horItemScrollview.setEventListener(new CustomHorizontalScrollView.EventListener() {
+            @Override
+            public void onEvent(MotionEvent ev) {
+
+                if (null != onContentScrollListener) onContentScrollListener.onScroll(ev);
+
+            }
+        });
+        //由于viewHolder的缓存,在1级缓存取出来是2个viewholder,并且不会被重新赋值,所以这里需要处理缓存的viewholder的位移
+        itemViewHolder.horItemScrollview.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+            @Override
+            public void onGlobalLayout() {
+                if (!itemViewHolder.isLayoutFinish()) {
+                    itemViewHolder.horItemScrollview.scrollTo(offestX, 0);
+                    itemViewHolder.setLayoutFinish(true);
+                }
+            }
+        });
+    }
+
+    float start, end;
+    float distance = 0;
+    boolean isclick = false;
+    boolean isFirst = false;
+
+    @Override
+    public int getItemCount() {
+        return null == datas ? 0 : datas.size();
+    }
+
+    public List<ItemViewHolder> getViewHolderCacheList() {
+        return mViewHolderList;
+    }
+
+    public int getOffestX() {
+        return offestX;
+    }
+
+    public static class ItemViewHolder extends RecyclerView.ViewHolder {
+        LinearLayout roots_view;//根部布局
+        TextView transfer_buy;//买卖大厅
+        TextView platnum_chart;//图表
+        TextView platnum_details;//详情
+        LinearLayout allView;//隐藏的底部操作空间
+        LinearLayout all_click_View;//item左侧点击控件
+        RelativeLayout item_onclick;
+        TextView tvLeftTitle;//左边销售方字段
+        RecyclerView rvItemRight;//右方的列表
+        ImageView click_icon;//图标
+        public CustomHorizontalScrollView horItemScrollview;//右方的滑动控件
+        private boolean isLayoutFinish;//自定义字段,用于标记layout
+
+        public boolean isLayoutFinish() {
+            return isLayoutFinish;
+        }
+
+        public void setLayoutFinish(boolean layoutFinish) {
+            isLayoutFinish = layoutFinish;
+        }
+
+        public ItemViewHolder(@NonNull View itemView) {
+            super(itemView);
+            item_onclick = itemView.findViewById(R.id.item_onclick);
+            click_icon = itemView.findViewById(R.id.click_icon);
+            transfer_buy = itemView.findViewById(R.id.transfer_buy);
+            platnum_chart = itemView.findViewById(R.id.platnum_chart);
+            platnum_details = itemView.findViewById(R.id.platnum_details);
+            tvLeftTitle = itemView.findViewById(R.id.tv_left_title);
+            rvItemRight = itemView.findViewById(R.id.rv_item_right);
+            horItemScrollview = itemView.findViewById(R.id.hor_item_scrollview);
+            allView = itemView.findViewById(R.id.all_view);
+            all_click_View = itemView.findViewById(R.id.all_click_View);
+            roots_view = itemView.findViewById(R.id.roots_view);
+        }
+    }
+}

+ 123 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessBuyHallViewHolder.kt

@@ -0,0 +1,123 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.business
+
+import android.content.Intent
+import android.view.Gravity
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.OrderQuoteDetailData
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
+import cn.muchinfo.rma.global.utils.VIewUtils
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.yrdzpurchase.delisting.PurchaseDelistingActivity
+import com.blankj.utilcode.util.ActivityUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+
+/**
+ * 买大厅viewholer
+ * @property activity AppCompatActivity
+ * @property viewModel BusinessHallViewModel
+ * @property itemSize IntArray
+ * @constructor
+ */
+class SwapsBusinessBuyHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String) : BaseViewHolder<WrTradeOrderDetailData>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+        verticalLayout {
+            background = resources.getDrawable(R.color.buy_color_bg)
+            data.bindOptional(context) {
+                if (it?.isClick == 0) {
+                   background = resources.getDrawable(R.color.buy_color_bg)
+                } else if (it?.isClick == 1) {
+                    background = resources.getDrawable(R.color.white)
+                }
+            }
+            onThrottleFirstClick {
+                viewModel.setOnBuyItemClick(data.value?.orderid ?: "")
+            }
+
+            linearLayout {
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
+                    textView {
+                        data.bindOptional(context){
+                            text = NumberUtils.roundNum(it?.orderprice,2)
+                        }
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(0, autoSize(90),1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER
+                    textView {
+                        data.bindOptional(context){
+                            text = it?.orderqty
+                        }
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent)
+                }.lparams(0, autoSize(90),1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
+                    textView {
+                        data.bindOptional(context){
+                            text = it?.userid + "  "  + it?.username
+                        }
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent){
+                        marginEnd = autoSize(36)
+                    }
+                }.lparams(0, autoSize(90),1f)
+            }.lparams(matchParent, autoSize(90))
+
+            // 控制区
+            linearLayout {
+                data.bindOptional(context) {
+                    if (it?.isClick == 0) {
+                        visibility = View.GONE
+                    } else if (it?.isClick == 1) {
+                        visibility = View.VISIBLE
+                    }
+                }
+                gravity = Gravity.CENTER_VERTICAL
+
+                emptyView()
+
+                textView {
+                    onThrottleFirstClick {
+                        onThrottleFirstClick {
+                            val intent = Intent()
+                            intent.putExtra("data",data.value)
+                            intent.putExtra("goodsId",data.value?.goodsid)
+                            intent.putExtra("goodsCode",goodsCode)
+                            intent.putExtra("type","0")
+                            intent.setClass(context, PurchaseDelistingActivity::class.java)
+                            ActivityUtils.startActivity(intent)
+                        }
+                    }
+                    backgroundResource = R.drawable.rma_item_click_bg
+                    gravity = Gravity.CENTER
+                    text = "摘牌"
+                    textColorInt = R.color.rma_item_click_color
+                    textSizeAuto = 26
+                }.lparams(autoSize(120), autoSize(48)) {
+                    marginEnd = autoSize(24)
+                }
+            }.lparams(matchParent, autoSize(72))
+        }.lparams(matchParent, wrapContent)
+    }
+
+}

+ 632 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallActivity.kt

@@ -0,0 +1,632 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.business
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.MutableLiveData
+import androidx.viewpager.widget.PagerAdapter
+import androidx.viewpager.widget.ViewPager
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.*
+import cn.muchinfo.rma.global.data.OrderQuoteData
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
+import cn.muchinfo.rma.global.database.DataBase
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
+import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.warehousereceipt.BusinessHallDetailsActivity
+import cn.muchinfo.rma.view.base.yrdzpurchase.listed.PurchaseListedActivity
+import cn.muchinfo.rma.view.eventbus.EventConstent
+import cn.muchinfo.rma.view.eventbus.MessageEvent
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
+import com.blankj.utilcode.util.ActivityUtils
+import com.blankj.utilcode.util.ConvertUtils
+import com.blankj.utilcode.util.LogUtils
+import com.qmuiteam.qmui.util.QMUIDisplayHelper
+import com.qmuiteam.qmui.widget.tab.QMUITabIndicator
+import com.qmuiteam.qmui.widget.tab.QMUITabSegment
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
+import org.jetbrains.anko.*
+import org.jetbrains.anko.support.v4.viewPager
+
+/**
+ * 合约市场买卖大厅
+ */
+class SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
+
+    lateinit var segment: QMUITabSegment
+    var selectedTabIndex: Int = 0
+    private lateinit var viewPager: ViewPager
+
+    val goodsId by lazy { intent.getStringExtra("goodsId") }
+
+    val goodsCode by lazy { intent.getStringExtra("goodsCode") }
+
+    //价格涨跌的上下箭头
+    lateinit var updowm_image : ImageView
+
+    //顶部数据是否展开
+    val priceUpDown: MutableLiveData<Boolean> = MutableLiveData<Boolean>().apply { value = false }
+
+    /** 用于订阅行情的唯一标识 */
+    val thisTag by lazy {
+        "ContractBusinessHallActivity"
+    }
+
+    //买大厅
+    val buyHallUI by lazy { SwapsBuyHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
+
+    //卖大厅
+    val sellHallUI by lazy { SwapsSellHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
+
+    //viewpager的适配器
+    private var newPagerAdapter: PagerAdapter? = null
+
+    //tabSegment标题
+    private val newTabsArray: ArrayList<String> = arrayListOf()
+
+    //暂存的页面组
+    private val uiList: ArrayList<_FrameLayout> = arrayListOf()
+
+    val selectIndex: MutableLiveData<Int> = MutableLiveData()
+
+    fun initMenuData() {
+
+        newTabsArray.add("卖大厅")
+        uiList.add(sellHallUI.root)
+
+        newTabsArray.add("买大厅")
+        uiList.add(buyHallUI.root)
+
+        newPagerAdapter = object : PagerAdapter() {
+
+            override fun getPageTitle(position: Int): CharSequence? = newTabsArray[position]
+
+            override fun instantiateItem(container: ViewGroup, position: Int): Any {
+                return uiList.get(position).apply {
+                    container.addView(
+                        this,
+                        ViewGroup.LayoutParams(matchParent, matchParent)
+                    )
+                }
+            }
+
+            override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
+                (`object` as? View)?.let { container.removeView(it) }
+            }
+
+            override fun isViewFromObject(view: View, `object`: Any): Boolean = view == `object`
+
+            override fun getCount(): Int = newTabsArray.size
+
+        }
+
+    }
+
+    //通用的消息更新通知
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onMessageEvent(messageEvent: MessageEvent) {
+        if (messageEvent.messageType == EventConstent.FID_MoneyChangedNtf) {//资金账号变化通知
+            viewModel.getTaAccounts()
+        }
+    }
+
+    //行情推送通知
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
+        val goodsids = quoteMessageEvent.goodsid
+        //如果推送的goodsid包含当前页面的goodsid,则进行页面刷新
+        if (goodsids.contains(goodsId?.toInt())) {
+            LogUtils.eTag("BusinessHallActivity", "行情推送" + goodsId)
+            val quote =
+                GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find { goodsCode == it.outgoodscode }?.quoteDayData
+            if (quote != null) {
+                //赋值盘面信息
+                viewModel.quoteDayData.postValue(quote)
+            }
+        }
+    }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        viewModel.removeSubscriptQuote(thisTag)
+        EventBus.getDefault().unregister(this)
+    }
+
+    //初始化商品信息
+    fun initializeData() {
+        viewModel.goodsInfo.postValue(
+            DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0)
+        )
+        viewModel.queryQuoteDay(tag = thisTag, goodsCodes = goodsCode ?: "", isShowLoading = false)
+    }
+
+
+    override fun onResume() {
+        super.onResume()
+        viewModel.queryBuyDataList(goodsid = goodsId ?: "")
+        viewModel.querySellDataList(goodsid = goodsId ?: "")
+        viewModel.queryQuoteDay(tag = thisTag, goodsCodes = goodsCode ?: "", isShowLoading = false)
+    }
+
+    @SuppressLint("SetTextI18n")
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        initMenuData()
+        initializeData()
+
+        verticalLayout {
+
+            createLoadingDialog(hintStr = "").bindTaskStatus(context, viewModel.loadingDialogStatus)
+
+            //头部标题
+            linearLayout {
+                background = resources.getDrawable(R.color.main_title_bg_color)
+                gravity = Gravity.CENTER_VERTICAL
+                imageView {
+                    onThrottleFirstClick {
+                        finish()
+                    }
+                    imageResource = R.mipmap.back
+                }.lparams(autoSize(45), autoSize(45)) {
+                    marginStart = autoSize(36)
+                }
+
+                view {
+
+                }.lparams(autoSize(45), autoSize(45)) {
+                    marginStart = autoSize(36)
+                }
+
+                emptyView()
+
+                verticalLayout {
+                    gravity = Gravity.CENTER
+                    textView {
+                        viewModel.goodsInfo.bindOptional(context) {
+                            text = it?.goodsname
+                        }
+                        textSizeAuto = 41
+                        textColorInt = R.color.white
+                    }.lparams(wrapContent, wrapContent) {
+                        topMargin = autoSize(10)
+                    }
+                }.lparams(wrapContent, autoSize(120))
+
+                emptyView()
+
+
+                imageView {
+                    onThrottleFirstClick {
+                        val intent = Intent()
+                        intent.putExtra("goodsId", goodsId)
+                        intent.putExtra("goodsCode", goodsCode)
+                        intent.setClass(context, PurchaseListedActivity::class.java)
+                        ActivityUtils.startActivity(intent)
+                    }
+                    imageResource = R.mipmap.hnst_add_icon
+                }.lparams(autoSize(45), autoSize(45)) {
+                    marginEnd = autoSize(36)
+                }
+
+                imageView {
+                    onThrottleFirstClick {
+                        val intent = Intent()
+                        intent.putExtra("data", OrderQuoteData())
+                        intent.putExtra("isCircle","0")
+                        intent.putExtra("type", "3")
+                        intent.putExtra("goodsId", goodsId)
+                        intent.setClass(context, BusinessHallDetailsActivity::class.java)
+                        ActivityUtils.startActivity(intent)
+                    }
+                    imageResource = R.mipmap.business_two
+                }.lparams(autoSize(45), autoSize(45)) {
+                    marginEnd = autoSize(36)
+                }
+            }.lparams(matchParent, autoSize(120))
+
+            linearLayout {
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "卖价"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(20)
+                    }
+
+                    emptyView()
+
+                    textView {
+                        viewModel.quoteDayData.bindOptional(context) {
+                            text = NumberUtils.roundNum(it?.ask?.toString(), 2)?.isZeroBlankString()
+                            textColorInt =
+                                it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
+                        }
+                        textSizeAuto = 29
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(20)
+                    }
+                }.lparams(0, autoSize(70),1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "卖量"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(30)
+                    }
+
+                    emptyView()
+
+                    textView {
+                        viewModel.quoteDayData.bindOptional(context) {
+                            text = NumberUtils.turnoverShort(it?.askvolume?.toString())?.isZeroBlankString()
+                        }
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(20)
+                    }
+                }.lparams(0, autoSize(70),1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "买价"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(30)
+                    }
+
+                    emptyView()
+
+                    textView {
+                        viewModel.quoteDayData.bindOptional(context) {
+                            text = NumberUtils.roundNum(it?.bid?.toString(), 2)?.isZeroBlankString()
+                            textColorInt =
+                                it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
+                        }
+                        textSizeAuto = 29
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(20)
+                    }
+                }.lparams(0, autoSize(70),1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    textView {
+                        text = "买量"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(30)
+                    }
+
+                    emptyView()
+
+                    textView {
+                        viewModel.quoteDayData.bindOptional(context) {
+                            text = NumberUtils.turnoverShort(it?.bidvolume?.toString())?.isZeroBlankString()
+                        }
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(20)
+                    }
+                }.lparams(0, autoSize(70),1f)
+            }.lparams(matchParent, autoSize(70))
+
+            linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "标的"
+                    textSizeAuto = 29
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(30)
+                }
+
+                textView {
+                    text = "IC2014"
+                    textSizeAuto = 29
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(20)
+                }
+
+                textView {
+                    text = "1312"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_red_color
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(20)
+                }
+
+                textView {
+                    text = "+90"
+                    textSizeAuto = 29
+                    textColorInt = R.color.rma_red_color
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(20)
+                }
+
+                textView {
+                    text = "+1.28%"
+                    textSizeAuto = 29
+                    textColorInt = R.color.rma_red_color
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(20)
+                }
+            }.lparams(matchParent, autoSize(70))
+
+            tabSegment {
+                segment = this
+                background = resources.getDrawable(R.color.segtabment_bg_color)
+                addOnTabSelectedListener(object :
+                    QMUITabSegment.OnTabSelectedListener {
+                    override fun onDoubleTap(index: Int) {}
+                    override fun onTabReselected(index: Int) {}
+                    override fun onTabUnselected(index: Int) {}
+                    override fun onTabSelected(index: Int) {
+                        selectedTabIndex = index
+                        selectIndex.postValue(index)
+                    }
+                })
+                setIndicator(
+                    QMUITabIndicator(
+                        QMUIDisplayHelper.dp2px(context, 2),
+                        false,
+                        true
+                    )
+                )
+                setDefaultTextSize(ConvertUtils.sp2px(16f), ConvertUtils.sp2px(18f))
+            }.lparams(matchParent, autoSize(100))
+
+            view {
+                background = resources.getDrawable(R.color.main_hit_bg_color)
+            }.lparams(matchParent, autoSize(1)) {
+                marginStart = autoSize(32)
+                marginEnd = autoSize(32)
+            }
+            viewPager {
+                background = resources.getDrawable(R.color.white)
+                viewPager = this
+                adapter = newPagerAdapter
+            }.lparams(matchParent, matchParent)
+
+            segment.setupWithViewPager(viewPager)
+            segment.selectTab(selectedTabIndex)
+
+        }
+    }
+
+}
+
+
+/**
+ * 卖大厅
+ * @property activity AppCompatActivity
+ * @property viewModel BusinessHallViewModel
+ * @constructor
+ */
+class SwapsSellHallUI(
+    private val activity: AppCompatActivity,
+    private val viewModel: SwapsBusinessHallViewModel,
+    private val goodsId: String,
+    private val goodsCode: String
+) {
+
+    // 下拉刷新
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    private val businessSellHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessSellHallViewHolder> =
+        BaseAdapter { _, _ ->
+            SwapsBusinessSellHallViewHolder(
+                activity,
+                viewModel,
+                goodsCode
+            )
+        }
+
+    val root = _FrameLayout(activity).apply {
+        verticalLayout {
+            viewModel.querySellDataList(goodsid = goodsId)
+            linearLayout {
+                background = resources.getDrawable(R.color.hnst_sell_hall_top_bg_color)
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
+                    textView {
+                        text = "价格"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(0, autoSize(74), 1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER
+                    textView {
+                        text = "数量"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent)
+                }.lparams(0, autoSize(74), 1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
+                    textView {
+                        text = "挂牌方"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(36)
+                    }
+                }.lparams(0, autoSize(74), 1f)
+            }.lparams(matchParent, autoSize(74))
+
+            statusLayout(contentBlock = {
+                statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                setRetryAction {
+                    viewModel.querySellDataList(goodsid = goodsId)
+                }
+                swipeToLoadLayout {
+                    swipeToLayout = this
+                    setEnableRefresh(true)
+                    setEnableLoadMore(false)
+                    setOnRefreshListener {
+                        viewModel.querySellDataList(goodsid = goodsId)
+                    }
+                    setEnableScrollContentWhenLoaded(false)
+                    setEnableLoadMoreWhenContentNotFull(false)
+
+                    // 未提交列表
+                    recyclerView {
+                        background = resources.getDrawable(R.color.white)
+                        adapter = businessSellHallAdapter
+                    }.lparams(matchParent, matchParent)
+                }
+            }, emptyBlock = {
+                emptyView(hint = resources.getString(R.string.now_no_data))
+            }).lparams(matchParent, matchParent)
+
+            viewModel.businessSellHallDataList.bindOptional(context) {
+                if (it?.isEmpty() == true || it?.size == 0) {
+                    statusLayout.showEmpty()
+                } else {
+                    if (swipeToLayout.getIsRefreshing()) {
+                        swipeToLayout.finishRefresh()
+                    }
+                    statusLayout.showSuccess()
+                    businessSellHallAdapter.setNewData(it)
+                }
+            }
+        }
+    }
+
+}
+
+
+/**
+ * 买大厅
+ * @property activity AppCompatActivity
+ * @property viewModel BusinessHallViewModel
+ * @constructor
+ */
+class SwapsBuyHallUI(
+    private val activity: AppCompatActivity,
+    private val viewModel: SwapsBusinessHallViewModel,
+    private val goodsId: String,
+    private val goodsCode: String
+) {
+
+    // 下拉刷新
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    private val businessBuyHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessBuyHallViewHolder> =
+        BaseAdapter { _, _ ->
+            SwapsBusinessBuyHallViewHolder(
+                activity,
+                viewModel,
+                goodsCode
+            )
+        }
+
+    val root = _FrameLayout(activity).apply {
+        verticalLayout {
+            viewModel.queryBuyDataList(goodsid = goodsId)
+            linearLayout {
+                background = resources.getDrawable(R.color.hnst_buy_hall_top_bg_color)
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
+                    textView {
+                        text = "价格"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(0, autoSize(74), 1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER
+                    textView {
+                        text = "数量"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent)
+                }.lparams(0, autoSize(74), 1f)
+
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
+                    textView {
+                        text = "挂牌方"
+                        textSizeAuto = 29
+                        textColorInt = R.color.rma_gray_color
+                    }.lparams(wrapContent, wrapContent) {
+                        marginEnd = autoSize(36)
+                    }
+                }.lparams(0, autoSize(74), 1f)
+            }.lparams(matchParent, autoSize(74))
+
+            statusLayout(contentBlock = {
+                statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                setRetryAction {
+                    viewModel.queryBuyDataList(goodsid = goodsId)
+                }
+                swipeToLoadLayout {
+                    swipeToLayout = this
+                    setEnableRefresh(true)
+                    setEnableLoadMore(false)
+                    setOnRefreshListener {
+                        viewModel.queryBuyDataList(goodsid = goodsId)
+                    }
+                    setEnableScrollContentWhenLoaded(false)
+                    setEnableLoadMoreWhenContentNotFull(false)
+
+                    // 未提交列表
+                    recyclerView {
+                        background = resources.getDrawable(R.color.white)
+                        adapter = businessBuyHallAdapter
+                    }.lparams(matchParent, matchParent)
+                }
+            }, emptyBlock = {
+                emptyView(hint = resources.getString(R.string.now_no_data))
+            }).lparams(matchParent, matchParent)
+
+            viewModel.businessBuyHallDataList.bindOptional(context) {
+                if (it?.isEmpty() == true || it?.size == 0) {
+                    statusLayout.showEmpty()
+                } else {
+                    if (swipeToLayout.getIsRefreshing()) {
+                        swipeToLayout.finishRefresh()
+                    }
+                    statusLayout.showSuccess()
+                    businessBuyHallAdapter.setNewData(it)
+                }
+            }
+        }
+    }
+
+}

+ 229 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallViewModel.kt

@@ -0,0 +1,229 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.business
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.AccountData
+import cn.muchinfo.rma.global.data.OrderQuoteDetailData
+import cn.muchinfo.rma.global.data.QuoteDayData
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.netManage.base.InteractiveException
+import cn.muchinfo.rma.view.MyApplication
+import cn.muchinfo.rma.view.autoWidget.remove
+import cn.muchinfo.rma.view.base.BaseViewModel
+import com.blankj.utilcode.util.LogUtils
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import mtp.polymer.com.autowidget.utils.TaskUiModel
+
+/**
+ * 合约市场买卖大厅viewmodel
+ */
+class SwapsBusinessHallViewModel : BaseViewModel(){
+
+    //该买卖大厅的商品信息
+    val goodsInfo : MutableLiveData<GoodsInfo> = MutableLiveData()
+
+    /**
+     * 加载状态控制
+     */
+    val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
+
+    //卖大厅数据
+    val businessSellHallDataList : MutableLiveData<List<WrTradeOrderDetailData>> = MutableLiveData()
+
+    //买大厅数据
+    val businessBuyHallDataList : MutableLiveData<List<WrTradeOrderDetailData>> = MutableLiveData()
+
+    /**
+     * 当前选择的资金账户
+     */
+    val usedAccountData : MutableLiveData<AccountData> = MutableLiveData()
+
+    /**
+     * 交易页面的当前商品的盘面信息
+     */
+    val quoteDayData: MutableLiveData<QuoteDayData> = MutableLiveData()
+
+    //摘牌时选择的买卖大厅实体
+    val selectData : MutableLiveData<OrderQuoteDetailData> = MutableLiveData()
+    //弹出摘牌dialog
+    val showPriceDialog : MutableLiveData<Boolean> = MutableLiveData<Boolean>().apply { value = false }
+
+
+    /**
+     * 查询买大厅数据
+     */
+    fun queryBuyDataList(goodsid : String){
+        val params = mutableMapOf<String,String>().apply {
+            put("goodsid",goodsid)
+            put("buyorsell","0")
+        }
+        MyApplication.getInstance()?.contractGoodsManager?.queryWrTradeOrderDetail(params = params){isSuccess, respData, error ->
+            if (isSuccess){
+                businessBuyHallDataList.postValue(respData)
+            }
+        }
+    }
+
+    /**
+     * 查询卖大厅数据
+     */
+    fun querySellDataList(goodsid : String){
+        val params = mutableMapOf<String,String>().apply {
+            put("goodsid",goodsid)
+            put("buyorsell","1")
+        }
+        MyApplication.getInstance()?.contractGoodsManager?.queryWrTradeOrderDetail(params = params){isSuccess, respData, error ->
+            if (isSuccess){
+                businessSellHallDataList.postValue(respData)
+            }
+        }
+    }
+
+    //查询资金账号信息
+    fun getTaAccounts(){
+        val params = mutableMapOf<String, String>().apply {
+            put("loginID", GlobalDataCollection.instance?.loginRsp?.loginID.toString())
+        }
+        MyApplication.getInstance()?.initializeManager?.getTaAccounts(params = params) { isSuccess, respData, error ->
+            if (isSuccess) {
+                GlobalDataCollection.instance?.accountDataList = respData
+                resetAccountData()
+            }
+        }
+    }
+
+    //重新赋值资金账户
+    fun resetAccountData(){
+        val accountDataList = GlobalDataCollection.instance?.accountDataList
+        if (accountDataList.isNullOrEmpty().not()) {
+            val accountData = GlobalDataCollection.instance?.accountData
+            accountData?.clearData()
+            accountData?.setNormalData()
+            usedAccountData.postValue(accountData)
+        }
+    }
+
+    //重新赋值资金账户
+    fun resetAccountDataBySelect(data : AccountData){
+        data.clearData()
+        data.setNormalData()
+        usedAccountData.postValue(data)
+    }
+
+
+    /**
+     * 买大厅item点击
+     * @param deliverygoodsid String
+     */
+    fun setOnBuyItemClick(orderid : String){
+        val oldList = businessBuyHallDataList.value
+        val newDataList = arrayListOf<WrTradeOrderDetailData>()
+        oldList?.forEach {
+            if (orderid == it.orderid){
+                if (it.isClick == 0){
+                    newDataList.add(it.copy(isClick = 1))
+                }else{
+                    newDataList.add(it.copy(isClick = 0))
+                }
+            }else{
+                newDataList.add(it.copy(isClick = 0))
+            }
+        }
+        businessBuyHallDataList.postValue(newDataList)
+    }
+
+    /**
+     * 卖大厅item点击
+     * @param deliverygoodsid String
+     */
+    fun setOnSellItemClick(orderid : String){
+        val oldList = businessSellHallDataList.value
+        val newDataList = arrayListOf<WrTradeOrderDetailData>()
+        oldList?.forEach {
+            if (orderid == it.orderid){
+                if (it.isClick == 0){
+                    newDataList.add(it.copy(isClick = 1))
+                }else{
+                    newDataList.add(it.copy(isClick = 0))
+                }
+            }else{
+                newDataList.add(it.copy(isClick = 0))
+            }
+        }
+        businessSellHallDataList.postValue(newDataList)
+    }
+
+
+    /**
+     * 请求盘面信息
+     * @param first Int
+     * @param last Int
+     * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
+     */
+    fun queryQuoteDay(
+        tag: String,
+        goodsCodes: String,
+        isShowLoading: Boolean
+    ) {
+        if (isShowLoading) {
+            loadingDialogStatus.postValue(TaskUiModel.inFlight())
+        }
+
+        val params = mutableMapOf<String, String>().apply {
+            put("goodsCodes", goodsCodes)
+        }
+        MyApplication.getInstance()?.futureManager?.queryQuoteDay(params = params) { isSuccess, respData, error ->
+            if (isSuccess) {
+                if (respData?.isEmpty()?.not() == true) {
+                    quoteDayData.postValue(respData[0])
+                }
+                if (isShowLoading) {
+                    loadingDialogStatus.postValue(TaskUiModel.success(msg = "数据请求成功"))
+                }
+
+            } else {
+                if (isShowLoading) {
+                    loadingDialogStatus.postValue(
+                        TaskUiModel.failed(
+                            InteractiveException(
+                                errorMessage = "数据请求失败"
+                            )
+                        )
+                    )
+                }
+            }
+        }
+        addSubscriptQuote(tag = tag, goodsCodes = setOf(goodsCodes))
+    }
+
+
+    /**
+     * 订阅行情
+     * @param tag String
+     * @param goodsInfoList List<GoodsInfo>
+     */
+    fun addSubscriptQuote(tag: String, goodsCodes: Set<String>) {
+        GlobalScope.launch {
+            MyApplication.getInstance()?.quoteManager?.addSubscriptQuote(
+                tag = tag, goodsCodeSet = goodsCodes
+            ) { isCompleted, err ->
+                LogUtils.eTag("dingyuehangqing", goodsCodes)
+            }
+        }
+    }
+
+    /**
+     * 取消订阅
+     * @param tag String
+     */
+    fun removeSubscriptQuote(tag: String) {
+        GlobalScope.launch {
+            MyApplication.getInstance()?.quoteManager?.removeSubscriptQuote(
+                tag = tag
+            )
+        }
+    }
+
+}

+ 125 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessSellHallViewHolder.kt

@@ -0,0 +1,125 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.business
+
+import android.content.Intent
+import android.view.Gravity
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.OrderQuoteDetailData
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.home.spotmarket.AddSpotMarketPriceActivity
+import cn.muchinfo.rma.view.base.home.spotmarket.SpotMarketDetailsActivity
+import cn.muchinfo.rma.view.base.yrdzpurchase.delisting.PurchaseDelistingActivity
+import com.blankj.utilcode.util.ActivityUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import mtp.polymer.com.autowidget.dialog.createWarningDialog
+import org.jetbrains.anko.*
+
+/**
+ * 卖大厅viewholder
+ * @property activity AppCompatActivity
+ * @property viewModel BusinessHallViewModel
+ * @property itemSize IntArray
+ * @constructor
+ */
+class SwapsBusinessSellHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String) : BaseViewHolder<WrTradeOrderDetailData>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+         verticalLayout {
+             background = resources.getDrawable(R.color.sell_color_bg)
+             data.bindOptional(context) {
+                 if (it?.isClick == 0) {
+                     background = resources.getDrawable(R.color.sell_color_bg)
+                 } else if (it?.isClick == 1) {
+                     background = resources.getDrawable(R.color.white)
+                 }
+             }
+             onThrottleFirstClick {
+                 viewModel.setOnSellItemClick(data.value?.orderid ?: "")
+             }
+
+             linearLayout {
+
+                 linearLayout {
+                     gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
+                     textView {
+                         data.bindOptional(context){
+                             text = NumberUtils.roundNum(it?.orderprice,2)
+                         }
+                         textSizeAuto = 34
+                         textColorInt = R.color.rma_black_33
+                     }.lparams(wrapContent, wrapContent){
+                         marginStart = autoSize(36)
+                     }
+                 }.lparams(0, autoSize(90),1f)
+
+                 linearLayout {
+                    gravity = Gravity.CENTER
+                     textView {
+                         data.bindOptional(context){
+                             text = it?.orderqty
+                         }
+                         textSizeAuto = 34
+                         textColorInt = R.color.rma_black_33
+                     }.lparams(wrapContent, wrapContent)
+                 }.lparams(0, autoSize(90),1f)
+
+                 linearLayout {
+                     gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
+                     textView {
+                         data.bindOptional(context){
+                             text = it?.userid + "  "  + it?.username
+                         }
+                         textSizeAuto = 34
+                         textColorInt = R.color.rma_black_33
+                     }.lparams(wrapContent, wrapContent){
+                         marginEnd = autoSize(36)
+                     }
+                 }.lparams(0, autoSize(90),1f)
+             }.lparams(matchParent, autoSize(90))
+
+             // 控制区
+             linearLayout {
+                 data.bindOptional(context) {
+                     if (it?.isClick == 0) {
+                         visibility = View.GONE
+                     } else if (it?.isClick == 1) {
+                         visibility = View.VISIBLE
+                     }
+                 }
+                 gravity = Gravity.CENTER_VERTICAL
+
+                 emptyView()
+
+                 textView {
+                     onThrottleFirstClick {
+                         val intent = Intent()
+                         intent.putExtra("data",data.value)
+                         intent.putExtra("goodsId",data.value?.goodsid)
+                         intent.putExtra("goodsCode",goodsCode)
+                         intent.putExtra("type","1")
+                         intent.setClass(context, PurchaseDelistingActivity::class.java)
+                         ActivityUtils.startActivity(intent)
+                     }
+                     backgroundResource = R.drawable.rma_item_click_bg
+                     gravity = Gravity.CENTER
+                     text = "摘牌"
+                     textColorInt = R.color.rma_item_click_color
+                     textSizeAuto = 26
+                 }.lparams(autoSize(120), autoSize(48)) {
+                     marginEnd = autoSize(24)
+                 }
+             }.lparams(matchParent, autoSize(72))
+         }.lparams(matchParent, wrapContent)
+    }
+
+}

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

@@ -0,0 +1,487 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.delisting
+
+import android.annotation.SuppressLint
+import android.os.Build
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.widget.CheckBox
+import android.widget.SeekBar
+import android.widget.TextView
+import androidx.annotation.RequiresApi
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.AccountData
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.global.database.DataBase
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
+import cn.muchinfo.rma.view.autoWidget.view.MangeNumberEditText2
+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 com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.dialog.creatAccountDataSheetDialog
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
+import org.jetbrains.anko.*
+
+/**
+ * 合约市场
+ */
+class SwapsDelistingActivity : BaseActivity<SwapsDelistingViewModel>(){
+
+    /** 传入的goodsid **/
+    val goodsId by lazy { intent.getStringExtra("goodsId") }
+
+    /** 传入的goodscode **/
+    val goodsCode by lazy { intent.getStringExtra("goodsCode") }
+
+    /** 传入的摘买摘卖类型 0是摘卖 1是摘买 **/
+    val type by lazy { intent.getStringExtra("type") }
+
+    /** 传入的买卖大厅数据 **/
+    val data by lazy { intent.getParcelableExtra<WrTradeOrderDetailData>("data") as WrTradeOrderDetailData }
+
+    /** 选择的资金账号 **/
+    val selectAccountData: MutableLiveData<AccountData> = MutableLiveData()
+
+    /** 摘牌数量 **/
+    lateinit var onePriceInputNumberEdittext: MangeNumberEditText2
+
+    /** SeekBar **/
+    lateinit var one_seekbar: SeekBar
+
+    /** 摘牌金额 **/
+    lateinit var one_delisting_amount: TextView
+
+    /** 是否选择市价 **/
+    lateinit var market_price_checkbox : CheckBox
+
+    /** 是否选择限价 **/
+    lateinit var limit_price_checkbox : CheckBox
+
+    /** 挂牌价格类型为浮动价是输入的买入价格 **/
+    lateinit var buy_price_input : MangeNumberEditText2
+
+    /** 对页面数据进行初始化 **/
+    fun initializeData(){
+        selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
+        viewModel.goodsInfo.postValue(DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0))
+        if (type == "0"){//摘卖 摘卖操作时需要查找相应accountid的持仓单
+            viewModel.queryContractTradePosition(accountid = GlobalDataCollection.instance?.accountId.toString(),goodsId = goodsId ?: "")
+        }else{
+            viewModel.maxDelistedingNumber.postValue(data.orderqty)//摘买时直接取值挂牌数量
+        }
+    }
+
+    @SuppressLint("SetTextI18n")
+    @RequiresApi(Build.VERSION_CODES.O)
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        initializeData()
+        verticalLayout {
+            createLoadingDialog(hintStr = "").bindTaskStatus(context, viewModel.loadingDialogStatus)
+            viewModel.tradePositionData.bindOptional(context){
+                val maxNumber = data.orderqty?.toInt()?.coerceAtMost(it?.enableqty?.toInt() ?: 0)
+                //对最大可摘进行赋值
+                viewModel.maxDelistedingNumber.postValue(maxNumber.toString())
+            }
+
+            topBar {
+                // 返回
+                commonLeftButton()
+                commonTitle {
+                    text = goodsCode
+                }
+            }
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                onThrottleFirstClick {
+                    creatAccountDataSheetDialog(
+                        "请选择资金账号",
+                        GlobalDataCollection.instance?.accountDataList ?: arrayListOf()
+                    ) {
+                        selectAccountData.postValue(this)
+                        viewModel.resetAccountDataBySelect(this)
+                        //选择资金账号后重新请求当前要交易的accoundid的持仓汇总
+                        viewModel.queryContractTradePosition(accountid = GlobalDataCollection.instance?.accountId.toString(),goodsId = goodsId ?: "")
+                    }
+                }
+                linearLayout {
+                    textView {
+                        text = "交易账户"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(250), wrapContent)
+
+                textView {
+                    selectAccountData.bindOptional(context) {
+                        text = it?.accountid.toString() + "   " + it?.accountname
+                    }
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent)
+
+                emptyView()
+
+                imageView {
+                    imageResource = R.mipmap.rma_more
+                }.lparams(autoSize(36), autoSize(36))
+
+            }.lparams(matchParent, autoSize(172))
+
+            itemView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    textView {
+                        text = "挂牌方"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(250), wrapContent)
+
+                textView {
+                    text = data.username
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    textView {
+                        text = "价格类型"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(250), wrapContent)
+
+                textView {
+                    text = "浮动价"
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            verticalLayout {
+                background = resources.getDrawable(R.color.white)
+                linearLayout {
+                    gravity = Gravity.CENTER_VERTICAL
+                    linearLayout {
+                        textView {
+                            text = "买入价格"
+                            textSizeAuto = 34
+                            textColorInt = R.color.rma_hint_text_color_ccc
+                        }.lparams(wrapContent, wrapContent) {
+                            marginStart = autoSize(36)
+                        }
+                    }.lparams(autoSize(250), wrapContent)
+
+                    checkBox {
+                        market_price_checkbox = this
+                        buttonDrawable = null
+                        background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                        setOnCheckedChangeListener { compoundButton, b ->
+                            if (b){
+                                limit_price_checkbox.isChecked = false
+                            }
+                        }
+                    }.lparams(autoSize(41), autoSize(41)) {
+                        marginStart = autoSize(36)
+                    }
+                    textView {
+                        text = "市价"
+                        textSizeAuto = 32
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent)
+
+                    checkBox {
+                        limit_price_checkbox = this
+                        buttonDrawable = null
+                        background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                        setOnCheckedChangeListener { compoundButton, b ->
+                            if (b){
+                                market_price_checkbox.isChecked = false
+                            }
+                        }
+                    }.lparams(autoSize(41), autoSize(41)) {
+                        marginStart = autoSize(36)
+                    }
+                    textView {
+                        text = "限价"
+                        textSizeAuto = 32
+                        textColorInt = R.color.rma_black_33
+                    }.lparams(wrapContent, wrapContent)
+
+
+                }.lparams(matchParent, autoSize(143))
+
+                linearLayout {
+                    view {
+
+                    }.lparams(autoSize(250), autoSize(143))
+
+                    numberEditText {
+                        text = "1"
+                        buy_price_input = this
+                        setOnTextChangeListener { view, value ->
+
+                        }
+                    }.lparams(0, autoSize(72), 1f) {
+                        marginEnd = autoSize(36)
+                    }
+                }.lparams(matchParent, autoSize(143))
+            }.lparams(matchParent, autoSize(286))
+
+            // 价格为固定价时就为挂牌价格
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    textView {
+                        text = "挂牌价格"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(250), wrapContent)
+
+                textView {
+                    text = data.orderprice
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_red_color
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    textView {
+                        text = "挂牌数量"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                    }
+                }.lparams(autoSize(250), wrapContent)
+
+                textView {
+                    text = data.orderqty
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                verticalLayout {
+                    textView {
+                        text = "摘牌数量"
+                        textSizeAuto = 34
+                        textColorInt = R.color.rma_hint_text_color_ccc
+                    }.lparams(wrapContent, wrapContent) {
+                        marginStart = autoSize(36)
+                        topMargin = autoSize(36)
+                    }
+
+                }.lparams(autoSize(250), autoSize(290))
+
+                verticalLayout {
+                    linearLayout {
+                        gravity = Gravity.CENTER_VERTICAL
+                        numberEditText {
+                            text = "1"
+                            onePriceInputNumberEdittext = this
+                            setOnTextChangeListener { view, value ->
+                                if (value.isNullOrEmpty().not()) {
+                                    one_delisting_amount.text = NumberUtils.roundNum(value?.toString()?.toDouble()?.times(data.orderprice?.toDouble() ?: 1.0)?.times(viewModel.goodsInfo.value?.agreeunit ?: 1)?.toString(),2)
+                                }
+                            }
+
+                        }.lparams(0, autoSize(72), 1f) {
+                            marginEnd = autoSize(36)
+                        }
+
+                        textView {
+                            visibility = View.GONE
+                            textSizeAuto = 34
+                            textColorInt = R.color.rma_hint_text_color_ccc
+                        }.lparams(wrapContent, wrapContent) {
+                            marginEnd = autoSize(36)
+                        }
+                    }.lparams(matchParent, autoSize(143))
+
+
+                    inflateLayout<SeekBar>(R.layout.main_seekbar) {
+                        one_seekbar = this
+                        min = 10
+                        max = 100
+                        isIndeterminate = false
+                        splitTrack = false
+                        setPadding(autoSize(30), 0, autoSize(30), 0)
+                        thumb = resources.getDrawable(R.mipmap.hnst_seekbar)
+                        progressDrawable = resources.getDrawable(R.drawable.seekbar_bg)
+                        setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
+                            override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
+                                onePriceInputNumberEdittext.text = NumberUtils.roundNum(
+                                    viewModel.maxDelistedingNumber.value?.toDouble()?.times(p1.div(100.0))
+                                        .toString(), 0
+                                )
+                            }
+
+                            override fun onStartTrackingTouch(p0: SeekBar?) {
+
+                            }
+
+                            override fun onStopTrackingTouch(p0: SeekBar?) {
+
+                            }
+                        })
+                    }.lparams(matchParent, autoSize(46)) {
+                        marginEnd = autoSize(110)
+                        topMargin = autoSize(20)
+                    }
+
+                    linearLayout {
+                        textView {
+                            text = "0"
+                            textSizeAuto = 29
+                            textColorInt = R.color.rma_gray_color
+                        }.lparams(wrapContent, wrapContent)
+
+                        emptyView()
+
+                        textView {
+                            viewModel.maxDelistedingNumber.bindOptional(context){
+                                text = it.toString()
+                            }
+                            text = "0"
+                            textSizeAuto = 29
+                            textColorInt = R.color.rma_gray_color
+                        }.lparams(wrapContent, wrapContent)
+                    }.lparams(matchParent, wrapContent) {
+                        marginEnd = autoSize(110)
+                        topMargin = autoSize(10)
+                    }
+
+                }.lparams(matchParent, autoSize(290))
+            }.lparams(matchParent, autoSize(290))
+
+            itemView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "摘牌金额"
+                    textSizeAuto = 34
+                    textColorInt = R.color.rma_hint_text_color_ccc
+                }.lparams(autoSize(214), wrapContent) {
+                    marginStart = autoSize(36)
+                }
+
+                textView {
+                    one_delisting_amount = this
+                    text = "--"
+                    textSizeAuto = 29
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent)
+            }.lparams(matchParent, autoSize(143))
+
+            textView {
+                viewModel.usedAccountData.bindOptional(context) {
+                    text = "可用资金" + NumberUtils.roundNum(it?.canUserAmount.toString(), 2)
+                }
+                textSizeAuto = 29
+                textColorInt = R.color.rma_black_33
+            }.lparams(wrapContent, wrapContent) {
+                topMargin = autoSize(20)
+                marginStart = autoSize(250)
+            }
+
+            verticalEmptyView()
+
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    onThrottleFirstClick {
+                        if (onePriceInputNumberEdittext.text.toString()
+                                .isNullOrEmpty() || onePriceInputNumberEdittext.text.toString()
+                                .toDouble() == 0.0
+                        ) {
+                            ToastUtils.showLong("请输入摘牌数量")
+                            return@onThrottleFirstClick
+                        }
+
+                        viewModel.commit(
+                            relatedID = data.orderid ?: "",
+                            goodsInfo = viewModel.goodsInfo.value ?: GoodsInfo(),
+                            isListed = false,
+                            orderPrice = data.orderprice ?: "1",
+                            qty = onePriceInputNumberEdittext.text.toString(),
+                            type = type ?: "",
+                            accountId = selectAccountData.value?.accountid ?: 0
+                        ){
+                            finish()
+                        }
+
+                    }
+                    gravity = Gravity.CENTER
+                    backgroundResource = R.drawable.qhj_main_blue_bg
+                    text = if (type == "0") { "卖出" } else { "买入" }
+                    textSizeAuto = 38
+                    textColorInt = R.color.white
+                }.lparams(autoSize(419), autoSize(119)) {
+                    marginStart = autoSize(24)
+                }
+
+                textView {
+                    onThrottleFirstClick {
+                        finish()
+                    }
+                    gravity = Gravity.CENTER
+                    backgroundResource = R.drawable.hnxt_cancel_bg
+                    text = "取消"
+                    textColorInt = R.color.white
+                    textSizeAuto = 38
+                }.lparams(autoSize(419), autoSize(119)) {
+                    marginStart = autoSize(13)
+                }
+            }.lparams(matchParent, autoSize(144)) {
+                gravity = Gravity.BOTTOM
+            }
+        }
+    }
+
+}

+ 165 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingViewModel.kt

@@ -0,0 +1,165 @@
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.delisting
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.business.contractgoods.adapter.OrderData
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.MTPEnums
+import cn.muchinfo.rma.global.data.AccountData
+import cn.muchinfo.rma.global.data.ContractTradePositionData
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.netManage.base.InteractiveException
+import cn.muchinfo.rma.view.MyApplication
+import cn.muchinfo.rma.view.base.BaseViewModel
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import mtp.polymer.com.autowidget.utils.TaskUiModel
+
+/**
+ * 合约市场摘牌viewmodel
+ */
+class SwapsDelistingViewModel : BaseViewModel(){
+
+    /**
+     * 加载状态控制
+     */
+    val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
+
+    /**
+     * 当前页面选择的商品详情
+     */
+    val goodsInfo : MutableLiveData<GoodsInfo> = MutableLiveData()
+
+    /**
+     * 当前选择的资金账户
+     */
+    val usedAccountData : MutableLiveData<AccountData> = MutableLiveData()
+
+    /**
+     * 当前资金账号的持仓汇总信息
+     */
+    val tradePositionData : MutableLiveData<ContractTradePositionData> = MutableLiveData()
+
+    /**
+     * 当前页面最大可摘数量(摘卖-min{持仓可用数量,挂牌数量},摘买-挂牌数量)
+     */
+    val maxDelistedingNumber : MutableLiveData<String> = MutableLiveData()
+
+    /**
+     * 查询当前选择资金账号的持仓汇总单据
+     * @param accountid String 当前资金账号
+     * @param goodsId String 当前页面的goodsid
+     */
+    fun queryContractTradePosition(accountid : String,goodsId : String){
+        val params = mutableMapOf<String,String>().apply {
+            put("accountID",accountid)
+        }
+        MyApplication.getInstance()?.contractGoodsManager?.queryContractTradePosition(params = params){isSuccess, respData, error ->
+            if (isSuccess){
+                setPositionDataByGoodsid(respData ?: arrayListOf(),goodsId)
+            }
+        }
+    }
+
+    /**
+     * 通过goodsid筛选当前需要的持仓单
+     * @param dataList List<ContractTradePositionData>
+     * @param goodsId String
+     */
+    fun setPositionDataByGoodsid(dataList : List<ContractTradePositionData>, goodsId: String){
+        val selectPositionData = dataList.find { it.goodsid == goodsId }
+        if (selectPositionData?.goodsid.isNullOrEmpty().not()){
+            tradePositionData.postValue(selectPositionData)
+        }else{
+            tradePositionData.postValue(ContractTradePositionData())
+        }
+    }
+
+    //重新赋值资金账户
+    fun resetAccountData(){
+        val accountDataList = GlobalDataCollection.instance?.accountDataList
+        if (accountDataList.isNullOrEmpty().not()) {
+            val accountData = GlobalDataCollection.instance?.accountData
+            accountData?.clearData()
+            accountData?.setNormalData()
+            usedAccountData.postValue(accountData)
+        }
+    }
+
+    //重新赋值资金账户
+    fun resetAccountDataBySelect(data : AccountData){
+        data.clearData()
+        data.setNormalData()
+        usedAccountData.postValue(data)
+    }
+
+    /**
+     *  type : 1 买 2 卖
+     *  selectPayType 1 按数量 2 按金额
+     * isListed 是否是挂牌
+     */
+    fun commit(
+        relatedID : String,
+        goodsInfo: GoodsInfo,
+        isListed: Boolean = true,
+        orderPrice: String,
+        qty: String,
+        type: String,
+        accountId : Long,
+        callback: (isCompleted: Boolean) -> Unit
+    ) {
+
+        val orderData = OrderData()
+        orderData.accountID = accountId
+        if (type == "1") {
+            orderData.buildType = MTPEnums.BUILDTYPE_OPEN// 建仓
+            orderData.buyOrSell = MTPEnums.DIRECTION_BUY// 买入
+        } else {
+            orderData.buildType = MTPEnums.BUILDTYPE_CLOSE// 平仓
+            orderData.buyOrSell = MTPEnums.DIRECTION_SALE// 卖出
+        }
+        orderData.goodsID = goodsInfo.goodsid
+        orderData.marketID = goodsInfo.marketid
+        if (type == "3") {
+            orderData.operateType = MTPEnums.OPERATETYPE_FINANC// 操作类型
+        } else {
+            orderData.operateType = MTPEnums.OPERATETYPE_NORMAL// 操作类型
+        }
+        orderData.orderPrice = orderPrice.toDouble()//价格
+        orderData.orderQty = qty.toLong()//数量
+        orderData.orderSrc = MTPEnums.ORDERSRC_CLIENT// 来自客户端
+        orderData.priceMode = MTPEnums.PRICEMODE_LIMIT// 限价
+        orderData.timevalidType = MTPEnums.TC_IOC//当日有效  1为当日有效 2为本周有效 3为指定日期有效 4为一直有效 5为指定时间有效
+        orderData.validType = MTPEnums.VALIDTYPE_DR//当日有效
+        orderData.delistingType = MTPEnums.DELISTINGTYPE_SELECTED//点选成交
+        if (isListed){//挂牌
+            orderData.listingSelectType = MTPEnums.LISTINGSELECTTYPE_LISTING// 挂牌
+        }else{
+            orderData.triggerType = 1
+            orderData.listingSelectType = MTPEnums.LISTINGSELECTTYPE_DELISTING// 摘牌
+            orderData.relatedID = relatedID.toLong()
+        }
+        orderData.optionType = MTPEnums.OPTION_TYPE_C//认购
+        orderData.triggerOperator = 1
+        loadingDialogStatus.value = TaskUiModel.inFlight()
+        GlobalScope.launch {
+            MyApplication.getInstance()?.contractGoodsManager?.orderReq(
+                data = orderData
+            ) { isCompleted, err ,rsp ->
+                if (isCompleted) {
+                    callback(true)
+                } else {
+                    loadingDialogStatus.postValue(
+                        TaskUiModel.failed(
+                            InteractiveException(
+                                errorMessage = err?.message!!
+                            )
+                        )
+                    )
+                }
+            }
+        }
+
+    }
+
+
+}