Commit 1096728b by Wyh

1、凍鏈、外送、自取,使用多折扣問題

Signed-off-by: Wyh <1239658231>
parent 5b0327e5
......@@ -50,7 +50,7 @@ class OrderDetails {
var NUMBER: Int = 0
var MEMBER_NAME: String? = null
var PRICE: Double = 0.toDouble()
var discount_amount: Double = 0.toDouble()
// var discount_amount: Double = 0.toDouble()
var takeTime: String? = null
var PHONE: String? = null
var memberTypeId: Int = 0
......@@ -188,7 +188,7 @@ class OrderDetails {
}
}
data class CouponBean(val couponName: String, val discount_amount: Float) : Serializable
data class CouponBean(val id: Int, val couponName: String, val discount_amount: Double) : Serializable
data class PayMultiple(val payTypeId: String, val amount: Double, val payName: String, val points: Double) : Serializable
}
......
package com.gingersoft.gsa.cloud.common.core.print.bean.adapter;
import android.text.TextUtils;
import android.view.View;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.core.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintCleanMachineContent;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintCleanMachineContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintTakeawayCheckoutContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintTakeawayFormContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintFoodItem;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintPayTypeItem;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.core.settlement.SettlementReport;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.jess.arms.utils.ArmsUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -124,7 +116,13 @@ public class PrintContentAdapter implements AdaptationContent {
takeawayPrintContent.setTotalAmountText("總金額: ");
takeawayPrintContent.setTotalAmount(AppConstans.CARSH_STR + data.getTOTAL_AMOUNT());
takeawayPrintContent.setPayAmountText("支付金額: ");
takeawayPrintContent.setPayAmount(AppConstans.CARSH_STR + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
double disCount = 0.0;
if (data.getCouponList() != null) {
for (OrderDetails.DataBean.CouponBean couponBean : data.getCouponList()) {
disCount = MoneyUtil.sum(disCount, couponBean.getDiscount_amount());
}
}
takeawayPrintContent.setPayAmount(AppConstans.CARSH_STR + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), disCount));
takeawayPrintContent.setMemberName("會員名稱: " + data.getMEMBER_NAME());
// takeawayPrintContent.setMemberNumber(data.getm);
takeawayPrintContent.setMemberPhone("會員電話: " + data.getPHONE());
......
......@@ -46,10 +46,12 @@ public abstract class DialogUtils implements LifecycleObserver {
view = LayoutInflater.from(mContext).inflate(xmlLayout, null);
init(mContext);
}
public DialogUtils(Context mContext, View view) {
this.view = view;
init(mContext);
}
private void init(Context context) {
dialog = new Dialog(context);
viewHepler = getViewHepler(context);
......
......@@ -38,7 +38,6 @@ public class LoadingDialog {
View view = LayoutInflater.from(context).inflate(R.layout.ui_dialog_loading, null);
TextView loadingText = view.findViewById(R.id.tv_loading_dialog_text);
loadingText.setText(msg);
if (mLoadingDialog == null) {
mLoadingDialog = new Dialog(context, R.style.ui_loading_dialog);
}
......
......@@ -218,6 +218,8 @@ public class OkHttp3Utils {
});
}
/**
* 心跳接口報錯,推送給相關人員
* 版本,時間,RP_HD001,Gingersoft,GS1,26ErrorMsg:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
......
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="@color/color_ef" />
......@@ -409,7 +409,13 @@
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/dp_14</item>
</style>
<style name="AppEditTextStyle">
<item name="android:textColorHint">@color/color_c9</item>
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:gravity">center_vertical|right</item>
<item name="android:textColor">@color/color_3c</item>
<item name="android:background">@null</item>
</style>
<style name="otherOrder_delivery_setting_layout_style">
<item name="android:paddingRight">@dimen/dp_20</item>
</style>
......
......@@ -10,13 +10,13 @@ import com.gingersoft.coldchain_module.mvp.model.bean.ShipAnyOrdersNewBean;
import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
......@@ -70,6 +70,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
if (downloadDisposable != null) {
downloadDisposable.dispose();
downloadDisposable = null;
}
}
public void findOrderDetails(int orderId, int isRead) {
......@@ -275,10 +279,12 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
}
Disposable downloadDisposable;
public void download(int orderId, String url) {
try {
updatePrintPdfStatus(orderId);
Disposable download_success = Observable.create((ObservableOnSubscribe<File>) emitter -> {
downloadDisposable = Observable.create((ObservableOnSubscribe<File>) emitter -> {
OkHttpClient client = new OkHttpClient.Builder().build();
Request request = new Request.Builder()
.url(url)
......@@ -308,6 +314,9 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
fos.write(buf, 0, len);
sum += len;
int progress = (int) (sum * 1.0f / total * 100);
if (downloadDisposable == null || downloadDisposable.isDisposed()) {
return;
}
mRootView.showLoading("下載打印文檔中" + progress + "%");
LogUtil.e(TAG, "download progress : " + progress);
}
......@@ -319,14 +328,16 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
LogUtil.e(TAG, "download failed : " + e.getMessage());
} finally {
try {
if (is != null)
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (fos != null)
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
......@@ -443,7 +454,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
.build();
mModel.updatePrintPdfStatus(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> { })
.doOnSubscribe(disposable -> {
})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......
......@@ -7,6 +7,8 @@ import android.os.Bundle;
import android.print.PrintManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -96,8 +98,12 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
TextView mTvLunchboxCost;
@BindView(R2.id.tv_delivery_fee)
TextView mTvDeliveryFee;
@BindView(R2.id.tv_discount)
TextView mTvDiscount;
// @BindView(R2.id.tv_discount)
// TextView mTvDiscount;
@BindView(R2.id.layout_discount)
LinearLayout layoutDiscount;
@BindView(R2.id.tv_total_amount2)
TextView mTvTotalAmount2;
@BindView(R2.id.tv_pay_amount)
......@@ -244,9 +250,19 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
mTvTotalAmount.setText(amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(bean.getTOTAL_AMOUNT()), bean.getLunchbox()), bean.getDELIVERY_CHARGE()));
mTvLunchboxCost.setText(amountUnit + bean.getLunchbox());
mTvDeliveryFee.setText(amountUnit + bean.getDELIVERY_CHARGE());
mTvDiscount.setText(amountUnit + bean.getDiscount_amount());
mTvTotalAmount2.setText(amountUnit + MoneyUtil.sub(Double.parseDouble(bean.getTOTAL_AMOUNT()), bean.getDiscount_amount()));
mTvPayAmount.setText(amountUnit + MoneyUtil.sub(Double.parseDouble(bean.getTOTAL_AMOUNT()), bean.getDiscount_amount()));
double totalAmount = Double.parseDouble(bean.getTOTAL_AMOUNT());
if (bean.getCouponList() != null) {
for (OrderDetails.DataBean.CouponBean couponBean : bean.getCouponList()) {
View view = View.inflate(mContext, R.layout.item_discount, null);
((TextView) view.findViewById(R.id.tv_discount_text)).setText(couponBean.getCouponName() + ":");
((TextView) view.findViewById(R.id.tv_discount_amount)).setText("$" + couponBean.getDiscount_amount());
layoutDiscount.addView(view);
totalAmount = MoneyUtil.sub(totalAmount, couponBean.getDiscount_amount());
}
}
mTvTotalAmount2.setText(amountUnit + totalAmount);
mTvPayAmount.setText(amountUnit + totalAmount);
if (bean.getOrderPayType() == 2 && bean.getPayMultiple() != null) {
StringBuilder sb = new StringBuilder();
......
......@@ -171,8 +171,8 @@
android:id="@+id/tv_receive_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:text="收貨電話:"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="收貨電話:" />
<TextView
android:id="@+id/tv_receive_phone"
......@@ -195,8 +195,8 @@
android:id="@+id/tv_receive_time_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:text="收貨時間:"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="收貨時間:" />
<TextView
android:id="@+id/tv_receive_time"
......@@ -258,78 +258,78 @@
android:gravity="right" />
</RelativeLayout>
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_name_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="派送員名稱:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_name"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_man_name_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_phone_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="派送員電話:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_phone"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_man_phone_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_num_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="物流號:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_num"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_num_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_name_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="派送員名稱:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_name"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_man_name_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_phone_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="派送員電話:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_man_phone"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_man_phone_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_14"-->
<!-- android:paddingLeft="@dimen/dp_7"-->
<!-- android:paddingRight="@dimen/dp_14">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_num_text"-->
<!-- style="@style/otherOrderReceiving_title_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- tools:text="物流號:"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_delivery_num"-->
<!-- style="@style/otherOrderReceiving_information_textStyle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_toRightOf="@id/tv_delivery_num_text"-->
<!-- android:gravity="right" />-->
<!-- </RelativeLayout>-->
</LinearLayout>
......@@ -438,30 +438,13 @@
android:gravity="right" />
</RelativeLayout>
<RelativeLayout
<LinearLayout
android:id="@+id/layout_discount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣:" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_discount_text"
android:gravity="right" />
</RelativeLayout>
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft" />
<RelativeLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_10">
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="折扣名:" />
<TextView
android:id="@+id/tv_discount_amount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
tools:text="折扣金額" />
</LinearLayout>
\ No newline at end of file
......@@ -17,17 +17,18 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ethanhua.skeleton.Skeleton
import com.ethanhua.skeleton.ViewSkeletonScreen
import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants
import com.gingersoft.gsa.cloud.common.function.FunctionManager
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.common.ui.utils.AppDialog
import com.gingersoft.gsa.cloud.common.ui.utils.BtnBuilder
import com.gingersoft.gsa.cloud.common.ui.view.AddKeyBoard
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.MessageBean
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.ServiceChargeRecordBean
......@@ -51,7 +52,6 @@ import com.gingersoft.gsa.delivery_pick_mode.util.showWaringDialog
import com.jess.arms.mvp.IPresenter
import com.qmuiteam.qmui.widget.QMUITopBar
import kotlinx.android.synthetic.main.activity_order_details.*
import java.lang.StringBuilder
import java.util.*
class OrderDetailsActivity : BaseActivity<IPresenter>() {
......@@ -135,9 +135,18 @@ class OrderDetailsActivity : BaseActivity<IPresenter>() {
orderDetails.order_type = orderType
orderDetails.orderPayType = orderPayType
binding.data = orderDetails
binding.totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble()
binding.isSelf = orderDetails.order_type == 7
var totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble()
orderDetails.couponList?.let {
for (coupon in it) {
val view = View.inflate(mContext, R.layout.item_discount, null)
view.findViewById<TextView>(R.id.tv_discount_text).text = coupon.couponName + ":"
view.findViewById<TextView>(R.id.tv_discount_amount).text = "$" + coupon.discount_amount
layout_takeaway_discount.addView(view)
totalAmount = MoneyUtil.sub(totalAmount, coupon.discount_amount)
}
}
binding.totalAmount = totalAmount
val btnList = ArrayList<BtnBuilder.BtnBean>()
val orderStatusText: String
......
......@@ -7,12 +7,12 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager
import com.gingersoft.gsa.cloud.common.core.pay.PayMethod
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails.DataBean
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails.DataBean
import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.BillBean
import com.gingersoft.gsa.delivery_pick_mode.model.viewModel.PageViewModel
......@@ -57,7 +57,13 @@ class PayActivity : BaseActivity<IPresenter>() {
foodCount += bean.num!!.toInt()
}
}
other_pay_view.loadInfo(this, ArrayList<PayMethod>(), MoneyUtil.sub(orderDetails.TOTAL_AMOUNT!!.toDouble(), orderDetails.discount_amount), foodCount)
var totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble()
orderDetails.couponList?.let {
for (coupon in it){
totalAmount = MoneyUtil.sub(totalAmount, coupon.discount_amount)
}
}
other_pay_view.loadInfo(this, ArrayList<PayMethod>(), totalAmount, foodCount)
pageViewModel.getPayMethod(ResturantInfoManager.newInstance().getBrandId(), ResturantInfoManager.newInstance().getRestaurantId())
pageViewModel.payTypeBean.observe(this, Observer {
......@@ -106,10 +112,12 @@ class PayActivity : BaseActivity<IPresenter>() {
if (orderDetails.DELIVERY_CHARGE > 0) {
billBeans.add(BillBean("送貨費:", orderDetails.DELIVERY_CHARGE))
}
if (orderDetails.discount_amount > 0) {
billBeans.add(BillBean("折扣:", orderDetails.discount_amount, 1))
orderDetails.couponList?.let {
for (coupon in it){
billBeans.add(BillBean(coupon.couponName+":", coupon.discount_amount, 1))
}
}
billBeans.add(BillBean("支付金額:", MoneyUtil.sub(orderDetails.TOTAL_AMOUNT!!.toDouble(), orderDetails.discount_amount)))
billBeans.add(BillBean("支付金額:", totalAmount))
rv_order_pay_bill.layoutManager = LinearLayoutManager(this)
rv_order_pay_bill.adapter = PayBillAdapter(R.layout.item_pay_bill, billBeans)
}
......
......@@ -13,10 +13,10 @@ import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.BillBean
import com.gingersoft.gsa.delivery_pick_mode.databinding.LayoutOrderInfoDialogNewBinding
......@@ -34,8 +34,12 @@ object OtherOrderUtils {
val tvStatus = hepler.getView<TextView>(R.id.tv_order_state)
val orderData = data.data!![0]
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogNewBinding = DataBindingUtil.bind(hepler.contentView)!!
val totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
var totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
orderData.couponList?.let {
for(coupon in it){
totalAmount = MoneyUtil.sub(totalAmount, coupon.discount_amount)
}
}
layoutOrderInfoDialogBinding.data = orderData
layoutOrderInfoDialogBinding.isSelf = orderType == 7
layoutOrderInfoDialogBinding.totalAmount = totalAmount
......@@ -131,7 +135,7 @@ object OtherOrderUtils {
}
}
}
billBeans.add(BillBean("支付金額:", MoneyUtil.sub(totalAmount, orderData.discount_amount), 1))
billBeans.add(BillBean("支付金額:", totalAmount, 1))
orderData.payMultiple?.let {
for (payMultiple in it) {
......
......@@ -13,7 +13,6 @@
<variable
name="totalAmount"
type="Double" />
<variable
name="data"
type="com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails.DataBean" />
......@@ -531,32 +530,13 @@
android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}" />
</RelativeLayout>
<RelativeLayout
<LinearLayout
android:id="@+id/layout_takeaway_discount"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣:" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_discount_text"
android:gravity="right"
android:text="@{@string/minus_amount_unit + data.discount_amount}" />
</RelativeLayout>
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"/>
<RelativeLayout
android:layout_width="match_parent"
......@@ -580,7 +560,7 @@
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_total_amount_text2"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}" />
android:text="@{@string/amount_unit + totalAmount}" />
</RelativeLayout>
<RelativeLayout
......@@ -605,7 +585,7 @@
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_pay_amount_text"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}"
android:text="@{@string/amount_unit + totalAmount}"
android:textColor="#FF0000" />
</RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_10">
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="折扣名:" />
<TextView
android:id="@+id/tv_discount_amount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
tools:text="折扣金額" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.gingersoft.gsa.cloud.common.utils.time.TimeUtils" />
<import type="com.gingersoft.gsa.cloud.common.utils.MoneyUtil" />
<import type="android.view.View" />
<variable
name="total_amount"
type="Double" />
<variable
name="data"
type="com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails.DataBean" />
<!-- 是否自取-->
<variable
name="isSelf"
type="Boolean" />
<variable
name="btnContent"
type="String" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_dialog_bg"
android:padding="@dimen/dp_10">
<TextView
android:id="@+id/tv_order_name"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_16"
android:text="@{data.order_from==7?@string/h5_order:@string/ricepon_order}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:text="訂單號:"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintLeft_toRightOf="@id/tv_order_name"
app:layout_constraintRight_toLeftOf="@id/tv_order_num"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_order_num"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{data.oRDER_NO}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/line_info_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_order_num" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_order_info"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingBottom="@dimen/dp_10"
app:layout_constraintBottom_toTopOf="@id/btn_assign_shipping"
app:layout_constraintTop_toBottomOf="@id/line_info_top">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_order_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:barrierDirection="right"
app:constraint_referenced_ids="tv_create_time_text,tv_receiver_text,tv_receive_phone_text,tv_receive_time_text,tv_receive_address_text,tv_receive_address_text" />
<TextView
android:id="@+id/tv_create_time_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="下單時間:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_create_time"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
app:layout_constraintLeft_toRightOf="@id/tv_create_time_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_create_time_text" />
<TextView
android:id="@+id/tv_receiver_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:gravity="right"
android:text="收貨人:"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_create_time" />
<TextView
android:id="@+id/tv_receiver"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.rECEIVER}"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receiver_text" />
<TextView
android:id="@+id/tv_receive_phone_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receiver" />
<TextView
android:id="@+id/tv_receive_phone"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.pHONE}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_phone_text" />
<TextView
android:id="@+id/tv_receive_time_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receive_phone" />
<TextView
android:id="@+id/tv_receive_time"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{isSelf?data.takeTime:data.sEND_TIME}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_time_text" />
<TextView
android:id="@+id/tv_receive_address_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/meal_code:@string/receiving_address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receive_time" />
<TextView
android:id="@+id/tv_receive_address"
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{isSelf?data.takeFoodCode:data.addressDetail}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_address_text" />
<View
android:id="@+id/line_info_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_receive_address" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/line_info_bottom" />
<View
android:id="@+id/line_food_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/rv_food" />
<TextView
android:id="@+id/tv_total_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="合計"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_food_bottom" />
<TextView
android:id="@+id/tv_total"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.tOTAL_AMOUNT), data.lunchbox),data.dELIVERY_CHARGE)}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_text" />
<TextView
android:id="@+id/tv_lunchbox_cost_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="餐盒費"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total" />
<TextView
android:id="@+id/tv_lunchbox_cost"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + data.lunchbox}"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_lunchbox_cost_text" />
<TextView
android:id="@+id/tv_delivery_fee_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="送貨費費"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
<TextView
android:id="@+id/tv_delivery_fee"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_fee_text" />
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="折扣"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_fee" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + data.discount_amount}"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_discount_text" />
<TextView
android:id="@+id/tv_total_amount_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="總金額"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_discount" />
<TextView
android:id="@+id/tv_total_amount"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_pay_amount_text"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="支付金額"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_pay_amount"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:textColor="#FF0000"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_pay_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btn_assign_shipping"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:background="@drawable/shape_app_btn"
android:text="@{btnContent}"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -115,7 +115,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:text="@{@string/amount_unit + total_amount}"
android:textColor="#BE1C42"
android:textSize="@dimen/dp_24"
app:layout_constraintLeft_toLeftOf="parent"
......
......@@ -448,16 +448,18 @@ public class PrintInfoBean {
if (data.getDELIVERY_CHARGE() != 0) {
printInfoBeans.add(new PrintInfoBean(new String[]{getLeftRightText("送貨費啊啥的和發哈是打飛機:", "$" + data.getDELIVERY_CHARGE(), paperWidth)}, new Boolean[]{false}, new Double[]{1d}));
}
double totalAmount = Double.parseDouble(data.getTOTAL_AMOUNT());
if (data.getCouponList() != null && data.getCouponList().size() > 0) {
for (OrderDetails.DataBean.CouponBean coupon : data.getCouponList()) {
printInfoBeans.add(new PrintInfoBean(new String[]{getLeftRightText(coupon.getCouponName() + ":", "-$" + coupon.getDiscount_amount(), paperWidth)}, new Boolean[]{false}, new Double[]{1d}));
totalAmount = MoneyUtil.sub(totalAmount, coupon.getDiscount_amount());
}
}
printInfoBeans.add(new PrintInfoBean(new String[]{getLeftRightText("總金額啊啥的和發哈是打飛機:", "$" + data.getTOTAL_AMOUNT(), paperWidth / 2)}, new Boolean[]{true}, new Double[]{2d}));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1, paperWidth)}, new Double[]{1d}));
printInfoBeans.add(new PrintInfoBean(new String[]{"支付金額:", "$" + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())}, new Boolean[]{true}, new Double[]{2d}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"支付金額:", "$" + totalAmount}, new Boolean[]{true}, new Double[]{2d}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1, paperWidth)}, new Double[]{1d}));
......
......@@ -96,9 +96,11 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
if (data.getDELIVERY_CHARGE() != 0) {
billData.add(getBillBean("送貨費:", MONETARY_UNIT + data.getDELIVERY_CHARGE()));
}
double totalAmount = Double.parseDouble(data.getTOTAL_AMOUNT());
if (data.getCouponList() != null && data.getCouponList().size() > 0) {
for (OrderDetails.DataBean.CouponBean coupon : data.getCouponList()) {
billData.add(getBillBean(coupon.getCouponName() + ":", "-" + MONETARY_UNIT + coupon.getDiscount_amount()));
totalAmount = MoneyUtil.sub(totalAmount, coupon.getDiscount_amount());
}
}
layout.addView(getTakeawayBillInfoView(mContext, billData));
......@@ -107,7 +109,7 @@ public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
layout.addView(getTakeawayLargeAmount(mContext, "總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT()));
layout.addView(getLine(mContext));
//支付信息
addTakeawayPayViews(mContext, layout, data.getPayMultiple(), MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
addTakeawayPayViews(mContext, layout, data.getPayMultiple(), totalAmount);
//用戶信息
getTakeawayReceiver(mContext, data, layout);
//尾部
......
......@@ -227,9 +227,11 @@ public class PrintOtherOrderClosing extends PrinterRoot<PrintTakeawayCheckoutCon
if (data.getDELIVERY_CHARGE() != 0) {
billData.add(getBillBean("送貨費:", MONETARY_UNIT + data.getDELIVERY_CHARGE()));
}
double totalAmount = Double.parseDouble(data.getTOTAL_AMOUNT());
if (data.getCouponList() != null && data.getCouponList().size() > 0) {
for (OrderDetails.DataBean.CouponBean coupon : data.getCouponList()) {
billData.add(getBillBean(coupon.getCouponName() + ":", "-" + MONETARY_UNIT + coupon.getDiscount_amount()));
totalAmount = MoneyUtil.sub(totalAmount, coupon.getDiscount_amount());
}
}
layout.addView(getTakeawayBillInfoView(mContext, billData));
......@@ -237,17 +239,7 @@ public class PrintOtherOrderClosing extends PrinterRoot<PrintTakeawayCheckoutCon
//總金額34sp
layout.addView(getTakeawayLargeAmount(mContext, "總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT()));
layout.addView(getLine(mContext));
// if (data.getPayMultiple() != null && data.getPayMultiple().size() > 0) {
// for (OrderDetails.DataBean.PayMultiple payMultiple : data.getPayMultiple()) {
// if (!TextUtil.isEmptyOrNullOrUndefined(payMultiple.getPayName())) {
// layout.addView(getTakeawayLargeAmount(mContext, payMultiple.getPayName(), MONETARY_UNIT + payMultiple.getAmount()));
// }
// }
// layout.addView(getLine(mContext));
// } else {
// layout.addView(getTakeawayLargeAmount(mContext, "支付金額:", MONETARY_UNIT + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()) + ""));
// }
addTakeawayPayViews(mContext, layout, data.getPayMultiple(), MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
addTakeawayPayViews(mContext, layout, data.getPayMultiple(), totalAmount);
//會員信息
layout.addView(getTakeawayMemberIntegerView(mContext, data));
......
......@@ -25,30 +25,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener;
import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.joe.print.mvp.ui.adapter.BillAdapter;
import com.joe.print.mvp.ui.adapter.BillTypeAdapter;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.joe.print.mvp.model.bean.BillingBean;
import com.gingersoft.gsa.cloud.common.core.pay.PayMethod;
import com.joe.print.mvp.ui.adapter.FoodAdapter;
import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.common.core.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.common.core.order.order.DoshokuOrder;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.common.utils.AidlUtil;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.utils.StringUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.common.utils.view.QRCodeUtil;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.common.core.pay.PayMethod;
import com.gingersoft.gsa.cloud.common.core.print.PrintExecutor;
import com.gingersoft.gsa.cloud.common.core.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.common.core.print.PrinterWriter58mm;
......@@ -56,16 +40,28 @@ import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintTakeawayCheckoutContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.PrintTakeawayFormContent;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintFoodItem;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintPayTypeItem;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import com.gingersoft.gsa.cloud.common.utils.AidlUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.common.utils.view.QRCodeUtil;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.google.zxing.WriterException;
import com.hyweb.n5.lib.constant.PrinterConstant;
import com.hyweb.n5.lib.util.PrinterUtil;
import com.hyweb.n5.server.aidl.IOnPrintCallback;
import com.jess.arms.integration.AppManager;
import com.joe.print.R;
import com.joe.print.mvp.model.bean.BillingBean;
import com.joe.print.mvp.model.bean.HtmlLable;
import com.gingersoft.gsa.cloud.common.core.print.bean.base.PrintBillItem;
import com.joe.print.mvp.print.common.HtmlContract;
import com.joe.print.mvp.print.common.PrinterFinderCallback;
import com.joe.print.mvp.print.common.SendResultCode;
......@@ -74,7 +70,10 @@ import com.joe.print.mvp.print.usb.UsbPrint;
import com.joe.print.mvp.print.usb.UsbPrinter;
import com.joe.print.mvp.print.usb.UsbPrinterFinder;
import com.joe.print.mvp.print.utils.BBposPrint;
import com.joe.print.mvp.ui.adapter.BillAdapter;
import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.BillTypeAdapter;
import com.joe.print.mvp.ui.adapter.FoodAdapter;
import com.sunmi.peripheral.printer.InnerResultCallbcak;
import java.io.IOException;
......@@ -90,8 +89,6 @@ import lombok.Getter;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_COLUMN;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_DIV;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_H2;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_H3;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_P;
@Getter
......
package com.gingersoft.supply_chain.di.component;
import dagger.BindsInstance;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.supply_chain.di.module.ConfirmOrderModule;
import com.gingersoft.supply_chain.mvp.contract.ConfirmOrderContract;
import com.jess.arms.di.scope.FragmentScope;
import com.gingersoft.supply_chain.mvp.ui.fragment.ConfirmOrderFragment;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
@Component(modules = ConfirmOrderModule.class, dependencies = AppComponent.class)
public interface ConfirmOrderComponent {
void inject(ConfirmOrderFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
ConfirmOrderComponent.Builder view(ConfirmOrderContract.View view);
ConfirmOrderComponent.Builder appComponent(AppComponent appComponent);
ConfirmOrderComponent build();
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.di.module;
import com.jess.arms.di.scope.FragmentScope;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.supply_chain.mvp.contract.ConfirmOrderContract;
import com.gingersoft.supply_chain.mvp.model.ConfirmOrderModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class ConfirmOrderModule {
@Binds
abstract ConfirmOrderContract.Model bindConfirmOrderModel(ConfirmOrderModel model);
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/17
* Time: 11:36
* Use:
*/
@Data
public class ConfirmOrderBean {
private static class purchaseOrder{
}
private String supplierName;
private String sendAddress;
private String sendTime;
private String totalAmount;
private String freight;
private String payAmount;
private String remarks;
}
package com.gingersoft.supply_chain.mvp.contract;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface ConfirmOrderContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel{
}
}
package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.ConfirmOrderContract;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class ConfirmOrderModel extends BaseModel implements ConfirmOrderContract.Model{
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public ConfirmOrderModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.ConfirmOrderContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class ConfirmOrderPresenter extends BasePresenter<ConfirmOrderContract.Model, ConfirmOrderContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
private List<List<PurchaseFoodListVosBean>> supplierFoods;
@Inject
public ConfirmOrderPresenter(ConfirmOrderContract.Model model, ConfirmOrderContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void organizeShopCartData() {
Map<Integer, List<PurchaseFoodListVosBean>> listMap = new HashMap<>(4);
double totalPrice = 0;
for (PurchaseFoodListVosBean cartFood : SupplyShoppingCart.getInstance().getCartFoods()) {
//計算總價
if (cartFood.isChecked()) {
totalPrice = MoneyUtil.sum(totalPrice, MoneyUtil.priceCalculation(cartFood.getUnitPrice(), cartFood.getFoodCount()));
totalTypeNumber++;
}
List<PurchaseFoodListVosBean> foodListVosBeans = listMap.get(cartFood.getSupplierId());
if (foodListVosBeans == null) {
foodListVosBeans = new ArrayList<>();
foodListVosBeans.add(cartFood);
listMap.put(cartFood.getSupplierId(), foodListVosBeans);
} else {
foodListVosBeans.add(cartFood);
}
}
supplierFoods = new ArrayList<>();
supplierFoods.addAll(listMap.values());
mRootView.loadAdapter(supplierFoods);
}
}
......@@ -212,6 +212,11 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
* @param integerMap 存放食品id和數量的map
*/
public void getSelectFood(Map<Integer, PurchaseFoodListVosBean> integerMap) {
for (PurchaseFoodListVosBean purchaseFoodListVosBean : integerMap.values()) {
if (purchaseFoodListVosBean.getFoodCount() <= 0) {
integerMap.remove(purchaseFoodListVosBean);
}
}
//把購物車的食品取出來
List<PurchaseFoodListVosBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
//清空
......
package com.gingersoft.supply_chain.mvp.ui.adapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils
import com.gingersoft.supply_chain.R
import com.gingersoft.supply_chain.mvp.bean.ConfirmOrderBean
/**
* @author 宇航.
* User: admin
* Date: 2020/12/17
* Time: 11:35
* Use:
*/
class ConfirmOrderAdapter : BaseQuickAdapter<ConfirmOrderBean, BaseViewHolder>(R.layout.item_confirm_order) {
override fun convert(holder: BaseViewHolder, item: ConfirmOrderBean) {
holder.setText(R.id.tv_confirm_order_item_supplier_name, item.supplierName)
holder.setText(R.id.tv_confirm_order_item_supplier_address, item.sendAddress)
holder.setText(R.id.tv_confirm_order_item_send_time, TimeUtils.getNextDay(1))
holder.setText(R.id.tv_confirm_order_item_total_amount, item.totalAmount.toString())
holder.setText(R.id.tv_confirm_order_item_freight, item.freight)
holder.setText(R.id.tv_confirm_order_item_pay_amount, item.payAmount.toString())
holder.setText(R.id.ed_confirm_order_item_remark, item.remarks)
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ import static com.gingersoft.supply_chain.mvp.ui.fragment.FoodIngredientsFragmen
* Time: 10:05
* Use: 供應鏈食品列表
*/
public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, BaseViewHolder> {
public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, FoodListAdapter.ViewHolder> {
private Context context;
/**
* 編輯或者下單
......@@ -66,7 +66,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, PurchaseFoodListVosBean foodInfoBean) {
protected void convert(@NotNull ViewHolder viewHolder, PurchaseFoodListVosBean foodInfoBean) {
viewHolder.setText(R.id.tv_food_item_supplier_name, foodInfoBean.getSupplierName());
ImageView foodImg = viewHolder.getView(R.id.iv_food_ingredient_img);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodInfoBean.getImages())) {
......@@ -110,7 +110,6 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
private OnCheckedChangeListener onCheckedChangeListener;
private OnNumberChangeListener onNumberChangeListener;
private TextWatcher foodNumTextWatcher;
public interface OnCheckedChangeListener {
/**
......@@ -143,21 +142,20 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
* @param viewHolder
* @param foodInfoBean
*/
private void setEdit(@NotNull BaseViewHolder viewHolder, PurchaseFoodListVosBean foodInfoBean) {
private void setEdit(@NotNull ViewHolder viewHolder, PurchaseFoodListVosBean foodInfoBean) {
EditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
PurchaseFoodListVosBean food = integerMap.get(foodInfoBean.getId());
if (viewHolder.textWatcher != null) {
editText.removeTextChangedListener(viewHolder.textWatcher);
}
if (food == null) {
editText.setText(String.valueOf(0));
} else {
editText.setText(String.valueOf(food.getFoodCount()));
}
viewHolder.getView(R.id.btn_food_operation_sub).setOnClickListener(v -> {
subNumber(editText, foodInfoBean);
});
viewHolder.getView(R.id.btn_food_operation_sub).setOnClickListener(v -> subNumber(editText, foodInfoBean));
viewHolder.getView(R.id.btn_food_operation_add).setOnClickListener(v -> {
addNumber(editText, foodInfoBean);
});
viewHolder.getView(R.id.btn_food_operation_add).setOnClickListener(v -> addNumber(editText, foodInfoBean));
// viewHolder.getView(R.id.btn_food_operation_sub).setOnLongClickListener(v -> {
// ThreadFactory namedThreadFactory = r -> null;
// ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1, namedThreadFactory);
......@@ -174,7 +172,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
// addNumber(editText, foodInfoBean);
// return true;
// });
foodNumTextWatcher = new TextWatcher() {
TextWatcher foodNumTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -189,7 +187,6 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
public void afterTextChanged(Editable s) {
PurchaseFoodListVosBean purchaseFoodListVosBean = getData().get(viewHolder.getAdapterPosition());
if (s == null || TextUtil.isEmptyOrNullOrUndefined(s.toString())) {
integerMap.put(purchaseFoodListVosBean.getId(), purchaseFoodListVosBean);
editText.setText(String.valueOf(0));
editText.setSelection(editText.getText().length());
if (onNumberChangeListener != null) {
......@@ -197,15 +194,17 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
}
} else {
purchaseFoodListVosBean.setFoodCount(Integer.parseInt(s.toString()));
integerMap.put(purchaseFoodListVosBean.getId(), purchaseFoodListVosBean);
if (purchaseFoodListVosBean.getFoodCount() > 0) {
integerMap.put(purchaseFoodListVosBean.getId(), purchaseFoodListVosBean);
}
if (onNumberChangeListener != null) {
onNumberChangeListener.onChanged(purchaseFoodListVosBean.getId(), Integer.parseInt(s.toString()), viewHolder.getAdapterPosition());
}
}
}
};
editText.removeTextChangedListener(foodNumTextWatcher);
editText.addTextChangedListener(foodNumTextWatcher);
viewHolder.textWatcher = foodNumTextWatcher;
}
public void setOnNumberChangeListener(OnNumberChangeListener onNumberChangeListener) {
......@@ -229,13 +228,13 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
private void subNumber(EditText editText, PurchaseFoodListVosBean foodInfoBean) {
PurchaseFoodListVosBean purchaseFoodListVosBean = integerMap.get(foodInfoBean.getId());
if (purchaseFoodListVosBean != null && purchaseFoodListVosBean.getFoodCount() > 0) {
purchaseFoodListVosBean.setFoodCount(purchaseFoodListVosBean.getFoodCount() - 1);
editText.setText(String.valueOf(purchaseFoodListVosBean.getFoodCount()));
editText.setSelection(editText.getText().length());
if (purchaseFoodListVosBean != null) {
purchaseFoodListVosBean.setFoodCount(Math.max(purchaseFoodListVosBean.getFoodCount() - 1, 0));
if (purchaseFoodListVosBean.getFoodCount() <= 0) {
integerMap.remove(foodInfoBean.getId());
}
editText.setText(String.valueOf(purchaseFoodListVosBean.getFoodCount()));
editText.setSelection(editText.getText().length());
} else {
integerMap.remove(foodInfoBean.getId());
}
......@@ -244,4 +243,12 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodListVosBean, B
public Map<Integer, PurchaseFoodListVosBean> getIntegerMap() {
return integerMap;
}
public static class ViewHolder extends BaseViewHolder {
public TextWatcher textWatcher;
public ViewHolder(@NotNull View view) {
super(view);
}
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerConfirmOrderComponent;
import com.gingersoft.supply_chain.mvp.contract.ConfirmOrderContract;
import com.gingersoft.supply_chain.mvp.presenter.ConfirmOrderPresenter;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
import butterknife.BindView;
import butterknife.OnClick;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/17/2020 10:24
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class ConfirmOrderFragment extends BaseSupplyChainFragment<ConfirmOrderPresenter> implements ConfirmOrderContract.View {
@BindView(R2.id.supply_top_bar)
QMUITopBar supplyTopBar;
@BindView(R2.id.rv_confirm_order)
RecyclerView rvConfirmOrder;
@BindView(R2.id.btn_confirm_order)
QMUIAlphaTextView btnConfirmOrder;
@BindView(R2.id.btn_cancel_order)
QMUIAlphaTextView btnCancelOrder;
public static ConfirmOrderFragment newInstance() {
ConfirmOrderFragment fragment = new ConfirmOrderFragment();
return fragment;
}
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerConfirmOrderComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_confirm_order, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(supplyTopBar, "採購單確認");
// ConfirmOrderAdapter adapter = new ConfirmOrderAdapter();
// rvConfirmOrder.setAdapter(adapter);
// adapter.setList();
}
@OnClick({R2.id.btn_confirm_order,R2.id.btn_cancel_order})
public void onClick(View view){
}
}
......@@ -77,7 +77,6 @@ public class OrderContentFragment extends BaseSupplyChainFragment<OrderContentPr
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
//全選
......@@ -108,9 +107,9 @@ public class OrderContentFragment extends BaseSupplyChainFragment<OrderContentPr
if (viewId == R.id.tv_order_content_complete) {
//完成
List<PurchaseFoodListVosBean> purchaseFoodListVosBeans = shoppingCartAdapter.getPurchaseFoodListVosBeans();
mPresenter.addNewPurchaseOrder(purchaseFoodListVosBeans, edOrderContentRemark.getText() + "");
// mPresenter.addNewPurchaseOrder(purchaseFoodListVosBeans, edOrderContentRemark.getText() + "");
//去到訂單確認頁面
startWithPop(SendMsgFragment.newInstance());
startWithPop(ConfirmOrderFragment.newInstance());
} else if (viewId == R.id.btn_order_content_order_template) {
//訂單模板
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/supply_chain_top_bar" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_confirm_order"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/btn_confirm_order"
style="@style/Save_Btn_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="@dimen/dp_11"
android:paddingBottom="@dimen/dp_11"
android:text="確定" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/btn_cancel_order"
style="@style/Save_Btn_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_weight="1"
android:background="@drawable/shape_black_border_small_radius"
android:paddingTop="@dimen/dp_11"
android:paddingBottom="@dimen/dp_11"
android:text="取消"
android:textColor="@color/color_3c" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="vertical">
<TextView
android:id="@+id/tv_confirm_order_item_supplier_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_8"
android:textColor="@color/color_222"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
tools:text="供應商名稱" />
<include layout="@layout/include_horizontal_color_ef_one_dividing_line" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="送貨地址:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_confirm_order_item_supplier_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right|center_vertical"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
tools:text="供應商地址" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="發送時間:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_confirm_order_item_send_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" android:gravity="right|center_vertical"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
tools:text="默認為第二天的時間" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="訂單合計($):"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_confirm_order_item_total_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" android:gravity="right|center_vertical"
android:text="900"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="運費($):"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_confirm_order_item_freight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" android:gravity="right|center_vertical"
android:text="100"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="實際應付($):"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_confirm_order_item_pay_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right|center_vertical"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
tools:text="1000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_8"
android:paddingRight="@dimen/dp_12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/dp_15"
android:text="備註:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<EditText
android:id="@+id/ed_confirm_order_item_remark"
style="@style/AppEditTextStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="right|center_vertical"
android:hint="請輸入備註"
android:textColor="@color/color_3c"
android:textColorHint="@color/color_c9"
android:textSize="@dimen/dp_15" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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