新增cash储值分期支付
This commit is contained in:
25
app/src/main/java/com/dskj/rbchat/model/InstallmentBean.java
Normal file
25
app/src/main/java/com/dskj/rbchat/model/InstallmentBean.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.dskj.rbchat.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class InstallmentBean implements Serializable {
|
||||
|
||||
private int periodCount;
|
||||
private int amount;
|
||||
|
||||
public int getPeriodCount() {
|
||||
return periodCount;
|
||||
}
|
||||
|
||||
public void setPeriodCount(int periodCount) {
|
||||
this.periodCount = periodCount;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.dskj.rbchat.model.FukuanResultBean;
|
||||
import com.dskj.rbchat.model.GameBean;
|
||||
import com.dskj.rbchat.model.GroupActionBean;
|
||||
import com.dskj.rbchat.model.GroupBeanResult;
|
||||
import com.dskj.rbchat.model.InstallmentBean;
|
||||
import com.dskj.rbchat.model.InviteDetailsBean;
|
||||
import com.dskj.rbchat.model.LinkBean;
|
||||
import com.dskj.rbchat.model.ListBeanResult;
|
||||
@@ -999,6 +1000,19 @@ public interface ApiService {
|
||||
@GET("/config/list")
|
||||
Observable<Result<List<ConfigBean>>> getConfig();
|
||||
|
||||
/**
|
||||
* 獲取分期費率
|
||||
*/
|
||||
@POST("/payment/zero_card/get_fee")
|
||||
Observable<Result<List<InstallmentBean>>> getFee(@Body Map<String, Object> param);
|
||||
|
||||
|
||||
/**
|
||||
* 零卡分期請求
|
||||
*/
|
||||
@POST("/payment/sendOrder/zero_card")
|
||||
Observable<Result<String>> payInstallment(@Body Map<String, Object> requestBody);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dskj.rbchat.wallet;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -9,7 +9,6 @@ import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -20,24 +19,21 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.dskj.rbchat.IMUIKitConfig;
|
||||
import com.dskj.rbchat.R;
|
||||
import com.dskj.rbchat.adapter.CommonAdapter;
|
||||
import com.dskj.rbchat.adapter.ViewHolder;
|
||||
import com.dskj.rbchat.databinding.ActivityTopupBinding;
|
||||
import com.dskj.rbchat.databinding.ActivityWalletInfoBinding;
|
||||
import com.dskj.rbchat.dialog.ActionConfirmDialog;
|
||||
import com.dskj.rbchat.login.PhoneLoginActivity;
|
||||
import com.dskj.rbchat.main.mine.ChangeAccoutActionActivity;
|
||||
import com.dskj.rbchat.model.BindBean;
|
||||
import com.dskj.rbchat.model.ExchangeConfBean;
|
||||
import com.dskj.rbchat.model.InstallmentBean;
|
||||
import com.dskj.rbchat.model.SendOrderBean;
|
||||
import com.dskj.rbchat.model.WalletBean;
|
||||
import com.dskj.rbchat.network.Api;
|
||||
import com.dskj.rbchat.network.BaseObserver;
|
||||
import com.dskj.rbchat.network.Result;
|
||||
import com.dskj.rbchat.pay.LipinDuiHuanActivity;
|
||||
import com.dskj.rbchat.utils.AnimUtil;
|
||||
import com.dskj.rbchat.utils.AppUtils;
|
||||
import com.dskj.rbchat.utils.GsonUtils;
|
||||
@@ -61,8 +57,12 @@ public class TopUpActivity extends BaseActivity {
|
||||
WalletBean walletBean;
|
||||
BindBean bindBean;
|
||||
private List<ExchangeConfBean.AmountItemsDTO> globalAmountList = new ArrayList<>();
|
||||
private List<InstallmentBean> installmentBeans = new ArrayList<>();
|
||||
CommonAdapter commonAdapter;
|
||||
CommonAdapter installmentAdapter;
|
||||
int defaultIndex = 0;
|
||||
private boolean isFenqi = false;
|
||||
private int installmentNum; //分期數
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -73,9 +73,30 @@ public class TopUpActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityTopupBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
setSelector(false);
|
||||
setFenqiView(false);
|
||||
initView();
|
||||
bindInfo();
|
||||
getConf();
|
||||
|
||||
}
|
||||
|
||||
public void setFenqiView(boolean show) {
|
||||
viewBinding.lineInstall.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
viewBinding.tvPaytypeFenqi.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
viewBinding.recyclerInstallment.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void setSelector(boolean fenqi) {
|
||||
isFenqi = fenqi;
|
||||
if (fenqi) {
|
||||
viewBinding.tvPaytypeCard.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.dialog_gou_ff), null);
|
||||
viewBinding.tvPaytypeFenqi.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.ic_single_selected), null);
|
||||
} else {
|
||||
viewBinding.tvPaytypeCard.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.ic_single_selected), null);
|
||||
viewBinding.tvPaytypeFenqi.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.dialog_gou_ff), null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,14 +124,120 @@ public class TopUpActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getFee() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("amount", defaultIndex);
|
||||
Api.getInstance().getFee(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<List<InstallmentBean>> feedbackResp) {
|
||||
LogUtils.i("获取到的数据:" + feedbackResp.data);
|
||||
installmentBeans.clear();
|
||||
if (feedbackResp.data != null && feedbackResp.data.size() > 0) {
|
||||
installmentBeans.addAll(feedbackResp.data);
|
||||
installmentNum = 0;
|
||||
}
|
||||
installmentAdapter.notifyDataSetChanged();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void payInstallment(int installment) {
|
||||
if (exchangeConfBean != null) {
|
||||
if ((defaultIndex < exchangeConfBean.getMinAmount()) || (defaultIndex > exchangeConfBean.getMaxAmount())) {
|
||||
ToastUtils.showShort(String.format(getString(R.string.taixiao_topup_txt), exchangeConfBean.getMinAmount() / exchangeConfBean.getExchangeRatio(), exchangeConfBean.getMaxAmount() / exchangeConfBean.getExchangeRatio()));
|
||||
return;
|
||||
}
|
||||
Map<String, Object> maps = new HashMap<>();
|
||||
maps.put("amount", defaultIndex);
|
||||
maps.put("type", 5);
|
||||
maps.put("installment", installment);
|
||||
Api.getInstance().payInstallment(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<String> feedbackResp) {
|
||||
LogUtils.i("获取到的数据:" + feedbackResp.data);
|
||||
if (!TextUtils.isEmpty(feedbackResp.data)) {
|
||||
// String packageName = "com.chailease.tw.app.android.ccfappcust.uat"; // 目标应用的包名
|
||||
// PackageManager packageManager = getPackageManager();
|
||||
// Intent intent = new Intent();
|
||||
// intent = packageManager.getLaunchIntentForPackage(packageName);
|
||||
// intent.setData(Uri.parse(feedbackResp.data));
|
||||
// if (intent == null) {
|
||||
// ToastUtils.showShort("请安装银角零卡APP");
|
||||
// } else {
|
||||
// startActivity(intent);
|
||||
// }
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(feedbackResp.data));
|
||||
startActivity(intent);
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(feedbackResp.data));
|
||||
// startActivity(intent);
|
||||
// BrowseActivity.Companion.launch(
|
||||
// TopUpActivity.this, getString(R.string.cash_cuzhi_txt), feedbackResp.data);
|
||||
// startActivity(new Intent(TopUpActivity.this, PayWebActivity.class).putExtra("url", feedbackResp.data));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void initView() {
|
||||
Drawable drawable = viewBinding.contactListActivityTitleBar.getBackImageView().getDrawable().mutate();//
|
||||
Drawable drawable = viewBinding.titlebar.getBackImageView().getDrawable().mutate();//
|
||||
Drawable wrap = DrawableCompat.wrap(drawable);
|
||||
DrawableCompat.setTint(wrap, ContextCompat.getColor(this, R.color.color_d4ab90));
|
||||
viewBinding.contactListActivityTitleBar.getBackImageView().setImageDrawable(wrap);
|
||||
viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
viewBinding.titlebar.getBackImageView().setImageDrawable(wrap);
|
||||
viewBinding.titlebar.getBackImageView().setOnClickListener(v -> finish());
|
||||
iniAdapter();
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(TopUpActivity.this);
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
viewBinding.recyclerInstallment.setLayoutManager(linearLayoutManager);
|
||||
installmentAdapter = new CommonAdapter<InstallmentBean>(TopUpActivity.this, R.layout.item_bill_installment, installmentBeans) {
|
||||
@Override
|
||||
public void convert(ViewHolder holder, InstallmentBean s, int index) {
|
||||
TextView titleTv = holder.getView(R.id.title_tv);
|
||||
TextView desTv = holder.getView(R.id.des_tv);
|
||||
titleTv.setText(getString(R.string.str_qi, s.getPeriodCount()));
|
||||
desTv.setText(getString(R.string.str_installment_tips, s.getAmount()));
|
||||
LinearLayout big_bg = holder.getView(R.id.big_bg);
|
||||
if (s.getPeriodCount() == installmentNum) {
|
||||
titleTv.setTextColor(Color.parseColor("#654C35"));
|
||||
desTv.setTextColor(Color.parseColor("#654C35"));
|
||||
big_bg.setBackgroundResource(R.drawable.logout_btn_main2);
|
||||
} else {
|
||||
titleTv.setTextColor(getColor(R.color.color_333333));
|
||||
desTv.setTextColor(getColor(R.color.color_333333));
|
||||
big_bg.setBackgroundResource(R.drawable.input_bg_t);
|
||||
}
|
||||
|
||||
big_bg.setOnClickListener(v -> {
|
||||
installmentNum = s.getPeriodCount();
|
||||
notifyDataSetChanged();
|
||||
viewBinding.tvCashvalue.setText("NT$:" + (defaultIndex + s.getAmount()));
|
||||
setSelector(true);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
viewBinding.recyclerInstallment.setAdapter(installmentAdapter);
|
||||
viewBinding.editQueryEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
@@ -145,16 +272,40 @@ public class TopUpActivity extends BaseActivity {
|
||||
} else if (!bindBean.getPayPasswordSet()) {
|
||||
showDialogPay();
|
||||
} else {
|
||||
sumbit();
|
||||
if (isFenqi) {
|
||||
if (installmentNum == 0) {
|
||||
ToastUtils.showShort(getString(R.string.str_installment_toast));
|
||||
return;
|
||||
}
|
||||
payInstallment(installmentNum);
|
||||
} else {
|
||||
sumbit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
viewBinding.tvPaytypeCard.setOnClickListener(v -> {
|
||||
setSelector(false);
|
||||
});
|
||||
viewBinding.tvPaytypeFenqi.setOnClickListener(v -> {
|
||||
setSelector(true);
|
||||
if (defaultIndex > 0) {
|
||||
getFee();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showBottomType() {
|
||||
viewBinding.tvCashvalue.setText("NT$:" + defaultIndex);
|
||||
setFenqiView(false);
|
||||
if (defaultIndex >= 1000) {
|
||||
setFenqiView(true);
|
||||
getFee();
|
||||
}
|
||||
|
||||
// if (exchangeConfBean != null) {
|
||||
// if(TextUtils.isEmpty(viewBinding.editQueryEt.getText().toString().trim())){
|
||||
// viewBinding.showZidingyiLy.setVisibility(View.GONE);
|
||||
@@ -250,6 +401,7 @@ public class TopUpActivity extends BaseActivity {
|
||||
viewBinding.editQueryEt.clearFocus();
|
||||
notifyDataSetChanged();
|
||||
showBottomType();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user