Commit c3c5c732 by Wyh

8.01 1、食品是否打印至賬單功能 2、外賣接單多種支付方式 3、登陸接口錯誤報警 4、優化外送結賬打印

Signed-off-by: Wyh <1239658231>
parent 19692ff3
...@@ -376,7 +376,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -376,7 +376,7 @@ public class GsaCloudApplication extends BaseApplication {
} }
public static String getGsPosShopId(Context context) { public static String getGsPosShopId(Context context) {
return (String) SPUtils.get(context, UserConstans.gsPosShopId, ""); return (String) SPUtils.get(context, UserConstans.gsPosShopId, "-1");
} }
public static String getAppName() { public static String getAppName() {
......
...@@ -689,35 +689,109 @@ public class OrderDetail implements Serializable { ...@@ -689,35 +689,109 @@ public class OrderDetail implements Serializable {
List<OrderDetail> orderDetailList = new ArrayList<>(); List<OrderDetail> orderDetailList = new ArrayList<>();
if (productnameBeans != null) { if (productnameBeans != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean productnameBean : productnameBeans) { for (OrderDetails.DataBean.PRODUCTNAMEBean productnameBean : productnameBeans) {
if (!(productnameBean.getPrintToBill() == 0 && Double.valueOf(productnameBean.getPRICE()) == 0) //遍歷食品信息,查詢是否需要打印
|| isPrint(productnameBean.getPrintTo(), type)) {
//食品金額不為0的不打印 //沒有價格的情況下,勾選了就打印,沒勾選就不打印
//或者printTo成立 //有價格的情況下,就會打印,不管有沒有勾選,如果是細項就只打印細項,如果是主項就只打印主項
//打印 //
orderDetailList.add(getOrderDetailByProductnameBean(productnameBean.getPRODUCT_NAME(), Integer.parseInt(productnameBean.getNum()), Double.valueOf(productnameBean.getPRICE()), 1)); //只要勾選了打印,不論有沒有價格都會打印
if (productnameBean.getChild() != null) { //細項只要勾選了,主項就會打印
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX : productnameBean.getChild()) {
if (childBeanX != null) { //如果細項勾選了,則不管主項的配置,都會打印主項
orderDetailList.add(getOrderDetailByProductnameBean(childBeanX.getPRODUCT_NAME(), Integer.parseInt(childBeanX.getNum()), Double.valueOf(childBeanX.getPRICE()), 2)); //如果細項沒勾選,就判斷是否有價格,修改isPrint
if (childBeanX.getChild() != null) { boolean isCheck = false;
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean childBean : childBeanX.getChild()) { boolean isCheck2 = false;//二級細項
orderDetailList.add(getOrderDetailByProductnameBean(childBean.getPRODUCT_NAME(), Integer.parseInt(childBean.getNum()), Double.valueOf(childBean.getPRICE()), 3)); if (productnameBean.getChild() != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX : productnameBean.getChild()) {
if (childBeanX != null) {
//判斷是否打印,為true的時候會同時打印主項
if (isPrint(childBeanX.getPrintTo(), type)) {
isCheck = true;
break;
}
if (childBeanX.getChild() != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean childBean : childBeanX.getChild()) {
//判斷是否打印,為true的時候會同時打印主項
if (isPrint(childBean.getPrintTo(), type)) {
isCheck2 = true;
break;
} }
} }
} }
} }
} }
} }
if (isCheck || isPrint(productnameBean.getPrintToBill(), Double.valueOf(productnameBean.getPRICE()), productnameBean.getPrintTo(), type)) {
// 細項勾選了||主項勾選了||主項價格不為0 主項就會打印
orderDetailList.add(getOrderDetailByProductnameBean(productnameBean.getPRODUCT_NAME(), Integer.parseInt(productnameBean.getNum()), Double.valueOf(productnameBean.getPRICE()), 1));
addFoodItem(type, orderDetailList, productnameBean, isCheck2);
} else {
//主項沒勾選&&主項價格為0&&細項也沒勾選
//那麼,不打印主項,查詢細項如果有價格就會打印
addFoodItem(type, orderDetailList, productnameBean, isCheck2);
}
} }
} }
return orderDetailList; return orderDetailList;
} }
/** /**
* 添加細項
*
* @param type
* @param orderDetailList
* @param productnameBean
* @param isCheck2
*/
private static void addFoodItem(int type, List<OrderDetail> orderDetailList, OrderDetails.DataBean.PRODUCTNAMEBean productnameBean, boolean isCheck2) {
if (productnameBean.getChild() == null) {
return;
}
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX : productnameBean.getChild()) {
if (childBeanX != null) {
if (isCheck2 || isPrint(childBeanX.getPrintToBill(), Double.valueOf(childBeanX.getPRICE()), childBeanX.getPrintTo(), type)) {
// 二級細項勾選了||細項勾選了||細項價格不為0 主項就會打印
orderDetailList.add(getOrderDetailByProductnameBean(childBeanX.getPRODUCT_NAME(), Integer.parseInt(childBeanX.getNum()), Double.valueOf(childBeanX.getPRICE()), 2));
addSecondFood(type, orderDetailList, childBeanX);
} else {
//二級細項沒勾選 && 細項也沒勾選了 && 細項價格為0
//那麼,不打印細項,查詢二級細項如果有價格就會打印
addSecondFood(type, orderDetailList, childBeanX);
}
}
}
}
/**
* 添加二級細項
*
* @param type
* @param orderDetailList
* @param childBeanX
*/
private static void addSecondFood(int type, List<OrderDetail> orderDetailList, OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX) {
if (childBeanX.getChild() != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean childBean : childBeanX.getChild()) {
if (isPrint(childBeanX.getPrintToBill(), Double.valueOf(childBeanX.getPRICE()), childBeanX.getPrintTo(), type)) {
//如果二級細項勾選了||價格不為0 二級細項就打印
orderDetailList.add(getOrderDetailByProductnameBean(childBean.getPRODUCT_NAME(), Integer.parseInt(childBean.getNum()), Double.valueOf(childBean.getPRICE()), 3));
}
}
}
}
private static boolean isPrint(int printToBill, double price, int printTo, int type) {
//printTo和price不為0 都會打印
return (!(printToBill == 0 && price == 0) || isPrint(printTo, type));
}
/**
* 是否打印 * 是否打印
* *
* @param printTo * @param printTo
* @param type 食品清單還是賬單 0 食品清單,1 賬單 * @param type 食品清單還是賬單 0 食品清單,1 賬單
* @return * @return
*/ */
public static boolean isPrint(int printTo, int type) { public static boolean isPrint(int printTo, int type) {
......
...@@ -260,7 +260,7 @@ public class OkHttp3Utils { ...@@ -260,7 +260,7 @@ public class OkHttp3Utils {
.add("code", errCode)//錯誤碼 .add("code", errCode)//錯誤碼
.add("shopId", GsaCloudApplication.getGsPosShopId(GsaCloudApplication.getAppContext())) .add("shopId", GsaCloudApplication.getGsPosShopId(GsaCloudApplication.getAppContext()))
.add("source", GsaCloudApplication.getAppName() + "")//錯誤來源 .add("source", GsaCloudApplication.getAppName() + "")//錯誤來源
.add("pushContent", pushContent + "")//推送內容 .add("pushContent", "報錯內容:" + pushContent)//推送內容
.add("version", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext()))//系統版本 .add("version", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext()))//系統版本
.build(); .build();
OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/monitor/pushAlarm", requestBody) OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/monitor/pushAlarm", requestBody)
......
...@@ -78,62 +78,6 @@ public class ImageUtils { ...@@ -78,62 +78,6 @@ public class ImageUtils {
return gray; return gray;
} }
/* *************************************************************************
* 假设一个240*240的图片,分辨率设为24, 共分10行打印
* 每一行,是一个 240*24 的点阵, 每一列有24个点,存储在3个byte里面。
* 每个byte存储8个像素点信息。因为只有黑白两色,所以对应为1的位是黑色,对应为0的位是白色
**************************************************************************/
/**
* 把一张Bitmap图片转化为打印机可以打印的字节流
*
* @param bmp
* @return
*/
public static byte[] draw2PxPoint(Bitmap bmp) {
//用来存储转换后的 bitmap 数据。为什么要再加1000,这是为了应对当图片高度无法
//整除24时的情况。比如bitmap 分辨率为 240 * 250,占用 7500 byte,5:5455,3,5447,4,5427
//但是实际上要存储11行数据,每一行需要 24 * 240 / 8 =720byte 的空间。再加上一些指令存储的开销,
//所以多申请 1000byte 的空间是稳妥的,不然运行时会抛出数组访问越界的异常。
int extra = bmp.getWidth() * 24 / 8;
int size = bmp.getWidth() * bmp.getHeight() / 8 + extra;
byte[] data = new byte[size];
int k = 0;
//设置行距为0的指令
data[k++] = 0x1B;
data[k++] = 0x33;
data[k++] = 0x00;
// 逐行打印
for (int j = 0; j < bmp.getHeight() / 24f; j++) {
//打印图片的指令
data[k++] = 0x1B;
data[k++] = 0x2A;
data[k++] = 33;
data[k++] = (byte) (bmp.getWidth() % 256); //nL
data[k++] = (byte) (bmp.getWidth() / 256); //nH
//对于每一行,逐列打印
for (int i = 0; i < bmp.getWidth(); i++) {
//每一列24个像素点,分为3个字节存储
for (int m = 0; m < 3; m++) {
//每个字节表示8个像素点,0表示白色,1表示黑色
for (int n = 0; n < 8; n++) {
byte b = px2Byte(i, j * 24 + m * 8 + n, bmp);
data[k] += data[k] + b;
}
k++;
}
}
data[k++] = 10;//换行
}
// long a=System.currentTimeMillis();
// byte[] data1 = new byte[k];
// System.arraycopy(data, 0, data1, 0, k);
// long b=System.currentTimeMillis();
// System.out.println("结束字节:"+k+"---"+data.length+"耗时:"+(b-a));
return data;
}
public int getStatus() { public int getStatus() {
return errorcode; return errorcode;
} }
......
...@@ -7,9 +7,9 @@ public class AppConstans { ...@@ -7,9 +7,9 @@ public class AppConstans {
public static final String RP_HEART_ERROR = "RP_HD001";//心跳斷開錯誤碼 public static final String RP_HEART_ERROR = "RP_HD001";//心跳斷開錯誤碼
public static final String RP_ORDER_LIST_ERROR = "RP_OL002";//訂單列表錯誤碼 public static final String RP_ORDER_LIST_ERROR = "RP_OL002";//訂單列表錯誤碼
public static final String RP_THIRE_LOGISTICS_ERROR = "RP_WL003";//訂單列表錯誤碼 public static final String RP_THIRE_LOGISTICS_ERROR = "RP_WL003";//第三方物流接口錯誤碼
public static final String RP_UPDATE_ORDER_STATE_ERROR = "RP_UO_";//修改訂單狀態失敗錯誤碼 public static final String RP_UPDATE_ORDER_STATE_ERROR = "RP_UO004";//修改訂單狀態失敗錯誤碼
public static final String RP_LOGIN_ERROR = "RP_LOGIN";//修改訂單狀態失敗錯誤碼 public static final String RP_LOGIN_ERROR = "RP_LOGIN";//登陸報錯錯誤碼
public static final String SECRETKEY_VALUES = "2309485937845783"; public static final String SECRETKEY_VALUES = "2309485937845783";
......
...@@ -2,7 +2,11 @@ package com.gingersoft.gsa.cloud.constans; ...@@ -2,7 +2,11 @@ package com.gingersoft.gsa.cloud.constans;
public class ExpandConstant { public class ExpandConstant {
public final static String DeliveryPrintCount = "DeliveryPrintCount"; public final static String DeliveryPrintCount = "DeliveryPrintCount";//外送印單打印次數
public final static String DeliveryClosingPC = "DeliveryClosingPC";//外送結賬打印次數
public final static String TableModePrintCount = "TableModePrintCount";//餐檯印單打印次數
public final static String TableModeClosingPC = "TableModeClosingPC";//餐檯模式結賬單打印次數
public final static String Rounding = "Rounding"; public final static String Rounding = "Rounding";
public final static String RoundingDecimal = "RoundingDecimal"; public final static String RoundingDecimal = "RoundingDecimal";
......
...@@ -75,9 +75,17 @@ class OrderDetails { ...@@ -75,9 +75,17 @@ class OrderDetails {
var order_type: Int = 0 var order_type: Int = 0
var orderPayType: Int = 0//0店內支付,1為貨到付款,2是在線支付 var orderPayType: Int = 0//0店內支付,1為貨到付款,2是在線支付
var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送 var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送
var payTime: String? = null
//
var payType: Int = 0//1:積分支付;2:支付寶;3:财付通;4:微信支付;5:貨到付款;6:其他支付 var payType: Int = 0//1:積分支付;2:支付寶;3:财付通;4:微信支付;5:貨到付款;6:其他支付
var payName: String? = null var payName: String? = null
var payTime: String? = null var payAmount: Double = 0.0
//
// var payType2: Int = 0//1:積分支付;2:支付寶;3:财付通;4:微信支付;5:貨到付款;6:其他支付
// var payName2: String? = null
// var payAmount2: Double = 0.0
var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null
var couponList: List<CouponBean>? = null var couponList: List<CouponBean>? = null
...@@ -88,7 +96,7 @@ class OrderDetails { ...@@ -88,7 +96,7 @@ class OrderDetails {
var addPoints: Double = 0.toDouble()//本次加多少積分 var addPoints: Double = 0.toDouble()//本次加多少積分
var oldPoints: Double = 0.toDouble()//之前有多少積分 var oldPoints: Double = 0.toDouble()//之前有多少積分
var nowPoints: Double = 0.toDouble()//現在有多少積分 var nowPoints: Double = 0.toDouble()//現在有多少積分
var orderPayInfoVO: List<OrderPayAmountVo>? = null
var curStat: Int = 0//訂單已創建 1 var curStat: Int = 0//訂單已創建 1
// * * Order Assigned To Delivery Man - 配送員已接單 2 // * * Order Assigned To Delivery Man - 配送員已接單 2
// * * Delivery Man Reached Pickup Point Nearby - 配送員已到達店鋪附近 3 // * * Delivery Man Reached Pickup Point Nearby - 配送員已到達店鋪附近 3
...@@ -116,12 +124,14 @@ class OrderDetails { ...@@ -116,12 +124,14 @@ class OrderDetails {
var PRODUCT_NAME: String? = null var PRODUCT_NAME: String? = null
var child: List<ChildBeanX>? = null var child: List<ChildBeanX>? = null
var printseting: String? = null var printseting: String? = null
var printToBill: Int = 1 //當金額=0時,是否打印在賬單上 0 否 1 是 var printToBill: Int = 1 //當金額=0時,是否打印在賬單上 0 否 1 是
//0食品清单打印 账单打印 //0食品清单打印 账单打印
//1食品清单不打印 账单不打印 //1食品清单不打印 账单不打印
//2食品清单打印 账单不打印 //2食品清单打印 账单不打印
//3食品清单不打印 账单打印 //3食品清单不打印 账单打印
var PrintTo: Int = 0 var printTo: Int = 0
class ChildBeanX : Serializable { class ChildBeanX : Serializable {
/** /**
...@@ -139,6 +149,12 @@ class OrderDetails { ...@@ -139,6 +149,12 @@ class OrderDetails {
var PRODUCT_NAME: String? = null var PRODUCT_NAME: String? = null
var child: List<ChildBean>? = null var child: List<ChildBean>? = null
var printseting: String? = null var printseting: String? = null
var printToBill: Int = 1 //當金額=0時,是否打印在賬單上 0 否 1 是
//0食品清单打印 账单打印
//1食品清单不打印 账单不打印
//2食品清单打印 账单不打印
//3食品清单不打印 账单打印
var printTo: Int = 0
class ChildBean : Serializable { class ChildBean : Serializable {
/** /**
...@@ -154,10 +170,17 @@ class OrderDetails { ...@@ -154,10 +170,17 @@ class OrderDetails {
var pid: String? = null var pid: String? = null
var PRODUCT_NAME: String? = null var PRODUCT_NAME: String? = null
var printseting: String? = null var printseting: String? = null
var printToBill: Int = 1 //當金額=0時,是否打印在賬單上 0 否 1 是
//0食品清单打印 账单打印
//1食品清单不打印 账单不打印
//2食品清单打印 账单不打印
//3食品清单不打印 账单打印
var printTo: Int = 0
} }
} }
} }
data class OrderPayAmountVo(var payTypeId: Int, var amount: Double, var payName: String) : Serializable
data class CouponBean(val couponName: String, val discount_amount: Float) : Serializable data class CouponBean(val couponName: String, val discount_amount: Float) : Serializable
} }
} }
\ No newline at end of file
...@@ -7,8 +7,8 @@ ext { ...@@ -7,8 +7,8 @@ ext {
targetSdkVersion : 28, targetSdkVersion : 28,
//正式版: 1.0.3 3 //正式版: 1.0.3 3
//內部測試版:1.2.0 20 //內部測試版:1.2.0 20
versionCode : 20, versionCode : 21,
versionName : "1.2.0" versionName : "1.2.1"
] ]
version = [ version = [
......
...@@ -85,7 +85,6 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas ...@@ -85,7 +85,6 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
} else { } else {
GsaCloudApplication.isLogin = false; GsaCloudApplication.isLogin = false;
mRootView.showMessage(info.getErrMsg()); mRootView.showMessage(info.getErrMsg());
OkHttp3Utils.noticePersonnel(AppConstans.RP_LOGIN_ERROR, info.getErrMsg());
if (IAcitivity instanceof LoginActivity) { if (IAcitivity instanceof LoginActivity) {
......
package com.gingersoft.gsa.other_order_mode.data package com.gingersoft.gsa.other_order_mode.data
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.JsonUtils
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
import com.gingersoft.gsa.cloud.constans.AppConstans import com.gingersoft.gsa.cloud.constans.AppConstans
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.ThirdItem import com.gingersoft.gsa.other_order_mode.data.model.bean.ThirdItem
import com.gingersoft.gsa.other_order_mode.data.model.bean.UpdateOrderStatusBean
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import com.google.gson.Gson import com.google.gson.Gson
import com.jess.arms.utils.DeviceUtils import com.jess.arms.utils.DeviceUtils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody import okhttp3.RequestBody
import kotlin.Pair as Pair1 import kotlin.Pair as Pair1
...@@ -78,11 +84,11 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -78,11 +84,11 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
// } // }
suspend fun gsUpdateOrderStatus(orderId: String, status: Int, orderType: Int, type: Int, sendDate: String?, suspend fun gsUpdateOrderStatus(orderId: Int, status: Int, orderType: Int, type: Int, sendDate: String = "",
sender: String, sendmobile: String, reasonId: String, reasonDesc: String, sender: String = "", sendmobile: String = "", reasonId: String = "", reasonDesc: String = "",
confirmationType: Int, orderFrom: Int, payTypeId: Int = 0) = withContext(Dispatchers.IO) { confirmationType: Int = 1, orderFrom: Int = 0) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("orderId", orderId)//訂單id .add("orderId", orderId.toString())//訂單id
.add("status", status.toString())//订单状态#0:未支付;1:待確認(已支付, 待餐廳確認);2:制作中(餐廳确認);3:派送中;4:确認收貨(完成);5:是否評論;6:取消; .add("status", status.toString())//订单状态#0:未支付;1:待確認(已支付, 待餐廳確認);2:制作中(餐廳确認);3:派送中;4:确認收貨(完成);5:是否評論;6:取消;
.add("orderType", orderType.toString())//訂單類型#1:餐廳訂單;2:線上外賣訂單3:扫码点餐;4固定二维码订单;5:预点餐;6:積分訂單;7:自取订单' .add("orderType", orderType.toString())//訂單類型#1:餐廳訂單;2:線上外賣訂單3:扫码点餐;4固定二维码订单;5:预点餐;6:積分訂單;7:自取订单'
.add("type", type.toString())//通知類型:1.未定,2:外賣 .add("type", type.toString())//通知類型:1.未定,2:外賣
...@@ -91,13 +97,21 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -91,13 +97,21 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
.add("sendmobile", sendmobile)//送餐員電話 .add("sendmobile", sendmobile)//送餐員電話
.add("reasonId", reasonId)//原因id .add("reasonId", reasonId)//原因id
.add("reasonDesc", reasonDesc)//原因描敘 .add("reasonDesc", reasonDesc)//原因描敘
.add("payTypeId", payTypeId.toString())
.add("confirmationType", confirmationType.toString())//接單類型,1 手動接單 2,自動接單 .add("confirmationType", confirmationType.toString())//接單類型,1 手動接單 2,自動接單
.add("orderFrom", orderFrom.toString())//订单来源#1:ios;2:安卓;3:gspos;4:web;5:第三方POS A;6:第三方POS B; .add("orderFrom", orderFrom.toString())//订单来源#1:ios;2:安卓;3:gspos;4:web;5:第三方POS A;6:第三方POS B;
.build() .build()
network.gsUpdateOrderStatus(requestBody) network.gsUpdateOrderStatus(requestBody)
} }
suspend fun updateOrderPay(orderId: Int, status: Int, orderType: Int, type: Int, sendDate: String = "",
sender: String = "", sendmobile: String = "", reasonId: String = "", reasonDesc: String = "",
confirmationType: Int = 1, orderFrom: Int = 0, orderPayInfoVO: List<OrderDetails.DataBean.OrderPayAmountVo>? = null) = withContext(Dispatchers.IO) {
val updateOrderStatusBean = UpdateOrderStatusBean(orderFrom, orderId, orderPayInfoVO, sendDate, sender, sendmobile, status, type, orderType, reasonId, reasonDesc, confirmationType)
val payRequest = GsonUtils.GsonString(updateOrderStatusBean)
val requestBody = RequestBody.create(MediaType.parse("application/json"), payRequest)
network.updateOrderPay(requestBody)
}
suspend fun updateIsRead(orderId: String) = withContext(Dispatchers.IO) { suspend fun updateIsRead(orderId: String) = withContext(Dispatchers.IO) {
network.updateIsRead(getBody("id" to orderId)) network.updateIsRead(getBody("id" to orderId))
} }
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
/**
* 更新訂單狀態提交數據類
* http://gingersoft.tpddns.cn:53000/project/24/interface/api/5716
*/
data class UpdateOrderStatusBean(var orderFrom: Int, var orderId: Int, var orderPayInfoVO: List<OrderDetails.DataBean.OrderPayAmountVo>?,
var sendDate: String, var sender: String,var sendmobile: String,var status: Int,var type: Int,var orderType: Int,
var reasonId: String, var reasonDesc: String,
var confirmationType: Int)
...@@ -2,7 +2,6 @@ package com.gingersoft.gsa.other_order_mode.data.network ...@@ -2,7 +2,6 @@ package com.gingersoft.gsa.other_order_mode.data.network
import com.gingersoft.gsa.other_order_mode.data.network.api.AppService import com.gingersoft.gsa.other_order_mode.data.network.api.AppService
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.FormBody
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
...@@ -22,6 +21,9 @@ class CoolWeatherNetwork { ...@@ -22,6 +21,9 @@ class CoolWeatherNetwork {
private val gsposService = ServiceCreator.create3(WeatherService::class.java) private val gsposService = ServiceCreator.create3(WeatherService::class.java)
private val cloudService = ServiceCreator.create4(WeatherService::class.java) private val cloudService = ServiceCreator.create4(WeatherService::class.java)
private val orderPayService = ServiceCreator.create5(WeatherService::class.java)
//獲取訂單列表 //獲取訂單列表
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await() suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
...@@ -43,6 +45,9 @@ class CoolWeatherNetwork { ...@@ -43,6 +45,9 @@ class CoolWeatherNetwork {
//gspost修改訂單狀態 //gspost修改訂單狀態
suspend fun gsUpdateOrderStatus(requestBody: RequestBody) = service.gsUpdateOrderStatus(requestBody).await() suspend fun gsUpdateOrderStatus(requestBody: RequestBody) = service.gsUpdateOrderStatus(requestBody).await()
//支付
suspend fun updateOrderPay(requestBody: RequestBody) = orderPayService.updateOrderPay(requestBody).await()
//第三方配送接口 //第三方配送接口
suspend fun thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await() suspend fun thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await()
......
...@@ -31,6 +31,9 @@ object ServiceCreator { ...@@ -31,6 +31,9 @@ object ServiceCreator {
private var BASE_URL = "$ROOT_URL/ricepon-wechat/api/" private var BASE_URL = "$ROOT_URL/ricepon-wechat/api/"
private var BASE_URL2 = "$ROOT_URL/member-web/api/" private var BASE_URL2 = "$ROOT_URL/member-web/api/"
private var BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/" private var BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/"
private var BASE_URL4 = "$ROOT_URL/ricepon-order/api/"
private val builder = Retrofit.Builder() private val builder = Retrofit.Builder()
.baseUrl(BASE_URL) .baseUrl(BASE_URL)
.client(httpClient.build()) .client(httpClient.build())
...@@ -55,6 +58,11 @@ object ServiceCreator { ...@@ -55,6 +58,11 @@ object ServiceCreator {
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
private val builder5 = Retrofit.Builder()
.baseUrl(BASE_URL4)
.client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
fun <T> create(serviceClass: Class<T>): T = builder.build().create(serviceClass) fun <T> create(serviceClass: Class<T>): T = builder.build().create(serviceClass)
fun <T> create2(serviceClass: Class<T>): T = builder2.build().create(serviceClass) fun <T> create2(serviceClass: Class<T>): T = builder2.build().create(serviceClass)
...@@ -63,6 +71,8 @@ object ServiceCreator { ...@@ -63,6 +71,8 @@ object ServiceCreator {
fun <T> create4(serviceClass: Class<T>): T = builder4.build().create(serviceClass) fun <T> create4(serviceClass: Class<T>): T = builder4.build().create(serviceClass)
fun <T> create5(serviceClass: Class<T>): T = builder5.build().create(serviceClass)
/** /**
* 添加请求头 * 添加请求头
*/ */
......
...@@ -30,6 +30,9 @@ interface WeatherService { ...@@ -30,6 +30,9 @@ interface WeatherService {
@POST("order/updateOrderStatus") @POST("order/updateOrderStatus")
fun gsUpdateOrderStatus(@Body requestBody: RequestBody): Call<MessageBean> fun gsUpdateOrderStatus(@Body requestBody: RequestBody): Call<MessageBean>
@POST("order/updateOrderPay")
fun updateOrderPay(@Body requestBody: RequestBody): Call<MessageBean>
@POST("gsa/shipAnyOrdersNew") @POST("gsa/shipAnyOrdersNew")
fun thirdDelivery(@Body requestBody: RequestBody): Call<ThirdSend> fun thirdDelivery(@Body requestBody: RequestBody): Call<ThirdSend>
......
...@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager ...@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.billy.cc.core.component.CC import com.billy.cc.core.component.CC
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
...@@ -35,6 +36,9 @@ import com.jess.arms.utils.ArmsUtils ...@@ -35,6 +36,9 @@ import com.jess.arms.utils.ArmsUtils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
import java.lang.NullPointerException import java.lang.NullPointerException
class PageViewModel(private val repository: WeatherRepository) : ViewModel() { class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
...@@ -319,7 +323,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -319,7 +323,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
BtnBuilder.ProductionCompletedBtn -> { BtnBuilder.ProductionCompletedBtn -> {
//製作完成 //製作完成
repository.gsUpdateOrderStatus(dataBean.ID.toString(), 3, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply { repository.gsUpdateOrderStatus(dataBean.ID, 3, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
listener.invoke(getMsgBean(ProductionComplete, errorMsg, code == "1")) listener.invoke(getMsgBean(ProductionComplete, errorMsg, code == "1"))
} }
} }
...@@ -333,12 +337,39 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -333,12 +337,39 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}) })
} }
fun closingBill(orderDetails: OrderDetails.DataBean, payMethods: List<PayMethod>, listener: (Int, Boolean) -> Unit) {
launch({
val orderPayInfoVO = ArrayList<OrderDetails.DataBean.OrderPayAmountVo>()
payMethods.forEach {
orderPayInfoVO.add(OrderDetails.DataBean.OrderPayAmountVo(it.id, it.payMoney, it.payName))
}
repository.updateOrderPay(orderDetails.ID, 4, orderDetails.order_type, 3, orderPayInfoVO = orderPayInfoVO).apply {
orderDetails.orderPayInfoVO = orderPayInfoVO
orderDetails.payTime = TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)
val bean = GsonUtils.GsonToBean(GsonUtils.GsonString(data), OrderClosingBean::class.java)
if (bean != null) {
orderDetails.oldPoints = bean.oldPoints
orderDetails.nowPoints = bean.nowPoints
orderDetails.addPoints = bean.addPoints
}
printOrderClosing(orderDetails, listener)
}
}, {
listener.invoke(OrderDelivery, false)
it.printStackTrace()
Log.e("eee", "gsUpdateOrderStatus報錯:" + it.message)
// integralBean.postValue(null)
})
}
fun gsUpdateOrderStatus(orderDetails: OrderDetails.DataBean, payTypeId: Int = 0, payName: String?, listener: (Int, Boolean) -> Unit) {
fun gsUpdateOrderStatus(orderDetails: OrderDetails.DataBean, orderPayInfoVO: List<OrderDetails.DataBean.OrderPayAmountVo>?, listener: (Int, Boolean) -> Unit) {
launch({ launch({
repository.gsUpdateOrderStatus(orderDetails.ID.toString(), 4, orderDetails.order_type, 3, "", "", "", "0", "", 1, 0, payTypeId).apply { repository.gsUpdateOrderStatus(orderDetails.ID, 4, orderDetails.order_type, 3, orderFrom = 0).apply {
orderDetails.payType = payTypeId orderDetails.orderPayInfoVO = orderPayInfoVO
orderDetails.payName = payName // orderDetails.payType = payTypeId
// orderDetails.payName = payName
orderDetails.payTime = TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT) orderDetails.payTime = TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)
val bean = GsonUtils.GsonToBean(GsonUtils.GsonString(data), OrderClosingBean::class.java) val bean = GsonUtils.GsonToBean(GsonUtils.GsonString(data), OrderClosingBean::class.java)
orderDetails.oldPoints = bean.oldPoints orderDetails.oldPoints = bean.oldPoints
...@@ -354,12 +385,24 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -354,12 +385,24 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}) })
} }
fun converToJson(vararg pair: Pair<String, String>): String {
val array = JSONArray()
array.apply {
pair.forEach {
val obj = JSONObject()
obj.put(it.first, it.second)
put(obj)
}
}
return array.toString()
}
/** /**
* 修改訂單狀態並打印 * 修改訂單狀態並打印
*/ */
private suspend fun updateOrderAndPrint(restaurantId: String, dataBean: OrderDetails.DataBean, status: Int, listener: (MessageBean) -> Unit) { private suspend fun updateOrderAndPrint(restaurantId: String, dataBean: OrderDetails.DataBean, status: Int, listener: (MessageBean) -> Unit) {
launch({ launch({
repository.gsUpdateOrderStatus(dataBean.ID.toString(), status, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply { repository.gsUpdateOrderStatus(dataBean.ID, status, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
if (status == 0 || status == 1 || status == 2) { if (status == 0 || status == 1 || status == 2) {
//確認送單 //確認送單
//添加數據到prj //添加數據到prj
...@@ -385,6 +428,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -385,6 +428,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
launch({ launch({
//添加PRJ
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯 //單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString()) repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString())
GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString()) GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
...@@ -417,7 +461,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -417,7 +461,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
}, { }, {
OkHttp3Utils.noticePersonnel(AppConstans.RP_UPDATE_ORDER_STATE_ERROR + status, it.message) OkHttp3Utils.noticePersonnel(AppConstans.RP_UPDATE_ORDER_STATE_ERROR, "訂單狀態" + status + it.message)
listener.invoke(getMsgBean(OrderDelivery, "", false)) listener.invoke(getMsgBean(OrderDelivery, "", false))
}) })
} }
...@@ -548,7 +592,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -548,7 +592,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
confirmBtn.setOnClickListener { confirmBtn.setOnClickListener {
if (selectIndex != -1) { if (selectIndex != -1) {
launch({ launch({
repository.gsUpdateOrderStatus(dataBean.ID.toString(), status, dataBean.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply { repository.gsUpdateOrderStatus(dataBean.ID, status, dataBean.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply {
if (code == "1") { if (code == "1") {
dialog?.dismiss() dialog?.dismiss()
//回調 //回調
......
...@@ -144,7 +144,7 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -144,7 +144,7 @@ class OrderDetailsActivity : BaseActivity() {
btnList.add(BtnBuilder().getSureBtn()) btnList.add(BtnBuilder().getSureBtn())
btnList.add(BtnBuilder().getCancelBtn()) btnList.add(BtnBuilder().getCancelBtn())
orderStatusText = "待確認" orderStatusText = "待確認"
tv_order_state.setTextColor(resources.getColor(R.color.order_state0_color)) tv_order_state.setTextColor(ContextCompat.getColor(this@OrderDetailsActivity, R.color.order_state0_color))
} }
} }
if (orderDetails.orderPayType == 2 && orderDetails.payName != null) { if (orderDetails.orderPayType == 2 && orderDetails.payName != null) {
...@@ -178,7 +178,7 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -178,7 +178,7 @@ class OrderDetailsActivity : BaseActivity() {
BtnBuilder.closingBtn -> { BtnBuilder.closingBtn -> {
//如果是在線支付的訂單,就直接修改訂單狀態 //如果是在線支付的訂單,就直接修改訂單狀態
if (orderPayType != 1) { if (orderPayType != 1) {
gsUpdateOrderStatus(orderDetails, orderDetails.order_type, orderDetails.payName) { status, isSuccess -> gsUpdateOrderStatus(orderDetails, null) { status, isSuccess ->
if (isSuccess) { if (isSuccess) {
finish() finish()
} else { } else {
......
...@@ -71,11 +71,18 @@ class PayActivity : BaseActivity() { ...@@ -71,11 +71,18 @@ class PayActivity : BaseActivity() {
hepler.getView<TextView>(R.id.tv_dialog_confirm).setOnClickListener { hepler.getView<TextView>(R.id.tv_dialog_confirm).setOnClickListener {
dialog.dismiss() dialog.dismiss()
showLoading() showLoading()
pageViewModel.gsUpdateOrderStatus(orderDetails, payMethods[0].id, payMethods[0].name) { _, _ ->
pageViewModel.closingBill(orderDetails, payMethods){_, _ ->
cancelDialogForLoading() cancelDialogForLoading()
setResult(RESULT_OK) setResult(RESULT_OK)
finish() finish()
} }
// pageViewModel.gsUpdateOrderStatus(orderDetails, payMethods[0].id, payMethods[0].name) { _, _ ->
// cancelDialogForLoading()
// setResult(RESULT_OK)
// finish()
// }
} }
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener { hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss() dialog.dismiss()
......
...@@ -43,13 +43,13 @@ public class EpsonPrint implements ReceiveListener { ...@@ -43,13 +43,13 @@ public class EpsonPrint implements ReceiveListener {
* @return * @return
*/ */
public boolean initializeObject(Context context, ReceiveListener receiveListener) { public boolean initializeObject(Context context, ReceiveListener receiveListener) {
if (mPrinter != null) { // if (mPrinter != null) {
return true; // return true;
} // }
try { try {
this.receiveListener = receiveListener; this.receiveListener = receiveListener;
//第一個參數是機型,第二個參數是語言, //第一個參數是機型,第二個參數是語言,
mPrinter = new Printer(Printer.TM_U220, Printer.MODEL_TAIWAN, context); mPrinter = new Printer(Printer.TM_U220, Printer.MODEL_KOREAN, context);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
...@@ -295,7 +295,6 @@ public class EpsonPrint implements ReceiveListener { ...@@ -295,7 +295,6 @@ public class EpsonPrint implements ReceiveListener {
} }
mPrinter.addFeedLine(1); mPrinter.addFeedLine(1);
} }
mPrinter.addPulse(Printer.DRAWER_LOW, Printer.PULSE_100);
mPrinter.addCut(Printer.CUT_FEED); mPrinter.addCut(Printer.CUT_FEED);
mPrinter.sendData(Printer.PARAM_DEFAULT); mPrinter.sendData(Printer.PARAM_DEFAULT);
} catch (Exception e) { } catch (Exception e) {
...@@ -304,13 +303,14 @@ public class EpsonPrint implements ReceiveListener { ...@@ -304,13 +303,14 @@ public class EpsonPrint implements ReceiveListener {
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
} }
} }
private int location = 0; private int location = 0;
private void print(PrintInfoBean printInfoBean, int i, int paperWidth) throws Epos2Exception { private void print(PrintInfoBean printInfoBean, int i, int paperWidth) throws Epos2Exception {
if (i == 0) { if (i == 0) {
location = 0; location = 0;
} }
int textSize = (int) MyPrintUtils.getContentByLength(printInfoBean.getSize(), i); int textSize = Double.valueOf(String.valueOf(MyPrintUtils.getContentByLength(printInfoBean.getSize(), i))).intValue();
//是否傾斜字體 //是否傾斜字體
int isItalic = ((Boolean) MyPrintUtils.getContentByLength(printInfoBean.getIsItalic(), i)) ? 1 : 0; int isItalic = ((Boolean) MyPrintUtils.getContentByLength(printInfoBean.getIsItalic(), i)) ? 1 : 0;
......
...@@ -68,7 +68,6 @@ public class LocationPrintStatus { ...@@ -68,7 +68,6 @@ public class LocationPrintStatus {
switch (status) { switch (status) {
case 0: //可以打印 case 0: //可以打印
// N5PrintCallback printCallBack = new N5PrintCallback(context); // N5PrintCallback printCallBack = new N5PrintCallback(context);
// PrinterUtil.registerCallback(printCallBack);
return true; return true;
case -1009: //打印未完成 case -1009: //打印未完成
String notCompleted = LanguageUtils.get_language_system(context, "print.not.completed", "打印未完成"); String notCompleted = LanguageUtils.get_language_system(context, "print.not.completed", "打印未完成");
......
...@@ -12,7 +12,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage; ...@@ -12,7 +12,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -36,6 +39,15 @@ public class PrintBill extends PrinterRoot { ...@@ -36,6 +39,15 @@ public class PrintBill extends PrinterRoot {
@Override @Override
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context);
List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo();
if (expandInfos != null) {
for (ExpandInfo expandInfo : expandInfos) {
if (expandInfo.getSettingName().equals(ExpandConstant.TableModeClosingPC)) {
return expandInfo.getValueInt();
}
}
}
return 1; return 1;
} }
......
...@@ -52,7 +52,9 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -52,7 +52,9 @@ public class PrintOtherOrder extends PrinterRoot {
List<Bitmap> bitmaps = new ArrayList<>(); List<Bitmap> bitmaps = new ArrayList<>();
// Bitmap bitmap = initPrintView(mContext, dataBean); // Bitmap bitmap = initPrintView(mContext, dataBean);
Bitmap bitmap = getBitmap(mContext, dataBean, deviceBean); Bitmap bitmap = getBitmap(mContext, dataBean, deviceBean);
// for (int i = 0; i < getPrintCount(mContext); i++) {
bitmaps.add(bitmap); bitmaps.add(bitmap);
// }
merge2ResultMap(bitmapMaps, "", bitmaps); merge2ResultMap(bitmapMaps, "", bitmaps);
return bitmapMaps; return bitmapMaps;
} }
...@@ -63,15 +65,14 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -63,15 +65,14 @@ public class PrintOtherOrder extends PrinterRoot {
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context); ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context);
List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo(); List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo();
int printCount = 1;
if (expandInfos != null) { if (expandInfos != null) {
for (ExpandInfo expandInfo : expandInfos) { for (ExpandInfo expandInfo : expandInfos) {
if (expandInfo.getSettingName().equals(ExpandConstant.DeliveryPrintCount)) { if (expandInfo.getSettingName().equals(ExpandConstant.DeliveryPrintCount)) {
printCount = expandInfo.getValueInt(); return expandInfo.getValueInt();
} }
} }
} }
return printCount; return 1;
} }
private void addCountBitmap(List<Bitmap> bitmaps, int count, Bitmap bitmap) { private void addCountBitmap(List<Bitmap> bitmaps, int count, Bitmap bitmap) {
...@@ -138,7 +139,7 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -138,7 +139,7 @@ public class PrintOtherOrder extends PrinterRoot {
layout.addView(getTakeawayOrderInfo(mContext, data)); layout.addView(getTakeawayOrderInfo(mContext, data));
//食品 //食品
layout.addView(getTextLine(mContext, "項目")); layout.addView(getTextLine(mContext, "項目"));
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<PrintBillBean> billData = new ArrayList<>();
...@@ -163,26 +164,12 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -163,26 +164,12 @@ public class PrintOtherOrder extends PrinterRoot {
layout.addView(getTakeawayLargeAmount(mContext, "支付金額:", MONETARY_UNIT + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()) + "")); layout.addView(getTakeawayLargeAmount(mContext, "支付金額:", MONETARY_UNIT + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()) + ""));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
//用戶信息 //用戶信息
String address = ""; getTakeawayReceiver(mContext, data, layout);
String receiver = "";
if (data.getOrder_type() == 2) {
//收貨地址
address = "地址:" + data.getAddressDetail();
//收貨人
receiver = "收貨人:" + data.getRECEIVER();
}
if (!TextUtil.isEmptyOrNullOrUndefined(address)) {
layout.addView(getTakeawayTextView(mContext, address));
}
if (!TextUtil.isEmptyOrNullOrUndefined(receiver)) {
layout.addView(getTakeawayTextView(mContext, receiver));
}
layout.addView(getTakeawayTextView(mContext, "手機號:" + data.getPHONE()));
//尾部 //尾部
return viewToZoomBitmap(mContext, layout, deviceBean); return viewToZoomBitmap(mContext, layout, deviceBean);
} }
private Bitmap initPrintView(Context context, OrderDetails.DataBean data) { private Bitmap initPrintView(Context context, OrderDetails.DataBean data) {
View view = LayoutInflater.from(context).inflate(R.layout.print_confirm_order_view, null, false); View view = LayoutInflater.from(context).inflate(R.layout.print_confirm_order_view, null, false);
TextView tvOrderClosing = view.findViewById(R.id.tv_order_closing); TextView tvOrderClosing = view.findViewById(R.id.tv_order_closing);
......
...@@ -4,14 +4,17 @@ import android.content.Context; ...@@ -4,14 +4,17 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
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;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
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.constans.ExpandConstant; import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo; import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
...@@ -39,7 +42,7 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -39,7 +42,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
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<>();
bitmaps.add(initPrintView(mContext, dataBean, deviceBean)); bitmaps.add(getBitmap(mContext, dataBean, deviceBean));
bitmapMaps.put("", bitmaps); bitmapMaps.put("", bitmaps);
return bitmapMaps; return bitmapMaps;
} }
...@@ -50,15 +53,14 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -50,15 +53,14 @@ public class PrintOtherOrderClosing extends PrinterRoot {
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context); ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context);
List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo(); List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo();
int printCount = 1;
if (expandInfos != null) { if (expandInfos != null) {
for (ExpandInfo expandInfo : expandInfos) { for (ExpandInfo expandInfo : expandInfos) {
if (expandInfo.getSettingName().equals(ExpandConstant.DeliveryPrintCount)) { if (expandInfo.getSettingName().equals(ExpandConstant.DeliveryClosingPC)) {
printCount = expandInfo.getValueInt(); return expandInfo.getValueInt();
} }
} }
} }
return printCount; return 1;
} }
private Bitmap initPrintView(Context context, OrderDetails.DataBean data, PrinterDeviceBean deviceBean) { private Bitmap initPrintView(Context context, OrderDetails.DataBean data, PrinterDeviceBean deviceBean) {
...@@ -72,6 +74,7 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -72,6 +74,7 @@ public class PrintOtherOrderClosing extends PrinterRoot {
TextView lineMember = view.findViewById(R.id.line_member_info); TextView lineMember = view.findViewById(R.id.line_member_info);
TextView tvOrderClosing = view.findViewById(R.id.tv_order_closing); TextView tvOrderClosing = view.findViewById(R.id.tv_order_closing);
TextView tvBillNumber = view.findViewById(R.id.tv_bill_number); TextView tvBillNumber = view.findViewById(R.id.tv_bill_number);
TextView tvPayMethodTwo = view.findViewById(R.id.tv_pay_amount_text_two);
//品牌名 //品牌名
setText(view, R.id.tv_brand_name, GsaCloudApplication.getBrandName(context)); setText(view, R.id.tv_brand_name, GsaCloudApplication.getBrandName(context));
//餐廳名 //餐廳名
...@@ -134,7 +137,8 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -134,7 +137,8 @@ public class PrintOtherOrderClosing extends PrinterRoot {
setText(view, R.id.tv_pay_type, "店內支付"); setText(view, R.id.tv_pay_type, "店內支付");
} else if (data.getOrderPayType() == 2) { } else if (data.getOrderPayType() == 2) {
setText(view, R.id.tv_pay_type, "在線支付"); setText(view, R.id.tv_pay_type, "在線支付");
setText(view, R.id.tv_pay_amount_text, data.getPayName() + ":" + amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())); // setText(view, R.id.tv_pay_amount_text, data.getPayName() + ":" + amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
setText(view, R.id.tv_pay_amount_text, data.getPayName() + ":" + amountUnit + data.getPayAmount());
} }
if (data.getPayTime() != null) { if (data.getPayTime() != null) {
tvOrderClosing.setText("結賬時間:" + data.getPayTime()); tvOrderClosing.setText("結賬時間:" + data.getPayTime());
...@@ -188,11 +192,58 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -188,11 +192,58 @@ public class PrintOtherOrderClosing extends PrinterRoot {
return viewToZoomBitmap(context, view, deviceBean); return viewToZoomBitmap(context, view, deviceBean);
} }
private Bitmap getBitmap(Context mContext, OrderDetails.DataBean data, PrinterDeviceBean deviceBean) {
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
//頭部
layout.addView(getHeader(mContext));
//訂單信息
layout.addView(getTakeawayOrderInfo(mContext, data));
//食品
layout.addView(getTextLine(mContext, "項目"));
layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(1, data.getPRODUCT_NAME()), deviceBean, 1, true));
layout.addView(getLine(mContext));
//訂單金額信息
List<PrintBillBean> billData = new ArrayList<>();
billData.add(getBillBean("合計:", MONETARY_UNIT + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()), data.getDELIVERY_CHARGE())));
if (data.getLunchbox() != 0) {
billData.add(getBillBean("餐盒費:", MONETARY_UNIT + data.getLunchbox()));
}
if (data.getDELIVERY_CHARGE() != 0) {
billData.add(getBillBean("送貨費:", MONETARY_UNIT + data.getDELIVERY_CHARGE()));
}
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()));
}
}
layout.addView(getTakeawayBillInfoView(mContext, billData));
layout.addView(getLine(mContext));
//總金額34sp
layout.addView(getTakeawayLargeAmount(mContext, "總金額:", MONETARY_UNIT + data.getTOTAL_AMOUNT()));
layout.addView(getLine(mContext));
//多種支付方式
if(data.getOrderPayInfoVO() != null){
for (OrderDetails.DataBean.OrderPayAmountVo orderPayAmountVo : data.getOrderPayInfoVO()) {
layout.addView(getTakeawayLargeAmount(mContext, orderPayAmountVo.getPayName(), MONETARY_UNIT + orderPayAmountVo.getAmount()));
}
}
// layout.addView(getTakeawayLargeAmount(mContext, "支付金額:", MONETARY_UNIT + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()) + ""));
layout.addView(getLine(mContext));
//會員信息
layout.addView(getTakeawayMemberIntegerView(mContext, data));
layout.addView(getLine(mContext));
getTakeawayReceiver(mContext, data, layout);
return viewToZoomBitmap(mContext, layout, deviceBean);
}
private PrintBillBean getBillBean(String title, String value) { private PrintBillBean getBillBean(String title, String value) {
return new PrintBillBean(title, value); return new PrintBillBean(title, value);
} }
private String getReplaceAfter(String str) { private String getReplaceAfter(String str) {
if (str != null && str.length() > 0) { if (str != null && str.length() > 0) {
int replaceStrCount = str.length() / 2; int replaceStrCount = str.length() / 2;
...@@ -210,4 +261,5 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -210,4 +261,5 @@ public class PrintOtherOrderClosing extends PrinterRoot {
return ""; return "";
} }
} }
\ No newline at end of file
...@@ -12,7 +12,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.TableBean; ...@@ -12,7 +12,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils;
import com.joe.print.R; import com.joe.print.R;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -44,6 +47,15 @@ public class PrintSlip extends PrinterRoot { ...@@ -44,6 +47,15 @@ public class PrintSlip extends PrinterRoot {
@Override @Override
public int getPrintCount(Context context) { public int getPrintCount(Context context) {
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(context);
List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo();
if (expandInfos != null) {
for (ExpandInfo expandInfo : expandInfos) {
if (expandInfo.getSettingName().equals(ExpandConstant.TableModePrintCount)) {
return expandInfo.getValueInt();
}
}
}
return 1; return 1;
} }
......
...@@ -2,12 +2,15 @@ package com.joe.print.mvp.print; ...@@ -2,12 +2,15 @@ package com.joe.print.mvp.print;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.view.Gravity;
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 com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
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.OrderDetails;
import com.joe.print.R; import com.joe.print.R;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -25,7 +28,7 @@ public class PrintTest extends PrinterRoot { ...@@ -25,7 +28,7 @@ public class PrintTest extends PrinterRoot {
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) { public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>(); Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
List<Bitmap> bitmaps = new ArrayList<>(); List<Bitmap> bitmaps = new ArrayList<>();
bitmaps.add(getTestPrintBitmap(mContext, deviceBean)); bitmaps.add(getBitmap(mContext, deviceBean));
bitmapMaps.put("", bitmaps); bitmapMaps.put("", bitmaps);
return bitmapMaps; return bitmapMaps;
} }
...@@ -49,4 +52,33 @@ public class PrintTest extends PrinterRoot { ...@@ -49,4 +52,33 @@ public class PrintTest extends PrinterRoot {
return viewToZoomBitmap(context, view, deviceBean); return viewToZoomBitmap(context, view, deviceBean);
} }
public Bitmap getBitmap(Context mContext, PrinterDeviceBean deviceBean){
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(getTextView(mContext, "炒爐打印測試", Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_10)));
layout.addView(getTextView(mContext, "時間:" + TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT), Gravity.LEFT, getDimensionPixelSize(mContext, R.dimen.dp_8)));
layout.addView(getTextLine(mContext, "項目"));
List<OrderDetails.DataBean.PRODUCTNAMEBean> productnameBeans = new ArrayList<>();
OrderDetails.DataBean.PRODUCTNAMEBean productnameBean = new OrderDetails.DataBean.PRODUCTNAMEBean();
productnameBean.setPRODUCT_NAME("測試食品");
productnameBean.setNum("1");
productnameBean.setPRICE("10.0");
List<OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX> childBeanXES = new ArrayList<>();
OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX = new OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX();
childBeanX.setPRODUCT_NAME("測試子食品");
childBeanX.setNum("1");
childBeanX.setPRICE("10.0");
childBeanXES.add(childBeanX);
productnameBean.setChild(childBeanXES);
productnameBeans.add(productnameBean);
layout.addView(getDiningFoodList(mContext, OrderDetail.productMameBeanToOrderDetail(0, productnameBeans), deviceBean, 0, true));
layout.addView(getTextLine(mContext, "Powered by Gingersoft"));
// layout.addView(getTextView(mContext, "(USB)", Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_8)));
return viewToZoomBitmap(mContext, layout, deviceBean);
}
} }
...@@ -197,6 +197,8 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -197,6 +197,8 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
//有打印位置 //有打印位置
hasPrinterSettingPrint(entry.getKey(), entry.getValue(), deviceBeans); hasPrinterSettingPrint(entry.getKey(), entry.getValue(), deviceBeans);
} }
} }
} }
} }
...@@ -536,13 +538,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -536,13 +538,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
for (int j = 0; j < bitmaps.size(); j++) { for (int j = 0; j < bitmaps.size(); j++) {
mPrinter.putPrintData(printerDeviceBean.getIp(), bitmaps.get(j)); mPrinter.putPrintData(printerDeviceBean.getIp(), bitmaps.get(j));
} }
// if (printListener != null) {
// if (state == 2) {
// printListener.printStateChanged(PrintActivity.LACK_OF_PAPER);
// } else {
// printListener.printStateChanged(PrintActivity.FINISH);
// }
// }
} else { } else {
PrintExecutor executor = new PrintExecutor(printerDeviceBean); PrintExecutor executor = new PrintExecutor(printerDeviceBean);
executor.setOnStateChangedListener(stateChangedListener); executor.setOnStateChangedListener(stateChangedListener);
...@@ -987,6 +982,25 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -987,6 +982,25 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return layout; return layout;
} }
protected void getTakeawayReceiver(Context mContext, OrderDetails.DataBean data, LinearLayout layout) {
String address = "";
String receiver = "";
if (data.getOrder_type() == 2) {
//收貨地址
address = "地址:" + data.getAddressDetail();
//收貨人
receiver = "收貨人:" + data.getRECEIVER();
}
if (!TextUtil.isEmptyOrNullOrUndefined(address)) {
layout.addView(getTakeawayTextView(mContext, address));
}
if (!TextUtil.isEmptyOrNullOrUndefined(receiver)) {
layout.addView(getTakeawayTextView(mContext, receiver));
}
layout.addView(getTakeawayTextView(mContext, "手機號:" + data.getPHONE()));
}
protected View getTakeawayTextView(Context mContext, String text) { protected View getTakeawayTextView(Context mContext, String text) {
return getTextView(mContext, text, Gravity.LEFT, 26, getColor(mContext, R.color.black)); return getTextView(mContext, text, Gravity.LEFT, 26, getColor(mContext, R.color.black));
} }
......
package com.joe.print.mvp.print; package com.joe.print.mvp.print;
import android.graphics.Bitmap;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.print.PrintDataMaker; import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter; import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.mvp.model.bean.PrintInfoBean; import com.joe.print.mvp.model.bean.PrintInfoBean;
import com.joe.print.mvp.print.utils.MyPrintUtils; import com.joe.print.mvp.print.utils.MyPrintUtils;
...@@ -18,15 +22,30 @@ public class TestPrintMaker implements PrintDataMaker { ...@@ -18,15 +22,30 @@ public class TestPrintMaker implements PrintDataMaker {
private PrinterWriter printer; private PrinterWriter printer;
private List<PrintInfoBean> printInfoBeans; private List<PrintInfoBean> printInfoBeans;
private Bitmap bitmap;
public TestPrintMaker(PrinterWriter printer, List<PrintInfoBean> printInfoBeans) { public TestPrintMaker(PrinterWriter printer, List<PrintInfoBean> printInfoBeans) {
this.printer = printer; this.printer = printer;
this.printInfoBeans = printInfoBeans; this.printInfoBeans = printInfoBeans;
} }
public TestPrintMaker( List<PrintInfoBean> printInfoBeans) {
this.printInfoBeans = printInfoBeans;
}
public TestPrintMaker(PrinterWriter printer) {
this.printer = printer;
}
public TestPrintMaker(Bitmap bitmap) {
this.bitmap = bitmap;
}
@Override @Override
public List<byte[]> getPrintData() { public List<byte[]> getPrintData() {
ArrayList<byte[]> data = new ArrayList<>();
try { try {
ArrayList<byte[]> data = new ArrayList<>();
if (printer == null) {
printer = new PrinterWriter80mm(255);
}
for (PrintInfoBean printInfoBean : printInfoBeans) { for (PrintInfoBean printInfoBean : printInfoBeans) {
//如果打印多列內容,並且字體大小配置多個,則每一列取自己對應的字體大小 //如果打印多列內容,並且字體大小配置多個,則每一列取自己對應的字體大小
for (int i = 0; i < printInfoBean.getContent().length; i++) { for (int i = 0; i < printInfoBean.getContent().length; i++) {
...@@ -34,6 +53,8 @@ public class TestPrintMaker implements PrintDataMaker { ...@@ -34,6 +53,8 @@ public class TestPrintMaker implements PrintDataMaker {
} }
printer.print("\n"); printer.print("\n");
} }
// data.add(ImageUtils.draw2PxPoint(bitmap));
printer.printLineFeed(); printer.printLineFeed();
printer.printLineFeed(); printer.printLineFeed();
printer.feedPaperCutPartial(); printer.feedPaperCutPartial();
......
...@@ -203,26 +203,24 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -203,26 +203,24 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
if (isShowDialog) { if (isShowDialog) {
initDialog(); initDialog();
} }
//先在這裡壓縮,之後在每個類自己生成的時候壓縮 //獲得對應的圖片
List<Bitmap> zoomBitmaps = printerInIt.getPrintBitmap(mContext, defaultPrint).get(""); List<Bitmap> zoomBitmaps = printerInIt.getPrintBitmap(mContext, defaultPrint).get("");
// List<Bitmap> zoomBitmaps = new ArrayList<>();
// for (Bitmap bitmap : bitmaps) {
// Bitmap zoomBitmap = printerInIt.zoomBitmap(defaultPrint, bitmap);
// zoomBitmaps.add(zoomBitmap);
// }
if (zoomBitmaps != null && zoomBitmaps.size() > 0) { if (zoomBitmaps != null && zoomBitmaps.size() > 0) {
if (defaultPrint.getPrinterDeviceType() == 1) { int printCount = printerInIt.getPrintCount(mContext);
//IP打印 for (int i = 0; i < printCount; i++) {
printerInIt.ipDevicePrint(defaultPrint, zoomBitmaps); if (defaultPrint.getPrinterDeviceType() == 1) {
} else if (defaultPrint.getPrinterDeviceType() == 2) { //IP打印
//本地N5或Sunmi打印 printerInIt.ipDevicePrint(defaultPrint, zoomBitmaps);
printerInIt.locationPrint(zoomBitmaps, this); } else if (defaultPrint.getPrinterDeviceType() == 2) {
} else if (defaultPrint.getPrinterDeviceType() == 3) { //本地N5或Sunmi打印
//USB打印打印 printerInIt.locationPrint(zoomBitmaps, this);
printerInIt.usbPrint(mContext, zoomBitmaps); } else if (defaultPrint.getPrinterDeviceType() == 3) {
} else { //USB打印打印
ToastUtils.show(mContext, "未找到對應的打印類型"); printerInIt.usbPrint(mContext, zoomBitmaps);
printFile(); } else {
ToastUtils.show(mContext, "未找到對應的打印類型");
printFile();
}
} }
} else { } else {
//打印失敗 //打印失敗
......
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
...@@ -25,10 +22,10 @@ import com.joe.print.di.component.DaggerPrintAddCurrencyComponent; ...@@ -25,10 +22,10 @@ import com.joe.print.di.component.DaggerPrintAddCurrencyComponent;
import com.joe.print.di.module.PrintAddCurrencyModule; import com.joe.print.di.module.PrintAddCurrencyModule;
import com.joe.print.mvp.contract.PrintAddCurrencyContract; import com.joe.print.mvp.contract.PrintAddCurrencyContract;
import com.joe.print.mvp.presenter.PrintAddCurrencyPresenter; import com.joe.print.mvp.presenter.PrintAddCurrencyPresenter;
import com.gingersoft.gsa.cloud.ui.view.WheelView;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -248,14 +245,8 @@ public class PrintAddCurrencyActivity extends BaseActivity<PrintAddCurrencyPrese ...@@ -248,14 +245,8 @@ public class PrintAddCurrencyActivity extends BaseActivity<PrintAddCurrencyPrese
} }
private void showSelectFoodFontSize(TextView view) { private void showSelectFoodFontSize(TextView view) {
List<String> types = new ArrayList<>(); List<String> fontSize = Arrays.asList("預設", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30");
types.add("1"); DialogUtils.showSelectPopop(this, fontSize, "字體大小", 0, i -> view.setText(fontSize.get(i)));
types.add("2");
types.add("3");
types.add("4");
types.add("5");
types.add("6");
DialogUtils.showSelectPopop(this, types, "字體大小", 0, i -> view.setText(types.get(i)));
} }
@OnClick({R2.id.printer_add_currency, R2.id.layout_currency_add_table_mode, R2.id.layout_currency_add_food_color, R2.id.layout_currency_add_food_item_color, R2.id.layout_currency_add_food_font_size, R2.id.layout_currency_add_food_item_font_size}) @OnClick({R2.id.printer_add_currency, R2.id.layout_currency_add_table_mode, R2.id.layout_currency_add_food_color, R2.id.layout_currency_add_food_item_color, R2.id.layout_currency_add_food_font_size, R2.id.layout_currency_add_food_item_font_size})
......
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.widget.EditText; import android.widget.EditText;
...@@ -17,6 +18,7 @@ import com.gingersoft.gsa.cloud.print.PrintSocketHolder; ...@@ -17,6 +18,7 @@ import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.joe.print.R; import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrintInfoBean; import com.joe.print.mvp.model.bean.PrintInfoBean;
import com.joe.print.mvp.print.EpsonPrint; import com.joe.print.mvp.print.EpsonPrint;
import com.joe.print.mvp.print.PrintTest;
import com.joe.print.mvp.print.common.PrinterFinderCallback; import com.joe.print.mvp.print.common.PrinterFinderCallback;
import com.joe.print.mvp.print.common.SendCallback; import com.joe.print.mvp.print.common.SendCallback;
import com.joe.print.mvp.print.common.SendResultCode; import com.joe.print.mvp.print.common.SendResultCode;
...@@ -139,18 +141,28 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH ...@@ -139,18 +141,28 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
printerFinder.startFinder(); printerFinder.startFinder();
List<PrintInfoBean> printInfoBeans = new ArrayList<>(); List<PrintInfoBean> printInfoBeans = new ArrayList<>();
printInfoBeans.add(new PrintInfoBean(new String[]{"EnglishEnglishEnglish"}, new String[]{"en"})); printInfoBeans.add(new PrintInfoBean(new String[]{"EnglishEnglishEnglish"}, new Double[]{2d},new String[]{"en"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"日語伐採に加えて"}, new String[]{"ja"})); printInfoBeans.add(new PrintInfoBean(new String[]{"日語伐採に加えて"}, new Double[]{2d}, new String[]{"ja"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"简体字简体字简体字"}, new String[]{"cn"})); printInfoBeans.add(new PrintInfoBean(new String[]{"简体字简体字简体字"}, new Double[]{2d}, new String[]{"cn"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"繁体字繁体字繁体字"}, new String[]{"tw"})); printInfoBeans.add(new PrintInfoBean(new String[]{"繁体字繁体字繁体字"}, new Double[]{2d}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"한국어.한국어.한국어."}, new String[]{"ko"})); printInfoBeans.add(new PrintInfoBean(new String[]{"한국어.한국어.한국어."}, new Double[]{2d}, new String[]{"ko"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"ภาษาไทยภาษาไทย"}, new String[]{"th"})); printInfoBeans.add(new PrintInfoBean(new String[]{"ภาษาไทยภาษาไทย"}, new Double[]{2d}, new String[]{"th"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"ViệtNameViệtName"}, new String[]{"vi"})); printInfoBeans.add(new PrintInfoBean(new String[]{"ViệtNameViệtName"}, new Double[]{2d}, new String[]{"vi"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"\n\n\nEnglishに加えて简体字繁体字한국어ภาษาไทยViệtName"}, new String[]{"multi"})); printInfoBeans.add(new PrintInfoBean(new String[]{"\n\n\nEnglishに加えて简体字繁体字한국어ภาษาไทยViệtName"}, new Double[]{2d}, new String[]{"multi"}));
PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean();
printerDeviceBean.setIp("192.168.1.203");
printerDeviceBean.setPort(9100);
Bitmap bitmap = new PrintTest().getTestPrintBitmap(this, printerDeviceBean);
findViewById(R.id.btn_test).setOnClickListener(view -> { findViewById(R.id.btn_test).setOnClickListener(view -> {
//打印測試 //打印測試
EpsonPrint mPrinter = EpsonPrint.getInstance(); // PrintExecutor executor = new PrintExecutor(printerDeviceBean);
// executor.setOnStateChangedListener(stateChangedListener);
// executor.setOnPrintResultListener(resultListener);
// TestPrintMaker maker = new TestPrintMaker(printInfoBeans);
// executor.doPrinterRequestAsync(maker);
EpsonPrint mPrinter = new EpsonPrint();
mPrinter.initializeObject(GsaCloudApplication.getAppContext(), this); mPrinter.initializeObject(GsaCloudApplication.getAppContext(), this);
mPrinter.putPrintString(ed_ip.getText().toString(), 42, printInfoBeans, this); mPrinter.putPrintString(ed_ip.getText().toString(), 42, printInfoBeans, this);
}); });
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_50" android:layout_height="@dimen/dp_50"
android:layout_marginTop="@dimen/dp_20" android:layout_marginTop="@dimen/dp_20"
android:text="192.168.1.203"
android:hint="请输入IP地址" /> android:hint="请输入IP地址" />
<Button <Button
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
...@@ -231,6 +232,13 @@ ...@@ -231,6 +232,13 @@
android:text="支付金額:" /> android:text="支付金額:" />
<TextView <TextView
android:id="@+id/tv_pay_amount_text_two"
style="@style/print_other_order_thirty_bold_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="支付金額2:" />
<TextView
android:id="@+id/tv_pay_amount_line" android:id="@+id/tv_pay_amount_line"
style="@style/print_other_order_twenty_six_style" style="@style/print_other_order_twenty_six_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
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