新增 充值页跳转私聊客服充值

This commit is contained in:
wzq
2023-09-25 16:00:50 +08:00
parent 12f2757861
commit 122d5842fe
11 changed files with 203 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderFairy;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
@@ -43,6 +44,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
@@ -169,6 +171,9 @@ public class ImInitHelper {
//CP
NimUIKit.registerMsgItemViewHolder(CpInviteAttachment.class, MsgViewHolderText.class);
NimUIKit.registerMsgItemViewHolder(FairySendAttachment.class, MsgViewHolderFairy.class);
// 客服充值
NimUIKit.registerMsgItemViewHolder(P2PContactRechargeAttachment.class, MsgViewHolderP2PContactRecharge.class);
NimUIKit.setSessionListener(listener);
NimUIKit.setContactEventListener(listener1);
}

View File

@@ -0,0 +1,81 @@
package com.yizhuan.erban.ui.im.chat;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yizhuan.erban.R;
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
import com.yizhuan.erban.utils.ClipboardUtils;
import com.yizhuan.xchat_android_core.im.custom.bean.OpenRoomNotiAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
/**
* Created by chenran on 2017/9/21.
*/
public class MsgViewHolderP2PContactRecharge extends MsgViewHolderBase implements View.OnClickListener {
private TextView mTvInstructions;
private String mCopyText;
public MsgViewHolderP2PContactRecharge(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
@Override
protected int getContentResId() {
return R.layout.layout_msg_view_holder_customer_service_recharge;
}
@Override
protected void inflateContentView() {
mTvInstructions = findViewById(R.id.tv_instructions);
mTvInstructions.setMovementMethod(new LinkMovementMethod());
mCopyText = context.getString(R.string.copy);
}
@Override
protected int leftBackground() {
return 0;
}
@Override
protected void bindContentView() {
P2PContactRechargeAttachment attachment = (P2PContactRechargeAttachment) message.getAttachment();
String string = context.getString(R.string.tips_cs_recharge, attachment.getIdWeChat(), attachment.getIdLine());
int first = string.indexOf(mCopyText);
SpannableString spannableString = new SpannableString(string);
spannableString.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(context, R.color.color_9168FA)) {
@Override
public void onClick(@NonNull View widget) {
ClipboardUtils.copyText(attachment.getIdWeChat());
SingleToastUtil.showToast(context.getString(R.string.have_copy));
}
}, first, first + 2, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
int second = string.indexOf(mCopyText, first + 2);
spannableString.setSpan(new OriginalDrawStatusClickSpan(ContextCompat.getColor(context, R.color.color_9168FA)) {
@Override
public void onClick(@NonNull View widget) {
ClipboardUtils.copyText(attachment.getIdLine());
SingleToastUtil.showToast(context.getString(R.string.have_copy));
}
}, second, second + 2, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
mTvInstructions.setText(spannableString);
}
@Override
public void onClick(View v) {
}
}

View File

@@ -1,5 +1,7 @@
package com.yizhuan.erban.ui.pay;
import static com.yizhuan.xchat_android_core.pay.PayModel.RECHARGE_LIMIT;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
@@ -28,23 +30,21 @@ import com.appsflyer.AFInAppEventParameterName;
import com.appsflyer.AFInAppEventType;
import com.appsflyer.AppsFlyerLib;
import com.netease.nim.uikit.StatusBarUtil;
import com.netease.nim.uikit.support.glide.ImageLoaderKit;
import com.yizhuan.erban.R;
import com.yizhuan.erban.UIHelper;
import com.yizhuan.erban.application.IReportConstants;
import com.yizhuan.erban.application.ReportManager;
import com.yizhuan.erban.base.BaseMvpActivity;
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
import com.yizhuan.erban.pay.presenter.ChargePresenter;
import com.yizhuan.erban.pay.view.IChargeView;
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.setting.ModifyPwdActivity;
import com.yizhuan.erban.ui.utils.ImageLoadKt;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.xchat_android_core.DemoCache;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.exception.FailReasonException;
import com.yizhuan.xchat_android_core.pay.PayModel;
import com.yizhuan.xchat_android_core.pay.bean.Banner;
import com.yizhuan.xchat_android_core.pay.bean.ChargeBean;
@@ -275,13 +275,31 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
PayModel.get().placeOrder(skuDetails.getSku())
.compose(bindToLifecycle())
.subscribe(recordId -> billingManager.initiatePurchaseFlow(skuDetails, recordId.getRecordId()),
throwable -> SingleToastUtil.showToast(throwable.getMessage()));
throwable -> {
if (throwable instanceof FailReasonException) {
FailReasonException failReasonException = (FailReasonException) throwable;
if (failReasonException.getCode() == RECHARGE_LIMIT) {
getDialogManager().showOkDialog(failReasonException.getMessage(), "聯繫客服", true,
() -> jumpContact());
return;
}
}
SingleToastUtil.showToast(throwable.getMessage());
});
} else {
Log.w(TAG, "skuDetails ==null");
}
}
@SuppressLint("CheckResult")
private void jumpContact() {
PayModel.get().getChargeContact()
.compose(bindToLifecycle())
.subscribe(data -> NimP2PMessageActivity.start(this, data),
e -> toast(e.getMessage()));
}
@Override
protected void onResume() {
super.onResume();

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/dp_278"
android:layout_height="@dimen/dp_236"
android:background="@drawable/bg_msg_vh_p2p_contact_recharge">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_58"
android:text="@string/how_to_recharge_with_cs"
android:textColor="@color/color_1F1B4F"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_instructions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_6"
android:layout_marginEnd="@dimen/dp_10"
android:lineSpacingExtra="@dimen/dp_2"
android:text="@string/tips_cs_recharge"
android:textColor="@color/color_767585"
android:textSize="@dimen/sp_12"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/tv_title"
app:layout_constraintTop_toBottomOf="@id/tv_title" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -866,7 +866,6 @@
<string name="label_play_together">一起玩</string>
<string name="delete">刪除</string>
<string name="copy">復製</string>
<string name="report">舉報</string>
<string name="copy_success">已復製</string>
<string name="delete_success">已刪除</string>
@@ -4910,6 +4909,7 @@
<string name="consume_diamond_num">%s鉆</string>
<string name="give_gold_to_user">向%s轉贈</string>
<string name="have_copy">已複製</string>
<string name="copy">複製</string>
<string name="donation_record">轉贈記錄</string>
<string name="me_num">數量</string>
<string name="me_all">全部</string>
@@ -5127,5 +5127,7 @@
<string name="buy_debris">購買%d個碎片</string>
<string name="buy_love_num">購買%d個愛心</string>
<string name="please_select_or_enter_the_quantity_of_hearts_purchased">請選擇或輸入購買的愛心數量</string>
<string name="how_to_recharge_with_cs">如何儲值:</string>
<string name="tips_cs_recharge">1.在Piko語音App內前往【我的】—【儲值鑽石】進行儲值\n2.聯繁客服獲取儲值鏈接\n客服WeChat: %s 複製\n客服Line: %s 複製\n3.如遇提示"儲值失敗,請聯系客服處理~",請添加客服進行處理</string>
</resources>

View File

@@ -646,6 +646,11 @@ public class CustomAttachParser implements MsgAttachmentParser {
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
attachment = new NotifyH5Attachment(second);
break;
case CustomAttachment.CUSTOM_MSG_P2P:
if (second == CustomAttachment.CUSTOM_MSG_P2P_CONTACT_RECHAGE) {
attachment = new P2PContactRechargeAttachment();
}
break;
default:
LogUtils.e(ResUtil.getString(R.string.custom_bean_customattachparser_01) + first + " second=" + second);
break;

View File

@@ -453,6 +453,13 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_SUB_CONVERT_L2 = 9732; // 召唤L2
public static final int CUSTOM_MSG_SUB_CONVERT_L3 = 9733; // 召唤L3
public static final int CUSTOM_MSG_P2P = 99;
/**
* 联系客服充值
*/
public static final int CUSTOM_MSG_P2P_CONTACT_RECHAGE = 99;
/**
* H5活动通用飘屏
*/

View File

@@ -0,0 +1,26 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
public class P2PContactRechargeAttachment extends CustomAttachment {
private String idWeChat;
private String idLine;
public P2PContactRechargeAttachment() {
super(CUSTOM_MSG_P2P, CUSTOM_MSG_P2P_CONTACT_RECHAGE);
}
@Override
protected void parseData(JSONObject data) {
idWeChat = data.getString("official0");
idLine = data.getString("official1");
}
public String getIdWeChat() {
return idWeChat;
}
public String getIdLine() {
return idLine;
}
}

View File

@@ -116,4 +116,6 @@ public interface IPayModel extends IModel {
Single<List<Banner>> loadChargeBanner();
Single<String> getChargeContact();
}

View File

@@ -65,6 +65,11 @@ public class PayModel extends BaseModel implements IPayModel {
*/
public static final int NOT_REAL_NAME_BEFORE_CHARGING = 10108;
/**
* 封控, 限制充值
*/
public static final int RECHARGE_LIMIT = 50000;
protected WalletInfo walletInfo;
private boolean firstChargeSuccess = false;
@@ -468,7 +473,7 @@ public class PayModel extends BaseModel implements IPayModel {
@Override
public Single<PayRecordId> placeOrder(String googlePlayProdId) {
return api.placeOrder(googlePlayProdId)
.compose(RxHelper.handleBeanData())
.compose(RxHelper.handleCommon())
.compose(RxHelper.handleSchedulers());
}
@@ -480,6 +485,13 @@ public class PayModel extends BaseModel implements IPayModel {
.map(ChargeBannerInfo::getBanners);
}
@Override
public Single<String> getChargeContact() {
return api.getChargeContact()
.compose(RxHelper.handleBeanData())
.compose(RxHelper.handleSchedulers());
}
public interface Api {
@@ -647,6 +659,9 @@ public class PayModel extends BaseModel implements IPayModel {
@GET("/charge/guide/banner")
Single<ServiceResult<ChargeBannerInfo>> getChargeBanner();
@GET("/charge/guide/contact")
Single<ServiceResult<String>> getChargeContact();
/**
* 验证googlePlay订单
*