Kaynağa Gözat

2024-2-28 代码备份
银行卡提现功能开发完成

zhangbing 2 yıl önce
ebeveyn
işleme
04ef6eaa1c

+ 63 - 22
app/src/main/java/com/yihucha/hbyhc/presentation/invitation/ImmediateWithdrawalActivity.java

@@ -28,11 +28,14 @@ import com.yihucha.hbyhc.base.WebViewTitleBaseActivity;
28 28
 import com.yihucha.hbyhc.config.Constants;
29 29
 import com.yihucha.hbyhc.databinding.ActivityImmediateWithdrawalBinding;
30 30
 import com.yihucha.hbyhc.presentation.annuity.RealNameAuthenticationActivity;
31
+import com.yihucha.hbyhc.presentation.apply_channel.model.UserInvitationCodeBean;
31 32
 import com.yihucha.hbyhc.presentation.invitation.model.BankCardBean;
32 33
 import com.yihucha.hbyhc.presentation.invitation.model.SpreadInfoBean;
33 34
 import com.yihucha.hbyhc.presentation.invitation.model.WithdrawalConfigurationBean;
34 35
 import com.yihucha.hbyhc.presentation.invitation.model.WithdrawalServiceBean;
35 36
 import com.yihucha.hbyhc.presentation.invitation.view_model.InviteViewModel;
37
+import com.yihucha.hbyhc.presentation.login.LoginActivity;
38
+import com.yihucha.hbyhc.presentation.login.view_model.LoginViewModel;
36 39
 import com.yihucha.hbyhc.presentation.mine.model.BindingStateBean;
37 40
 import com.yihucha.hbyhc.presentation.mine.model.UpdateAccountBean;
38 41
 import com.yihucha.hbyhc.presentation.mine.model.UserAnnuityInfoBean;
@@ -42,9 +45,11 @@ import com.yihucha.hbyhc.presentation.mine.view_model.MineSpreadInfo;
42 45
 import com.yihucha.hbyhc.presentation.mine.view_model.MineViewModel;
43 46
 import com.yihucha.hbyhc.utils.EmptyCheckUtils;
44 47
 import com.yihucha.hbyhc.utils.LogUtil;
48
+import com.yihucha.hbyhc.utils.MVUtils;
45 49
 import com.yihucha.hbyhc.utils.StringsUtil;
46 50
 import com.yihucha.hbyhc.view.MyToast;
47 51
 import com.tencent.mm.opensdk.modelmsg.SendAuth;
52
+import com.yihucha.hbyhc.view.SmsCodeDialog;
48 53
 
49 54
 import org.greenrobot.eventbus.EventBus;
50 55
 import org.greenrobot.eventbus.Subscribe;
@@ -60,7 +65,7 @@ import java.util.Map;
60 65
  * @date 2022/8/2
61 66
  * note:立即提现
62 67
  */
63
-public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<ActivityImmediateWithdrawalBinding> implements View.OnClickListener {
68
+public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<ActivityImmediateWithdrawalBinding> implements View.OnClickListener, SmsCodeDialog.DialogCallBack {
64 69
     private InviteViewModel mInviteViewModel;
65 70
     private String is_certification;//是否实名认证:1是
66 71
     private String mBrokeragePrice;//可提现
@@ -77,6 +82,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
77 82
     private BindingStateBViewModel mBindingStateBViewModel;
78 83
     private MineViewModel mineViewModel;
79 84
     private MineSpreadInfo mineSpreadInfo;//用户信息数据
85
+    private SmsCodeDialog smsCodeDialog;
80 86
     @SuppressLint("HandlerLeak")
81 87
     private Handler mHandler = new Handler() {
82 88
         @SuppressWarnings("unused")
@@ -126,7 +132,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
126 132
             }
127 133
         }
128 134
     };
129
-
135
+    private LoginViewModel loginViewModel;
130 136
 
131 137
 
132 138
     @Override
@@ -134,6 +140,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
134 140
         super.onCreate(savedInstanceState);
135 141
         mInviteViewModel = new ViewModelProvider(this).get(InviteViewModel.class);
136 142
         mineViewModel = new ViewModelProvider(this).get(MineViewModel.class);
143
+        loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
137 144
         mBindingStateBViewModel = new ViewModelProvider(this).get(BindingStateBViewModel.class);
138 145
         Bundle data = getIntent().getBundleExtra("data");
139 146
         //保持提现页面一致,暂时隐藏该部分
@@ -147,9 +154,12 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
147 154
 
148 155
     @SuppressLint("SetTextI18n")
149 156
     private void initData() {
157
+        String phone = MVUtils.getString(Constants.PHONE);
158
+        smsCodeDialog = new SmsCodeDialog(ImmediateWithdrawalActivity.this,
159
+                phone, this);
160
+        loginViewModel.mPhone.postValue(phone);
150 161
         //佣金信息
151
-        mInviteViewModel.getSpreadInfo();
152
-        mInviteViewModel.mSpreadInfoData.observe(this, spreadInfoBean -> {
162
+       /* mInviteViewModel.mSpreadInfoData.observe(this, spreadInfoBean -> {
153 163
             mBrokeragePrice = spreadInfoBean.getBrokerage_price();
154 164
             mViewBinding.tvBrokeragePrice.setText("可用余额:¥" + mBrokeragePrice);
155 165
             mMemberBrokeragePrice = spreadInfoBean.getMember_brokerage_price();
@@ -166,7 +176,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
166 176
             } catch (Exception e) {
167 177
 
168 178
             }
169
-        });
179
+        });*/
170 180
         mBindingStateBViewModel.getBindingState();
171 181
 //        mInviteViewModel.getBandAccountInfo(type, "");
172 182
         mBindingStateBViewModel.mBindingStateBean.observe(this, bindingStateBeans -> {
@@ -240,18 +250,15 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
240 250
         });
241 251
         //支付宝授权链接
242 252
         mInviteViewModel.mAuthInfoSucceed.observe(this, s -> {
243
-            Runnable authRunnable = new Runnable() {
244
-                @Override
245
-                public void run() {
246
-                    // 构造AuthTask 对象
247
-                    AuthTask authTask = new AuthTask(ImmediateWithdrawalActivity.this);
248
-                    // 调用授权接口,获取授权结果
249
-                    Map<String, String> result = authTask.authV2(s, true);
250
-                    Message msg = new Message();
251
-                    msg.what = SDK_AUTH_FLAG;
252
-                    msg.obj = result;
253
-                    mHandler.sendMessage(msg);
254
-                }
253
+            Runnable authRunnable = () -> {
254
+                // 构造AuthTask 对象
255
+                AuthTask authTask = new AuthTask(ImmediateWithdrawalActivity.this);
256
+                // 调用授权接口,获取授权结果
257
+                Map<String, String> result = authTask.authV2(s, true);
258
+                Message msg = new Message();
259
+                msg.what = SDK_AUTH_FLAG;
260
+                msg.obj = result;
261
+                mHandler.sendMessage(msg);
255 262
             };
256 263
 
257 264
             // 必须异步调用
@@ -280,8 +287,25 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
280 287
         });
281 288
 
282 289
         mineViewModel.getSpreadInfoYhc();
283
-        mineViewModel.spreadInfo.observe(this,mineSpreadInfo -> {
290
+        mineViewModel.spreadInfo.observe(this, mineSpreadInfo -> {
284 291
             this.mineSpreadInfo = mineSpreadInfo;
292
+            mMemberBrokeragePrice = mBrokeragePrice = mineSpreadInfo.getCurrentBalance();
293
+            mViewBinding.tvRedIntegral.setText("可提现金额:" + mMemberBrokeragePrice);
294
+            mViewBinding.tvRedIntegral.setVisibility(View.VISIBLE);
295
+            mViewBinding.tvIntegral.setVisibility(View.GONE);
296
+            mViewBinding.tvBrokeragePrice.setVisibility(View.GONE);
297
+            try {
298
+                if (mWithdrawal_money != null && !isShow) {
299
+                    if ((Double.parseDouble(mBrokeragePrice) < Double.parseDouble(mWithdrawal_money))) {
300
+                        Toast toast = Toast.makeText(context, "满" + mWithdrawal_money + "才可以提现~", Toast.LENGTH_SHORT);
301
+                        toast.setGravity(Gravity.CENTER, 0, 0);
302
+                        toast.show();
303
+                    }
304
+                    isShow = true;
305
+                }
306
+            } catch (Exception e) {
307
+
308
+            }
285 309
         });
286 310
 
287 311
         mInviteViewModel.failed.observe(this, s -> ToastUtils.showLong(s));
@@ -370,7 +394,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
370 394
                 mViewBinding.etCashWithdrawalAmount.setText(mBrokeragePrice);
371 395
             }
372 396
         } else if (v == mViewBinding.tvImmediateWithdrawal) {
373
-            if ("0".equals(mineSpreadInfo.getIdentity())){
397
+            if ("0".equals(mineSpreadInfo.getIdentity())) {
374 398
                 ToastUtils.showLong("需要您升级为合伙人");
375 399
                 return;
376 400
             }
@@ -428,9 +452,14 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
428 452
                 RealNameAuthenticationActivity.launch(context);
429 453
                 return;
430 454
             }
431
-            //TODO 这里如果是银行卡提现,需要弹窗获取验证码,然后输入验证码后进行提现此操作
432
-            //立即提现
433
-            mInviteViewModel.getApplicationWithdrawal(mViewBinding.etCashWithdrawalAmount.getText().toString(), type, isRed);
455
+            if ("1".equals(type)) {
456
+                //立即提现
457
+                mInviteViewModel.getApplicationWithdrawal(mViewBinding.etCashWithdrawalAmount.getText().toString(), type, isRed);
458
+            } else {
459
+//                loginViewModel.getCode(ImmediateWithdrawalActivity.this);
460
+                smsCodeDialog.show();
461
+            }
462
+
434 463
         } else if (v == mViewBinding.llWx) {
435 464
             //微信
436 465
             type = "1";
@@ -520,4 +549,16 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
520 549
         super.onDestroy();
521 550
         EventBus.getDefault().unregister(this);
522 551
     }
552
+
553
+    @Override
554
+    public void onConfirm(String code) {
555
+        //验证码确认
556
+        mInviteViewModel.getApplicationWithdrawal(mViewBinding.etCashWithdrawalAmount.getText().toString(), type, code);
557
+    }
558
+
559
+    @Override
560
+    public void onReGetCode() {
561
+        //重新获取验证码
562
+        loginViewModel.getCode(ImmediateWithdrawalActivity.this);
563
+    }
523 564
 }

+ 11 - 1
app/src/main/java/com/yihucha/hbyhc/presentation/invitation/view_model/InviteViewModel.java

@@ -520,13 +520,23 @@ public class InviteViewModel extends BaseViewModel {
520 520
      * @param extract_price
521 521
      * @param extract_type
522 522
      */
523
-    @SuppressLint("CheckResult")
523
+    //微信提现
524 524
     public void getApplicationWithdrawal(String extract_price, String extract_type, boolean isRed) {
525
+        getApplicationWithdrawal(extract_price,extract_type,isRed,null);
526
+    }
527
+    //银行卡提现
528
+    public void getApplicationWithdrawal(String extract_price, String extract_type, String sms_code) {
529
+        getApplicationWithdrawal(extract_price,extract_type,false,sms_code);
530
+    }
531
+    @SuppressLint("CheckResult")
532
+    public void getApplicationWithdrawal(String extract_price, String extract_type, boolean isRed,String sms_code) {
525 533
         Map<String, Object> map = new HashMap<>();
526 534
         map.put("extract_price", extract_price);
527 535
         map.put("extract_type", extract_type);
528 536
         if (isRed)
529 537
             map.put("type", 2);
538
+        if (EmptyCheckUtils.isNotEmpty(sms_code))
539
+            map.put("sms_code",sms_code);
530 540
         UserService userService = NetworkApi.createService(UserService.class);
531 541
         userService.getApplicationWithdrawal(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse>() {
532 542
             @Override

+ 0 - 9
app/src/main/java/com/yihucha/hbyhc/presentation/mine/MyCommissionActivity.kt

@@ -44,15 +44,6 @@ class MyCommissionActivity :
44 44
     }
45 45
 
46 46
     private fun initData() {
47
-        /* TODO 不确定该接口是否还有用
48
-        mInviteViewModel.getAgentInfo()
49
-        mInviteViewModel.mInvitePHPBean.observe(this) {
50
-
51
-        }
52
-        mInviteViewModel.failed.observe(this) {
53
-            ToastUtils.showLong(it)
54
-        }
55
-        */
56 47
         mInviteViewModel.getYanglaojinInfo()
57 48
         mInviteViewModel.userAnnuityInfoBeanMutableLiveData.observe(
58 49
             this

+ 6 - 4
app/src/main/java/com/yihucha/hbyhc/utils/CountDownTimeUtil.java

@@ -10,7 +10,7 @@ import java.lang.ref.WeakReference;
10 10
  * 倒计时
11 11
  */
12 12
 public class CountDownTimeUtil {
13
-
13
+    private int tvColor = Color.parseColor("#9E9E9E");
14 14
     private WeakReference<TextView> tvCodeWr;//控件软引用,防止内存泄漏
15 15
 
16 16
     private CountDownTimer timer;
@@ -22,7 +22,9 @@ public class CountDownTimeUtil {
22 22
         super();
23 23
         this.tvCodeWr = new WeakReference(textView);
24 24
     }
25
-
25
+    public void setTvColor(int color){
26
+        tvColor = color;
27
+    }
26 28
     public void runTimer() {
27 29
         //倒计时的总时长   每次的间隔时间   单位都是毫秒
28 30
         timer = new CountDownTimer(times, 1000) {
@@ -35,7 +37,7 @@ public class CountDownTimeUtil {
35 37
                 if (tvCodeWr.get() != null) {
36 38
                     tvCodeWr.get().setClickable(true);
37 39
                     tvCodeWr.get().setText("重新获取");
38
-                    tvCodeWr.get().setTextColor(Color.parseColor("#9E9E9E"));
40
+                    tvCodeWr.get().setTextColor(tvColor);
39 41
                 }
40 42
                 cancel();
41 43
             }
@@ -50,7 +52,7 @@ public class CountDownTimeUtil {
50 52
                 if (tvCodeWr.get() != null) {
51 53
                     tvCodeWr.get().setClickable(false);
52 54
                     tvCodeWr.get().setText("重新发送("+millisUntilFinished / 1000+")");
53
-                    tvCodeWr.get().setTextColor(Color.parseColor("#9E9E9E"));
55
+                    tvCodeWr.get().setTextColor(tvColor);
54 56
                 }
55 57
             }
56 58
         }.start();

+ 4 - 6
app/src/main/java/com/yihucha/hbyhc/view/CustomDialog.java

@@ -626,12 +626,7 @@ public class CustomDialog {
626 626
         }
627 627
         TextView areaView = lDialog.getView(R.id.tv_content_area);
628 628
         areaView.setText(area);
629
-        lDialog.getView(R.id.imgv_close).setOnClickListener(new View.OnClickListener() {
630
-            @Override
631
-            public void onClick(View v) {
632
-                lDialog.dismiss();
633
-            }
634
-        });
629
+        lDialog.getView(R.id.imgv_close).setOnClickListener(v -> lDialog.dismiss());
635 630
         lDialog.show();
636 631
     }
637 632
 
@@ -643,4 +638,7 @@ public class CustomDialog {
643 638
         lDialog.getView(R.id.tv_dialog_iknow).setOnClickListener(v -> lDialog.dismiss());
644 639
         lDialog.show();
645 640
     }
641
+
642
+
643
+
646 644
 }

+ 78 - 0
app/src/main/java/com/yihucha/hbyhc/view/SmsCodeDialog.java

@@ -0,0 +1,78 @@
1
+package com.yihucha.hbyhc.view;
2
+
3
+import android.annotation.SuppressLint;
4
+import android.content.Context;
5
+import android.graphics.Color;
6
+import android.view.View;
7
+import android.widget.EditText;
8
+import android.widget.TextView;
9
+
10
+import com.liys.dialoglib.LDialog;
11
+import com.yihucha.hbyhc.R;
12
+import com.yihucha.hbyhc.utils.CountDownTimeUtil;
13
+import com.yihucha.hbyhc.utils.EmptyCheckUtils;
14
+import com.yihucha.hbyhc.utils.StringUtils;
15
+import com.yihucha.hbyhc.utils.StringsUtil;
16
+
17
+/**
18
+ * author : zhangbing
19
+ * time   : 2024/2/29 9:51
20
+ * com.yihucha.hbyhc.view
21
+ * 提现获取验证码代理类
22
+ */
23
+public class SmsCodeDialog {
24
+    private CountDownTimeUtil mCountDownTimeUtil = null;
25
+    private TextView tvCode;
26
+    private Context context;
27
+    private LDialog lDialog;
28
+
29
+    @SuppressLint("SetTextI18n")
30
+    public SmsCodeDialog(Context context, String phone, DialogCallBack dialogCallBack) {
31
+        this.context = context;
32
+        lDialog = LDialog.newInstance(context, R.layout.dialog_smscode_tixian);
33
+        EditText editText = lDialog.getView(R.id.et_code);
34
+        tvCode = lDialog.getView(R.id.tv_code);
35
+        TextView textView = lDialog.getView(R.id.tv_phone_smscode);
36
+        textView.setText("已给" + StringUtils.resetPhone(phone) + "发送验证码");
37
+        lDialog.getView(R.id.confirm_negative).setOnClickListener(v -> {
38
+            lDialog.dismiss();
39
+            mCountDownTimeUtil.cancel();
40
+        });
41
+        lDialog.getView(R.id.confirm_positive).setOnClickListener(v -> {
42
+            if (EmptyCheckUtils.isNotEmpty(dialogCallBack)) {
43
+                dialogCallBack.onConfirm(editText.getText().toString());
44
+                lDialog.dismiss();
45
+                mCountDownTimeUtil.cancel();
46
+            }
47
+        });
48
+        lDialog.getView(R.id.tv_code).setOnClickListener(v -> {
49
+            if (EmptyCheckUtils.isNotEmpty(dialogCallBack))
50
+                dialogCallBack.onReGetCode();
51
+            mCountDownTimeUtil.runTimer();
52
+        });
53
+        mCountDownTimeUtil = new CountDownTimeUtil(tvCode);
54
+        mCountDownTimeUtil.setTvColor(Color.WHITE);
55
+    }
56
+
57
+    public void show() {
58
+        if (EmptyCheckUtils.isNotEmpty(lDialog)) {
59
+            mCountDownTimeUtil.runTimer();
60
+            lDialog.show();
61
+        }
62
+
63
+    }
64
+
65
+    public void cancle() {
66
+        mCountDownTimeUtil.cancel();
67
+        if (EmptyCheckUtils.isNotEmpty(lDialog)) {
68
+            lDialog.dismiss();
69
+        }
70
+    }
71
+
72
+    public interface DialogCallBack {
73
+        void onConfirm(String code);
74
+
75
+        void onReGetCode();
76
+    }
77
+
78
+}

+ 6 - 6
app/src/main/res/layout/activity_withdrawal_record.xml

@@ -6,11 +6,11 @@
6 6
     android:orientation="vertical">
7 7
 
8 8
 
9
-        <androidx.recyclerview.widget.RecyclerView
10
-            android:id="@+id/rv_withdrawal_record"
11
-            android:layout_width="match_parent"
12
-            android:background="@color/white"
13
-            android:layout_height="wrap_content"
14
-            android:layout_marginTop="13dp" />
9
+    <androidx.recyclerview.widget.RecyclerView
10
+        android:id="@+id/rv_withdrawal_record"
11
+        android:layout_width="match_parent"
12
+        android:layout_height="wrap_content"
13
+        android:layout_marginTop="13dp"
14
+        android:background="@color/white" />
15 15
 
16 16
 </LinearLayout>

+ 97 - 0
app/src/main/res/layout/dialog_smscode_tixian.xml

@@ -0,0 +1,97 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="280dp"
4
+    android:layout_height="wrap_content"
5
+    android:orientation="vertical"
6
+    android:background="@drawable/shape_white_8dp"
7
+    android:padding="16dp">
8
+
9
+    <TextView
10
+        android:layout_width="wrap_content"
11
+        android:layout_height="wrap_content"
12
+        android:layout_gravity="center_horizontal"
13
+        android:text="请输入验证码"
14
+        android:textColor="@color/black_333333"
15
+        android:textSize="16sp" />
16
+
17
+    <TextView
18
+        android:id="@+id/tv_phone_smscode"
19
+        android:layout_width="wrap_content"
20
+        android:layout_height="wrap_content"
21
+        android:layout_gravity="center_horizontal"
22
+        android:layout_marginTop="20dp"
23
+        android:text="已给188****3333发送验证码"
24
+        android:textColor="@color/black_333333"
25
+        android:textSize="14sp" />
26
+
27
+    <LinearLayout
28
+        android:layout_width="wrap_content"
29
+        android:layout_height="wrap_content"
30
+        android:layout_gravity="center_horizontal"
31
+        android:layout_marginTop="10dp"
32
+        android:orientation="horizontal">
33
+
34
+        <EditText
35
+            android:id="@+id/et_code"
36
+            android:layout_width="100dp"
37
+            android:layout_height="wrap_content"
38
+            android:layout_marginRight="5dp"
39
+            android:background="@null"
40
+            android:hint="@string/input_code"
41
+            android:maxLength="11"
42
+            android:textSize="16sp" />
43
+
44
+        <TextView
45
+            android:id="@+id/tv_code"
46
+            android:layout_width="wrap_content"
47
+            android:layout_height="wrap_content"
48
+            android:layout_marginLeft="5dp"
49
+            android:background="@drawable/shape_fe0032_50dp"
50
+            android:paddingLeft="8dp"
51
+            android:paddingTop="4dp"
52
+            android:paddingRight="8dp"
53
+            android:paddingBottom="4dp"
54
+            android:text="@string/get_code"
55
+            android:textColor="@color/white"
56
+            android:textSize="14sp" />
57
+    </LinearLayout>
58
+
59
+    <View
60
+        android:layout_width="match_parent"
61
+        android:layout_height="1dp"
62
+        android:layout_marginTop="10dp"
63
+        android:alpha="0.5"
64
+        android:background="@color/gray_999999" />
65
+
66
+    <LinearLayout
67
+        android:layout_width="match_parent"
68
+        android:layout_height="40dp"
69
+        android:orientation="horizontal">
70
+
71
+        <TextView
72
+            android:id="@+id/confirm_negative"
73
+            android:layout_width="0dp"
74
+            android:layout_height="match_parent"
75
+            android:layout_weight="1"
76
+            android:gravity="center"
77
+            android:text="@string/cancel"
78
+            android:textColor="@color/black_333333"
79
+            android:textSize="18sp" />
80
+
81
+        <View
82
+            android:id="@+id/line"
83
+            android:layout_width="0.5dp"
84
+            android:layout_height="match_parent"
85
+            android:background="@color/gray_e5e5e5" />
86
+
87
+        <com.yihucha.hbyhc.view.BoldText
88
+            android:id="@+id/confirm_positive"
89
+            android:layout_width="0dp"
90
+            android:layout_height="match_parent"
91
+            android:layout_weight="1"
92
+            android:gravity="center"
93
+            android:text="@string/confirm"
94
+            android:textColor="@color/red_fe0032"
95
+            android:textSize="18sp" />
96
+    </LinearLayout>
97
+</LinearLayout>