|
@@ -1,9 +1,11 @@
|
|
|
package com.bgy.autosale.ui.consumer;
|
|
|
|
|
|
+import static com.bgy.autosale.ui.operator.fragments.PriceFragment.ProductAbout.defaultName;
|
|
|
import static org.greenrobot.eventbus.EventBus.getDefault;
|
|
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
import android.animation.ObjectAnimator;
|
|
|
+import android.app.Dialog;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.support.annotation.NonNull;
|
|
@@ -23,6 +25,7 @@ import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.ViewStub;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.view.animation.Animation;
|
|
|
import android.view.animation.AnimationUtils;
|
|
|
import android.view.animation.OvershootInterpolator;
|
|
@@ -44,6 +47,7 @@ import com.bgy.autosale.helpers.StockHelper;
|
|
|
import com.bgy.autosale.helpers.UISoundHelper;
|
|
|
import com.bgy.autosale.payutil.CoinPaySuccessDialog;
|
|
|
import com.bgy.autosale.payutil.CreditCardDialog;
|
|
|
+import com.bgy.autosale.payutil.CustomDecimalFormat;
|
|
|
import com.bgy.autosale.payutil.ImgOrderBean;
|
|
|
import com.bgy.autosale.payutil.MdbCreditCardDialog;
|
|
|
import com.bgy.autosale.payutil.PayMixDialog;
|
|
@@ -69,6 +73,7 @@ import com.bumptech.glide.Glide;
|
|
|
import com.example.offpay.event.OfflineMessageEvent;
|
|
|
import com.example.offpay.event.WmdbIctMessageEvent;
|
|
|
import com.example.offpay.ictrs232.ByteUtils;
|
|
|
+import com.example.offpay.ictrs232.DataUtils;
|
|
|
import com.example.offpay.nayax.CreditCardPresenter;
|
|
|
import com.example.offpay.wmdb.WeaverUtil;
|
|
|
import com.google.gson.Gson;
|
|
@@ -86,10 +91,14 @@ import com.hboxs.base_library.http.exception.ExceptionFactory;
|
|
|
import com.hboxs.base_library.http.observer.HttpResultObserver;
|
|
|
import com.hboxs.base_library.http.response.HttpResultHandler;
|
|
|
import com.hboxs.base_library.util.DialogUtil;
|
|
|
+import com.hboxs.base_library.util.DrawableSelectorUtils;
|
|
|
+import com.hboxs.base_library.util.FileUtil;
|
|
|
import com.hboxs.base_library.util.LogUtil;
|
|
|
import com.hboxs.base_library.util.LogUtils;
|
|
|
import com.hboxs.base_library.util.UiUtil;
|
|
|
import com.orhanobut.hawk.Hawk;
|
|
|
+import com.zyao89.view.zloading.ZLoadingDialog;
|
|
|
+import com.zyao89.view.zloading.Z_TYPE;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
@@ -98,11 +107,15 @@ import org.greenrobot.eventbus.ThreadMode;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.DecimalFormatSymbols;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Timer;
|
|
|
+import java.util.TimerTask;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import io.reactivex.Observable;
|
|
@@ -124,7 +137,7 @@ import top.keepempty.sph.library.SphResultCallback;
|
|
|
public class IceCreamFragment extends BaseAutoExitFragment implements View.OnClickListener, Animation.AnimationListener {
|
|
|
|
|
|
// 去除末尾的0
|
|
|
- private DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
|
|
+// private DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
|
|
|
|
|
//辅助点击太快的判断
|
|
|
private ClickHelper mClickHelper = new ClickHelper(300);
|
|
@@ -145,7 +158,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
private TextView priceView;
|
|
|
private RecyclerView recyclerView;
|
|
|
private InfoView dialog;
|
|
|
-
|
|
|
+ private TextView tvDeviceId1;
|
|
|
//海外新加
|
|
|
// private LinearLayout contain_1, contain_2, contain_3, contain_4, contain_5;
|
|
|
private ImageView logo_hw_iv;
|
|
@@ -174,6 +187,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
private String freeWithPhone = null;
|
|
|
private TextView tvMoney;
|
|
|
private Disposable showDelayDisposable;
|
|
|
+// private PriceFragment.PriceBean priceBean= Hawk.get("PRICEBEAN");
|
|
|
|
|
|
public static IceCreamFragment getFragment(String manualReason) {
|
|
|
Bundle bundle = new Bundle();
|
|
@@ -200,7 +214,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (bundle != null) {
|
|
|
manualReason = bundle.getString("manualReason");
|
|
|
}
|
|
|
- Log.d(TAG, "onViewCreated: 2");
|
|
|
+ Log.d(TAG, "onViewCreated: 2" + StockHelper.getInstance().getDishesBean(manualReason != null));
|
|
|
|
|
|
currentDish = BeanCloneUtil.cloneTo(StockHelper.getInstance().getDishesBean(manualReason != null));
|
|
|
if (currentDish == null) {
|
|
@@ -221,6 +235,10 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
tvMoney = findViewById(R.id.tv_money);
|
|
|
Log.d(TAG, "onViewCreated: 4");
|
|
|
tvMoney.setText(haveMoney/* + (Global.hasmoney.doubleValue() + Global.hasmoney.doubleValue())*/);
|
|
|
+ tvDeviceId1 = findViewById(R.id.tv_device_id1);
|
|
|
+ if (Heartbeat.deviceId != null && Heartbeat.deviceId.length() > 6) {
|
|
|
+ tvDeviceId1.setText(Heartbeat.deviceId.substring(Heartbeat.deviceId.length() - 6));
|
|
|
+ }
|
|
|
Log.d(TAG, "onViewCreated: 5");
|
|
|
|
|
|
stockView = view.findViewById(R.id.dishes_stock);
|
|
@@ -323,7 +341,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
});
|
|
|
}
|
|
|
}, 1, TimeUnit.SECONDS);
|
|
|
- if (App.app.payChannel == Constant.PAY_PRICE_MODEL||App.app.payChannel==Constant.PAY_NAYAX_PAY_MIX) {
|
|
|
+ if (App.app.payChannel == Constant.PAY_PRICE_MODEL || App.app.payChannel == Constant.PAY_NAYAX_PAY_MIX||App.app.payChannel==Constant.PAY_ONLINE_AND_PRICE_MODEL) {
|
|
|
findViewById(R.id.rl_money_show).setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
}
|
|
@@ -331,6 +349,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
@Override
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
+ Heartbeat.deviceId = FileUtil.getDeviceId().trim();
|
|
|
EventBus.getDefault().register(this);
|
|
|
Log.d(TAG, "MDB_COIN: 0");
|
|
|
if (Hawk.get("MDB_COIN", false)) {
|
|
@@ -339,9 +358,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
Log.d(TAG, "MDB_COIN: 2");
|
|
|
mHandler.postDelayed(mRunnable, 500);
|
|
|
}
|
|
|
- if (Hawk.get("nayax", false)){
|
|
|
+ if (Hawk.get("nayax", false)) {
|
|
|
Log.d(TAG, "onCreate: ALWAYS_IDLE1");
|
|
|
- if (mCreditCardPresenter==null){
|
|
|
+ if (mCreditCardPresenter == null) {
|
|
|
initCreditCardDriver();
|
|
|
}
|
|
|
}
|
|
@@ -363,7 +382,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
showToast(UiUtil.getStringRes(R.string.nany_noconnect));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private CreditCardPresenter mCreditCardPresenter;
|
|
@@ -476,28 +494,45 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (id == R.id.dishes_shop_cart_clear) {
|
|
|
showClearDialog();
|
|
|
} else if (id == R.id.dishes_shop_cart_pay) {
|
|
|
+ showLoading();
|
|
|
if (App.app.payChannel == Constant.PAY_FREE || manualReason != null) {
|
|
|
manualMake();
|
|
|
+ LogUtils.logWrite("免费制作了");
|
|
|
} else if (App.app.payChannel == Constant.PAY_ONLINE || manualReason != null) {
|
|
|
+ if (Hawk.get("PRICEBEAN") != null) {
|
|
|
+ priceBeans = Hawk.get("PRICEBEAN");
|
|
|
+ } else {
|
|
|
+ dismissLoading();
|
|
|
+ showToast("请重新设置价格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
carsPay(str());//国内二码合一支付
|
|
|
Log.d(TAG, "onClick: 二码合一");
|
|
|
+ }else if (App.app.payChannel == Constant.PAY_ONLINE_AND_PRICE_MODEL || manualReason != null) {
|
|
|
+ dismissLoading();
|
|
|
+ showDialogChoosePay();
|
|
|
+ Log.d(TAG, "onClick: 二码合一");
|
|
|
} else if (App.app.payChannel == Constant.PAY_POS_DEVICE || manualReason != null) {
|
|
|
Log.d(TAG, "onClick: MDB板信用卡支付");
|
|
|
pay();//MDB板信用卡支付
|
|
|
} else if (App.app.payChannel == Constant.PAY_PRICE_MODEL || manualReason != null) {
|
|
|
showPayMixDialog();
|
|
|
- } else if (App.app.payChannel == Constant.PAY_NAYAX_MODEL ||App.app.payChannel == Constant.PAY_NAYAX_MODEL_IDLE || manualReason != null) {
|
|
|
+ } else if (App.app.payChannel == Constant.PAY_NAYAX_MODEL || App.app.payChannel == Constant.PAY_NAYAX_MODEL_IDLE || manualReason != null) {
|
|
|
showNayaxCreditCard();
|
|
|
- }else if (App.app.payChannel == Constant.PAY_NAYAX_PAY_MIX || manualReason != null){
|
|
|
+ } else if (App.app.payChannel == Constant.PAY_NAYAX_PAY_MIX || manualReason != null) {
|
|
|
+ dismissLoading();
|
|
|
+ showDialogChoosePay();
|
|
|
+ } else if (App.app.payChannel == Constant.PAY_POS_DEVICE_PAY_MIX || manualReason != null) {
|
|
|
+ dismissLoading();
|
|
|
showDialogChoosePay();
|
|
|
}
|
|
|
} else if (id == R.id.dishes_ice_cream) {
|
|
|
notifyAddShopCart();
|
|
|
} else if (id == R.id.dishes_add_shop_cart) {
|
|
|
- if (App.app.payChannel == Constant.PAY_POS_DEVICE && !Global.MDBCreditCardSuccess && Global.MDBCreditCardSuccessNumber != 1) {
|
|
|
- showToast(getString(R.string.credit_failed));
|
|
|
- return;
|
|
|
- }
|
|
|
+// if (App.app.payChannel == Constant.PAY_POS_DEVICE && !Global.MDBCreditCardSuccess && Global.MDBCreditCardSuccessNumber != 1) {
|
|
|
+// showToast(getString(R.string.credit_failed));
|
|
|
+// return;
|
|
|
+// }
|
|
|
addShopCart();
|
|
|
|
|
|
} else if (id == R.id.dishes_sauce_1) {
|
|
@@ -514,15 +549,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private ShoppingTrolleyDialogChoosePay shoppingTrolleyDialogChoosePay;
|
|
|
- private void showDialogChoosePay(){
|
|
|
+
|
|
|
+ private void showDialogChoosePay() {
|
|
|
if (shoppingTrolleyDialogChoosePay == null) {
|
|
|
shoppingTrolleyDialogChoosePay = new ShoppingTrolleyDialogChoosePay(getContext());
|
|
|
shoppingTrolleyDialogChoosePay.setCanTouchOutsideDismiss(false);
|
|
|
}
|
|
|
+ ispaySuccess = true;
|
|
|
shoppingTrolleyDialogChoosePay.setListener(new DialogClickListener() {
|
|
|
@Override
|
|
|
public void onClickListener(int type) {
|
|
|
- switch (type){
|
|
|
+ switch (type) {
|
|
|
case 125:
|
|
|
shoppingTrolleyDialogChoosePay.dismiss();
|
|
|
break;
|
|
@@ -532,6 +569,19 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
case R.id.iv_nayax:
|
|
|
showNayaxCreditCard();
|
|
|
break;
|
|
|
+ case R.id.iv_w_mdb_xinyongka:
|
|
|
+ showDialogWMDBCreditCard();
|
|
|
+ break;
|
|
|
+ case R.id.iv_qr_code:
|
|
|
+ if (Hawk.get("PRICEBEAN") != null) {
|
|
|
+ priceBeans = Hawk.get("PRICEBEAN");
|
|
|
+ } else {
|
|
|
+ dismissLoading();
|
|
|
+ showToast("请重新设置价格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ carsPay(str());//国内二码合一支付
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -540,6 +590,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
private CreditCardDialog mCreditCardDialog;
|
|
|
private boolean isCreditCards = false;
|
|
|
+
|
|
|
+
|
|
|
private void showDialogCreditCard() {
|
|
|
Log.d(TAG, "showDialogCreditCard: ");
|
|
|
LogUtils.logWrite("弹出刷卡对话框");
|
|
@@ -583,6 +635,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
mCreditCardDialog.show();
|
|
|
//停止时间
|
|
|
+ dismissLoading();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -726,6 +780,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private void initSpecView() {
|
|
|
+
|
|
|
for (SpecCategoryBean specCategoryBean : currentDish.specCategoryBeans) {
|
|
|
if (DishesBean.SPEC_CATEGORY_SAUCE.equals(specCategoryBean.code)) {
|
|
|
initSpecItems(sauceViews, specCategoryBean, true);
|
|
@@ -785,9 +840,15 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private void initPrice() {
|
|
|
- Log.d(TAG, "debug initPrice1: ");
|
|
|
Log.d(TAG, "debug initPrice: " + PriceUtil.getDishPriceOne(currentDish));
|
|
|
- String p = decimalFormat.format(manualReason == null ? PriceUtil.getDishPriceOne(currentDish) : 0d);
|
|
|
+ Log.d(TAG, "debug initPrice: " + currentDish);
|
|
|
+
|
|
|
+// DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
|
|
+// symbols.setDecimalSeparator('.');
|
|
|
+// DecimalFormat decimalFormat = new DecimalFormat("###################.###########", symbols);
|
|
|
+ String p = CustomDecimalFormat.getDecimalFormat().format(manualReason == null ? PriceUtil.getDishPriceOne(currentDish) : 0);
|
|
|
+// String p=priceBean.getPriceDefault();
|
|
|
+ Log.d(TAG, "initPrice1111: " + p);
|
|
|
int endPosition = p.indexOf(".");
|
|
|
if (endPosition == -1) {
|
|
|
endPosition = p.length();
|
|
@@ -882,11 +943,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
double yPrice;
|
|
|
yPrice = PriceUtil.getAllDishPriceDouble(orderList);
|
|
|
pri = yPrice;
|
|
|
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
|
|
+ symbols.setDecimalSeparator('.');
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("###################.###########", symbols);
|
|
|
realPay = decimalFormat.format(yPrice);
|
|
|
dishes_shop_cart_price.setText("");
|
|
|
int endPosition = realPay.indexOf(".");
|
|
|
if (endPosition == -1) {
|
|
|
- realPay += ".0";
|
|
|
+ if (App.app.payChannel == Constant.PAY_ONLINE)
|
|
|
+ realPay += ".0";
|
|
|
+ } else {
|
|
|
+ realPay += "";
|
|
|
}
|
|
|
|
|
|
int priceLength = realPay.length() + App.app.currencySymbol.length();
|
|
@@ -1150,7 +1217,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
public void event(WmdbIctMessageEvent messageEvent) {
|
|
|
String asciiData = (String) messageEvent.getData();
|
|
|
Log.d(TAG, "event: " + asciiData);
|
|
|
- LogUtils.logWrite("RD:" + asciiData);
|
|
|
+// LogUtils.logWrite("RD:" + asciiData);
|
|
|
switch (messageEvent.getName()) {
|
|
|
case Name.WMDB:
|
|
|
Log.d(TAG, "wmdbDataevent1005: " + asciiData);
|
|
@@ -1191,9 +1258,11 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
scanDialog.dismiss();
|
|
|
scanDialog.stopTimeDown();
|
|
|
}
|
|
|
- showDialogPaySuccess(R.string.pay_success, R.drawable.icon_zhifu_pay);
|
|
|
- LogUtil.d(TAG, "测试event: showDialogPaySuccess" + messageEvent.getData());
|
|
|
-// }
|
|
|
+ if (ispaySuccess) {
|
|
|
+ ispaySuccess = false;
|
|
|
+ showDialogPaySuccess(R.string.pay_success, R.drawable.icon_zhifu_pay);
|
|
|
+ LogUtil.d(TAG, "测试event: showDialogPaySuccess" + messageEvent.getData());
|
|
|
+ }
|
|
|
break;
|
|
|
case "phone":
|
|
|
//实时更新电话联系人和电话号码
|
|
@@ -1278,6 +1347,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
private double remainMoney = 0;
|
|
|
private double coin = 0;
|
|
|
+ private boolean ispaySuccess = true;
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void event(OfflineMessageEvent messageEvent) {
|
|
@@ -1293,9 +1363,13 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
tvMoney.setText(haveMoney + (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri));
|
|
|
remainMoney = Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri;
|
|
|
payPaperSuccess(); // 收钞完成
|
|
|
- EventBus.getDefault().post(new ApiMessageEvent("cashsale", ByteUtils.decimal2fitHex((long) (coin * 100), 4) + ";" + ByteUtils.decimal2fitHex((long) 1, 4)));
|
|
|
+ EventBus.getDefault().post(new ApiMessageEvent("cashsale",
|
|
|
+ ByteUtils.decimal2fitHex((long) (coin * 100), 4)
|
|
|
+ + ";" + ByteUtils.decimal2fitHex((long) 1, 4)));
|
|
|
} else {
|
|
|
- payMixDialog.setNameAndPrice("冰淇淋", String.valueOf(new BigDecimal(pri + "").subtract(Global.hasmoney).subtract(Global.hascoin)));
|
|
|
+ payMixDialog.setNameAndPrice("冰淇淋",
|
|
|
+ String.valueOf(new BigDecimal(pri + "")
|
|
|
+ .subtract(Global.hasmoney).subtract(Global.hascoin)));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1304,6 +1378,15 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
case Name.BEGINSESSION://插卡了
|
|
|
break;
|
|
|
case Name.VENDAPPROVED://支付成功
|
|
|
+ Log.d(TAG, "event: VENDAPPROVED" + ispaySuccess);
|
|
|
+ synchronized (WeaverUtil.class) {
|
|
|
+ if (ispaySuccess) {
|
|
|
+ ispaySuccess = false;
|
|
|
+ if (mMdbCreditCardDialog != null) {
|
|
|
+ mMdbCreditCardDialog.getListener().onClickListener(130);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case Name.ENDSESSION:
|
|
|
if (Hawk.get(Name.END_CREDIT_CARD, false)) {
|
|
@@ -1368,6 +1451,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
});
|
|
|
payMixDialog.show();
|
|
|
+ dismissLoading();
|
|
|
if (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() >= pri) {
|
|
|
tvMoney.setText(haveMoney + (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri));
|
|
|
payPaperSuccess(); // 收钞完成
|
|
@@ -1392,6 +1476,27 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private MdbCreditCardDialog mMdbCreditCardDialog;
|
|
|
+ private Timer tradingTimer;
|
|
|
+ private TimerTask tradingTimerTask;
|
|
|
+ //用于结束监听是否支付成功。
|
|
|
+ private boolean tradingTime = false;
|
|
|
+
|
|
|
+ private void startTradingTimerDown() {
|
|
|
+ tradingTime = false;
|
|
|
+ stopTradingTimerDown(tradingTimer, tradingTimerTask);
|
|
|
+ tradingTimer = new Timer();
|
|
|
+ tradingTimerTask = new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //todo 退出交易的时候结束监听
|
|
|
+ if (tradingTime) {
|
|
|
+ stopTradingTimerDown(tradingTimer, tradingTimerTask);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ tradingTimer.schedule(tradingTimerTask, 6000, 1000);
|
|
|
+ }
|
|
|
|
|
|
private void showDialogWMDBCreditCard() {
|
|
|
double coin = pri;
|
|
@@ -1404,12 +1509,81 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
mMdbCreditCardDialog.setCanTouchOutsideDismiss(false);
|
|
|
}
|
|
|
if (Hawk.get(Name.WMDB, false)) {
|
|
|
- Log.d(TAG, "showDialogWMDBCreditCard: ");
|
|
|
WeaverUtil.creditCardrequestVend(ByteUtils.decimal2fitHex((long) (coin * Global.creditCardMultiplier), 4), "0001");
|
|
|
+ Log.d(TAG, "showDialogWMDBCreditCard: " + coin + ":" + coin * Global.creditCardMultiplier);
|
|
|
Global.beginSession = false;
|
|
|
Global.beginSessionNew = 2;
|
|
|
+ Log.d(TAG, "pay: isPaySuccess4");
|
|
|
}
|
|
|
+ startTradingTimerDown();
|
|
|
+ mMdbCreditCardDialog.setListener(new DialogClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClickListener(int type) {
|
|
|
+ switch (type) {
|
|
|
+ case 125:
|
|
|
+ break;
|
|
|
+ case 130:
|
|
|
+ //通用
|
|
|
+ synchronized (DataUtils.class) {
|
|
|
+ EventBus.getDefault().post(new ApiMessageEvent("vendsuccess", ByteUtils.decimal2fitHex((long) 1, 4)));
|
|
|
+ Log.d(TAG, "event: CreditCardMessage2");
|
|
|
+ try {
|
|
|
+ Thread.sleep(500);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Thread.sleep(500);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ EventBus.getDefault().post(new ApiMessageEvent("sessioncomplete", ByteUtils.decimal2fitHex((long) 1, 4)));//end
|
|
|
+ stopTradingTimerDown(tradingTimer, tradingTimerTask);
|
|
|
+ //支付成功
|
|
|
+ if (mMdbCreditCardDialog != null) {
|
|
|
+ mMdbCreditCardDialog.dismiss();
|
|
|
+ }
|
|
|
+ isCreditCards = true;
|
|
|
+ //显示投币成功弹窗
|
|
|
+ showDialogPaySuccess(R.string.coin_success, R.drawable.img_toubi_pay);
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ Log.d(TAG, "event: CreditCardMessage3");
|
|
|
+ manualMake();
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.btn_cancel:
|
|
|
+ WeaverUtil.creditCardVendCancel();
|
|
|
+ Log.d(TAG, "onClickListener: 取消支付");
|
|
|
+ stopTradingTimerDown(tradingTimer, tradingTimerTask);
|
|
|
+ //关闭 重新支付弹窗倒计
|
|
|
+// if (dialogChoosePay != null) {
|
|
|
+// dialogChoosePay.startTimeDown(60);
|
|
|
+// }
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (mMdbCreditCardDialog != null) {
|
|
|
+ mMdbCreditCardDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 3000);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
mMdbCreditCardDialog.show((ViewGroup) iceCreamView.getParent());
|
|
|
+ dismissLoading();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void stopTradingTimerDown(Timer timer, TimerTask task) {
|
|
|
+ if (timer != null) {
|
|
|
+ task.cancel();
|
|
|
+ timer.cancel();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private Animation notifyAnim;
|
|
@@ -1424,17 +1598,20 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
// 进入手动制作的界面
|
|
|
private void manualMake() {
|
|
|
+ if (App.app.payChannel != Constant.PAY_FREE) {
|
|
|
+ LogUtils.logWrite("制作冰激凌了");
|
|
|
+ }
|
|
|
+ if (loadingDialog != null) {
|
|
|
+ loadingDialog.dismiss();
|
|
|
+ }
|
|
|
if (paySuccessDialog != null) {
|
|
|
paySuccessDialog.dismiss();
|
|
|
}
|
|
|
if (getFragmentManager() != null) {
|
|
|
|
|
|
removeFinish();
|
|
|
-
|
|
|
LinkedList<MakeIceCreamBean> iceCreamOrders = OrderHelper.getInstance().generateMakingIceCream();
|
|
|
-
|
|
|
CommunicationHelper.getInstance().setMakingIceCreams(iceCreamOrders);
|
|
|
-
|
|
|
Fragment fragment = PaySuccessFragment.getFragment(CommunicationHelper.getInstance().getMakingIceCreams().size(), isManualMode());
|
|
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
|
|
transaction.add(getContainerId(), fragment);
|
|
@@ -1481,8 +1658,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
public void carsPay(String productNameMap) {
|
|
|
+ showLoading();
|
|
|
resetFinishDelay();
|
|
|
-
|
|
|
Log.d(TAG, "carsPay: " + productNameMap);
|
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), productNameMap);
|
|
|
String url = "tOrder/iceCreamCarsPay?clientId=" + Heartbeat.deviceId;
|
|
@@ -1516,20 +1693,14 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
LogUtil.d("优惠码过期了哦!", type + "");
|
|
|
break;
|
|
|
default:
|
|
|
- LogUtil.d("SettingPresenter", "测试1");
|
|
|
Gson gson = new Gson();
|
|
|
- LogUtil.d("SettingPresenter", "测试2");
|
|
|
ImgOrderBean imgOrderBean = gson.fromJson(type, ImgOrderBean.class);
|
|
|
- LogUtil.d("SettingPresenter", "测试3" + imgOrderBean);
|
|
|
PaySuccessConstant.sn = imgOrderBean.getSn();
|
|
|
LogUtil.d("SettingPresenter", imgOrderBean.getSn() + "测试3.1:" + PaySuccessConstant.sn);
|
|
|
if (type != null && !TextUtils.isEmpty(imgOrderBean.getRd_Pic()) && !TextUtils.isEmpty(imgOrderBean.getSn())) {
|
|
|
- LogUtil.d("SettingPresenter", "测试4");
|
|
|
getCodeSuccess(imgOrderBean.getRd_Pic(), imgOrderBean.getSn());
|
|
|
//存儲訂單編號。
|
|
|
- LogUtil.d("SettingPresenter", "测试5");
|
|
|
// Global.mapOrderReference.put(imgOrderBean.getSn(), imgOrderBean.getSn());
|
|
|
- LogUtil.d("SettingPresenter", "测试6");
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -1545,24 +1716,19 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
getCodeFailed(t.getMessage());
|
|
|
}
|
|
|
Log.d(TAG, "carsPay onError: " + t.getMessage());
|
|
|
+ dismissLoading();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private void getCodeSuccess(String rd_Pic, String sn) {
|
|
|
- Log.d(TAG, "测试11: ");
|
|
|
LogUtil.d(TAG, "getCodeSuccess: " + rd_Pic);
|
|
|
- Log.d(TAG, "测试13: ");
|
|
|
- Log.d(TAG, "测试12: ");
|
|
|
resetFinishDelay();
|
|
|
-
|
|
|
showDialogScan(rd_Pic, sn);
|
|
|
}
|
|
|
|
|
|
private void showDialogScan(String rd_Pic, String sn) {
|
|
|
- Log.d(TAG, "测试14: ");
|
|
|
// Global.makeStatus = Name.IN_PRODUCTION;
|
|
|
- Log.d(TAG, "测试15");
|
|
|
if (scanDialog == null) {
|
|
|
scanDialog = new ScanDialog(getContext(), getActivity());
|
|
|
}
|
|
@@ -1599,6 +1765,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
// scanDialog.setGifType(frpCode);
|
|
|
scanDialog.setCodeData(rd_Pic, sn);
|
|
|
scanDialog.show();
|
|
|
+ dismissLoading();
|
|
|
Log.d(TAG, "showDialogScan end : ");
|
|
|
|
|
|
/**
|
|
@@ -1614,16 +1781,16 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
Log.d(TAG, "onClick: 总共需要制作的组合:" + orderHelper.getOrderList().size());
|
|
|
Log.d(TAG, "onClick: 总共需要制作冰淇淋的杯数:" + orderHelper.generateMakingIceCream().size());
|
|
|
Log.d(TAG, "onClick: 总价格:" + pri);
|
|
|
-
|
|
|
+ Log.d(TAG, "str112: " + orderHelper.getOrderList());
|
|
|
for (int i = 0; i < orderHelper.getOrderList().size(); i++) {
|
|
|
ShoppingCartBean shoppingCart = new ShoppingCartBean();
|
|
|
Log.d(TAG, "onClick: 冰淇淋组合:" + orderHelper.getOrderList().get(i).selectTag +
|
|
|
// "冰淇淋的金额:"+orderHelper.getOrderList().get(i).price+
|
|
|
"单个商品需要制作的杯数:" + orderHelper.getOrderList().get(i).buyCount);
|
|
|
String str = "";
|
|
|
- String[] parts = orderHelper.getOrderList().get(i).selectTag.split("雪糕");
|
|
|
+ String[] parts = orderHelper.getOrderList().get(i).selectTag.split(",");
|
|
|
str = getStr(str, parts);
|
|
|
- Log.d(TAG, "str: " + str);
|
|
|
+ Log.d(TAG, "str111: " + str);
|
|
|
shoppingCart.setShoppingName(str);//商品名字
|
|
|
shoppingCart.setCount(orderHelper.getOrderList().get(i).buyCount);
|
|
|
shoppingCart.setPrice(Double.parseDouble(currentDish.price));
|
|
@@ -1659,7 +1826,10 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
+ ArrayList<PriceFragment.PriceBean> priceBeans = new ArrayList<>();
|
|
|
+
|
|
|
private String getStr(String str, String[] parts) {
|
|
|
+ Log.d(TAG, "getStrtestPriceBean: " + priceBeans);
|
|
|
for (String part : parts) {
|
|
|
Log.d(TAG, "onClick0: " + part);
|
|
|
if (part.contains("_")) {
|
|
@@ -1668,45 +1838,53 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (index != -1) {
|
|
|
// 获取下划线前面的部分
|
|
|
String part1 = part.substring(0, index);
|
|
|
+ Log.d(TAG, "onClick0getStr: " + part1);
|
|
|
String a = "";
|
|
|
- if (part1.trim().equals("芒果")) {
|
|
|
- a = "果酱(1)";
|
|
|
- } else if (part1.trim().equals("菠萝")) {
|
|
|
- a = "果酱(2)";
|
|
|
- } else if (part1.trim().equals("草莓")) {
|
|
|
- a = "果酱(3)";
|
|
|
+ if (part1.trim().equals(priceBeans.get(3).getChineseName())) {
|
|
|
+ a = priceBeans.get(3).getDefaultName();
|
|
|
+ } else if (part1.trim().equals(priceBeans.get(4).getChineseName())) {
|
|
|
+ a = priceBeans.get(4).getDefaultName();
|
|
|
+ } else if (part1.trim().equals(priceBeans.get(5).getChineseName())) {
|
|
|
+ a = priceBeans.get(5).getDefaultName();
|
|
|
}
|
|
|
- // 获取下划线后面的部分
|
|
|
- String part2 = part.substring(index + 1);
|
|
|
+// // 获取下划线后面的部分
|
|
|
+// Log.d(TAG, "onClick0getStrgetStr1: "+part.substring(index + 1));
|
|
|
+ String part2 = part.substring(index + 1).replace(priceBeans.get(0).getChineseName(), "");
|
|
|
+ Log.d(TAG, "onClick0getStrpart2: " + part2);
|
|
|
String b = "";
|
|
|
- if (part2.trim().equals("花生")) {
|
|
|
- b = "果碎(1)";
|
|
|
- } else if (part2.trim().equals("榛子")) {
|
|
|
- b = "果碎(2)";
|
|
|
+ if (part2.trim().equals(priceBeans.get(1).getChineseName())) {
|
|
|
+ b = priceBeans.get(1).getDefaultName();
|
|
|
+ } else if (part2.trim().equals(priceBeans.get(2).getChineseName())) {
|
|
|
+ b = priceBeans.get(2).getDefaultName();
|
|
|
}
|
|
|
- Log.d(TAG, "onClick1: " + "雪糕" + "-" + a + "," + b);
|
|
|
- str = "雪糕" + "-" + a + "," + b;
|
|
|
+ str = priceBeans.get(0).getDefaultName() + "-" + a + "," + b;
|
|
|
+ Log.d(TAG, "onClick0getStrgetStr3: " + str);
|
|
|
}
|
|
|
} else {
|
|
|
// 字符串中没有下划线的情况处理...
|
|
|
Log.d(TAG, "onClick2: " + part);
|
|
|
- if (part.trim().equals("原味")) {
|
|
|
- str = "雪糕";
|
|
|
+ if (part.trim().equals(priceBeans.get(0).getChineseName())) {
|
|
|
+ str = priceBeans.get(0).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr:priceBeans " + str);
|
|
|
} else {
|
|
|
String s = "";
|
|
|
- if (part.trim().equals("花生")) {
|
|
|
- s = "果碎(1)";
|
|
|
- } else if (part.trim().equals("榛子")) {
|
|
|
- s = "果碎(2)";
|
|
|
- } else if (part.trim().equals("芒果")) {
|
|
|
- s = "果酱(1)";
|
|
|
- } else if (part.trim().equals("菠萝")) {
|
|
|
- s = "果酱(2)";
|
|
|
- } else if (part.trim().equals("草莓")) {
|
|
|
- s = "果酱(3)";
|
|
|
+ if (part.equals(priceBeans.get(1).getChineseName() + priceBeans.get(0).getChineseName())) {
|
|
|
+ s = priceBeans.get(1).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr1:priceBeans " + s);
|
|
|
+ } else if (part.equals(priceBeans.get(2).getChineseName() + priceBeans.get(0).getChineseName())) {
|
|
|
+ s = priceBeans.get(2).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr2:priceBeans " + s);
|
|
|
+ } else if (part.equals(priceBeans.get(3).getChineseName() + priceBeans.get(0).getChineseName())) {
|
|
|
+ s = priceBeans.get(3).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr3:priceBeans " + s);
|
|
|
+ } else if (part.equals(priceBeans.get(4).getChineseName() + priceBeans.get(0).getChineseName())) {
|
|
|
+ s = priceBeans.get(4).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr4:priceBeans " + s);
|
|
|
+ } else if (part.equals(priceBeans.get(5).getChineseName() + priceBeans.get(0).getChineseName())) {
|
|
|
+ s = priceBeans.get(5).getDefaultName();
|
|
|
+ Log.d(TAG, "getStr5:priceBeans " + s);
|
|
|
}
|
|
|
- Log.d(TAG, "onClick3: " + "雪糕" + "-" + s);//这里是只加了一种料的名字
|
|
|
- str = "雪糕" + "-" + s;
|
|
|
+ str = priceBeans.get(0).getDefaultName() + "-" + s;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1747,4 +1925,33 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
.subscribe(observer);
|
|
|
mDisposables.add(observer);
|
|
|
}
|
|
|
+
|
|
|
+ private ZLoadingDialog loadingDialog;
|
|
|
+
|
|
|
+ private void showLoading() {
|
|
|
+ if (loadingDialog == null) {
|
|
|
+ loadingDialog = new ZLoadingDialog(getContext());
|
|
|
+ }
|
|
|
+
|
|
|
+ loadingDialog.setLoadingBuilder(Z_TYPE.DOUBLE_CIRCLE)//设置类型
|
|
|
+ .setLoadingColor(DrawableSelectorUtils.getColorByAttrId(getContext(), R.attr.text_color))//颜色
|
|
|
+ .setHintText("Loading...");
|
|
|
+ Dialog dialog = this.loadingDialog.create();
|
|
|
+ dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
|
|
+ dialog.show();
|
|
|
+ dialog.setCanceledOnTouchOutside(false);
|
|
|
+ dialog.setCancelable(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void dismissLoading() {
|
|
|
+ // 延迟1秒后关闭弹窗
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (loadingDialog != null && loadingDialog.isShowing()) {
|
|
|
+ loadingDialog.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
}
|