Explorar el Código

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

Liu.bolan hace 4 años
padre
commit
fa04ea6c88
Se han modificado 15 ficheros con 658 adiciones y 222 borrados
  1. 2 0
      RMA/app/src/main/AndroidManifest.xml
  2. 1 1
      RMA/app/src/main/java/cn/muchinfo/rma/business/contractgoods/adapter/OrderData.java
  3. 4 0
      RMA/app/src/main/java/cn/muchinfo/rma/global/data/TjmdTradeOrderDetailData.kt
  4. 2 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/warehousereceipt/BusinessHallActivity.kt
  5. 1 1
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/YrdzDdjyFragment.kt
  6. 11 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/TransferSwapsAdapter.java
  7. 8 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessBuyHallViewHolder.kt
  8. 52 128
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallActivity.kt
  9. 8 10
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessHallViewModel.kt
  10. 8 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/business/SwapsBusinessSellHallViewHolder.kt
  11. 12 1
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingActivity.kt
  12. 1 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/delisting/SwapsDelistingViewModel.kt
  13. 465 32
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/listed/SwapsListedActivity.kt
  14. 81 41
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/listed/SwapsListedViewModel.kt
  15. 2 2
      RMA/app/src/main/res/drawable/rma_item_text_bg.xml

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

@@ -463,6 +463,8 @@
         <activity android:name=".view.base.yrdzpurchase.swaps.business.SwapsBusinessHallActivity"/>
 
         <activity android:name=".view.base.yrdzpurchase.swaps.delisting.SwapsDelistingActivity"/>
+
+        <activity android:name=".view.base.yrdzpurchase.swaps.listed.SwapsListedActivity"/>
     </application>
 
 </manifest>

+ 1 - 1
RMA/app/src/main/java/cn/muchinfo/rma/business/contractgoods/adapter/OrderData.java

@@ -40,7 +40,7 @@ public class OrderData {
     private int orderSrc = 0;
     private long operatorID = 0;
     private double orderPrice = 0;
-    private double marketMaxSub = 0;
+    private double marketMaxSub = 0;//浮动价时传入基差
     private long orderQty = 0;
     private int buyOrSell = 0;
     private int buildType = 0;

+ 4 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/data/TjmdTradeOrderDetailData.kt

@@ -14,6 +14,8 @@ data class TjmdTradeOrderDetailData(
     val goodsid : String? = "",//商品id
     @SerializedName("orderid")
     val orderid : String? = "",//委托单号
+    @SerializedName("pricemode")
+    val pricemode : String? = "",//取价方式 - 1:市价 2: 限价 3:浮动价
     @SerializedName("orderprice")
     val orderprice : String? = "",//委托价格
     @SerializedName("orderqty")
@@ -32,6 +34,7 @@ data class TjmdTradeOrderDetailData(
         parcel.readString(),
         parcel.readString(),
         parcel.readString(),
+        parcel.readString(),
         parcel.readInt()
     ) {
     }
@@ -40,6 +43,7 @@ data class TjmdTradeOrderDetailData(
         parcel.writeString(buyorsell)
         parcel.writeString(goodsid)
         parcel.writeString(orderid)
+        parcel.writeString(pricemode)
         parcel.writeString(orderprice)
         parcel.writeString(orderqty)
         parcel.writeString(userid)

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

@@ -181,14 +181,14 @@ class BusinessHallActivity : BaseActivity<BusinessHallViewModel>() {
                     this@BusinessHallActivity,
                     type ?: "1",
                     viewModel,
-                    viewModel.orderQuoteData.value ?: OrderQuoteData()
+                    orderQuoteData
                 ).show()
             } else {
                 this@BusinessHallActivity.FloatListedDialog(
                     this@BusinessHallActivity,
                     type ?: "1",
                     viewModel,
-                    viewModel.orderQuoteData.value ?: OrderQuoteData()
+                    orderQuoteData
                 ).show()
             }
         }

+ 1 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/YrdzDdjyFragment.kt

@@ -53,7 +53,7 @@ class YrdzDdjyFragment : BaseFragment<YrdzDdjyViewModel>() {
         BasePriceFragment.getInstance()
     }
 
-    //掉期
+    //掉期交易
     private val swapsFragment by lazy {
         GoodsSwapsFragment.getInstance()
     }

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

@@ -30,6 +30,7 @@ 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.QuoteGoodsListData;
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo;
 import cn.muchinfo.rma.global.database.DataBase;
 import cn.muchinfo.rma.view.autoWidget.CustomHorizontalScrollView;
@@ -54,6 +55,7 @@ public class TransferSwapsAdapter extends RecyclerView.Adapter<TransferSwapsAdap
     private List<ItemViewHolder> mViewHolderList = new ArrayList<>();
     public int offestX = 0;
     private OnContentScrollListener onContentScrollListener;
+    private  QuoteGoodsListData quoteGoodsListData = null;
 
 
     public interface OnContentScrollListener {
@@ -96,6 +98,14 @@ public class TransferSwapsAdapter extends RecyclerView.Adapter<TransferSwapsAdap
     public void onBindViewHolder(@NonNull final ItemViewHolder itemViewHolder, int i) {
         this.index = i;
         GoodsInfo data = datas.get(i);
+
+        ArrayList<QuoteGoodsListData> quoteGoodsListDataList = GlobalDataCollection.Companion.getInstance().getQuoteGoodsListDataArrayList();
+        for (int k = 0;k < quoteGoodsListDataList.size();k++){
+            if (quoteGoodsListDataList.get(k).getGoodsid().equals(String.valueOf(data.getGoodsid()))){
+                quoteGoodsListData = quoteGoodsListDataList.get(k);
+            }
+        }
+
         itemViewHolder.tvLeftTitle.setText(datas.get(i).getGoodsname());
         //右边滑动部分
         LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
@@ -287,6 +297,7 @@ public class TransferSwapsAdapter extends RecyclerView.Adapter<TransferSwapsAdap
                 Intent intent = new Intent();
                 intent.putExtra("goodsId", String.valueOf(data.getGoodsid()));
                 intent.putExtra("goodsCode", data.getGoodscode());
+                intent.putExtra("quoteGoodsListData",quoteGoodsListData);
                 intent.setClass(context, SwapsBusinessHallActivity.class);
                 ActivityUtils.startActivity(intent);
             }

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

@@ -6,6 +6,8 @@ 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.QuoteGoodsListData
+import cn.muchinfo.rma.global.data.TjmdTradeOrderDetailData
 import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
 import cn.muchinfo.rma.global.utils.VIewUtils
 import cn.muchinfo.rma.lifecycle.bindOptional
@@ -16,6 +18,7 @@ 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 cn.muchinfo.rma.view.base.yrdzpurchase.swaps.delisting.SwapsDelistingActivity
 import com.blankj.utilcode.util.ActivityUtils
 import mtp.polymer.com.autowidget.adapter.BaseViewHolder
 import org.jetbrains.anko.*
@@ -27,7 +30,9 @@ import org.jetbrains.anko.*
  * @property itemSize IntArray
  * @constructor
  */
-class SwapsBusinessBuyHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String) : BaseViewHolder<WrTradeOrderDetailData>(activity){
+class SwapsBusinessBuyHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String,
+                                     private val quoteGoodsListData : QuoteGoodsListData
+) : BaseViewHolder<TjmdTradeOrderDetailData>(activity){
     override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
 
     override fun _FrameLayout.createContentView() {
@@ -104,7 +109,8 @@ class SwapsBusinessBuyHallViewHolder(private val activity : AppCompatActivity, p
                             intent.putExtra("goodsId",data.value?.goodsid)
                             intent.putExtra("goodsCode",goodsCode)
                             intent.putExtra("type","0")
-                            intent.setClass(context, PurchaseDelistingActivity::class.java)
+                            intent.putExtra("quoteGoodsListData",quoteGoodsListData)
+                            intent.setClass(context, SwapsDelistingActivity::class.java)
                             ActivityUtils.startActivity(intent)
                         }
                     }

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

@@ -14,6 +14,8 @@ 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.QuoteGoodsListData
+import cn.muchinfo.rma.global.data.TjmdTradeOrderDetailData
 import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
 import cn.muchinfo.rma.global.database.DataBase
 import cn.muchinfo.rma.lifecycle.bindOptional
@@ -23,6 +25,7 @@ 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.base.yrdzpurchase.swaps.listed.SwapsListedActivity
 import cn.muchinfo.rma.view.eventbus.EventConstent
 import cn.muchinfo.rma.view.eventbus.MessageEvent
 import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
@@ -54,6 +57,9 @@ class SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
 
     val goodsCode by lazy { intent.getStringExtra("goodsCode") }
 
+    //标的合约
+    val quoteGoodsListData by lazy { intent.getParcelableExtra<QuoteGoodsListData>("quoteGoodsListData") as QuoteGoodsListData }
+
     //价格涨跌的上下箭头
     lateinit var updowm_image : ImageView
 
@@ -66,10 +72,10 @@ class SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
     }
 
     //买大厅
-    val buyHallUI by lazy { SwapsBuyHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
+    val buyHallUI by lazy { SwapsBuyHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "",quoteGoodsListData) }
 
     //卖大厅
-    val sellHallUI by lazy { SwapsSellHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
+    val sellHallUI by lazy { SwapsSellHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "",quoteGoodsListData) }
 
     //viewpager的适配器
     private var newPagerAdapter: PagerAdapter? = null
@@ -213,7 +219,8 @@ class SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
                         val intent = Intent()
                         intent.putExtra("goodsId", goodsId)
                         intent.putExtra("goodsCode", goodsCode)
-                        intent.setClass(context, PurchaseListedActivity::class.java)
+                        intent.putExtra("quoteGoodsListData",quoteGoodsListData)
+                        intent.setClass(context, SwapsListedActivity::class.java)
                         ActivityUtils.startActivity(intent)
                     }
                     imageResource = R.mipmap.hnst_add_icon
@@ -237,144 +244,57 @@ class SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
                 }
             }.lparams(matchParent, autoSize(120))
 
+
             linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "标的"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_gray_color
+                }.lparams(wrapContent, wrapContent){
+                    marginStart = autoSize(48)
+                }
+
                 linearLayout {
                     gravity = Gravity.CENTER_VERTICAL
+                    backgroundResource = R.drawable.rma_list_item_bg
                     textView {
-                        text = "卖价"
+                        text = quoteGoodsListData.refgoodscode
                         textSizeAuto = 29
-                        textColorInt = R.color.rma_gray_color
+                        textColorInt = R.color.rma_blue_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)
+                        text = "1233"
+                        textSizeAuto = 44
+                        textColorInt = R.color.rma_red_color
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(36)
                     }
-                }.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)
+                        text = "+19"
+                        textSizeAuto = 27
+                        textColorInt = R.color.rma_red_color
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(25)
                     }
 
-                    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)
+                        text = "+19%"
+                        textSizeAuto = 27
+                        textColorInt = R.color.rma_red_color
+                    }.lparams(wrapContent, wrapContent){
+                        marginEnd = autoSize(36)
+                        marginStart = autoSize(25)
                     }
-                }.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)
+                }.lparams(wrapContent, autoSize(72)){
+                    marginStart = autoSize(36)
                 }
 
-                textView {
-                    text = "+1.28%"
-                    textSizeAuto = 29
-                    textColorInt = R.color.rma_red_color
-                }.lparams(wrapContent, wrapContent) {
-                    marginStart = autoSize(20)
-                }
-            }.lparams(matchParent, autoSize(70))
+            }.lparams(matchParent, autoSize(120))
 
             tabSegment {
                 segment = this
@@ -430,19 +350,21 @@ class SwapsSellHallUI(
     private val activity: AppCompatActivity,
     private val viewModel: SwapsBusinessHallViewModel,
     private val goodsId: String,
-    private val goodsCode: String
+    private val goodsCode: String,
+    private val quoteGoodsListData : QuoteGoodsListData
 ) {
 
     // 下拉刷新
     private lateinit var swipeToLayout: SwipeToLoadLayout
     private lateinit var statusLayout: StatusLayout
 
-    private val businessSellHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessSellHallViewHolder> =
+    private val businessSellHallAdapter: BaseAdapter<TjmdTradeOrderDetailData, SwapsBusinessSellHallViewHolder> =
         BaseAdapter { _, _ ->
             SwapsBusinessSellHallViewHolder(
                 activity,
                 viewModel,
-                goodsCode
+                goodsCode,
+                quoteGoodsListData
             )
         }
 
@@ -536,19 +458,21 @@ class SwapsBuyHallUI(
     private val activity: AppCompatActivity,
     private val viewModel: SwapsBusinessHallViewModel,
     private val goodsId: String,
-    private val goodsCode: String
+    private val goodsCode: String,
+    private val quoteGoodsListData : QuoteGoodsListData
 ) {
 
     // 下拉刷新
     private lateinit var swipeToLayout: SwipeToLoadLayout
     private lateinit var statusLayout: StatusLayout
 
-    private val businessBuyHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessBuyHallViewHolder> =
+    private val businessBuyHallAdapter: BaseAdapter<TjmdTradeOrderDetailData, SwapsBusinessBuyHallViewHolder> =
         BaseAdapter { _, _ ->
             SwapsBusinessBuyHallViewHolder(
                 activity,
                 viewModel,
-                goodsCode
+                goodsCode,
+                quoteGoodsListData
             )
         }
 

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

@@ -2,10 +2,7 @@ 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.*
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
 import cn.muchinfo.rma.netManage.base.InteractiveException
 import cn.muchinfo.rma.view.MyApplication
@@ -30,10 +27,10 @@ class SwapsBusinessHallViewModel : BaseViewModel(){
     val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
 
     //卖大厅数据
-    val businessSellHallDataList : MutableLiveData<List<WrTradeOrderDetailData>> = MutableLiveData()
+    val businessSellHallDataList : MutableLiveData<List<TjmdTradeOrderDetailData>> = MutableLiveData()
 
     //买大厅数据
-    val businessBuyHallDataList : MutableLiveData<List<WrTradeOrderDetailData>> = MutableLiveData()
+    val businessBuyHallDataList : MutableLiveData<List<TjmdTradeOrderDetailData>> = MutableLiveData()
 
     /**
      * 当前选择的资金账户
@@ -60,7 +57,7 @@ class SwapsBusinessHallViewModel : BaseViewModel(){
             put("goodsid",goodsid)
             put("buyorsell","0")
         }
-        MyApplication.getInstance()?.contractGoodsManager?.queryWrTradeOrderDetail(params = params){isSuccess, respData, error ->
+        MyApplication.getInstance()?.swapsManager?.queryTjmdTradeOrderDetail(params = params){isSuccess, respData, error ->
             if (isSuccess){
                 businessBuyHallDataList.postValue(respData)
             }
@@ -72,10 +69,11 @@ class SwapsBusinessHallViewModel : BaseViewModel(){
      */
     fun querySellDataList(goodsid : String){
         val params = mutableMapOf<String,String>().apply {
+            put("usertype",GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype.toString())
             put("goodsid",goodsid)
             put("buyorsell","1")
         }
-        MyApplication.getInstance()?.contractGoodsManager?.queryWrTradeOrderDetail(params = params){isSuccess, respData, error ->
+        MyApplication.getInstance()?.swapsManager?.queryTjmdTradeOrderDetail(params = params){isSuccess, respData, error ->
             if (isSuccess){
                 businessSellHallDataList.postValue(respData)
             }
@@ -120,7 +118,7 @@ class SwapsBusinessHallViewModel : BaseViewModel(){
      */
     fun setOnBuyItemClick(orderid : String){
         val oldList = businessBuyHallDataList.value
-        val newDataList = arrayListOf<WrTradeOrderDetailData>()
+        val newDataList = arrayListOf<TjmdTradeOrderDetailData>()
         oldList?.forEach {
             if (orderid == it.orderid){
                 if (it.isClick == 0){
@@ -141,7 +139,7 @@ class SwapsBusinessHallViewModel : BaseViewModel(){
      */
     fun setOnSellItemClick(orderid : String){
         val oldList = businessSellHallDataList.value
-        val newDataList = arrayListOf<WrTradeOrderDetailData>()
+        val newDataList = arrayListOf<TjmdTradeOrderDetailData>()
         oldList?.forEach {
             if (orderid == it.orderid){
                 if (it.isClick == 0){

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

@@ -7,6 +7,8 @@ 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.QuoteGoodsListData
+import cn.muchinfo.rma.global.data.TjmdTradeOrderDetailData
 import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
 import cn.muchinfo.rma.lifecycle.bindOptional
 import cn.muchinfo.rma.view.autoWidget.autoSize
@@ -18,6 +20,7 @@ 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 cn.muchinfo.rma.view.base.yrdzpurchase.swaps.delisting.SwapsDelistingActivity
 import com.blankj.utilcode.util.ActivityUtils
 import mtp.polymer.com.autowidget.adapter.BaseViewHolder
 import mtp.polymer.com.autowidget.dialog.createWarningDialog
@@ -30,7 +33,9 @@ import org.jetbrains.anko.*
  * @property itemSize IntArray
  * @constructor
  */
-class SwapsBusinessSellHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String) : BaseViewHolder<WrTradeOrderDetailData>(activity){
+class SwapsBusinessSellHallViewHolder(private val activity : AppCompatActivity, private val viewModel: SwapsBusinessHallViewModel, private val goodsCode : String,
+                                      private val quoteGoodsListData : QuoteGoodsListData
+) : BaseViewHolder<TjmdTradeOrderDetailData>(activity){
     override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
 
     override fun _FrameLayout.createContentView() {
@@ -107,7 +112,8 @@ class SwapsBusinessSellHallViewHolder(private val activity : AppCompatActivity,
                          intent.putExtra("goodsId",data.value?.goodsid)
                          intent.putExtra("goodsCode",goodsCode)
                          intent.putExtra("type","1")
-                         intent.setClass(context, PurchaseDelistingActivity::class.java)
+                         intent.putExtra("quoteGoodsListData",quoteGoodsListData)
+                         intent.setClass(context, SwapsDelistingActivity::class.java)
                          ActivityUtils.startActivity(intent)
                      }
                      backgroundResource = R.drawable.rma_item_click_bg

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

@@ -13,6 +13,8 @@ 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.QuoteGoodsListData
+import cn.muchinfo.rma.global.data.TjmdTradeOrderDetailData
 import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
 import cn.muchinfo.rma.global.database.DataBase
@@ -46,11 +48,20 @@ class SwapsDelistingActivity : BaseActivity<SwapsDelistingViewModel>(){
     val type by lazy { intent.getStringExtra("type") }
 
     /** 传入的买卖大厅数据 **/
-    val data by lazy { intent.getParcelableExtra<WrTradeOrderDetailData>("data") as WrTradeOrderDetailData }
+    val data by lazy { intent.getParcelableExtra<TjmdTradeOrderDetailData>("data") as TjmdTradeOrderDetailData }
+
+    //标的合约
+    val quoteGoodsListData by lazy { intent.getParcelableExtra<QuoteGoodsListData>("quoteGoodsListData") as QuoteGoodsListData }
 
     /** 选择的资金账号 **/
     val selectAccountData: MutableLiveData<AccountData> = MutableLiveData()
 
+    /** 用于订阅行情的唯一标识 */
+    val thisTag by lazy {
+        "SwapsDelistingActivity"
+    }
+
+
     /** 摘牌数量 **/
     lateinit var onePriceInputNumberEdittext: MangeNumberEditText2
 

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

@@ -98,6 +98,7 @@ class SwapsDelistingViewModel : BaseViewModel(){
      * isListed 是否是挂牌
      */
     fun commit(
+        pricetype : Int = 0,
         relatedID : String,
         goodsInfo: GoodsInfo,
         isListed: Boolean = true,

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

@@ -16,9 +16,11 @@ import androidx.viewpager.widget.ViewPager
 import cn.muchinfo.rma.R
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.AccountData
+import cn.muchinfo.rma.global.data.QuoteGoodsListData
 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
@@ -45,7 +47,7 @@ import org.jetbrains.anko.support.v4.viewPager
 /**
  * 合约交易挂牌操作
  */
-class PurchaseListedActivity : BaseActivity<SwapsListedViewModel>() {
+class SwapsListedActivity : BaseActivity<SwapsListedViewModel>() {
 
     lateinit var segment: QMUITabSegment
     var selectedTabIndex: Int = 0
@@ -57,6 +59,14 @@ class PurchaseListedActivity : BaseActivity<SwapsListedViewModel>() {
     /** 传入的goodscode **/
     val goodsCode by lazy { intent.getStringExtra("goodsCode") }
 
+    //标的合约
+    val quoteGoodsListData by lazy { intent.getParcelableExtra<QuoteGoodsListData>("quoteGoodsListData") as QuoteGoodsListData }
+
+    /** 用于订阅行情的唯一标识 */
+    val thisTag by lazy {
+        "SwapsListedActivity"
+    }
+
     /**
      * 卖挂ui
      */
@@ -120,6 +130,7 @@ class PurchaseListedActivity : BaseActivity<SwapsListedViewModel>() {
 
     override fun onDestroy() {
         super.onDestroy()
+        viewModel.removeSubscriptQuote(thisTag)
         EventBus.getDefault().unregister(this)
     }
 
@@ -128,7 +139,11 @@ class PurchaseListedActivity : BaseActivity<SwapsListedViewModel>() {
         viewModel.goodsInfo.postValue(
             DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0)
         )
-        viewModel.queryQuoteDay(goodsCodes = goodsCode ?: "",isShowLoading = false)
+        viewModel.queryQuoteDay(
+            tag = thisTag,
+            goodsCodes = quoteGoodsListData.refgoodscode ?: "",
+            isShowLoading = false
+        )
     }
 
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -211,6 +226,15 @@ class SellListedUI(
     /** 挂牌数量 **/
     lateinit var onePriceInputNumberEdittext: MangeNumberEditText2
 
+    /** 浮动价时的基差 **/
+    lateinit var basis_price_input: MangeNumberEditText2
+
+    /** 为浮动价挂牌时的估算价 **/
+    lateinit var estimate_price: TextView
+
+    /** 当前的价格类型 1 是固定价 2 是浮动价 **/
+    val priceType: MutableLiveData<Int> = MutableLiveData()
+
     /** SeekBar **/
     lateinit var one_seekbar: SeekBar
 
@@ -220,7 +244,11 @@ class SellListedUI(
     //初始化一些数据
     fun initializeData() {
         selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
-        viewModel.queryContractTradePosition(accountid = GlobalDataCollection.instance?.accountId.toString(),goodsId = goodsId ?: "")
+        viewModel.queryContractTradePosition(
+            accountid = GlobalDataCollection.instance?.accountId.toString(),
+            goodsId = goodsId ?: ""
+        )
+        priceType.postValue(1)
     }
 
     @RequiresApi(Build.VERSION_CODES.O)
@@ -228,11 +256,7 @@ class SellListedUI(
         verticalLayout {
             initializeData()
             linearLayout {
-                viewModel.tradePositionData.bindOptional(context){
-                    val maxNumber = it?.enableqty?.toInt() ?: 0
-                    //对最大可摘进行赋值
-                    viewModel.maxSellListedingNumber.postValue(maxNumber.toString())
-                }
+
                 gravity = Gravity.CENTER_VERTICAL
                 onThrottleFirstClick {
                     activity.creatAccountDataSheetDialog(
@@ -276,11 +300,154 @@ class SellListedUI(
 
             itemView()
 
-            verticalLayout {
+            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 {
+                    isChecked = true
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    priceType.bindOptional(context) {
+                        if (it == 2) {
+                            isChecked = false
+                        }
+                    }
+                    buttonDrawable = null
+                    background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                    setOnCheckedChangeListener { compoundButton, b ->
+                        if (b) {
+                            priceType.postValue(1)
+                        }
+                    }
+                }.lparams(autoSize(41), autoSize(41)) {
+                    marginStart = autoSize(36)
+                }
 
+                textView {
+                    text = "固定价"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(30)
+                }
+
+                checkBox {
+
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    priceType.bindOptional(context) {
+                        if (it == 1) {
+                            isChecked = false
+                        }
+                    }
+                    buttonDrawable = null
+                    background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                    setOnCheckedChangeListener { compoundButton, b ->
+                        if (b) {
+                            priceType.postValue(2)
+                        }
+                    }
+                }.lparams(autoSize(41), autoSize(41)) {
+                    marginStart = autoSize(36)
+                }
+
+                textView {
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    text = "浮动价"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(30)
+                }
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            linearLayout {
+                priceType.bindOptional(context) {
+                    if (it == 2) {
+                        visibility = View.VISIBLE
+                    } else {
+                        visibility = View.GONE
+                    }
+                }
+                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)
+
+                numberEditText {
+                    basis_price_input = this
+                    setOnTextChangeListener { view, value ->
+                        viewModel.quoteDayData.postValue(viewModel.quoteDayData.value)
+                    }
+                    text = "0"
+                    setTextColor(R.color.buy_hall_color)
+                }.lparams(0, autoSize(72), 1f){
+                    marginEnd = autoSize(110)
+                }
+
+            }.lparams(matchParent, autoSize(143))
+
+             textView {
+                 priceType.bindOptional(context) {
+                     if (it == 2) {
+                         visibility = View.VISIBLE
+                     } else {
+                         visibility = View.GONE
+                     }
+                 }
+                viewModel.quoteDayData.bindOptional(context) {
+                    if (basis_price_input.text.toString().isNullOrEmpty().not()) {
+                        text = "估算价" + NumberUtils.roundNum(
+                            it?.getPrice()?.plus(basis_price_input.text.toString().toDouble())
+                                ?: 0.0, 2
+                        )
+                    }
+                }
+                estimate_price = this
+                text = "估算价--"
+                textSizeAuto = 29
+                textColorInt = R.color.rma_black_33
+            }.lparams(wrapContent, wrapContent) {
+                marginStart = autoSize(250)
+                topMargin = autoSize(30)
+                bottomMargin = autoSize(30)
             }
 
             linearLayout {
+                priceType.bindOptional(context) {
+                    if (it == 1) {
+                        visibility = View.VISIBLE
+                    } else {
+                        visibility = View.GONE
+                    }
+                }
                 gravity = Gravity.CENTER_VERTICAL
                 linearLayout {
                     textView {
@@ -293,19 +460,32 @@ class SellListedUI(
                 }.lparams(autoSize(250), wrapContent)
 
                 numberEditText {
-                    viewModel.quoteDayData.bindOptional(context){
-                        text = NumberUtils.roundNum(it?.getPrice()?.toString(),viewModel.goodsInfo.value?.decimalplace ?: 2)
+                    viewModel.quoteDayData.bindOptional(context) {
+                        text = NumberUtils.roundNum(
+                            it?.getPrice()?.toString(),
+                            viewModel.goodsInfo.value?.decimalplace ?: 2
+                        )
                     }
-                    viewModel.goodsInfo.bindOptional(context){
+                    viewModel.goodsInfo.bindOptional(context) {
                         decimal = it?.decimalplace ?: 2
                     }
                     text = "0"
                     onePriceInputEdittext = this
                     setOnTextChangeListener { view, value ->
                         if (value.isNullOrEmpty().not() && value.toString().toDouble() != 0.0) {
-                            if (onePriceInputNumberEdittext.text.toString().isNullOrEmpty().not()){
-                                one_delisting_amount.text = NumberUtils.roundNum(value.toString().toDouble().times(onePriceInputNumberEdittext.text.toString()?.toDouble())?.times(viewModel.goodsInfo.value?.agreeunit ?: 1),2)
+                            if (onePriceInputNumberEdittext.text.toString().isNullOrEmpty().not()) {
+                                one_delisting_amount.text = NumberUtils.roundNum(
+                                    value.toString().toDouble().times(
+                                        onePriceInputNumberEdittext.text.toString()?.toDouble()
+                                    )?.times(viewModel.goodsInfo.value?.agreeunit ?: 1), 2
+                                )
                             }
+
+                            viewModel.maxSellListedingNumber.postValue(
+                                viewModel.usedAccountData.value?.canUserAmount?.div(
+                                    value?.toString()?.toDouble() ?: 1.0
+                                )?.toInt().toString()
+                            )
                         }
                     }
                     setTextColor(R.color.buy_hall_color)
@@ -340,8 +520,14 @@ class SellListedUI(
                             }
                             setOnTextChangeListener { view, value ->
                                 if (value.isNullOrEmpty().not()) {
-                                    if (onePriceInputEdittext.text.toString().isNullOrEmpty().not()){
-                                        one_delisting_amount.text = NumberUtils.roundNum(value.toString().toDouble().times(onePriceInputEdittext.text.toString()?.toDouble())?.times(viewModel.goodsInfo.value?.agreeunit ?: 1),2)
+                                    if (onePriceInputEdittext.text.toString().isNullOrEmpty()
+                                            .not()
+                                    ) {
+                                        one_delisting_amount.text = NumberUtils.roundNum(
+                                            value.toString().toDouble().times(
+                                                onePriceInputEdittext.text.toString()?.toDouble()
+                                            )?.times(viewModel.goodsInfo.value?.agreeunit ?: 1), 2
+                                        )
                                     }
                                 }
                             }
@@ -372,7 +558,8 @@ class SellListedUI(
                         setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
                             override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
                                 onePriceInputNumberEdittext.text = NumberUtils.roundNum(
-                                    viewModel.maxSellListedingNumber.value?.toDouble()?.times(p1.div(100.0))
+                                    viewModel.maxSellListedingNumber.value?.toDouble()
+                                        ?.times(p1.div(100.0))
                                         .toString(), 0
                                 )
                             }
@@ -420,7 +607,14 @@ class SellListedUI(
             linearLayout {
                 gravity = Gravity.CENTER_VERTICAL
                 textView {
-                    text = "挂牌金额"
+                    priceType.bindOptional(context){
+                        if (it == 1){//固定价
+                            text = "挂牌金额"
+                        }else{//浮动价
+                            text = "挂牌金额"
+                        }
+                    }
+
                     textSizeAuto = 34
                     textColorInt = R.color.rma_hint_text_color_ccc
                 }.lparams(autoSize(214), wrapContent) {
@@ -428,6 +622,24 @@ class SellListedUI(
                 }
                 //公式 :挂牌金额*挂牌数量*合约单位
                 textView {
+                    viewModel.quoteDayData.bindOptional(context){
+                        if (priceType.value == 2){
+                            var basis = 0.0
+                            if (basis_price_input.text.toString().isNullOrEmpty()){
+                                basis = 0.0
+                            }else{
+                                basis = basis_price_input.text.toString().toDouble()
+                            }
+                            text = NumberUtils.roundNum(
+                                (it?.getPrice()?.plus(basis))?.times(
+                                    onePriceInputEdittext.text.toString().toDouble()
+                                        .times(
+                                            viewModel.goodsInfo.value?.agreeunit ?: 1
+                                        )
+                                ) ?: 0.0, 2
+                            )
+                        }
+                    }
                     one_delisting_amount = this
                     text = "--"
                     textSizeAuto = 29
@@ -435,6 +647,17 @@ class SellListedUI(
                 }.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()
 
@@ -459,7 +682,16 @@ class SellListedUI(
                             return@onThrottleFirstClick
                         }
 
+                        var marketMaxSub = 0.0
+                        if (priceType.value == 2){
+                            if (basis_price_input.text.toString().isNullOrEmpty().not()){
+                                marketMaxSub = basis_price_input.text.toString().toDouble()
+                            }
+                        }
+
                         viewModel.commit(
+                            marketMaxSub = marketMaxSub,
+                            pricetype = priceType.value ?: 1,
                             goodsInfo = viewModel.goodsInfo.value ?: GoodsInfo(),
                             isListed = true,
                             orderPrice = onePriceInputEdittext.text.toString(),
@@ -522,6 +754,15 @@ class BuyListedUI(
     /** 挂牌数量 **/
     lateinit var onePriceInputNumberEdittext: MangeNumberEditText2
 
+    /** 浮动价时的基差 **/
+    lateinit var basis_price_input: MangeNumberEditText2
+
+    /** 为浮动价挂牌时的估算价 **/
+    lateinit var estimate_price: TextView
+
+    /** 当前的价格类型 1 是固定价 2 是浮动价 **/
+    val priceType: MutableLiveData<Int> = MutableLiveData()
+
     /** SeekBar **/
     lateinit var one_seekbar: SeekBar
 
@@ -530,6 +771,7 @@ class BuyListedUI(
 
     //初始化一些数据
     fun initializeData() {
+        priceType.postValue(1)
         selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
     }
 
@@ -586,6 +828,153 @@ class BuyListedUI(
                 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 {
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    isChecked = true
+                    priceType.bindOptional(context) {
+                        if (it == 2) {
+                            isChecked = false
+                        }
+                    }
+                    buttonDrawable = null
+                    background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                    setOnCheckedChangeListener { compoundButton, b ->
+                        if (b) {
+                            priceType.postValue(1)
+                        }
+                    }
+                }.lparams(autoSize(41), autoSize(41)) {
+                    marginStart = autoSize(36)
+                }
+
+                textView {
+                    text = "固定价"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(30)
+                }
+
+                checkBox {
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    priceType.bindOptional(context) {
+                        if (it == 1) {
+                            isChecked = false
+                        }
+                    }
+                    buttonDrawable = null
+                    background = resources.getDrawable(R.drawable.yrdz_check_select_backgrond)
+                    setOnCheckedChangeListener { compoundButton, b ->
+                        if (b) {
+                            priceType.postValue(2)
+                        }
+                    }
+                }.lparams(autoSize(41), autoSize(41)) {
+                    marginStart = autoSize(36)
+                }
+
+                textView {
+                    if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 5) {//普通交易商
+                        visibility = View.GONE
+                    } else if (GlobalDataCollection.instance?.loginQueryData?.userInfo?.usertype == 2) {//掉期交易商
+                        visibility = View.VISIBLE
+                    }
+                    text = "浮动价"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(30)
+                }
+            }.lparams(matchParent, autoSize(143))
+
+            itemView()
+
+            linearLayout {
+                priceType.bindOptional(context) {
+                    if (it == 2) {
+                        visibility = View.VISIBLE
+                    } else {
+                        visibility = View.GONE
+                    }
+                }
+                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)
+
+                numberEditText {
+                    basis_price_input = this
+                    setOnTextChangeListener { view, value ->
+                        viewModel.quoteDayData.postValue(viewModel.quoteDayData.value)
+                    }
+                    text = "0"
+                    setTextColor(R.color.buy_hall_color)
+                }.lparams(0, autoSize(72), 1f) {
+                    marginEnd = autoSize(110)
+                }
+
+
+            }.lparams(matchParent, autoSize(143))
+
+            textView {
+                priceType.bindOptional(context) {
+                    if (it == 2) {
+                        visibility = View.VISIBLE
+                    } else {
+                        visibility = View.GONE
+                    }
+                }
+                viewModel.quoteDayData.bindOptional(context) {
+                    if (basis_price_input.text.toString().isNullOrEmpty().not()) {
+                        text = "估算价" + NumberUtils.roundNum(
+                            it?.getPrice()?.plus(basis_price_input.text.toString().toDouble())
+                                ?: 0.0, 2
+                        )
+                    }
+                }
+                estimate_price = this
+                text = "估算价--"
+                textSizeAuto = 29
+                textColorInt = R.color.rma_black_33
+            }.lparams(wrapContent, wrapContent) {
+                marginStart = autoSize(250)
+                topMargin = autoSize(30)
+                bottomMargin = autoSize(30)
+            }
+
+            linearLayout {
+                priceType.bindOptional(context) {
+                    if (it == 1) {
+                        visibility = View.VISIBLE
+                    } else {
+                        visibility = View.GONE
+                    }
+                }
+                gravity = Gravity.CENTER_VERTICAL
+                linearLayout {
+                    textView {
                         text = "挂牌价格"
                         textSizeAuto = 34
                         textColorInt = R.color.rma_hint_text_color_ccc
@@ -595,19 +984,25 @@ class BuyListedUI(
                 }.lparams(autoSize(250), wrapContent)
 
                 numberEditText {
-                    viewModel.quoteDayData.bindOptional(context){
-                        text = NumberUtils.roundNum(it?.getPrice()?.toString(),viewModel.goodsInfo.value?.decimalplace ?: 2)
+                    viewModel.quoteDayData.bindOptional(context) {
+                        text = NumberUtils.roundNum(
+                            it?.getPrice()?.toString(),
+                            viewModel.goodsInfo.value?.decimalplace ?: 2
+                        )
                     }
-                    viewModel.goodsInfo.bindOptional(context){
+                    viewModel.goodsInfo.bindOptional(context) {
                         decimal = it?.decimalplace ?: 2
                     }
+                    text = "0"
                     onePriceInputEdittext = this
                     setOnTextChangeListener { view, value ->
                         if (value.isNullOrEmpty().not() && value.toString().toDouble() != 0.0) {
                             if (onePriceInputNumberEdittext.text.toString().isNullOrEmpty().not()) {
                                 one_delisting_amount.text = NumberUtils.roundNum(
                                     value.toString().toDouble()
-                                        .times(onePriceInputNumberEdittext.text.toString().toDouble())
+                                        .times(
+                                            onePriceInputNumberEdittext.text.toString().toDouble()
+                                        )
                                         .times(viewModel.goodsInfo.value?.agreeunit ?: 1), 2
                                 )
                             }
@@ -652,9 +1047,10 @@ class BuyListedUI(
                                     ) {
                                         one_delisting_amount.text = NumberUtils.roundNum(
                                             value.toString().toDouble().times(
-                                                onePriceInputEdittext.text.toString().toDouble().times(
-                                                    viewModel.goodsInfo.value?.agreeunit ?: 1
-                                                )
+                                                onePriceInputEdittext.text.toString().toDouble()
+                                                    .times(
+                                                        viewModel.goodsInfo.value?.agreeunit ?: 1
+                                                    )
                                             ), 2
                                         )
                                     }
@@ -736,7 +1132,14 @@ class BuyListedUI(
             linearLayout {
                 gravity = Gravity.CENTER_VERTICAL
                 textView {
-                    text = "挂牌金额"
+                    priceType.bindOptional(context){
+                        if (it == 1){//固定价
+                            text = "挂牌金额"
+                        }else{//浮动价
+                            text = "挂牌金额"
+                        }
+                    }
+
                     textSizeAuto = 34
                     textColorInt = R.color.rma_hint_text_color_ccc
                 }.lparams(autoSize(214), wrapContent) {
@@ -744,6 +1147,24 @@ class BuyListedUI(
                 }
                 //公式 :挂牌金额*挂牌数量*合约单位
                 textView {
+                    viewModel.quoteDayData.bindOptional(context){
+                        if (priceType.value == 2){
+                            var basis = 0.0
+                            if (basis_price_input.text.toString().isNullOrEmpty()){
+                                basis = 0.0
+                            }else{
+                                basis = basis_price_input.text.toString().toDouble()
+                            }
+                            text = NumberUtils.roundNum(
+                                (it?.getPrice()?.plus(basis))?.times(
+                                    onePriceInputEdittext.text.toString().toDouble()
+                                        .times(
+                                            viewModel.goodsInfo.value?.agreeunit ?: 1
+                                        )
+                                ) ?: 0.0, 2
+                            )
+                        }
+                    }
                     one_delisting_amount = this
                     text = "--"
                     textSizeAuto = 29
@@ -769,14 +1190,17 @@ class BuyListedUI(
                 gravity = Gravity.CENTER_VERTICAL
                 textView {
                     onThrottleFirstClick {
-                        if (onePriceInputEdittext.text.toString()
-                                .isNullOrEmpty() || onePriceInputEdittext.text.toString()
-                                .toDouble() == 0.0
-                        ) {
-                            ToastUtils.showLong("请输入挂牌金额")
-                            return@onThrottleFirstClick
+                        if (priceType.value == 2) {
+                            if (onePriceInputEdittext.text.toString()
+                                    .isNullOrEmpty() || onePriceInputEdittext.text.toString()
+                                    .toDouble() == 0.0
+                            ) {
+                                ToastUtils.showLong("请输入挂牌价格")
+                                return@onThrottleFirstClick
+                            }
                         }
 
+
                         if (onePriceInputNumberEdittext.text.toString()
                                 .isNullOrEmpty() || onePriceInputNumberEdittext.text.toString()
                                 .toDouble() == 0.0
@@ -785,7 +1209,16 @@ class BuyListedUI(
                             return@onThrottleFirstClick
                         }
 
+                        var marketMaxSub = 0.0
+                        if (priceType.value == 2){
+                            if (basis_price_input.text.toString().isNullOrEmpty().not()){
+                                marketMaxSub = basis_price_input.text.toString().toDouble()
+                            }
+                        }
+
                         viewModel.commit(
+                            marketMaxSub = marketMaxSub,
+                            pricetype = priceType.value ?: 1,
                             goodsInfo = viewModel.goodsInfo.value ?: GoodsInfo(),
                             isListed = true,
                             orderPrice = onePriceInputEdittext.text.toString(),

+ 81 - 41
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/listed/SwapsListedViewModel.kt

@@ -12,6 +12,7 @@ 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 com.blankj.utilcode.util.LogUtils
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
 import mtp.polymer.com.autowidget.utils.TaskUiModel
@@ -56,45 +57,6 @@ class SwapsListedViewModel : BaseViewModel(){
      */
     val quoteDayData: MutableLiveData<QuoteDayData> = MutableLiveData()
 
-    /**
-     * 获取盘面信息
-     * @param goodsCodes String
-     * @param isShowLoading Boolean
-     */
-    fun queryQuoteDay(
-        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 = "数据请求失败"
-                            )
-                        )
-                    )
-                }
-            }
-        }
-    }
-
 
     //查询资金账号信息
     fun getTaAccounts(){
@@ -164,6 +126,8 @@ class SwapsListedViewModel : BaseViewModel(){
      * isListed 是否是挂牌
      */
     fun commit(
+        marketMaxSub : Double = 0.0,
+        pricetype : Int = 0,
         goodsInfo: GoodsInfo,
         isListed: Boolean = true,
         orderPrice: String,
@@ -179,7 +143,7 @@ class SwapsListedViewModel : BaseViewModel(){
             orderData.buildType = MTPEnums.BUILDTYPE_OPEN// 建仓
             orderData.buyOrSell = MTPEnums.DIRECTION_BUY// 买入
         } else {
-            orderData.buildType = MTPEnums.BUILDTYPE_CLOSE// 平
+            orderData.buildType = MTPEnums.BUILDTYPE_OPEN// 建
             orderData.buyOrSell = MTPEnums.DIRECTION_SALE// 卖出
         }
         orderData.goodsID = goodsInfo.goodsid
@@ -193,7 +157,11 @@ class SwapsListedViewModel : BaseViewModel(){
         orderData.orderQty = qty.toLong()//数量
 
         orderData.orderSrc = MTPEnums.ORDERSRC_CLIENT// 来自客户端
-        orderData.priceMode = MTPEnums.PRICEMODE_LIMIT//
+        if (pricetype == 1){
+            orderData.priceMode = MTPEnums.PRICEMODE_LIMIT// 2是固定价 3是浮动价
+        }else if (pricetype == 2){
+            orderData.priceMode = MTPEnums.PRICEMODE_FLOAT// 2是固定价 3是浮动价
+        }
         orderData.timevalidType = MTPEnums.TC_IOC
         orderData.validType = MTPEnums.VALIDTYPE_DR
         orderData.delistingType = MTPEnums.DELISTINGTYPE_SELECTED
@@ -227,4 +195,76 @@ class SwapsListedViewModel : BaseViewModel(){
 
     }
 
+
+    /**
+     * 请求盘面信息
+     * @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
+            )
+        }
+    }
+
+
 }

+ 2 - 2
RMA/app/src/main/res/drawable/rma_item_text_bg.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
     <stroke
-        android:color=" #DAEDFF "
+        android:color="#DAEDFF "
         android:width="0.5dp" />
-    <solid android:color=" #DAEDFF "/>
+    <solid android:color="#DAEDFF "/>
     <corners android:radius="40dp"/>
 </shape>