Commit da93bfc3 by Wyh

04-06 修改打印邏輯前

parent 0fd819b0
...@@ -41,6 +41,7 @@ public class OtherOrderComponent implements IComponent { ...@@ -41,6 +41,7 @@ public class OtherOrderComponent implements IComponent {
break; break;
case "orderActivity": case "orderActivity":
CCUtil.navigateTo(cc, OtherOrderActivity.class); CCUtil.navigateTo(cc, OtherOrderActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
break; break;
default: default:
// cc.callAsync(new IComponentCallback() { // cc.callAsync(new IComponentCallback() {
......
...@@ -31,6 +31,16 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -31,6 +31,16 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
} }
suspend fun getOrderInfo(orderId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.build()
val data = network.getOrderInfo(requestBody)
data
}
companion object { companion object {
private lateinit var instance: WeatherRepository private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class OrderDetails {
/**
* success : true
* sysTime : 1585823531720
* data : [{"Order_ID":50349,"NUMBER":1,"MEMBER_NAME":"忆逝1","PRICE":88,"discount_amount":0,"PHONE":"15728241877","ORDER_NO":"26202811401145744","Lunchbox":0,"remark":"","pid":0,"PRODUCT_NAME":[{"odsId":"1650249","PRICE":"88.0","num":"1","pid":"0","PRODUCT_NAME":"脆炸粟米蟹肉餅"}],"odsId":1650249,"addressDetail":"香港長沙灣青山道479 - 479A號麗昌工廠大廈 704 室及 802 室(接待處於 704 室蘋果迷你倉 - 荔枝角 (麗昌分店)分店","DELIVERY_CHARGE":0,"order_from":7,"sender":"","SEND_TIME":"盡快送達 18:27","PAY_AMOUNT":88,"ID":50349,"CREATE_TIME":"2020-04-02 17:57:29.0","takeFoodCode":"0","RECEIVER":"張學友 先生","TOTAL_AMOUNT":"88.0"}]
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: List<DataBean>? = null
fun isSuccess(): Boolean {
return success
}
fun setSuccess(success: Boolean) {
this.success = success
}
fun getSysTime(): Long {
return sysTime
}
fun setSysTime(sysTime: Long) {
this.sysTime = sysTime
}
fun getData(): List<DataBean>? {
return data
}
fun setData(data: List<DataBean>) {
this.data = data
}
class DataBean {
/**
* Order_ID : 50349
* NUMBER : 1
* MEMBER_NAME : 忆逝1
* PRICE : 88.0
* discount_amount : 0.0
* PHONE : 15728241877
* ORDER_NO : 26202811401145744
* Lunchbox : 0.0
* remark :
* pid : 0
* PRODUCT_NAME : [{"odsId":"1650249","PRICE":"88.0","num":"1","pid":"0","PRODUCT_NAME":"脆炸粟米蟹肉餅"}]
* odsId : 1650249
* addressDetail : 香港長沙灣青山道479 - 479A號麗昌工廠大廈 704 室及 802 室(接待處於 704 室蘋果迷你倉 - 荔枝角 (麗昌分店)分店
* DELIVERY_CHARGE : 0.0
* order_from : 7
* sender :
* SEND_TIME : 盡快送達 18:27
* PAY_AMOUNT : 88.0
* ID : 50349
* CREATE_TIME : 2020-04-02 17:57:29.0
* takeFoodCode : 0
* RECEIVER : 張學友 先生
* TOTAL_AMOUNT : 88.0
*/
var Order_ID: Int = 0
var NUMBER: Int = 0
var MEMBER_NAME: String? = null
var PRICE: Double = 0.toDouble()
var discount_amount: Double = 0.toDouble()
var PHONE: String? = null
var ORDER_NO: String? = null
var Lunchbox: Double = 0.toDouble()
var remark: String? = null
var pid: Int = 0
var odsId: Int = 0
var addressDetail: String? = null
var DELIVERY_CHARGE: Double = 0.toDouble()
var order_from: Int = 0
var sender: String? = null
var SEND_TIME: String? = null
var PAY_AMOUNT: Double = 0.toDouble()
var ID: Int = 0
var CREATE_TIME: String? = null
var takeFoodCode: String? = null
var RECEIVER: String? = null
var TOTAL_AMOUNT: String? = null
var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null
class PRODUCTNAMEBean {
/**
* odsId : 1650249
* PRICE : 88.0
* num : 1
* pid : 0
* PRODUCT_NAME : 脆炸粟米蟹肉餅
*/
var odsId: String? = null
var price: String? = null
var num: String? = null
var pid: String? = null
var producT_NAME: String? = null
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.network package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
...@@ -20,6 +19,9 @@ class CoolWeatherNetwork { ...@@ -20,6 +19,9 @@ class CoolWeatherNetwork {
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await() suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await()
private suspend fun <T> Call<T>.await(): T { private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation -> return suspendCoroutine { continuation ->
enqueue(object : Callback<T> { enqueue(object : Callback<T> {
......
package com.gingersoft.gsa.other_order_mode.data.network.api package com.gingersoft.gsa.other_order_mode.data.network.api
import com.gingersoft.gsa.other_order_mode.data.model.bean.MessageBean import com.gingersoft.gsa.other_order_mode.data.model.bean.MessageBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
...@@ -14,4 +15,9 @@ interface WeatherService { ...@@ -14,4 +15,9 @@ interface WeatherService {
@POST("wx/updateRestOpenStatus") @POST("wx/updateRestOpenStatus")
fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean> fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean>
@POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
} }
\ No newline at end of file
...@@ -20,6 +20,12 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -20,6 +20,12 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
private var databeans: List<OrderList.DataBeanX.DataBean>? = null private var databeans: List<OrderList.DataBeanX.DataBean>? = null
private var listenter: ((item: OrderList.DataBeanX.DataBean) -> Unit)? = null
fun setOnItemClickListenter(listenter: (item: OrderList.DataBeanX.DataBean) -> Unit) {
this.listenter = listenter
}
fun setData(databeans: List<OrderList.DataBeanX.DataBean>) { fun setData(databeans: List<OrderList.DataBeanX.DataBean>) {
this.databeans = databeans this.databeans = databeans
notifyDataSetChanged() notifyDataSetChanged()
...@@ -100,6 +106,10 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -100,6 +106,10 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
} }
} }
holder.binding.payMethodBg = payMethodBg holder.binding.payMethodBg = payMethodBg
holder.itemView.setOnClickListener {
listenter?.invoke(data)
}
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
...@@ -110,7 +120,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -110,7 +120,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
} }
} }
fun getColor(color: Int): Int { private fun getColor(color: Int): Int {
return context.resources.getColor(color) return context.resources.getColor(color)
} }
......
...@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData ...@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
...@@ -90,6 +91,19 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -90,6 +91,19 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}) })
} }
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getOrderInfo(orderId: String, listener: (OrderDetails) -> Unit) {
launch({
repository.getOrderInfo(orderId).apply {
listener.invoke(this)
}
}, {
//出錯
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch { private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try { try {
......
package com.gingersoft.gsa.other_order_mode.ui.main package com.gingersoft.gsa.other_order_mode.ui.main
import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOrderInfoDialogBinding
import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.jess.arms.utils.ArmsUtils
import kotlinx.android.synthetic.main.fragment_other_order.* import kotlinx.android.synthetic.main.fragment_other_order.*
/** /**
...@@ -39,9 +44,25 @@ class PlaceholderFragment : Fragment() { ...@@ -39,9 +44,25 @@ class PlaceholderFragment : Fragment() {
} }
//初始化recyclerview //初始化recyclerview
rv_other_order.layoutManager = LinearLayoutManager(activity) rv_other_order.layoutManager = LinearLayoutManager(activity)
var adapter = OtherOrdersAdapter(activity!!) val adapter = OtherOrdersAdapter(activity!!)
rv_other_order.adapter = adapter
adapter.setOnItemClickListenter {
//點擊查詢食品詳情
pageViewModel.getOrderInfo(it.Id.toString()) { it1 ->
//顯示彈窗
object : DialogUtils(activity, R.layout.layout_order_info_dialog) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (it1.getData() != null && it1.getData()!!.isNotEmpty()) {
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogBinding = DataBindingUtil.bind(hepler.contentView)!!
layoutOrderInfoDialogBinding.data = it1.getData()!![0]
}
}
}.setHeight((ArmsUtils.getScreenHeidth(activity) * 0.6).toInt())
.createDialogView()
.show()
}
}
rv_other_order.adapter = adapter
while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) { while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
pageViewModel.mOrderList.add(MutableLiveData()) pageViewModel.mOrderList.add(MutableLiveData())
...@@ -63,6 +84,9 @@ class PlaceholderFragment : Fragment() { ...@@ -63,6 +84,9 @@ class PlaceholderFragment : Fragment() {
page++ page++
getOrderList(pageViewModel, true) getOrderList(pageViewModel, true)
} }
// rv_other_order
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/white" />
<corners android:radius="@dimen/dp_8" />
</shape>
\ No newline at end of file
...@@ -186,12 +186,14 @@ ...@@ -186,12 +186,14 @@
<TextView <TextView
android:id="@+id/tv_address" android:id="@+id/tv_address"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_5"
android:text="@{data.aDDRESS_DETAIL}" android:text="@{data.aDDRESS_DETAIL}"
android:textColor="@color/color_ccc" android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num" app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintRight_toLeftOf="@id/tv_order_amount"
app:layout_constraintTop_toTopOf="@id/tv_address_text" /> app:layout_constraintTop_toTopOf="@id/tv_address_text" />
<TextView <TextView
......
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">--> <!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;--> <!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!-- <item name="colorPrimary">@color/colorPrimary</item>--> <!-- <item name="colorPrimary">@color/colorPrimary</item>-->
<!-- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>--> <!-- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!-- <item name="colorAccent">@color/colorAccent</item>--> <!-- <item name="colorAccent">@color/colorAccent</item>-->
<!-- </style>--> <!-- </style>-->
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
...@@ -17,4 +17,18 @@ ...@@ -17,4 +17,18 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="otherOrderInfoDialogBoldTextStyle">
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item>
</style>
<style name="otherOrderInfoDialogTextStyle">
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">normal</item>
</style>
</resources> </resources>
...@@ -76,20 +76,9 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta ...@@ -76,20 +76,9 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
initDialog(); initDialog();
initIntent(); initIntent();
callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID); callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID);
// if (type == 3) { printOrder(this);
//廚房單,可能會有多個IP打印
//獲得ip打印列表,
//再將食品數據根據打印位置分組。
//打印一組之後,關閉連接,切換第二台打印機ip,如此循環
//打印完成之後,返回所有打印結果。
// } else {
printOrder(this);
// }
} }
private void initDialog() { private void initDialog() {
try { try {
View view = LayoutInflater.from(mContext).inflate(R.layout.ui_dialog_loading, null); View view = LayoutInflater.from(mContext).inflate(R.layout.ui_dialog_loading, null);
......
...@@ -305,6 +305,19 @@ public class MoneyUtil { ...@@ -305,6 +305,19 @@ public class MoneyUtil {
} }
/** /**
* 計算差
*
* @param v1
* @param v2
* @return
*/
// public static double sub(String v1, double v2) {
// BigDecimal b1 = new BigDecimal(Double.toString(v1));
// BigDecimal b2 = new BigDecimal(Double.toString(v2));
// return b1.subtract(b2).doubleValue();
// }
/**
* 計算除 保留兩位小數,四捨五入 * 計算除 保留兩位小數,四捨五入
* *
* @param v1 * @param v1
......
...@@ -79,8 +79,8 @@ ...@@ -79,8 +79,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:text="K1 廚房" android:text="K1 廚房"
app:layout_constraintLeft_toRightOf="@id/tv_order_time" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_order_time" /> app:layout_constraintTop_toBottomOf="@id/tv_order_time" />
<TextView <TextView
android:id="@+id/tv_people_text" android:id="@+id/tv_people_text"
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="人數:" android:text="人數:"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_time_text" /> app:layout_constraintTop_toBottomOf="@id/tv_kitchen_location" />
<TextView <TextView
android:id="@+id/tv_people" android:id="@+id/tv_people"
......
...@@ -52,6 +52,9 @@ android { ...@@ -52,6 +52,9 @@ android {
lintOptions { lintOptions {
abortOnError false abortOnError false
} }
dataBinding {
enabled = true
}
//修改生成的apk名字 //修改生成的apk名字
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { variant.outputs.all {
...@@ -78,6 +81,7 @@ dependencies { ...@@ -78,6 +81,7 @@ dependencies {
addComponent 'download-data' addComponent 'download-data'
addComponent 'table-mode' addComponent 'table-mode'
addComponent 'print-module' addComponent 'print-module'
addComponent 'other_order_mode'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment