Commit c1f2f178 by Wyh

1、供應鏈下單,食品列表

Signed-off-by: Wyh <1239658231>
parent 50265e6a
......@@ -73,7 +73,7 @@ public class DefaultFormatPrinter implements FormatPrinter {
*
* @param request
* @param bodyString
*/
*/
@Override
public void printJsonRequest(Request request, String bodyString) {
final String requestBody = LINE_SEPARATOR + BODY_TAG + LINE_SEPARATOR + bodyString;
......@@ -105,15 +105,15 @@ public class DefaultFormatPrinter implements FormatPrinter {
/**
* 打印网络响应信息, 当网络响应时 {{@link okhttp3.ResponseBody}} 可以解析的情况
*
* @param chainMs 服务器响应耗时(单位毫秒)
* @param chainMs 服务器响应耗时(单位毫秒)
* @param isSuccessful 请求是否成功
* @param code 响应码
* @param headers 请求头
* @param contentType 服务器返回数据的数据类型
* @param bodyString 服务器返回的数据(已解析)
* @param segments 域名后面的资源地址
* @param message 响应信息
* @param responseUrl 请求地址
* @param code 响应码
* @param headers 请求头
* @param contentType 服务器返回数据的数据类型
* @param bodyString 服务器返回的数据(已解析)
* @param segments 域名后面的资源地址
* @param message 响应信息
* @param responseUrl 请求地址
*/
@Override
public void printJsonResponse(long chainMs, boolean isSuccessful, int code, String headers, MediaType contentType,
......@@ -135,13 +135,13 @@ public class DefaultFormatPrinter implements FormatPrinter {
/**
* 打印网络响应信息, 当网络响应时 {{@link okhttp3.ResponseBody}} 为 {@code null} 或不可解析的情况
*
* @param chainMs 服务器响应耗时(单位毫秒)
* @param chainMs 服务器响应耗时(单位毫秒)
* @param isSuccessful 请求是否成功
* @param code 响应码
* @param headers 请求头
* @param segments 域名后面的资源地址
* @param message 响应信息
* @param responseUrl 请求地址
* @param code 响应码
* @param headers 请求头
* @param segments 域名后面的资源地址
* @param message 响应信息
* @param responseUrl 请求地址
*/
@Override
public void printFileResponse(long chainMs, boolean isSuccessful, int code, String headers,
......@@ -165,6 +165,7 @@ public class DefaultFormatPrinter implements FormatPrinter {
* @param withLineSize 为 {@code true} 时, 每行的信息长度不会超过110, 超过则自动换行
*/
private static void logLines(String tag, String[] lines, boolean withLineSize) {
StringBuilder text = new StringBuilder();
for (String line : lines) {
int lineLength = line.length();
int MAX_LONG_SIZE = withLineSize ? 110 : lineLength;
......@@ -173,9 +174,11 @@ public class DefaultFormatPrinter implements FormatPrinter {
int end = (i + 1) * MAX_LONG_SIZE;
end = end > line.length() ? line.length() : end;
Timber.tag(tag).i(DEFAULT_LINE + line.substring(start, end));
Log.e(tag, DEFAULT_LINE + line.substring(start, end));
text.append("\n").append(line.substring(start, end));
// Log.e(tag, DEFAULT_LINE + line.substring(start, end));
}
}
Log.e(tag, text.toString());
}
......
......@@ -19,16 +19,17 @@ import android.app.Activity;
import android.app.Service;
import android.view.View;
import com.jess.arms.utils.Preconditions;
import com.trello.rxlifecycle2.RxLifecycle;
import org.simple.eventbus.EventBus;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;
import com.jess.arms.utils.Preconditions;
import com.trello.rxlifecycle2.RxLifecycle;
import org.simple.eventbus.EventBus;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
......
......@@ -30,10 +30,10 @@ public class ResturantInfoManager {
if (restaurantInfo == null) {
restaurantInfo = new RestaurantInfo();
}
brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 0));
brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 1));
brandInfo.setBrandName((String) SPUtils.get(UserConstans.brandName, ""));
restaurantInfo.setGsPosShopId((String) SPUtils.get(UserConstans.gsPosShopId, "-1"));
restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 0));
restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 26));
restaurantInfo.setRestaurantName((String) SPUtils.get(UserConstans.restaurantName, ""));
}
......
......@@ -20,6 +20,14 @@ public class TextUtil {
str.equals("null") || str.equals("undefined");
}
public static boolean isEmptyOrNullOrUndefined(EditText editText) {
if (editText == null || editText.getText() == null) {
return true;
} else {
return isEmptyOrNullOrUndefined(editText.getText().toString());
}
}
public static boolean isNotEmptyOrNullOrUndefined(String str) {
return str != null && str.length() != 0 &&
!str.equals("null") && !str.equals("undefined");
......
......@@ -13,6 +13,8 @@ import lombok.Data;
public class CategoryBean {
private int id;
private String categoryName;
//數量
private int count;
public CategoryBean() {
}
......@@ -21,4 +23,10 @@ public class CategoryBean {
this.id = id;
this.categoryName = categoryName;
}
public CategoryBean(int id, String categoryName, int count) {
this.id = id;
this.categoryName = categoryName;
this.count = count;
}
}
......@@ -520,7 +520,7 @@
<!-- 供應鏈功能的文字顏色-->
<color name="supply_function_color">#94918F</color>
<!-- 供應鏈頁面背景色-->
<color name="supply_chain_bg_color">#EEF2F5</color>
<color name="supply_chain_bg_color">@color/color_f3</color>
<color name="supply_chain_category_title_bg">#2CA0EA</color>
......
package com.gingersoft.gsa.delivery_pick_mode.data.network
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.intercept.HeadersInterceptor
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.intercept.LoggingInterceptor
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans.ROOT_SERVER
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans.URK_RICEPON_GSA
......@@ -20,6 +21,7 @@ object ServiceCreator {
.writeTimeout(30, TimeUnit.SECONDS)
.addInterceptor(RequestInterceptor())
.addInterceptor(HeadersInterceptor())
.addInterceptor(LoggingInterceptor())
private lateinit var builder: Retrofit.Builder
private lateinit var builder2: Retrofit.Builder
......
......@@ -12,24 +12,24 @@ import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.billy.cc.core.component.CC
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.app.GsaCloudApplication
import com.gingersoft.gsa.cloud.common.core.pay.PayMethod
import com.gingersoft.gsa.cloud.common.constans.AppConstans
import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans
import com.gingersoft.gsa.cloud.common.constans.PrintConstans
import com.gingersoft.gsa.cloud.common.core.order.order.TakeawayOrder
import com.gingersoft.gsa.cloud.common.core.pay.PayMethod
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.common.core.print.bean.adapter.PrintContentAdapter
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils
import com.gingersoft.gsa.cloud.component.ComponentName
import com.gingersoft.gsa.cloud.common.constans.AppConstans
import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans
import com.gingersoft.gsa.cloud.common.constans.PrintConstans
import com.gingersoft.gsa.cloud.common.core.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.common.core.print.bean.adapter.PrintContentAdapter
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService
import com.gingersoft.gsa.delivery_pick_mode.R
import com.gingersoft.gsa.delivery_pick_mode.data.WeatherRepository
import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.*
......@@ -182,7 +182,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
RxTimerUtil.interval({
launch({
//獲取即時單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 0).apply {
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1] + ",8", fragmentType[0], "1", orderNo, phone, 0).apply {
if (isSuccess()) {
val data = getData()
if (data != null) {
......@@ -192,6 +192,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//確認訂單之前得先獲取訂單詳情
val orderInfo = repository.getOrderInfo(dataList[0].Id.toString())
if (orderInfo.data != null && orderInfo.data!!.isNotEmpty()) {
orderInfo.data!![0].order_type = dataList[0].order_type
orderInfo.data!![0].orderPayType = dataList[0].orderPayType
val orderDetail = orderInfo.data!![0]
if (orderDetail.order_type == 7) {
//如果是自取單,將物流類型改為本店
......
......@@ -200,7 +200,6 @@ public class PrjService extends Service implements ReceiveListener {
@Override
public void onNext(String s) {
Log.e(TAG, "請求到PRJ數據:" + s);
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
// startPrint(s);
newPrint(s);
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.supply_chain" >
package="com.gingersoft.supply_chain">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name="com.gingersoft.gsa.cloud.app.GsaCloudApplication"
android:requestLegacyExternalStorage="true"
android:networkSecurityConfig="@xml/network_android" >
<activity android:name=".mvp.ui.activity.SupplyChainMainActivity" >
android:networkSecurityConfig="@xml/network_android"
android:requestLegacyExternalStorage="true">
<activity android:name=".mvp.ui.activity.SupplyChainMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
......@@ -28,8 +30,7 @@
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="640" />
<!--适配android 7.0文件访问 -->
android:value="640" /> <!-- 适配android 7.0文件访问 -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.gingersoft.supply_chain"
......
......@@ -26,24 +26,6 @@ public class FoodListInfoBean {
private String supplierName;
private long createTime;
//食材集合
private List<PurchaseFoodListVOSBean> purchaseFoodListVOS;
/**
* 食材信息
*/
@Data
public static class PurchaseFoodListVOSBean {
private int id;
private String supplierName;
private String images;
private String foodNo;
private String name;
private double unitPrice;
private int quantityStarts;
private int quantityEnd;
private int type;
private String unitContent;
private long createTime;
}
private List<PurchaseFoodListVosBean> purchaseFoodListVOS;
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/5
* Time: 17:23
* Use:新增採購單時,需要傳遞的數據
*/
@Data
public class NewPurchaseOrderBean {
private int brandId;
private int restaurantId;
private double totalAmount;
private String remarks;
private List<PurchaseOrderDetailsBean> purchaseOrderDetailsVOS;
@Data
public static class PurchaseOrderDetailsBean {
private int foodId;
private int foodQuantity;
private double foodPrice;
private int supplierId;
}
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/5
* Time: 17:01
* Use: 採購單對象
*/
@Data
public class OrderBean {
private int id;
private int uid;
private int orderNo;
private int foodCount;
private double totalAmount;
private int status;
private int createTime;
}
package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/4
* Time: 11:41
* Use:食材信息
*/
@Data
public class PurchaseFoodListVosBean {
private int id;
private String supplierName;
private String images;
private String foodNo;
private String name;
private double unitPrice;
private int quantityStarts;
private int quantityEnd;
private int type;
private String unitContent;
private long createTime;
/**
* 食品數量,記錄用戶點了多少份
*/
private int foodCount;
/**
* 分類id
*/
private int categoryId;
/**
* 所屬供應商id
*/
private int supplierId;
/**
* 是否選中
*/
private boolean isChecked;
/**
* 是否刪除
* {@link Constant.DELETE,Constant.NORMAL}
*
*/
private int deletes;
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/2
* Time: 17:36
* Use: 採購訂單
*/
@Data
public class PurchaseOrderBean {
private String supplierName;
private String orderNo;
private long createTime;
private int count;
private String foods;
private double total;
public PurchaseOrderBean(String supplierName, String orderNo, long createTime, int count, String foods, double total) {
this.supplierName = supplierName;
this.orderNo = orderNo;
this.createTime = createTime;
this.count = count;
this.foods = foods;
this.total = total;
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/5
* Time: 16:42
* Use: 供應鏈採購單
*/
@Data
public class PurchaseOrderResultBean {
private boolean success;
private long sysTime;
private DataBean data;
@Data
public static class DataBean {
private int count;
private List<OrderBean> list;
}
}
package com.gingersoft.supply_chain.mvp.content;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import java.util.Map;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/5
* Time: 16:27
* Use:
*/
public class Constant {
public static final int DELETE = 1;
public static final int NORMAL = 0;
public static void mapAddInfo(Map<String, Object> map){
map.put("restaurantId", ResturantInfoManager.newInstance().getRestaurantId());
map.put("brandId", ResturantInfoManager.newInstance().getBrandId());
map.put("pageSize", 10);
}
}
package com.gingersoft.supply_chain.mvp.content;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import java.util.ArrayList;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/12/4
* Time: 11:21
* Use: 供應鏈購物車,需要緩存用戶選中的食品
*/
public class SupplyShoppingCart {
/**
* key為食品id
* value為食品信息
*/
private static List<PurchaseFoodListVosBean> cartFoods;
private static SupplyShoppingCart shoppingCart;
public static SupplyShoppingCart getInstance() {
if (shoppingCart == null) {
shoppingCart = new SupplyShoppingCart();
}
return shoppingCart;
}
public List<PurchaseFoodListVosBean> getCartFoods() {
if (cartFoods == null) {
cartFoods = new ArrayList<>();
}
return cartFoods;
}
public void setCartFoods(List<PurchaseFoodListVosBean> cartFoods) {
SupplyShoppingCart.cartFoods = cartFoods;
}
}
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
......@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -29,7 +31,9 @@ public interface FoodIngredientsContract {
interface View extends IView {
void loadLeftSupplierInfo(List<CategoryBean> categoryBeans);
void loadRightFoodIngredients(List<FoodListInfoBean.DataBean.PurchaseFoodListVOSBean> purchaseFoodListVOS);
void loadRightFoodIngredients(List<PurchaseFoodListVosBean> purchaseFoodListVOS);
void onDeleteFoodSuccess(int position);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......@@ -38,5 +42,6 @@ public interface FoodIngredientsContract {
Observable<BaseResult> getFoodBySupplierId(Map<String, Object> map);
Observable<BaseResult> updateFood(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.jess.arms.mvp.IView;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -19,11 +26,13 @@ import com.jess.arms.mvp.IModel;
public interface OrderContentContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadAdapter(List<List<PurchaseFoodListVosBean>> supplierFoods);
void setTotalInfo(int typeTotal, double totalPrice);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> addNewPurchaseOrder(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.jess.arms.mvp.IView;
import com.gingersoft.supply_chain.mvp.bean.OrderBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderResultBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
/**
......@@ -19,11 +26,11 @@ import com.jess.arms.mvp.IModel;
public interface PurchaseListContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadOrderList(List<OrderBean> list);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<PurchaseOrderResultBean> getOrderList(Map<String, Object> map);
}
}
......@@ -16,6 +16,7 @@ import java.util.Map;
import javax.inject.Inject;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -59,4 +60,9 @@ public class FoodIngredientsModel extends BaseModel implements FoodIngredientsCo
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodBySupplierId(map);
}
@Override
public Observable<BaseResult> updateFood(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).updateFood(requestBody);
}
}
\ No newline at end of file
......@@ -2,15 +2,18 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.contract.OrderContentContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.OrderContentContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -43,4 +46,9 @@ public class OrderContentModel extends BaseModel implements OrderContentContract
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<BaseResult> addNewPurchaseOrder(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addNewPurchaseOrder(requestBody);
}
}
\ No newline at end of file
......@@ -2,15 +2,19 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderResultBean;
import com.gingersoft.supply_chain.mvp.contract.PurchaseListContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import java.util.Map;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.PurchaseListContract;
import io.reactivex.Observable;
/**
......@@ -43,4 +47,9 @@ public class PurchaseListModel extends BaseModel implements PurchaseListContract
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<PurchaseOrderResultBean> getOrderList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getOrderList(map);
}
}
\ No newline at end of file
......@@ -5,8 +5,12 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.FoodIngredientsContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -26,6 +30,8 @@ import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
......@@ -55,7 +61,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
* 集合是對應的食品
* 如果通過在map中有食品,就不用再次調用接口
*/
private Map<Integer, List<FoodListInfoBean.DataBean.PurchaseFoodListVOSBean>> supplierFoodsMap;
private Map<Integer, List<PurchaseFoodListVosBean>> supplierFoodsMap;
@Inject
public FoodIngredientsPresenter(FoodIngredientsContract.Model model, FoodIngredientsContract.View rootView) {
......@@ -71,6 +77,11 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
this.mApplication = null;
}
/**
* 獲取數據,供應商
*
* @param supplierId
*/
public void loadFoodIngredientsData(int supplierId) {
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
......@@ -97,12 +108,17 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
supplierFoodsMap = new HashMap<>();
}
for (FoodListInfoBean.DataBean datum : info.getData()) {
categoryBeans.add(new CategoryBean(datum.getId(), datum.getSupplierName()));
//將供應商信息轉為左側用來顯示的數據類型
CategoryBean categoryBean = new CategoryBean(datum.getId(), datum.getSupplierName());
//將供應商和供應商的食品添加到map中
if (datum.getPurchaseFoodListVOS() == null) {
supplierFoodsMap.put(datum.getId(), null);
} else {
int totalCount = setFoodCount(datum.getPurchaseFoodListVOS());
categoryBean.setCount(totalCount);
supplierFoodsMap.put(datum.getId(), new ArrayList<>(datum.getPurchaseFoodListVOS()));
}
categoryBeans.add(categoryBean);
}
mRootView.loadLeftSupplierInfo(categoryBeans);
if (info.getData().size() > 0) {
......@@ -113,6 +129,32 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
});
}
/**
* 將購物車中的食品
*
* @param purchaseFoodListVOS
*/
private int setFoodCount(List<PurchaseFoodListVosBean> purchaseFoodListVOS) {
//統計當前食品集合中有多少個被選中
int totalCount = 0;
for (PurchaseFoodListVosBean cartFood : SupplyShoppingCart.getInstance().getCartFoods()) {
//將購物車中的食品數量同步到當前數據中
for (PurchaseFoodListVosBean purchaseFoodListVO : purchaseFoodListVOS) {
if (cartFood.getId() == purchaseFoodListVO.getId()) {
//購物車裡的食品id和當前的食品id一樣,則將購物車中的食品數量賦值給當前食品
purchaseFoodListVO.setFoodCount(cartFood.getFoodCount());
totalCount += cartFood.getFoodCount();
}
}
}
return totalCount;
}
/**
* 獲取數據,供應商
*
* @param supplierId
*/
public void loadFoodsBySupplierId(int supplierId) {
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
......@@ -134,10 +176,11 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
@Override
public void onNext(@NonNull BaseResult info) {
if (info.isSuccess() && info.getData() != null) {
List<FoodListInfoBean.DataBean.PurchaseFoodListVOSBean> purchaseFoodListVOS = JsonUtils.parseArray(info.getData(), FoodListInfoBean.DataBean.PurchaseFoodListVOSBean.class);
List<PurchaseFoodListVosBean> purchaseFoodListVOS = JsonUtils.parseArray(info.getData(), PurchaseFoodListVosBean.class);
if (purchaseFoodListVOS == null) {
supplierFoodsMap.put(supplierId, new ArrayList<>());
} else {
setFoodCount(purchaseFoodListVOS);
supplierFoodsMap.put(supplierId, new ArrayList<>(purchaseFoodListVOS));
}
mRootView.loadRightFoodIngredients(purchaseFoodListVOS);
......@@ -148,7 +191,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
public void getFoodsBySupplierId(int supplierId) {
if (supplierFoodsMap != null) {
List<FoodListInfoBean.DataBean.PurchaseFoodListVOSBean> purchaseFoodListVOSBeans = supplierFoodsMap.get(supplierId);
List<PurchaseFoodListVosBean> purchaseFoodListVOSBeans = supplierFoodsMap.get(supplierId);
if (purchaseFoodListVOSBeans != null) {
mRootView.loadRightFoodIngredients(purchaseFoodListVOSBeans);
} else {
......@@ -157,4 +200,39 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
}
}
/**
* 獲取選中的食品,存入購物車
*
* @param integerMap 存放食品id和數量的map
*/
public void getSelectFood(Map<Integer, PurchaseFoodListVosBean> integerMap) {
//把購物車的食品取出來
List<PurchaseFoodListVosBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
//清空
cartFoods.clear();
//將本次選擇的添加進去
cartFoods.addAll(integerMap.values());
}
public void deleteFood(PurchaseFoodListVosBean purchaseFoodListVosBean, int position){
purchaseFoodListVosBean.setDeletes(Constant.DELETE);
mModel.updateFood(RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(purchaseFoodListVosBean)))
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("刪除中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(()->mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if(baseResult.isSuccess()){
mRootView.onDeleteFoodSuccess(position);
} else if(TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())){
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage("刪除失敗");
}
}
});
}
}
package com.gingersoft.supply_chain.mvp.presenter;
import android.annotation.SuppressLint;
import android.app.Application;
import android.widget.CheckBox;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.ResturantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.mvp.bean.NewPurchaseOrderBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.OrderContentContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
......@@ -36,6 +59,8 @@ public class OrderContentPresenter extends BasePresenter<OrderContentContract.Mo
@Inject
AppManager mAppManager;
private List<List<PurchaseFoodListVosBean>> supplierFoods;
@Inject
public OrderContentPresenter(OrderContentContract.Model model, OrderContentContract.View rootView) {
super(model, rootView);
......@@ -49,4 +74,106 @@ public class OrderContentPresenter extends BasePresenter<OrderContentContract.Mo
this.mImageLoader = null;
this.mApplication = null;
}
public void organizeShopCartData() {
Map<Integer, List<PurchaseFoodListVosBean>> listMap = new HashMap<>(4);
double totalPrice = 0;
int totalTypeNumber = 0;
for (PurchaseFoodListVosBean cartFood : SupplyShoppingCart.getInstance().getCartFoods()) {
//計算總價
if (cartFood.isChecked()) {
totalPrice = MoneyUtil.sum(totalPrice, MoneyUtil.priceCalculation(cartFood.getUnitPrice(), cartFood.getFoodCount()));
totalTypeNumber++;
}
List<PurchaseFoodListVosBean> foodListVosBeans = listMap.get(cartFood.getSupplierId());
if (foodListVosBeans == null) {
foodListVosBeans = new ArrayList<>();
foodListVosBeans.add(cartFood);
listMap.put(cartFood.getSupplierId(), foodListVosBeans);
} else {
foodListVosBeans.add(cartFood);
}
}
supplierFoods = new ArrayList<>();
supplierFoods.addAll(listMap.values());
mRootView.loadAdapter(supplierFoods);
mRootView.setTotalInfo(totalTypeNumber, totalPrice);
}
/**
* 計算出已選中食品的總價
*/
public void calculateTotalPrice(CheckBox cbAllSelect) {
double totalAmount = 0;
int totalTypeFood = 0;
for (PurchaseFoodListVosBean purchaseFoodListVosBean : SupplyShoppingCart.getInstance().getCartFoods()) {
if (purchaseFoodListVosBean.isChecked()) {
totalTypeFood++;
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodListVosBean.getUnitPrice(), purchaseFoodListVosBean.getFoodCount()));
}
}
mRootView.setTotalInfo(totalTypeFood, totalAmount);
cbAllSelect.setChecked(totalTypeFood == SupplyShoppingCart.getInstance().getCartFoods().size());
}
@SuppressLint("CheckResult")
public void addNewPurchaseOrder(List<PurchaseFoodListVosBean> purchaseFoodListVosBeans, String remarks) {
NewPurchaseOrderBean newPurchaseOrderBean = new NewPurchaseOrderBean();
newPurchaseOrderBean.setBrandId(ResturantInfoManager.newInstance().getBrandId());
newPurchaseOrderBean.setRestaurantId(ResturantInfoManager.newInstance().getRestaurantId());
double totalAmount = 0;
for (PurchaseFoodListVosBean purchaseFoodListVosBean : purchaseFoodListVosBeans) {
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodListVosBean.getUnitPrice(), purchaseFoodListVosBean.getFoodCount()));
}
newPurchaseOrderBean.setTotalAmount(totalAmount);
newPurchaseOrderBean.setRemarks(remarks);
ArrayList<NewPurchaseOrderBean.PurchaseOrderDetailsBean> purchaseOrderDetailsBeans = new ArrayList<>();
Observable.fromIterable(purchaseFoodListVosBeans)
.map(purchaseFoodListVosBean -> {
NewPurchaseOrderBean.PurchaseOrderDetailsBean orderDetailsBean = new NewPurchaseOrderBean.PurchaseOrderDetailsBean();
orderDetailsBean.setFoodId(purchaseFoodListVosBean.getId());
orderDetailsBean.setFoodPrice(purchaseFoodListVosBean.getUnitPrice());
orderDetailsBean.setFoodQuantity(purchaseFoodListVosBean.getFoodCount());
orderDetailsBean.setSupplierId(purchaseFoodListVosBean.getSupplierId());
return orderDetailsBean;
}).subscribe(new Observer<NewPurchaseOrderBean.PurchaseOrderDetailsBean>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(NewPurchaseOrderBean.PurchaseOrderDetailsBean purchaseOrderDetailsBean) {
purchaseOrderDetailsBeans.add(purchaseOrderDetailsBean);
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
newPurchaseOrderBean.setPurchaseOrderDetailsVOS(purchaseOrderDetailsBeans);
}
});
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(newPurchaseOrderBean));
mModel.addNewPurchaseOrder(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
}
});
}
}
......@@ -2,15 +2,26 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderResultBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.PurchaseListContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
/**
......@@ -40,4 +51,31 @@ public class PurchaseListPresenter extends BasePresenter<PurchaseListContract.Mo
this.mImageLoader = null;
this.mApplication = null;
}
public void getOrderList(String orderNo, int orderStatus, int pageIndex) {
Map<String, Object> map = new HashMap<>(6);
Constant.mapAddInfo(map);
if (TextUtil.isNotEmptyOrNullOrUndefined(orderNo)) {
map.put("orderNo", orderNo);
}
if (orderStatus != 0) {
map.put("status", orderStatus);
}
map.put("pageIndex", pageIndex);
mModel.getOrderList(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<PurchaseOrderResultBean>(mErrorHandler) {
@Override
public void onNext(@NonNull PurchaseOrderResultBean info) {
if (info.isSuccess() && info.getData() != null) {
mRootView.loadOrderList(info.getData().getList());
}
}
});
}
}
......@@ -4,6 +4,7 @@ import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderResultBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import java.util.List;
......@@ -25,57 +26,116 @@ import retrofit2.http.QueryMap;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
*Date: 2020/11/20
* Time: 15:29
* Use:
*/
public interface SupplierServer {
/**
* 新增供應商
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("supplier/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addSupplier(@Body RequestBody requestBody);
/**
* 獲取供應商列表
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("supplier/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<SupplierResultBean> getSupplierList(@QueryMap Map<String, Object> map);
/**
* 修改供應商信息
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("supplier/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateSupplier(@Body RequestBody requestBody);
/**
* 獲取供應商聯繫方式
* @param supplierId
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("supplier/contact/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getSupplierContact(@Query("supplierId") String supplierId);
/**
* 獲取食品單位列表集合
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("foodUnit/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<MeasurementUnitBean> getMeasurementUnitList(@QueryMap Map<String, Object> map);
/**
* 修改食品單位
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("foodUnit/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateFoodUnit(@Body RequestBody requestBody);
/**
* 獲取食品分類
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("foodCategory/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<FoodCategoryResultBean> getFoodCategoryList(@QueryMap Map<String, Object> map);
/**
* 新增食品單位
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("foodCategory/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addFoodUnit(@Body RequestBody requestBody);
/**
* 新增分類
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("foodCategory/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addFoodCategory(@Body RequestBody requestBody);
/**
* 上傳圖片
* @param parts
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@Multipart
@POST("purchaseFood/image/upload" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> upLoadPic(@Part List<MultipartBody.Part> parts);
/**
* 新增食品
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseFood/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addFood(@Body RequestBody requestBody);
/**
* 根據供應商獲取食品集合信息
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("supplier/purchaseFood/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<FoodListInfoBean> getFoodIngredientsData(@QueryMap Map<String, Object> map);
......@@ -89,4 +149,31 @@ public interface SupplierServer {
@GET("supplier/purchaseFood/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getFoodBySupplierId(@QueryMap Map<String, Object> map);
/**
* 修改食材信息
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseFood/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateFood(@Body RequestBody requestBody);
/**
* 獲取採購單列表
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseOrder/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<PurchaseOrderResultBean> getOrderList(@QueryMap Map<String, Object> map);
/**
* 新增採購訂單
* @param requestBody
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseOrder/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addNewPurchaseOrder(@Body RequestBody requestBody);
}
......@@ -55,7 +55,6 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
@Override
public void initIntent() {
}
@Override
......
......@@ -4,7 +4,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderBean;
import com.gingersoft.supply_chain.mvp.bean.OrderBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -18,21 +18,20 @@ import java.util.List;
* Time: 17:36
* Use: 採購訂單列表
*/
public class PurchaseOrderAdapter extends BaseQuickAdapter<PurchaseOrderBean, BaseViewHolder> {
public class PurchaseOrderAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {
public PurchaseOrderAdapter(@Nullable List<PurchaseOrderBean> data) {
public PurchaseOrderAdapter(@Nullable List<OrderBean> data) {
super(R.layout.item_purchase_order, data);
addChildClickViewIds(R.id.btn_purchase_send, R.id.btn_purchase_buy_again, R.id.btn_receiver_goods);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, PurchaseOrderBean purchaseOrderBean) {
viewHolder.setText(R.id.tv_food_item_supplier_name, purchaseOrderBean.getSupplierName());
viewHolder.setText(R.id.tv_purchase_order_no, purchaseOrderBean.getOrderNo());
protected void convert(@NotNull BaseViewHolder viewHolder, OrderBean purchaseOrderBean) {
viewHolder.setText(R.id.tv_purchase_order_no, "" + purchaseOrderBean.getOrderNo());
viewHolder.setText(R.id.tv_purchase_order_create_time, TimeUtils.getTime(purchaseOrderBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
viewHolder.setText(R.id.tv_purchase_order_goods_num, purchaseOrderBean.getCount() + "");
viewHolder.setText(R.id.tv_purchase_order_goods, purchaseOrderBean.getFoods());
viewHolder.setText(R.id.tv_purchase_order_total_price, purchaseOrderBean.getTotal() + "");
viewHolder.setText(R.id.tv_purchase_order_goods_num, purchaseOrderBean.getFoodCount() + "");
// viewHolder.setText(R.id.tv_purchase_order_goods, purchaseOrderBean.getFoods());
viewHolder.setText(R.id.tv_purchase_order_total_price, purchaseOrderBean.getTotalAmount() + "");
// viewHolder.setText(R.id.tv_purchase_order_time_out, purchaseOrderBean.getTotal() + "");
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.gingersoft.supply_chain.mvp.ui.adapter.FoodListAdapter.ORDER_TYPE;
/**
* @author 宇航.
* User: admin
......@@ -7,5 +30,135 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
* Time: 18:11
* Use:
*/
//public class ShoppingCartAdapter extends {
//}
public class ShoppingCartAdapter extends BaseQuickAdapter<List<PurchaseFoodListVosBean>, BaseViewHolder> {
private Context context;
private List<PurchaseFoodListVosBean> selectFoods;
public ShoppingCartAdapter(Context context, @Nullable List<List<PurchaseFoodListVosBean>> data) {
super(R.layout.item_shopping_cart, data);
this.context = context;
selectFoods = new ArrayList<>();
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, List<PurchaseFoodListVosBean> purchaseFoodListVosBeans) {
RecyclerView rvFoods = viewHolder.getView(R.id.rv_shopping_cart_food);
if (purchaseFoodListVosBeans != null && purchaseFoodListVosBeans.size() > 0) {
viewHolder.setText(R.id.tv_order_item_supplier_name, purchaseFoodListVosBeans.get(0).getSupplierName());
TextView tvPrice = viewHolder.getView(R.id.tv_order_item_total_amount);
TextView tvFoodTypeNumber = viewHolder.getView(R.id.tv_order_item_food_type_total);
FoodListAdapter foodListAdapter = new FoodListAdapter(context, purchaseFoodListVosBeans, ORDER_TYPE);
Map<Integer, PurchaseFoodListVosBean> integerMap = foodListAdapter.getIntegerMap();
for (PurchaseFoodListVosBean purchaseFoodListVosBean : purchaseFoodListVosBeans) {
integerMap.put(purchaseFoodListVosBean.getId(), purchaseFoodListVosBean);
}
rvFoods.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST));
rvFoods.setAdapter(foodListAdapter);
CheckBox cbAllSelect = viewHolder.getView(R.id.cb_order_item_all_select);
//全選按鈕的事件監聽
allSelectListener(foodListAdapter, cbAllSelect);
//單個食品的數量修改
foodListAdapter.setOnNumberChangeListener((foodId, number) -> {
//當數量發生改變時,重新計算價格。
calculateTotalPrice(purchaseFoodListVosBeans, tvPrice, tvFoodTypeNumber, cbAllSelect);
});
//單個食品選中狀態切換
foodListAdapter.setOnCheckedChangeListener((isChecked, purchaseFoodListVosBean) -> {
foodCheckedChanged(isChecked, purchaseFoodListVosBean);
calculateTotalPrice(foodListAdapter.getData(), tvPrice, tvFoodTypeNumber, cbAllSelect);
});
//計算總價,類型數量
calculateTotalPrice(purchaseFoodListVosBeans, tvPrice, tvFoodTypeNumber, cbAllSelect);
rvFoods.setVisibility(View.VISIBLE);
} else {
viewHolder.setText(R.id.tv_order_item_supplier_name, "");
viewHolder.setText(R.id.tv_order_item_food_type_total, String.valueOf(0));
viewHolder.setText(R.id.tv_order_item_total_amount, "$0");
rvFoods.setVisibility(View.GONE);
}
}
private OnInfoChangeListener onInfoChangeListener;
public interface OnInfoChangeListener {
/**
* 當選中或者數量發生變化時,通知外部修改
*/
void onInfoChange();
}
public void setOnInfoChangeListener(OnInfoChangeListener onInfoChangeListener) {
this.onInfoChangeListener = onInfoChangeListener;
}
/**
* 食品的選中狀態發生改變
*
* @param isChecked 是否選中
* @param purchaseFoodListVosBean 所修改的食品
*/
private void foodCheckedChanged(boolean isChecked, PurchaseFoodListVosBean purchaseFoodListVosBean) {
purchaseFoodListVosBean.setChecked(isChecked);
if (isChecked) {
//添加到已選中食品的集合中,下單時候用
if (!selectFoods.contains(purchaseFoodListVosBean)) {
selectFoods.add(purchaseFoodListVosBean);
}
} else {
selectFoods.remove(purchaseFoodListVosBean);
}
}
/**
* 全選按鈕的狀態切換
*
* @param foodListAdapter 顯示所有食品的adapter
* @param cbAllSelect 複選框
*/
private void allSelectListener(FoodListAdapter foodListAdapter, CheckBox cbAllSelect) {
//全選
cbAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()) {
for (PurchaseFoodListVosBean purchaseFoodListVosBean : foodListAdapter.getData()) {
if (!selectFoods.contains(purchaseFoodListVosBean)) {
selectFoods.add(purchaseFoodListVosBean);
}
purchaseFoodListVosBean.setChecked(isChecked);
}
foodListAdapter.notifyDataSetChanged();
}
});
}
/**
* 計算出已選中食品的總價
*
* @param purchaseFoodListVosBeans 所有食品
* @param tvPrice 顯示價格的textview
* @param tvNumber 顯示數量的textview
*/
public void calculateTotalPrice(List<PurchaseFoodListVosBean> purchaseFoodListVosBeans, TextView tvPrice, TextView tvNumber, CheckBox cbAllSelect) {
double totalAmount = 0;
int totalTypeFood = 0;
for (PurchaseFoodListVosBean purchaseFoodListVosBean : purchaseFoodListVosBeans) {
if (purchaseFoodListVosBean.isChecked()) {
totalTypeFood++;
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodListVosBean.getUnitPrice(), purchaseFoodListVosBean.getFoodCount()));
}
}
tvPrice.setText("$" + totalAmount);
tvNumber.setText(String.valueOf(totalTypeFood));
cbAllSelect.setChecked(totalTypeFood == purchaseFoodListVosBeans.size());
if (onInfoChangeListener != null) {
onInfoChangeListener.onInfoChange();
}
}
public List<PurchaseFoodListVosBean> getPurchaseFoodListVosBeans() {
return selectFoods;
}
}
......@@ -41,18 +41,28 @@ public class SupplierAdapter extends BaseQuickAdapter<SupplierInfoBean, BaseView
viewHolder.setText(R.id.tv_supplier_phone, supplierBean.getContactInformation());
viewHolder.setText(R.id.tv_supplier_contact, supplierBean.getContacts());
viewHolder.setText(R.id.tv_supplier_create_date, TimeUtils.getTime(supplierBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT) + "");
RadioButton radioButton = viewHolder.getView(R.id.rb_supplier);
radioButton.setChecked(viewHolder.getAdapterPosition() == selectIndex);
viewHolder.setGone(R.id.rb_supplier, !isSelect);
viewHolder.setGone(R.id.iv_supplier_edit, isSelect);
viewHolder.setGone(R.id.iv_supplier_delete, isSelect);
radioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
SupplierAdapter.this.notifyItemChanged(selectIndex);
selectIndex = viewHolder.getAdapterPosition();
SupplierAdapter.this.notifyItemChanged(selectIndex);
}
});
if(isSelect) {
RadioButton radioButton = viewHolder.getView(R.id.rb_supplier);
radioButton.setChecked(viewHolder.getAdapterPosition() == selectIndex);
radioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
if (getRecyclerView().isComputingLayout()) {
getRecyclerView().post(() -> notifyData(viewHolder));
} else {
notifyData(viewHolder);
}
}
});
}
}
private void notifyData(@NotNull BaseViewHolder viewHolder) {
SupplierAdapter.this.notifyItemChanged(selectIndex);
selectIndex = viewHolder.getAdapterPosition();
SupplierAdapter.this.notifyItemChanged(selectIndex);
}
public int getSelectIndex() {
......
......@@ -17,6 +17,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.ui.widget.dialog.DialogUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.adapter.BaseCategoryAdapter;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
......@@ -137,7 +138,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
hepler.setText(R.id.tv_parent_category_name, finalParentCategoryName);
EditText editText = hepler.getView(R.id.ed_new_category_name);
hepler.setOnClickListenter(R.id.btn_create_category, v1 -> {
if (editText.getText() == null) {
if (TextUtil.isEmptyOrNullOrUndefined(editText)) {
ToastUtils.show(mContext, "請輸入分類名稱");
return;
}
......@@ -165,7 +166,11 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
for (int i = 0; i < list.size(); i++) {
data.add(new CategoryBean(list.get(i).getId(), list.get(i).getName()));
}
mPresenter.getCategoryBeansById(data.get(0).getId(), mPresenter.secondCategoryTag);
if (data.size() > 0) {
mPresenter.getCategoryBeansById(data.get(0).getId(), mPresenter.secondCategoryTag);
} else {
hideLoading();
}
} else {
mPresenter.getCategoryBeansById(-1, mPresenter.secondCategoryTag);
}
......
package com.gingersoft.supply_chain.mvp.ui.fragment;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
......@@ -15,12 +16,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.gingersoft.gsa.cloud.common.ui.utils.AppDialog;
import com.gingersoft.gsa.cloud.ui.adapter.BaseCategoryAdapter;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerFoodIngredientsComponent;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.FoodIngredientsContract;
import com.gingersoft.supply_chain.mvp.presenter.FoodIngredientsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.FoodListAdapter;
......@@ -29,6 +32,7 @@ import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -37,14 +41,6 @@ import butterknife.OnClick;
/**
* ================================================
* Description: 食材管理
* <p>
* Created by MVPArmsTemplate on 11/24/2020 15:28
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredientsPresenter> implements FoodIngredientsContract.View, View.OnClickListener {
......@@ -115,6 +111,9 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
pageType = arguments.getInt(pageTypeKey);
}
initTopBar();
//初始化購物車數據
SupplyShoppingCart.getInstance().getCartFoods();
getFoodsBySupplierId();
}
......@@ -167,7 +166,11 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
} else if (viewId == R.id.btn_food_ingredients_confirm) {
//選擇完食品後,完成
//把選中的數據取出,
if (foodListAdapter != null) {
mPresenter.getSelectFood(foodListAdapter.getIntegerMap());
}
startWithPop(OrderContentFragment.newInstance());
} else if (viewId == R.id.btn_food_ingredients_cancel) {
//取消
killMyself();
......@@ -190,11 +193,15 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
}
@Override
public void loadRightFoodIngredients(List<FoodListInfoBean.DataBean.PurchaseFoodListVOSBean> purchaseFoodListVOS) {
public void loadRightFoodIngredients(List<PurchaseFoodListVosBean> purchaseFoodListVOS) {
if (foodListAdapter != null) {
foodListAdapter.setList(purchaseFoodListVOS);
} else {
foodListAdapter = new FoodListAdapter(mContext, purchaseFoodListVOS, pageType);
Map<Integer, PurchaseFoodListVosBean> integerMap = foodListAdapter.getIntegerMap();
for (PurchaseFoodListVosBean purchaseFoodListVosBean : SupplyShoppingCart.getInstance().getCartFoods()) {
integerMap.put(purchaseFoodListVosBean.getId(), purchaseFoodListVosBean);
}
LinearLayoutManager rightLayoutManager = new LinearLayoutManager(mContext);
rvRightFoodIngredients.setLayoutManager(rightLayoutManager);
rvRightFoodIngredients.setAdapter(foodListAdapter);
......@@ -206,10 +213,21 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
} else if (view.getId() == R.id.iv_supplier_delete) {
//刪除食材
PurchaseFoodListVosBean purchaseFoodListVosBean = foodListAdapter.getData().get(position);
new AppDialog().showWaringDialog(mContext, "是否確認刪除" + purchaseFoodListVosBean.getName(), new AppDialog.DialogOnClickListenter() {
@Override
public void onclick(View view, Dialog dialog) {
mPresenter.deleteFood(purchaseFoodListVosBean, position);
}
});
}
}
});
}
}
@Override
public void onDeleteFoodSuccess(int position) {
foodListAdapter.notifyItemChanged(position);
}
}
......@@ -5,7 +5,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
......@@ -13,19 +12,24 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerOrderContentComponent;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodListVosBean;
import com.gingersoft.supply_chain.mvp.contract.OrderContentContract;
import com.gingersoft.supply_chain.mvp.presenter.OrderContentPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.ShoppingCartAdapter;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.supply_chain.mvp.ui.fragment.FoodIngredientsFragment.ADD_ORDER;
/**
* ================================================
......@@ -47,6 +51,8 @@ public class OrderContentFragment extends BaseSupplyChainFragment<OrderContentPr
@BindView(R2.id.ed_order_content_remark)
EditText edOrderContentRemark;
private ShoppingCartAdapter shoppingCartAdapter;
public static OrderContentFragment newInstance() {
OrderContentFragment fragment = new OrderContentFragment();
return fragment;
......@@ -69,11 +75,28 @@ public class OrderContentFragment extends BaseSupplyChainFragment<OrderContentPr
@Override
public void initData(@Nullable Bundle savedInstanceState) {
cbOrderContentAllSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//全選
topbar.setTitle("採購單");
topbar.addLeftBackImageButton().setOnClickListener(v -> killMyself());
mPresenter.organizeShopCartData();
cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
//全選
if (buttonView.isPressed()) {
if (shoppingCartAdapter != null) {
double totalAmount = 0;
int totalTypeFood = 0;
for (List<PurchaseFoodListVosBean> datum : shoppingCartAdapter.getData()) {
for (PurchaseFoodListVosBean purchaseFoodListVosBean : datum) {
purchaseFoodListVosBean.setChecked(isChecked);
if (isChecked) {
totalTypeFood++;
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodListVosBean.getUnitPrice(), purchaseFoodListVosBean.getFoodCount()));
}
}
}
setTotalInfo(totalTypeFood, totalAmount);
shoppingCartAdapter.notifyDataSetChanged();
}
}
});
}
......@@ -84,15 +107,27 @@ public class OrderContentFragment extends BaseSupplyChainFragment<OrderContentPr
int viewId = v.getId();
if (viewId == R.id.tv_order_content_complete) {
//完成
List<PurchaseFoodListVosBean> purchaseFoodListVosBeans = shoppingCartAdapter.getPurchaseFoodListVosBeans();
mPresenter.addNewPurchaseOrder(purchaseFoodListVosBeans, edOrderContentRemark.getText() + "");
} else if (viewId == R.id.btn_order_content_order_template) {
//訂單模板
} else if (viewId == R.id.btn_order_content_add_food) {
//添加食材
startWithPop(FoodIngredientsFragment.newInstance(ADD_ORDER));
}
}
@Override
public void loadAdapter(List<List<PurchaseFoodListVosBean>> supplierFoods) {
shoppingCartAdapter = new ShoppingCartAdapter(mContext, supplierFoods);
rvOrderContent.setAdapter(shoppingCartAdapter);
shoppingCartAdapter.setOnInfoChangeListener(() -> mPresenter.calculateTotalPrice(cbOrderContentAllSelect));
}
@Override
public void setTotalInfo(int typeTotal, double totalPrice) {
tvOrderContentFoodTypeTotal.setText(String.valueOf(typeTotal));
tvOrderContentTotalAmount.setText("$" + totalPrice);
}
}
......@@ -14,7 +14,7 @@ import androidx.viewpager2.widget.ViewPager2;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerPurchaseListComponent;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderBean;
import com.gingersoft.supply_chain.mvp.bean.OrderBean;
import com.gingersoft.supply_chain.mvp.contract.PurchaseListContract;
import com.gingersoft.supply_chain.mvp.presenter.PurchaseListPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.PurchaseOrderAdapter;
......@@ -31,7 +31,6 @@ import com.qmuiteam.qmui.widget.tab.QMUITabIndicator;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment2;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
......@@ -54,11 +53,14 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
@BindView(R2.id.btn_save)
QMUIAlphaButton btnNewOrder;
private PurchaseOrderAdapter purchaseOrderAdapter;
public static PurchaseListFragment newInstance() {
PurchaseListFragment fragment = new PurchaseListFragment();
return fragment;
}
private final int[] orderState = new int[]{0, 1, 2, 3};
private int pageIndex = 1;
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerPurchaseListComponent //如找不到该类,请编译一下项目
......@@ -83,6 +85,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
});
initTopBar();
initTabAndData();
mPresenter.getOrderList("", orderState[0], pageIndex);
}
private void initTopBar() {
......@@ -91,6 +94,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
View view = View.inflate(mContext, R.layout.layout_shopping_cart, null);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
mTopBar.addRightView(view, R.id.qmui_shopping_cart, layoutParams);
view.setOnClickListener(v -> start(OrderContentFragment.newInstance()));
}
private void initTabAndData() {
......@@ -98,11 +102,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.setNormalColor(ContextCompat.getColor(mContext, R.color.color_86))
.setSelectColor(ContextCompat.getColor(mContext, R.color.theme_color));
List<PurchaseOrderBean> orderBeans = new ArrayList<>();
for (int i = 0; i < 10; i++) {
orderBeans.add(new PurchaseOrderBean("海鮮天地", "123456" + i, System.currentTimeMillis(), 3 * i, "", 10.56 * i));
}
purchaseOrderAdapter = new PurchaseOrderAdapter(orderBeans);
purchaseOrderAdapter = new PurchaseOrderAdapter(null);
PurchasePageAdapter adapter = new PurchasePageAdapter(purchaseOrderAdapter, 4);
contentViewPager.setAdapter(adapter);
mTabSegment.setupWithViewPager(contentViewPager);
......@@ -114,10 +114,10 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
mTabSegment.addTab(builder.setText("全部收貨").build(getContext()));
mTabSegment.notifyDataChanged();
mTabSegment.setMode(QMUITabSegment.MODE_FIXED);
mTabSegment.addOnTabSelectedListener(new QMUIBasicTabSegment.OnTabSelectedListener(){
mTabSegment.addOnTabSelectedListener(new QMUIBasicTabSegment.OnTabSelectedListener() {
@Override
public void onTabSelected(int index) {
mPresenter.getOrderList("", orderState[index], pageIndex);
}
@Override
......@@ -141,7 +141,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
@Override
public void onClick(View v) {
int viewId = v.getId();
if(viewId == R.id.layout_purchase_list_screen){
if (viewId == R.id.layout_purchase_list_screen) {
//篩選
QMUIPopups.popup(mContext, ViewGroup.LayoutParams.MATCH_PARENT)
.arrow(false)
......@@ -153,4 +153,9 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.show(v);
}
}
@Override
public void loadOrderList(List<OrderBean> list) {
purchaseOrderAdapter.setList(list);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
......@@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
<include layout="@layout/include_topbar" />
......@@ -42,13 +44,17 @@
android:id="@+id/rv_order_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_10"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_25"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_25"
android:paddingBottom="@dimen/dp_4">
......@@ -125,20 +131,20 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="@dimen/dp_5"
android:gravity="left"
android:hint="輸入備註" />
android:hint="輸入備註"
android:paddingLeft="@dimen/dp_5" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_order_content_complete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_35"
android:layout_marginLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_35"
android:background="@drawable/shape_app_btn"
android:paddingLeft="@dimen/dp_35"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_35"
android:paddingBottom="@dimen/dp_10"
android:background="@drawable/shape_app_btn"
android:text="完成"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
......
......@@ -12,6 +12,7 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_food_supplier_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="@dimen/dp_8"
......@@ -53,7 +54,9 @@
</LinearLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<include
android:id="@+id/line_supplier_info"
layout="@layout/include_horizontal_color_eee_dividing_line" />
<LinearLayout
android:layout_width="match_parent"
......@@ -61,9 +64,20 @@
android:layout_margin="@dimen/dp_8"
android:orientation="horizontal">
<CheckBox
android:id="@+id/cb_order_item_all_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_15"
android:button="@drawable/selector_checkbox"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
<LinearLayout
android:layout_width="@dimen/dp_84"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:orientation="vertical">
<ImageView
......@@ -83,7 +97,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:orientation="vertical">
......@@ -101,9 +115,16 @@
<TextView
android:id="@+id/tv_food_item_no"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="SP001" />
<ImageView
android:id="@+id/iv_order_food_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_red_delete" />
</LinearLayout>
<LinearLayout
......
......@@ -8,8 +8,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:elevation="@dimen/dp_2"
android:background="@drawable/shape_white_eight_corners_bg"
android:elevation="@dimen/dp_2"
android:orientation="vertical">
<LinearLayout
......@@ -21,11 +21,11 @@
android:orientation="horizontal">
<TextView
android:id="@+id/tv_food_item_supplier_name"
android:id="@+id/tv_purchase_order_no"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="海鮮天地"
tools:text="訂單編號"
android:textColor="@color/black"
android:textSize="@dimen/dp_17"
android:textStyle="bold" />
......@@ -68,15 +68,7 @@
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="訂單編號:" />
<TextView
android:id="@+id/tv_purchase_order_no"
style="@style/Food_Ingredient_Info_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="123456789" />
android:text="下單時間:" />
<TextView
android:id="@+id/tv_purchase_order_create_time"
......@@ -168,35 +160,45 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:gravity="right"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/btn_purchase_send"
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_38"
android:layout_height="wrap_content"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:text="發送"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/btn_purchase_buy_again"
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_38"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:background="@drawable/shape_bug_again_btn"
android:gravity="center"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:text="再次購買"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/btn_receiver_goods"
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_38"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:background="@drawable/shape_to_be_received_btn"
android:gravity="center"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:text="待收貨"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_15"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="供應商:"
android:textColor="@color/black"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_item_supplier_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="海鮮天地"
android:textColor="@color/black"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_shopping_cart_food"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_15"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_15"
android:paddingBottom="@dimen/dp_20">
<CheckBox
android:id="@+id/cb_order_item_all_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/selector_checkbox"
android:text="全選"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_25"
android:text="食材種類:"
android:textColor="@color/color_222"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_item_food_type_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/required_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold"
tools:text="3" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_25"
android:layout_weight="1"
android:gravity="right"
android:text="總計:"
android:textColor="@color/color_222"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_item_total_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/required_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold"
tools:text="$330" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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