|
|
@@ -0,0 +1,1140 @@
|
|
|
+package cn.muchinfo.rma.view.base.hnstcdys.dialog
|
|
|
+
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.graphics.Color
|
|
|
+import android.os.Build
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import android.view.inputmethod.EditorInfo
|
|
|
+import android.widget.EditText
|
|
|
+import android.widget.SeekBar
|
|
|
+import android.widget.TextView
|
|
|
+import androidx.annotation.RequiresApi
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
+import androidx.core.view.isInvisible
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import androidx.viewpager.widget.PagerAdapter
|
|
|
+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.HoldLBData
|
|
|
+import cn.muchinfo.rma.global.data.OrderQuoteData
|
|
|
+import cn.muchinfo.rma.global.utils.TimeUtils
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.protobuf.protoclasses.WarehouseTradeMI1
|
|
|
+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.autoWidget.view.MangeNumberEditText3
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import cn.muchinfo.rma.view.base.hnstcdys.HnstcdysViewModel
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.verticalEmptyView
|
|
|
+import cn.muchinfo.rma.view.base.warehousereceipt.WarehouseReceiptViewModel
|
|
|
+import cn.muchinfo.rma.view.base.warehousereceipt.dialog.ListedData
|
|
|
+import com.blankj.utilcode.util.ConvertUtils
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
+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.dialog.CustomDialogFragment
|
|
|
+import mtp.polymer.com.autowidget.dialog.creatAccountDataSheetDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.creatHnstSpotDetailSheetDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.createCustomDialog
|
|
|
+import org.jetbrains.anko.*
|
|
|
+import org.jetbrains.anko.support.v4.viewPager
|
|
|
+import org.w3c.dom.Text
|
|
|
+
|
|
|
+/**
|
|
|
+ * 浮动价的买卖挂牌(此页面是进入买卖大厅有仓单要素id的浮动价挂牌)
|
|
|
+ * @receiver AppCompatActivity
|
|
|
+ * @param activity AppCompatActivity
|
|
|
+ * @param viewModel BusinessHallViewModel
|
|
|
+ * @param data OrderQuoteData
|
|
|
+ * @return CustomDialogFragment
|
|
|
+ */
|
|
|
+fun AppCompatActivity.HnstFloatListedDialog(
|
|
|
+ activity: AppCompatActivity,
|
|
|
+ type: String,
|
|
|
+ viewModel: HnstcdysViewModel,
|
|
|
+ data: ListedData
|
|
|
+): CustomDialogFragment {
|
|
|
+
|
|
|
+ val tag = "quotetag"
|
|
|
+
|
|
|
+ lateinit var segment: QMUITabSegment
|
|
|
+ var selectedTabIndex: Int = 0
|
|
|
+ lateinit var viewPager: ViewPager
|
|
|
+
|
|
|
+ //浮动价卖挂牌
|
|
|
+ val oneSellListedUI by lazy {
|
|
|
+ FloatSellListedUI(activity, viewModel, type, data, tag)
|
|
|
+ }
|
|
|
+
|
|
|
+ //浮动价买挂牌
|
|
|
+ val oneBuyListedUI by lazy {
|
|
|
+ FloatBuyListedUI(activity, viewModel, type, data, tag)
|
|
|
+ }
|
|
|
+
|
|
|
+ //viewpager的适配器
|
|
|
+ var newPagerAdapter: PagerAdapter? = null
|
|
|
+
|
|
|
+ //tabSegment标题
|
|
|
+ val newTabsArray: ArrayList<String> = arrayListOf()
|
|
|
+
|
|
|
+ //暂存的页面组
|
|
|
+ val uiList: ArrayList<_FrameLayout> = arrayListOf()
|
|
|
+
|
|
|
+ val selectIndex: MutableLiveData<Int> = MutableLiveData()
|
|
|
+
|
|
|
+ fun initMenuData() {
|
|
|
+
|
|
|
+ newTabsArray.add("卖挂牌")
|
|
|
+ uiList.add(oneSellListedUI.root)
|
|
|
+
|
|
|
+ newTabsArray.add("买挂牌")
|
|
|
+ uiList.add(oneBuyListedUI.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
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return createCustomDialog(cancelable = false) { dialog ->
|
|
|
+ backgroundColor = Color.parseColor("#5f000000")
|
|
|
+ initMenuData()
|
|
|
+ //对资金信息进行初始化
|
|
|
+ viewModel.resetAccountData()
|
|
|
+ //查询是否有相应的预售仓单
|
|
|
+ viewModel.queryorderSummaryWrPosition(deliverygoodsid = data.DeliveryGoodsID,wrstandardid = data.WrFtWrstandard.wrstandardid ?: "",warehouseid = data.getWarehouseid(),dgitemname = data.getdgitemname())
|
|
|
+
|
|
|
+ viewModel.queryQuoteDayByListed(
|
|
|
+ tag = tag,
|
|
|
+ goodsCodes = data.goodsCode,
|
|
|
+ isShowLoading = false
|
|
|
+ )
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.controlDialogDisappear.bindOptional(context) {
|
|
|
+ if (it == true) {
|
|
|
+ dialog.dismiss()
|
|
|
+ viewModel.controlDialogDisappear.postValue(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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(16f))
|
|
|
+ }.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)
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
+ topMargin = autoSize(120)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//浮动价卖挂牌
|
|
|
+class FloatSellListedUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: HnstcdysViewModel,
|
|
|
+ private val type: String,
|
|
|
+ data: ListedData,
|
|
|
+ tag: String//订阅标示
|
|
|
+) {
|
|
|
+
|
|
|
+ //选择的资金账号
|
|
|
+ val selectAccountData: MutableLiveData<AccountData> = MutableLiveData()
|
|
|
+
|
|
|
+ //基差输入
|
|
|
+ lateinit var basisInputEdittext: MangeNumberEditText3
|
|
|
+
|
|
|
+ //初始化后基差是否被define
|
|
|
+ var isdefineByBasis: Boolean = false
|
|
|
+
|
|
|
+ //数量
|
|
|
+ lateinit var listednumberEdittext: MangeNumberEditText2
|
|
|
+
|
|
|
+ //起摘数量输入框
|
|
|
+ lateinit var startInputNumber: EditText
|
|
|
+
|
|
|
+ //估算总额
|
|
|
+ lateinit var float_delisting_amount: TextView
|
|
|
+
|
|
|
+ //估算总价
|
|
|
+ lateinit var float_total_amount: TextView
|
|
|
+
|
|
|
+ lateinit var max_number: TextView
|
|
|
+
|
|
|
+ //浮动价挂牌金额
|
|
|
+ val listed_price: MutableLiveData<Double> = MutableLiveData()
|
|
|
+
|
|
|
+ var marginValue = 0.0//履约保证金比例
|
|
|
+
|
|
|
+ //初始化设置履约保证金比例
|
|
|
+ fun setMarginValue() {
|
|
|
+ if (type == "1") {//有仓单的卖履约保证金
|
|
|
+ marginValue =
|
|
|
+ GlobalDataCollection.instance?.marketTradeConfigData?.sellmarginvalue?.toDouble()
|
|
|
+ ?: 0.0
|
|
|
+ } else {//无仓单的卖履约保证金比例
|
|
|
+ marginValue =
|
|
|
+ GlobalDataCollection.instance?.marketTradeConfigData?.sellmarginvalue2?.toDouble()
|
|
|
+ ?: 0.0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ @RequiresApi(Build.VERSION_CODES.O)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ setMarginValue()
|
|
|
+ selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
|
|
|
+ backgroundDrawable = createRoundRectDrawable("#ffffff", 24)
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ //行情下发计算挂牌金额 = (基差价格+期货合约价)* 挂牌数量
|
|
|
+ if (isdefineByBasis && basisInputEdittext.text.toString().isNullOrEmpty()
|
|
|
+ .not() && basisInputEdittext.text.toString() != "-"
|
|
|
+ ) {//初始化相应控件后才能取值计算
|
|
|
+ listed_price.postValue(
|
|
|
+ basisInputEdittext.text.toString().toDouble().plus(it?.getPrice() ?: 0.0)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ onThrottleFirstClick {
|
|
|
+ activity.creatAccountDataSheetDialog(
|
|
|
+ "请选择资金账号",
|
|
|
+ GlobalDataCollection.instance?.accountDataList ?: arrayListOf()
|
|
|
+ ) {
|
|
|
+ selectAccountData.postValue(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ 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)
|
|
|
+
|
|
|
+ numberEditText3 {
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ val MarketTradeConfig = GlobalDataCollection.instance?.marketTradeConfigData
|
|
|
+ max =
|
|
|
+ it?.preclose?.times(MarketTradeConfig?.basisupratio?.toDouble() ?: 0.0)
|
|
|
+ ?: 0.0
|
|
|
+ min = it?.preclose?.times(-1.0)
|
|
|
+ ?.times(MarketTradeConfig?.basisdownratio?.toDouble() ?: 0.0) ?: 0.0
|
|
|
+ }
|
|
|
+ basisInputEdittext = this
|
|
|
+ isdefineByBasis = true
|
|
|
+ text = "0"
|
|
|
+ setOnTextChangeListener { view, value ->
|
|
|
+ if (value.isNotEmpty()) {
|
|
|
+ //行情下发计算挂牌金额 = (基差价格+期货合约价)* 挂牌数量
|
|
|
+ listed_price.postValue(
|
|
|
+ value.toString().toDouble()
|
|
|
+ .plus(viewModel.quoteDayData.value?.getPrice() ?: 0.0)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(72), 1f) {
|
|
|
+ marginEnd = autoSize(110)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ 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"
|
|
|
+ listednumberEdittext = this
|
|
|
+ setOnTextChangeListener { view, value ->
|
|
|
+ if (value.isNullOrEmpty().not()) {
|
|
|
+
|
|
|
+ val floatDelistingAmount =
|
|
|
+ listed_price.value?.times(value.toString().toDouble())
|
|
|
+ if (floatDelistingAmount != 0.0) {
|
|
|
+ //显示估算总额
|
|
|
+ if (marginValue == 0.0) {
|
|
|
+ float_delisting_amount.text =
|
|
|
+ NumberUtils.roundNum(floatDelistingAmount ?: 0.0, 2)
|
|
|
+ } else {
|
|
|
+ float_delisting_amount.text = NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount ?: 0.0,
|
|
|
+ 2
|
|
|
+ ) + "(需履约保证金" + NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount?.times(marginValue) ?: 0.0,
|
|
|
+ 2
|
|
|
+ ) + ")"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(0, autoSize(72), 1f) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = data.WrFtWrstandard.enumdicname
|
|
|
+ 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) {
|
|
|
+ min = 10
|
|
|
+ max = 100
|
|
|
+ isIndeterminate = false
|
|
|
+ splitTrack = false
|
|
|
+ setPadding(0, 0, 0, 0)
|
|
|
+ thumb = resources.getDrawable(R.mipmap.hnst_seekbar)
|
|
|
+ thumbOffset = 0
|
|
|
+ progressDrawable = resources.getDrawable(R.drawable.seekbar_bg)
|
|
|
+ setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
|
|
+ override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
+ listednumberEdittext.text = NumberUtils.roundNum(
|
|
|
+ max_number.text.toString().toDouble().times(p1.div(100.0)), 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
+ marginEnd = autoSize(110)
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = "0"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ max_number = this
|
|
|
+ text = "1"
|
|
|
+ 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 {
|
|
|
+ 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)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ editText {
|
|
|
+ startInputNumber = this
|
|
|
+ hint = "请输入起摘数量"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_NUMBER
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(0, autoSize(132), 1f) {
|
|
|
+ topMargin = autoSize(15)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = data.WrFtWrstandard.enumdicname
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text =
|
|
|
+ "最小单位" + data.WrFtWrstandard.minivalue + data.WrFtWrstandard.enumdicname
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(matchParent, autoSize(167))
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(167))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "估算总价"
|
|
|
+ textSizeAuto = 34
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(autoSize(214), wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "--"
|
|
|
+ listed_price.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(it ?: 0.0, 2)
|
|
|
+ }
|
|
|
+ float_total_amount = this
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(matchParent, autoSize(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "估算总额"
|
|
|
+ textSizeAuto = 34
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(autoSize(214), wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "--"
|
|
|
+ listed_price.bindOptional(context) {
|
|
|
+ val floatDelistingAmount =
|
|
|
+ it?.times(listednumberEdittext.text.toString().toDouble())
|
|
|
+ if (floatDelistingAmount != 0.0) {
|
|
|
+ if (marginValue == 0.0) {
|
|
|
+ text = NumberUtils.roundNum(floatDelistingAmount ?: 0.0, 2)
|
|
|
+ } else {
|
|
|
+ text = NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount ?: 0.0,
|
|
|
+ 2
|
|
|
+ ) + "(需履约保证金" + NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount?.times(
|
|
|
+ marginValue
|
|
|
+ ) ?: 0.0, 2
|
|
|
+ ) + ")"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ float_delisting_amount = this
|
|
|
+ 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 (viewModel.summaryWrPositionDataByDialog.value?.accountid.isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("没有对应的仓单数据,不能进行挂牌操作")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (listednumberEdittext.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入挂牌数量")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (listednumberEdittext.text.toString().toDouble() == 0.0) {
|
|
|
+ ToastUtils.showLong("挂牌数量不能为零")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (basisInputEdittext.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入基差")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startInputNumber.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入起摘数量")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (startInputNumber.text.toString()
|
|
|
+ .toLong() < data.WrFtWrstandard.minivalue?.toLong() ?: 0
|
|
|
+ ) {
|
|
|
+ ToastUtils.showLong("起摘数量不能小于" + data.WrFtWrstandard.minivalue)
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ viewModel.requeryWRListingOrderReq(
|
|
|
+ FactoryItems = data.getFactoryItems(),
|
|
|
+ LadingBillId = 0,
|
|
|
+ TradeDate = TimeUtils.getNowTime("yyyyMMdd"),
|
|
|
+ SubNum = 0,
|
|
|
+ WRFactorTypeId = 0,
|
|
|
+ UserID = GlobalDataCollection.instance?.loginRsp?.userID ?: 0,
|
|
|
+ AccountID = GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ IsSpecified = 0,
|
|
|
+ OrderQty = listednumberEdittext.text.toString().toLong(),
|
|
|
+ DeliveryGoodsID = data.DeliveryGoodsID.toInt() ?: 0,
|
|
|
+ WRPriceType = 2,
|
|
|
+ WRTradeGoods = getWRTradeGoods(data),
|
|
|
+ PriceFactor = 1.0,
|
|
|
+ PriceMove = basisInputEdittext.text.toString().toDouble(),
|
|
|
+ TimevalidType = 4,
|
|
|
+ FirstRatio = 0.0,
|
|
|
+ PerformanceTemplateID = 0,
|
|
|
+ BuyOrSell = 1,
|
|
|
+ PriceDisplayMode = 1,
|
|
|
+ CanBargain = 0,
|
|
|
+ ApplyID = 0,
|
|
|
+ CanPart = 1,
|
|
|
+ HasWr = 0,
|
|
|
+ DeliveryMonth = data.DeliveryMonth,
|
|
|
+ DelistMinQty = startInputNumber.text.toString().toLong(),
|
|
|
+ WRStandardID = data.WrFtWrstandard.wrstandardid?.toInt() ?: 0
|
|
|
+ ) {
|
|
|
+ viewModel.removeSubscriptQuote(tag = tag)
|
|
|
+ viewModel.controlDialogDisappear.postValue(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.drawable.qhj_main_blue_bg
|
|
|
+ text = "卖出"
|
|
|
+ textSizeAuto = 38
|
|
|
+ textColorInt = R.color.white
|
|
|
+ }.lparams(autoSize(419), autoSize(119)) {
|
|
|
+ marginStart = autoSize(24)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ viewModel.removeSubscriptQuote(tag = tag)
|
|
|
+ viewModel.controlDialogDisappear.postValue(true)
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getWRTradeGoods(data: ListedData): WarehouseTradeMI1.WRGoodsInfo {
|
|
|
+ val wRTradeGoods = WarehouseTradeMI1.WRGoodsInfo.newBuilder()
|
|
|
+ wRTradeGoods.setGoodsID(data.goodsId.toInt())
|
|
|
+ wRTradeGoods.setGoodsCode(data.goodsCode)
|
|
|
+ wRTradeGoods.setPriceFactor(1.0)
|
|
|
+ wRTradeGoods.setPriceMove(1.0)
|
|
|
+ wRTradeGoods.setWeightRatio(1.0)
|
|
|
+ return wRTradeGoods.build()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//浮动价买挂牌
|
|
|
+class FloatBuyListedUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: HnstcdysViewModel,
|
|
|
+ type: String,
|
|
|
+ data: ListedData,
|
|
|
+ tag: String//订阅标示
|
|
|
+) {
|
|
|
+ //选择的资金账号
|
|
|
+ val selectAccountData: MutableLiveData<AccountData> = MutableLiveData()
|
|
|
+
|
|
|
+ //基差
|
|
|
+ lateinit var basisInputEdittext: MangeNumberEditText3
|
|
|
+
|
|
|
+ //初始化后基差是否被define
|
|
|
+ var isdefineByBasis: Boolean = false
|
|
|
+
|
|
|
+ //挂牌数量
|
|
|
+ lateinit var oneNumberInputEdittext: MangeNumberEditText2
|
|
|
+
|
|
|
+ //起摘数量输入框
|
|
|
+ lateinit var startInputNumber: EditText
|
|
|
+
|
|
|
+ //摘牌金额
|
|
|
+ lateinit var one_delisting_amount: TextView
|
|
|
+
|
|
|
+ //估算总额
|
|
|
+ lateinit var float_delisting_amount: TextView
|
|
|
+
|
|
|
+ //估算总价
|
|
|
+ lateinit var float_total_amount: TextView
|
|
|
+
|
|
|
+ //SeekBar
|
|
|
+ lateinit var seekBar: SeekBar
|
|
|
+
|
|
|
+ //挂牌最大数量
|
|
|
+ val maxlistedNumber: MutableLiveData<Int> = MutableLiveData()
|
|
|
+
|
|
|
+ //浮动价挂牌金额
|
|
|
+ val listed_price: MutableLiveData<Double> = MutableLiveData()
|
|
|
+
|
|
|
+ var marginValue = 0.0//履约保证金比例
|
|
|
+
|
|
|
+ //初始化设置履约保证金比例
|
|
|
+ fun setMarginValue() {
|
|
|
+ marginValue =
|
|
|
+ GlobalDataCollection.instance?.marketTradeConfigData?.buymarginvalue?.toDouble()
|
|
|
+ ?: 0.0
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ @RequiresApi(Build.VERSION_CODES.O)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ //行情下发计算挂牌金额 = (基差价格+期货合约价)* 挂牌数量
|
|
|
+ if (isdefineByBasis && basisInputEdittext.text.toString().isNullOrEmpty()
|
|
|
+ .not() && basisInputEdittext.text.toString() != "-"
|
|
|
+ ) {
|
|
|
+ listed_price.postValue(
|
|
|
+ basisInputEdittext.text.toString().toDouble().plus(it?.getPrice() ?: 0.0)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setMarginValue()
|
|
|
+ selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
|
|
|
+ backgroundDrawable = createRoundRectDrawable("#ffffff", 24)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ onThrottleFirstClick {
|
|
|
+ activity.creatAccountDataSheetDialog(
|
|
|
+ "请选择资金账号",
|
|
|
+ GlobalDataCollection.instance?.accountDataList ?: arrayListOf()
|
|
|
+ ) {
|
|
|
+ selectAccountData.postValue(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ 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)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ numberEditText3 {
|
|
|
+ text = "0"
|
|
|
+ basisInputEdittext = this
|
|
|
+ isdefineByBasis = true
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ val MarketTradeConfig = GlobalDataCollection.instance?.marketTradeConfigData
|
|
|
+ max =
|
|
|
+ it?.preclose?.times(MarketTradeConfig?.basisupratio?.toDouble() ?: 0.0)
|
|
|
+ ?: 0.0
|
|
|
+ min = it?.preclose?.times(-1.0)
|
|
|
+ ?.times(MarketTradeConfig?.basisdownratio?.toDouble() ?: 0.0) ?: 0.0
|
|
|
+ }
|
|
|
+ setOnTextChangeListener { view, value ->
|
|
|
+ if (value.isNotEmpty()) {
|
|
|
+ // 计算挂牌金额 = (基差价格+期货合约价)* 挂牌数量
|
|
|
+ listed_price.postValue(
|
|
|
+ value.toString().toDouble()
|
|
|
+ .plus(viewModel.quoteDayData.value?.getPrice() ?: 0.0)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(0, autoSize(72), 1f) {
|
|
|
+ marginEnd = autoSize(110)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ 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"
|
|
|
+ oneNumberInputEdittext = this
|
|
|
+ setOnTextChangeListener { view, value ->
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(0, autoSize(72), 1f) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "吨"
|
|
|
+ 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) {
|
|
|
+ min = 10
|
|
|
+ max = 100
|
|
|
+ seekBar = this
|
|
|
+ isIndeterminate = false
|
|
|
+ splitTrack = false
|
|
|
+ setPadding(0, 0, 0, 0)
|
|
|
+ thumb = resources.getDrawable(R.mipmap.hnst_seekbar)
|
|
|
+ thumbOffset = 0
|
|
|
+ progressDrawable = resources.getDrawable(R.drawable.seekbar_bg)
|
|
|
+ setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
|
|
+ override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
+ oneNumberInputEdittext.text = NumberUtils.roundNum(
|
|
|
+ maxlistedNumber.value?.times(p1.div(100.0)).toString(), 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
+ marginEnd = autoSize(110)
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ text = "0"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ maxlistedNumber.bindOptional(context) {
|
|
|
+ oneNumberInputEdittext.text = NumberUtils.roundNum(
|
|
|
+ it?.times(seekBar.progress.div(100.0)).toString(), 0
|
|
|
+ )
|
|
|
+ text = it.toString() + data.WrFtWrstandard.enumdicname
|
|
|
+ }
|
|
|
+ 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 {
|
|
|
+ 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)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ editText {
|
|
|
+ startInputNumber = this
|
|
|
+ hint = "请输入起摘数量"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(0, autoSize(132), 1f) {
|
|
|
+ topMargin = autoSize(15)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = data.WrFtWrstandard.enumdicname
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text =
|
|
|
+ "最小单位" + data.WrFtWrstandard.minivalue + data.WrFtWrstandard.enumdicname
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(5)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(167))
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(167))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "估算总价"
|
|
|
+ textSizeAuto = 34
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(autoSize(214), wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "--"
|
|
|
+ listed_price.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(it ?: 0.0, 2)
|
|
|
+ if (it != 0.0 && marginValue != 0.0) {
|
|
|
+ maxlistedNumber.postValue(
|
|
|
+ viewModel.usedAccountData.value?.canUserAmount?.div(
|
|
|
+ marginValue
|
|
|
+ )?.div(it ?: 1.0)?.toInt()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ float_total_amount = this
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(matchParent, autoSize(143))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "估算总额"
|
|
|
+ textSizeAuto = 34
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(autoSize(214), wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "--"
|
|
|
+ listed_price.bindOptional(context) {
|
|
|
+ val floatDelistingAmount =
|
|
|
+ it?.times(oneNumberInputEdittext.text.toString().toDouble())
|
|
|
+ if (floatDelistingAmount != 0.0) {
|
|
|
+ if (marginValue == 0.0) {
|
|
|
+ text = NumberUtils.roundNum(floatDelistingAmount ?: 0.0, 2)
|
|
|
+ } else {
|
|
|
+ text = NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount ?: 0.0,
|
|
|
+ 2
|
|
|
+ ) + "(需履约保证金" + NumberUtils.roundNum(
|
|
|
+ floatDelistingAmount?.times(
|
|
|
+ marginValue
|
|
|
+ ) ?: 0.0, 2
|
|
|
+ ) + ")"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ float_delisting_amount = this
|
|
|
+ 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 (basisInputEdittext.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入基差")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (basisInputEdittext.text.toString().toDouble() == 0.0) {
|
|
|
+ ToastUtils.showLong("基差不能为零")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (oneNumberInputEdittext.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入挂牌数量")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (oneNumberInputEdittext.text.toString().toDouble() == 0.0) {
|
|
|
+ ToastUtils.showLong("挂牌数量不能为零")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startInputNumber.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入起摘数量")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (startInputNumber.text.toString()
|
|
|
+ .toLong() < data.WrFtWrstandard.minivalue?.toLong() ?: 0
|
|
|
+ ) {
|
|
|
+ ToastUtils.showLong("起摘数量不能小于" + data.WrFtWrstandard.minivalue)
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ viewModel.requeryWRListingOrderReq(
|
|
|
+ FactoryItems = data.getFactoryItems(),
|
|
|
+ TradeDate = TimeUtils.getNowTime("yyyyMMdd"),
|
|
|
+ WRFactorTypeId = 0,
|
|
|
+ UserID = GlobalDataCollection.instance?.loginRsp?.userID ?: 0,
|
|
|
+ AccountID = selectAccountData.value?.accountid ?: 0,
|
|
|
+ IsSpecified = 0,
|
|
|
+ OrderQty = oneNumberInputEdittext.text.toString().toLong(),
|
|
|
+ DeliveryGoodsID = data.DeliveryGoodsID.toInt() ?: 0,
|
|
|
+ WRPriceType = 2,
|
|
|
+ PriceMove = basisInputEdittext.text.toString().toDouble(),
|
|
|
+ WRTradeGoods = getWRTradeGoods(data),
|
|
|
+ TimevalidType = 4,
|
|
|
+ FirstRatio = 0.0,
|
|
|
+ PerformanceTemplateID = 0,
|
|
|
+ BuyOrSell = 0,
|
|
|
+ PriceDisplayMode = 1,
|
|
|
+ CanBargain = 0,
|
|
|
+ ApplyID = 0,
|
|
|
+ CanPart = 1,
|
|
|
+ HasWr = 0,
|
|
|
+ DeliveryMonth = data.DeliveryMonth,
|
|
|
+ DelistMinQty = startInputNumber.text.toString().toLong(),
|
|
|
+ WRStandardID = data.WrFtWrstandard.wrstandardid?.toInt() ?: 0
|
|
|
+ ) {
|
|
|
+ viewModel.removeSubscriptQuote(tag = tag)
|
|
|
+ viewModel.controlDialogDisappear.postValue(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.drawable.qhj_main_blue_bg
|
|
|
+ text = "买入"
|
|
|
+ textSizeAuto = 38
|
|
|
+ textColorInt = R.color.white
|
|
|
+ }.lparams(autoSize(419), autoSize(119)) {
|
|
|
+ marginStart = autoSize(24)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ viewModel.controlDialogDisappear.postValue(true)
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getWRTradeGoods(data: ListedData): WarehouseTradeMI1.WRGoodsInfo {
|
|
|
+ val wRTradeGoods = WarehouseTradeMI1.WRGoodsInfo.newBuilder()
|
|
|
+ wRTradeGoods.setGoodsID(data.goodsId.toInt())
|
|
|
+ wRTradeGoods.setGoodsCode(data.goodsCode)
|
|
|
+ wRTradeGoods.setPriceFactor(1.0)
|
|
|
+ wRTradeGoods.setPriceMove(1.0)
|
|
|
+ wRTradeGoods.setWeightRatio(1.0)
|
|
|
+ return wRTradeGoods.build()
|
|
|
+ }
|
|
|
+}
|