|
@@ -122,6 +122,7 @@ import com.hboxs.base_library.util.PreventSpeedClickUtil;
|
|
|
import com.hboxs.base_library.util.ReturnTomainScreenUtil;
|
|
|
import com.hboxs.base_library.util.SharedPreferencesUtils;
|
|
|
import com.hboxs.base_library.util.UiUtil;
|
|
|
+import com.nayax.demo.jni.SerialPort;
|
|
|
import com.orhanobut.hawk.Hawk;
|
|
|
import com.zyao89.view.zloading.ZLoadingDialog;
|
|
|
import com.zyao89.view.zloading.Z_TYPE;
|
|
@@ -158,6 +159,7 @@ import io.reactivex.observers.DisposableObserver;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import okhttp3.MediaType;
|
|
|
import okhttp3.RequestBody;
|
|
|
+import top.keepempty.sph.library.SerialPortHelper;
|
|
|
import top.keepempty.sph.library.SphCmdEntity;
|
|
|
import top.keepempty.sph.library.SphResultCallback;
|
|
|
|
|
@@ -473,7 +475,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
Heartbeat.deviceId = FileUtil.getDeviceId().trim();
|
|
|
EventBus.getDefault().register(this);
|
|
|
Log.d(TAG, "MDB_COIN: 0");
|
|
|
- if (Hawk.get("MDB_COIN", false)) {
|
|
|
+ if (Hawk.get("MDB_COIN", false)/*&&Hawk.get(Name.CASH_PAY, true)*/) {
|
|
|
Log.d(TAG, "MDB_COIN: 1");
|
|
|
openSerialPort();
|
|
|
Log.d(TAG, "MDB_COIN: 2");
|
|
@@ -541,27 +543,32 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
public void openSerialPort() {
|
|
|
Log.d(TAG, "MDB_COIN: 3");
|
|
|
- MainActivity.openSerialPortA().setSphResultCallback(new SphResultCallback() {
|
|
|
- @Override
|
|
|
- public void onSendData(SphCmdEntity sendCom) {
|
|
|
- }
|
|
|
+ SerialPortHelper serialPortHelper = MainActivity.openSerialPortA();
|
|
|
+ if (serialPortHelper != null) {
|
|
|
+ serialPortHelper.setSphResultCallback(new SphResultCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSendData(SphCmdEntity sendCom) {
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onReceiveData(SphCmdEntity data) {
|
|
|
- if (data.commandsHex.startsWith("010304") && data.commandsHex.length() >= 10) {
|
|
|
- String result = data.commandsHex.substring(6, 10);
|
|
|
- double coin = Integer.parseInt(result, 16) / 100.00;
|
|
|
- if (!result.equals("0000")) {
|
|
|
- Global.hascoin = Global.hascoin.add(new BigDecimal((coin * Global.coinMultiplier) / Global.coinMultiplierDivide)).setScale(2, RoundingMode.HALF_UP);
|
|
|
- getDefault().post(new OfflineMessageEvent(Name.CURRENCYCHANGES, null));
|
|
|
+ @Override
|
|
|
+ public void onReceiveData(SphCmdEntity data) {
|
|
|
+ if (data.commandsHex.startsWith("010304") && data.commandsHex.length() >= 10) {
|
|
|
+ String result = data.commandsHex.substring(6, 10);
|
|
|
+ double coin = Integer.parseInt(result, 16) / 100.00;
|
|
|
+ if (!result.equals("0000")) {
|
|
|
+ Global.hascoin = Global.hascoin.add(new BigDecimal((coin * Global.coinMultiplier) / Global.coinMultiplierDivide)).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ getDefault().post(new OfflineMessageEvent(Name.CURRENCYCHANGES, null));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void onComplete() {
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ LogUtils.logWrite("没有MDB硬币器");
|
|
|
+ }
|
|
|
Log.d(TAG, "MDB_COIN: 4");
|
|
|
}
|
|
|
|
|
@@ -633,17 +640,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
ToastUtil.getInstance().showText(CommunicationHelper.getInstance().getWhyCanOrderText());
|
|
|
return;//是否开机
|
|
|
}
|
|
|
- if (Hawk.get(Name.SHOPPING_TROLLEY,true)){
|
|
|
+ if (Hawk.get(Name.SHOPPING_TROLLEY, true)) {
|
|
|
addShopCart();
|
|
|
- Log.d(TAG, "无购物车测试orderHelperonClick:2 "+currentDish);
|
|
|
- }else {
|
|
|
+ Log.d(TAG, "无购物车测试orderHelperonClick:2 " + currentDish);
|
|
|
+ } else {
|
|
|
orderHelper = OrderHelper.getInstance();
|
|
|
orderHelper.init(currentDish);
|
|
|
addItem(currentDish.selectSpecBeans);
|
|
|
initIceCream();
|
|
|
showChoosePay();
|
|
|
- Log.d(TAG, "无购物车测试orderHelperonClick:1 "+orderHelper.getOrderList());
|
|
|
- Log.d(TAG, "无购物车测试orderHelperonClick:2 "+currentDish);
|
|
|
+ Log.d(TAG, "无购物车测试orderHelperonClick:1 " + orderHelper.getOrderList());
|
|
|
+ Log.d(TAG, "无购物车测试orderHelperonClick:2 " + currentDish);
|
|
|
}
|
|
|
|
|
|
} else if (id == R.id.dishes_sauce_1) {
|
|
@@ -660,7 +667,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private void showChoosePay() {
|
|
|
- if (Hawk.get(Name.SHOPPING_TROLLEY,true)) {
|
|
|
+ if (Hawk.get(Name.SHOPPING_TROLLEY, true)) {
|
|
|
if (Global.isVersions == 2) {
|
|
|
priceList = new ArrayList<>();
|
|
|
priceList1 = new ArrayList<>();
|
|
@@ -685,7 +692,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
Log.d(TAG, "onClick:priceList " + priceList);
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
priceList = new ArrayList<>();
|
|
|
priceList1 = new ArrayList<>();
|
|
|
|
|
@@ -787,7 +794,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
arrayCode = inputText.split("#");
|
|
|
combinationCount = arrayCode.length;
|
|
|
Log.d(TAG, "handlePaymentSelection: " + arrayCode);
|
|
|
- if (combinationCount > orderHelper.generateMakingIceCream().size()&&Hawk.get(Name.SHOPPING_TROLLEY,true)) {
|
|
|
+ if (combinationCount > orderHelper.generateMakingIceCream().size() && Hawk.get(Name.SHOPPING_TROLLEY, true)) {
|
|
|
ToastUtil.getInstance().showText(UiUtil.getStringRes(R.string.only_one_code));
|
|
|
return; // 直接返回,不继续执行
|
|
|
} else {
|
|
@@ -1060,14 +1067,14 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (v.isSelected()) {
|
|
|
SpecBean sb = v.getSpecBean();
|
|
|
currentDish.selectSpecBeans.add(sb);
|
|
|
- Log.d(TAG, "无购物车测试initIceCream1: "+currentDish.selectSpecBeans);
|
|
|
+ Log.d(TAG, "无购物车测试initIceCream1: " + currentDish.selectSpecBeans);
|
|
|
}
|
|
|
}
|
|
|
for (BatchingView v : kernelViews) {
|
|
|
if (v.isSelected()) {
|
|
|
SpecBean sb = v.getSpecBean();
|
|
|
currentDish.selectSpecBeans.add(sb);
|
|
|
- Log.d(TAG, "无购物车测试initIceCream2: "+currentDish.selectSpecBeans);
|
|
|
+ Log.d(TAG, "无购物车测试initIceCream2: " + currentDish.selectSpecBeans);
|
|
|
}
|
|
|
}
|
|
|
initPrice();
|
|
@@ -1785,7 +1792,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
private void showDialogWMDBCreditCard() {
|
|
|
double coin = pri;
|
|
|
if (coin <= 0) {
|
|
|
- ToastUtil.getInstance().showText("金额异常");
|
|
|
+ LogUtils.logWrite("MDB刷卡免费制作");
|
|
|
+ showDialogPaySuccess(R.string.pay_success, R.drawable.img_toubi_pay);
|
|
|
return;
|
|
|
}
|
|
|
removeFinish();
|
|
@@ -2167,64 +2175,64 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
// HashMap<String, String> strings1 = new HashMap<>();
|
|
|
|
|
|
ArrayList<String> strings = new ArrayList<>();
|
|
|
- Log.d(TAG, "无购物车测试: "+currentDish);
|
|
|
- if (Hawk.get(Name.SHOPPING_TROLLEY,true)){
|
|
|
+ Log.d(TAG, "无购物车测试: " + currentDish);
|
|
|
+ if (Hawk.get(Name.SHOPPING_TROLLEY, true)) {
|
|
|
for (int i = 0; i < shoppingCartBeanList.size(); i++) {
|
|
|
- strings.clear();
|
|
|
- //优惠码集合
|
|
|
- for (int i1 = 0; i1 < shoppingCartBeanList.get(i).getCount(); i1++) {
|
|
|
- if (i1 < promotionCodes.size()) {
|
|
|
- strings.add(promotionCodes.get(i1));
|
|
|
- } else {
|
|
|
- strings.add("0");
|
|
|
+ strings.clear();
|
|
|
+ //优惠码集合
|
|
|
+ for (int i1 = 0; i1 < shoppingCartBeanList.get(i).getCount(); i1++) {
|
|
|
+ if (i1 < promotionCodes.size()) {
|
|
|
+ strings.add(promotionCodes.get(i1));
|
|
|
+ } else {
|
|
|
+ strings.add("0");
|
|
|
+ }
|
|
|
+ Log.d(TAG, ":shoppingCartBeanList onClick: " + strings + " " + promotionCodes);
|
|
|
}
|
|
|
- Log.d(TAG, ":shoppingCartBeanList onClick: " + strings + " " + promotionCodes);
|
|
|
- }
|
|
|
- String s1 = new Gson().toJson(strings);
|
|
|
- Log.d(TAG, ":shoppingCartBeanList onClick:0 " + s1 + " " + promotionCodes);
|
|
|
- for (int j = 0; j < promotionCodes.size(); j++) {
|
|
|
- String s = promotionCodes.get(j);
|
|
|
- if (s != null && "".equals(s)) {
|
|
|
- Log.d(TAG, ":shoppingCartBeanList onClick:2 " + s1 + " " + promotionCodes);
|
|
|
- s1 = s;
|
|
|
+ String s1 = new Gson().toJson(strings);
|
|
|
+ Log.d(TAG, ":shoppingCartBeanList onClick:0 " + s1 + " " + promotionCodes);
|
|
|
+ for (int j = 0; j < promotionCodes.size(); j++) {
|
|
|
+ String s = promotionCodes.get(j);
|
|
|
+ if (s != null && "".equals(s)) {
|
|
|
+ Log.d(TAG, ":shoppingCartBeanList onClick:2 " + s1 + " " + promotionCodes);
|
|
|
+ s1 = s;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- Log.d(TAG, shoppingCartBeanList.size() + ":shoppingCartBeanList onClick: " + s1 + ":" + shoppingCartBeanList.get(i).getShoppingName() + "-" + shoppingCartBeanList.get(i).getCount());
|
|
|
- a.put(shoppingCartBeanList.get(i).getShoppingName() + "-" + shoppingCartBeanList.get(i).getCount(), s1);
|
|
|
- //将优惠码保存起来,带到make界面去处理。等于0就什么都不做
|
|
|
- Gson gson1 = new Gson();
|
|
|
- ArrayList<String> list = gson1.fromJson(s1, new TypeToken<List<String>>() {
|
|
|
- }.getType());
|
|
|
- if (list != null) {
|
|
|
- for (String s : list) {
|
|
|
+ Log.d(TAG, shoppingCartBeanList.size() + ":shoppingCartBeanList onClick: " + s1 + ":" + shoppingCartBeanList.get(i).getShoppingName() + "-" + shoppingCartBeanList.get(i).getCount());
|
|
|
+ a.put(shoppingCartBeanList.get(i).getShoppingName() + "-" + shoppingCartBeanList.get(i).getCount(), s1);
|
|
|
+ //将优惠码保存起来,带到make界面去处理。等于0就什么都不做
|
|
|
+ Gson gson1 = new Gson();
|
|
|
+ ArrayList<String> list = gson1.fromJson(s1, new TypeToken<List<String>>() {
|
|
|
+ }.getType());
|
|
|
+ if (list != null) {
|
|
|
+ for (String s : list) {
|
|
|
// promotionCodes.add(s);
|
|
|
// Log.d(TAG, "showShoppingTrolleyDialog0-2: " + s);
|
|
|
- promotionCodes.remove(s);
|
|
|
+ promotionCodes.remove(s);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- }else {
|
|
|
- if (arrayCode!=null){
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (arrayCode != null) {
|
|
|
strings.add(arrayCode[0]);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
strings.add("0");
|
|
|
}
|
|
|
String s1 = new Gson().toJson(strings);
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
- if (currentDish.selectSpecBeans.size()>0){
|
|
|
- Log.d(TAG, "无购物车测试1: "+currentDish.selectSpecBeans);
|
|
|
+ if (currentDish.selectSpecBeans.size() > 0) {
|
|
|
+ Log.d(TAG, "无购物车测试1: " + currentDish.selectSpecBeans);
|
|
|
for (int i = 0; i < currentDish.selectSpecBeans.size(); i++) {
|
|
|
sb.append(currentDish.selectSpecBeans.get(i).name);
|
|
|
if (i < currentDish.selectSpecBeans.size() - 1) {
|
|
|
sb.append(",");
|
|
|
}
|
|
|
}
|
|
|
- a.put(currentDish.name+"-"+sb+"-1",s1);
|
|
|
- }else {
|
|
|
- Log.d(TAG, "无购物车测试2: "+currentDish.selectSpecBeans);
|
|
|
- a.put(currentDish.name+"-"+"1",s1);
|
|
|
+ a.put(currentDish.name + "-" + sb + "-1", s1);
|
|
|
+ } else {
|
|
|
+ Log.d(TAG, "无购物车测试2: " + currentDish.selectSpecBeans);
|
|
|
+ a.put(currentDish.name + "-" + "1", s1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2374,7 +2382,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
bean.setNo(productName + "-" + "I01" + "-" + productNumber);
|
|
|
Gson gson = new Gson();
|
|
|
String json = gson.toJson(bean);
|
|
|
- Log.d(TAG, "saveCoinOrder: "+json);
|
|
|
+ Log.d(TAG, "saveCoinOrder: " + json);
|
|
|
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json;charset=utf-8"), json);
|
|
|
addSubscription(OrderApi.api.newSaveCoinOrder(body).compose(HttpResultHandler.<String>transformer())
|
|
|
, new HttpResultObserver<String>(mView, getContext()) {
|