1、開通守護-使用優惠券

This commit is contained in:
Martin 2024-07-05 13:58:35 +08:00
parent 963fe2c110
commit 3dcc801331
7 changed files with 89 additions and 27 deletions

View File

@ -28,11 +28,17 @@ public class GuardPriceModel extends BaseModel {
private String couponDiscountEn; private String couponDiscountEn;
@SerializedName("coupon_discount_price") @SerializedName("coupon_discount_price")
private String couponDiscountPrice; private String couponDiscountPrice;
@SerializedName("coupon_id")
private String couponId;
public String getCouponDiscount() { public String getCouponDiscount() {
return couponDiscount; return couponDiscount;
} }
public String getCouponId() {
return couponId;
}
public String getCouponDiscountEn() { public String getCouponDiscountEn() {
return couponDiscountEn; return couponDiscountEn;
} }

View File

@ -21,7 +21,7 @@ public class GuardBuyCouponTipsDialog {
* @param simpleCallback * @param simpleCallback
*/ */
public static void showBuyOrRenewDialog(Context context, String coupon, String coin, String content, public static void showBuyOrRenewDialog(Context context, String coupon, String coin, String content,
DialogUitl.SimpleCallback simpleCallback) { DialogUitl.SimpleCallback3 simpleCallback) {
if (context instanceof Activity) { if (context instanceof Activity) {
if (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()) { if (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()) {
return; return;
@ -57,19 +57,22 @@ public class GuardBuyCouponTipsDialog {
dialog.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() { dialog.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
simpleCallback.onCancel();
dialog.dismiss(); dialog.dismiss();
} }
}); });
dialog.findViewById(R.id.btn_cancel1).setOnClickListener(new View.OnClickListener() { dialog.findViewById(R.id.btn_cancel1).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
simpleCallback.onCancel();
dialog.dismiss(); dialog.dismiss();
} }
}); });
btn_confirm.setOnClickListener(new View.OnClickListener() { btn_confirm.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
simpleCallback.onConfirmClick(dialog, ""); simpleCallback.onConfirmClick(dialog);
dialog.dismiss();
} }
}); });
dialog.show(); dialog.show();

View File

@ -0,0 +1,44 @@
package com.yunbao.common.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import com.yunbao.common.R;
import com.yunbao.common.utils.WordUtil;
public class GuardBuyTipsNewDialog {
/**
* @param context
*/
public static void showBuyOrRenewDialog(Context context) {
if (context instanceof Activity) {
if (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()) {
return;
}
}
final Dialog dialog = new Dialog(context, R.style.dialog2);
dialog.setContentView(R.layout.dialog_guard_buy_tips);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
TextView btn_confirm = dialog.findViewById(R.id.btn_confirm);
btn_confirm.setText(WordUtil.isNewZh() ? "確認" : "Confirm");
dialog.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.findViewById(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}

View File

@ -1194,7 +1194,7 @@ public interface PDLiveApi {
Observable<ResponseModel<GuardGetGuardOpenInfoModel>> getGuardOpenInfo(@Query("liveuid") String liveUid); Observable<ResponseModel<GuardGetGuardOpenInfoModel>> getGuardOpenInfo(@Query("liveuid") String liveUid);
@GET("/api/public/?service=Guard.openGuard") @GET("/api/public/?service=Guard.openGuard")
Observable<ResponseModel<Object>> openGuard(@Query("liveuid") String liveUid, @Query("guard_type") String guardType, @Query("price_key") String priceKey, @Query("stream") String stream,@Query("coupon_type") String coupon_type); Observable<ResponseModel<Object>> openGuard(@Query("liveuid") String liveUid, @Query("guard_type") String guardType, @Query("price_key") String priceKey, @Query("stream") String stream,@Query("coupon_type") String coupon_type,@Query("coupon_id") String coupon_id);
@GET("/api/public/?service=Guard.sendMoneyLong") @GET("/api/public/?service=Guard.sendMoneyLong")
Observable<ResponseModel<Object>> sendMoneyLong(@Query("liveuid") String liveUid, @Query("gold_num") String goldNum); Observable<ResponseModel<Object>> sendMoneyLong(@Query("liveuid") String liveUid, @Query("gold_num") String goldNum);

View File

@ -3014,9 +3014,9 @@ public class LiveNetManager {
} }
public void openGuard(String liveUid, String guardType, String priceKey, String stream,String coupon_type, HttpCallback<String> callback) { public void openGuard(String liveUid, String guardType, String priceKey, String stream,String coupon_type,String couponId, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.openGuard(liveUid, guardType, priceKey, stream,coupon_type) .openGuard(liveUid, guardType, priceKey, stream,coupon_type,couponId)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<Object>>() { .subscribe(new Consumer<ResponseModel<Object>>() {

View File

@ -2,13 +2,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="310dp" android:layout_width="310dp"
android:layout_height="250dp" android:layout_height="220dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="230dp" android:layout_height="200dp"
android:background="@drawable/guard_buy_tips_bg"> android:background="@drawable/guard_buy_tips_bg">
<ImageView <ImageView
@ -40,7 +40,7 @@
android:layout_below="@+id/title" android:layout_below="@+id/title"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="10dp" android:layout_marginTop="30dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:gravity="center" android:gravity="center"
android:letterSpacing="0.1" android:letterSpacing="0.1"

View File

@ -43,6 +43,7 @@ import com.yunbao.common.custom.LiveGuardScalePageTransformer;
import com.yunbao.common.dialog.AbsDialogPopupWindow; import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.dialog.GuardBuyCouponTipsDialog; import com.yunbao.common.dialog.GuardBuyCouponTipsDialog;
import com.yunbao.common.dialog.GuardBuyTipsDialog; import com.yunbao.common.dialog.GuardBuyTipsDialog;
import com.yunbao.common.dialog.GuardBuyTipsNewDialog;
import com.yunbao.common.dialog.GuardUpgradePopup; import com.yunbao.common.dialog.GuardUpgradePopup;
import com.yunbao.common.dialog.LiveBuyGuardSelectPopup; import com.yunbao.common.dialog.LiveBuyGuardSelectPopup;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
@ -247,8 +248,10 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
openTheGuard.setText(dataTipModel.isOpen() ? WordUtil.isNewZh() ? "續費神之守護" : "Renew God Guardian" openTheGuard.setText(dataTipModel.isOpen() ? WordUtil.isNewZh() ? "續費神之守護" : "Renew God Guardian"
: WordUtil.getNewString(R.string.open_the_god_guard)); : WordUtil.getNewString(R.string.open_the_god_guard));
} }
discountPrice.setTag("1");
guardPriceModel = price.get(0); guardPriceModel = price.get(0);
discountPrice.setTag("1");
discount.setTag(guardPriceModel.getCouponId());
if (TextUtils.isEmpty(guardPriceModel.getDiscountPrice())) { if (TextUtils.isEmpty(guardPriceModel.getDiscountPrice())) {
discountPrice.setText(String.valueOf(guardPriceModel.getOriginalPrice())); discountPrice.setText(String.valueOf(guardPriceModel.getOriginalPrice()));
originalPrice.setVisibility(GONE); originalPrice.setVisibility(GONE);
@ -311,6 +314,7 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
public void onLiveBuyGuardSelectListener(GuardPriceModel model) { public void onLiveBuyGuardSelectListener(GuardPriceModel model) {
guardPriceModel = model; guardPriceModel = model;
discountPrice.setTag(String.valueOf(guardPriceModel.getPriceKey())); discountPrice.setTag(String.valueOf(guardPriceModel.getPriceKey()));
discount.setTag(guardPriceModel.getCouponId());
if (TextUtils.isEmpty(guardPriceModel.getDiscountPrice())) { if (TextUtils.isEmpty(guardPriceModel.getDiscountPrice())) {
discountPrice.setText(String.valueOf(guardPriceModel.getOriginalPrice())); discountPrice.setText(String.valueOf(guardPriceModel.getOriginalPrice()));
originalPrice.setVisibility(GONE); originalPrice.setVisibility(GONE);
@ -343,23 +347,28 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
ViewClicksAntiShake.clicksAntiShake(openTheGuard, new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(openTheGuard, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
if (TextUtils.equals(mGuardUserInfoModel.getIsOpen(), "1") &&
dataTipModel.getGuardType() < mGuardUserInfoModel.getGuardType()) {
//开通比当前低级的的守护
GuardBuyTipsNewDialog.showBuyOrRenewDialog(mContext);
}else{
//判断是否选择的是一个月 //判断是否选择的是一个月
if(discountPrice.getTag().equals("1")){ if(discountPrice.getTag().equals("1")&&!discount.getTag().toString().equals("0")){
GuardBuyCouponTipsDialog.showBuyOrRenewDialog(mContext, WordUtil.isNewZh() ? guardPriceModel.getCouponDiscount() : guardPriceModel.getCouponDiscountEn(), guardPriceModel.getCouponDiscountPrice(), dataTipModel.getGuardName(), new DialogUitl.SimpleCallback2() { GuardBuyCouponTipsDialog.showBuyOrRenewDialog(mContext, WordUtil.isNewZh() ? guardPriceModel.getCouponDiscount() : guardPriceModel.getCouponDiscountEn(), guardPriceModel.getCouponDiscountPrice(), dataTipModel.getGuardName(), new DialogUitl.SimpleCallback3() {
@Override @Override
public void onCancelClick() { public void onConfirmClick(Dialog dialog) {
bugGurd(true);
} }
@Override @Override
public void onConfirmClick(Dialog dialog, String content) { public void onCancel() {
bugGurd(true); bugGurd(false);
dialog.dismiss();
} }
}); });
}else{ }else{
bugGurd(false); bugGurd(false);
} }
}
switch (dataTipModel.getGuardType()) { switch (dataTipModel.getGuardType()) {
case 1: case 1:
MobclickAgent.onEvent(mContext, "star_guardian_renew_btn", "星之守护开通/续费按钮点击次数及人数"); MobclickAgent.onEvent(mContext, "star_guardian_renew_btn", "星之守护开通/续费按钮点击次数及人数");
@ -444,7 +453,7 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
LiveNetManager.get(activity) LiveNetManager.get(activity)
.openGuard(mLiveUid, .openGuard(mLiveUid,
String.valueOf(dataTipModel.getGuardType()), String.valueOf(dataTipModel.getGuardType()),
String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0", new HttpCallback<String>() { String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0",discount.getTag().toString(), new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
if (TextUtils.equals(data, "22")) { if (TextUtils.equals(data, "22")) {
@ -531,7 +540,7 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
LiveNetManager.get(activity) LiveNetManager.get(activity)
.openGuard(mLiveUid, .openGuard(mLiveUid,
String.valueOf(dataTipModel.getGuardType()), String.valueOf(dataTipModel.getGuardType()),
String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0", new HttpCallback<String>() { String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0",discount.getTag().toString(), new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
if (TextUtils.equals(data, "22")) { if (TextUtils.equals(data, "22")) {
@ -586,7 +595,7 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
LiveNetManager.get(activity) LiveNetManager.get(activity)
.openGuard(mLiveUid, .openGuard(mLiveUid,
String.valueOf(dataTipModel.getGuardType()), String.valueOf(dataTipModel.getGuardType()),
String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0", new HttpCallback<String>() { String.valueOf(guardPriceModel.getPriceKey()), mStream,isCoupon?"1":"0",discount.getTag().toString(), new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
if (TextUtils.equals(data, "22")) { if (TextUtils.equals(data, "22")) {