Browse Source

qrcode for sku and search shop goods

billyyoyo 6 years ago
parent
commit
75c5299921

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1924,7 +1924,7 @@ public interface ApiService {
     Observable<BaseMessage> checkAuth(@Query("Authorization") String token, @Query("game_id") String game_id, @Query("wlan") String wlan, @Query("auto_login") int autoLogin, @Query("face_url") String face_url);
 
     @GET("app/search")
-    Observable<BaseMessage> search(@Query("keyword") String keyword, @Query("game_count") int gameCount, @Query("task_count") int taskCount, @Query("gift_count") int giftCount, @Query("article_count") int articleCount);
+    Observable<BaseMessage> search(@Query("keyword") String keyword, @Query("game_count") int gameCount, @Query("task_count") int taskCount, @Query("gift_count") int giftCount, @Query("article_count") int articleCount, @Query("goods_count") int goodsCount);
 
     @GET("app/search/keywords")
     Observable<BaseMessage> keywords();

+ 86 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/ShopGoodsInfo.java

@@ -0,0 +1,86 @@
+package com.sheep.gamegroup.model.entity;
+
+public class ShopGoodsInfo {
+
+    private int id;
+    private String name;
+    private String image;
+    private String brand;
+    private float market_price;
+    private float goods_price;
+    private float vip_goods_price;
+    private int sale_number;
+    private int but_type;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public float getMarket_price() {
+        return market_price;
+    }
+
+    public void setMarket_price(float market_price) {
+        this.market_price = market_price;
+    }
+
+    public float getGoods_price() {
+        return goods_price;
+    }
+
+    public void setGoods_price(float goods_price) {
+        this.goods_price = goods_price;
+    }
+
+    public float getVip_goods_price() {
+        return vip_goods_price;
+    }
+
+    public void setVip_goods_price(float vip_goods_price) {
+        this.vip_goods_price = vip_goods_price;
+    }
+
+    public int getSale_number() {
+        return sale_number;
+    }
+
+    public void setSale_number(int sale_number) {
+        this.sale_number = sale_number;
+    }
+
+    public int getBut_type() {
+        return but_type;
+    }
+
+    public void setBut_type(int but_type) {
+        this.but_type = but_type;
+    }
+}

+ 9 - 4
app/src/main/java/com/sheep/gamegroup/module/qrcode/QRCodeCaptureHelper.java

@@ -13,6 +13,8 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.Constant;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.groups.creditcard.RegexUtils;
+import com.sheep.jiuyan.samllsheep.Config;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
@@ -24,9 +26,12 @@ public class QRCodeCaptureHelper {
 
     public static void handle(Activity activity, String text) {
         if (TextUtils.isEmpty(text)) return;
-        if(text.startsWith("http://") || text.startsWith("https://")){
+        if (text.startsWith("http://") || text.startsWith("https://")) {
             Jump2View.getInstance().goWeb(activity, text, "-");
             return;
+        } else if (RegexUtils.isNumberString(text)) {
+            Jump2View.getInstance().gotoYYShopMerchandise(activity, text);
+            return;
         }
         SheepApp.getInstance().getNetComponent().getApiService().getQRCodeInfo(SpUtils.getToken(activity), text)
                 .subscribeOn(Schedulers.io())
@@ -59,14 +64,14 @@ public class QRCodeCaptureHelper {
     }
 
     private static void handleAction(Activity activity, Uri uri, String extra) {
-        if(uri.toString().startsWith("sheep://liveness")){
+        if (uri.toString().startsWith("sheep://liveness")) {
             FaceSDKManager.getInstance().goLivenessCheck(activity, FaceSDKManager.NEED_FILEPATH, Constant.INTENT_DETECT_FACE, extra);
-        } else if(uri.toString().startsWith("sheep://facedetect")){
+        } else if (uri.toString().startsWith("sheep://facedetect")) {
             FaceSDKManager.getInstance().goFaceDetect(activity, FaceSDKManager.NEED_FILEPATH, Constant.INTENT_DETECT_FACE, extra);
         }
     }
 
-    public static void submitQRCodeResult(Activity activity, String code, String result){
+    public static void submitQRCodeResult(Activity activity, String code, String result) {
         JSONObject json = new JSONObject();
         json.put("action_content", result);
         json.put("status", 1);

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/module/search/AdpSearchResult.java

@@ -8,6 +8,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
 
+import com.sheep.gamegroup.model.entity.ShopGoodsInfo;
 import com.sheep.jiuyan.samllsheep.R;
 
 import java.util.ArrayList;
@@ -50,6 +51,9 @@ public class AdpSearchResult extends RecyclerView.Adapter<SearchResultHolder> {
         } else if (i == 4) {
             itemView = LayoutInflater.from(mContext).inflate(R.layout.find_item_news, viewGroup, false);
             holder = new ArticleHolder(itemView);
+        } else if (i == 5) {
+            itemView = LayoutInflater.from(mContext).inflate(R.layout.shop_goods_item, viewGroup, false);
+            holder = new GoodsHolder(itemView);
         } else {
             itemView = new TextView(mContext);
             holder = new SearchResultHolder(itemView) {

+ 6 - 1
app/src/main/java/com/sheep/gamegroup/module/search/FgtSearch.java

@@ -15,6 +15,7 @@ import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.GameSimple;
 import com.sheep.gamegroup.model.entity.GiftBag;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
+import com.sheep.gamegroup.model.entity.ShopGoodsInfo;
 import com.sheep.gamegroup.model.entity.TaskSimple;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -41,6 +42,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
     private int taskCount = 0;
     private int giftCount = 0;
     private int articleCount = 0;
+    private int goodsCount = 0;
 
     private String keyword;
 
@@ -110,7 +112,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
 
     private void search(boolean isRefresh) {
         SheepApp.getInstance().getNetComponent().getApiService()
-                .search(keyword, gameCount, taskCount, giftCount, articleCount)
+                .search(keyword, gameCount, taskCount, giftCount, articleCount, goodsCount)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
@@ -124,6 +126,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
                             taskCount += base.getInt("task_count");
                             giftCount += base.getInt("gift_count");
                             articleCount += base.getInt("article_count");
+                            goodsCount += base.getInt("goods_count");
                             JSONArray array = base.getJSONArray("list");
                             for (int i = 0; i < array.length(); i++) {
                                 JSONObject object = array.getJSONObject(i);
@@ -138,6 +141,8 @@ public class FgtSearch extends BaseFragment implements ISearch {
                                     item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, GiftBagApp.class);
                                 } else if (item.type == 4) {
                                     item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, Article.class);
+                                } else if (item.type == 5) {
+                                    item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, ShopGoodsInfo.class);
                                 } else {
                                     continue;
                                 }

+ 39 - 0
app/src/main/java/com/sheep/gamegroup/module/search/GoodsHolder.java

@@ -0,0 +1,39 @@
+package com.sheep.gamegroup.module.search;
+
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.sheep.gamegroup.model.entity.Article;
+import com.sheep.gamegroup.model.entity.ShopGoodsInfo;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.R;
+
+import butterknife.BindView;
+
+public class GoodsHolder extends SearchResultHolder<ShopGoodsInfo> {
+
+    @BindView(R.id.name_view)
+    TextView name_view;
+    @BindView(R.id.price_view)
+    TextView price_view;
+    @BindView(R.id.image_view)
+    ImageView image_view;
+
+    public GoodsHolder(@NonNull View itemView) {
+        super(itemView);
+        itemView.setOnClickListener((v) -> {
+            Jump2View.getInstance().gotoYYShopMerchandise(itemView.getContext(), item.getId() + "");
+        });
+    }
+
+    @Override
+    public void configView() {
+        ViewUtil.setText(name_view, item.getName());
+        ViewUtil.setText(price_view, "VIP回报购\n" + item.getVip_goods_price() + "\n回报购\n" + item.getGoods_price());
+        ViewUtil.setImage(image_view, item.getImage());
+    }
+
+}

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -2893,6 +2893,16 @@ public class Jump2View {
         });
     }
 
+    public void gotoYYShopMerchandise(Context activity, String merId) {
+        CommonUtil.getInstance().getConfigValue(Config.KEY_YY_SHOP_URL, url -> {
+            if (TextUtils.isEmpty(url)) {
+                url = "http://smallstation.9yan.io/yy_shop/#/pages/goods/goodsDetail";
+            }
+            url += "?id=" + merId;
+            goWeb(activity, new WebParams(url, Config.YY_SHOP_NAME));
+        });
+    }
+
     //点击一条消息
     public void onClickSystemNotification(Activity activity, SystemNotification item) {
         switch (item.getType()) {//消息类型 1:通知 2:活动 3:模块上线 4:任务上线 5:任务成功 6:任务失败

+ 2 - 0
app/src/main/java/com/sheep/groups/creditcard/RegexConstants.java

@@ -107,6 +107,8 @@ public final class RegexConstants {
      */
     public static final String REGEX_NEGATIVE_FLOAT       = "^-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*$";
 
+    public static final String REGEX_NUMBER_STRING = "[0-9]+";
+
     ///////////////////////////////////////////////////////////////////////////
     // If u want more please visit http://toutiao.com/i6231678548520731137
     ///////////////////////////////////////////////////////////////////////////

+ 4 - 0
app/src/main/java/com/sheep/groups/creditcard/RegexUtils.java

@@ -88,6 +88,10 @@ public final class RegexUtils {
         return isMatch(RegexConstants.REGEX_EMAIL, input);
     }
 
+    public static boolean isNumberString(final CharSequence input){
+        return isMatch(RegexConstants.REGEX_NUMBER_STRING, input);
+    }
+
     /**
      * Return whether input matches regex of url.
      *

+ 52 - 0
app/src/main/res/layout/shop_goods_item.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="96dp"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <ImageView
+        android:id="@+id/image_view"
+        android:scaleType="centerCrop"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginTop="12dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        android:layout_marginLeft="12dp"
+        android:layout_width="72dp"
+        android:layout_height="72dp" />
+
+    <TextView
+        android:id="@+id/name_view"
+        android:text="abc"
+        android:textSize="14sp"
+        android:textColor="@color/black_6_3"
+        app:layout_constraintLeft_toRightOf="@+id/image_view"
+        android:layout_marginLeft="8dp"
+        android:layout_marginRight="80dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <TextView
+        android:id="@+id/price_view"
+        android:text="VIP回报购"
+        android:textColor="@color/red_F07422"
+        android:textSize="12sp"
+        android:gravity="center"
+        android:layout_marginRight="12dp"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <View
+        style="@style/style_item_line_full"
+        android:layout_height="0.5dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:background="@color/gray_F0F0F0" />
+
+</android.support.constraint.ConstraintLayout>