From 0177a1314da102d41826a4dd9a8fc5ecd584951a Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 31 Mar 2023 14:40:43 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=B4=AD=E4=B9=B0=E5=AE=88=E6=8A=A4?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/bean/DiscountsModel.java | 109 ++++++++++++++++++ .../com/yunbao/common/http/PDLiveApi.java | 9 +- .../common/http/live/LiveNetManager.java | 22 ++++ .../dialog/LiveNewGuardBuyDialogFragment.java | 14 +++ 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/DiscountsModel.java diff --git a/common/src/main/java/com/yunbao/common/bean/DiscountsModel.java b/common/src/main/java/com/yunbao/common/bean/DiscountsModel.java new file mode 100644 index 000000000..825b3db99 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/DiscountsModel.java @@ -0,0 +1,109 @@ +package com.yunbao.common.bean; + +import androidx.annotation.NonNull; + +import com.google.gson.annotations.SerializedName; + +/** + * 优惠卷 + */ +public class DiscountsModel extends BaseModel { + //------------------贵族-------------------- + public static final int TYPE_VISCOUNT=1;//子爵 + public static final int TYPE_MARQUIS=2;//侯爵 + public static final int TYPE_DUKE=3;//公爵 + public static final int TYPE_KING=4;//国王 + public static final int TYPE_EMPEROR=5;//皇帝 + //------------------守护-------------------- + public static final int TYPE_WEEKS=6;//周守护 + public static final int TYPE_MONTH=7;//月守护 + public static final int TYPE_YEARS=8;//月守护 + + @SerializedName("userCouponID") + private int userCouponID; + @SerializedName("num") + private int num; + @SerializedName("endTime") + private long endTime; + @SerializedName("img") + private String img; + @SerializedName("name") + private String name; + @SerializedName("discount") + private double discount; + @SerializedName("describe") + private String describe; + + public DiscountsModel() { + } + + public int getUserCouponID() { + return userCouponID; + } + + public void setUserCouponID(int userCouponID) { + this.userCouponID = userCouponID; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getDiscount() { + return discount; + } + + public void setDiscount(double discount) { + this.discount = discount; + } + + public String getDescribe() { + return describe; + } + + public void setDescribe(String describe) { + this.describe = describe; + } + + @NonNull + @Override + public String toString() { + return "DiscountsModel{" + + "userCouponID=" + userCouponID + + ", num=" + num + + ", endTime=" + endTime + + ", img='" + img + '\'' + + ", name='" + name + '\'' + + ", discount=" + discount + + ", describe='" + describe + '\'' + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index c6ff26e03..40349b368 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -7,6 +7,7 @@ import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.HourRank; @@ -671,5 +672,11 @@ public interface PDLiveApi { @Query("type") int type, @Query("list") String list ); - + /** + * 获取折扣卷信息 + */ + @GET("/api/public/?service=Coupon.getUserCoupon") + Observable>> getDiscountInfo( + @Query("type") int type + ); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index fa7cd900f..f16633fcc 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -10,6 +10,7 @@ import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.LinkMicUserBean; @@ -1357,6 +1358,27 @@ public class LiveNetManager { } }).isDisposed(); } + public void getDiscountInfo(int type,HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getDiscountInfo(type) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> wishListGiftConfModelResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } /** * 直播间取消网络请求 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java index ac7877b56..19492c34e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java @@ -24,6 +24,7 @@ import com.makeramen.roundedimageview.RoundedImageView; import com.opensource.svgaplayer.SVGAImageView; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; +import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.glide.ImgLoader; @@ -380,6 +381,19 @@ public class LiveNewGuardBuyDialogFragment extends AbsDialogFragment implements if (mTargetBuyBean == null) { return; } + int discountType = 0; + switch (mTargetBuyBean.getType()) { + case Constants.GUARD_TYPE_DAY: + discountType = DiscountsModel.TYPE_WEEKS; + break; + case Constants.GUARD_TYPE_MONTH: + discountType = DiscountsModel.TYPE_MONTH; + break; + case Constants.GUARD_TYPE_YEAR: + discountType = DiscountsModel.TYPE_YEARS; + break; + } + LiveHttpUtil.buyGuard(mLiveUid, mStream, mTargetBuyBean.getId(), new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) {