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 {
*/
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.theme_color, android.R.color.white);//全局设置主题颜色
return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
}
SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) -> {
layout.setPrimaryColorsId(R.color.theme_color, android.R.color.white);//全局设置主题颜色
return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
});
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
}
SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) -> {
//指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
});
}
......@@ -120,6 +114,7 @@ public class GsaCloudApplication extends BaseApplication {
initPrint();
//初始化日誌管理庫
initXLog();
//初始化服務器地址
initDomainUrl();
//初始化crash記錄
AppCrashHandler.getInstance().init(this);
......@@ -155,13 +150,15 @@ public class GsaCloudApplication extends BaseApplication {
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"}),不添加則是使用默認域名
setGlobalDomain();
//清機報表請求地址
RetrofitUrlManager.getInstance().putDomain("settlement_report_server", HttpsConstans.ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL);
//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);
//沽清控制請求地址
......@@ -189,6 +186,7 @@ public class GsaCloudApplication extends BaseApplication {
public static void setGlobalDomain() {
//配置全局默認URL
//取出SharedPreferences中存儲的默認服務器地址
RetrofitUrlManager.getInstance().setGlobalDomain(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL);
}
......
......@@ -224,25 +224,33 @@ public class MoneyUtil {
public static BigDecimal divide(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return b2;
}
return b1.divide(b2, 2, ROUND_HALF_UP);
}
/**
* 計算除
*
* @param v1
* @param v2
* @param scale 保留幾位小數
* @param scale 保留幾位小數
* @param RoundingMode ROUND_HALF_UP為四捨五入
* @return
*/
public static float divide(double v1, double v2, int scale, int RoundingMode) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return 0f;
}
return b1.divide(b2, scale, RoundingMode).floatValue();
}
/**
* 計算除
*
* @param v1
* @param v2
* @param scale 保留幾位小數
......@@ -251,6 +259,9 @@ public class MoneyUtil {
public static float divide(double v1, double v2, int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b2.intValue() <= 0) {
return 0f;
}
return b1.divide(b2, scale, ROUND_HALF_UP).floatValue();
}
......
......@@ -30,7 +30,7 @@ import com.gingersoft.gsa.cloud.base.R;
*/
public abstract class DialogUtils {
private Context mContext;
private Dialog dialog = null;
private static Dialog dialog;
private View view;
private int style = R.style.PhotoDialog;
private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT;
......@@ -43,6 +43,7 @@ public abstract class DialogUtils {
view = LayoutInflater.from(mContext).inflate(xmlLayout, null);
}
public DialogUtils(Context mContext, View view) {
this.mContext = mContext;
this.view = view;
......@@ -64,10 +65,12 @@ public abstract class DialogUtils {
}
public DialogUtils createDialogView() {
dialog = new Dialog(mContext, style);
if(dialog != null) {
dialog.dismiss();
}
dialog = new Dialog(mContext);
viewHepler = getViewHepler();
initLayout(viewHepler, dialog);
dialog.setContentView(viewHepler.getContentView());
Window dialogWindow = dialog.getWindow();
// WindowManager.LayoutParams lp = dialogWindow.getAttributes();
......@@ -109,20 +112,20 @@ public abstract class DialogUtils {
}
public DialogUtils dismiss() {
if (dialog != null) {
if (dialog != null)
dialog.dismiss();
}
return this;
}
public DialogUtils setGravity(int gravity) {
if (dialog != null && dialog.getWindow() != null) {
if (dialog.getWindow() != null) {
dialog.getWindow().setGravity(gravity);
}
return this;
}
public DialogUtils show() {
dismiss();
dialog.show();
return this;
}
......@@ -204,6 +207,12 @@ public abstract class DialogUtils {
return (T) view;
}
public ViewHepler setOnClickListenter(int viewId, View.OnClickListener onClickListener) {
getView(viewId).setOnClickListener(onClickListener);
return this;
}
/**
* 为TextView设置字符串
*
......
......@@ -4,17 +4,89 @@ package com.gingersoft.gsa.cloud.constans;
* Created by Wyh on 2019/12/21.
*/
public class HttpsConstans {
//默認為香港
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com: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 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_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/";//清機接口地址
// 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_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/";
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/";//微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據
//--------------------------------------------其他全局----------------------------------------------------------------------------
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";//香港測試
public static String _SERVER_ADDRESS = "http://a.ricepon.com:61177/member-web/api/";//報表地址
}
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_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 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 void init() {
_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
}
}
\ No newline at end of file
......@@ -68,9 +68,13 @@ class OrderDetails {
//後台不會返回
var order_type: 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 couponList: List<CouponBean>? = null
var estimatedTime: String? = null
class PRODUCTNAMEBean {
/**
......@@ -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 @@
<corners android:radius="@dimen/dp_8" />
<stroke
android:width="@dimen/dp_2"
android:width="@dimen/dp_3"
android:color="@color/order_state0_color" />
</shape>
\ No newline at end of file
......@@ -480,4 +480,8 @@
<color name="switcher_on_color">#6EBE8C</color>
<color name="switcher_off_color">#ff4651</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>
......@@ -19,4 +19,8 @@
<item name="qmui_arch_swipe_layout_in_back" type="id"/>
<item name="iv_left_back" type="id"/>
<item name="iv_history" type="id"/>
<item name="topbar_right_change_button" type="id"/>
</resources>
\ No newline at end of file
......@@ -55,7 +55,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
}
public void login(String account, String pwd) {
if (account.equals("88888888") && pwd.equals("cc81081168")) {
if (account.equals("888888") && pwd.equals("cc81081168")) {
mRootView.startToSwitchServer();
return;
}
......@@ -80,7 +80,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
GsaCloudApplication.userName = info.getData().getUser().getUserName();
mRootView.showMessage("登陸成功");
mRootView.loginSuccess(info);
//開啟打印服務
//開啟Prj打印服務
CC.obtainBuilder("Component.Print")
.setActionName("openPrintService")
.build()
......
......@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.login.R;
import com.gingersoft.gsa.cloud.login.R2;
......@@ -39,12 +40,10 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/
public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> implements SwitchServerContract.View {
@BindView(R2.id.rb_server_sz)
RadioButton rbSZ;
@BindView(R2.id.rb_server_hk)
RadioButton rbHK;
@BindView(R2.id.rb_youchang_hk)
RadioButton rb_youchang_hk;
@BindView(R2.id.rb_server_formal)
RadioButton rbFormal;
@BindView(R2.id.btn_switch_server)
Button switchServer;
@BindView(R2.id.tv_now_server)
......@@ -65,32 +64,28 @@ public class SwitchServerActivity extends BaseActivity<SwitchServerPresenter> im
return R.layout.activity_switch_server; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
///RetrofitUrlManager.getInstance().putDomain("common", HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL);
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String nowServer = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL;
tvNowServer.setText("當前服務器:" + nowServer);
rbHK.setText("香港服務器:" + HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK);
rbSZ.setText("深圳服務器:" + HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ);
rb_youchang_hk.setText("世維本地:" + HttpsConstans.ROOT_SERVER_YOU_CHANG_HK);
if (nowServer.equals(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ)) {
rbSZ.setChecked(true);
} else if (nowServer.equals(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK)) {
if (HttpsConstans.isFormal) {
rbFormal.setChecked(true);
} else {
rbHK.setChecked(true);
}else{
rb_youchang_hk.setChecked(true);
}
rbHK.setText("測試服務器");
rbFormal.setText("正式服務器");
switchServer.setOnClickListener(v -> {
if (rbSZ.isChecked()) {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_SZ;
} else if (rbHK.isChecked()) {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_HK;
}else {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL = HttpsConstans.ROOT_SERVER_SHI_WEI_HK;
if (rbHK.isChecked()) {
SPUtils.put(this, "isFormal", false);
} else {
SPUtils.put(this, "isFormal", true);
}
GsaCloudApplication.setGlobalDomain();
GsaCloudApplication.initDomainUrl();
finish();
startActivity(new Intent(mContext, LoginActivity.class));
System.exit(0);
});
}
......
......@@ -282,6 +282,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override
public void loginSuccess(LoginBean info) {
super.loginSuccess(info);
finish();
}
private boolean isChooseRestaurant = false;
......
......@@ -10,32 +10,22 @@
android:layout_height="wrap_content">
<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:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="香港環境"
android:text="測試環境"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_16" />
<RadioButton
android:id="@+id/rb_youchang_hk"
android:id="@+id/rb_server_formal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="友常本地"
android:text="正式環境"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_16" />
</RadioGroup>
<TextView
......
......@@ -173,12 +173,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
if (BuildConfig.DEBUG) {
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_about_us, "關於我們"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
}
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_password, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "清機"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境"));
}
......@@ -317,7 +317,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
.setActionName("showSoldoutCtrlActivity")
.build()
.call();
}else if(name.equals("餐臺管理")){
} else if (name.equals("餐臺管理")) {
CC.obtainBuilder("Component.Manager")
.setActionName("showTableManageActivity")
.build()
......
......@@ -58,13 +58,14 @@ 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_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.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_food_sales_num, item.getNumber() + "");
helper.setText(R.id.tv_ranking_food_sales_amount, item.getAmount() + "");
helper.setText(R.id.tv_ranking_proportion_quantity, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getNumber(), totalNum, 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)) + "%");
if (item != null) {
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_food_sales_num, item.getNumber() + "");
helper.setText(R.id.tv_ranking_food_sales_amount, item.getAmount() + "");
helper.setText(R.id.tv_ranking_proportion_quantity, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getNumber(), totalNum, 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)) + "%");
}
}
}
}
......@@ -302,7 +302,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) ->
{
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH);
......
......@@ -188,11 +188,13 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
public void loadInfo(List<SalesFoodsBean.DataBean.SalesRankingBean> salesRanking) {
totalAmount = 0;
totalNum = 0;
for (SalesFoodsBean.DataBean.SalesRankingBean salesRankingBean : salesRanking) {
totalAmount = MoneyUtil.sum(totalAmount, salesRankingBean.getAmount());
totalNum = totalNum + salesRankingBean.getNumber();
if (salesRankingBean != null) {
totalAmount = MoneyUtil.sum(totalAmount, salesRankingBean.getAmount());
totalNum = totalNum + salesRankingBean.getNumber();
}
}
List<SalesFoodsBean.DataBean.SalesRankingBean> rankings = new ArrayList<>(salesRanking);
rankings.add(0, new SalesFoodsBean.DataBean.SalesRankingBean());
if (mSortNumberingAdapter == null) {
......
......@@ -71,6 +71,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
......
......@@ -7,12 +7,14 @@
<application>
<activity
android:name=".ui.activity.OtherOrderActivity"
android:launchMode="singleTop"
android:label="@string/app_name" />
<service android:name=".service.GetInfoUpdateService" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<activity android:name=".ui.activity.DeliverySettingActivity"/>
</application>
</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
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()
.add("restaurantId", restaurantId)
.add("status", status)
.add("pageIndex", pageIndex)
.add("pageSize", pageSize)
.add("orderNo", orderNo)
.add("startDate", startDate)
.add("endDate", endDate)
.add("phone", phone)
.build()
val heWeather = network.getHistoryOrderList(requestBody)
......
......@@ -6,6 +6,8 @@ import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
import okhttp3.RequestBody
import kotlin.Pair as Pair1
class WeatherRepository private constructor(private val network: CoolWeatherNetwork) {
......@@ -30,10 +32,10 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
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()
.add("restId", restaurantId)
.add("openStatus", if (state) "1" else "2")
.add("openStatus", state.toString())
.build()
val data = network.updateRestOpenStatus(requestBody)
data
......@@ -47,6 +49,16 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
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) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
......@@ -96,6 +108,26 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
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 {
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(
val success: Boolean,
val sysTime: Long) {
data class Data(
val self: List<SelfTakeaway>,
val self: List<Self>,
val selfTakeaway: List<SelfTakeaway>,
val takeaway: List<SelfTakeaway>) {
data class SelfTakeaway(
val STATUS: 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 {
var PHONE: String? = null
var orderPayType: Int = 0
var ORDER_NO: String? = null
var sendTime: String? = null
var waimaiSendTime:String? = null
var Id: Int = 0
var CREATE_TIME: String? = null
var takeFoodCode: String? = null
......@@ -82,7 +84,7 @@ class OrderList {
var maxOrderSelf: Int = 0
var num: 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_7: OrderType? = null
......
......@@ -16,27 +16,46 @@ class CoolWeatherNetwork {
private val service = ServiceCreator.create2(WeatherService::class.java)
private val gsposService = ServiceCreator.create3(WeatherService::class.java)
//獲取訂單列表
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
//修改餐廳營業狀態
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
//獲取訂單分組數量,例:待確認訂單數量,製作中訂單數量。。。
suspend fun getOrderGroupNum(requestBody: RequestBody) = orderService.getOrderGroupNum(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 thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await()
//修改自取訂單狀態
suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await()
// 獲取餐廳配送人員信息
suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await()
//獲取物流配置
suspend fun getDeliveryConfigDTO(requestBody: RequestBody) = gsposService.getDeliveryConfigDTO(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 {
return suspendCoroutine { continuation ->
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
import android.util.Log
import com.gingersoft.gsa.cloud.constans.HttpsConstans
import com.gingersoft.gsa.cloud.globalconfig.applyOptions.intercept.LoggingInterceptor
import okhttp3.OkHttpClient
import retrofit2.Retrofit
......@@ -8,17 +10,15 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
import java.util.concurrent.TimeUnit
object ServiceCreator {
private val httpClient = OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS).addInterceptor(LoggingInterceptor())
private const val ROOT_SZ_URL = "http://192.168.1.74:6060"
private const val ROOT_HK_TEST_URL = "https://hktest.ricepon.com:64377"
private const val ROOT_FORMAL_URL = "https://m.ricepon.com"
var ROOT_URL: String = HttpsConstans.ROOT_URL
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()
......@@ -26,6 +26,9 @@ object ServiceCreator {
.client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.apply {
Log.e("eee", "服務器地址$ROOT_URL")
}
private val builder2 = Retrofit.Builder()
.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 {
@POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
@POST("gsa/calculateEstimatedTime")
fun getShipanyOrderTime(@Body requestBody: RequestBody): Call<EstimatedBean>
@POST("wechat/updateOrderStatus")
fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
......@@ -38,4 +41,10 @@ interface WeatherService {
@POST("wechat/findHistoryOrderList")
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
class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepository) : ViewModel() {
var data = MutableLiveData<HistoryOrderBean>()
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getHistoryOrderList(context: Context, pageIndex: String, orderNum: String = "", listener: (HistoryOrderBean) -> Unit) {
fun getHistoryOrderList(context: Context, pageIndex: String, orderNum: String = "", startDate: String, endDate: String, listener: (HistoryOrderBean?) -> Unit) {
launch({
var phone = ""
var orderNumber = ""
......@@ -26,7 +23,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
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 {
if (it.size > 0) {
it.removeAt(it.size - 1)//移除最後一個,最後一個是顯示總條數的
......@@ -39,11 +36,12 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
if (pageIndex == "1") {
data.value = this
}
listener.invoke(data.value!!)
listener.invoke(data.value)
}
}, {
//出錯
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
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.R2
......@@ -17,6 +19,8 @@ import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.gingersoft.gsa.other_order_mode.util.setState
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import kotlinx.android.synthetic.main.activity_history_order.*
import java.text.ParseException
import java.util.*
class HistoryOrderActivity : BaseActivity() {
......@@ -35,43 +39,49 @@ class HistoryOrderActivity : BaseActivity() {
rvOrderList = findViewById(R.id.rv_other_order)
layoutNoData = findViewById(R.id.layout_nodata)
tv_start_time.text = TimeUtils.getOldDate(0)
tv_end_time.text = TimeUtils.getOldDate(0)
initAppTop()
rvOrderList.layoutManager = LinearLayoutManager(this)
initViewModel()
getHistoryInfo()
getHistoryInfo(time = tv_start_time.text.toString())
initSearch()
initRefresh()
}
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "") {
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "", time: String) {
showLoading()
mViewModel.getHistoryOrderList(this, page.toString(), orderNum) {
mViewModel.getHistoryOrderList(this, page.toString(), orderNum, time, time) {
cancelDialogForLoading()
refreshLayout.setEnableLoadMore(it.getData() != null)
refreshLayout.finishRefresh()
refreshLayout.finishLoadMore()
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) }
rvOrderList.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter {
showLoading()
mViewModel.getOrderInfo(it.Id.toString()) { it2 ->
cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗
OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { _, _ ->
//確認訂單、指派送貨點擊事件
it?.let {
refreshLayout.setEnableLoadMore(it.getData() != null)
refreshLayout.finishRefresh()
refreshLayout.finishLoadMore()
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) }
rvOrderList.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter {
showLoading()
mViewModel.getOrderInfo(it.Id.toString()) { it2 ->
cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗
OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { view, _, _ ->
//確認訂單、指派送貨點擊事件
}
} else {
ToastUtils.show(this, "未查詢到訂單信息")
}
} else {
ToastUtils.show(this, "未查詢到訂單信息")
}
}
} else {
mHistoryOrderAdapter!!.data = it.getData()
mHistoryOrderAdapter!!.notifyDataSetChanged()
}
} else {
mHistoryOrderAdapter!!.data = it.getData()
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() {
iv_search_order.setOnClickListener {
//搜索
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 {
ToastUtils.show(this@HistoryOrderActivity, "請輸入手機號或訂單號")
}
......@@ -96,11 +106,11 @@ class HistoryOrderActivity : BaseActivity() {
//下拉刷新,加載更多
refreshLayout.setOnRefreshListener {
pageIndex = 1
getHistoryInfo()
getHistoryInfo(time = tv_start_time.text.toString())
}
refreshLayout.setOnLoadMoreListener {
pageIndex++
getHistoryInfo()
getHistoryInfo(time = tv_start_time.text.toString())
}
}
......@@ -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.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
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.core.animation.doOnEnd
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
......@@ -24,7 +23,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
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.databinding.ActivityOtherOrderBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
......@@ -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.base.BaseActivity
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.*
......@@ -60,7 +62,6 @@ class OtherOrderActivity : BaseActivity() {
private var layoutHeight: Float = 0F
private var btnHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
......@@ -159,26 +160,85 @@ class OtherOrderActivity : BaseActivity() {
}
}
private var restaurantPopup: QMUIPopup? = null
private var stateBg = GradientDrawable()
/**
* 切換餐廳狀態按鈕
*/
private fun initSwitchRestStatus() {
stateBg.cornerRadius = QMUIDisplayHelper.dp2px(this, 4).toFloat()
btnOpenBg = resources.getDrawable(R.drawable.shape_white_bottom_border)
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 {
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 {
setOrderInfoOpenOrClose()
}
}
private fun updateRestaurantState(state: Int) {
pageViewModel.setRestaurantState(this@OtherOrderActivity, state)
restaurantPopup?.dismiss()
}
private fun initWebsocket() {
//開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java)
......@@ -199,7 +259,7 @@ class OtherOrderActivity : BaseActivity() {
if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) {
//播放提示音
if (type == 5) {
if (type == 5 || type == 4) {
pageViewModel.refreshState.postValue(1)
} else {
pageViewModel.refreshState.postValue(type)
......@@ -312,16 +372,47 @@ class OtherOrderActivity : BaseActivity() {
view.requestLayout()
}
private var pop: QMUIPopup? = null
/**
* 初始化標題欄
*/
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.addRightImageButton(R.drawable.ic_history_order, R.id.iv_history).setOnClickListener {
//歷史訂單
startActivity(Intent(this, HistoryOrderActivity::class.java))
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))
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))
}
}
\ 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
import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator.ofFloat
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.support.v4.media.session.PlaybackStateCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -45,22 +43,18 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
holder.binding.data = data
holder.binding.isSelf = data.order_type == 7
data.trkNo?.apply {
if (length > 0) {
holder.binding.deliveryState = when (data.curStat) {
1 -> "訂單已創建"
2 -> "配送員已接單"
3 -> "配送員到店附近"
4 -> "配送員已到店"
5 -> "配送中"
6 -> "到達目的地附近"
7 -> "訂單已完成"
8 -> "物流已取消"//取餐前
9 -> "物流已取消"//取餐後
10 -> "已指派另一位配送員"
else -> ""
}
}
holder.binding.deliveryState = when (data.curStat) {
1 -> "已通知物流"
2 -> "配送員已接單"
3 -> "配送員到店附近"
4 -> "配送員已到店"
5 -> "配送中"
6 -> "到達目的地附近"
7 -> "訂單已完成"
8 -> "物流已取消"//取餐前
9 -> "物流已取消"//取餐後
10 -> "已指派另一位配送員"
else -> ""
}
var state: String? = null
......@@ -100,20 +94,22 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
//堂食外賣背景
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 =
when {
data.order_type == 2 -> {
orderingMethodBg.setColor(getColor(R.color.order_state2_color))
"外"
"外"
}
data.order_type == 7 -> {
orderingMethodBg.setColor(getColor(R.color.order_state3_color))
"自"
"自"
}
else -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color))
"堂"
"堂"
}
}
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
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
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.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter
......@@ -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.setState
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.
......@@ -37,10 +43,10 @@ class PlaceholderFragment : BaseFragment() {
// 並且type一致
//如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
Log.e("eee", "$it,當前fragment的" + PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!])
if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
page = 1
getOrderList(this, false)
}
if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
page = 1
getOrderList(this, false)
}
})
}
......@@ -51,28 +57,71 @@ class PlaceholderFragment : BaseFragment() {
adapter.setOnItemClickListenter { data ->
// 點擊查詢食品詳情
showLoading()
pageViewModel.getOrderInfo(data.Id.toString()) { it1 ->
//顯示彈窗
pageViewModel.getShipanyAndOrderInfo(data.curStat, GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) { it1 ->
cancelDialogForLoading()
//顯示彈窗
if (this@PlaceholderFragment.context != null && it1 != null) {
OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { _, dialog ->
pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
dialog.dismiss()
if (it) {
// 關閉彈窗,並刷新當前頁面
refresh()
// pageViewModel.refreshState.postValue(pageViewModel.refreshState.value!! + 1)
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) {
dialog.dismiss()
if (it) {
// 關閉彈窗,並刷新當前頁面
refresh()
}
}
}
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
//有多少個Fragment就添加多少個監聽
while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
pageViewModel.mOrderList.add(MutableLiveData())
}
// 綁定當前fragment的數據項
// 綁定監聽當前fragment的數據項
pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
it.let { adapter.setData(it) }
})
......@@ -82,8 +131,10 @@ class PlaceholderFragment : BaseFragment() {
// 下拉刷新,加載更多
refresh_layout.setOnRefreshListener {
refresh()
//重新拉取一遍送貨員和第三方派送信息
pageViewModel.getDeliveryInfo(context!!)
pageViewModel.getDeliveryConfigDTO(context!!)
}
refresh_layout.setOnLoadMoreListener {
page++
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
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.WeatherRepository
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.WeatherModelFactory
......@@ -19,5 +22,6 @@ object InjectorUtil {
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
import android.app.Dialog
import android.content.Context
import android.widget.Button
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.DataBindingUtil
......@@ -17,7 +17,7 @@ import com.jess.arms.utils.ArmsUtils
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) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (data.data != null) {
......@@ -30,7 +30,9 @@ object OtherOrderUtils {
//如果有物流號,就不顯示指派送貨按鈕
layoutOrderInfoDialogBinding.showBtn = showBtn
val btnContent: String
val type = if (orderType == 7) "自取" else "外賣"
var cancelBtnContent = ""
val type = if (orderType == 7) "自取" else "外送"
val orderStatus: String
when (orderStuats) {
......@@ -39,11 +41,14 @@ object OtherOrderUtils {
//自取
btnContent = "製作完成"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
cancelBtnContent = "取消訂單"
} else {
btnContent = if (orderData.isDelete == 1) {
"指派送貨"
if (orderData.isDelete == 0) {
btnContent = "重印"
cancelBtnContent = "取消物流"
} else {
"重印"
btnContent = "指派送貨"
cancelBtnContent = "取消訂單"
}
tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color))
}
......@@ -64,19 +69,40 @@ object OtherOrderUtils {
btnContent = "確認訂單"
orderStatus = "待確認"
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.btnContent = btnContent
layoutOrderInfoDialogBinding.cancelBtnContent = cancelBtnContent
layoutOrderInfoDialogBinding.estimatedTime = orderData.estimatedTime
}
val rvFood: RecyclerView = hepler.getView(R.id.rv_food)
rvFood.layoutManager = LinearLayoutManager(context)
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 {
......
package com.gingersoft.gsa.other_order_mode.util
import android.content.Context
import android.graphics.drawable.Drawable
import android.view.View
fun View.setState(state: Boolean) {
......@@ -8,4 +10,9 @@ fun View.setState(state: Boolean) {
} else {
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 @@
android:layout_height="match_parent"
android:background="@color/color_f0"
android:orientation="vertical"
tools:context=".ui.activity.OtherOrderActivity">
tools:context=".ui.activity.HistoryOrderActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
......@@ -26,6 +26,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="@dimen/dp_10">
<EditText
......@@ -35,11 +37,11 @@
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_search_bg"
android:hint="請輸入手機號或訂單號"
android:inputType="number"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc"
android:inputType="number"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
......@@ -54,9 +56,70 @@
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="@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>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/fragment_other_order"/>
<include layout="@layout/fragment_other_order" />
</LinearLayout>
\ No newline at end of file
......@@ -47,9 +47,9 @@
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
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_marginRight="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_6"
android:background="@drawable/shape_dialog_bg"
android:focusable="true"
android:focusableInTouchMode="true">
......@@ -154,14 +154,14 @@
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_search_bg"
android:hint="請輸入手機號或訂單號"
android:inputType="number"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc"
android:textSize="@dimen/dp_14"
android:inputType="number"
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" />
<ImageView
......@@ -175,22 +175,43 @@
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
<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"
<TextView
android:id="@+id/tv_restaurant_state"
style="@style/otherOrder_restaurant_state_style"
android:background="@drawable/shape_restaurant_state_bg"
android:text="營業中 "
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent"
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
......
<?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 @@
<TextView
android:id="@+id/tv_order_user_name"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{data.rECEIVER}"
......@@ -83,6 +83,7 @@
android:textSize="@dimen/sp_14"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_order_time"
app:layout_constraintTop_toBottomOf="@id/tv_ordering_method" />
<TextView
......@@ -92,7 +93,6 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
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_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 @@
<string name="deliveryman_phone">送貨員手機號:</string>
<string name="logistics_number">物流號:</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>
......@@ -82,6 +82,14 @@
<item name="android:textColor">@color/color_66</item>
<item name="android:textSize">@dimen/dp_12</item>
</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>
......@@ -184,7 +184,7 @@ public class PrintOtherOrder extends PrinterRoot {
private Bitmap initPrintView(Context context, OrderDetails.DataBean data) {
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());
if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) {
......@@ -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.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()));
//支付金額
......
......@@ -363,6 +363,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
hepler.setViewClick(R.id.internet_print, v -> {
//修改默認打印方式為IP打印
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
dialog.dismiss();
//彈出彈窗,讓用戶選擇ip打印機
showIpPrintDeviceList(printerDeviceBeans, bitmaps);
});
......
......@@ -119,9 +119,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
if (printerInIt != null) {
printerInIt.setmContext(mContext).setPrintListener(this);
}
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(mContext);
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
if (type == PrinterRoot.PRINT_TEST) {
if (deviceBean != null) {
printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
......@@ -311,6 +310,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private void addPrintDevice() {
ToastUtils.show(mContext, "沒有打印機,請添加");
printFile();
// startActivityForResult(new Intent(mContext, PrinterAddActivity.class), ADD_PRINT_CODE);
}
......
......@@ -139,9 +139,9 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override
public void initIntent() {
int position = getIntent().getIntExtra("printer_position", 0);
int position = getIntent().getIntExtra("printer_position", -1);
devicess = (List<PrinterDeviceBean>) getIntent().getSerializableExtra("printList");
if (devicess != null) {
if (devicess != null && position != -1) {
printerDeviceBean = devicess.get(position);
if (printerDeviceBean != null) {
devicess.remove(position);//從打印機列表中移除掉當前打印機,選擇飛單時不能選擇當前打印機
......@@ -245,11 +245,15 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
.createDialogView()
.setOnDismissListener(dialog -> {
if (viewId == R.id.layout_select_fail_one) {
mTvFailNameOne.setText(devicess.get(oneFailPosition).getName());
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
if (oneFailPosition < devicess.size() && oneFailPosition >= 0) {
mTvFailNameOne.setText(devicess.get(oneFailPosition).getName());
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
}
} else {
mTvFailNameTwo.setText(devicess.get(twoFailPosition).getName());
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
if (twoFailPosition < devicess.size() && twoFailPosition >= 0) {
mTvFailNameTwo.setText(devicess.get(twoFailPosition).getName());
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
}
}
})
.show();
......@@ -259,7 +263,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
* 添加或測試打印機
*/
private void addOrTestPrint(View v) {
if(mEdPrintName.getText() == null || mEdPrintName.getText().toString().isEmpty()){
if (mEdPrintName.getText() == null || mEdPrintName.getText().toString().isEmpty()) {
ToastUtils.show(mContext, "請輸入打印機名稱");
return;
}
......
......@@ -77,6 +77,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
initViewPager();
}
private IpPrintListActivityFragment ipPrintListActivityFragment;
/**
* 设置Viewpager的适配器
*/
......@@ -88,7 +90,8 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
mFragments.add(LocalPrintFragment.newInstance());
}
titles.add("網絡打印");
mFragments.add(IpPrintListActivityFragment.newInstance());
ipPrintListActivityFragment = IpPrintListActivityFragment.newInstance();
mFragments.add(ipPrintListActivityFragment);
//实例化适配器
mTabFragmentAdapter = new TabFragmentAdapter(getSupportFragmentManager(), 1);
......@@ -110,7 +113,11 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
topBar.setTitle("打印設置");
topBar.setBackgroundColor(getResources().getColor(R.color.theme_color));
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
......
......@@ -39,9 +39,13 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
}
((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.setOnItemSelectedClickListener(R.id.layout_delete,)
helper.addOnClickListener(R.id.layout_delete);
}
public int getSelectPosition() {
return selectPosition;
}
......
package com.joe.print.mvp.ui.fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
......@@ -18,10 +17,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
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.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
......@@ -31,15 +29,12 @@ import com.joe.print.di.component.DaggerIpPrintListActivityComponent;
import com.joe.print.di.module.IpPrintListActivityModule;
import com.joe.print.mvp.contract.IpPrintListActivityContract;
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.adapter.PrinterListAdapter;
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
import com.yanzhenjie.recyclerview.SwipeMenuItem;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.yanzhenjie.recyclerview.touch.OnItemMoveListener;
import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.io.Serializable;
import java.util.Collections;
......@@ -166,16 +161,16 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
// 1. MATCH_PARENT 自适应高度,保持和Item一样高;
// 2. 指定具体的高,比如80;
// 3. WRAP_CONTENT,自身高度,不推荐;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
// int height = ViewGroup.LayoutParams.MATCH_PARENT;
// 添加右侧的按鈕。
SwipeMenuItem deleteItem = new SwipeMenuItem(mContext).setBackground(
R.color.theme_color)
// .setImage(R.drawable.ic_action_delete)
.setText("刪除")
.setTextColor(Color.WHITE)
.setWidth(width)
.setHeight(height);
swipeRightMenu.addMenuItem(deleteItem);// 添加一个按钮到右侧侧菜单。
// SwipeMenuItem deleteItem = new SwipeMenuItem(mContext).setBackground(
// R.color.theme_color)
//// .setImage(R.drawable.ic_action_delete)
// .setText("刪除")
// .setTextColor(Color.WHITE)
// .setWidth(width)
// .setHeight(height);
// swipeRightMenu.addMenuItem(deleteItem);// 添加一个按钮到右侧侧菜单。
};
/**
......@@ -216,27 +211,24 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
if (printListAdapter == null) {
mRvPrintList.setOnItemClickListener((view, adapterPosition) -> {
//item點擊事件 打開打印機詳情
Intent intent = new Intent(mContext, PrinterAddActivity.class);
intent.putExtra("printer_position", adapterPosition);
intent.putExtra("printList", (Serializable) devicess);
startActivity(intent);
startToEditPrint(adapterPosition);
});
//menu 右侧菜單點擊事件
mRvPrintList.setOnItemMenuClickListener((menuBridge, position) -> {
//刪除按鈕點擊事件
menuBridge.closeMenu();
//調用刪除接口
mPresenter.deletePrinter(devicess.get(position).getId() + "");
if (printListAdapter.getSelectPosition() == position) {
//如果刪除的是當前選中的默認打印機,那麼移除默認打印機
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_IP);
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PORT);
SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PAPER);
printListAdapter.setSelectPosition(-1);
}
devicess.remove(position);
printListAdapter.notifyItemRemoved(position);
});
// mRvPrintList.setOnItemMenuClickListener((menuBridge, position) -> {
// //刪除按鈕點擊事件
// menuBridge.closeMenu();
// //調用刪除接口
// mPresenter.deletePrinter(devicess.get(position).getId() + "");
// if (printListAdapter.getSelectPosition() == position) {
// //如果刪除的是當前選中的默認打印機,那麼移除默認打印機
// SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_IP);
// SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PORT);
// SPUtils.remove(mContext, PrintConstans.DEFAULT_PRINT_PAPER);
// printListAdapter.setSelectPosition(-1);
// }
// devicess.remove(position);
// printListAdapter.notifyItemRemoved(position);
// });
// Item的Menu点击。
mRvPrintList.setOnItemStateChangedListener(mOnItemStateChangedListener); // 监听Item的手指状态,拖拽、侧滑、松开。
mRvPrintList.setLongPressDragEnabled(true); // 长按拖拽,默认关闭。
......@@ -270,6 +262,18 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
});// 监听拖拽和侧滑删除,更新UI和数据源。
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.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color)));
......@@ -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
public void loadFile() {
mRvPrintList.setVisibility(View.GONE);
......@@ -291,7 +302,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_add_print) {
startActivity(new Intent(mContext, PrinterAddActivity.class));
startToEditPrint(-1);
}
}
}
......@@ -97,7 +97,7 @@
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='單時間' />
android:text='單時間' />
<TextView
android:id="@+id/tv_remark"
......@@ -185,7 +185,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費:"
android:text="送貨費:"
android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
......
......@@ -74,13 +74,29 @@
android:id="@+id/tv_printer_edit"
android:layout_width="@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:text="編輯"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintRight_toLeftOf="@id/layout_delete"
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
android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent"
......
......@@ -3,6 +3,6 @@
<string name="print_port">端口號:%1$s</string>
<string name="create_order_time">單時間:</string>
<string name="create_order_time">單時間:</string>
<string name="address">地址:</string>
</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