提交 3d3081fb authored 作者: lgd's avatar lgd

1.修改通用购物车检查数量

上级 f0f366bc
......@@ -170,6 +170,15 @@ public class ProductBean {
private double outerPrice;
private double quantity;
private double innerPrice;
private int flag;// 0 未超出,1 超出预警值
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public double getInnerPrice() {
return innerPrice;
......
......@@ -1991,4 +1991,13 @@ public interface ApiService {
@PUT("/returnApply/po/audit/group/{applyId}")
Observable<BaseBean> endPoCheck(@Path("applyId") String applyId,@Body RequestBody requestBody);
/**
* 下单或审核前预检(产品列表)安全库存数量是否超出
*
* @return
*/
@POST("/stock-quantity/dept-product/startOrderProductsCountCheck")
Observable<BaseBean> proNumCheck(@Body RequestBody requestBody);
}
......@@ -718,6 +718,10 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
toast("请填写销售单价");
return;
}
if (TextUtils.equals(num.getNumber(), "0")) {
toast("请选择数量");
return;
}
addCart(data, num.getNumber(), etPrice.getText().toString());
addCartDialog.dismiss();
}
......
......@@ -6,17 +6,24 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.StockBean;
import com.wd.workoffice.bean.event.ModifyCarEvent;
import com.wd.workoffice.bean.workEnum.PermissionType;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.ui.adapter.StoreCarAdapter;
import com.wd.workoffice.util.DialogUtils;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.UserKeeper;
import com.wd.workoffice.util.WorkUtils;
import org.greenrobot.eventbus.EventBus;
......@@ -24,13 +31,17 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import io.reactivex.disposables.Disposable;
/**
* 商店-销售-购物车
......@@ -52,6 +63,7 @@ public class StoreSaleCarActivity extends WorkToolBarActivity {
RecyclerView rvProduct;
private List<ProductBean.RecordsBean> productList;
private StoreCarAdapter productAdapter;
private int warningFlag;
@Override
protected void initView() {
......@@ -107,7 +119,7 @@ public class StoreSaleCarActivity extends WorkToolBarActivity {
public void onViewClicked() {
String allPrice = "";
for (ProductBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum() , MathUtils.converData(recordsBean.getInternalPrice(),3) , 3), 3);
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum(), MathUtils.converData(recordsBean.getInternalPrice(), 3), 3), 3);
}
if (productList.size() == 0) {
toast("购物车里没有产品哦");
......@@ -119,7 +131,7 @@ public class StoreSaleCarActivity extends WorkToolBarActivity {
"subProcessId", getIntent().getStringExtra("subProcessId"),
"inStockId", getIntent().getStringExtra("inStockId"),
"intoStore", getIntent().getStringExtra("intoStore"),
"outerStore",getIntent().getStringExtra("outerStore"),
"outerStore", getIntent().getStringExtra("outerStore"),
"customerId", getIntent().getStringExtra("customerId"),
"receiveDeptId", getIntent().getStringExtra("receiveDeptId"),
"code", getIntent().getStringExtra("code"),
......@@ -147,8 +159,64 @@ public class StoreSaleCarActivity extends WorkToolBarActivity {
tvNum.setText("共 ".concat(productList.size() + "").concat(" 件"));
String allPrice = "";
for (ProductBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum(), MathUtils.converData(recordsBean.getInternalPrice(),3), 3), 3);
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum(), MathUtils.converData(recordsBean.getInternalPrice(), 3), 3), 3);
}
tvPrice.setText("总计: ¥ ".concat(allPrice));
checkNum();
}
/**
* 检查库存预警
*/
private void checkNum() {
Map<String, Object> param = new HashMap<>();
param.put("launchDeptId", UserKeeper.getInstance().getUserDepId());
List<JSONObject> proList = new ArrayList<>();
for (ProductBean.RecordsBean proBean : productList) {
JSONObject data = new JSONObject();
data.put("productId", proBean.getId());
data.put("productCount", proBean.getCarNum());
proList.add(data);
}
param.put("basalOrderItems", proList);
RtfUtils.getRtf().proNumCheck(WorkUtils.convertMapToBody(param)).compose(Transformer.schedule()).subscribe(new WorkObserver<BaseBean>() {
@Override
public void doOnSubscribe(Disposable d) {
}
@Override
public void onFail(String errorMsg) {
hideLoading();
toast(errorMsg);
}
@Override
public void onSuccess(BaseBean data) {
hideLoading();
if (data.getCode() != 0) {
toast(data.getMessage());
return;
}
JSONArray warningList = JSON.parseArray(data.getData().toString());
for (ProductBean.RecordsBean pro : productList) {
pro.setFlag(0);
}
if (warningList.size() > 0) {
warningFlag = 1;
for (int i = 0; i < warningList.size(); i++) {
JSONObject proWarning = warningList.getJSONObject(i);
Integer productId = proWarning.getInteger("productId");
for (ProductBean.RecordsBean pro : productList) {
if (pro.getId() == productId) {
pro.setFlag(1);
}
}
}
} else {
warningFlag = 0;
}
productAdapter.notifyDataSetChanged();
}
});
}
}
......@@ -48,6 +48,7 @@ public class StoreCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, B
helper.setText(R.id.tv_price, "¥".concat(MathUtils.converData(item.getInternalPrice(),3)));
helper.setText(R.id.tv_unit, MathUtils.converData(item.getWeight(),3).concat("吨"));
helper.setText(R.id.tv_all_price, MathUtils.multiply(item.getCarNum(), MathUtils.converData(item.getInternalPrice(),3), 3));
helper.setGone(R.id.tv_desc, item.getFlag()==1);
if (type == 1) {
helper.addOnClickListener(R.id.rl_choose_dep);
helper.addOnClickListener(R.id.rl_upload);
......@@ -63,9 +64,11 @@ public class StoreCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, B
num.setOnNumberChangedListener(new AddAndReduceView.OnNumberChangedListener() {
@Override
public void OnNumberChanged(String vs) {
item.setCarNum(vs);
helper.setText(R.id.tv_all_price, MathUtils.multiply(vs , MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
if (!TextUtils.equals(vs,item.getCarNum())){
item.setCarNum(vs);
helper.setText(R.id.tv_all_price, MathUtils.multiply(vs , MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
}
}
});
EditText etPrice = helper.getView(R.id.et_price);
......@@ -77,9 +80,11 @@ public class StoreCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, B
num.setOnNumberChangedListener(new AddAndReduceView.OnNumberChangedListener() {
@Override
public void OnNumberChanged(String vs) {
item.setCarNum(vs);
helper.setText(R.id.tv_all_price, MathUtils.multiply(vs, MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
if (!TextUtils.equals(vs,item.getCarNum())){
item.setCarNum(vs);
helper.setText(R.id.tv_all_price, MathUtils.multiply(vs , MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
}
}
});
EditText etPrice = helper.getView(R.id.et_price);
......@@ -102,9 +107,11 @@ public class StoreCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, B
ToastUtil.showShort("请输入销售单价");
return;
}
item.setCarPrice(s.toString());
helper.setText(R.id.tv_all_price, MathUtils.multiply(item.getCarNum(), MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
if (!TextUtils.equals(s.toString(),item.getCarPrice())){
item.setCarPrice(s.toString());
helper.setText(R.id.tv_all_price, MathUtils.multiply(item.getCarNum(), MathUtils.converData(item.getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
}
}
});
num.setNumber(item.getCarNum());
......
......@@ -209,24 +209,40 @@
android:layout_marginLeft="10mm" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="30mm">
<TextView
android:id="@+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小计: ¥ "
android:text="下单数量超出预警值"
android:visibility="gone"
android:textColor="@color/red"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_all_price"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2300.00"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
android:layout_alignParentRight="true"
android:layout_gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小计: ¥ "
android:textSize="12sp" />
<TextView
android:id="@+id/tv_all_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2300.00"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论