|
|
@@ -24,6 +24,7 @@ import com.core.base.activity.BaseMVPActivity;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.SpanUtils;
|
|
|
import com.core.widget.DrawableCenterTextView;
|
|
|
+import com.core.widget.RecycleViewDivider;
|
|
|
import com.me.network.app.base.HttpCallback;
|
|
|
import com.me.network.app.base.HttpParams;
|
|
|
import com.me.network.app.http.HttpRequest;
|
|
|
@@ -50,23 +51,15 @@ import java.util.Map;
|
|
|
*/
|
|
|
|
|
|
public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter> implements View.OnClickListener, HttpCallback {
|
|
|
- private static final int OBTAIN_PURCHASE_ORDER_LIST = 0x01, OBTAIN_CUSTOMER_INQUIRY_LIST = 0x02, OBTAIN_PUBLIC_INQUIRY_LIST = 0x03;
|
|
|
+ private static final int OBTAIN_PURCHASE_ORDER_LIST = 0x01, OBTAIN_CUSTOMER_INQUIRY_LIST = 0x02, OBTAIN_PUBLIC_INQUIRY_LIST = 0x03, REQUEST_PURCHASE_DETAIL = 0x04, REQUEST_CUSTOMER_DETAIL = 0x05, REQUEST_PUBLIC_DETAIL = 0x06;
|
|
|
|
|
|
private RefreshLayout mRefreshLayout;
|
|
|
private ImageView mBackImageView;
|
|
|
private DrawableCenterTextView mCompanyNameTextView;
|
|
|
- private LinearLayout mPurchaseOrderIv;
|
|
|
- private LinearLayout mCustomerInquiryIv;
|
|
|
- private LinearLayout mPublicInquiryIv;
|
|
|
- private TextView mPurchaseOrderAllTv;
|
|
|
- private RecyclerView mPurchaseOrderRv;
|
|
|
- private TextView mCustomerInquiryAllTv;
|
|
|
- private RecyclerView mCustomerInquiryRv;
|
|
|
- private TextView mPublicInquiryAllTv;
|
|
|
- private RecyclerView mPublicInquiryRv;
|
|
|
+ private LinearLayout mPurchaseOrderIv, mCustomerInquiryIv, mPublicInquiryIv;
|
|
|
+ private TextView mPurchaseOrderAllTv, mCustomerInquiryAllTv, mPublicInquiryAllTv, mAccountSureTextView, mAccountCancelTextView;
|
|
|
+ private RecyclerView mPurchaseOrderRv, mCustomerInquiryRv, mPublicInquiryRv, mAccountRecyclerView;
|
|
|
private MaterialDialog mAccountDialog;
|
|
|
- private RecyclerView mAccountRecyclerView;
|
|
|
- private TextView mAccountSureTextView, mAccountCancelTextView;
|
|
|
|
|
|
private B2BCompanyBean mB2BCompanyBean;
|
|
|
private SpanUtils mSpanUtils;
|
|
|
@@ -75,6 +68,7 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
private List<B2BBusinessListBean> mPurchaseOrderBeans, mCustomerInquiryBeans, mPublicInquiryBeans;
|
|
|
private B2bBusinessListAdapter mPurchaseOrderAdapter, mCustomerInquiryAdapter, mPublicInquiryAdapter;
|
|
|
private boolean isPurchaseSuccess, isCustomerSuccess, isPublicSuccess;
|
|
|
+ private int mSelectPosition = -1;
|
|
|
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
@@ -118,18 +112,21 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
|
|
|
mPurchaseOrderRv.setLayoutManager(new LinearLayoutManager(mContext));
|
|
|
mPurchaseOrderRv.setNestedScrollingEnabled(false);
|
|
|
+ mPurchaseOrderRv.addItemDecoration(new RecycleViewDivider(mContext, LinearLayout.HORIZONTAL, 1, getResources().getColor(R.color.gray_light)));
|
|
|
mPurchaseOrderBeans = new ArrayList<>();
|
|
|
mPurchaseOrderAdapter = new B2bBusinessListAdapter(mContext, mPurchaseOrderBeans);
|
|
|
mPurchaseOrderRv.setAdapter(mPurchaseOrderAdapter);
|
|
|
|
|
|
mCustomerInquiryRv.setLayoutManager(new LinearLayoutManager(mContext));
|
|
|
mCustomerInquiryRv.setNestedScrollingEnabled(false);
|
|
|
+ mCustomerInquiryRv.addItemDecoration(new RecycleViewDivider(mContext, LinearLayout.HORIZONTAL, 1, getResources().getColor(R.color.gray_light)));
|
|
|
mCustomerInquiryBeans = new ArrayList<>();
|
|
|
mCustomerInquiryAdapter = new B2bBusinessListAdapter(mContext, mCustomerInquiryBeans);
|
|
|
mCustomerInquiryRv.setAdapter(mCustomerInquiryAdapter);
|
|
|
|
|
|
mPublicInquiryRv.setLayoutManager(new LinearLayoutManager(mContext));
|
|
|
mPublicInquiryRv.setNestedScrollingEnabled(false);
|
|
|
+ mPublicInquiryRv.addItemDecoration(new RecycleViewDivider(mContext, LinearLayout.HORIZONTAL, 1, getResources().getColor(R.color.gray_light)));
|
|
|
mPublicInquiryBeans = new ArrayList<>();
|
|
|
mPublicInquiryAdapter = new B2bBusinessListAdapter(mContext, mPublicInquiryBeans);
|
|
|
mPublicInquiryRv.setAdapter(mPublicInquiryAdapter);
|
|
|
@@ -174,35 +171,86 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
mPurchaseOrderAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
|
|
|
+ mSelectPosition = i;
|
|
|
Intent intent = new Intent();
|
|
|
intent.setClass(mContext, PurchaseDetailsActivity.class);
|
|
|
intent.putExtra(Constants.FLAG.KEY_PURCHASE_ID, mPurchaseOrderBeans.get(i).getId());
|
|
|
intent.putExtra(Constants.FLAG.KEY_PURCHASE_STATUS, mPurchaseOrderBeans.get(i).getBillState());
|
|
|
- startActivity(intent);
|
|
|
+ startActivityForResult(intent, REQUEST_PURCHASE_DETAIL);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
mCustomerInquiryAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
|
|
|
+ mSelectPosition = i;
|
|
|
Intent intent = new Intent();
|
|
|
intent.setClass(mContext, CustomerInquiryDetailActivity.class);
|
|
|
intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_ID, mCustomerInquiryBeans.get(i).getId());
|
|
|
intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_STATE, mCustomerInquiryBeans.get(i).getBillState());
|
|
|
intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_JSON, mCustomerInquiryBeans.get(i).getJsonData());
|
|
|
- startActivity(intent);
|
|
|
+ startActivityForResult(intent, REQUEST_CUSTOMER_DETAIL);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
mPublicInquiryAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
@Override
|
|
|
- public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
|
|
|
+ public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, final int position) {
|
|
|
Intent intent = new Intent();
|
|
|
- intent.setClass(mContext, PublicInquiryDetailActivity.class);
|
|
|
- intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_ID, mPublicInquiryBeans.get(i).getId());
|
|
|
- intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_STATE, mPublicInquiryBeans.get(i).getBillState());
|
|
|
- intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_JSON, mPublicInquiryBeans.get(i).getJsonData());
|
|
|
- startActivity(intent);
|
|
|
+ String billState = mPublicInquiryBeans.get(position).getBillState();
|
|
|
+ if (Constants.FLAG.STATE_PUBLIC_INQUIRY_DONE.equals(billState)) {
|
|
|
+ intent.setClass(mContext, PublicInquiryDetailActivity.class);
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_ID, mPublicInquiryBeans.get(position).getId());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_STATE, mPublicInquiryBeans.get(position).getBillState());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_JSON, mPublicInquiryBeans.get(position).getJsonData());
|
|
|
+ startActivity(intent);
|
|
|
+ } else if (Constants.FLAG.STATE_PUBLIC_INQUIRY_TODO.equals(billState)) {
|
|
|
+ showLoading(null);
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ // params.put("en_uu", mEnuu);
|
|
|
+ params.put("en_uu", 10041559);
|
|
|
+ // params.put("user_tel", MyApplication.getInstance().mLoginUser.getTelephone());
|
|
|
+ params.put("user_tel", "15671616315");
|
|
|
+ params.put("id", mPublicInquiryBeans.get(position).getId());
|
|
|
+
|
|
|
+ HttpRequest.getInstance().sendRequest("http://218.17.158.219:24000/",
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url("inquiry/sale/quote")
|
|
|
+ .method(Method.GET)
|
|
|
+ .setHeaders(new HashMap<String, Object>())
|
|
|
+ .setParams(params)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ hideLoading();
|
|
|
+ Intent intent = null;
|
|
|
+ String result = o.toString();
|
|
|
+ if (TextUtils.isEmpty(result)) {
|
|
|
+// mSelectPosition = position;
|
|
|
+ intent = new Intent();
|
|
|
+ intent.setClass(mContext, CustomerInquiryDetailActivity.class);
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_ID, mPublicInquiryBeans.get(position).getId());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_STATE, mPublicInquiryBeans.get(position).getBillState());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_JSON, mPublicInquiryBeans.get(position).getJsonData());
|
|
|
+ startActivityForResult(intent, REQUEST_PUBLIC_DETAIL);
|
|
|
+ } else {
|
|
|
+ intent = new Intent();
|
|
|
+ intent.setClass(mContext, PublicInquiryDetailActivity.class);
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_ID, mPublicInquiryBeans.get(position).getId());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_STATE, mPublicInquiryBeans.get(position).getBillState());
|
|
|
+ intent.putExtra(Constants.FLAG.EXTRA_B2B_LIST_JSON, mPublicInquiryBeans.get(position).getJsonData());
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ hideLoading();
|
|
|
+ toast(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -229,6 +277,7 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
}
|
|
|
|
|
|
private void getListData(int flag) {
|
|
|
+ String host = "http://192.168.253.102:8090/platform-b2b/";
|
|
|
String url = "";
|
|
|
switch (flag) {
|
|
|
case OBTAIN_PURCHASE_ORDER_LIST:
|
|
|
@@ -238,7 +287,8 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
url = "mobile/sale/inquiry/info/search";
|
|
|
break;
|
|
|
case OBTAIN_PUBLIC_INQUIRY_LIST:
|
|
|
- url = "mobile/purc/inquiry/publicInquiryItem";
|
|
|
+ host = "http://218.17.158.219:24000/";
|
|
|
+ url = "inquiry/public/mobile";
|
|
|
break;
|
|
|
}
|
|
|
showLoading(null);
|
|
|
@@ -252,7 +302,7 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
params.put("page", 1);
|
|
|
params.put("size", 3);
|
|
|
|
|
|
- HttpRequest.getInstance().sendRequest("http://192.168.253.102:8090/platform-b2b/",
|
|
|
+ HttpRequest.getInstance().sendRequest(host,
|
|
|
new HttpParams.Builder()
|
|
|
.url(url)
|
|
|
.flag(flag)
|
|
|
@@ -277,6 +327,32 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (requestCode == REQUEST_PURCHASE_DETAIL
|
|
|
+ && resultCode == Constants.FLAG.RESULT_PURCHASE_ORDER && data != null) {
|
|
|
+ String purchaseStatus = data.getStringExtra(Constants.FLAG.KEY_PURCHASE_STATUS);
|
|
|
+ B2BBusinessListBean b2BBusinessListBean = mPurchaseOrderBeans.get(mSelectPosition);
|
|
|
+ if (b2BBusinessListBean != null) {
|
|
|
+ b2BBusinessListBean.setBillState(purchaseStatus);
|
|
|
+ mPurchaseOrderAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else if (requestCode == REQUEST_CUSTOMER_DETAIL
|
|
|
+ && resultCode == Constants.FLAG.RESULT_CUSTOMER_INQUIRY) {
|
|
|
+ B2BBusinessListBean b2BBusinessListBean = mCustomerInquiryBeans.get(mSelectPosition);
|
|
|
+ if (b2BBusinessListBean != null) {
|
|
|
+ b2BBusinessListBean.setBillState(Constants.FLAG.STATE_CUSTOMER_INQUIRY_DONE);
|
|
|
+ }
|
|
|
+ } else if (requestCode == REQUEST_PUBLIC_DETAIL
|
|
|
+ && resultCode == Constants.FLAG.RESULT_PUBLIC_INQUIRY) {
|
|
|
+ /*B2BBusinessListBean b2BBusinessListBean = mPublicInquiryBeans.get(mSelectPosition);
|
|
|
+ if (b2BBusinessListBean != null) {
|
|
|
+ b2BBusinessListBean.setBillState(Constants.FLAG.STATE_PUBLIC_INQUIRY_DONE);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) {
|
|
|
try {
|
|
|
@@ -322,6 +398,7 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
return;
|
|
|
}
|
|
|
mPublicInquiryBeans.clear();
|
|
|
+ analisisPublicInquiry(contentArray);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -332,6 +409,53 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void analisisPublicInquiry(JSONArray contentArray) {
|
|
|
+ for (int i = 0; i < contentArray.size(); i++) {
|
|
|
+ JSONObject contentObject = contentArray.getJSONObject(i);
|
|
|
+ if (contentObject != null) {
|
|
|
+ B2BBusinessListBean b2BBusinessListBean = new B2BBusinessListBean();
|
|
|
+ b2BBusinessListBean.setJsonData(contentObject.toString());
|
|
|
+ b2BBusinessListBean.setItemType(B2BBusinessListBean.PUBLIC_INQUIRY_LIST);
|
|
|
+ b2BBusinessListBean.setId(JSONUtil.getText(contentObject, "id"));
|
|
|
+
|
|
|
+ long date = contentObject.getLongValue("date");
|
|
|
+ if (date != 0) {
|
|
|
+ b2BBusinessListBean.setBillDate(DateFormatUtil.long2Str(date, DateFormatUtil.YMD));
|
|
|
+ }
|
|
|
+ JSONObject inquiryObject = contentObject.getJSONObject("inquiry");
|
|
|
+ JSONObject productObject = contentObject.getJSONObject("product");
|
|
|
+
|
|
|
+ if (productObject != null) {
|
|
|
+ b2BBusinessListBean.setProductName(JSONUtil.getText(productObject, "title"));
|
|
|
+ b2BBusinessListBean.setProductModel(JSONUtil.getText(productObject, "code"));
|
|
|
+ b2BBusinessListBean.setProductSpecification(JSONUtil.getText(productObject, "spec"));
|
|
|
+ b2BBusinessListBean.setProductBrand(JSONUtil.getText(productObject, "brand"));
|
|
|
+ }
|
|
|
+ if (inquiryObject != null) {
|
|
|
+ JSONObject enterpriseObject = inquiryObject.getJSONObject("enterprise");
|
|
|
+ if (enterpriseObject != null) {
|
|
|
+ b2BBusinessListBean.setCompanyName(JSONUtil.getText(enterpriseObject, "enName"));
|
|
|
+ }
|
|
|
+
|
|
|
+ long endDate = inquiryObject.getLongValue("endDate");
|
|
|
+ if (endDate != 0) {
|
|
|
+ b2BBusinessListBean.setExpiryDate(DateFormatUtil.long2Str(endDate, DateFormatUtil.YMD));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String invalid = JSONUtil.getText(contentObject, "invalid");
|
|
|
+ String overdue = JSONUtil.getText(contentObject, "overdue");
|
|
|
+ String status = JSONUtil.getText(contentObject, "status");
|
|
|
+ if ("1".equals(invalid) || "1".equals(overdue) || "201".equals(status)) {
|
|
|
+ b2BBusinessListBean.setBillState(Constants.FLAG.STATE_PUBLIC_INQUIRY_DONE);
|
|
|
+ } else {
|
|
|
+ b2BBusinessListBean.setBillState(Constants.FLAG.STATE_PUBLIC_INQUIRY_TODO);
|
|
|
+ }
|
|
|
+ mPublicInquiryBeans.add(b2BBusinessListBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mPublicInquiryAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
private void analysisCustomerInquiry(JSONArray contentArray) {
|
|
|
for (int i = 0; i < contentArray.size(); i++) {
|
|
|
JSONObject contentObject = contentArray.getJSONObject(i);
|
|
|
@@ -342,19 +466,22 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
b2BBusinessListBean.setId(JSONUtil.getText(contentObject, "id"));
|
|
|
|
|
|
JSONObject inquiryObject = contentObject.getJSONObject("inquiry");
|
|
|
+ JSONObject productObject = contentObject.getJSONObject("product");
|
|
|
if (inquiryObject != null) {
|
|
|
JSONObject enterpriseObject = inquiryObject.getJSONObject("enterprise");
|
|
|
if (enterpriseObject != null) {
|
|
|
b2BBusinessListBean.setCompanyName(JSONUtil.getText(enterpriseObject, "enName"));
|
|
|
}
|
|
|
- b2BBusinessListBean.setMaterialNum(JSONUtil.getText(inquiryObject, "code"));
|
|
|
- b2BBusinessListBean.setBillNum(JSONUtil.getText(inquiryObject, "id"));
|
|
|
+ b2BBusinessListBean.setBillNum(JSONUtil.getText(inquiryObject, "code"));
|
|
|
|
|
|
long endDate = inquiryObject.getLongValue("endDate");
|
|
|
if (endDate != 0) {
|
|
|
b2BBusinessListBean.setExpiryDate(DateFormatUtil.long2Str(endDate, DateFormatUtil.YMD));
|
|
|
}
|
|
|
}
|
|
|
+ if (productObject != null) {
|
|
|
+ b2BBusinessListBean.setMaterialNum(JSONUtil.getText(productObject, "code"));
|
|
|
+ }
|
|
|
long date = contentObject.getLongValue("date");
|
|
|
if (date != 0) {
|
|
|
b2BBusinessListBean.setBillDate(DateFormatUtil.long2Str(date, DateFormatUtil.YMD));
|
|
|
@@ -398,7 +525,11 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
b2BBusinessListBean.setJsonData(contentObject.toString());
|
|
|
b2BBusinessListBean.setItemType(B2BBusinessListBean.PURCHASE_ORDER_LIST);
|
|
|
b2BBusinessListBean.setId(JSONUtil.getText(contentObject, "id"));
|
|
|
- b2BBusinessListBean.setCompanyName(JSONUtil.getText(contentObject, "receiveName"));
|
|
|
+
|
|
|
+ JSONObject enterprise = contentObject.getJSONObject("enterprise");
|
|
|
+ if (enterprise != null) {
|
|
|
+ b2BBusinessListBean.setCompanyName(JSONUtil.getText(enterprise, "enName"));
|
|
|
+ }
|
|
|
|
|
|
long date = contentObject.getLongValue("date");
|
|
|
if (date != 0) {
|
|
|
@@ -523,6 +654,14 @@ public class B2BBusinessMainActivity extends BaseMVPActivity<WorkPlatPresenter>
|
|
|
if (mB2BCompanyBeans == null || mB2BCompanyBeans.size() == 0) {
|
|
|
toast("您的账号未绑定任何B2B账套");
|
|
|
} else {
|
|
|
+ for (B2BCompanyBean b2BCompanyBean : mB2BCompanyBeans) {
|
|
|
+ String enuu = b2BCompanyBean.getEnuu();
|
|
|
+ if (enuu != null && enuu.equals(mB2BCompanyBean.getEnuu())) {
|
|
|
+ b2BCompanyBean.setSelected(true);
|
|
|
+ } else {
|
|
|
+ b2BCompanyBean.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
mB2BAccountAdapter.notifyDataSetChanged();
|
|
|
mAccountDialog.show();
|
|
|
}
|