|
|
@@ -46,14 +46,14 @@ import org.jetbrains.anko.*
|
|
|
class PlatinumBuyOrSellUI(
|
|
|
private val activity: PlatinumTradeActivity,
|
|
|
private val viewModel: PlatinumTradeViewModel,
|
|
|
- private val goodsId : String,
|
|
|
- private val outGoodsCode : String,
|
|
|
- private val thisTag : String,
|
|
|
+ private val goodsId: String,
|
|
|
+ private val outGoodsCode: String,
|
|
|
+ private val thisTag: String,
|
|
|
private val type: String
|
|
|
) {
|
|
|
|
|
|
//选择的交易类型 金额或者数量 1 是数量 2 是金额
|
|
|
- val selectPayType : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+ val selectPayType: MutableLiveData<SelectData> = MutableLiveData()
|
|
|
|
|
|
// 下拉刷新
|
|
|
private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
@@ -66,10 +66,10 @@ class PlatinumBuyOrSellUI(
|
|
|
lateinit var trade_number_or_amount: MangeNumberEditText2
|
|
|
|
|
|
//销售价
|
|
|
- lateinit var sell_price : TextView
|
|
|
+ lateinit var sell_price: TextView
|
|
|
|
|
|
//回购价
|
|
|
- lateinit var buy_price : TextView
|
|
|
+ lateinit var buy_price: TextView
|
|
|
|
|
|
/**
|
|
|
* 交易下持仓
|
|
|
@@ -82,10 +82,21 @@ class PlatinumBuyOrSellUI(
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- fun initData(goodsId: String, outGoodsCode: String = "",buyOrSell: Int = -1,isShowLoading : Boolean = true){
|
|
|
- selectPayType.postValue(SelectData(id = "1",value = "数量"))
|
|
|
- viewModel.goodsInfoData.postValue(DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId.toInt()))//获取商品详情
|
|
|
- viewModel.queryQuoteDay(tag = thisTag,goodsCodes = outGoodsCode,isShowLoading = isShowLoading)//请求盘面
|
|
|
+ fun initData(
|
|
|
+ goodsId: String,
|
|
|
+ outGoodsCode: String = "",
|
|
|
+ buyOrSell: Int = -1,
|
|
|
+ isShowLoading: Boolean = true
|
|
|
+ ) {
|
|
|
+ selectPayType.postValue(SelectData(id = "1", value = "数量"))
|
|
|
+ viewModel.goodsInfoData.postValue(
|
|
|
+ DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId.toInt())
|
|
|
+ )//获取商品详情
|
|
|
+ viewModel.queryQuoteDay(
|
|
|
+ tag = thisTag,
|
|
|
+ goodsCodes = outGoodsCode,
|
|
|
+ isShowLoading = isShowLoading
|
|
|
+ )//请求盘面
|
|
|
viewModel.queryContractTradePosition()
|
|
|
viewModel.queryGoodsEx(goodsid = goodsId)
|
|
|
}
|
|
|
@@ -95,11 +106,13 @@ class PlatinumBuyOrSellUI(
|
|
|
fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
|
|
|
val goodsids = quoteMessageEvent.goodsid
|
|
|
//如果推送的goodsid包含当前页面的goodsid,则进行页面刷新
|
|
|
- if (goodsids.contains(goodsId?.toInt())){
|
|
|
- LogUtils.eTag("dasjhdkjagfkask","行情推送" + goodsId)
|
|
|
- val goodsInfo = DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0)
|
|
|
- val quote = GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find { goodsInfo?.outgoodscode == it.outgoodscode }?.quoteDayData
|
|
|
- if (quote != null){
|
|
|
+ if (goodsids.contains(goodsId?.toInt())) {
|
|
|
+ LogUtils.eTag("dasjhdkjagfkask", "行情推送" + goodsId)
|
|
|
+ val goodsInfo =
|
|
|
+ DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0)
|
|
|
+ val quote =
|
|
|
+ GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find { goodsInfo?.outgoodscode == it.outgoodscode }?.quoteDayData
|
|
|
+ if (quote != null) {
|
|
|
viewModel.quoteDayData.postValue(quote)
|
|
|
}
|
|
|
}
|
|
|
@@ -109,14 +122,22 @@ class PlatinumBuyOrSellUI(
|
|
|
val root = _FrameLayout(activity).apply {
|
|
|
|
|
|
verticalLayout {
|
|
|
- activity.createLoadingDialog(hintStr = "请求中...").bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
- initData(goodsId = goodsId,outGoodsCode = outGoodsCode,isShowLoading = false)
|
|
|
+ activity.createLoadingDialog(hintStr = "请求中...")
|
|
|
+ .bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+ initData(goodsId = goodsId, outGoodsCode = outGoodsCode, isShowLoading = false)
|
|
|
background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
linearLayout {
|
|
|
background = resources.getDrawable(R.color.white)
|
|
|
onThrottleFirstClick {
|
|
|
- activity.creatGoodsInfoBottomSheetDialog("请选择商品",viewModel.getGoodsInfoList()){
|
|
|
- initData(goodsId = this.goodsid.toString(),outGoodsCode = this.outgoodscode,isShowLoading = false)
|
|
|
+ activity.creatGoodsInfoBottomSheetDialog(
|
|
|
+ "请选择商品",
|
|
|
+ viewModel.getGoodsInfoList()
|
|
|
+ ) {
|
|
|
+ initData(
|
|
|
+ goodsId = this.goodsid.toString(),
|
|
|
+ outGoodsCode = this.outgoodscode,
|
|
|
+ isShowLoading = false
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
@@ -129,7 +150,7 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
|
|
|
textView {
|
|
|
- viewModel.goodsInfoData.bindOptional(context){
|
|
|
+ viewModel.goodsInfoData.bindOptional(context) {
|
|
|
text = it?.goodsname?.isBlankString()
|
|
|
}
|
|
|
textColorInt = R.color.rma_black_33
|
|
|
@@ -168,7 +189,7 @@ class PlatinumBuyOrSellUI(
|
|
|
|
|
|
}
|
|
|
//拿到商品信息后对输入框进行初始化
|
|
|
- viewModel.goodsInfoData.bindOptional(context) {data ->
|
|
|
+ viewModel.goodsInfoData.bindOptional(context) { data ->
|
|
|
// val goodsExData = GlobalDataCollection.instance?.goodsExInfoDataArrayList?.find { it.goodsid == data?.goodsid.toString()}
|
|
|
// if (goodsExData?.goodsid?.isNotEmpty() == true){
|
|
|
//
|
|
|
@@ -188,10 +209,22 @@ class PlatinumBuyOrSellUI(
|
|
|
|
|
|
//行情变化后根据不同的价格类型分别对赋值
|
|
|
viewModel.quoteDayData.bindOptional(context) {
|
|
|
- if (type == "1"){
|
|
|
- setText(NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.ask.toString()),2))
|
|
|
- }else{
|
|
|
- setText(NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.bid.toString()),2))
|
|
|
+ if (trade_price_edittext.text.toString().isNullOrEmpty()) {
|
|
|
+ if (type == "1") {
|
|
|
+ setText(
|
|
|
+ NumberUtils.roundNum(
|
|
|
+ NumberUtils.doubleDistortion(it?.ask.toString()),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ setText(
|
|
|
+ NumberUtils.roundNum(
|
|
|
+ NumberUtils.doubleDistortion(it?.bid.toString()),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}.lparams(matchParent, autoSize(88)) {
|
|
|
@@ -205,15 +238,17 @@ class PlatinumBuyOrSellUI(
|
|
|
linearLayout {
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
onThrottleFirstClick {
|
|
|
- val selectDataList = arrayListOf(SelectData(id = "1",value = "数量"),
|
|
|
- SelectData(id = "2",value = "金额"))
|
|
|
+ val selectDataList = arrayListOf(
|
|
|
+ SelectData(id = "1", value = "数量"),
|
|
|
+ SelectData(id = "2", value = "金额")
|
|
|
+ )
|
|
|
activity.creatBottomSheetDialog("请选择方式", selectDataList) {
|
|
|
selectPayType.postValue(this)
|
|
|
viewModel.goodsInfoData.postValue(viewModel.goodsInfoData.value)
|
|
|
}
|
|
|
}
|
|
|
textView {
|
|
|
- selectPayType.bindOptional(context){
|
|
|
+ selectPayType.bindOptional(context) {
|
|
|
text = it?.value
|
|
|
}
|
|
|
textSizeAuto = 36
|
|
|
@@ -236,16 +271,19 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
|
|
|
//拿到商品信息后对输入框进行初始化
|
|
|
- viewModel.goodsInfoData.bindOptional(context) {data ->
|
|
|
- val goodsExData = GlobalDataCollection.instance?.goodsExInfoDataArrayList?.find { it.goodsid == data?.goodsid.toString()}
|
|
|
- if (goodsExData?.goodsid?.isNotEmpty() == true){
|
|
|
- if (selectPayType.value?.id == "1"){//按数量
|
|
|
+ viewModel.goodsInfoData.bindOptional(context) { data ->
|
|
|
+ val goodsExData =
|
|
|
+ GlobalDataCollection.instance?.goodsExInfoDataArrayList?.find { it.goodsid == data?.goodsid.toString() }
|
|
|
+ if (goodsExData?.goodsid?.isNotEmpty() == true) {
|
|
|
+ if (selectPayType.value?.id == "1") {//按数量
|
|
|
setMin(goodsExData.regularlybuyminqty?.toDouble() ?: 0.0)
|
|
|
setStep(goodsExData.regularlybuyminqty?.toDouble() ?: 0.01)
|
|
|
setText(goodsExData.regularlybuyminqty)
|
|
|
- }else{//按金额
|
|
|
+ } else {//按金额
|
|
|
setMin(goodsExData.regularlybuyminamount?.toDouble() ?: 0.0)
|
|
|
- setStep(goodsExData.regularlybuyminamount?.toDouble() ?: 0.01)
|
|
|
+ setStep(
|
|
|
+ goodsExData.regularlybuyminamount?.toDouble() ?: 0.01
|
|
|
+ )
|
|
|
setText(goodsExData.regularlybuyminamount)
|
|
|
}
|
|
|
}
|
|
|
@@ -279,8 +317,11 @@ class PlatinumBuyOrSellUI(
|
|
|
|
|
|
textView {
|
|
|
sell_price = this
|
|
|
- viewModel.quoteDayData.bindOptional(context){
|
|
|
- text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.ask.toString()),2)//卖一
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(
|
|
|
+ NumberUtils.doubleDistortion(it?.ask.toString()),
|
|
|
+ 2
|
|
|
+ )//卖一
|
|
|
}
|
|
|
textSizeAuto = 41
|
|
|
textColorInt = R.color.rma_red_color
|
|
|
@@ -303,8 +344,11 @@ class PlatinumBuyOrSellUI(
|
|
|
|
|
|
textView {
|
|
|
buy_price = this
|
|
|
- viewModel.quoteDayData.bindOptional(context){
|
|
|
- text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.bid.toString()),2)//买一
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(
|
|
|
+ NumberUtils.doubleDistortion(it?.bid.toString()),
|
|
|
+ 2
|
|
|
+ )//买一
|
|
|
}
|
|
|
textSizeAuto = 41
|
|
|
textColorInt = R.color.rma_red_color
|
|
|
@@ -329,7 +373,12 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
textView {
|
|
|
onThrottleFirstClick {
|
|
|
- creatOrderDetailsDialog(type = "1",orderPrice = trade_price_edittext.text.toString(),goodsInfo = viewModel.goodsInfoData.value ?: GoodsInfo(),selectPayType = selectPayType.value?.id ?: "1")
|
|
|
+ creatOrderDetailsDialog(
|
|
|
+ type = "1",
|
|
|
+ orderPrice = trade_price_edittext.text.toString(),
|
|
|
+ goodsInfo = viewModel.goodsInfoData.value ?: GoodsInfo(),
|
|
|
+ selectPayType = selectPayType.value?.id ?: "1"
|
|
|
+ )
|
|
|
}
|
|
|
gravity = Gravity.CENTER
|
|
|
text = "买入"
|
|
|
@@ -342,14 +391,15 @@ class PlatinumBuyOrSellUI(
|
|
|
}
|
|
|
|
|
|
verticalLayout {
|
|
|
- viewModel.goodsExData.bindOptional(context){
|
|
|
- if (it?.canfinance == "0"){
|
|
|
+ viewModel.goodsExData.bindOptional(context) {
|
|
|
+ if (it?.canfinance == "0") {
|
|
|
visibility = View.GONE
|
|
|
- }else if(it?.canfinance == "1"){
|
|
|
- val userinfo = GlobalDataCollection.instance?.loginQueryData?.userInfo?.userinfotype
|
|
|
- if (userinfo == 2){
|
|
|
+ } else if (it?.canfinance == "1") {
|
|
|
+ val userinfo =
|
|
|
+ GlobalDataCollection.instance?.loginQueryData?.userInfo?.userinfotype
|
|
|
+ if (userinfo == 2) {
|
|
|
visibility = View.VISIBLE
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
visibility = View.GONE
|
|
|
}
|
|
|
}
|
|
|
@@ -377,15 +427,15 @@ class PlatinumBuyOrSellUI(
|
|
|
textView {
|
|
|
onThrottleFirstClick {
|
|
|
val intent = Intent()
|
|
|
- intent.putExtra("goodsId",goodsId)
|
|
|
- intent.putExtra("outGoodsCode",outGoodsCode)
|
|
|
- intent.setClass(context,AddCastSurelyActivity::class.java)
|
|
|
+ intent.putExtra("goodsId", goodsId)
|
|
|
+ intent.putExtra("outGoodsCode", outGoodsCode)
|
|
|
+ intent.setClass(context, AddCastSurelyActivity::class.java)
|
|
|
ActivityUtils.startActivity(intent)
|
|
|
}
|
|
|
- viewModel.goodsExData.bindOptional(context){
|
|
|
- if (it?.canregularlybuy == "0"){
|
|
|
+ viewModel.goodsExData.bindOptional(context) {
|
|
|
+ if (it?.canregularlybuy == "0") {
|
|
|
visibility = View.GONE
|
|
|
- }else if(it?.canregularlybuy == "1"){
|
|
|
+ } else if (it?.canregularlybuy == "1") {
|
|
|
visibility = View.VISIBLE
|
|
|
}
|
|
|
}
|
|
|
@@ -444,11 +494,11 @@ class PlatinumBuyOrSellUI(
|
|
|
text = "持有"
|
|
|
textSizeAuto = 30
|
|
|
textColorInt = R.color.rma_hint_title_text_color
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
topMargin = autoSize(10)
|
|
|
}
|
|
|
textView {
|
|
|
- text ="可用"
|
|
|
+ text = "可用"
|
|
|
textSizeAuto = 30
|
|
|
textColorInt = R.color.rma_hint_title_text_color
|
|
|
}.lparams(wrapContent, wrapContent)
|
|
|
@@ -461,15 +511,15 @@ class PlatinumBuyOrSellUI(
|
|
|
text = "成本"
|
|
|
textSizeAuto = 30
|
|
|
textColorInt = R.color.rma_hint_title_text_color
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
topMargin = autoSize(10)
|
|
|
marginEnd = autoSize(30)
|
|
|
}
|
|
|
textView {
|
|
|
- text ="现价"
|
|
|
+ text = "现价"
|
|
|
textSizeAuto = 30
|
|
|
textColorInt = R.color.rma_hint_title_text_color
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginEnd = autoSize(30)
|
|
|
}
|
|
|
}.lparams(0, autoSize(100), 1f)
|
|
|
@@ -526,7 +576,12 @@ class PlatinumBuyOrSellUI(
|
|
|
* selectPayType 1 按数量 2 按金额
|
|
|
*/
|
|
|
|
|
|
- fun creatOrderDetailsDialog(type: String, orderPrice: String, goodsInfo : GoodsInfo, selectPayType : String) {
|
|
|
+ fun creatOrderDetailsDialog(
|
|
|
+ type: String,
|
|
|
+ orderPrice: String,
|
|
|
+ goodsInfo: GoodsInfo,
|
|
|
+ selectPayType: String
|
|
|
+ ) {
|
|
|
activity.createCustomDialog(cancelable = false) { dialog ->
|
|
|
backgroundColor = Color.parseColor("#5f000000")
|
|
|
|
|
|
@@ -629,9 +684,9 @@ class PlatinumBuyOrSellUI(
|
|
|
linearLayout {
|
|
|
emptyView()
|
|
|
textView {
|
|
|
- if (selectPayType == "1"){
|
|
|
+ if (selectPayType == "1") {
|
|
|
text = "数量:"
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
text = "金额:"
|
|
|
}
|
|
|
textColorInt = R.color.rma_black_33
|
|
|
@@ -666,12 +721,19 @@ class PlatinumBuyOrSellUI(
|
|
|
gravity = Gravity.CENTER
|
|
|
onThrottleFirstClick {
|
|
|
var orderQtyOrAmount = 0.0
|
|
|
- if (selectPayType == "1"){//数量
|
|
|
- orderQtyOrAmount = trade_number_or_amount.text.toString().toDouble().times(Math.pow(10.0,goodsInfo.decimalplace.toDouble()))
|
|
|
- }else{
|
|
|
+ if (selectPayType == "1") {//数量
|
|
|
+ orderQtyOrAmount = trade_number_or_amount.text.toString().toDouble()
|
|
|
+ .times(Math.pow(10.0, goodsInfo.qtydecimalplace.toDouble()))
|
|
|
+ } else {
|
|
|
orderQtyOrAmount = trade_number_or_amount.text.toString().toDouble()
|
|
|
}
|
|
|
- viewModel.commit(goodsInfo = goodsInfo,type = type,orderPrice = orderPrice,orderQtyOrAmount = orderQtyOrAmount.toString(),selectPayType = selectPayType){
|
|
|
+ viewModel.commit(
|
|
|
+ goodsInfo = goodsInfo,
|
|
|
+ type = type,
|
|
|
+ orderPrice = orderPrice,
|
|
|
+ orderQtyOrAmount = orderQtyOrAmount.toString(),
|
|
|
+ selectPayType = selectPayType
|
|
|
+ ) {
|
|
|
viewModel.loadingDialogStatus.postValue(TaskUiModel.success(msg = "下单成功"))
|
|
|
}
|
|
|
// commitDealData(
|