|
@@ -6,12 +6,13 @@ import android.animation.AnimatorSet;
|
|
|
import android.animation.ObjectAnimator;
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.app.Dialog;
|
|
|
-import android.content.Intent;
|
|
|
+import android.content.Context;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.annotation.RequiresApi;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
@@ -33,6 +34,8 @@ import android.view.WindowManager;
|
|
|
import android.view.animation.Animation;
|
|
|
import android.view.animation.AnimationUtils;
|
|
|
import android.view.animation.OvershootInterpolator;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
@@ -43,6 +46,7 @@ import com.bgy.autosale.R;
|
|
|
import com.bgy.autosale.entitys.DishesBean;
|
|
|
import com.bgy.autosale.entitys.MakeIceCreamBean;
|
|
|
import com.bgy.autosale.entitys.ResponseBean;
|
|
|
+import com.bgy.autosale.entitys.ShopCartAdapterBean;
|
|
|
import com.bgy.autosale.entitys.SpecBean;
|
|
|
import com.bgy.autosale.entitys.SpecCategoryBean;
|
|
|
import com.bgy.autosale.helpers.ClickHelper;
|
|
@@ -64,8 +68,6 @@ import com.bgy.autosale.payutil.dialog.ShoppingTrolleyDialogChoosePay;
|
|
|
import com.bgy.autosale.ui.MainActivity;
|
|
|
import com.bgy.autosale.ui.adapters.ShopCartAdapter;
|
|
|
import com.bgy.autosale.ui.base.BaseAutoExitFragment;
|
|
|
-import com.bgy.autosale.ui.operator.LockActivity;
|
|
|
-import com.bgy.autosale.ui.operator.MyFragmentActivity;
|
|
|
import com.bgy.autosale.ui.operator.fragments.PriceFragment;
|
|
|
import com.bgy.autosale.ui.widget.BatchingView;
|
|
|
import com.bgy.autosale.ui.widget.ClickLinearLayout;
|
|
@@ -96,11 +98,15 @@ import com.hboxs.base_library.constant.Global;
|
|
|
import com.hboxs.base_library.constant.Heartbeat;
|
|
|
import com.hboxs.base_library.constant.Name;
|
|
|
import com.hboxs.base_library.event.ApiMessageEvent;
|
|
|
+import com.hboxs.base_library.http.NoPayOrderApi;
|
|
|
+import com.hboxs.base_library.http.NoPayOrderStringApi;
|
|
|
import com.hboxs.base_library.http.OrderApi;
|
|
|
import com.hboxs.base_library.http.PayApi;
|
|
|
import com.hboxs.base_library.http.exception.BaseException;
|
|
|
import com.hboxs.base_library.http.exception.ExceptionFactory;
|
|
|
+import com.hboxs.base_library.http.observer.HttpResultNotActivityObserver;
|
|
|
import com.hboxs.base_library.http.observer.HttpResultObserver;
|
|
|
+import com.hboxs.base_library.http.response.HttpResult;
|
|
|
import com.hboxs.base_library.http.response.HttpResultHandler;
|
|
|
import com.hboxs.base_library.util.DialogUtil;
|
|
|
import com.hboxs.base_library.util.DrawableSelectorUtils;
|
|
@@ -126,6 +132,7 @@ import java.text.NumberFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedList;
|
|
@@ -221,8 +228,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
private MdbCreditCardDialog mMdbCreditCardDialog;
|
|
|
private ScanDialog scanDialog;
|
|
|
|
|
|
- private int ADVERTISING_TIME1=Hawk.get(Name.ADVERTISING_TIME1,90);//自动模式
|
|
|
- private int ADVERTISING_TIME2=Hawk.get(Name.ADVERTISING_TIME2,60);//手动模式
|
|
|
+ private int ADVERTISING_TIME1 = Hawk.get(Name.ADVERTISING_TIME1, 90);//自动模式
|
|
|
+ private int ADVERTISING_TIME2 = Hawk.get(Name.ADVERTISING_TIME2, 60);//手动模式
|
|
|
|
|
|
public static IceCreamFragment getFragment(String manualReason) {
|
|
|
Bundle bundle = new Bundle();
|
|
@@ -233,7 +240,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
protected int getExitTime() {
|
|
|
- return isManualMode() ? ADVERTISING_TIME2*1000 : ADVERTISING_TIME1*1000;
|
|
|
+ return isManualMode() ? ADVERTISING_TIME2 * 1000 : ADVERTISING_TIME1 * 1000;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -248,12 +255,12 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
getActivity().getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
|
|
|
}
|
|
|
- RelativeLayout rlSelectLanguage=view.findViewById(R.id.rl_select_language);
|
|
|
- if (Hawk.get(Name.LANGUAGE_SHOW,false)){
|
|
|
+ RelativeLayout rlSelectLanguage = view.findViewById(R.id.rl_select_language);
|
|
|
+ if (Hawk.get(Name.LANGUAGE_SHOW, false)) {
|
|
|
rlSelectLanguage.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
|
|
|
- TextView tvArab=view.findViewById(R.id.tv_arab);
|
|
|
+ TextView tvArab = view.findViewById(R.id.tv_arab);
|
|
|
int languageNumber = Hawk.get(Name.LANGUAGE2, 4);
|
|
|
tvArab.setText(LanguageUtil.LANGUAGE3[languageNumber] + "");
|
|
|
tvArab.setOnClickListener(new View.OnClickListener() {
|
|
@@ -265,16 +272,16 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
exit();
|
|
|
}
|
|
|
});
|
|
|
- TextView tvEnglish=view.findViewById(R.id.tv_english);
|
|
|
+ TextView tvEnglish = view.findViewById(R.id.tv_english);
|
|
|
int language = (int) SharedPreferencesUtils.getParam(Name.LANGUAGE_TYPE2, 1);
|
|
|
- Log.d(TAG, "onViewCreated: "+language);
|
|
|
- tvEnglish.setText(LanguageUtil.LANGUAGE_TEXT2[language-1] + "");
|
|
|
+ Log.d(TAG, "onViewCreated: " + language);
|
|
|
+ tvEnglish.setText(LanguageUtil.LANGUAGE_TEXT2[language - 1] + "");
|
|
|
tvEnglish.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
SharedPreferencesUtils.setParam(Name.LANGUAGE_TYPE, SharedPreferencesUtils.getParam(Name.LANGUAGE_TYPE2, 0));
|
|
|
LanguageUtil.setLanguage();
|
|
|
- Log.d(TAG, "onClick2: "+languageNumber);
|
|
|
+ Log.d(TAG, "onClick2: " + languageNumber);
|
|
|
|
|
|
// Intent intent = getActivity().getIntent(); // 获取当前 Activity 的 Intent
|
|
|
// getActivity().finish(); // 结束当前 Activity
|
|
@@ -343,17 +350,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
// if (!Constant.LANGUAGE_ZH.equals(App.app.language)) {
|
|
|
// logo_hw_iv.setVisibility(View.VISIBLE);
|
|
|
// }
|
|
|
- if (Hawk.get(Name.IC_TEXT,"").equals("")){
|
|
|
+ if (Hawk.get(Name.IC_TEXT, "").equals("")) {
|
|
|
logo_hw_iv.setBackground(UiUtil.getDrawableRes(R.drawable.logo_hw));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
logo_hw_iv.setBackground(null);
|
|
|
- if (Hawk.get(Name.IC_TEXT,"").length()>27&&Hawk.get(Name.IC_TEXT,"").length()<=76){
|
|
|
+ if (Hawk.get(Name.IC_TEXT, "").length() > 27 && Hawk.get(Name.IC_TEXT, "").length() <= 76) {
|
|
|
logo_hw_iv.setTextSize(25);
|
|
|
- }else if (Hawk.get(Name.IC_TEXT,"").length()>76){
|
|
|
+ } else if (Hawk.get(Name.IC_TEXT, "").length() > 76) {
|
|
|
logo_hw_iv.setTextSize(19);
|
|
|
}
|
|
|
- logo_hw_iv.setText(Hawk.get(Name.IC_TEXT,""));
|
|
|
- Log.d(TAG, "onViewCreated00: "+Hawk.get(Name.IC_TEXT,""));
|
|
|
+ logo_hw_iv.setText(Hawk.get(Name.IC_TEXT, ""));
|
|
|
+ Log.d(TAG, "onViewCreated00: " + Hawk.get(Name.IC_TEXT, ""));
|
|
|
}
|
|
|
|
|
|
kernelEffectViews = new AppCompatImageView[]{
|
|
@@ -575,6 +582,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private List<Double> priceList;//分别拿到列表价格。
|
|
|
+ private List<Double> priceList1;//分别拿到列表价格。
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
if (!mClickHelper.canClick()) {
|
|
@@ -585,6 +595,29 @@ 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) {
|
|
|
+ if (Global.isVersions==2){
|
|
|
+ priceList = new ArrayList<>();
|
|
|
+ priceList1 = new ArrayList<>();
|
|
|
+ for (int i = 0; i < orderHelper.getOrderList().size(); i++) {
|
|
|
+ ShoppingCartBean shoppingCart = new ShoppingCartBean();
|
|
|
+ shoppingCart.setShoppingName(orderHelper.getOrderList().get(i).selectTag);//商品名字
|
|
|
+ shoppingCart.setCount(orderHelper.getOrderList().get(i).buyCount);
|
|
|
+ shoppingCart.setPrice(Double.parseDouble(orderHelper.getOrderList().get(i).price));
|
|
|
+ double totalSum = 0.0; // 用于存储总和
|
|
|
+ if (orderHelper.getOrderList().get(i).selectSpecBeans.size() > 0) {
|
|
|
+ for (int j = 0; j < orderHelper.getOrderList().get(i).selectSpecBeans.size(); j++) {
|
|
|
+ totalSum += Double.parseDouble(orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price);
|
|
|
+ }
|
|
|
+ totalSum += shoppingCart.getPrice();
|
|
|
+ } else {
|
|
|
+ totalSum = shoppingCart.getPrice();
|
|
|
+ }
|
|
|
+ for (int k = 0; k < orderHelper.getOrderList().get(i).buyCount; k++) {
|
|
|
+ priceList.add(totalSum); // 将单个商品的总价格添加 buyCount 次
|
|
|
+ }
|
|
|
+ Log.d(TAG, "onClick:orderHelper 商品名字:" + orderHelper.getOrderList().get(i).selectTag + " 单个商品价格:" + totalSum + " 数量:" + orderHelper.getOrderList().get(i).buyCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
showLoading();
|
|
|
if (App.app.payChannel == Constant.PAY_FREE || manualReason != null) {
|
|
|
payType = 0;
|
|
@@ -647,12 +680,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
|
|
|
private ShoppingTrolleyDialogChoosePay shoppingTrolleyDialogChoosePay;
|
|
|
+ int combinationCount;
|
|
|
+ String[] arrayCode;
|
|
|
+ private EditText etDiscountsCode;
|
|
|
|
|
|
private void showDialogChoosePay() {
|
|
|
if (shoppingTrolleyDialogChoosePay == null) {
|
|
|
shoppingTrolleyDialogChoosePay = new ShoppingTrolleyDialogChoosePay(getContext());
|
|
|
shoppingTrolleyDialogChoosePay.setCanTouchOutsideDismiss(false);
|
|
|
}
|
|
|
+ etDiscountsCode = shoppingTrolleyDialogChoosePay.findViewById(R.id.et_discounts_code);
|
|
|
+
|
|
|
ispaySuccess = true;
|
|
|
shoppingTrolleyDialogChoosePay.setListener(new DialogClickListener() {
|
|
|
@Override
|
|
@@ -662,16 +700,13 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
shoppingTrolleyDialogChoosePay.dismiss();
|
|
|
break;
|
|
|
case R.id.iv_qianbi:
|
|
|
- payType = 3;
|
|
|
- showPayMixDialog();
|
|
|
+ handlePaymentSelection(3, R.id.iv_qianbi, () -> showPayMixDialog());
|
|
|
break;
|
|
|
case R.id.iv_nayax:
|
|
|
- payType = 4;
|
|
|
- showNayaxCreditCard();
|
|
|
+ handlePaymentSelection(4, R.id.iv_nayax, () -> showNayaxCreditCard());
|
|
|
break;
|
|
|
case R.id.iv_w_mdb_xinyongka:
|
|
|
- payType = 4;
|
|
|
- showDialogWMDBCreditCard();
|
|
|
+ handlePaymentSelection(4, R.id.iv_w_mdb_xinyongka, () -> showDialogWMDBCreditCard());
|
|
|
break;
|
|
|
case R.id.iv_qr_code:
|
|
|
if (Hawk.get("PRICEBEAN") != null) {
|
|
@@ -681,7 +716,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
showToast("请重新设置价格");
|
|
|
return;
|
|
|
}
|
|
|
- carsPay(str());//国内二码合一支付
|
|
|
+ Log.d(TAG, "onClickListener: 1");
|
|
|
+ handlePaymentSelection(5, R.id.iv_qr_code, () -> carsPay(str()));//国内二码合一支付
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -689,6 +725,31 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
shoppingTrolleyDialogChoosePay.show((ViewGroup) iceCreamView.getParent());
|
|
|
}
|
|
|
|
|
|
+ private void handlePaymentSelection(int payType, int id, Runnable fallbackAction) {
|
|
|
+ this.payType = payType;
|
|
|
+ shoppingNumber = 0;
|
|
|
+ specialPrice = 0;
|
|
|
+ if (Hawk.get(Name.PROMOTION_CODE, false)) {
|
|
|
+ String inputText = etDiscountsCode.getText().toString();
|
|
|
+ if (!inputText.equals("")) {
|
|
|
+ arrayCode = inputText.split("#");
|
|
|
+ combinationCount = arrayCode.length;
|
|
|
+ Log.d(TAG, "handlePaymentSelection: " + arrayCode);
|
|
|
+ if (combinationCount > orderHelper.generateMakingIceCream().size()) {
|
|
|
+ ToastUtil.getInstance().showText(UiUtil.getStringRes(R.string.only_one_code));
|
|
|
+ return; // 直接返回,不继续执行
|
|
|
+ } else {
|
|
|
+ getDiscountCodeOverseas(arrayCode[shoppingNumber], id);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+// manualMake();
|
|
|
+ fallbackAction.run(); // 执行对应的回调方法
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ fallbackAction.run(); // 执行对应的回调方法
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isCreditCards = false;
|
|
|
|
|
|
private void showDialogCreditCard() {
|
|
@@ -962,11 +1023,11 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
// String p=priceBean.getPriceDefault();
|
|
|
Log.d(TAG, "initPrice1111: " + p);
|
|
|
double num = 0;
|
|
|
- if (p.contains("٠")|| p.contains("١")|| p.contains("٢")||
|
|
|
- p.contains("٣")|| p.contains("٤")|| p.contains("٥")||
|
|
|
- p.contains("٦")|| p.contains("٧")|| p.contains("٨")||
|
|
|
- p.contains("٩")){
|
|
|
- String str= p
|
|
|
+ if (p.contains("٠") || p.contains("١") || p.contains("٢") ||
|
|
|
+ p.contains("٣") || p.contains("٤") || p.contains("٥") ||
|
|
|
+ p.contains("٦") || p.contains("٧") || p.contains("٨") ||
|
|
|
+ p.contains("٩")) {
|
|
|
+ String str = p
|
|
|
.replace("٠", "0")
|
|
|
.replace("١", "1")
|
|
|
.replace("٢", "2")
|
|
@@ -984,11 +1045,11 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
num = Double.parseDouble(p);
|
|
|
}
|
|
|
|
|
|
- Log.d(TAG, "initPrice11112: "+num);
|
|
|
+ Log.d(TAG, "initPrice11112: " + num);
|
|
|
int endPosition = p.indexOf(".");
|
|
|
if (endPosition == -1) {
|
|
|
endPosition = p.length();
|
|
@@ -1759,11 +1820,20 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
addShopCartView.startAnimation(notifyAnim);
|
|
|
}
|
|
|
|
|
|
+ private double getPri;
|
|
|
+ private List<Double> getPriceList;
|
|
|
+
|
|
|
// 进入手动制作的界面
|
|
|
private void manualMake() {
|
|
|
Log.d(TAG, "manualMake orderHelper: " + orderHelper.getOrderList().toString());
|
|
|
+ if (arrayCode!=null){
|
|
|
+ for (String s : arrayCode) {
|
|
|
+ updateCode(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (Global.isVersions != 1 && orderHelper.getOrderList().size() > 0) {
|
|
|
for (int i = 0; i < orderHelper.getOrderList().size(); i++) {
|
|
|
+ double totalSum = 0.0; // 用于存储总和
|
|
|
ShoppingCartBean shoppingCart = new ShoppingCartBean();
|
|
|
Log.d(TAG, "onClick: 冰淇淋组合:" + orderHelper.getOrderList().get(i).selectTag);
|
|
|
// "冰淇淋的金额:"+orderHelper.getOrderList().get(i).price+
|
|
@@ -1771,17 +1841,41 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
shoppingCart.setShoppingName(orderHelper.getOrderList().get(i).selectTag);//商品名字
|
|
|
shoppingCart.setCount(orderHelper.getOrderList().get(i).buyCount);
|
|
|
shoppingCart.setPrice(Double.parseDouble(orderHelper.getOrderList().get(i).price));
|
|
|
- double totalSum = 0.0; // 用于存储总和
|
|
|
- if (orderHelper.getOrderList().get(i).selectSpecBeans.size() > 0) {
|
|
|
- for (int j = 0; j < orderHelper.getOrderList().get(i).selectSpecBeans.size(); j++) {
|
|
|
- totalSum += Double.parseDouble(orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price);
|
|
|
+ for (int j = 0; j < orderHelper.getOrderList().get(i).selectSpecBeans.size(); j++) {
|
|
|
+ totalSum += Double.parseDouble(orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price);
|
|
|
+ }
|
|
|
+ totalSum += shoppingCart.getPrice();
|
|
|
+ Log.d(TAG, "manualMake:42 " + totalSum + "*" + orderHelper.getOrderList().get(i).buyCount);
|
|
|
+ getPriceList = new ArrayList<>();
|
|
|
+ for (int j = 0; j < orderHelper.getOrderList().get(i).buyCount; j++) {
|
|
|
+ getPriceList.add(totalSum);
|
|
|
+ }
|
|
|
+ Log.d(TAG, "DecimalFormat: 1");
|
|
|
+ for (int j = 0; j < getPriceList.size(); j++) {
|
|
|
+ DecimalFormat df = new DecimalFormat("#.##");
|
|
|
+ df.setRoundingMode(RoundingMode.HALF_UP);
|
|
|
+ if (priceList1.size() > 0) {
|
|
|
+ double newPri = getPriceList.get(j) - priceList1.get(0);
|
|
|
+ String roundedResult = df.format(newPri);
|
|
|
+ getPriceList.set(j, Double.valueOf(roundedResult));
|
|
|
+ priceList1.remove(0);
|
|
|
+ Log.d(TAG, "DecimalFormat: 2");
|
|
|
}
|
|
|
- totalSum += shoppingCart.getPrice();
|
|
|
- } else {
|
|
|
- totalSum = shoppingCart.getPrice();
|
|
|
}
|
|
|
- number=0;
|
|
|
- saveCoinOrder(shoppingCart.getShoppingName(), totalSum, payType,localOrderSn, orderHelper.getOrderList().get(i).buyCount);
|
|
|
+// if (i<priceList1.size()) {
|
|
|
+// DecimalFormat df = new DecimalFormat("#.##");
|
|
|
+// df.setRoundingMode(RoundingMode.HALF_UP);
|
|
|
+// double newPri= getPriceList.get(i)-priceList1.get(i);
|
|
|
+// String roundedResult = df.format(newPri);
|
|
|
+// getPriceList.set(i, Double.valueOf(roundedResult));
|
|
|
+// }
|
|
|
+ number = 0;
|
|
|
+ double sum = 0.0; // 用于存储总和
|
|
|
+ for (Double price : getPriceList) {
|
|
|
+ sum += price; // 单个商品价格的总和
|
|
|
+ }
|
|
|
+ Log.d(TAG, "manualMake: sum" + sum + ":" + orderHelper.getOrderList().get(i).buyCount);
|
|
|
+ saveCoinOrder(shoppingCart.getShoppingName(), sum, payType,localOrderSn, orderHelper.getOrderList().get(i).buyCount);
|
|
|
}
|
|
|
}
|
|
|
LogUtils.logWrite("制作了" + orderHelper.generateMakingIceCream().size() + "杯冰淇淋");
|
|
@@ -1794,6 +1888,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
if (paySuccessDialog != null) {
|
|
|
paySuccessDialog.dismiss();
|
|
|
}
|
|
|
+ if (shoppingTrolleyDialogChoosePay != null) {
|
|
|
+ shoppingTrolleyDialogChoosePay.dismiss();
|
|
|
+ }
|
|
|
if (getFragmentManager() != null) {
|
|
|
|
|
|
removeFinish();
|
|
@@ -1965,8 +2062,12 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
//scanDialog.startGetTime(sn);
|
|
|
// extracted();
|
|
|
}
|
|
|
-
|
|
|
+ private ArrayList<String> promotionCodes;
|
|
|
private String str() {
|
|
|
+ promotionCodes = new ArrayList<>();
|
|
|
+ if (arrayCode!=null&&arrayCode.length>0){
|
|
|
+ promotionCodes.addAll(Arrays.asList(arrayCode));
|
|
|
+ }
|
|
|
shoppingCartBeanList.clear();
|
|
|
Log.d(TAG, "onClick: 总共需要制作的组合:" + orderHelper.getOrderList().size());
|
|
|
Log.d(TAG, "onClick: 总共需要制作冰淇淋的杯数:" + orderHelper.generateMakingIceCream().size());
|
|
@@ -1989,27 +2090,44 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
Log.d(TAG, "str测试: " + shoppingCartBeanList);
|
|
|
Gson gson = new Gson();
|
|
|
Map<String, String> a = new HashMap<String, String>();
|
|
|
- HashMap<String, String> strings1 = new HashMap<>();
|
|
|
+// HashMap<String, String> strings1 = new HashMap<>();
|
|
|
+
|
|
|
ArrayList<String> strings = new ArrayList<>();
|
|
|
for (int i = 0; i < shoppingCartBeanList.size(); i++) {
|
|
|
strings.clear();
|
|
|
//优惠码集合
|
|
|
for (int i1 = 0; i1 < shoppingCartBeanList.get(i).getCount(); i1++) {
|
|
|
- strings.add("0");
|
|
|
+ if (i1<promotionCodes.size()){
|
|
|
+ strings.add(promotionCodes.get(i1));
|
|
|
+ }else {
|
|
|
+ strings.add("0");
|
|
|
+ }
|
|
|
+ Log.d(TAG, ":shoppingCartBeanList onClick: "+strings+" "+promotionCodes);
|
|
|
}
|
|
|
String s1 = new Gson().toJson(strings);
|
|
|
- if (strings1.size() > 0) {
|
|
|
- String s = strings1.get(shoppingCartBeanList.get(i).getShoppingName());
|
|
|
- if (s != null && "".equals(s)) {
|
|
|
- s1 = s;
|
|
|
- }
|
|
|
+ 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) {
|
|
|
+// promotionCodes.add(s);
|
|
|
+// Log.d(TAG, "showShoppingTrolleyDialog0-2: " + s);
|
|
|
+ promotionCodes.remove(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
String str = gson.toJson(a);
|
|
|
Log.d(TAG, shoppingCartBeanList.size() + "showShoppingTrolleyDialog: " + str);
|
|
@@ -2024,14 +2142,14 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
String getOneTaste = "";
|
|
|
for (String part : parts) {
|
|
|
Log.d(TAG, "onClick0: " + part);
|
|
|
- String[] getFlavorCombinations = part.split(SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0],""));
|
|
|
- Log.d(TAG, "getStr13: "+SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0],""));
|
|
|
+ String[] getFlavorCombinations = part.split(SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0], ""));
|
|
|
+ Log.d(TAG, "getStr13: " + SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0], ""));
|
|
|
for (String getFlavorCombination : getFlavorCombinations) {
|
|
|
Log.d(TAG, "getStr:10 " + getFlavorCombination);
|
|
|
if (getFlavorCombinations.length == 1) {
|
|
|
getOneTaste = getFlavorCombination;
|
|
|
Log.d(TAG, "getStr:14 " + getOneTaste);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Log.d(TAG, "getStr:15 " + getOneTaste);
|
|
|
|
|
|
}
|
|
@@ -2051,10 +2169,10 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
} else {
|
|
|
if (getOneTaste.equals("")) {
|
|
|
str = SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0], getString(PriceFragment.ProductAbout.defaultName[0]));
|
|
|
- Log.d(TAG, "getStr: 16"+str);
|
|
|
+ Log.d(TAG, "getStr: 16" + str);
|
|
|
} else {
|
|
|
str = SPUtils.getInstance(App.app).getString(PriceFragment.ProductAbout.nameKey[0], getString(PriceFragment.ProductAbout.defaultName[0])) + "-" + getOneTaste;
|
|
|
- Log.d(TAG, "getStr: 17"+str);
|
|
|
+ Log.d(TAG, "getStr: 17" + str);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2066,7 +2184,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
|
|
|
public void getPromotionSuccess() {
|
|
|
//直接制作
|
|
|
- //manualMake();
|
|
|
+ manualMake();
|
|
|
}
|
|
|
|
|
|
private void getCodeFailed(String data) {
|
|
@@ -2095,6 +2213,21 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
mDisposables.add(observer);
|
|
|
}
|
|
|
|
|
|
+ protected void addSubscriptionNew(Observable observable, Class clazz, DisposableObserver observer) {
|
|
|
+ if (mDisposables == null) {
|
|
|
+ mDisposables = new CompositeDisposable();
|
|
|
+ }
|
|
|
+ if (clazz == HttpResult.class) {
|
|
|
+ observable = observable.compose(HttpResultHandler.<String>transformer());
|
|
|
+ }
|
|
|
+ observable
|
|
|
+ .unsubscribeOn(Schedulers.io())
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(observer);
|
|
|
+ mDisposables.add(observer);
|
|
|
+ }
|
|
|
+
|
|
|
private ZLoadingDialog loadingDialog;
|
|
|
|
|
|
private void showLoading() {
|
|
@@ -2123,11 +2256,12 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
}, 1000);
|
|
|
}
|
|
|
+
|
|
|
int number = 0;
|
|
|
|
|
|
private String localOrderSn = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
- private void saveCoinOrder(String productName, double price, int payType,String Sn, int productNumber) {
|
|
|
+ private void saveCoinOrder(String productName, double price, int payType, String Sn, int productNumber) {
|
|
|
CoinOrdeBean bean = new CoinOrdeBean();
|
|
|
String sn = UUID.randomUUID().toString().replace("-", "");
|
|
|
bean.setClientId(Heartbeat.deviceId);
|
|
@@ -2135,7 +2269,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
bean.setPayType(payType);
|
|
|
bean.setName(productName + "x" + productNumber);
|
|
|
bean.setProductNumber(productNumber);
|
|
|
- bean.setPrice(price*productNumber);
|
|
|
+ bean.setPrice(price);
|
|
|
bean.setCreateDate(getStackCompleteTime());
|
|
|
bean.setNo(productName + "-" + "I01" + "-" + productNumber);
|
|
|
Gson gson = new Gson();
|
|
@@ -2157,20 +2291,20 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- LogUtils.logWrite("order e:"+t.getMessage());
|
|
|
+ LogUtils.logWrite("order e:" + t.getMessage());
|
|
|
saveCoinOrder(productName, price, payType, sn, productNumber);
|
|
|
}
|
|
|
}, 3000);
|
|
|
- }else if (Hawk.get(Name.AUTOUPLOADORDER, false)) {
|
|
|
+ } else if (Hawk.get(Name.AUTOUPLOADORDER, false)) {
|
|
|
saveErrorOrder(productName, price, payType, sn, productNumber, getStackCompleteTime());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public void saveErrorOrder(String productName, double price, int payType, String sn, int productNumber ,String time){
|
|
|
+ public void saveErrorOrder(String productName, double price, int payType, String sn, int productNumber, String time) {
|
|
|
UpCoinOrderBeanDao upCoinOrderBeanDao = BaseApplication.getBaseApplication().getDaoSession().getUpCoinOrderBeanDao();
|
|
|
- UpCoinOrderBean upCoinOrderBean=new UpCoinOrderBean();
|
|
|
+ UpCoinOrderBean upCoinOrderBean = new UpCoinOrderBean();
|
|
|
upCoinOrderBean.setClientId(Heartbeat.deviceId);
|
|
|
upCoinOrderBean.setSn(sn);
|
|
|
upCoinOrderBean.setProductNumber(productNumber);
|
|
@@ -2309,4 +2443,169 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private int shoppingNumber = 0;
|
|
|
+
|
|
|
+ public void getDiscountCodeOverseas(String code, int id) {
|
|
|
+ String systemId = (String) SharedPreferencesUtils.getParam(Name.SYSTEM_ID, "");
|
|
|
+ if (systemId == null && TextUtils.isEmpty(systemId)) {
|
|
|
+ showToast(UiUtil.getStringRes(R.string.ljsb));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ HashMap<String, String> params = new HashMap<>();
|
|
|
+ params.put("code", code);
|
|
|
+ params.put("clientId", Heartbeat.deviceId);
|
|
|
+ addSubscription(NoPayOrderStringApi.api.selectCode(params),
|
|
|
+ new HttpResultObserver<String>(mView, getContext()) {
|
|
|
+ public void onNext(String type) {
|
|
|
+ Log.d(TAG, "type onNext: " + type);
|
|
|
+ switch (type) {
|
|
|
+ case "0":
|
|
|
+ //成功
|
|
|
+ getPromotionSuccess();
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ //不存在
|
|
|
+ showToast(UiUtil.getStringRes(R.string.promotioncode1));
|
|
|
+// mView.getPromotionFailure(code+UiUtil.getStringRes(R.string.promotioncode1));
|
|
|
+ LogUtil.d("优惠码不存在哦", type + "");
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //已使用
|
|
|
+ showToast(UiUtil.getStringRes(R.string.promotioncode2));
|
|
|
+// mView.getPromotionFailure(code+UiUtil.getStringRes(R.string.promotioncode2));
|
|
|
+ LogUtil.d("优惠码已使用了哦", type + "");
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //此优惠码不是这个商家的
|
|
|
+ showToast(UiUtil.getStringRes(R.string.promotioncode3));
|
|
|
+// mView.getPromotionFailure(code+UiUtil.getStringRes(R.string.promotioncode3));
|
|
|
+ LogUtil.d("此优惠码不是这个商家的哦", type + "");
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ //优惠码过期了哦
|
|
|
+ showToast(UiUtil.getStringRes(R.string.promotioncode4));
|
|
|
+// mView.getPromotionFailure(code+UiUtil.getStringRes(R.string.promotioncode4));
|
|
|
+ LogUtil.d("优惠码过期了哦!", type + "");
|
|
|
+ break;
|
|
|
+ case "success":
|
|
|
+ if (Global.isVersions==2){
|
|
|
+ getConfirmCodeOverseas(code, id);
|
|
|
+ }else {
|
|
|
+ getConfirmCodeSuccess(1, id);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ Log.d(TAG, "DiscountCodeApionNext: " + type);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable t) {
|
|
|
+ super.onError(t);
|
|
|
+// mView.getDiscountCodeOverseasFial();
|
|
|
+ dismissLoading();
|
|
|
+ getCodeFailed(t.getMessage());
|
|
|
+ Log.d(TAG, "getDiscountCodeOverseasFial1 onError: " + t.getMessage());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private double specialPrice = 0;
|
|
|
+
|
|
|
+ public void getConfirmCodeOverseas(String mCodeText, int id) {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("code", mCodeText);
|
|
|
+ addSubscription(NoPayOrderApi.api.getConfirmCode(params).compose(HttpResultHandler.<String>transformer()),
|
|
|
+ new HttpResultNotActivityObserver<String>(mView, getContext()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(String data) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ HashMap<String, Object> hashMap = gson.fromJson(data, HashMap.class);
|
|
|
+ Double discount = (Double) hashMap.get("discount");
|
|
|
+ String type = (String) hashMap.get("type");
|
|
|
+ Log.d(TAG, "discount onNext: " + discount + " " + type); // 输出折扣信息
|
|
|
+ // 处理折扣为负的情况
|
|
|
+ if (discount != null && Double.valueOf(discount) <= 0) {
|
|
|
+ type = "0"; // 设置为默认值
|
|
|
+ }
|
|
|
+ Log.d(TAG, "onClick:orderHelper:0 " + priceList);
|
|
|
+
|
|
|
+ double price = priceList.get(shoppingNumber);
|
|
|
+ double total = 0;
|
|
|
+ double total1 = 0;
|
|
|
+
|
|
|
+ if ("0".equals(type)) {
|
|
|
+ Float data1 = (Float.parseFloat(discount + "")) / 10;
|
|
|
+
|
|
|
+ double result = (price * (1 - data1) * 100) / 100;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.##");
|
|
|
+ df.setRoundingMode(RoundingMode.HALF_UP);
|
|
|
+ String roundedResult = df.format(result);
|
|
|
+ roundedResult = roundedResult.replace(",", ".");
|
|
|
+ total += Double.valueOf(roundedResult);
|
|
|
+ total1 = Double.valueOf(roundedResult);
|
|
|
+ Log.d(TAG, "onClick:orderHelper:1 " + total);
|
|
|
+ } else if ("1".equals(type)) {
|
|
|
+ total = discount;
|
|
|
+ total1 = discount;
|
|
|
+ }
|
|
|
+ priceList1.add(total1);
|
|
|
+ specialPrice += total;
|
|
|
+ Log.d(TAG, "onNextspecialPrice: " + specialPrice);
|
|
|
+ shoppingNumber++;
|
|
|
+ if (shoppingNumber < arrayCode.length) {
|
|
|
+ getDiscountCodeOverseas(arrayCode[shoppingNumber], id);
|
|
|
+ } else {
|
|
|
+ Log.d(TAG, "onNext: getConfirmCodeSuccess");
|
|
|
+ getConfirmCodeSuccess(specialPrice, id);
|
|
|
+ //然后显示价格弹窗。
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable t) {
|
|
|
+ super.onError(t);
|
|
|
+ dismissLoading();
|
|
|
+ getCodeFailed(t.getMessage());
|
|
|
+ Log.d(TAG, "getDiscountCodeOverseasFial onError: " + t.getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getConfirmCodeSuccess(double format, int id) {
|
|
|
+ pri = PriceUtil.getAllDishPriceDouble(orderHelper.getOrderList()) - format;
|
|
|
+ if (id == R.id.iv_qianbi) {
|
|
|
+ showPayMixDialog();
|
|
|
+ } else if (id == R.id.iv_nayax) {
|
|
|
+ showNayaxCreditCard();
|
|
|
+ } else if (id == R.id.iv_w_mdb_xinyongka) {
|
|
|
+ showDialogWMDBCreditCard();
|
|
|
+ }else if (id == R.id.iv_qr_code) {
|
|
|
+ carsPay(str());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateCode(String code) {
|
|
|
+ Map<String, String> map = new HashMap();
|
|
|
+ map.put("code", code);
|
|
|
+ map.put("clientId", Heartbeat.deviceId);
|
|
|
+ addSubscriptionNew(NoPayOrderStringApi.api.updateCode(map), String.class,
|
|
|
+ new HttpResultObserver<String>(mView, getContext()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(String o) {
|
|
|
+ LogUtil.d("updateCode", "onNext: " + o);
|
|
|
+// mView.updateCodeSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable t) {
|
|
|
+ super.onError(t);
|
|
|
+ Log.e(TAG, "Throwable: " + t.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|