diff --git a/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java b/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java index 7441cdded..41b0ec718 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java +++ b/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java @@ -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); } diff --git a/app/src/main/java/com/yizhuan/erban/ui/im/chat/MsgViewHolderP2PContactRecharge.java b/app/src/main/java/com/yizhuan/erban/ui/im/chat/MsgViewHolderP2PContactRecharge.java new file mode 100644 index 000000000..272c9b895 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/ui/im/chat/MsgViewHolderP2PContactRecharge.java @@ -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) { + + } +} diff --git a/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java b/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java index 821591383..40b3d3398 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java +++ b/app/src/main/java/com/yizhuan/erban/ui/pay/ChargeActivity.java @@ -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 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(); diff --git a/app/src/main/res/drawable-xhdpi/bg_msg_vh_p2p_contact_recharge.webp b/app/src/main/res/drawable-xhdpi/bg_msg_vh_p2p_contact_recharge.webp new file mode 100644 index 000000000..f6d4930bf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/bg_msg_vh_p2p_contact_recharge.webp differ diff --git a/app/src/main/res/layout/layout_msg_view_holder_customer_service_recharge.xml b/app/src/main/res/layout/layout_msg_view_holder_customer_service_recharge.xml new file mode 100644 index 000000000..da500023c --- /dev/null +++ b/app/src/main/res/layout/layout_msg_view_holder_customer_service_recharge.xml @@ -0,0 +1,35 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c187eea7..119050170 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -866,7 +866,6 @@ 一起玩 刪除 - 復製 舉報 已復製 已刪除 @@ -4910,6 +4909,7 @@ %s鉆 向%s轉贈 已複製 + 複製 轉贈記錄 數量 全部 @@ -5127,5 +5127,7 @@ 購買%d個碎片 購買%d個愛心 請選擇或輸入購買的愛心數量 + 如何儲值: + 1.在Piko語音App內前往【我的】—【儲值鑽石】進行儲值\n2.聯繁客服獲取儲值鏈接\n客服WeChat: %s 複製\n客服Line: %s 複製\n3.如遇提示"儲值失敗,請聯系客服處理~",請添加客服進行處理 \ No newline at end of file diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index 2d4bfc057..c7ee3519d 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -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; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java index 2cf40ba04..ab4356be0 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java @@ -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活动通用飘屏 */ diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/P2PContactRechargeAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/P2PContactRechargeAttachment.java new file mode 100644 index 000000000..16eb59e64 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/P2PContactRechargeAttachment.java @@ -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; + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java index bf10eb8a9..3c3938bbc 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java @@ -116,4 +116,6 @@ public interface IPayModel extends IModel { Single> loadChargeBanner(); + Single getChargeContact(); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java index d07268f8e..6b0edd294 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java @@ -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 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 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> getChargeBanner(); + @GET("/charge/guide/contact") + Single> getChargeContact(); + /** * 验证googlePlay订单 *