Commit 2c1f9815 by Wyh

7.02

營業報表增加餐盒費送貨費
取消訂單時自動取消物流
優化心跳問題
parent 1955d118
...@@ -44,9 +44,7 @@ public abstract class DialogUtils { ...@@ -44,9 +44,7 @@ public abstract class DialogUtils {
} }
private void init(Context context) { private void init(Context context) {
if (dialog != null) { dismiss();
dialog.dismiss();
}
dialog = new Dialog(context); dialog = new Dialog(context);
viewHepler = getViewHepler(context); viewHepler = getViewHepler(context);
initLayout(viewHepler, dialog); initLayout(viewHepler, dialog);
...@@ -155,6 +153,10 @@ public abstract class DialogUtils { ...@@ -155,6 +153,10 @@ public abstract class DialogUtils {
public DialogUtils dismiss() { public DialogUtils dismiss() {
if (dialog != null) if (dialog != null)
dialog.dismiss(); dialog.dismiss();
if (viewHepler != null) {
viewHepler.clearAll();
}
dialog = null;
return this; return this;
} }
...@@ -166,7 +168,7 @@ public abstract class DialogUtils { ...@@ -166,7 +168,7 @@ public abstract class DialogUtils {
} }
public DialogUtils show() { public DialogUtils show() {
dismiss(); dialog.dismiss();
dialog.show(); dialog.show();
return this; return this;
} }
...@@ -218,6 +220,15 @@ public abstract class DialogUtils { ...@@ -218,6 +220,15 @@ public abstract class DialogUtils {
mConvertView = view; mConvertView = view;
} }
public void clearAll(){
context = null;
if(mViews != null) {
mViews.clear();
}
mConvertView = null;
viewHepler = null;
}
public static ViewHepler get(Context context, int layoutId) { public static ViewHepler get(Context context, int layoutId) {
viewHepler = new ViewHepler(context, layoutId); viewHepler = new ViewHepler(context, layoutId);
return viewHepler; return viewHepler;
......
...@@ -56,6 +56,10 @@ public class BusinessDetailsBean { ...@@ -56,6 +56,10 @@ public class BusinessDetailsBean {
* private double totalMeals; * private double totalMeals;
* //外賣總數 * //外賣總數
* private double takeawayTotal; * private double takeawayTotal;
* 餐盒費
* totalLunchbox
* 送貨費
* deliveryCharge
*/ */
private double prices; private double prices;
private double scamount; private double scamount;
...@@ -66,6 +70,8 @@ public class BusinessDetailsBean { ...@@ -66,6 +70,8 @@ public class BusinessDetailsBean {
private double totamount; private double totamount;
private double totalMeals; private double totalMeals;
private double takeawayTotal; private double takeawayTotal;
private double totalLunchbox;
private double deliveryCharge;
private int num;//賬單數 private int num;//賬單數
private int person;//人數 private int person;//人數
...@@ -141,6 +147,22 @@ public class BusinessDetailsBean { ...@@ -141,6 +147,22 @@ public class BusinessDetailsBean {
this.takeawayTotal = takeawayTotal; this.takeawayTotal = takeawayTotal;
} }
public double getTotalLunchbox() {
return totalLunchbox;
}
public void setTotalLunchbox(double totalLunchbox) {
this.totalLunchbox = totalLunchbox;
}
public double getDeliveryCharge() {
return deliveryCharge;
}
public void setDeliveryCharge(double deliveryCharge) {
this.deliveryCharge = deliveryCharge;
}
public int getNum() { public int getNum() {
return num; return num;
} }
......
...@@ -150,6 +150,9 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac ...@@ -150,6 +150,9 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac
averageConsumption = MoneyUtil.divide(dataBean.getPrices(), dataBean.getPerson()); averageConsumption = MoneyUtil.divide(dataBean.getPrices(), dataBean.getPerson());
} }
businessBeans.add(new BusinessBean(itemNames[12], String.valueOf(averageConsumption)));//平均每人 businessBeans.add(new BusinessBean(itemNames[12], String.valueOf(averageConsumption)));//平均每人
businessBeans.add(new BusinessBean(itemNames[13], String.valueOf(dataBean.getDeliveryCharge())));
businessBeans.add(new BusinessBean(itemNames[14], String.valueOf(dataBean.getTotalLunchbox())));
} else { } else {
//為空,全部顯示0 //為空,全部顯示0
for (String itemName : itemNames) { for (String itemName : itemNames) {
......
...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils; ...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.main.BuildConfig; import com.gingersoft.gsa.cloud.main.BuildConfig;
import com.gingersoft.gsa.cloud.main.R; import com.gingersoft.gsa.cloud.main.R;
...@@ -367,6 +368,8 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -367,6 +368,8 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
new ChooseRestaurantDialog.BottomListSheetBuilder(this) new ChooseRestaurantDialog.BottomListSheetBuilder(this)
.addBrandItems(brandsBeans) .addBrandItems(brandsBeans)
.setOnItemClickListener((dialog, item, position) -> { .setOnItemClickListener((dialog, item, position) -> {
//切換餐廳,發送關閉接單的廣播,並清除心跳
sendBroadcast(new Intent(AppConstans.CLEAR_ORDER_RECEIVING_HEART));
LoginBean.DataBean.UserBean.BrandsBean brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brandsBeans, item.getId()); LoginBean.DataBean.UserBean.BrandsBean brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brandsBeans, item.getId());
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.gingersoft.gsa.cloud.ui.view.MyScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/theme_background_color" android:background="@color/theme_background_color"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
...@@ -92,6 +93,8 @@ ...@@ -92,6 +93,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_215" android:layout_height="@dimen/dp_215"
android:layout_gravity="center" android:layout_gravity="center"
android:focusableInTouchMode="true"
android:focusable="true"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:visibility="visible" /> android:visibility="visible" />
</LinearLayout> </LinearLayout>
...@@ -154,4 +157,4 @@ ...@@ -154,4 +157,4 @@
</LinearLayout> </LinearLayout>
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
</LinearLayout> </LinearLayout>
</com.gingersoft.gsa.cloud.ui.view.MyScrollView> </androidx.core.widget.NestedScrollView>
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
android:id="@+id/tv_business_info_amount" android:id="@+id/tv_business_info_amount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_20" android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_5"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/theme_color" android:textColor="@color/theme_color"
android:textSize="@dimen/sp_17" /> android:textSize="@dimen/sp_17" />
...@@ -24,7 +26,9 @@ ...@@ -24,7 +26,9 @@
android:id="@+id/tv_business_info_name" android:id="@+id/tv_business_info_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20"
android:layout_weight="1" android:layout_weight="1"
android:singleLine="true" android:singleLine="true"
......
...@@ -706,9 +706,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -706,9 +706,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/** /**
* 取消訂單 * 取消訂單
*/ */
fun cancelOrder(context: Context, orderId: String, reasonId: String, reasonDesc: String, listener: (Boolean) -> Unit) { fun cancelOrder(memberId: String, memberName:String, orderId: String, reasonId: String, reasonDesc: String, listener: (Boolean) -> Unit) {
launch({ launch({
repository.updateOrderStates(GsaCloudApplication.getMemberId(context).toString(), orderId, "6", GsaCloudApplication.getMemberName(context), reasonId, reasonDesc).apply { repository.updateOrderStates(memberId, orderId, "6", memberName, reasonId, reasonDesc).apply {
listener.invoke(code == "1") listener.invoke(code == "1")
} }
}, { }, {
......
package com.gingersoft.gsa.other_order_mode.service package com.gingersoft.gsa.other_order_mode.service
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.* import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
...@@ -14,7 +17,6 @@ import android.os.Binder ...@@ -14,7 +17,6 @@ import android.os.Binder
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import android.view.LayoutInflater
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
...@@ -27,6 +29,7 @@ import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator ...@@ -27,6 +29,7 @@ import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity
import com.gingersoft.gsa.other_order_mode.util.RxTimerUtil import com.gingersoft.gsa.other_order_mode.util.RxTimerUtil
import com.google.gson.Gson import com.google.gson.Gson
import io.reactivex.schedulers.Schedulers
import okhttp3.* import okhttp3.*
import okio.ByteString import okio.ByteString
import org.json.JSONObject import org.json.JSONObject
...@@ -48,6 +51,11 @@ class GetInfoUpdateService : Service() { ...@@ -48,6 +51,11 @@ class GetInfoUpdateService : Service() {
var postCallBack: PostCallBack? = null var postCallBack: PostCallBack? = null
val restaurantId by lazy {
GsaCloudApplication.getRestaurantId(this)
}
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {
return MyBind() return MyBind()
} }
...@@ -111,10 +119,6 @@ class GetInfoUpdateService : Service() { ...@@ -111,10 +119,6 @@ class GetInfoUpdateService : Service() {
} }
inner class MyBind : Binder() { inner class MyBind : Binder() {
fun getService(): GetInfoUpdateService {
return this@GetInfoUpdateService
}
fun setOnPostCallBack(postCallBack: PostCallBack?) { fun setOnPostCallBack(postCallBack: PostCallBack?) {
this@GetInfoUpdateService.postCallBack = postCallBack this@GetInfoUpdateService.postCallBack = postCallBack
} }
...@@ -153,7 +157,7 @@ class GetInfoUpdateService : Service() { ...@@ -153,7 +157,7 @@ class GetInfoUpdateService : Service() {
super.onOpen(webSocket, response) super.onOpen(webSocket, response)
if (!this@GetInfoUpdateService.isDestroy) { if (!this@GetInfoUpdateService.isDestroy) {
mWebSocket = webSocket mWebSocket = webSocket
val token = "weixin_" + GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService) + "_" + getRandomString(24) val token = "weixin_" + restaurantId + "_" + getRandomString(24)
Log.e(TAG, "token:$token") Log.e(TAG, "token:$token")
webSocket.send(Gson().toJson(MsgBean(1, token))) webSocket.send(Gson().toJson(MsgBean(1, token)))
} }
...@@ -334,9 +338,10 @@ class GetInfoUpdateService : Service() { ...@@ -334,9 +338,10 @@ class GetInfoUpdateService : Service() {
private fun clearHeart() { private fun clearHeart() {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService).toString() + "") .add("restaurantId", restaurantId.toString())
.build() .build()
OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/restaurant/clearHeartbeat", requestBody)//清除心跳 OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/restaurant/clearHeartbeat", requestBody)
.subscribeOn(Schedulers.io()).subscribe()
} }
inner class ClearHeartBroadcastReceiver : BroadcastReceiver() { inner class ClearHeartBroadcastReceiver : BroadcastReceiver() {
......
...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter ...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.showWaringDialog
import com.qmuiteam.qmui.widget.QMUITopBar import com.qmuiteam.qmui.widget.QMUITopBar
import kotlinx.android.synthetic.main.activity_order_details.* import kotlinx.android.synthetic.main.activity_order_details.*
...@@ -107,10 +108,10 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -107,10 +108,10 @@ class OrderDetailsActivity : BaseActivity() {
tv_order_state.setTextColor(resources.getColor(R.color.order_state1_color)) tv_order_state.setTextColor(resources.getColor(R.color.order_state1_color))
} }
orderStatusText = "製作中" orderStatusText = "製作中"
if (orderDetails.isDelete != 0) { // if (orderDetails.isDelete != 0) {
//不是第三方物流才顯示取消訂單 //不是第三方物流才顯示取消訂單
btnList.add(BtnBuilder().getCancelBtn()) btnList.add(BtnBuilder().getCancelBtn())
} // }
} }
3 -> {//外賣是送貨中,自取是待取餐 3 -> {//外賣是送貨中,自取是待取餐
btnList.add(BtnBuilder().getPrintBtn()) btnList.add(BtnBuilder().getPrintBtn())
...@@ -262,11 +263,11 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -262,11 +263,11 @@ class OrderDetailsActivity : BaseActivity() {
//如果有配置取消原因 //如果有配置取消原因
//彈出彈窗讓用戶選擇取消原因 //彈出彈窗讓用戶選擇取消原因
selectorCancelReason(this@OrderDetailsActivity, cancelReson, "選擇取消原因") { selectorCancelReason(this@OrderDetailsActivity, cancelReson, "選擇取消原因") {
isSureCancelOrder(orderDetails.ID.toString(), cancelReson.data[it].id.toString(), cancelReson.data[it].content) isSureCancelOrder(orderDetails, cancelReson.data[it].id.toString(), cancelReson.data[it].content)
} }
} else { } else {
//後台沒有配置取消原因,彈出彈窗詢問是否取消 //後台沒有配置取消原因,彈出彈窗詢問是否取消
isSureCancelOrder(orderDetails.ID.toString(), "", "") isSureCancelOrder(orderDetails, "", "")
} }
} }
} }
...@@ -274,25 +275,38 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -274,25 +275,38 @@ class OrderDetailsActivity : BaseActivity() {
/** /**
* 是否確認取消訂單 * 是否確認取消訂單
*/ */
private fun PageViewModel.isSureCancelOrder(orderId: String, reasonId: String, reasonDesc: String) { private fun PageViewModel.isSureCancelOrder(orderDetails: OrderDetails.DataBean, reasonId: String, reasonDesc: String) {
AppDialog().showWaringDialog(this@OrderDetailsActivity, "是否確認取消訂單?") { v, dialog -> showWaringDialog("是否確認取消訂單?", { dialog ->
when (v.id) { dialog.dismiss()
R.id.tv_dialog_confirm -> { showLoading()
dialog.dismiss() if (orderDetails.isDelete == 0) {
showLoading() //是第三方物流單,先取消物流,再取消訂單
cancelOrder(this@OrderDetailsActivity, orderId, reasonId, reasonDesc) { cancelLogistics(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), orderId, reasonId, reasonDesc) {
cancelOrder(GsaCloudApplication.getMemberId(this@OrderDetailsActivity).toString(), GsaCloudApplication.getMemberName(this@OrderDetailsActivity), orderId, reasonId, reasonDesc) {
cancelDialogForLoading() cancelDialogForLoading()
ToastUtils.show(this@OrderDetailsActivity, if (it) { if (it) {
"取消訂單成功" finish()
ToastUtils.show(this@OrderDetailsActivity, "取消訂單成功")
} else { } else {
"取消訂單失敗" ToastUtils.show(this@OrderDetailsActivity, "取消訂單失敗")
}) }
}
}
} else {
//取消訂單
cancelOrder(GsaCloudApplication.getMemberId(this@OrderDetailsActivity).toString(), GsaCloudApplication.getMemberName(this@OrderDetailsActivity), orderId, reasonId, reasonDesc) {
cancelDialogForLoading()
if (it) {
finish() finish()
ToastUtils.show(this@OrderDetailsActivity, "取消訂單成功")
} else {
ToastUtils.show(this@OrderDetailsActivity, "取消訂單失敗")
} }
} }
R.id.tv_dialog_cancel -> dialog.dismiss()
} }
} }, {
it.dismiss()
})
} }
/** /**
......
...@@ -288,25 +288,20 @@ class OtherOrderActivity : BaseActivity() { ...@@ -288,25 +288,20 @@ class OtherOrderActivity : BaseActivity() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
bind?.setOnPostCallBack(null)
unregisterReceiver(mReceiver) unregisterReceiver(mReceiver)
unbindService(serviceConnection) unbindService(serviceConnection)
} }
var bind: GetInfoUpdateService.MyBind? = null
private var serviceConnection = object : ServiceConnection { private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) { override fun onServiceConnected(name: ComponentName, service: IBinder) {
val bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind bind = service as GetInfoUpdateService.MyBind
bind.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack { bind?.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack {
override fun callBack(type: Int) { override fun callBack(type: Int) {
//-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知" //-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
Log.e("message", "消息類型$type")
if (type == 3 || type == 4 || type == 5 if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) { || type == 6 || type == 7) {
// if (type == 6 || type == 7) {
//
// } else {
// //播放提示音
// initSoundPool()
// }
pageViewModel.refreshState.postValue(selectPosition) pageViewModel.refreshState.postValue(selectPosition)
} }
} }
...@@ -314,7 +309,6 @@ class OtherOrderActivity : BaseActivity() { ...@@ -314,7 +309,6 @@ class OtherOrderActivity : BaseActivity() {
} }
override fun onServiceDisconnected(name: ComponentName) { override fun onServiceDisconnected(name: ComponentName) {
} }
} }
......
package com.gingersoft.gsa.other_order_mode.util package com.gingersoft.gsa.other_order_mode.util
import android.app.Activity
import android.app.Dialog
import android.view.View import android.view.View
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.other_order_mode.R
fun View.setState(state: Boolean) { fun View.setState(state: Boolean) {
visibility = if (state) { visibility = if (state) {
...@@ -10,3 +14,17 @@ fun View.setState(state: Boolean) { ...@@ -10,3 +14,17 @@ fun View.setState(state: Boolean) {
} }
} }
fun Activity.showWaringDialog(title: String, confirm: (Dialog) -> Unit, cancel: (Dialog) -> Unit) {
AppDialog().showWaringDialog(this, title) { view, dialog ->
when (view.id) {
R.id.tv_dialog_confirm -> {
confirm.invoke(dialog)
}
R.id.tv_dialog_cancel -> {
cancel.invoke(dialog)
}
}
}
}
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