Commit fb2f2dca by 宁斌

外賣接單 結賬單,外賣接單 印單

parent 922cde77
...@@ -10,6 +10,7 @@ import java.util.regex.Pattern; ...@@ -10,6 +10,7 @@ import java.util.regex.Pattern;
public class StringUtils { public class StringUtils {
public static final String DEFAULT_QUERY_REGEX = "[!$^&*+=|{}';'\",<>/?~!#¥%……&*——|{}【】‘;:”“'。,、?]"; public static final String DEFAULT_QUERY_REGEX = "[!$^&*+=|{}';'\",<>/?~!#¥%……&*——|{}【】‘;:”“'。,、?]";
/** /**
* 生成指定长度字符串,不足位右补空格,超出換行 * 生成指定长度字符串,不足位右补空格,超出換行
* *
...@@ -190,29 +191,30 @@ public class StringUtils { ...@@ -190,29 +191,30 @@ public class StringUtils {
/** /**
* 特殊字符转义处理 * 特殊字符转义处理
*
* @param data * @param data
* @return * @return
*/ */
public static String stringEscape(String data) { public static String stringEscape(String data) {
data = data.replace(" ","%20"); data = data.replace(" ", "%20");
data = data.replace("\"","%22"); data = data.replace("\"", "%22");
data = data.replace("#","%23"); data = data.replace("#", "%23");
data = data.replace("%","%25"); data = data.replace("%", "%25");
data = data.replace("&","%26"); data = data.replace("&", "%26");
data = data.replace("(","%28"); data = data.replace("(", "%28");
data = data.replace(")","%29"); data = data.replace(")", "%29");
data = data.replace("+","%2B"); data = data.replace("+", "%2B");
data = data.replace(",","%2C"); data = data.replace(",", "%2C");
data = data.replace("/","%2F"); data = data.replace("/", "%2F");
data = data.replace(":","%3A"); data = data.replace(":", "%3A");
data = data.replace(";","%3B"); data = data.replace(";", "%3B");
data = data.replace("<","%3C"); data = data.replace("<", "%3C");
data = data.replace("=","%3D"); data = data.replace("=", "%3D");
data = data.replace(">","%3E"); data = data.replace(">", "%3E");
data = data.replace("?","%3F"); data = data.replace("?", "%3F");
data = data.replace("@","%40"); data = data.replace("@", "%40");
data = data.replace("\\ ","%5C"); data = data.replace("\\ ", "%5C");
data = data.replace("|","%7C"); data = data.replace("|", "%7C");
return data; return data;
} }
...@@ -268,4 +270,21 @@ public class StringUtils { ...@@ -268,4 +270,21 @@ public class StringUtils {
protected String getQueryRegex() { protected String getQueryRegex() {
return DEFAULT_QUERY_REGEX; return DEFAULT_QUERY_REGEX;
} }
/**
* 方法二:推荐,速度最快
* 判断是否为整数
* @param str 传入的字符串
* @return 是整数返回true, 否则返回false
*/
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
}
} }
\ No newline at end of file
...@@ -2,17 +2,15 @@ package com.gingersoft.gsa.cloud.print.bean; ...@@ -2,17 +2,15 @@ package com.gingersoft.gsa.cloud.print.bean;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import lombok.Getter; import lombok.Data;
import lombok.Setter;
/** /**
* @author : bin * @author : bin
* @create date: 2020-11-06 * @create date: 2020-11-06
* @update date: 2020-11-06 * @update date: 2020-11-06
* @description:skyorder 打印實體 * @description:skyorder qrcode打印實體
* */ */
@Getter @Data
@Setter
public class PrintQRCodeContent implements PrintContent, Parcelable { public class PrintQRCodeContent implements PrintContent, Parcelable {
private String printTableName; private String printTableName;
...@@ -63,4 +61,6 @@ public class PrintQRCodeContent implements PrintContent, Parcelable { ...@@ -63,4 +61,6 @@ public class PrintQRCodeContent implements PrintContent, Parcelable {
return new PrintQRCodeContent[size]; return new PrintQRCodeContent[size];
} }
}; };
} }
package com.gingersoft.gsa.cloud.print.bean;
import android.os.Parcel;
import android.os.Parcelable;
import com.gingersoft.gsa.cloud.print.bean.base.PrintPayTypeItem;
import java.util.List;
import lombok.Data;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:外賣結賬打印實體
*/
@Data
public class PrintTakeawayCheckoutContent extends PrintTakeawayFormContent implements Parcelable ,PrintContent {
/**
* 支付方式
*/
private List<PrintPayTypeItem> payTypeList;
public PrintTakeawayCheckoutContent() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeTypedList(this.payTypeList);
}
protected PrintTakeawayCheckoutContent(Parcel in) {
super(in);
this.payTypeList = in.createTypedArrayList(PrintPayTypeItem.CREATOR);
}
public static final Creator<PrintTakeawayCheckoutContent> CREATOR = new Creator<PrintTakeawayCheckoutContent>() {
@Override
public PrintTakeawayCheckoutContent createFromParcel(Parcel source) {
return new PrintTakeawayCheckoutContent(source);
}
@Override
public PrintTakeawayCheckoutContent[] newArray(int size) {
return new PrintTakeawayCheckoutContent[size];
}
};
}
package com.gingersoft.gsa.cloud.print.bean;
import android.os.Parcel;
import android.os.Parcelable;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintPayTypeItem;
import java.util.List;
import lombok.Data;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:外賣印單打印實體
*/
@Data
public class PrintTakeawayFormContent implements PrintContent, Parcelable {
private String brand;
private String resturantName;
/**
* 支付類型:在線支付,貨到付款
*/
private String payType;
//送達時間
private String deliveryTime;
//單號
private String orderNumber;
//訂單碼
private String billNumber;
//取餐碼
private String orderTakeFoodCode;
//開單時間
private String billingTime;
//支付時間
private String payTime;
//備註
private String remark;
//訂單實體
private List<PrintFoodItem> foodItemList;
private List<PrintBillItem> billItemList;
private List<PrintPayTypeItem> printPayTypeItemList;
//總金額
private String totalAmountText;
private String totalAmount;
//支付金額
private String payAmountText;
private String payAmount;
//會員積分信息
private String memberName;
private String memberNumber;
private String memberPhone;
private String memberOldPoints;
private String memberAddPoints;
private String memberNowPoints;
//收貨信息
private String adress;
private String receiver;
private String phone;
//禮貌用語
private String politeLanguage;
//打印時間
private String printTime;
public PrintTakeawayFormContent() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.brand);
dest.writeString(this.resturantName);
dest.writeString(this.payType);
dest.writeString(this.deliveryTime);
dest.writeString(this.orderNumber);
dest.writeString(this.billNumber);
dest.writeString(this.orderTakeFoodCode);
dest.writeString(this.billingTime);
dest.writeString(this.payTime);
dest.writeString(this.remark);
dest.writeTypedList(this.foodItemList);
dest.writeTypedList(this.billItemList);
dest.writeTypedList(this.printPayTypeItemList);
dest.writeString(this.totalAmountText);
dest.writeString(this.totalAmount);
dest.writeString(this.payAmount);
dest.writeString(this.memberNumber);
dest.writeString(this.memberName);
dest.writeString(this.memberPhone);
dest.writeString(this.memberOldPoints);
dest.writeString(this.memberAddPoints);
dest.writeString(this.memberNowPoints);
dest.writeString(this.adress);
dest.writeString(this.receiver);
dest.writeString(this.phone);
dest.writeString(this.politeLanguage);
dest.writeString(this.printTime);
}
protected PrintTakeawayFormContent(Parcel in) {
this.brand = in.readString();
this.resturantName = in.readString();
this.payType = in.readString();
this.deliveryTime = in.readString();
this.orderNumber = in.readString();
this.billNumber = in.readString();
this.orderTakeFoodCode = in.readString();
this.billingTime = in.readString();
this.payTime = in.readString();
this.remark = in.readString();
this.foodItemList = in.createTypedArrayList(PrintFoodItem.CREATOR);
this.billItemList = in.createTypedArrayList(PrintBillItem.CREATOR);
this.printPayTypeItemList = in.createTypedArrayList(PrintPayTypeItem.CREATOR);
this.totalAmountText = in.readString();
this.totalAmount = in.readString();
this.payAmount = in.readString();
this.memberNumber = in.readString();
this.memberName = in.readString();
this.memberPhone = in.readString();
this.memberOldPoints = in.readString();
this.memberAddPoints = in.readString();
this.memberNowPoints = in.readString();
this.adress = in.readString();
this.receiver = in.readString();
this.phone = in.readString();
this.politeLanguage = in.readString();
this.printTime = in.readString();
}
public static final Creator<PrintTakeawayFormContent> CREATOR = new Creator<PrintTakeawayFormContent>() {
@Override
public PrintTakeawayFormContent createFromParcel(Parcel source) {
return new PrintTakeawayFormContent(source);
}
@Override
public PrintTakeawayFormContent[] newArray(int size) {
return new PrintTakeawayFormContent[size];
}
};
}
package com.gingersoft.gsa.cloud.print.bean.adapter;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:
*/
public interface AdaptationContent {
PrintContent adaptationQRCode();
PrintContent adaptationPrintTakeawayFormContent(OrderDetails.DataBean data);
PrintContent adaptationPrintTakeawayCheckoutContent(OrderDetails.DataBean data);
PrintContent adaptationPrintCleanMachineContent();
}
package com.gingersoft.gsa.cloud.print.bean.adapter;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:
*/
public interface AdaptationContent2 {
PrintContent adaptationQRCode();
// PrintContent adaptationPrintTakeawayFormContent(OrderDetails.DataBean data);
//
// PrintContent adaptationPrintTakeawayCheckoutContent(OrderDetails.DataBean data);
//
// PrintContent adaptationPrintCleanMachineContent();
}
package com.gingersoft.gsa.cloud.print.bean.adapter;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.account.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.PrintTakeawayFormContent;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintPayTypeItem;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:
*/
@Data
public class PrintContentAdapter implements AdaptationContent {
public PrintContentAdapter() {
}
@Override
public PrintContent adaptationQRCode() {
return null;
}
@Override
public PrintContent adaptationPrintTakeawayFormContent(OrderDetails.DataBean data) {
return getPrintTakeawayFormContent(data);
}
@Override
public PrintContent adaptationPrintTakeawayCheckoutContent(OrderDetails.DataBean data) {
return getPrintTakeawayFormContent(data);
}
@Override
public PrintContent adaptationPrintCleanMachineContent() {
return null;
}
public PrintTakeawayFormContent getPrintTakeawayFormContent(OrderDetails.DataBean data) {
PrintTakeawayFormContent takeawayFormContent = new PrintTakeawayFormContent();
takeawayFormContent.setBrand(ResturantInfoManager.newInstance().getBrandName());
takeawayFormContent.setResturantName(ResturantInfoManager.newInstance().getRestaurantName());
takeawayFormContent.setPayType(String.valueOf(data.getPayType()));
takeawayFormContent.setDeliveryTime(data.getOrder_type() == 2 ? data.getSEND_TIME() : data.getTakeTime());
takeawayFormContent.setOrderNumber(data.getORDER_NO());
takeawayFormContent.setBillNumber(data.getBillNo());
takeawayFormContent.setOrderTakeFoodCode(data.getTakeFoodCode());
takeawayFormContent.setBillingTime(data.getCREATE_TIME());
takeawayFormContent.setPayTime(data.getPayTime());
takeawayFormContent.setRemark(data.getRemark());
// takeawayFormContent.setFoodItemList(getPrintFoodItemsByProductBeans(data.getPRODUCT_NAME()));
takeawayFormContent.setBillItemList(getBillItemListByInfo(data.getTOTAL_AMOUNT(), data.getLunchbox(), data.getDELIVERY_CHARGE()));
takeawayFormContent.setPrintPayTypeItemList(getPrintPayTypeItemsByPayMultiple(data.getPayMultiple()));
takeawayFormContent.setTotalAmountText("總金額: ");
takeawayFormContent.setTotalAmount(data.getTOTAL_AMOUNT());
takeawayFormContent.setPayAmountText("支付金額: ");
takeawayFormContent.setPayAmount(String.valueOf(data.getPAY_AMOUNT()));
takeawayFormContent.setMemberName(data.getMEMBER_NAME());
// takeawayFormContent.setMemberNumber(data.getm);
takeawayFormContent.setMemberPhone(data.getPHONE());
takeawayFormContent.setMemberOldPoints(String.valueOf(data.getOldPoints()));
takeawayFormContent.setMemberAddPoints(String.valueOf(data.getAddPoints()));
takeawayFormContent.setMemberNowPoints(String.valueOf(data.getNowPoints()));
takeawayFormContent.setAdress(data.getAddressDetail());
takeawayFormContent.setReceiver(data.getRECEIVER());
takeawayFormContent.setPhone(data.getPHONE());
takeawayFormContent.setPoliteLanguage("謝謝光臨!");
return takeawayFormContent;
}
// private List<PrintFoodItem> getPrintFoodItemsByProductBeans(List<OrderDetails.DataBean.PRODUCTNAMEBean> productnameBeanList) {
// List<OrderDetail> orderDetailList = OrderDetail.productMameBeanToOrderDetail(1, productnameBeanList);
// List<PrintFoodItem> printFoodItems = new ArrayList<>();
// for (OrderDetail orderDetail : orderDetailList) {
// printFoodItems.add(new PrintFoodItem(orderDetail.getProductName(), orderDetail.getNumber(), orderDetail.getPrice(), orderDetail.getItemType()));
// }
// return printFoodItems;
// }
private List<PrintBillItem> getBillItemListByInfo(String totalAmount, double lunchbox, double deliveryCharge) {
List<PrintBillItem> billItems = new ArrayList<>();
if (TextUtils.isEmpty(totalAmount)) {
billItems.add(new PrintBillItem("合計: ", String.valueOf(totalAmount)));
}
if (lunchbox != 0.0) {
billItems.add(new PrintBillItem("餐盒費: ", String.valueOf(lunchbox)));
}
if (deliveryCharge != 0.0) {
billItems.add(new PrintBillItem("送貨費: ", String.valueOf(deliveryCharge)));
}
return billItems;
}
private List<PrintPayTypeItem> getPrintPayTypeItemsByPayMultiple(List<OrderDetails.DataBean.PayMultiple> payMultiples) {
List<PrintPayTypeItem> printPayTypeItems = new ArrayList<>();
for (OrderDetails.DataBean.PayMultiple payMultiple : payMultiples) {
printPayTypeItems.add(new PrintPayTypeItem(payMultiple.getPayName(), String.valueOf(payMultiple.getAmount())));
}
return printPayTypeItems;
}
}
package com.gingersoft.gsa.cloud.print.bean.base;
import android.os.Parcel;
import android.os.Parcelable;
import lombok.Data;
/**
* 賬單打印實體
*/
@Data
public class PrintBillItem implements Parcelable {
private String billName;
private String billAmount;
public PrintBillItem(String billName, String billAmount) {
this.billName = billName;
this.billAmount = billAmount;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.billName);
dest.writeString(this.billAmount);
}
protected PrintBillItem(Parcel in) {
this.billName = in.readString();
this.billAmount = in.readString();
}
public static final Creator<PrintBillItem> CREATOR = new Creator<PrintBillItem>() {
@Override
public PrintBillItem createFromParcel(Parcel source) {
return new PrintBillItem(source);
}
@Override
public PrintBillItem[] newArray(int size) {
return new PrintBillItem[size];
}
};
}
package com.gingersoft.gsa.cloud.print.bean.base;
import android.os.Parcel;
import android.os.Parcelable;
import lombok.Data;
/**
* @author : bin
* @create date: 2020-12-01
* @update date: 2020-12-01
* @description:食品打印實體
*/
@Data
public class PrintFoodItem implements Parcelable {
private String name;
private int num;
private double price;
private int itemType;
public PrintFoodItem(String name, int num, double price, int itemType) {
this.name = name;
this.num = num;
this.price = price;
this.itemType = itemType;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.name);
dest.writeInt(this.num);
dest.writeDouble(this.price);
dest.writeInt(this.itemType);
}
protected PrintFoodItem(Parcel in) {
this.name = in.readString();
this.num = in.readInt();
this.price = in.readDouble();
this.itemType = in.readInt();
}
public static final Creator<PrintFoodItem> CREATOR = new Creator<PrintFoodItem>() {
@Override
public PrintFoodItem createFromParcel(Parcel source) {
return new PrintFoodItem(source);
}
@Override
public PrintFoodItem[] newArray(int size) {
return new PrintFoodItem[size];
}
};
}
package com.gingersoft.gsa.cloud.print.bean.base;
import android.os.Parcel;
import android.os.Parcelable;
import lombok.Data;
/**
* 賬單支付方式實體
*/
@Data
public class PrintPayTypeItem implements Parcelable {
private String payName;
private String payAmount;
public PrintPayTypeItem(String payName, String payAmount) {
this.payName = payName;
this.payAmount = payAmount;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.payName);
dest.writeString(this.payAmount);
}
protected PrintPayTypeItem(Parcel in) {
this.payName = in.readString();
this.payAmount = in.readString();
}
public static final Creator<PrintPayTypeItem> CREATOR = new Creator<PrintPayTypeItem>() {
@Override
public PrintPayTypeItem createFromParcel(Parcel source) {
return new PrintPayTypeItem(source);
}
@Override
public PrintPayTypeItem[] newArray(int size) {
return new PrintPayTypeItem[size];
}
};
}
...@@ -88,7 +88,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo ...@@ -88,7 +88,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
//訂單信息和廚房單 //訂單信息和廚房單
orderDetails.data!![0].order_type = data.order_type orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType orderDetails.data!![0].orderPayType = data.orderPayType
TakeawayOrder.getInstance().shoppingCart.dataBean = orderDetails.data!![0] TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = orderDetails.data!![0]
CC.obtainBuilder(ComponentName.COMPONENT_PRINT) CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER) .addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER)
.setActionName("printActivity") .setActionName("printActivity")
...@@ -101,7 +101,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo ...@@ -101,7 +101,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
} else { } else {
listener.invoke(true) listener.invoke(true)
} }
TakeawayOrder.getInstance().shoppingCart.dataBean = null TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = null
} }
} else { } else {
ToastUtils.show(context, "沒有訂單內容,打印失敗") ToastUtils.show(context, "沒有訂單內容,打印失敗")
......
...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.cloud.constans.AppConstans ...@@ -28,6 +28,7 @@ import com.gingersoft.gsa.cloud.constans.AppConstans
import com.gingersoft.gsa.cloud.constans.FoodSummaryConstans import com.gingersoft.gsa.cloud.constans.FoodSummaryConstans
import com.gingersoft.gsa.cloud.constans.PrintConstans import com.gingersoft.gsa.cloud.constans.PrintConstans
import com.gingersoft.gsa.cloud.print.bean.OrderDetails import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.print.bean.PrintContent
import com.gingersoft.gsa.cloud.service.GetInfoUpdateService import com.gingersoft.gsa.cloud.service.GetInfoUpdateService
import com.gingersoft.gsa.delivery_pick_mode.R import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.WeatherRepository import com.gingersoft.gsa.delivery_pick_mode.data.WeatherRepository
...@@ -618,13 +619,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -618,13 +619,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
*/ */
fun printOrder(code: Int, dataBean: OrderDetails.DataBean, listener: (MessageBean) -> Unit) { fun printOrder(code: Int, dataBean: OrderDetails.DataBean, listener: (MessageBean) -> Unit) {
//訂單信息和廚房單,打印前需要修改dataBean的order_type和orderPayType //訂單信息和廚房單,打印前需要修改dataBean的order_type和orderPayType
TakeawayOrder.getInstance().shoppingCart.dataBean = dataBean TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = dataBean
CC.obtainBuilder(ComponentName.COMPONENT_PRINT) CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER) .addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER)
.setActionName("printActivity") .setActionName("printActivity")
.build() .build()
.callAsyncCallbackOnMainThread { _, result -> .callAsyncCallbackOnMainThread { _, result ->
TakeawayOrder.getInstance().shoppingCart.dataBean = null TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = null
listener.invoke(getMsgBean(code, "打印", result.isSuccess)) listener.invoke(getMsgBean(code, "打印", result.isSuccess))
} }
} }
...@@ -633,15 +634,23 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -633,15 +634,23 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
* 打印結賬單 * 打印結賬單
*/ */
private fun printOrderClosing(dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) { private fun printOrderClosing(dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) {
TakeawayOrder.getInstance().shoppingCart.dataBean = dataBean TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = dataBean
var contentAdapter: PrintContentAd = PrintContent()
var PrintContent = contentAdapter.adaptationPrintTakeawayFormContent(TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData)
CC.obtainBuilder(ComponentName.COMPONENT_PRINT) CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_CLOSING) .addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_CLOSING)
.setActionName("printActivity") .setActionName("printActivity")
.addParam(PrintConstans.PRINT_CONTENT, PrintContent)
.build() .build()
.callAsyncCallbackOnMainThread { _, result -> .callAsyncCallbackOnMainThread { _, result ->
TakeawayOrder.getInstance().shoppingCart.dataBean = null TakeawayOrder.getInstance().shoppingCart.deliveryAndPickupData = null
listener.invoke(PrintCode, result.isSuccess) listener.invoke(PrintCode, result.isSuccess)
} }
} }
/** /**
......
...@@ -16,7 +16,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -16,7 +16,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.order.billItem.BillItem; import com.gingersoft.gsa.cloud.base.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.base.order.billItem.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart; import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.order.order.TakeawayOrder; import com.gingersoft.gsa.cloud.base.order.order.TakeawayOrder;
......
...@@ -14,7 +14,6 @@ import com.gingersoft.gsa.cloud.print.bean.OrderDetails; ...@@ -14,7 +14,6 @@ import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -42,7 +41,7 @@ public class ShoppingCart { ...@@ -42,7 +41,7 @@ public class ShoppingCart {
/** /**
* 外送/自取 的訂單數據 * 外送/自取 的訂單數據
*/ */
protected OrderDetails.DataBean dataBean; protected OrderDetails.DataBean deliveryAndPickupData;
/** /**
* 商品列表 * 商品列表
*/ */
......
package com.gingersoft.gsa.cloud.base.order.cart; package com.gingersoft.gsa.cloud.base.order.cart;
import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
......
...@@ -9,7 +9,6 @@ import com.gingersoft.gsa.cloud.database.bean.Discount; ...@@ -9,7 +9,6 @@ import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.Food; import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier; import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails; import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
......
...@@ -34,15 +34,32 @@ public class HtmlLable { ...@@ -34,15 +34,32 @@ public class HtmlLable {
this.attributesList = attributes; this.attributesList = attributes;
} }
public HtmlLable(String value, HtmlLable.Attributes... attributes) {
this.value = value;
this.attributesList = attributes;
}
@Data @Data
public static final class Attributes { public static final class Attributes {
private String attributesName; private String attributesName;
private String attributesVaule; private String attributesVaule;
/**
* 值類型:
* 0:自身類型 如1=int型
* 1:字符串 有時間1可能為字符串類型
*/
private byte valueType = 0;
public Attributes(String attributesName, String attributesVaule) { public Attributes(String attributesName, String attributesVaule) {
this.attributesName = attributesName; this.attributesName = attributesName;
this.attributesVaule = attributesVaule; this.attributesVaule = attributesVaule;
} }
public Attributes(String attributesName, String attributesVaule, byte valueType) {
this.attributesName = attributesName;
this.attributesVaule = attributesVaule;
this.valueType = valueType;
}
} }
} }
package com.joe.print.mvp.model.bean;
public class PrintBillBean {
public PrintBillBean(String billName, String billAmount) {
this.billName = billName;
this.billAmount = billAmount;
}
private String billName;
private String billAmount;
public String getBillName() {
return billName;
}
public void setBillName(String billName) {
this.billName = billName;
}
public String getBillAmount() {
return billAmount;
}
public void setBillAmount(String billAmount) {
this.billAmount = billAmount;
}
}
...@@ -9,7 +9,6 @@ import com.gingersoft.gsa.cloud.base.common.bean.BillingBean; ...@@ -9,7 +9,6 @@ import com.gingersoft.gsa.cloud.base.common.bean.BillingBean;
import com.gingersoft.gsa.cloud.base.common.bean.MemberInfo; import com.gingersoft.gsa.cloud.base.common.bean.MemberInfo;
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod; import com.gingersoft.gsa.cloud.base.common.bean.PayMethod;
import com.gingersoft.gsa.cloud.base.order.billItem.BillItem; import com.gingersoft.gsa.cloud.base.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.base.order.billItem.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart; import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder; import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder;
...@@ -20,7 +19,6 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; ...@@ -20,7 +19,6 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant; import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails; import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
......
...@@ -4,6 +4,7 @@ import android.content.Context; ...@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import com.gingersoft.gsa.cloud.account.restaurant.ResturantInfoManager; import com.gingersoft.gsa.cloud.account.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.account.user.UserContext; import com.gingersoft.gsa.cloud.account.user.UserContext;
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod; import com.gingersoft.gsa.cloud.base.common.bean.PayMethod;
...@@ -15,10 +16,12 @@ import com.gingersoft.gsa.cloud.constans.AppConstans; ...@@ -15,10 +16,12 @@ import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.PrintCleanMachineContent; import com.gingersoft.gsa.cloud.print.bean.PrintCleanMachineContent;
import com.joe.print.mvp.model.bean.HtmlLable; import com.joe.print.mvp.model.bean.HtmlLable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.joe.print.mvp.print.common.HtmlContract.ATTRIBUTES_ALIGN; import static com.joe.print.mvp.print.common.HtmlContract.ATTRIBUTES_ALIGN;
import static com.joe.print.mvp.print.common.HtmlContract.ATTRIBUTES_OFFSET; import static com.joe.print.mvp.print.common.HtmlContract.ATTRIBUTES_OFFSET;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_COLUMN; import static com.joe.print.mvp.print.common.HtmlContract.LABLE_COLUMN;
...@@ -102,15 +105,15 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -102,15 +105,15 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
} }
private String getHtmlHeadInfo() { private String getHtmlHeadInfo() {
HtmlLable[] htmlLables = new HtmlLable[7]; List<HtmlLable> htmlLables = new ArrayList<>();
htmlLables[0] = new HtmlLable(LABLE_P, "上次清機時間:" + mCleanMachineContent.getRestaurantOperation().getOperationTime()); htmlLables.add(new HtmlLable(LABLE_P, "上次清機時間:" + mCleanMachineContent.getRestaurantOperation().getOperationTime()));
htmlLables[1] = new HtmlLable(LABLE_P, "品牌名稱:" + ResturantInfoManager.newInstance().getBrandName()); htmlLables.add(new HtmlLable(LABLE_P, "品牌名稱:" + ResturantInfoManager.newInstance().getBrandName()));
htmlLables[2] = new HtmlLable(LABLE_P, "店鋪名稱:" + ResturantInfoManager.newInstance().getRestaurantName()); htmlLables.add(new HtmlLable(LABLE_P, "店鋪名稱:" + ResturantInfoManager.newInstance().getRestaurantName()));
htmlLables[3] = new HtmlLable(LABLE_P, "每日營業報表"); htmlLables.add(new HtmlLable(LABLE_P, "每日營業報表"));
htmlLables[4] = new HtmlLable(LABLE_P, "由營業日期:" + mCleanMachineContent.getStartTime()); htmlLables.add(new HtmlLable(LABLE_P, "由營業日期:" + mCleanMachineContent.getStartTime()));
htmlLables[5] = new HtmlLable(LABLE_P, "到營業日期:" + mCleanMachineContent.getCurrentTime()); htmlLables.add(new HtmlLable(LABLE_P, "到營業日期:" + mCleanMachineContent.getCurrentTime()));
htmlLables[6] = new HtmlLable(LABLE_P, "-----------------------------------------------------------------"); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
return getHtmlLables(htmlLables); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
private String getHtmlBusinessTotal() { private String getHtmlBusinessTotal() {
...@@ -150,8 +153,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -150,8 +153,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
} }
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
/** /**
...@@ -180,8 +182,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -180,8 +182,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
} }
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
/** /**
...@@ -225,8 +226,8 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -225,8 +226,8 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray();
return getHtmlLables(htmlLables2); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
/** /**
...@@ -248,8 +249,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -248,8 +249,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.addAll(getHtmlBillingStatisticsItem(analysisBean, voBean)); htmlLables.addAll(getHtmlBillingStatisticsItem(analysisBean, voBean));
} }
} }
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
private List<HtmlLable> getHtmlBillingStatisticsItem(SettlementReport.AnalysisBean analysisBean, SettlementReport.VoBean voBean) { private List<HtmlLable> getHtmlBillingStatisticsItem(SettlementReport.AnalysisBean analysisBean, SettlementReport.VoBean voBean) {
...@@ -338,8 +338,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -338,8 +338,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.add(new HtmlLable(getRowLableEnd())); htmlLables.add(new HtmlLable(getRowLableEnd()));
} }
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
...@@ -377,8 +376,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -377,8 +376,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.add(new HtmlLable(getRowLableEnd())); htmlLables.add(new HtmlLable(getRowLableEnd()));
} }
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
...@@ -397,9 +395,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> { ...@@ -397,9 +395,7 @@ public class PrintCleanMachine extends PrinterRoot<PrintCleanMachineContent> {
htmlLables.add(new HtmlLable(LABLE_COLUMN, items.get(i))); htmlLables.add(new HtmlLable(LABLE_COLUMN, items.get(i)));
htmlLables.add(new HtmlLable(getRowLableEnd())); htmlLables.add(new HtmlLable(getRowLableEnd()));
} }
HtmlLable[] htmlLables2 = (HtmlLable[]) htmlLables.toArray(); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables2);
} }
} }
...@@ -14,7 +14,6 @@ import com.gingersoft.gsa.cloud.base.table.bean.TableBean; ...@@ -14,7 +14,6 @@ import com.gingersoft.gsa.cloud.base.table.bean.TableBean;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil; import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.joe.print.R; import com.joe.print.R;
import java.util.ArrayList; import java.util.ArrayList;
......
...@@ -11,7 +11,8 @@ import com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils; ...@@ -11,7 +11,8 @@ import com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant; import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails; import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.joe.print.mvp.model.bean.PrintBillBean; import com.gingersoft.gsa.cloud.print.bean.PrintTakeawayFormContent;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -21,12 +22,18 @@ import java.util.Map; ...@@ -21,12 +22,18 @@ import java.util.Map;
/** /**
* 外送接單,印單 已改新版 * 外送接單,印單 已改新版
*/ */
public class PrintOtherOrder extends PrinterRoot { public class PrintOtherOrder extends PrinterRoot<PrintTakeawayFormContent> {
private PrintTakeawayFormContent printTakeawayFormContent;
@Override
protected void setPrintContent(PrintTakeawayFormContent printContent) {
this.printTakeawayFormContent = printContent;
}
@Override @Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) { public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) {
OrderDetails.DataBean dataBean = TakeawayOrder.getInstance().getShoppingCart().getDataBean(); OrderDetails.DataBean dataBean = TakeawayOrder.getInstance().getShoppingCart().getDeliveryAndPickupData();
if (dataBean != null) { if (dataBean != null) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>(); Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
//廚房單,可能會有多個IP打印 //廚房單,可能會有多個IP打印
...@@ -49,9 +56,20 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -49,9 +56,20 @@ public class PrintOtherOrder extends PrinterRoot {
@Override @Override
public String[] getPrintDatas(Context mContext, PrinterDeviceBean deviceBean) { public String[] getPrintDatas(Context mContext, PrinterDeviceBean deviceBean) {
return null;
if (printTakeawayFormContent == null) {
return new String[]{"<html><body></body></html>"};
}
String stringBuilder = "<html><body>" +
getTakewayPrintContent(printTakeawayFormContent,deviceBean) +
"</body></html>";
String[] pritContent = new String[1];
pritContent[0] = stringBuilder;
return pritContent;
} }
@Override @Override
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
return RestaurantExpandInfoUtils.getValue(ExpandConstant.DeliveryPrintCount,1); return RestaurantExpandInfoUtils.getValue(ExpandConstant.DeliveryPrintCount,1);
...@@ -69,7 +87,7 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -69,7 +87,7 @@ public class PrintOtherOrder extends PrinterRoot {
layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(0, data.getPRODUCT_NAME()), deviceBean, 1, true)); layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(0, data.getPRODUCT_NAME()), deviceBean, 1, true));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
//訂單金額信息 //訂單金額信息
List<PrintBillBean> billData = new ArrayList<>(); List<PrintBillItem> billData = new ArrayList<>();
billData.add(getBillBean("合計:", MONETARY_UNIT + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE()))); billData.add(getBillBean("合計:", MONETARY_UNIT + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE())));
if (data.getLunchbox() != 0) { if (data.getLunchbox() != 0) {
billData.add(getBillBean("餐盒費:", MONETARY_UNIT + data.getLunchbox())); billData.add(getBillBean("餐盒費:", MONETARY_UNIT + data.getLunchbox()));
...@@ -95,8 +113,8 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -95,8 +113,8 @@ public class PrintOtherOrder extends PrinterRoot {
return viewToZoomBitmap(mContext, layout, deviceBean); return viewToZoomBitmap(mContext, layout, deviceBean);
} }
private PrintBillBean getBillBean(String title, String value) { private PrintBillItem getBillBean(String title, String value) {
return new PrintBillBean(title, value); return new PrintBillItem(title, value);
} }
} }
...@@ -6,6 +6,7 @@ import android.view.LayoutInflater; ...@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
...@@ -18,8 +19,9 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; ...@@ -18,8 +19,9 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant; import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails; import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintTakeawayCheckoutContent;
import com.joe.print.R; import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrintBillBean; import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.joe.print.mvp.ui.adapter.BillItemAdapter; import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.OtherOrderAdapter; import com.joe.print.mvp.ui.adapter.OtherOrderAdapter;
...@@ -31,11 +33,19 @@ import java.util.Map; ...@@ -31,11 +33,19 @@ import java.util.Map;
/** /**
* 打印外賣接單 結賬單 * 打印外賣接單 結賬單
*/ */
public class PrintOtherOrderClosing extends PrinterRoot { public class PrintOtherOrderClosing extends PrinterRoot<PrintTakeawayCheckoutContent> {
private PrintTakeawayCheckoutContent mTakeawayCheckoutContent;
@Override
protected void setPrintContent(PrintTakeawayCheckoutContent printContent) {
this.mTakeawayCheckoutContent = printContent;
}
@Override @Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) { public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) {
OrderDetails.DataBean dataBean = TakeawayOrder.getInstance().getShoppingCart().getDataBean(); OrderDetails.DataBean dataBean = TakeawayOrder.getInstance().getShoppingCart().getDeliveryAndPickupData();
if (dataBean != null) { if (dataBean != null) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>(); Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
List<Bitmap> bitmaps = new ArrayList<>(); List<Bitmap> bitmaps = new ArrayList<>();
...@@ -48,12 +58,21 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -48,12 +58,21 @@ public class PrintOtherOrderClosing extends PrinterRoot {
@Override @Override
public String[] getPrintDatas(Context mContext, PrinterDeviceBean deviceBean) { public String[] getPrintDatas(Context mContext, PrinterDeviceBean deviceBean) {
return null;
if (mTakeawayCheckoutContent == null) {
return new String[]{"<html><body></body></html>"};
}
String stringBuilder = "<html><body>" +
getTakewayPrintContent(mTakeawayCheckoutContent, deviceBean) +
"</body></html>";
String[] pritContent = new String[1];
pritContent[0] = stringBuilder;
return pritContent;
} }
@Override @Override
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
return RestaurantExpandInfoUtils.getValue(ExpandConstant.DeliveryClosingPC,1); return RestaurantExpandInfoUtils.getValue(ExpandConstant.DeliveryClosingPC, 1);
} }
private Bitmap initPrintView(Context context, OrderDetails.DataBean data, PrinterDeviceBean deviceBean) { private Bitmap initPrintView(Context context, OrderDetails.DataBean data, PrinterDeviceBean deviceBean) {
...@@ -98,7 +117,7 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -98,7 +117,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
String amountUnit = context.getString(R.string.amount_unit); String amountUnit = context.getString(R.string.amount_unit);
RecyclerView rvBill = view.findViewById(R.id.rv_bill); RecyclerView rvBill = view.findViewById(R.id.rv_bill);
List<PrintBillBean> billData = new ArrayList<>(); List<PrintBillItem> billData = new ArrayList<>();
billData.add(getBillBean("合計:", amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE()))); billData.add(getBillBean("合計:", amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE())));
if (data.getLunchbox() != 0) { if (data.getLunchbox() != 0) {
billData.add(getBillBean("餐盒費:", amountUnit + data.getLunchbox())); billData.add(getBillBean("餐盒費:", amountUnit + data.getLunchbox()));
...@@ -197,7 +216,7 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -197,7 +216,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(1, data.getPRODUCT_NAME()), deviceBean, 1, true)); layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(1, data.getPRODUCT_NAME()), deviceBean, 1, true));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
//訂單金額信息 //訂單金額信息
List<PrintBillBean> billData = new ArrayList<>(); List<PrintBillItem> billData = new ArrayList<>();
billData.add(getBillBean("合計:", MONETARY_UNIT + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE()))); billData.add(getBillBean("合計:", MONETARY_UNIT + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE())));
if (data.getLunchbox() != 0) { if (data.getLunchbox() != 0) {
billData.add(getBillBean("餐盒費:", MONETARY_UNIT + data.getLunchbox())); billData.add(getBillBean("餐盒費:", MONETARY_UNIT + data.getLunchbox()));
...@@ -236,8 +255,8 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -236,8 +255,8 @@ public class PrintOtherOrderClosing extends PrinterRoot {
return viewToZoomBitmap(mContext, layout, deviceBean); return viewToZoomBitmap(mContext, layout, deviceBean);
} }
private PrintBillBean getBillBean(String title, String value) { private PrintBillItem getBillBean(String title, String value) {
return new PrintBillBean(title, value); return new PrintBillItem(title, value);
} }
} }
\ No newline at end of file
...@@ -197,7 +197,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -197,7 +197,7 @@ public class PrintPrjKitchen extends PrinterRoot {
htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------")); htmlLables.add(new HtmlLable(LABLE_P, "-----------------------------------------------------------------"));
htmlLables.add(new HtmlLable(getBrLable())); htmlLables.add(new HtmlLable(getBrLable()));
return getHtmlLables((HtmlLable[]) htmlLables.toArray()); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
private String getHtmlKitchenFood(List<PrjBean.DataBean.Bean> prjBeans) { private String getHtmlKitchenFood(List<PrjBean.DataBean.Bean> prjBeans) {
...@@ -212,7 +212,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -212,7 +212,7 @@ public class PrintPrjKitchen extends PrinterRoot {
} }
htmlLables.add(new HtmlLable(getBrLable())); htmlLables.add(new HtmlLable(getBrLable()));
return getHtmlLables((HtmlLable[]) htmlLables.toArray()); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
private String getHtmlEndInfo(PrjBean.DataBean.Bean prjBean) { private String getHtmlEndInfo(PrjBean.DataBean.Bean prjBean) {
...@@ -225,7 +225,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -225,7 +225,7 @@ public class PrintPrjKitchen extends PrinterRoot {
new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_prj_page_index), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_prj_page_index),
new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center))); new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)));
} }
return getHtmlLables((HtmlLable[]) htmlLables.toArray()); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
@Override @Override
...@@ -411,30 +411,30 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -411,30 +411,30 @@ public class PrintPrjKitchen extends PrinterRoot {
} }
} }
private String getProductNameByLanguageType(PrjBean.DataBean.Bean prjBean) { // private String getProductNameByLanguageType(PrjBean.DataBean.Bean prjBean) {
for (String type : languageTypes) { // for (String type : languageTypes) {
String languageType = type; // String languageType = type;
if (languageType.contains(".")) { // if (languageType.contains(".")) {
languageType = type.substring(0, type.indexOf(".")); // languageType = type.substring(0, type.indexOf("."));
} // }
if (languageType.equals("2")) { // if (languageType.equals("2")) {
//語言二 // //語言二
if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName2())) { // if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName2())) {
return prjBean.getProductName2(); // return prjBean.getProductName2();
} // }
} else if (languageType.equals("3")) { // } else if (languageType.equals("3")) {
//語言三 // //語言三
if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName3())) { // if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName3())) {
return prjBean.getProductName3(); // return prjBean.getProductName3();
} // }
} else { // } else {
//語言一或其他 // //語言一或其他
if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName())) { // if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getProductName())) {
return prjBean.getProductName(); // return prjBean.getProductName();
} // }
} // }
} // }
} // }
public static Map<String, List<PrjBean.DataBean.Bean>> getPrjMap() { public static Map<String, List<PrjBean.DataBean.Bean>> getPrjMap() {
if (prjMap == null) { if (prjMap == null) {
......
...@@ -17,6 +17,8 @@ import com.joe.print.mvp.model.bean.HtmlLable; ...@@ -17,6 +17,8 @@ import com.joe.print.mvp.model.bean.HtmlLable;
import com.joe.print.mvp.print.common.HtmlContract; import com.joe.print.mvp.print.common.HtmlContract;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -55,8 +57,8 @@ public class PrintQRCode extends PrinterRoot<PrintQRCodeContent> { ...@@ -55,8 +57,8 @@ public class PrintQRCode extends PrinterRoot<PrintQRCodeContent> {
} }
String stringBuilder = "<html><body>" + String stringBuilder = "<html><body>" +
getHtmlHeadInfo() + getHtmlHeadInfo() +
getHtmlQRcode() + getHtmlQRcode()
getHtmlEndInfo() // getHtmlEndInfo()
+ "</body></html>"; + "</body></html>";
String[] pritContent = new String[1]; String[] pritContent = new String[1];
pritContent[0] = stringBuilder; pritContent[0] = stringBuilder;
...@@ -64,31 +66,30 @@ public class PrintQRCode extends PrinterRoot<PrintQRCodeContent> { ...@@ -64,31 +66,30 @@ public class PrintQRCode extends PrinterRoot<PrintQRCodeContent> {
} }
private String getHtmlHeadInfo() { private String getHtmlHeadInfo() {
HtmlLable[] htmlLables = { List<HtmlLable> htmlLables = new ArrayList<>();
new HtmlLable(LABLE_P, mQRCodeBean.getPrintTableName(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)), htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintTableName(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center))));
new HtmlLable(LABLE_P, mQRCodeBean.getPrintTableName(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)), htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintTopInfo(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center))));
new HtmlLable(getBrLable())}; return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
return getHtmlLables(htmlLables);
} }
private String getHtmlQRcode() { private String getHtmlQRcode() {
HtmlLable[] htmlLables = { HtmlLable[] htmlLables = {
new HtmlLable(getBrLable()), new HtmlLable(LABLE_QRCODE, mQRCodeBean.getPrintQrcode(),
new HtmlLable(LABLE_QRCODE, mQRCodeBean.getPrintQrcode(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_SCALE, HtmlContract.value_scale_1, HtmlContract.value_type_string),
new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)),
new HtmlLable(getBrLable())}; new HtmlLable(getBrLable())};
return getHtmlLables(htmlLables); return getHtmlLables(htmlLables);
} }
private String getHtmlEndInfo() { private String getHtmlEndInfo() {
HtmlLable[] htmlLables = { List<HtmlLable> htmlLables = new ArrayList<>();
new HtmlLable(LABLE_P, mQRCodeBean.getPrintTime()), htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintTime())));
new HtmlLable(LABLE_P, mQRCodeBean.getPrintPeopleNum()), htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintPeopleNum())));
new HtmlLable(LABLE_P, mQRCodeBean.getPrintMealEndTime()), htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintMealEndTime())));
new HtmlLable(LABLE_P, mQRCodeBean.getPrintBottonInfo())}; htmlLables.addAll(getRowInformation(new HtmlLable(mQRCodeBean.getPrintBottonInfo())));
return getHtmlLables(htmlLables); return getHtmlLables(htmlLables.toArray(new HtmlLable[htmlLables.size()]));
} }
@Override @Override
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
return 1; return 1;
......
...@@ -7,7 +7,6 @@ import android.widget.LinearLayout; ...@@ -7,7 +7,6 @@ import android.widget.LinearLayout;
import com.gingersoft.gsa.cloud.base.common.bean.BillingBean; import com.gingersoft.gsa.cloud.base.common.bean.BillingBean;
import com.gingersoft.gsa.cloud.base.order.billItem.BillItem; import com.gingersoft.gsa.cloud.base.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.base.order.billItem.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart; import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder; import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder;
......
...@@ -2,6 +2,8 @@ package com.joe.print.mvp.print; ...@@ -2,6 +2,8 @@ package com.joe.print.mvp.print;
import android.text.TextUtils; import android.text.TextUtils;
import com.joe.print.mvp.model.bean.HtmlLable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -13,7 +15,7 @@ public class PrintUtils { ...@@ -13,7 +15,7 @@ public class PrintUtils {
//一行42個 17.5 //一行42個 17.5
public final static int lineLength = 42; public final static int lineLength = 42;
private static int foodNameSpace = 20; public static int foodNameSpace = 20;
private static int foodNumSpace = 8; private static int foodNumSpace = 8;
private static int foodAmountSpace = 12; private static int foodAmountSpace = 12;
public final static double BBPOS_Chinese_Length = 2.4; public final static double BBPOS_Chinese_Length = 2.4;
...@@ -23,6 +25,7 @@ public class PrintUtils { ...@@ -23,6 +25,7 @@ public class PrintUtils {
private static final int food_width_percentage = 60; private static final int food_width_percentage = 60;
private static final int num_and_amount_percentage = 40; private static final int num_and_amount_percentage = 40;
/** /**
* @param content 要顯示的內容 * @param content 要顯示的內容
* @param maxLength 字符串最大長度 * @param maxLength 字符串最大長度
...@@ -217,16 +220,5 @@ public class PrintUtils { ...@@ -217,16 +220,5 @@ public class PrintUtils {
} }
} }
/**
* 獲取BBPos食品行打印信息
* @param name1s
* @param name2s
* @param name3s
* @return
*/
public static String getBBPosFoodLineString(List<String> name1s, List<String> name2s, List<String> name3s){
}
} }
...@@ -39,6 +39,7 @@ import com.gingersoft.gsa.cloud.base.table.bean.TableBean; ...@@ -39,6 +39,7 @@ import com.gingersoft.gsa.cloud.base.table.bean.TableBean;
import com.gingersoft.gsa.cloud.base.threadPool.ThreadPoolManager; import com.gingersoft.gsa.cloud.base.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.base.utils.AidlUtil; import com.gingersoft.gsa.cloud.base.utils.AidlUtil;
import com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils; import com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.StringUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil; import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils; import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
...@@ -51,9 +52,11 @@ import com.gingersoft.gsa.cloud.print.PrintExecutor; ...@@ -51,9 +52,11 @@ import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.PrinterWriter58mm; import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails; import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.gingersoft.gsa.cloud.print.bean.PrintCleanMachineContent;
import com.gingersoft.gsa.cloud.print.bean.PrintContent; import com.gingersoft.gsa.cloud.print.bean.PrintContent;
import com.gingersoft.gsa.cloud.print.bean.PrintQRCodeContent; import com.gingersoft.gsa.cloud.print.bean.PrintTakeawayCheckoutContent;
import com.gingersoft.gsa.cloud.print.bean.PrintTakeawayFormContent;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintPayTypeItem;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import com.hyweb.n5.lib.constant.PrinterConstant; import com.hyweb.n5.lib.constant.PrinterConstant;
import com.hyweb.n5.lib.util.PrinterUtil; import com.hyweb.n5.lib.util.PrinterUtil;
...@@ -61,7 +64,8 @@ import com.hyweb.n5.server.aidl.IOnPrintCallback; ...@@ -61,7 +64,8 @@ import com.hyweb.n5.server.aidl.IOnPrintCallback;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.joe.print.R; import com.joe.print.R;
import com.joe.print.mvp.model.bean.HtmlLable; import com.joe.print.mvp.model.bean.HtmlLable;
import com.joe.print.mvp.model.bean.PrintBillBean; import com.gingersoft.gsa.cloud.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.PrinterFinderCallback;
import com.joe.print.mvp.print.common.SendResultCode; import com.joe.print.mvp.print.common.SendResultCode;
import com.joe.print.mvp.print.usb.EscCommand; import com.joe.print.mvp.print.usb.EscCommand;
...@@ -83,6 +87,11 @@ import javax.inject.Inject; ...@@ -83,6 +87,11 @@ import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
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_H4;
import static com.joe.print.mvp.print.common.HtmlContract.LABLE_P;
@Getter @Getter
public abstract class PrinterRoot<T extends PrintContent> implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener, ReceiveListener { public abstract class PrinterRoot<T extends PrintContent> implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener, ReceiveListener {
...@@ -120,7 +129,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -120,7 +129,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
} }
/** /**
* 需要打印的實體類 需要重寫這個方法 * 需要打印實體的類 需要重寫這個方法
* *
* @param printContent * @param printContent
*/ */
...@@ -204,7 +213,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -204,7 +213,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
/** /**
* 本機打印 * 本機打印
*/ */
public void locationPrint(List<Bitmap> bitmaps, String [] BBPosPrintDatas, PrintListener listener) { public void locationPrint(List<Bitmap> bitmaps, String[] BBPosPrintDatas, PrintListener listener) {
//本機打印 //本機打印
String model = Build.MODEL; String model = Build.MODEL;
if (PrintConstans.PRINT_MODEL_V2.contains(model)) { if (PrintConstans.PRINT_MODEL_V2.contains(model)) {
...@@ -704,7 +713,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -704,7 +713,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
return view; return view;
} }
protected View getTakeawayBillInfoView(Context mContext, List<PrintBillBean> data) { protected View getTakeawayBillInfoView(Context mContext, List<PrintBillItem> data) {
return getVerticalRecyclerView(mContext, new BillItemAdapter(data)); return getVerticalRecyclerView(mContext, new BillItemAdapter(data));
} }
...@@ -988,11 +997,167 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -988,11 +997,167 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
return PrintUtils.getLineString(name1, name2, name3, PrintUtils.BBPOS_Chinese_Length); return PrintUtils.getLineString(name1, name2, name3, PrintUtils.BBPOS_Chinese_Length);
} }
private static final String font_size_total_amount = "48";
private static final String font_size_pay_type = "48";
private static final String font_size_pay_amuount = "48";
private static final String font_size_integral = "48";
protected String getTakewayPrintContent(PrintTakeawayFormContent printContent, PrinterDeviceBean deviceBean) {
List<HtmlLable> htmlLables = new ArrayList<>();
/**
* 頭部
*/
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getBrand(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center))));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getResturantName(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center))));
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------外送------------------------------"));
htmlLables.add(new HtmlLable(LABLE_H3, printContent.getPayType(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_ALIGN, HtmlContract.value_align_center)));
htmlLables.add(new HtmlLable(LABLE_H4, printContent.getDeliveryTime()));
/**
* 訂單信息
*/
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------------------------------------"));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getOrderNumber())));
htmlLables.add(new HtmlLable(LABLE_H2, printContent.getBillNumber()));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getBillingTime())));
/**
* 食品信息
*/
htmlLables.addAll(getBBPosFoodLineString(printContent.getFoodItemList(), deviceBean));
/**
* 總金額,支付信息
*/
//賬單項(合計,送貨費)
List<PrintBillItem> billItemList = printContent.getBillItemList();
for (PrintBillItem billItem : billItemList) {
htmlLables.addAll(getRowInformation(
new HtmlLable(billItem.getBillName()),
new HtmlLable(billItem.getBillAmount(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last))));
}
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------------------------------------"));
//總金額
htmlLables.addAll(getRowInformation(
new HtmlLable(printContent.getTotalAmountText(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_total_amount)),
new HtmlLable(printContent.getTotalAmount(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_total_amount))));
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------------------------------------"));
if (printContent instanceof PrintTakeawayCheckoutContent) {
//TODO 外送結賬有支付方式
PrintTakeawayCheckoutContent takeawayCheckoutContent = (PrintTakeawayCheckoutContent) printContent;
//支付方式
List<PrintPayTypeItem> payTypeList = takeawayCheckoutContent.getPayTypeList();
for (PrintPayTypeItem payTypeItem : payTypeList) {
htmlLables.addAll(getRowInformation(
new HtmlLable(payTypeItem.getPayName(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_pay_type)),
new HtmlLable(payTypeItem.getPayAmount(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_pay_type))));
}
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------------------------------------"));
}
//支付金額
htmlLables.addAll(getRowInformation(
new HtmlLable(printContent.getPayAmountText(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_pay_amuount)),
new HtmlLable(printContent.getPayAmount(), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_FONT_SIZE, font_size_pay_amuount))));
htmlLables.add(new HtmlLable(LABLE_P, "---------------------------------------------------------------"));
/**
* 會員積分
*/
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberName())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberNumber())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberPhone())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberOldPoints())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberAddPoints())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getMemberNowPoints())));
/**
* 配送信息
*/
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getAdress())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getReceiver())));
htmlLables.addAll(getRowInformation(new HtmlLable(printContent.getPhone())));
return getHtmlLables((HtmlLable[]) htmlLables.toArray());
}
/**
* BBPos公共的食品行打印信息拼裝
*
* @param foodItemList
* @return
*/
protected List<HtmlLable> getBBPosFoodLineString(List<PrintFoodItem> foodItemList, PrinterDeviceBean printerDeviceBean) {
int foodFontSize = 24;
int modifierFontSize = 24;
int foodIsBold = printerDeviceBean.getFoodIsBold();
int modifierIsBold = printerDeviceBean.getModifierIsBold();
int foodIsItalic = printerDeviceBean.getFoodIsItalic();
int modifierIsItalic = printerDeviceBean.getModifierIsItalic();
try {
foodFontSize = Integer.parseInt(printerDeviceBean.getFoodFont()) * 2;
modifierFontSize = Integer.parseInt(printerDeviceBean.getModifierFont()) * 2;
} catch (NumberFormatException e) {
e.printStackTrace();
}
List<String> nameList = new ArrayList<>();
List<Integer> numList = new ArrayList<>();
List<Double> priceList = new ArrayList<>();
List<Integer> itemTypes = new ArrayList<>();
for (int i = 0; i < foodItemList.size(); i++) {
PrintFoodItem foodItem = foodItemList.get(i);
nameList.add(foodItem.getName());
numList.add(foodItem.getNum());
priceList.add(foodItem.getPrice());
itemTypes.add(foodItem.getItemType());
}
List<HtmlLable> htmlLables = new ArrayList<>();
for (int i = 0; i < nameList.size(); i++) {
String name = nameList.get(i);
int num = 0;
double price = -9999;
if (numList.size() > (i + 1)) {
num = numList.get(i);
}
if (priceList.size() > (i + 1)) {
price = priceList.get(i);
}
List<String> name1s = PrintUtils.getFormatList(name, PrintUtils.foodNameSpace, PrintUtils.BBPOS_Chinese_Length);
if (name1s.size() > 1) {
//食品名需要獨佔一行,甚至換行顯示
//需要佔用的行數
int lines = name1s.size() / 2;
if (lines > 1) {
//大於一行
for (int j = 0; j < lines; j++) {
htmlLables.addAll(getRowFoodInformation(name));
}
htmlLables.addAll(getRowFoodInformation(num, price));
} else {
//一行
htmlLables.addAll(getRowFoodInformation(name));
htmlLables.addAll(getRowFoodInformation(num, price));
}
} else {
htmlLables.addAll(getRowFoodInformation(name, num, price));
}
}
return htmlLables;
}
protected String getHtmlLables(HtmlLable... lables) { protected String getHtmlLables(HtmlLable... lables) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (HtmlLable lable : lables) { for (HtmlLable lable : lables) {
if (TextUtils.isEmpty(lable.getValue()) && lable.getAttributesList() == null) { if (lable.getLablename().contains("row") || lable.getLablename().contains("br")) {
//沒有標籤屬性 一般為<row>,<br>標籤直接追加即可 //<row>,<br>標籤直接追加即可
stringBuilder.append(lable.getLablename()); stringBuilder.append(lable.getLablename());
continue; continue;
} }
...@@ -1008,12 +1173,94 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -1008,12 +1173,94 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
protected String traverseAttributes(HtmlLable.Attributes[] attributesMap) { protected String traverseAttributes(HtmlLable.Attributes[] attributesMap) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (HtmlLable.Attributes attributes : attributesMap) { for (HtmlLable.Attributes attributes : attributesMap) {
stringBuilder.append(" " + attributes.getAttributesName() + "="); stringBuilder.append(" ");
stringBuilder.append(attributes.getAttributesVaule()); stringBuilder.append(attributes.getAttributesName());
stringBuilder.append("=");
String attributesVaule = attributes.getAttributesVaule();
if (attributes.getValueType() == HtmlContract.value_type_string) {
stringBuilder.append("\"" + attributes.getAttributesVaule() + "\"");
} else {
if (StringUtils.isNumeric(attributesVaule)) {
stringBuilder.append(attributes.getAttributesVaule());
} else {
stringBuilder.append("\"" + attributes.getAttributesVaule() + "\"");
}
}
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
/**
* 獲取一行信息,多個column
*
* @param lables
* @return
*/
protected List<HtmlLable> getRowInformation(HtmlLable... lables) {
List<HtmlLable> htmlLables = new ArrayList<>();
htmlLables.add(new HtmlLable(getRowLableStart()));
if (lables != null) {
for (HtmlLable lable : lables) {
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, lable.getValue(), lable.getAttributesList()));
}
}
htmlLables.add(new HtmlLable(getRowLableEnd()));
return htmlLables;
}
/**
* 獲取一行食品信息(食品名稱)
*
* @param name
* @return
*/
private List<HtmlLable> getRowFoodInformation(String name) {
List<HtmlLable> htmlLables = new ArrayList<>();
htmlLables.add(new HtmlLable(getRowLableStart()));
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, name));
htmlLables.add(new HtmlLable(getRowLableEnd()));
return htmlLables;
}
/**
* 獲取一行食品信息(數量,金額)
*
* @param num
* @param amount
* @return
*/
private List<HtmlLable> getRowFoodInformation(int num, double amount) {
List<HtmlLable> htmlLables = new ArrayList<>();
htmlLables.add(new HtmlLable(getRowLableStart()));
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, String.valueOf(num), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_percentage_foodNum)));
if (amount != -9999) {
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, String.valueOf(amount), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last)));
}
htmlLables.add(new HtmlLable(getRowLableEnd()));
return htmlLables;
}
/**
* 獲取一行食品信息(食品名稱,數量,金額)
*
* @param name
* @param num
* @param amount
* @return
*/
private List<HtmlLable> getRowFoodInformation(String name, int num, double amount) {
List<HtmlLable> htmlLables = new ArrayList<>();
htmlLables.add(new HtmlLable(getRowLableStart()));
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, name));
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, String.valueOf(num), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_percentage_foodNum)));
if (amount != -9999) {
htmlLables.add(new HtmlLable(HtmlContract.LABLE_COLUMN, String.valueOf(amount), new HtmlLable.Attributes(HtmlContract.ATTRIBUTES_OFFSET, HtmlContract.value_offset_last)));
}
htmlLables.add(new HtmlLable(getRowLableEnd()));
return htmlLables;
}
protected String getRowLableStart() { protected String getRowLableStart() {
return "<row>"; return "<row>";
} }
...@@ -1022,7 +1269,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket ...@@ -1022,7 +1269,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
return "</row>\n"; return "</row>\n";
} }
protected String getRowLableStart(HtmlLable.Attributes ... attributes) { protected String getRowLableStart(HtmlLable.Attributes... attributes) {
return "<row " + traverseAttributes(attributes) + ">"; return "<row " + traverseAttributes(attributes) + ">";
} }
......
...@@ -8,6 +8,9 @@ package com.joe.print.mvp.print.common; ...@@ -8,6 +8,9 @@ package com.joe.print.mvp.print.common;
*/ */
public class HtmlContract { public class HtmlContract {
public static final String LABLE_H2 = "h2";
public static final String LABLE_H3 = "h3";
public static final String LABLE_H4 = "h4";
public static final String LABLE_BR = "br"; public static final String LABLE_BR = "br";
public static final String LABLE_DIV = "div"; public static final String LABLE_DIV = "div";
public static final String LABLE_P = "p"; public static final String LABLE_P = "p";
...@@ -30,7 +33,15 @@ public class HtmlContract { ...@@ -30,7 +33,15 @@ public class HtmlContract {
public static final String value_offset_percentage30 = "0.3"; public static final String value_offset_percentage30 = "0.3";
public static final String value_offset_percentage35 = "0.35"; public static final String value_offset_percentage35 = "0.35";
public static final String value_offset_percentage20 = "0.2"; public static final String value_offset_percentage20 = "0.2";
public static final String value_offset_percentage_foodNum = "0.6";
public static final String value_scale_1 = "1";
public static final String value_align_center = "center"; public static final String value_align_center = "center";
public static final String value_align_right = "right"; public static final String value_align_right = "right";
public static final byte value_type_default = 0;
public static final byte value_type_string = 1;
} }
...@@ -41,7 +41,7 @@ public class BBposPrint { ...@@ -41,7 +41,7 @@ public class BBposPrint {
public void onNext(String s) { public void onNext(String s) {
analysisPrintResult(s, wiseposBean, listener); analysisPrintResult(s, wiseposBean, listener);
} }
// HTML不完整,请确保转义特殊字符
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -5,21 +5,21 @@ import androidx.annotation.Nullable; ...@@ -5,21 +5,21 @@ import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.joe.print.R; import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrintBillBean; import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import java.util.List; import java.util.List;
/** /**
* Created by Wyh on 2020/1/16. * Created by Wyh on 2020/1/16.
*/ */
public class BillItemAdapter extends BaseQuickAdapter<PrintBillBean, BaseViewHolder> { public class BillItemAdapter extends BaseQuickAdapter<PrintBillItem, BaseViewHolder> {
public BillItemAdapter(@Nullable List<PrintBillBean> data) { public BillItemAdapter(@Nullable List<PrintBillItem> data) {
super(R.layout.print_bill_adapter_item_bill, data); super(R.layout.print_bill_adapter_item_bill, data);
} }
@Override @Override
protected void convert(BaseViewHolder helper, PrintBillBean item) { protected void convert(BaseViewHolder helper, PrintBillItem item) {
helper.setText(R.id.print_bill_name, item.getBillName()); helper.setText(R.id.print_bill_name, item.getBillName());
helper.setText(R.id.print_bill_value, item.getBillAmount()); helper.setText(R.id.print_bill_value, item.getBillAmount());
} }
......
...@@ -6,7 +6,6 @@ import android.content.Context; ...@@ -6,7 +6,6 @@ import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart;
import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.base.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder; import com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils; import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
......
...@@ -150,7 +150,6 @@ public class OrderPayPresenter extends BaseOrderPresenter<OrderPayContract.Model ...@@ -150,7 +150,6 @@ public class OrderPayPresenter extends BaseOrderPresenter<OrderPayContract.Model
String payRequest = GsonUtils.GsonString(getOrderPayRequest(orderPayView)); String payRequest = GsonUtils.GsonString(getOrderPayRequest(orderPayView));
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), payRequest); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), payRequest);
String json = GsonUtils.GsonString(payRequest);
mModel.toOrderPay(requestBody) mModel.toOrderPay(requestBody)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
......
...@@ -43,7 +43,6 @@ import com.gingersoft.gsa.cloud.database.bean.Function; ...@@ -43,7 +43,6 @@ import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.bean.Modifier; import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.utils.FoodComboDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FoodComboDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils; import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.function.FunctionManager;
import com.gingersoft.gsa.cloud.ui.widget.dialog.BaseRetryDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.BaseRetryDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
......
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