From ddff7888bf7e754d12fb5fc85a58f3012f456490 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 05 六月 2021 17:26:03 +0800 Subject: [PATCH] 特价完善 --- app/src/main/java/com/tejia/lijin/app/util/goods/GoodsBuyUtil.java | 104 +++++++++++++++++++++++++++------------------------- 1 files changed, 54 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/tejia/lijin/app/util/goods/GoodsBuyUtil.java b/app/src/main/java/com/tejia/lijin/app/util/goods/GoodsBuyUtil.java index 26f74b8..fa230a4 100644 --- a/app/src/main/java/com/tejia/lijin/app/util/goods/GoodsBuyUtil.java +++ b/app/src/main/java/com/tejia/lijin/app/util/goods/GoodsBuyUtil.java @@ -2,37 +2,25 @@ import android.app.Activity; import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebViewClient; -import android.widget.Toast; import com.alibaba.baichuan.android.trade.AlibcTradeSDK; import com.alibaba.baichuan.android.trade.model.AlibcShowParams; import com.alibaba.baichuan.android.trade.model.OpenType; -import com.alibaba.baichuan.android.trade.page.AlibcDetailPage; import com.alibaba.baichuan.trade.biz.AlibcConstants; import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; -import com.alibaba.baichuan.trade.biz.login.AlibcLogin; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.tejia.lijin.app.BasicTextHttpResponseHandler; import com.tejia.lijin.app.ShoppingApi; import com.tejia.lijin.app.entity.TbPidInfo; import com.tejia.lijin.app.entity.common.GoodsConvertLinkJumpLink; -import com.tejia.lijin.app.ui.recommend.GoodsDetailActivityJD; -import com.tejia.lijin.app.ui.recommend.GoodsDetailActivityPDD; -import com.tejia.lijin.app.ui.recommend.GoodsDetailActivitySuning; -import com.tejia.lijin.app.ui.recommend.GoodsDetailActivityTB; -import com.tejia.lijin.app.ui.recommend.GoodsDetailActivityVIP; +import com.tejia.lijin.app.entity.user.UserLijinLevelInfoVO; import com.tejia.lijin.app.util.Constant; import com.tejia.lijin.app.util.GoodsBuyJumpUtil; import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil; -import com.tejia.lijin.app.util.user.UserUtil; import com.wpc.library.util.common.StringUtils; import org.apache.http.Header; @@ -46,12 +34,13 @@ /** * 鍟嗗搧璐拱 + * * @param activity * @param context * @param requestInfo * @param resultListener */ - public static void buy(Activity activity, Context context, GoodsBuyRequestInfo requestInfo, IBuyGoodsResultListener resultListener) { + public static void fanli(Activity activity, Context context, GoodsBuyRequestInfo requestInfo, IBuyGoodsResultListener resultListener) { switch (requestInfo.getGoodsType()) { case Constant.GOODS_TYPE_TB: @@ -61,13 +50,13 @@ buyJD(activity, requestInfo, resultListener); break; case Constant.GOODS_TYPE_PDD: - buyPDD(context, requestInfo, resultListener); + buyPDD(activity, requestInfo, resultListener); break; case Constant.GOODS_TYPE_VIP: - buyVIP(context, requestInfo, resultListener); + buyVIP(activity, requestInfo, resultListener); break; case Constant.GOODS_TYPE_SUNING: - buySuning(context, requestInfo, resultListener); + buySuning(activity, requestInfo, resultListener); break; } @@ -77,7 +66,7 @@ /** * 鎵撳紑鎸囧畾閾炬帴 */ - private static void jumpTB(Activity activity, TbPidInfo tInfo, String clickUrl, String couponUrl, final IBuyGoodsResultListener buyGoodsResultListener) { + public static void jumpTB(Activity activity, TbPidInfo tInfo, String clickUrl, String couponUrl, final IBuyGoodsResultListener buyGoodsResultListener) { AlibcShowParams alibcShowParams = new AlibcShowParams(); alibcShowParams.setOpenType(OpenType.Auto); alibcShowParams.setBackUrl("alisdk://"); @@ -112,19 +101,25 @@ public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { Gson gson = new GsonBuilder().serializeNulls().create(); + JSONObject data = jsonObject.optJSONObject("data"); TbPidInfo tInfo = null; String clickUrl = null; String couponUrl = null; - if (jsonObject.optJSONObject("data").optJSONObject("tbPidInfo") != null) - tInfo = gson.fromJson(jsonObject.optJSONObject("data").optJSONObject("tbPidInfo").toString(), TbPidInfo.class); + if (data.optJSONObject("tbPidInfo") != null) + tInfo = gson.fromJson(data.optJSONObject("tbPidInfo").toString(), TbPidInfo.class); - JSONObject object = jsonObject.optJSONObject("data").optJSONObject("link"); + JSONObject object = data.optJSONObject("link"); if (object != null) { clickUrl = object.optString("clickUrl"); couponUrl = object.optString("couponUrl"); } + buyGoodsResultListener.onConvertLinkSuccess(); - jumpTB(activity, tInfo, clickUrl, couponUrl, buyGoodsResultListener); + UserLijinLevelInfoVO userLevel = null; + if (data.optJSONObject("userLevel") != null) { + userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); + } + GoodsBuyJumpUtil.jumpTB(activity, tInfo, clickUrl, couponUrl,userLevel, buyGoodsResultListener); } else { buyGoodsResultListener.onConvertLinkFail(jsonObject.optString("msg")); } @@ -156,20 +151,13 @@ @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { - GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(jsonObject.optJSONObject("data").toString(), GoodsConvertLinkJumpLink.class); - buyGoodsResultListener.onJumpThirdAppStart(); - GoodsBuyJumpUtil.jumpJD(activity, jumpLink, new GoodsBuyJumpUtil.IJumpResult() { - - @Override - public void onSuccess() { - buyGoodsResultListener.onJumpThirdAppSuccess(); - } - - @Override - public void onFail(String msg) { - buyGoodsResultListener.onJumpThirdAppFail(); - } - }); + JSONObject data = jsonObject.optJSONObject("data"); + GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class); + UserLijinLevelInfoVO userLevel = null; + if (data.optJSONObject("userLevel") != null) { + userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); + } + GoodsBuyJumpUtil.jumpJD(activity, jumpLink, userLevel, null); } else { buyGoodsResultListener.onConvertLinkFail(jsonObject.optString("msg")); } @@ -196,14 +184,20 @@ } - private static void buyPDD(final Context context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { + private static void buyPDD(final Activity context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { ShoppingApi.getPDDLinkInfo(context, requestInfo.getUid(), requestInfo.getGoodsId(), requestInfo.getFrom(), "", new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { - GoodsConvertLinkJumpLink pddJumpLink = new Gson().fromJson(jsonObject.optJSONObject("data").toString(), GoodsConvertLinkJumpLink.class); + JSONObject data = jsonObject.optJSONObject("data"); + GoodsConvertLinkJumpLink pddJumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class); buyGoodsResultListener.onJumpThirdAppStart(); - GoodsBuyJumpUtil.jumpPDD(context, pddJumpLink); + UserLijinLevelInfoVO userLevel = null; + if (data.optJSONObject("userLevel") != null) { + userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); + } + GoodsBuyJumpUtil.jumpPDD(context, pddJumpLink, userLevel); + } else { buyGoodsResultListener.onConvertLinkFail(jsonObject.optString("msg")); } @@ -229,14 +223,20 @@ }); } - private static void buyVIP(final Context context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { + private static void buyVIP(final Activity context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { ShoppingApi.getVIPLinkInfo(context, requestInfo.getUid(), requestInfo.getGoodsId(), requestInfo.getFrom(), "", new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { - GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(jsonObject.optJSONObject("data").toString(), GoodsConvertLinkJumpLink.class); + JSONObject data = jsonObject.optJSONObject("data"); + GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class); buyGoodsResultListener.onJumpThirdAppStart(); - GoodsBuyJumpUtil.jumpVIPShop(context, jumpLink); + UserLijinLevelInfoVO userLevel = null; + if (data.optJSONObject("userLevel") != null) { + userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); + } + GoodsBuyJumpUtil.jumpVIPShop(context, jumpLink, userLevel); + } else { buyGoodsResultListener.onConvertLinkFail(jsonObject.optString("msg")); } @@ -264,14 +264,19 @@ } - private static void buySuning(final Context context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { + private static void buySuning(final Activity context, GoodsBuyRequestInfo requestInfo, final IBuyGoodsResultListener buyGoodsResultListener) { ShoppingApi.getSuningLinkInfo(context, requestInfo.getUid(), requestInfo.getGoodsId(), requestInfo.getFrom(), "", new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { - GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(jsonObject.optJSONObject("data").toString(), GoodsConvertLinkJumpLink.class); + JSONObject data = jsonObject.optJSONObject("data"); + GoodsConvertLinkJumpLink jumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class); buyGoodsResultListener.onJumpThirdAppStart(); - GoodsBuyJumpUtil.jumpSuning(context, jumpLink); + UserLijinLevelInfoVO userLevel = null; + if (data.optJSONObject("userLevel") != null) { + userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); + } + GoodsBuyJumpUtil.jumpSuning(context, jumpLink, userLevel); } else { buyGoodsResultListener.onConvertLinkFail(jsonObject.optString("msg")); } @@ -296,17 +301,16 @@ } }); } - /** * 鍟嗗搧璐拱璇锋眰鍙傛暟 */ - static class GoodsBuyRequestInfo { + public static class GoodsBuyRequestInfo { private int goodsType; private String goodsId; private String couponLink; - private String uid; + private Long uid; private String from; @@ -334,11 +338,11 @@ this.couponLink = couponLink; } - public String getUid() { + public Long getUid() { return uid; } - public void setUid(String uid) { + public void setUid(Long uid) { this.uid = uid; } -- Gitblit v1.8.0