Commit 79a55f43 by 宁斌

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
parents 21087f3c 1c6d730d
...@@ -81,20 +81,14 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -81,20 +81,14 @@ public class GsaCloudApplication extends BaseApplication {
*/ */
static { static {
//设置全局的Header构建器 //设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() { SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) -> {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.theme_color, android.R.color.white);//全局设置主题颜色 layout.setPrimaryColorsId(R.color.theme_color, android.R.color.white);//全局设置主题颜色
return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
}
}); });
//设置全局的Footer构建器 //设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() { SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) -> {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter //指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20); return new ClassicsFooter(context).setDrawableSize(20);
}
}); });
} }
...@@ -120,6 +114,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -120,6 +114,7 @@ public class GsaCloudApplication extends BaseApplication {
initPrint(); initPrint();
//初始化日誌管理庫 //初始化日誌管理庫
initXLog(); initXLog();
//初始化服務器地址
initDomainUrl(); initDomainUrl();
//初始化crash記錄 //初始化crash記錄
AppCrashHandler.getInstance().init(this); AppCrashHandler.getInstance().init(this);
...@@ -155,13 +150,15 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -155,13 +150,15 @@ public class GsaCloudApplication extends BaseApplication {
ClassicsFooter.REFRESH_FOOTER_NOTHING = getString(R.string.srl_footer_nothing);//"全部加载完成"; ClassicsFooter.REFRESH_FOOTER_NOTHING = getString(R.string.srl_footer_nothing);//"全部加载完成";
} }
private void initDomainUrl() { public static void initDomainUrl() {
HttpsConstans.isFormal = (boolean) SPUtils.get(getAppContext(), "isFormal", true);
HttpsConstans.init();
//需要單獨配置域名URL的,在接口上添加@Headers({"Domain-Name: settlement_report_server"}),不添加則是使用默認域名 //需要單獨配置域名URL的,在接口上添加@Headers({"Domain-Name: settlement_report_server"}),不添加則是使用默認域名
setGlobalDomain(); setGlobalDomain();
//清機報表請求地址 //清機報表請求地址
RetrofitUrlManager.getInstance().putDomain("settlement_report_server", HttpsConstans.ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL); RetrofitUrlManager.getInstance().putDomain("settlement_report_server", HttpsConstans.ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL);
//gsa報表請求地址 //gsa報表請求地址
RetrofitUrlManager.getInstance().putDomain("gsa_report", HttpsConstans.REPORT_SERVER_ADDRESS); RetrofitUrlManager.getInstance().putDomain("gsa_report", HttpsConstans.REPORT_SERVER_ADDRESS);//DEFAULT_REPORT_ADDRESS
//微信報表請求地址 //微信報表請求地址
RetrofitUrlManager.getInstance().putDomain("wechat_report", HttpsConstans.WECHAR_REPORT_SERVER_ADDRESS); RetrofitUrlManager.getInstance().putDomain("wechat_report", HttpsConstans.WECHAR_REPORT_SERVER_ADDRESS);
//沽清控制請求地址 //沽清控制請求地址
...@@ -189,6 +186,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -189,6 +186,7 @@ public class GsaCloudApplication extends BaseApplication {
public static void setGlobalDomain() { public static void setGlobalDomain() {
//配置全局默認URL //配置全局默認URL
//取出SharedPreferences中存儲的默認服務器地址
RetrofitUrlManager.getInstance().setGlobalDomain(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL); RetrofitUrlManager.getInstance().setGlobalDomain(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL);
} }
......
...@@ -224,11 +224,15 @@ public class MoneyUtil { ...@@ -224,11 +224,15 @@ public class MoneyUtil {
public static BigDecimal divide(double v1, double v2) { public static BigDecimal divide(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return b2;
}
return b1.divide(b2, 2, ROUND_HALF_UP); return b1.divide(b2, 2, ROUND_HALF_UP);
} }
/** /**
* 計算除 * 計算除
*
* @param v1 * @param v1
* @param v2 * @param v2
* @param scale 保留幾位小數 * @param scale 保留幾位小數
...@@ -238,11 +242,15 @@ public class MoneyUtil { ...@@ -238,11 +242,15 @@ public class MoneyUtil {
public static float divide(double v1, double v2, int scale, int RoundingMode) { public static float divide(double v1, double v2, int scale, int RoundingMode) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return 0f;
}
return b1.divide(b2, scale, RoundingMode).floatValue(); return b1.divide(b2, scale, RoundingMode).floatValue();
} }
/** /**
* 計算除 * 計算除
*
* @param v1 * @param v1
* @param v2 * @param v2
* @param scale 保留幾位小數 * @param scale 保留幾位小數
...@@ -251,6 +259,9 @@ public class MoneyUtil { ...@@ -251,6 +259,9 @@ public class MoneyUtil {
public static float divide(double v1, double v2, int scale) { public static float divide(double v1, double v2, int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return 0f;
}
return b1.divide(b2, scale, ROUND_HALF_UP).floatValue(); return b1.divide(b2, scale, ROUND_HALF_UP).floatValue();
} }
......
...@@ -30,7 +30,7 @@ import com.gingersoft.gsa.cloud.base.R; ...@@ -30,7 +30,7 @@ import com.gingersoft.gsa.cloud.base.R;
*/ */
public abstract class DialogUtils { public abstract class DialogUtils {
private Context mContext; private Context mContext;
private Dialog dialog = null; private static Dialog dialog;
private View view; private View view;
private int style = R.style.PhotoDialog; private int style = R.style.PhotoDialog;
private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT; private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT;
...@@ -43,6 +43,7 @@ public abstract class DialogUtils { ...@@ -43,6 +43,7 @@ public abstract class DialogUtils {
view = LayoutInflater.from(mContext).inflate(xmlLayout, null); view = LayoutInflater.from(mContext).inflate(xmlLayout, null);
} }
public DialogUtils(Context mContext, View view) { public DialogUtils(Context mContext, View view) {
this.mContext = mContext; this.mContext = mContext;
this.view = view; this.view = view;
...@@ -64,10 +65,12 @@ public abstract class DialogUtils { ...@@ -64,10 +65,12 @@ public abstract class DialogUtils {
} }
public DialogUtils createDialogView() { public DialogUtils createDialogView() {
dialog = new Dialog(mContext, style); if(dialog != null) {
dialog.dismiss();
}
dialog = new Dialog(mContext);
viewHepler = getViewHepler(); viewHepler = getViewHepler();
initLayout(viewHepler, dialog); initLayout(viewHepler, dialog);
dialog.setContentView(viewHepler.getContentView()); dialog.setContentView(viewHepler.getContentView());
Window dialogWindow = dialog.getWindow(); Window dialogWindow = dialog.getWindow();
// WindowManager.LayoutParams lp = dialogWindow.getAttributes(); // WindowManager.LayoutParams lp = dialogWindow.getAttributes();
...@@ -109,20 +112,20 @@ public abstract class DialogUtils { ...@@ -109,20 +112,20 @@ public abstract class DialogUtils {
} }
public DialogUtils dismiss() { public DialogUtils dismiss() {
if (dialog != null) { if (dialog != null)
dialog.dismiss(); dialog.dismiss();
}
return this; return this;
} }
public DialogUtils setGravity(int gravity) { public DialogUtils setGravity(int gravity) {
if (dialog != null && dialog.getWindow() != null) { if (dialog.getWindow() != null) {
dialog.getWindow().setGravity(gravity); dialog.getWindow().setGravity(gravity);
} }
return this; return this;
} }
public DialogUtils show() { public DialogUtils show() {
dismiss();
dialog.show(); dialog.show();
return this; return this;
} }
...@@ -204,6 +207,12 @@ public abstract class DialogUtils { ...@@ -204,6 +207,12 @@ public abstract class DialogUtils {
return (T) view; return (T) view;
} }
public ViewHepler setOnClickListenter(int viewId, View.OnClickListener onClickListener) {
getView(viewId).setOnClickListener(onClickListener);
return this;
}
/** /**
* 为TextView设置字符串 * 为TextView设置字符串
* *
......
...@@ -4,17 +4,89 @@ package com.gingersoft.gsa.cloud.constans; ...@@ -4,17 +4,89 @@ package com.gingersoft.gsa.cloud.constans;
* Created by Wyh on 2019/12/21. * Created by Wyh on 2019/12/21.
*/ */
public class HttpsConstans { public class HttpsConstans {
//默認為香港
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/ricepon-cloud-gsa/api/"; // public static String ROOT_ADDRESS_FORMAL = "https://m.ricepon.com:8444/ricepon-cloud-gsa/api/";//正式服務器
public static final String ROOT_SERVER_ADDRESS_FORMAL_SZ = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";//深圳服务器 // public static final String ROOT_SERVER_ADDRESS_FORMAL_SZ = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";//深圳服务器
public static final String ROOT_SERVER_ADDRESS_FORMAL_HK = "http://a.ricepon.com:58201/ricepon-cloud-gsa/api/";//香港服务器 // public static final String ROOT_SERVER_ADDRESS_FORMAL_HK = "http://a.ricepon.com:58201/ricepon-cloud-gsa/api/";//香港服务器
// public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9012/api/"; //友常本地
// public static String ROOT_SERVER_SHI_WEI_HK = "http://192.168.1.154:9012/api/"; //世維本地
// //默認為正式
// public static String ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_ADDRESS_FORMAL_HK;
//
// //外賣接單
// public static final String ROOT_SZ_URL = "http://192.168.1.74:6060";//友常本地
// public static final String ROOT_HK_TEST_URL = "https://hktest.ricepon.com:64377";//香港測試
// public static final String ROOT_FORMAL_URL = "https://m.ricepon.com";//正式
// public static String ROOT_URL = HttpsConstans.ROOT_HK_TEST_URL;
//
// //清機接口地址
// public static String ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/";
// //報表地址
// public static String REPORT_SERVER_ADDRESS = "http://a.ricepon.com:58201/ricepon-report/api/";
// //微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據
// public static String WECHAR_REPORT_SERVER_ADDRESS = "http://a.ricepon.com:61177/member-web/api/";
// //報表地址
// public static String _SERVER_ADDRESS = "http://a.ricepon.com:61177/member-web/api/";
//--------------------------------------------其他全局----------------------------------------------------------------------------
private static String HTTP_ADDRESS_URL_FORMAL = "https://m.ricepon.com:8444";//正式服務器
private static String HTTP_ADDRESS_URL_SZ = "http://gingersoft.tpddns.cn:58201";//深圳測試
private static String HTTP_ADDRESS_URL_HK = "http://a.ricepon.com:58201";//香港測試
private static String PATH = "/ricepon-cloud-gsa/api/";//路徑
public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9012/api/"; //友常本地 public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9012/api/"; //友常本地
public static String ROOT_SERVER_SHI_WEI_HK = "http://192.168.1.156:9012/api/"; //世維本地 public static String ROOT_SERVER_SHI_WEI_HK = "http://192.168.1.154:9012/api/"; //世維本地
//------------------------------------------外賣接單---------------------------------------------------------------------------
public static final String ROOT_SZ_URL = "http://192.168.1.74:6060";//友常本地
public static final String ROOT_HK_TEST_URL = "https://hktest.ricepon.com:64377";//香港測試
public static final String ROOT_FORMAL_URL = "https://m.ricepon.com";//正式
//-------------------------------------------報表-------------------------------------------------------------------------------
private static String REPORT_TEST_ADDRESS = "http://a.ricepon.com:58201";//報表測試地址
private static String REPORT_FORMAL_ADDRESS = HTTP_ADDRESS_URL_FORMAL;//報表正式地址
//報表路徑
private static String REPORT_PATH = "/ricepon-report/api/";
//----------------------------------微信公眾號報表地址------------------------------------------------------------------------------------------
private static String WECHAR_REPORT_TEST_ADDRESS = "http://a.ricepon.com:61177";//微信公眾號報表測試地址
private static String WECHAR_REPORT_FORMAL_ADDRESS = HTTP_ADDRESS_URL_FORMAL;//微信公眾號報表正式地址
private static String WECHAR_REPORT_PATH = "/member-web/api/";//微信公眾號報表路徑
//--------------------------------------配置-----------------------------------------------------------------------------------
/**
* 修改這個值控制是否是正式
*/
public static boolean isFormal = true;
//沽清控制地址
public static String _SERVER_ADDRESS = (isFormal ? HTTP_ADDRESS_URL_FORMAL : "http://a.ricepon.com:61177") + "/member-web/api/";
//清機接口地址
public static String ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = isFormal ? HTTP_ADDRESS_URL_FORMAL : REPORT_TEST_ADDRESS;
//默認url,配置這個值修改環境
public static String ROOT_SERVER_ADDRESS_FORMAL = (isFormal ? HTTP_ADDRESS_URL_FORMAL : HTTP_ADDRESS_URL_HK) + PATH;
//修改這個值,配置外賣接單環境
public static String ROOT_URL = isFormal ? ROOT_FORMAL_URL : ROOT_HK_TEST_URL;//正式:ROOT_FORMAL_URL 測試:ROOT_HK_TEST_URL
//修改這個值,修改報表默認環境
public static String REPORT_SERVER_ADDRESS = (isFormal ? REPORT_FORMAL_ADDRESS : REPORT_TEST_ADDRESS) + REPORT_PATH;//測試:REPORT_FORMAL_ADDRESS 正式:REPORT_TEST_ADDRESS
public static String ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/";//清機接口地址 //修改這個值,修改微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據
public static String WECHAR_REPORT_SERVER_ADDRESS = (isFormal ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
public static String REPORT_SERVER_ADDRESS = "http://a.ricepon.com:58201/ricepon-report/api/";//報表地址 public static void init() {
public static String WECHAR_REPORT_SERVER_ADDRESS = "http://a.ricepon.com:61177/member-web/api/";//微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據 _SERVER_ADDRESS = (isFormal ? HTTP_ADDRESS_URL_FORMAL : "http://a.ricepon.com:61177") + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = isFormal ? HTTP_ADDRESS_URL_FORMAL : REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = (isFormal ? HTTP_ADDRESS_URL_FORMAL : HTTP_ADDRESS_URL_HK) + PATH;
ROOT_URL = isFormal ? ROOT_FORMAL_URL : ROOT_HK_TEST_URL;//正式:ROOT_FORMAL_URL 測試:ROOT_HK_TEST_URL
REPORT_SERVER_ADDRESS = (isFormal ? REPORT_FORMAL_ADDRESS : REPORT_TEST_ADDRESS) + REPORT_PATH;//測試:REPORT_FORMAL_ADDRESS 正式:REPORT_TEST_ADDRESS
WECHAR_REPORT_SERVER_ADDRESS = (isFormal ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
}
public static String _SERVER_ADDRESS = "http://a.ricepon.com:61177/member-web/api/";//報表地址
} }
\ No newline at end of file
...@@ -68,9 +68,13 @@ class OrderDetails { ...@@ -68,9 +68,13 @@ class OrderDetails {
//後台不會返回 //後台不會返回
var order_type: Int = 0 var order_type: Int = 0
var orderPayType: Int = 0 var orderPayType: Int = 0
var isDelete: Int = 1 //默認為1,為1時是本店配送,為0是第三方物流 var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送
var payType: Int = 0//1:积分支付;2:支付宝;3:财付通;4:微信支付;5:货到付款;6:其他支付
var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null
var couponList: List<CouponBean>? = null
var estimatedTime: String? = null
class PRODUCTNAMEBean { class PRODUCTNAMEBean {
/** /**
...@@ -123,5 +127,7 @@ class OrderDetails { ...@@ -123,5 +127,7 @@ class OrderDetails {
} }
} }
} }
data class CouponBean(val couponName: String, val discount_amount: Float)
} }
} }
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.utils;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
public class AppDialog {
public static void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
showWaringDialog(context, title, null, null, sureOnclickListenter, null);
}
// public static void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
// showWaringDialog(context, title, null, null, sureOnclickListenter, null);
// }
private static void showWaringDialog(Context context, String title, String confimText, String cancelText, DialogOnClickListenter sureOnclickListenter, DialogOnClickListenter cancelOnclickListenter) {
//暫停接單,彈窗向用戶確認是否關閉
new DialogUtils(context, R.layout.other_order_pause_orders) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
if (title != null)
hepler.setText(R.id.tv_warning_title, title);
if (confimText != null)
hepler.setText(R.id.tv_dialog_confirm, confimText);
if (sureOnclickListenter != null) {
hepler.getView(R.id.tv_dialog_confirm).setOnClickListener(v -> sureOnclickListenter.onclick(v, dialog));
}
if (cancelText != null)
hepler.setText(R.id.tv_dialog_cancel, cancelText);
if (cancelOnclickListenter != null)
hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> cancelOnclickListenter.onclick(v, dialog));
else
hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> dialog.dismiss());
}
}.createDialogView().show();
}
public interface DialogOnClickListenter {
void onclick(View view, Dialog dialog);
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<corners android:radius="@dimen/dp_8" /> <corners android:radius="@dimen/dp_8" />
<stroke <stroke
android:width="@dimen/dp_2" android:width="@dimen/dp_3"
android:color="@color/order_state0_color" /> android:color="@color/order_state0_color" />
</shape> </shape>
\ No newline at end of file
...@@ -480,4 +480,8 @@ ...@@ -480,4 +480,8 @@
<color name="switcher_on_color">#6EBE8C</color> <color name="switcher_on_color">#6EBE8C</color>
<color name="switcher_off_color">#ff4651</color> <color name="switcher_off_color">#ff4651</color>
<color name="switcher_icon_color">@color/white</color> <color name="switcher_icon_color">@color/white</color>
<color name="restaurant_color_open">#6FBE8E</color>
<color name="restaurant_color_busy_close">#F56C6C</color>
<color name="restaurant_color_busy_open">#E6A23C</color>
</resources> </resources>
...@@ -19,4 +19,8 @@ ...@@ -19,4 +19,8 @@
<item name="qmui_arch_swipe_layout_in_back" type="id"/> <item name="qmui_arch_swipe_layout_in_back" type="id"/>
<item name="iv_left_back" type="id"/> <item name="iv_left_back" type="id"/>
<item name="iv_history" type="id"/> <item name="iv_history" type="id"/>
<item name="topbar_right_change_button" type="id"/>
</resources> </resources>
\ No newline at end of file
...@@ -55,7 +55,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas ...@@ -55,7 +55,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
} }
public void login(String account, String pwd) { public void login(String account, String pwd) {
if (account.equals("88888888") && pwd.equals("cc81081168")) { if (account.equals("888888") && pwd.equals("cc81081168")) {
mRootView.startToSwitchServer(); mRootView.startToSwitchServer();
return; return;
} }
...@@ -80,7 +80,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas ...@@ -80,7 +80,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
GsaCloudApplication.userName = info.getData().getUser().getUserName(); GsaCloudApplication.userName = info.getData().getUser().getUserName();
mRootView.showMessage("登陸成功"); mRootView.showMessage("登陸成功");
mRootView.loginSuccess(info); mRootView.loginSuccess(info);
//開啟打印服務 //開啟Prj打印服務
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("openPrintService") .setActionName("openPrintService")
.build() .build()
......
...@@ -10,6 +10,7 @@ import androidx.annotation.NonNull; ...@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.constans.HttpsConstans; import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.login.R; import com.gingersoft.gsa.cloud.login.R;
import com.gingersoft.gsa.cloud.login.R2; import com.gingersoft.gsa.cloud.login.R2;
...@@ -39,12 +40,10 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -39,12 +40,10 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/ */
public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> implements SwitchServerContract.View { public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> implements SwitchServerContract.View {
@BindView(R2.id.rb_server_sz)
RadioButton rbSZ;
@BindView(R2.id.rb_server_hk) @BindView(R2.id.rb_server_hk)
RadioButton rbHK; RadioButton rbHK;
@BindView(R2.id.rb_youchang_hk) @BindView(R2.id.rb_server_formal)
RadioButton rb_youchang_hk; RadioButton rbFormal;
@BindView(R2.id.btn_switch_server) @BindView(R2.id.btn_switch_server)
Button switchServer; Button switchServer;
@BindView(R2.id.tv_now_server) @BindView(R2.id.tv_now_server)
...@@ -65,32 +64,28 @@ public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> im ...@@ -65,32 +64,28 @@ public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> im
return R.layout.activity_switch_server; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0 return R.layout.activity_switch_server; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
} }
///RetrofitUrlManager.getInstance().putDomain("common", HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL);
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
String nowServer = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL; String nowServer = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL;
tvNowServer.setText("當前服務器:" + nowServer); tvNowServer.setText("當前服務器:" + nowServer);
rbHK.setText("香港服務器:" + HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK); if (HttpsConstans.isFormal) {
rbSZ.setText("深圳服務器:" + HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ); rbFormal.setChecked(true);
rb_youchang_hk.setText("世維本地:" + HttpsConstans.ROOT_SERVER_YOU_CHANG_HK); } else {
if (nowServer.equals(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ)) {
rbSZ.setChecked(true);
} else if (nowServer.equals(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK)) {
rbHK.setChecked(true); rbHK.setChecked(true);
}else{
rb_youchang_hk.setChecked(true);
} }
rbHK.setText("測試服務器");
rbFormal.setText("正式服務器");
switchServer.setOnClickListener(v -> { switchServer.setOnClickListener(v -> {
if (rbSZ.isChecked()) { if (rbHK.isChecked()) {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ; SPUtils.put(this, "isFormal", false);
} else if (rbHK.isChecked()) { } else {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK; SPUtils.put(this, "isFormal", true);
}else {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_SHI_WEI_HK;
} }
GsaCloudApplication.setGlobalDomain(); GsaCloudApplication.initDomainUrl();
finish(); finish();
startActivity(new Intent(mContext, LoginActivity.class)); System.exit(0);
}); });
} }
......
...@@ -282,6 +282,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -282,6 +282,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override @Override
public void loginSuccess(LoginBean info) { public void loginSuccess(LoginBean info) {
super.loginSuccess(info); super.loginSuccess(info);
finish();
} }
private boolean isChooseRestaurant = false; private boolean isChooseRestaurant = false;
......
...@@ -10,32 +10,22 @@ ...@@ -10,32 +10,22 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RadioButton <RadioButton
android:id="@+id/rb_server_sz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="深圳環境"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_16" />
<RadioButton
android:id="@+id/rb_server_hk" android:id="@+id/rb_server_hk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/dp_10" android:padding="@dimen/dp_10"
android:text="香港環境" android:text="測試環境"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16" />
<RadioButton <RadioButton
android:id="@+id/rb_youchang_hk" android:id="@+id/rb_server_formal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/dp_10" android:padding="@dimen/dp_10"
android:text="友常本地" android:text="正式環境"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16" />
</RadioGroup> </RadioGroup>
<TextView <TextView
......
...@@ -173,12 +173,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -173,12 +173,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
}
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "清機"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
}
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "清機"));
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境"));
} }
...@@ -317,7 +317,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -317,7 +317,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
.setActionName("showSoldoutCtrlActivity") .setActionName("showSoldoutCtrlActivity")
.build() .build()
.call(); .call();
}else if(name.equals("餐臺管理")){ } else if (name.equals("餐臺管理")) {
CC.obtainBuilder("Component.Manager") CC.obtainBuilder("Component.Manager")
.setActionName("showTableManageActivity") .setActionName("showTableManageActivity")
.build() .build()
......
...@@ -58,7 +58,7 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean ...@@ -58,7 +58,7 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean
helper.setTextColor(R.id.tv_ranking_food_unit_price, mContext.getResources().getColor(R.color.color_3c)); helper.setTextColor(R.id.tv_ranking_food_unit_price, mContext.getResources().getColor(R.color.color_3c));
helper.setTextColor(R.id.tv_ranking_proportion_quantity, mContext.getResources().getColor(R.color.color_3c)); helper.setTextColor(R.id.tv_ranking_proportion_quantity, mContext.getResources().getColor(R.color.color_3c));
helper.setTextColor(R.id.tv_ranking_ratio_amount, mContext.getResources().getColor(R.color.color_3c)); helper.setTextColor(R.id.tv_ranking_ratio_amount, mContext.getResources().getColor(R.color.color_3c));
if (item != null) {
helper.setText(R.id.tv_ranking_food_unit_price, item.getPrice() + ""); helper.setText(R.id.tv_ranking_food_unit_price, item.getPrice() + "");
helper.setText(R.id.tv_ranking_foodname, item.getProductName()); helper.setText(R.id.tv_ranking_foodname, item.getProductName());
helper.setText(R.id.tv_ranking_food_sales_num, item.getNumber() + ""); helper.setText(R.id.tv_ranking_food_sales_num, item.getNumber() + "");
...@@ -67,4 +67,5 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean ...@@ -67,4 +67,5 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean
helper.setText(R.id.tv_ranking_ratio_amount, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getAmount(), totalAmount, 2, ROUND_HALF_UP), 100)) + "%"); helper.setText(R.id.tv_ranking_ratio_amount, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getAmount(), totalAmount, 2, ROUND_HALF_UP), 100)) + "%");
} }
} }
}
} }
...@@ -188,11 +188,13 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales ...@@ -188,11 +188,13 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
public void loadInfo(List<SalesFoodsBean.DataBean.SalesRankingBean> salesRanking) { public void loadInfo(List<SalesFoodsBean.DataBean.SalesRankingBean> salesRanking) {
totalAmount = 0; totalAmount = 0;
totalNum = 0; totalNum = 0;
for (SalesFoodsBean.DataBean.SalesRankingBean salesRankingBean : salesRanking) { for (SalesFoodsBean.DataBean.SalesRankingBean salesRankingBean : salesRanking) {
if (salesRankingBean != null) {
totalAmount = MoneyUtil.sum(totalAmount, salesRankingBean.getAmount()); totalAmount = MoneyUtil.sum(totalAmount, salesRankingBean.getAmount());
totalNum = totalNum + salesRankingBean.getNumber(); totalNum = totalNum + salesRankingBean.getNumber();
} }
}
List<SalesFoodsBean.DataBean.SalesRankingBean> rankings = new ArrayList<>(salesRanking); List<SalesFoodsBean.DataBean.SalesRankingBean> rankings = new ArrayList<>(salesRanking);
rankings.add(0, new SalesFoodsBean.DataBean.SalesRankingBean()); rankings.add(0, new SalesFoodsBean.DataBean.SalesRankingBean());
if (mSortNumberingAdapter == null) { if (mSortNumberingAdapter == null) {
......
...@@ -71,6 +71,7 @@ dependencies { ...@@ -71,6 +71,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
<application> <application>
<activity <activity
android:name=".ui.activity.OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
android:launchMode="singleTop"
android:label="@string/app_name" /> android:label="@string/app_name" />
<service android:name=".service.GetInfoUpdateService" /> <service android:name=".service.GetInfoUpdateService" />
<activity android:name=".ui.activity.HistoryOrderActivity" /> <activity android:name=".ui.activity.HistoryOrderActivity" />
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" /> android:value="ConfigModule" />
<activity android:name=".ui.activity.DeliverySettingActivity"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data
import com.gingersoft.gsa.other_order_mode.data.network.DeliveryNetwork
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
class DeliveryRepository private constructor(private val network: DeliveryNetwork) {
suspend fun queryDeliveryList(restaurantId: String) = withContext(Dispatchers.IO){
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.build()
network.queryDeliveryList(requestBody)
}
companion object {
private lateinit var instance: DeliveryRepository
fun getInstance(network: DeliveryNetwork): DeliveryRepository {
if (!Companion::instance.isInitialized) {
synchronized(DeliveryRepository::class.java) {
if (!Companion::instance.isInitialized) {
instance = DeliveryRepository(network)
}
}
}
return instance
}
}
}
\ No newline at end of file
...@@ -7,13 +7,15 @@ import okhttp3.FormBody ...@@ -7,13 +7,15 @@ import okhttp3.FormBody
class HistoryOrderRepository private constructor(private val network: CoolWeatherNetwork) { class HistoryOrderRepository private constructor(private val network: CoolWeatherNetwork) {
suspend fun getHistoryOrderList(restaurantId: String, status: String, pageIndex: String, pageSize: String, orderNo: String = "", phone: String = "") = withContext(Dispatchers.IO) { suspend fun getHistoryOrderList(restaurantId: String, status: String, startDate: String, endDate: String, pageIndex: String, pageSize: String, orderNo: String = "", phone: String = "") = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId) .add("restaurantId", restaurantId)
.add("status", status) .add("status", status)
.add("pageIndex", pageIndex) .add("pageIndex", pageIndex)
.add("pageSize", pageSize) .add("pageSize", pageSize)
.add("orderNo", orderNo) .add("orderNo", orderNo)
.add("startDate", startDate)
.add("endDate", endDate)
.add("phone", phone) .add("phone", phone)
.build() .build()
val heWeather = network.getHistoryOrderList(requestBody) val heWeather = network.getHistoryOrderList(requestBody)
......
...@@ -6,6 +6,8 @@ import com.google.gson.Gson ...@@ -6,6 +6,8 @@ import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.RequestBody
import kotlin.Pair as Pair1
class WeatherRepository private constructor(private val network: CoolWeatherNetwork) { class WeatherRepository private constructor(private val network: CoolWeatherNetwork) {
...@@ -30,10 +32,10 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -30,10 +32,10 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network.getOrderGroupNum(requestBody) network.getOrderGroupNum(requestBody)
} }
suspend fun updateRestOpenStatus(state: Boolean, restaurantId: String) = withContext(Dispatchers.IO) { suspend fun updateRestOpenStatus(state: Int, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restId", restaurantId) .add("restId", restaurantId)
.add("openStatus", if (state) "1" else "2") .add("openStatus", state.toString())
.build() .build()
val data = network.updateRestOpenStatus(requestBody) val data = network.updateRestOpenStatus(requestBody)
data data
...@@ -47,6 +49,16 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -47,6 +49,16 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data data
} }
suspend fun getShipanyOrderTime(restaurantId: String, orderId: String, type: Int) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.add("restaurantId", restaurantId)
.add("type", type.toString())//1、预计整张订单完成时间2、預計配送員接單時間3、預計配送員到店時間4、配送員預計送達時間
.build()
network.getShipanyOrderTime(requestBody)
}
suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int) = withContext(Dispatchers.IO) { suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("orderId", orderId) .add("orderId", orderId)
...@@ -96,6 +108,26 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -96,6 +108,26 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network.getDeliveryConfigDTO(requestBody) network.getDeliveryConfigDTO(requestBody)
} }
suspend fun cancelLogistics(shopId: String, orderId: String) = withContext(Dispatchers.IO) {
network.cancelLogistics(getBody("restaurantId" to shopId, "orderId" to orderId))
}
suspend fun updateOrderStates(memberId: String, orderId: String, status: String, updateBy: String) = withContext(Dispatchers.IO) {
network.cancelOrder(getBody("memberId" to memberId, "orderId" to orderId, "status" to status, "type" to "2", "updateBy" to updateBy))
}
fun getBody(vararg pair: Pair1<String, String>): RequestBody {
val requestBody = FormBody.Builder()
requestBody.apply {
pair.forEach {
requestBody.add(it.first, it.second)
}
}
return requestBody.build()
}
companion object { companion object {
private lateinit var instance: WeatherRepository private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class CancelLogisticsBean(val code: String, val success: Boolean, val errCode: String, val errMsg: String, val sysTime: Long, val data: Data) {
data class Data(val result: Result) {
data class Result(val code: Int, val descr: String)
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class Data(
val estimated_time: Int
)
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class EstimatedBean(
val `data`: Data,
val success: Boolean,
val sysTime: Long
)
\ No newline at end of file
...@@ -5,12 +5,16 @@ data class OrderGoupNumBean( ...@@ -5,12 +5,16 @@ data class OrderGoupNumBean(
val success: Boolean, val success: Boolean,
val sysTime: Long) { val sysTime: Long) {
data class Data( data class Data(
val self: List<SelfTakeaway>, val self: List<Self>,
val selfTakeaway: List<SelfTakeaway>, val selfTakeaway: List<SelfTakeaway>,
val takeaway: List<SelfTakeaway>) { val takeaway: List<SelfTakeaway>) {
data class SelfTakeaway( data class SelfTakeaway(
val STATUS: Int, val STATUS: Int,
val SumNum: Int val SumNum: Int
) )
data class Self(val STATUS: Int,
val selfSumNum: Int)
} }
} }
\ No newline at end of file
...@@ -71,6 +71,8 @@ class OrderList { ...@@ -71,6 +71,8 @@ class OrderList {
var PHONE: String? = null var PHONE: String? = null
var orderPayType: Int = 0 var orderPayType: Int = 0
var ORDER_NO: String? = null var ORDER_NO: String? = null
var sendTime: String? = null
var waimaiSendTime:String? = null
var Id: Int = 0 var Id: Int = 0
var CREATE_TIME: String? = null var CREATE_TIME: String? = null
var takeFoodCode: String? = null var takeFoodCode: String? = null
...@@ -82,7 +84,7 @@ class OrderList { ...@@ -82,7 +84,7 @@ class OrderList {
var maxOrderSelf: Int = 0 var maxOrderSelf: Int = 0
var num: Int = 0 var num: Int = 0
var dayOrderNum: Int = 0 var dayOrderNum: Int = 0
var Open_Status: String? = null//1為營業中 2為休息中 var Open_Status: String? = null//0=休息中, 1=營業中,2=繁忙中不可接單,3繁忙可接單
var orderType_2: OrderType? = null var orderType_2: OrderType? = null
var orderType_7: OrderType? = null var orderType_7: OrderType? = null
......
...@@ -16,27 +16,46 @@ class CoolWeatherNetwork { ...@@ -16,27 +16,46 @@ class CoolWeatherNetwork {
private val service = ServiceCreator.create2(WeatherService::class.java) private val service = ServiceCreator.create2(WeatherService::class.java)
private val gsposService = ServiceCreator.create3(WeatherService::class.java) private val gsposService = ServiceCreator.create3(WeatherService::class.java)
//獲取訂單列表
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await() suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
//修改餐廳營業狀態
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await() suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
//獲取訂單分組數量,例:待確認訂單數量,製作中訂單數量。。。
suspend fun getOrderGroupNum(requestBody: RequestBody) = orderService.getOrderGroupNum(requestBody).await() suspend fun getOrderGroupNum(requestBody: RequestBody) = orderService.getOrderGroupNum(requestBody).await()
//獲取訂單信息
suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await() suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await()
//獲取第三方物流信息
suspend fun getShipanyOrderTime(requestBody: RequestBody) = gsposService.getShipanyOrderTime(requestBody).await()
//修改訂單狀態
suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await() suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await()
//第三方配送接口
suspend fun thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await() suspend fun thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await()
//修改自取訂單狀態
suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await() suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await()
// 獲取餐廳配送人員信息
suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await() suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await()
//獲取物流配置
suspend fun getDeliveryConfigDTO(requestBody: RequestBody) = gsposService.getDeliveryConfigDTO(requestBody).await() suspend fun getDeliveryConfigDTO(requestBody: RequestBody) = gsposService.getDeliveryConfigDTO(requestBody).await()
//獲取歷史訂單
suspend fun getHistoryOrderList(requestBody: RequestBody) = orderService.getHistoryOrderList(requestBody).await() suspend fun getHistoryOrderList(requestBody: RequestBody) = orderService.getHistoryOrderList(requestBody).await()
//取消物流
suspend fun cancelLogistics(requestBody: RequestBody) = gsposService.cancelLogistics(requestBody).await()
//取消訂單,有物流需要提示先取消物流
suspend fun cancelOrder(requestBody: RequestBody) = service.cancelOrder(requestBody).await()
private suspend fun <T> Call<T>.await(): T { private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation -> return suspendCoroutine { continuation ->
enqueue(object : Callback<T> { enqueue(object : Callback<T> {
......
package com.gingersoft.gsa.other_order_mode.data.network
import com.gingersoft.gsa.other_order_mode.data.network.api.DeliveryService
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
class DeliveryNetwork {
private val orderService = ServiceCreator.create(DeliveryService::class.java)
private val service = ServiceCreator.create2(DeliveryService::class.java)
private val gsposService = ServiceCreator.create3(DeliveryService::class.java)
//獲取物流配置
suspend fun queryDeliveryList(requestBody: RequestBody) = gsposService.queryDeliveryList(requestBody).await()
private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation ->
enqueue(object : Callback<T> {
override fun onFailure(call: Call<T>, t: Throwable) {
t.printStackTrace()
continuation.resumeWithException(t)
}
override fun onResponse(call: Call<T>, response: Response<T>) {
val body = response.body()
if (body != null) {
continuation.resume(body)
} else continuation.resumeWithException(RuntimeException("response body is null") as Throwable)
}
})
}
}
companion object {
private var network: DeliveryNetwork? = null
fun getInstance(): DeliveryNetwork {
if (network == null) {
synchronized(DeliveryNetwork::class.java) {
if (network == null) {
network = DeliveryNetwork()
}
}
}
return network!!
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.network package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.cloud.constans.HttpsConstans
import com.gingersoft.gsa.cloud.globalconfig.applyOptions.intercept.LoggingInterceptor import com.gingersoft.gsa.cloud.globalconfig.applyOptions.intercept.LoggingInterceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
...@@ -8,17 +10,15 @@ import retrofit2.converter.scalars.ScalarsConverterFactory ...@@ -8,17 +10,15 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
object ServiceCreator { object ServiceCreator {
private val httpClient = OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS).addInterceptor(LoggingInterceptor()) private val httpClient = OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS).addInterceptor(LoggingInterceptor())
private const val ROOT_SZ_URL = "http://192.168.1.74:6060" var ROOT_URL: String = HttpsConstans.ROOT_URL
private const val ROOT_HK_TEST_URL = "https://hktest.ricepon.com:64377"
private const val ROOT_FORMAL_URL = "https://m.ricepon.com"
const val ROOT_URL = ROOT_HK_TEST_URL private var BASE_URL = "$ROOT_URL/ricepon-wechat/api/"
private var BASE_URL2 = "$ROOT_URL/member-web/api/"
private var BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/"
private const val BASE_URL = "$ROOT_URL/ricepon-wechat/api/"
private const val BASE_URL2 = "$ROOT_URL/member-web/api/"
private const val BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/"
private val builder = Retrofit.Builder() private val builder = Retrofit.Builder()
...@@ -26,6 +26,9 @@ object ServiceCreator { ...@@ -26,6 +26,9 @@ object ServiceCreator {
.client(httpClient.build()) .client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.apply {
Log.e("eee", "服務器地址$ROOT_URL")
}
private val builder2 = Retrofit.Builder() private val builder2 = Retrofit.Builder()
.baseUrl(BASE_URL2) .baseUrl(BASE_URL2)
......
package com.gingersoft.gsa.other_order_mode.data.network.api
import com.gingersoft.gsa.other_order_mode.data.model.bean.DeliveryConfig
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
interface DeliveryService {
@POST("gsa/getDeliveryConfigDTO")
fun queryDeliveryList(@Body requestBody: RequestBody): Call<DeliveryConfig>
}
\ No newline at end of file
...@@ -21,6 +21,9 @@ interface WeatherService { ...@@ -21,6 +21,9 @@ interface WeatherService {
@POST("wechat/findOrderDetails") @POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails> fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
@POST("gsa/calculateEstimatedTime")
fun getShipanyOrderTime(@Body requestBody: RequestBody): Call<EstimatedBean>
@POST("wechat/updateOrderStatus") @POST("wechat/updateOrderStatus")
fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean> fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
...@@ -38,4 +41,10 @@ interface WeatherService { ...@@ -38,4 +41,10 @@ interface WeatherService {
@POST("wechat/findHistoryOrderList") @POST("wechat/findHistoryOrderList")
fun getHistoryOrderList(@Body requestBody: RequestBody): Call<HistoryOrderBean> fun getHistoryOrderList(@Body requestBody: RequestBody): Call<HistoryOrderBean>
@POST("gsa/cancelOrder")
fun cancelLogistics(@Body requestBody: RequestBody): Call<CancelLogisticsBean>
@POST("order/updateOrderStatus")
fun cancelOrder(@Body requestBody: RequestBody): Call<CancelLogisticsBean>
} }
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.factory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.data.DeliveryRepository
import com.gingersoft.gsa.other_order_mode.model.viewModel.DeliveryViewModel
class DeliveryFactory(private val repository: DeliveryRepository) : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return DeliveryViewModel(repository) as T
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.viewModel
import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
import kotlinx.coroutines.launch
open class BaseViewModel : ViewModel() {
protected fun showLoading(context: Context, message: String? = null) {
if (message != null)
LoadingDialog.showDialogForLoading(context, message, true)
else
LoadingDialog.showDialogForLoading(context)
}
protected fun cancelDialogForLoading() {
LoadingDialog.cancelDialogForLoading()
}
protected fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
} catch (e: Throwable) {
error(e)
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.viewModel
import com.gingersoft.gsa.other_order_mode.data.DeliveryRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.DeliveryConfig
class DeliveryViewModel(private val repository: DeliveryRepository) : BaseViewModel() {
fun queryDeliveryList(restaurantId: String, listenter: (DeliveryConfig?) -> Unit) {
launch({
repository.queryDeliveryList(restaurantId).apply {
listenter.invoke(this)
}
}, {
listenter.invoke(null)
})
}
}
...@@ -13,10 +13,7 @@ import kotlinx.coroutines.launch ...@@ -13,10 +13,7 @@ import kotlinx.coroutines.launch
class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepository) : ViewModel() { class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepository) : ViewModel() {
var data = MutableLiveData<HistoryOrderBean>() var data = MutableLiveData<HistoryOrderBean>()
/** fun getHistoryOrderList(context: Context, pageIndex: String, orderNum: String = "", startDate: String, endDate: String, listener: (HistoryOrderBean?) -> Unit) {
* 根據訂單id獲取訂單詳細信息
*/
fun getHistoryOrderList(context: Context, pageIndex: String, orderNum: String = "", listener: (HistoryOrderBean) -> Unit) {
launch({ launch({
var phone = "" var phone = ""
var orderNumber = "" var orderNumber = ""
...@@ -26,7 +23,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo ...@@ -26,7 +23,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
orderNumber = orderNum orderNumber = orderNum
} }
historyOrderRepository.getHistoryOrderList(GsaCloudApplication.getRestaurantId(context).toString(), "4", pageIndex, "10", orderNumber, phone).apply { historyOrderRepository.getHistoryOrderList(GsaCloudApplication.getRestaurantId(context).toString(), "4", startDate, endDate, pageIndex, "10", orderNumber, phone).apply {
this.getData()?.let { this.getData()?.let {
if (it.size > 0) { if (it.size > 0) {
it.removeAt(it.size - 1)//移除最後一個,最後一個是顯示總條數的 it.removeAt(it.size - 1)//移除最後一個,最後一個是顯示總條數的
...@@ -39,11 +36,12 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo ...@@ -39,11 +36,12 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
if (pageIndex == "1") { if (pageIndex == "1") {
data.value = this data.value = this
} }
listener.invoke(data.value!!) listener.invoke(data.value)
} }
}, { }, {
//出錯 //出錯
it.printStackTrace() it.printStackTrace()
listener.invoke(null)
}) })
} }
......
package com.gingersoft.gsa.other_order_mode.ui.activity
import android.os.Bundle
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.ui.fragment.UpdateDeliveryFragment
import kotlinx.android.synthetic.main.activity_delivery.*
class DeliverySettingActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_delivery)
top_bar_delivery.setTitle("備送設置")
top_bar_delivery.setBackgroundColor(resources.getColor(R.color.theme_color))
top_bar_delivery.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
top_bar_delivery.addRightImageButton(R.drawable.ic_add, R.id.topbar_right_change_button).setOnClickListener { v ->
supportFragmentManager.beginTransaction().replace(R.id.fl_delivery, UpdateDeliveryFragment.newInstance()).addToBackStack(null).commit()
}
}
}
\ No newline at end of file
...@@ -6,6 +6,8 @@ import androidx.lifecycle.ViewModelProvider ...@@ -6,6 +6,8 @@ import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView import butterknife.BindView
import com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.R2 import com.gingersoft.gsa.other_order_mode.R2
...@@ -17,6 +19,8 @@ import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils ...@@ -17,6 +19,8 @@ import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.gingersoft.gsa.other_order_mode.util.setState import com.gingersoft.gsa.other_order_mode.util.setState
import com.scwang.smartrefresh.layout.SmartRefreshLayout import com.scwang.smartrefresh.layout.SmartRefreshLayout
import kotlinx.android.synthetic.main.activity_history_order.* import kotlinx.android.synthetic.main.activity_history_order.*
import java.text.ParseException
import java.util.*
class HistoryOrderActivity : BaseActivity() { class HistoryOrderActivity : BaseActivity() {
...@@ -35,18 +39,23 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -35,18 +39,23 @@ class HistoryOrderActivity : BaseActivity() {
rvOrderList = findViewById(R.id.rv_other_order) rvOrderList = findViewById(R.id.rv_other_order)
layoutNoData = findViewById(R.id.layout_nodata) layoutNoData = findViewById(R.id.layout_nodata)
tv_start_time.text = TimeUtils.getOldDate(0)
tv_end_time.text = TimeUtils.getOldDate(0)
initAppTop() initAppTop()
rvOrderList.layoutManager = LinearLayoutManager(this) rvOrderList.layoutManager = LinearLayoutManager(this)
initViewModel() initViewModel()
getHistoryInfo() getHistoryInfo(time = tv_start_time.text.toString())
initSearch() initSearch()
initRefresh() initRefresh()
} }
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "") {
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "", time: String) {
showLoading() showLoading()
mViewModel.getHistoryOrderList(this, page.toString(), orderNum) { mViewModel.getHistoryOrderList(this, page.toString(), orderNum, time, time) {
cancelDialogForLoading() cancelDialogForLoading()
it?.let {
refreshLayout.setEnableLoadMore(it.getData() != null) refreshLayout.setEnableLoadMore(it.getData() != null)
refreshLayout.finishRefresh() refreshLayout.finishRefresh()
refreshLayout.finishLoadMore() refreshLayout.finishLoadMore()
...@@ -59,7 +68,7 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -59,7 +68,7 @@ class HistoryOrderActivity : BaseActivity() {
cancelDialogForLoading() cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) { if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗 //顯示彈窗
OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { _, _ -> OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { view, _, _ ->
//確認訂單、指派送貨點擊事件 //確認訂單、指派送貨點擊事件
} }
} else { } else {
...@@ -71,7 +80,8 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -71,7 +80,8 @@ class HistoryOrderActivity : BaseActivity() {
mHistoryOrderAdapter!!.data = it.getData() mHistoryOrderAdapter!!.data = it.getData()
mHistoryOrderAdapter!!.notifyDataSetChanged() mHistoryOrderAdapter!!.notifyDataSetChanged()
} }
layoutNoData.setState(it.getData() == null || it.getData()!!.size <= 0) }
layoutNoData.setState(it?.getData() == null || it.getData()!!.size <= 0)
} }
} }
...@@ -83,7 +93,7 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -83,7 +93,7 @@ class HistoryOrderActivity : BaseActivity() {
iv_search_order.setOnClickListener { iv_search_order.setOnClickListener {
//搜索 //搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) { if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
getHistoryInfo(1, ed_order_num_search.text.toString()) getHistoryInfo(1, ed_order_num_search.text.toString(), "")
} else { } else {
ToastUtils.show(this@HistoryOrderActivity, "請輸入手機號或訂單號") ToastUtils.show(this@HistoryOrderActivity, "請輸入手機號或訂單號")
} }
...@@ -96,11 +106,11 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -96,11 +106,11 @@ class HistoryOrderActivity : BaseActivity() {
//下拉刷新,加載更多 //下拉刷新,加載更多
refreshLayout.setOnRefreshListener { refreshLayout.setOnRefreshListener {
pageIndex = 1 pageIndex = 1
getHistoryInfo() getHistoryInfo(time = tv_start_time.text.toString())
} }
refreshLayout.setOnLoadMoreListener { refreshLayout.setOnLoadMoreListener {
pageIndex++ pageIndex++
getHistoryInfo() getHistoryInfo(time = tv_start_time.text.toString())
} }
} }
...@@ -109,4 +119,43 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -109,4 +119,43 @@ class HistoryOrderActivity : BaseActivity() {
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() } qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color)) qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
} }
fun onClickListener(v: View?) {
when (v!!.id) {
R.id.iv_start_time_triangle, R.id.tv_start_time -> {
iv_start_time_triangle.toggle()
val cal = Calendar.getInstance()
try {
//設置默認時間為當前的起止時間
cal.time = TimeUtils.DATE_FORMAT_DATE.parse(tv_start_time.text.toString())
} catch (e: ParseException) {
e.printStackTrace()
}
TimePickerUtils.showReportTimePicker(this@HistoryOrderActivity, cal) { date, v ->
tv_start_time.text = TimeUtils.DATE_FORMAT_DATE.format(date)
}.setOnDismissListener {
iv_start_time_triangle.toggle()
pageIndex = 1
getHistoryInfo(time = tv_start_time.text.toString())
}
}
// R.id.tv_end_time, R.id.iv_end_time_triangle -> {
// iv_end_time_triangle.toggle()
// val cal = Calendar.getInstance()
// try {
// //設置默認時間為當前的起止時間
// cal.time = TimeUtils.DATE_FORMAT_DATE.parse(tv_end_time.text.toString())
// } catch (e: ParseException) {
// e.printStackTrace()
// }
// TimePickerUtils.showReportTimePicker(this@HistoryOrderActivity, cal) { date, v ->
// tv_end_time.text = TimeUtils.DATE_FORMAT_DATE.format(date)
// }.setOnDismissListener {
// iv_end_time_triangle.toggle()
// pageIndex = 1
// getHistoryInfo()
// }
// }
}
}
} }
\ No newline at end of file
...@@ -13,10 +13,9 @@ import android.media.SoundPool ...@@ -13,10 +13,9 @@ import android.media.SoundPool
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.view.LayoutInflater
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.core.animation.doOnEnd
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
...@@ -24,7 +23,6 @@ import androidx.lifecycle.ViewModelProvider ...@@ -24,7 +23,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.ui.view.SwitchButton
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
...@@ -32,6 +30,10 @@ import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService ...@@ -32,6 +30,10 @@ import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import com.gingersoft.gsa.other_order_mode.ui.adapter.SectionsPagerAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.SectionsPagerAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView
import com.qmuiteam.qmui.util.QMUIDisplayHelper
import com.qmuiteam.qmui.widget.popup.QMUIPopup
import com.qmuiteam.qmui.widget.popup.QMUIPopups
import kotlinx.android.synthetic.main.activity_other_order.* import kotlinx.android.synthetic.main.activity_other_order.*
...@@ -60,7 +62,6 @@ class OtherOrderActivity : BaseActivity() { ...@@ -60,7 +62,6 @@ class OtherOrderActivity : BaseActivity() {
private var layoutHeight: Float = 0F private var layoutHeight: Float = 0F
private var btnHeight: Float = 0F private var btnHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order) val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
...@@ -159,26 +160,85 @@ class OtherOrderActivity : BaseActivity() { ...@@ -159,26 +160,85 @@ class OtherOrderActivity : BaseActivity() {
} }
} }
private var restaurantPopup: QMUIPopup? = null
private var stateBg = GradientDrawable()
/** /**
* 切換餐廳狀態按鈕 * 切換餐廳狀態按鈕
*/ */
private fun initSwitchRestStatus() { private fun initSwitchRestStatus() {
stateBg.cornerRadius = QMUIDisplayHelper.dp2px(this, 4).toFloat()
btnOpenBg = resources.getDrawable(R.drawable.shape_white_bottom_border) btnOpenBg = resources.getDrawable(R.drawable.shape_white_bottom_border)
btnCloseBg = resources.getDrawable(R.drawable.shape_dialog_bg) btnCloseBg = resources.getDrawable(R.drawable.shape_dialog_bg)
btn_switch_restaurant_state.setOnClickListener { //切換營業狀態
pageViewModel.setRestaurantState(this, !(it as SwitchButton).statusBasedOnPos) tv_restaurant_state.setOnClickListener {
if (restaurantPopup == null) {
val view: View = LayoutInflater.from(this).inflate(R.layout.popup_layout_restaurant_state, null)
restaurantPopup = QMUIPopups.popup(this)
.preferredDirection(QMUIPopup.DIRECTION_BOTTOM)
.view(view)
.radius(QMUIDisplayHelper.dp2px(this, 5))
.arrow(false)
.shadow(false)
.offsetYIfTop(0)
.animStyle(QMUIPopup.ANIM_AUTO)
.show(it)
view.apply {
//營業中
findViewById<TextView>(R.id.tv_restaurant_open).setOnClickListener {
updateRestaurantState(1)
}
//休息中
findViewById<TextView>(R.id.tv_restaurant_close).setOnClickListener {
updateRestaurantState(0)
}
//繁忙不接單
findViewById<TextView>(R.id.tv_restaurant_busy_close).setOnClickListener {
updateRestaurantState(2)
}
//繁忙可接單
findViewById<TextView>(R.id.tv_restaurant_busy_open).setOnClickListener {
updateRestaurantState(3)
}
}
} else {
restaurantPopup?.show(it)
}
} }
//綁定營業按鈕狀態 //綁定營業按鈕狀態
pageViewModel.restaurantState.observe(this, Observer { pageViewModel.restaurantState.observe(this, Observer {
btn_switch_restaurant_state.isChecked = it when (it) {
0 -> {
tv_restaurant_state.text = "休息中"
stateBg.setColor(resources.getColor(R.color.color_c8))
}
1 -> {
tv_restaurant_state.text = "營業中"
stateBg.setColor(resources.getColor(R.color.restaurant_color_open))
}
2 -> {
tv_restaurant_state.text = "繁忙不接"
stateBg.setColor(resources.getColor(R.color.restaurant_color_busy_close))
}
3 -> {
tv_restaurant_state.text = "繁忙可接"
stateBg.setColor(resources.getColor(R.color.restaurant_color_busy_open))
}
}
tv_restaurant_state.background = stateBg
}) })
btn_open_or_close_info.setOnClickListener { btn_open_or_close_info.setOnClickListener {
setOrderInfoOpenOrClose() setOrderInfoOpenOrClose()
} }
} }
private fun updateRestaurantState(state: Int) {
pageViewModel.setRestaurantState(this@OtherOrderActivity, state)
restaurantPopup?.dismiss()
}
private fun initWebsocket() { private fun initWebsocket() {
//開啟websocket //開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java) val intent = Intent(this, GetInfoUpdateService::class.java)
...@@ -199,7 +259,7 @@ class OtherOrderActivity : BaseActivity() { ...@@ -199,7 +259,7 @@ class OtherOrderActivity : BaseActivity() {
if (type == 3 || type == 4 || type == 5 if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) { || type == 6 || type == 7) {
//播放提示音 //播放提示音
if (type == 5) { if (type == 5 || type == 4) {
pageViewModel.refreshState.postValue(1) pageViewModel.refreshState.postValue(1)
} else { } else {
pageViewModel.refreshState.postValue(type) pageViewModel.refreshState.postValue(type)
...@@ -312,16 +372,47 @@ class OtherOrderActivity : BaseActivity() { ...@@ -312,16 +372,47 @@ class OtherOrderActivity : BaseActivity() {
view.requestLayout() view.requestLayout()
} }
private var pop: QMUIPopup? = null
/** /**
* 初始化標題欄 * 初始化標題欄
*/ */
private fun initAppTop() { private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.app_name) qm_other_order_bar.setTitle(GsaCloudApplication.getRestaurantName(this))
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() } qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_other_order_bar.addRightImageButton(R.drawable.ic_history_order, R.id.iv_history).setOnClickListener { qm_other_order_bar.addRightImageButton(R.drawable.icon_topbar_overflow, R.id.topbar_right_change_button).setOnClickListener {
//彈出彈窗
if (pop == null) {
val view = LayoutInflater.from(this).inflate(R.layout.layout_more_popup, null)
pop = QMUIPopups.popup(this)
.preferredDirection(QMUIPopup.DIRECTION_BOTTOM)
.view(view)
.radius(QMUIDisplayHelper.dp2px(this, 5))
.arrow(true)
.shadow(true)
.dimAmount(0.6f)
.offsetYIfTop(0)
.animStyle(QMUIPopup.ANIM_AUTO)
.show(it)
view.findViewById<QMUIAlphaTextView>(R.id.tv_delivery_setting).setOnClickListener {
//備送設置
startActivity(Intent(this, DeliverySettingActivity::class.java))
pop!!.dismiss()
}
view.findViewById<QMUIAlphaTextView>(R.id.tv_history_order).setOnClickListener {
//歷史訂單 //歷史訂單
startActivity(Intent(this, HistoryOrderActivity::class.java)) startActivity(Intent(this, HistoryOrderActivity::class.java))
pop!!.dismiss()
}
} else {
pop!!.show(it)
}
} }
// qm_other_order_bar.addRightImageButton(R.drawable.ic_history_order, R.id.iv_history).setOnClickListener {
// //歷史訂單
// startActivity(Intent(this, HistoryOrderActivity::class.java))
// }
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color)) qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
} }
} }
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.DeliveryConfig
import com.gingersoft.gsa.other_order_mode.databinding.ItemDeliveryLayoutBinding
class DeliveryListAdapter(val context: Context, data: List<DeliveryConfig.Data.DeliveryInfo>) : BaseQuickAdapter<DeliveryConfig.Data.DeliveryInfo, DeliveryListAdapter.ViewHolder>(data) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_delivery_layout, null)
return ViewHolder(view)
}
override fun convert(helper: ViewHolder?, item: DeliveryConfig.Data.DeliveryInfo?) {
helper?.let { helper ->
helper.binding.apply {
// deliveryType = when(item!!.distributionType){
// "SHORT_RANGE"->
// "STANDARD"->
// "LONG_DISTANCE"->
// else ->""
// }
item?.let { it ->
deliveryType = it.distributionType
deliveryExpenses = "${it.distributionFeeMin}-${it.distributionFeeMax}"
deliveryFee = it.distributionFee.toString()
deliveryMethod = if (it.type == 1) "物流備送" else "本店備送"
deliveryDifference = it.deliveryCost.toString()
}
}
}
}
class ViewHolder(itemView: View) : BaseViewHolder(itemView) {
var binding: ItemDeliveryLayoutBinding = DataBindingUtil.bind(itemView)!!
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.adapter package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.animation.Animator
import android.animation.AnimatorSet import android.animation.AnimatorSet
import android.animation.ObjectAnimator.ofFloat import android.animation.ObjectAnimator.ofFloat
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.content.Context import android.content.Context
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.support.v4.media.session.PlaybackStateCompat
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -45,10 +43,8 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -45,10 +43,8 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
holder.binding.data = data holder.binding.data = data
holder.binding.isSelf = data.order_type == 7 holder.binding.isSelf = data.order_type == 7
data.trkNo?.apply {
if (length > 0) {
holder.binding.deliveryState = when (data.curStat) { holder.binding.deliveryState = when (data.curStat) {
1 -> "訂單已創建" 1 -> "已通知物流"
2 -> "配送員已接單" 2 -> "配送員已接單"
3 -> "配送員到店附近" 3 -> "配送員到店附近"
4 -> "配送員已到店" 4 -> "配送員已到店"
...@@ -60,8 +56,6 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -60,8 +56,6 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
10 -> "已指派另一位配送員" 10 -> "已指派另一位配送員"
else -> "" else -> ""
} }
}
}
var state: String? = null var state: String? = null
val bg = GradientDrawable() val bg = GradientDrawable()
...@@ -100,20 +94,22 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -100,20 +94,22 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
//堂食外賣背景 //堂食外賣背景
val orderingMethodBg = GradientDrawable() val orderingMethodBg = GradientDrawable()
orderingMethodBg.shape = GradientDrawable.OVAL orderingMethodBg.shape = GradientDrawable.RECTANGLE
orderingMethodBg.cornerRadii = floatArrayOf(dp2px(8f).toFloat(), dp2px(8f).toFloat(), 0f, 0f, 0f, 0f, dp2px(8f).toFloat(), dp2px(8f).toFloat())
holder.binding.orderingMethod = holder.binding.orderingMethod =
when { when {
data.order_type == 2 -> { data.order_type == 2 -> {
orderingMethodBg.setColor(getColor(R.color.order_state2_color)) orderingMethodBg.setColor(getColor(R.color.order_state2_color))
"外" "外"
} }
data.order_type == 7 -> { data.order_type == 7 -> {
orderingMethodBg.setColor(getColor(R.color.order_state3_color)) orderingMethodBg.setColor(getColor(R.color.order_state3_color))
"自" "自"
} }
else -> { else -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color)) orderingMethodBg.setColor(getColor(R.color.order_state1_color))
"堂" "堂"
} }
} }
holder.binding.orderingMethodBg = orderingMethodBg holder.binding.orderingMethodBg = orderingMethodBg
......
package com.gingersoft.gsa.other_order_mode.ui.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.DeliveryViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryListAdapter
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.fragment_delivery_list.*
class DeliveryFragment : Fragment() {
companion object {
fun newInstance() = DeliveryFragment()
}
private lateinit var viewModel: DeliveryViewModel
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_delivery_list, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getDeliveryFactory())[DeliveryViewModel::class.java]
viewModel.queryDeliveryList(GsaCloudApplication.getRestaurantId(activity!!).toString()) {
if (it?.data?.list != null && it.data.list.isNotEmpty()) {
val deliveryListAdapter = DeliveryListAdapter(context!!, it.data.list)
rv_delivery.adapter = deliveryListAdapter
rv_delivery.layoutManager = LinearLayoutManager(context!!)
rv_delivery.visibility = View.VISIBLE
} else {
rv_delivery.visibility = View.GONE
}
}
// rv_delivery
}
}
...@@ -9,6 +9,9 @@ import androidx.lifecycle.MutableLiveData ...@@ -9,6 +9,9 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter
...@@ -17,6 +20,9 @@ import com.gingersoft.gsa.other_order_mode.util.InjectorUtil ...@@ -17,6 +20,9 @@ import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.gingersoft.gsa.other_order_mode.util.setState import com.gingersoft.gsa.other_order_mode.util.setState
import kotlinx.android.synthetic.main.fragment_other_order.* import kotlinx.android.synthetic.main.fragment_other_order.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlin.String as String1
/** /**
* A placeholder fragment containing a simple view. * A placeholder fragment containing a simple view.
...@@ -51,28 +57,71 @@ class PlaceholderFragment : BaseFragment() { ...@@ -51,28 +57,71 @@ class PlaceholderFragment : BaseFragment() {
adapter.setOnItemClickListenter { data -> adapter.setOnItemClickListenter { data ->
// 點擊查詢食品詳情 // 點擊查詢食品詳情
showLoading() showLoading()
pageViewModel.getOrderInfo(data.Id.toString()) { it1 -> pageViewModel.getShipanyAndOrderInfo(data.curStat, GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) { it1 ->
//顯示彈窗
cancelDialogForLoading() cancelDialogForLoading()
//顯示彈窗
if (this@PlaceholderFragment.context != null && it1 != null) { if (this@PlaceholderFragment.context != null && it1 != null) {
OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { _, dialog -> OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { view, _, dialog ->
when (view.id) {
R.id.btn_assign_shipping -> {
//修改訂單狀態
pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) { pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
dialog.dismiss() dialog.dismiss()
if (it) { if (it) {
// 關閉彈窗,並刷新當前頁面 // 關閉彈窗,並刷新當前頁面
refresh() refresh()
// pageViewModel.refreshState.postValue(pageViewModel.refreshState.value!! + 1)
} }
} }
} }
R.id.btn_cancel_order -> {
//取消訂單,先判斷有沒有物流
showLoading()
if (it1.data!![0].isDelete == 0) {
//第三方物流單
//彈出彈窗詢問是否確認取消
AppDialog.showWaringDialog(context, "是否確認取消第三方派送?") { v, dialog ->
when (v.id) {
R.id.tv_dialog_confirm -> {
//取消物流
pageViewModel.cancelLogistics(GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) {
ToastUtils.show(context, it)
cancelDialogForLoading()
refresh()//刷新當前頁面
}
dialog.dismiss()
}
R.id.tv_dialog_cancel -> dialog.dismiss()
}
}
} else {
//本店配送的單
pageViewModel.cancelOrder(context!!, data.Id.toString()) {
ToastUtils.show(context, if (it) {
"取消訂單成功"
} else {
"取消訂單失敗"
})
cancelDialogForLoading()
refresh()//刷新當前頁面
}
}
dialog.dismiss()
}
}
}
} else {
ToastUtils.show(context, "獲取訂單詳情失敗")
} }
} }
} }
rv_other_order.adapter = adapter rv_other_order.adapter = adapter
//有多少個Fragment就添加多少個監聽
while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) { while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
pageViewModel.mOrderList.add(MutableLiveData()) pageViewModel.mOrderList.add(MutableLiveData())
} }
// 綁定當前fragment的數據項 // 綁定監聽當前fragment的數據項
pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer { pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
it.let { adapter.setData(it) } it.let { adapter.setData(it) }
}) })
...@@ -82,8 +131,10 @@ class PlaceholderFragment : BaseFragment() { ...@@ -82,8 +131,10 @@ class PlaceholderFragment : BaseFragment() {
// 下拉刷新,加載更多 // 下拉刷新,加載更多
refresh_layout.setOnRefreshListener { refresh_layout.setOnRefreshListener {
refresh() refresh()
//重新拉取一遍送貨員和第三方派送信息
pageViewModel.getDeliveryInfo(context!!)
pageViewModel.getDeliveryConfigDTO(context!!)
} }
refresh_layout.setOnLoadMoreListener { refresh_layout.setOnLoadMoreListener {
page++ page++
getOrderList(pageViewModel, true) getOrderList(pageViewModel, true)
......
package com.gingersoft.gsa.other_order_mode.ui.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.DeliveryViewModel
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.update_delivery_fragment.*
class UpdateDeliveryFragment : Fragment() {
companion object {
fun newInstance() = UpdateDeliveryFragment()
}
private lateinit var viewModel: DeliveryViewModel
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.update_delivery_fragment, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getDeliveryFactory())[DeliveryViewModel::class.java]
top_bar_update_delivery.setTitle("備送設置")
top_bar_update_delivery.setBackgroundColor(resources.getColor(R.color.theme_color))
top_bar_update_delivery.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { activity?.let { it.onBackPressed() } }
}
}
package com.gingersoft.gsa.other_order_mode.util package com.gingersoft.gsa.other_order_mode.util
import com.gingersoft.gsa.other_order_mode.data.DeliveryRepository
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import com.gingersoft.gsa.other_order_mode.data.network.DeliveryNetwork
import com.gingersoft.gsa.other_order_mode.model.factory.DeliveryFactory
import com.gingersoft.gsa.other_order_mode.model.factory.HistoryOrderModelFactory import com.gingersoft.gsa.other_order_mode.model.factory.HistoryOrderModelFactory
import com.gingersoft.gsa.other_order_mode.model.factory.WeatherModelFactory import com.gingersoft.gsa.other_order_mode.model.factory.WeatherModelFactory
...@@ -19,5 +22,6 @@ object InjectorUtil { ...@@ -19,5 +22,6 @@ object InjectorUtil {
private fun getHistoryRepository() = HistoryOrderRepository.getInstance(CoolWeatherNetwork.getInstance()) private fun getHistoryRepository() = HistoryOrderRepository.getInstance(CoolWeatherNetwork.getInstance())
fun getDeliveryFactory() = DeliveryFactory(DeliveryRepository.getInstance(DeliveryNetwork.getInstance()))
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.gingersoft.gsa.other_order_mode.util ...@@ -2,7 +2,7 @@ package com.gingersoft.gsa.other_order_mode.util
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.widget.Button import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
...@@ -17,7 +17,7 @@ import com.jess.arms.utils.ArmsUtils ...@@ -17,7 +17,7 @@ import com.jess.arms.utils.ArmsUtils
object OtherOrderUtils { object OtherOrderUtils {
fun showOrderDetailsDialog(context: Context, data: OrderDetails, orderStuats: Int, orderType: Int, showBtn: Boolean = true, listenter: ((data: OrderDetails.DataBean, dialog: Dialog) -> Unit)?) { fun showOrderDetailsDialog(context: Context, data: OrderDetails, orderStuats: Int, orderType: Int, showBtn: Boolean = true, listenter: ((view: View, data: OrderDetails.DataBean, dialog: Dialog) -> Unit)?) {
object : DialogUtils(context, R.layout.layout_order_info_dialog_new) { object : DialogUtils(context, R.layout.layout_order_info_dialog_new) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) { override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (data.data != null) { if (data.data != null) {
...@@ -30,7 +30,9 @@ object OtherOrderUtils { ...@@ -30,7 +30,9 @@ object OtherOrderUtils {
//如果有物流號,就不顯示指派送貨按鈕 //如果有物流號,就不顯示指派送貨按鈕
layoutOrderInfoDialogBinding.showBtn = showBtn layoutOrderInfoDialogBinding.showBtn = showBtn
val btnContent: String val btnContent: String
val type = if (orderType == 7) "自取" else "外賣" var cancelBtnContent = ""
val type = if (orderType == 7) "自取" else "外送"
val orderStatus: String val orderStatus: String
when (orderStuats) { when (orderStuats) {
...@@ -39,11 +41,14 @@ object OtherOrderUtils { ...@@ -39,11 +41,14 @@ object OtherOrderUtils {
//自取 //自取
btnContent = "製作完成" btnContent = "製作完成"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color)) tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
cancelBtnContent = "取消訂單"
} else { } else {
btnContent = if (orderData.isDelete == 1) { if (orderData.isDelete == 0) {
"指派送貨" btnContent = "重印"
cancelBtnContent = "取消物流"
} else { } else {
"重印" btnContent = "指派送貨"
cancelBtnContent = "取消訂單"
} }
tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color)) tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color))
} }
...@@ -64,19 +69,40 @@ object OtherOrderUtils { ...@@ -64,19 +69,40 @@ object OtherOrderUtils {
btnContent = "確認訂單" btnContent = "確認訂單"
orderStatus = "待確認" orderStatus = "待確認"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color)) tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
cancelBtnContent = "取消訂單"
}
}
layoutOrderInfoDialogBinding.patMethod = when (orderData.payType) {
1 -> "积分支付"
2 -> "支付宝"
3 -> "财付通"
4 -> "微信支付"
5 -> "货到付款"
6 -> "其他支付"
else -> ""
} }
if (!showBtn) {
cancelBtnContent = ""
} }
layoutOrderInfoDialogBinding.orderStatus = type + orderStatus layoutOrderInfoDialogBinding.orderStatus = type + orderStatus
layoutOrderInfoDialogBinding.btnContent = btnContent layoutOrderInfoDialogBinding.btnContent = btnContent
layoutOrderInfoDialogBinding.cancelBtnContent = cancelBtnContent
layoutOrderInfoDialogBinding.estimatedTime = orderData.estimatedTime
} }
val rvFood: RecyclerView = hepler.getView(R.id.rv_food) val rvFood: RecyclerView = hepler.getView(R.id.rv_food)
rvFood.layoutManager = LinearLayoutManager(context) rvFood.layoutManager = LinearLayoutManager(context)
rvFood.adapter = FoodListAdapter(context, data.data!![0].PRODUCT_NAME!!) rvFood.adapter = FoodListAdapter(context, data.data!![0].PRODUCT_NAME!!)
hepler.getView<Button>(R.id.btn_assign_shipping).setOnClickListener { hepler.setOnClickListenter(R.id.btn_assign_shipping) {
//指派送貨或是確認訂單? //指派送貨或是確認訂單?
//確認訂單,調用接口,並打印 //確認訂單,調用接口,並打印
listenter?.invoke(data.data!![0], dialog) listenter?.invoke(it, data.data!![0], dialog)
}
hepler.setOnClickListenter(R.id.btn_cancel_order) {
//取消訂單
listenter?.invoke(it, data.data!![0], dialog)
} }
hepler.getView<ImageView>(R.id.iv_close).setOnClickListener { hepler.getView<ImageView>(R.id.iv_close).setOnClickListener {
......
package com.gingersoft.gsa.other_order_mode.util package com.gingersoft.gsa.other_order_mode.util
import android.content.Context
import android.graphics.drawable.Drawable
import android.view.View import android.view.View
fun View.setState(state: Boolean) { fun View.setState(state: Boolean) {
...@@ -9,3 +11,8 @@ fun View.setState(state: Boolean) { ...@@ -9,3 +11,8 @@ fun View.setState(state: Boolean) {
View.GONE View.GONE
} }
} }
fun Context.getDrawable(drawable: Int): Drawable {
return this.resources.getDrawable(drawable)
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_4"/>
<solid android:color="@color/restaurant_color_open"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fl_delivery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/top_bar_delivery"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" />
<fragment
android:name="com.gingersoft.gsa.other_order_mode.ui.fragment.DeliveryFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/top_bar_delivery" />
</RelativeLayout>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/color_f0" android:background="@color/color_f0"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.OtherOrderActivity"> tools:context=".ui.activity.HistoryOrderActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="@dimen/dp_10"> android:padding="@dimen/dp_10">
<EditText <EditText
...@@ -35,11 +37,11 @@ ...@@ -35,11 +37,11 @@
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_search_bg" android:background="@drawable/shape_white_search_bg"
android:hint="請輸入手機號或訂單號" android:hint="請輸入手機號或訂單號"
android:inputType="number"
android:paddingLeft="@dimen/dp_10" android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_50" android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc" android:textColorHint="@color/color_ccc"
android:inputType="number"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
...@@ -54,9 +56,70 @@ ...@@ -54,9 +56,70 @@
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search" app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="@id/ed_order_num_search" app:layout_constraintRight_toRightOf="@id/ed_order_num_search"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" /> app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<TextView
android:id="@+id/tv_start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:onClick="onClickListener"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="@id/ed_order_num_search"
app:layout_constraintTop_toBottomOf="@id/ed_order_num_search" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_start_time_triangle"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
android:onClick="onClickListener"
app:layout_constraintBottom_toBottomOf="@id/tv_start_time"
app:layout_constraintLeft_toRightOf="@id/tv_start_time"
app:layout_constraintTop_toTopOf="@id/tv_start_time"
app:trv_direction="bottom" />
<TextView
android:id="@+id/tv_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:text="至"
android:visibility="gone"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="@id/iv_start_time_triangle"
app:layout_constraintLeft_toRightOf="@id/iv_start_time_triangle"
app:layout_constraintTop_toTopOf="@id/iv_start_time_triangle" />
<TextView
android:id="@+id/tv_end_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:onClick="onClickListener"
android:textColor="@color/theme_333_color"
android:visibility="gone"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="@id/tv_to"
app:layout_constraintLeft_toRightOf="@id/tv_to"
app:layout_constraintTop_toTopOf="@id/tv_to" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_end_time_triangle"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
android:onClick="onClickListener"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/tv_end_time"
app:layout_constraintLeft_toRightOf="@id/tv_end_time"
app:layout_constraintTop_toTopOf="@id/tv_end_time"
app:trv_direction="bottom" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/fragment_other_order"/> <include layout="@layout/fragment_other_order" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -47,9 +47,9 @@ ...@@ -47,9 +47,9 @@
android:id="@+id/cl_order_info" android:id="@+id/cl_order_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_6"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_6"
android:background="@drawable/shape_dialog_bg" android:background="@drawable/shape_dialog_bg"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"> android:focusableInTouchMode="true">
...@@ -154,14 +154,14 @@ ...@@ -154,14 +154,14 @@
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_search_bg" android:background="@drawable/shape_search_bg"
android:hint="請輸入手機號或訂單號" android:hint="請輸入手機號或訂單號"
android:inputType="number"
android:paddingLeft="@dimen/dp_10" android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_50" android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc" android:textColorHint="@color/color_ccc"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_14"
android:inputType="number"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_switch_restaurant_state" app:layout_constraintRight_toLeftOf="@id/tv_restaurant_state"
app:layout_constraintTop_toBottomOf="@id/tv_month_takeaway_num_text" /> app:layout_constraintTop_toBottomOf="@id/tv_month_takeaway_num_text" />
<ImageView <ImageView
...@@ -175,22 +175,43 @@ ...@@ -175,22 +175,43 @@
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" /> app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<com.gingersoft.gsa.cloud.ui.view.SwitchButton <TextView
android:id="@+id/btn_switch_restaurant_state" android:id="@+id/tv_restaurant_state"
android:layout_width="wrap_content" style="@style/otherOrder_restaurant_state_style"
android:layout_height="@dimen/dp_40" android:background="@drawable/shape_restaurant_state_bg"
android:textColor="@color/white" android:text="營業中 "
android:textSize="@dimen/dp_12"
app:kswBackColor="@color/selector_switch_button"
app:kswBackRadius="@dimen/dp_20"
app:kswTextOff="@string/resting"
app:kswTextOn="@string/open"
app:kswThumbColor="@color/white"
app:kswThumbMarginBottom="@dimen/dp_4"
app:kswThumbMarginTop="@dimen/dp_4"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search" app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" /> app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<ImageView
android:layout_width="@dimen/dp_10"
android:layout_height="@dimen/dp_5"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_4"
android:src="@drawable/qmui_popup_arrow_down"
app:layout_constraintBottom_toBottomOf="@id/tv_restaurant_state"
app:layout_constraintRight_toRightOf="@id/tv_restaurant_state"
app:layout_constraintTop_toTopOf="@id/tv_restaurant_state" />
<!-- -->
<!-- <com.gingersoft.gsa.cloud.ui.view.SwitchButton-->
<!-- android:id="@+id/btn_switch_restaurant_state"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="@dimen/dp_40"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="@dimen/dp_12"-->
<!-- app:kswBackColor="@color/selector_switch_button"-->
<!-- app:kswBackRadius="@dimen/dp_20"-->
<!-- app:kswTextOff="@string/resting"-->
<!-- app:kswTextOn="@string/open"-->
<!-- app:kswThumbColor="@color/white"-->
<!-- app:kswThumbMarginBottom="@dimen/dp_4"-->
<!-- app:kswThumbMarginTop="@dimen/dp_4"-->
<!-- app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />-->
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_delivery"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/tv_add_delivery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_border_bg"
android:text="添加備送方式"
android:padding="@dimen/dp_10"
android:textColor="@color/theme_color" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="delivery_type"
type="String" />
<variable
name="delivery_expenses"
type="String" />
<variable
name="delivery_fee"
type="String" />
<variable
name="delivery_method"
type="String" />
<variable
name="delivery_difference"
type="String" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_delivery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:text="@{@string/delivery_type+ delivery_type}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_delivery_expenses"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/delivery_expenses + delivery_expenses}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_delivery_type"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_type" />
<TextView
android:id="@+id/tv_delivery_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/delivery_fee + delivery_fee}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_delivery_type"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_expenses" />
<TextView
android:id="@+id/tv_delivery_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/delivery_method + delivery_method}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_delivery_type"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_fee" />
<TextView
android:id="@+id/tv_difference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/delivery_difference + delivery_difference}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_delivery_type"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_method" />
<TextView
android:id="@+id/iv_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:text="編輯"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/iv_delete"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/iv_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:text="刪除"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_difference" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<TextView <TextView
android:id="@+id/tv_order_user_name" android:id="@+id/tv_order_user_name"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:text="@{data.rECEIVER}" android:text="@{data.rECEIVER}"
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_order_time"
app:layout_constraintTop_toBottomOf="@id/tv_ordering_method" /> app:layout_constraintTop_toBottomOf="@id/tv_ordering_method" />
<TextView <TextView
...@@ -92,7 +93,6 @@ ...@@ -92,7 +93,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}" android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_order_user_name" /> app:layout_constraintTop_toTopOf="@id/tv_order_user_name" />
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_delivery_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10"
android:text="備送設置"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_history_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10"
android:text="歷史訂單"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_restaurant_open"
style="@style/otherOrder_restaurant_state_style"
android:background="@color/restaurant_color_open"
android:text="營業中" />
<TextView
android:id="@+id/tv_restaurant_close"
style="@style/otherOrder_restaurant_state_style"
android:background="@color/color_c8"
android:text="休息中" />
<TextView
android:id="@+id/tv_restaurant_busy_close"
style="@style/otherOrder_restaurant_state_style"
android:background="@color/restaurant_color_busy_close"
android:text="繁忙不接" />
<TextView
android:id="@+id/tv_restaurant_busy_open"
style="@style/otherOrder_restaurant_state_style"
android:background="@color/restaurant_color_busy_open"
android:text="繁忙可接" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".ui.fragment.UpdateDeliveryFragment">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/top_bar_update_delivery"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
app:layout_constraintTop_toTopOf="parent"
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -41,4 +41,14 @@ ...@@ -41,4 +41,14 @@
<string name="deliveryman_phone">送貨員手機號:</string> <string name="deliveryman_phone">送貨員手機號:</string>
<string name="logistics_number">物流號:</string> <string name="logistics_number">物流號:</string>
<string name="take_food_code_omit">----</string> <string name="take_food_code_omit">----</string>
<string name="left_parenthesis"></string>
<string name="right_parenthesis"></string>
<string name="delivery_type">配送類型:</string>
<string name="delivery_expenses">配送費範圍:</string>
<string name="delivery_fee">起送費:</string>
<string name="delivery_method">配送方式:</string>
<string name="delivery_difference">補差價:</string>
</resources> </resources>
...@@ -82,6 +82,14 @@ ...@@ -82,6 +82,14 @@
<item name="android:textColor">@color/color_66</item> <item name="android:textColor">@color/color_66</item>
<item name="android:textSize">@dimen/dp_12</item> <item name="android:textSize">@dimen/dp_12</item>
</style> </style>
<!-- 餐廳營業狀態按鈕樣式-->
<style name="otherOrder_restaurant_state_style">
<item name="android:layout_width">@dimen/dp_80</item>
<item name="android:layout_height">@dimen/dp_28</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">@dimen/dp_8</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/dp_14</item>
</style>
</resources> </resources>
...@@ -184,7 +184,7 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -184,7 +184,7 @@ public class PrintOtherOrder extends PrinterRoot {
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);
// 訂單類型 // 訂單類型
setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外" : "自取"); setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外" : "自取");
// 訂單號 // 訂單號
setText(view, R.id.tv_order_number, "訂單號:" + data.getORDER_NO()); setText(view, R.id.tv_order_number, "訂單號:" + data.getORDER_NO());
if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) { if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) {
...@@ -203,7 +203,7 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -203,7 +203,7 @@ public class PrintOtherOrder extends PrinterRoot {
//配送費 //配送費
setAmount(data.getDELIVERY_CHARGE(), view.findViewById(R.id.tv_delivery_fee_text), view.findViewById(R.id.tv_delivery_fee), amountUnit); setAmount(data.getDELIVERY_CHARGE(), view.findViewById(R.id.tv_delivery_fee_text), view.findViewById(R.id.tv_delivery_fee), amountUnit);
//折扣 //折扣
setAmount(data.getDiscount_amount(), view.findViewById(R.id.tv_discount_text), view.findViewById(R.id.tv_discount), amountUnit); setAmount(data.getDiscount_amount(), view.findViewById(R.id.tv_discount_text), view.findViewById(R.id.tv_discount), "-" + amountUnit);
//總金額 //總金額
setText(view, R.id.tv_total_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())); setText(view, R.id.tv_total_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
//支付金額 //支付金額
......
...@@ -363,6 +363,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -363,6 +363,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
hepler.setViewClick(R.id.internet_print, v -> { hepler.setViewClick(R.id.internet_print, v -> {
//修改默認打印方式為IP打印 //修改默認打印方式為IP打印
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
dialog.dismiss();
//彈出彈窗,讓用戶選擇ip打印機 //彈出彈窗,讓用戶選擇ip打印機
showIpPrintDeviceList(printerDeviceBeans, bitmaps); showIpPrintDeviceList(printerDeviceBeans, bitmaps);
}); });
......
...@@ -119,9 +119,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -119,9 +119,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
if (printerInIt != null) { if (printerInIt != null) {
printerInIt.setmContext(mContext).setPrintListener(this); printerInIt.setmContext(mContext).setPrintListener(this);
} }
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(mContext); PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean(); printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
if (type == PrinterRoot.PRINT_TEST) { if (type == PrinterRoot.PRINT_TEST) {
if (deviceBean != null) { if (deviceBean != null) {
printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get("")); printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
...@@ -311,6 +310,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -311,6 +310,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private void addPrintDevice() { private void addPrintDevice() {
ToastUtils.show(mContext, "沒有打印機,請添加"); ToastUtils.show(mContext, "沒有打印機,請添加");
printFile();
// startActivityForResult(new Intent(mContext, PrinterAddActivity.class), ADD_PRINT_CODE); // startActivityForResult(new Intent(mContext, PrinterAddActivity.class), ADD_PRINT_CODE);
} }
......
...@@ -139,9 +139,9 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -139,9 +139,9 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override @Override
public void initIntent() { public void initIntent() {
int position = getIntent().getIntExtra("printer_position", 0); int position = getIntent().getIntExtra("printer_position", -1);
devicess = (List<PrinterDeviceBean>) getIntent().getSerializableExtra("printList"); devicess = (List<PrinterDeviceBean>) getIntent().getSerializableExtra("printList");
if (devicess != null) { if (devicess != null && position != -1) {
printerDeviceBean = devicess.get(position); printerDeviceBean = devicess.get(position);
if (printerDeviceBean != null) { if (printerDeviceBean != null) {
devicess.remove(position);//從打印機列表中移除掉當前打印機,選擇飛單時不能選擇當前打印機 devicess.remove(position);//從打印機列表中移除掉當前打印機,選擇飛單時不能選擇當前打印機
...@@ -245,12 +245,16 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -245,12 +245,16 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
.createDialogView() .createDialogView()
.setOnDismissListener(dialog -> { .setOnDismissListener(dialog -> {
if (viewId == R.id.layout_select_fail_one) { if (viewId == R.id.layout_select_fail_one) {
if (oneFailPosition < devicess.size() && oneFailPosition >= 0) {
mTvFailNameOne.setText(devicess.get(oneFailPosition).getName()); mTvFailNameOne.setText(devicess.get(oneFailPosition).getName());
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c)); mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
}
} else { } else {
if (twoFailPosition < devicess.size() && twoFailPosition >= 0) {
mTvFailNameTwo.setText(devicess.get(twoFailPosition).getName()); mTvFailNameTwo.setText(devicess.get(twoFailPosition).getName());
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c)); mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
} }
}
}) })
.show(); .show();
} }
...@@ -259,7 +263,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -259,7 +263,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
* 添加或測試打印機 * 添加或測試打印機
*/ */
private void addOrTestPrint(View v) { private void addOrTestPrint(View v) {
if(mEdPrintName.getText() == null || mEdPrintName.getText().toString().isEmpty()){ if (mEdPrintName.getText() == null || mEdPrintName.getText().toString().isEmpty()) {
ToastUtils.show(mContext, "請輸入打印機名稱"); ToastUtils.show(mContext, "請輸入打印機名稱");
return; return;
} }
......
...@@ -77,6 +77,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -77,6 +77,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
initViewPager(); initViewPager();
} }
private IpPrintListActivityFragment ipPrintListActivityFragment;
/** /**
* 设置Viewpager的适配器 * 设置Viewpager的适配器
*/ */
...@@ -88,7 +90,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -88,7 +90,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
mFragments.add(LocalPrintFragment.newInstance()); mFragments.add(LocalPrintFragment.newInstance());
} }
titles.add("網絡打印"); titles.add("網絡打印");
mFragments.add(IpPrintListActivityFragment.newInstance()); ipPrintListActivityFragment = IpPrintListActivityFragment.newInstance();
mFragments.add(ipPrintListActivityFragment);
//实例化适配器 //实例化适配器
mTabFragmentAdapter = new TabFragmentAdapter(getSupportFragmentManager(), 1); mTabFragmentAdapter = new TabFragmentAdapter(getSupportFragmentManager(), 1);
...@@ -110,7 +113,11 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -110,7 +113,11 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
topBar.setTitle("打印設置"); topBar.setTitle("打印設置");
topBar.setBackgroundColor(getResources().getColor(R.color.theme_color)); topBar.setBackgroundColor(getResources().getColor(R.color.theme_color));
topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish()); topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish());
topBar.addRightImageButton(R.drawable.ic_add, R.id.printer_add).setOnClickListener(v -> startActivity(new Intent(mContext, PrinterAddActivity.class))); topBar.addRightImageButton(R.drawable.ic_add, R.id.printer_add).setOnClickListener(v -> {
if (ipPrintListActivityFragment != null && ipPrintListActivityFragment.isAdded()) {
ipPrintListActivityFragment.startToEditPrint(-1);
}
});
} }
@Override @Override
......
...@@ -39,9 +39,13 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base ...@@ -39,9 +39,13 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
} }
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(item.getStatus() == 2); ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(item.getStatus() == 2);
helper.getView(R.id.tv_default_print).setVisibility(item.getStatus() == 2 ? View.VISIBLE : View.GONE); helper.getView(R.id.tv_default_print).setVisibility(item.getStatus() == 2 ? View.VISIBLE : View.GONE);
// helper.setOnItemSelectedClickListener(R.id.layout_delete,)
helper.addOnClickListener(R.id.layout_delete);
} }
public int getSelectPosition() { public int getSelectPosition() {
return selectPosition; return selectPosition;
} }
......
package com.joe.print.mvp.ui.fragment; package com.joe.print.mvp.ui.fragment;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -18,10 +17,9 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -18,10 +17,9 @@ 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.PrinterManger.PrinterManager; import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils; import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.jess.arms.base.BaseFragment; import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -31,15 +29,12 @@ import com.joe.print.di.component.DaggerIpPrintListActivityComponent; ...@@ -31,15 +29,12 @@ import com.joe.print.di.component.DaggerIpPrintListActivityComponent;
import com.joe.print.di.module.IpPrintListActivityModule; import com.joe.print.di.module.IpPrintListActivityModule;
import com.joe.print.mvp.contract.IpPrintListActivityContract; import com.joe.print.mvp.contract.IpPrintListActivityContract;
import com.joe.print.mvp.presenter.IpPrintListActivityPresenter; import com.joe.print.mvp.presenter.IpPrintListActivityPresenter;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.joe.print.mvp.ui.activity.PrinterAddActivity; import com.joe.print.mvp.ui.activity.PrinterAddActivity;
import com.joe.print.mvp.ui.adapter.PrinterListAdapter; import com.joe.print.mvp.ui.adapter.PrinterListAdapter;
import com.yanzhenjie.recyclerview.SwipeMenuCreator; import com.yanzhenjie.recyclerview.SwipeMenuCreator;
import com.yanzhenjie.recyclerview.SwipeMenuItem;
import com.yanzhenjie.recyclerview.SwipeRecyclerView; import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.yanzhenjie.recyclerview.touch.OnItemMoveListener; import com.yanzhenjie.recyclerview.touch.OnItemMoveListener;
import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener; import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
...@@ -166,16 +161,16 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -166,16 +161,16 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
// 1. MATCH_PARENT 自适应高度,保持和Item一样高; // 1. MATCH_PARENT 自适应高度,保持和Item一样高;
// 2. 指定具体的高,比如80; // 2. 指定具体的高,比如80;
// 3. WRAP_CONTENT,自身高度,不推荐; // 3. WRAP_CONTENT,自身高度,不推荐;
int height = ViewGroup.LayoutParams.MATCH_PARENT; // int height = ViewGroup.LayoutParams.MATCH_PARENT;
// 添加右侧的按鈕。 // 添加右侧的按鈕。
SwipeMenuItem deleteItem = new SwipeMenuItem(mContext).setBackground( // SwipeMenuItem deleteItem = new SwipeMenuItem(mContext).setBackground(
R.color.theme_color) // R.color.theme_color)
// .setImage(R.drawable.ic_action_delete) //// .setImage(R.drawable.ic_action_delete)
.setText("刪除") // .setText("刪除")
.setTextColor(Color.WHITE) // .setTextColor(Color.WHITE)
.setWidth(width) // .setWidth(width)
.setHeight(height); // .setHeight(height);
swipeRightMenu.addMenuItem(deleteItem);// 添加一个按钮到右侧侧菜单。 // swipeRightMenu.addMenuItem(deleteItem);// 添加一个按钮到右侧侧菜单。
}; };
/** /**
...@@ -216,27 +211,24 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -216,27 +211,24 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
if (printListAdapter == null) { if (printListAdapter == null) {
mRvPrintList.setOnItemClickListener((view, adapterPosition) -> { mRvPrintList.setOnItemClickListener((view, adapterPosition) -> {
//item點擊事件 打開打印機詳情 //item點擊事件 打開打印機詳情
Intent intent = new Intent(mContext, PrinterAddActivity.class); startToEditPrint(adapterPosition);
intent.putExtra("printer_position", adapterPosition);
intent.putExtra("printList", (Serializable) devicess);
startActivity(intent);
}); });
//menu 右侧菜單點擊事件 //menu 右侧菜單點擊事件
mRvPrintList.setOnItemMenuClickListener((menuBridge, position) -> { // mRvPrintList.setOnItemMenuClickListener((menuBridge, position) -> {
//刪除按鈕點擊事件 // //刪除按鈕點擊事件
menuBridge.closeMenu(); // menuBridge.closeMenu();
//調用刪除接口 // //調用刪除接口
mPresenter.deletePrinter(devicess.get(position).getId() + ""); // mPresenter.deletePrinter(devicess.get(position).getId() + "");
if (printListAdapter.getSelectPosition() == position) { // if (printListAdapter.getSelectPosition() == position) {
//如果刪除的是當前選中的默認打印機,那麼移除默認打印機 // //如果刪除的是當前選中的默認打印機,那麼移除默認打印機
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_IP); // SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_IP);
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PORT); // SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PORT);
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PAPER); // SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PAPER);
printListAdapter.setSelectPosition(-1); // printListAdapter.setSelectPosition(-1);
} // }
devicess.remove(position); // devicess.remove(position);
printListAdapter.notifyItemRemoved(position); // printListAdapter.notifyItemRemoved(position);
}); // });
// Item的Menu点击。 // Item的Menu点击。
mRvPrintList.setOnItemStateChangedListener(mOnItemStateChangedListener); // 监听Item的手指状态,拖拽、侧滑、松开。 mRvPrintList.setOnItemStateChangedListener(mOnItemStateChangedListener); // 监听Item的手指状态,拖拽、侧滑、松开。
mRvPrintList.setLongPressDragEnabled(true); // 长按拖拽,默认关闭。 mRvPrintList.setLongPressDragEnabled(true); // 长按拖拽,默认关闭。
...@@ -270,6 +262,18 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -270,6 +262,18 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
});// 监听拖拽和侧滑删除,更新UI和数据源。 });// 监听拖拽和侧滑删除,更新UI和数据源。
printListAdapter = new PrinterListAdapter(devicess, mContext); printListAdapter = new PrinterListAdapter(devicess, mContext);
printListAdapter.setOnItemChildClickListener((adapter, view, position) -> AppDialog.showWaringDialog(mContext, "是否刪除打印機", (view1, dialog) -> {
//調用刪除接口
mPresenter.deletePrinter(devicess.get(position).getId() + "");
devicess.remove(position);
printListAdapter.notifyItemRemoved(position);
dialog.dismiss();
if (devicess == null || devicess.size() == 0) {
mTvAddPrint.setVisibility(View.VISIBLE);
} else {
mTvAddPrint.setVisibility(View.GONE);
}
}));
mRvPrintList.setLayoutManager(new LinearLayoutManager(mContext)); mRvPrintList.setLayoutManager(new LinearLayoutManager(mContext));
//分割线 //分割线
// mRvPrintList.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color))); // mRvPrintList.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color)));
...@@ -281,6 +285,13 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -281,6 +285,13 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
} }
} }
public void startToEditPrint(int adapterPosition) {
Intent intent = new Intent(mContext, PrinterAddActivity.class);
intent.putExtra("printer_position", adapterPosition);
intent.putExtra("printList", (Serializable) devicess);
startActivity(intent);
}
@Override @Override
public void loadFile() { public void loadFile() {
mRvPrintList.setVisibility(View.GONE); mRvPrintList.setVisibility(View.GONE);
...@@ -291,7 +302,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -291,7 +302,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.tv_add_print) { if (v.getId() == R.id.tv_add_print) {
startActivity(new Intent(mContext, PrinterAddActivity.class)); startToEditPrint(-1);
} }
} }
} }
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
style="@style/printOtherOrderTextStyle_font_style_twenty" style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text='單時間' /> android:text='單時間' />
<TextView <TextView
android:id="@+id/tv_remark" android:id="@+id/tv_remark"
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:text="配送費:" android:text="送貨費:"
android:textStyle="normal" android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" /> app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
......
...@@ -74,13 +74,29 @@ ...@@ -74,13 +74,29 @@
android:id="@+id/tv_printer_edit" android:id="@+id/tv_printer_edit"
android:layout_width="@dimen/dp_17" android:layout_width="@dimen/dp_17"
android:layout_height="@dimen/dp_17" android:layout_height="@dimen/dp_17"
android:layout_marginRight="@dimen/dp_19" android:layout_marginRight="@dimen/dp_10"
android:src="@drawable/ic_edit" android:src="@drawable/ic_edit"
android:text="編輯" android:text="編輯"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toLeftOf="@id/layout_delete"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/layout_delete"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/dp_19"
android:src="@drawable/ic_delete_bill_method" />
</FrameLayout>
<View <View
android:id="@+id/horizontal_dividing_line" android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<string name="print_port">端口號:%1$s</string> <string name="print_port">端口號:%1$s</string>
<string name="create_order_time">單時間:</string> <string name="create_order_time">單時間:</string>
<string name="address">地址:</string> <string name="address">地址:</string>
</resources> </resources>
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