Parcourir la source

Merge remote-tracking branch 'origin/sheep_develop' into sheep_develop

zengjiebin il y a 7 ans
Parent
commit
15c088a114

+ 4 - 0
app/src/main/AndroidManifest.xml

@@ -926,6 +926,10 @@
             android:name="com.sheep.gamegroup.module.user.activity.ActVip"
             android:screenOrientation="portrait"
             android:theme="@style/AppActionTheme"/>
+        <activity
+            android:name="com.sheep.gamegroup.view.activity.ActMyGame"
+            android:theme="@style/AppActionTheme"
+            android:screenOrientation="portrait" />
     </application>
 
 </manifest>

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/UserAssets.java

@@ -25,6 +25,7 @@ public class UserAssets {
     private float cash_withdrawal;
     private String extension_extract;//推广提成
     private float directional_currency;//定向消费货币
+    private float game_golden_dan =0f;
 
     public void setSheep_bi_total(String sheep_bi_total){
         this.sheep_bi_total = sheep_bi_total;
@@ -35,6 +36,15 @@ public class UserAssets {
     public void setRecharge_amount(String recharge_amount){
         this.recharge_amount = recharge_amount;
     }
+
+    public float getGame_golden_dan() {
+        return game_golden_dan;
+    }
+
+    public void setGame_golden_dan(float game_golden_dan) {
+        this.game_golden_dan = game_golden_dan;
+    }
+
     public String getRecharge_amount(){
         return this.recharge_amount;
     }

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

@@ -91,6 +91,7 @@ import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.ActMiDong;
 import com.sheep.gamegroup.view.activity.ActModifyThird;
 import com.sheep.gamegroup.view.activity.ActMyFocus;
+import com.sheep.gamegroup.view.activity.ActMyGame;
 import com.sheep.gamegroup.view.activity.ActMyMoney;
 import com.sheep.gamegroup.view.activity.ActMyWelfare;
 import com.sheep.gamegroup.view.activity.ActNewAboutUs;
@@ -1724,6 +1725,12 @@ public class Jump2View {
         UMConfigUtils.Event.SHEEP_GAME_TASK.onEvent();
     }
 
+    public void goMyGame(Context activity) {
+        Intent intent = new Intent(activity, ActMyGame.class);
+        activity.startActivity(intent);
+        UMConfigUtils.Event.SHEEP_GAME_TASK.onEvent();
+    }
+
     /**
      * 订单管理
      */

+ 12 - 5
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -3,6 +3,7 @@ package com.sheep.gamegroup.util.js;
 import android.app.Activity;
 import android.content.Intent;
 import android.text.TextUtils;
+import android.util.Log;
 import android.webkit.JavascriptInterface;
 
 import com.alibaba.fastjson.JSONObject;
@@ -120,24 +121,30 @@ public class KFZSJs {
 
     @JavascriptInterface
     public void paymentCompleted(String from, boolean ret, String msg, String orderNo) {
-        if (from.equals("sdk")) {
+        //1. app
+        //2. sdk
+        if (from.equals("2")) {
             Intent intent = new Intent();
             intent.putExtra("ret", ret);
             intent.putExtra("msg", msg);
             intent.putExtra("order_no", orderNo);
-            activity.setResult(Activity.RESULT_OK);
-            activity.setIntent(intent);
+            activity.setResult(Activity.RESULT_OK, intent);
         }
         activity.finish();
     }
 
     @JavascriptInterface
-    public void jumpGame(){
+    public void jumpGame() {
         Jump2View.getInstance().goMainGame(activity);
     }
 
     @JavascriptInterface
-    public void jumpShop(){
+    public void jumpMyGame() {
+        Jump2View.getInstance().goMyGame(activity);
+    }
+
+    @JavascriptInterface
+    public void jumpShop() {
         Jump2View.getInstance().gotoYfShop(activity);
     }
 

+ 39 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActMyGame.java

@@ -0,0 +1,39 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.content.Intent;
+import android.support.v4.app.Fragment;
+
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.view.fragment.FgtEveryDayShare;
+import com.sheep.gamegroup.view.fragment.FgtMyGame;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+import com.umeng.socialize.UMShareAPI;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+
+/**
+ * Created by realicing on 2018/11/23.
+ * realicing@sina.com
+ * 小绵羊3.4.5新增--每日分享
+ */
+public class ActMyGame extends BaseContainerActivity {
+
+    @Override
+    protected Fragment initFragment() {
+        return FgtMyGame.newInstance(2);
+    }
+
+    @Override
+    public void initView() {
+        super.initView();
+        TitleBarUtils
+                .getInstance()
+                .setShowOrHide(this, true)
+                .setTitle(this, getString(R.string.my_games))
+                .setTitleFinish(this);
+    }
+
+}

+ 91 - 11
app/src/main/java/com/sheep/gamegroup/view/activity/ActPay.java

@@ -12,9 +12,11 @@ import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.PayOrder;
+import com.sheep.gamegroup.model.entity.UserAssets;
 import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -25,6 +27,8 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 
+import org.afinal.simplecache.ApiKey;
+
 import java.util.List;
 import java.util.Locale;
 
@@ -39,6 +43,7 @@ import io.reactivex.schedulers.Schedulers;
 public class ActPay extends BaseActivity {
 
     public final static int ACTION_FOR_H5_PAY = 1003;
+    public final static int ACTION_FOR_RECHARGE = 1004;
 
     @Override
     protected boolean needButterKnife() {
@@ -55,14 +60,38 @@ public class ActPay extends BaseActivity {
     private TextView pay_info;
     private TextView pay_amount;
     private TextView pay_amount2;
+    private View directionalPayBtn;
+    private View rechargeLayout;
+
+    private View pay_amount_layout;
+    private TextView sheep_coin_amount;
+    private TextView game_golden_amount;
+    private TextView order_amount;
+    private TextView golden_sub_amount;
+    private TextView yiyouhui_amount;
 
     private List<View> payOrderViewList = ListUtil.emptyList();
     private List<View> successViewList = ListUtil.emptyList();
     private List<View> failedViewList = ListUtil.emptyList();
 
+    private boolean orderOk = false;
+    private boolean assetsOk = false;
+    private UserAssets assets;
+    private PayOrder payOrder;
+    private String token;
+
     @Override
     public void initView() {
         ImageView title_img_back = findViewById(R.id.title_img_back);
+        pay_amount_layout = findViewById(R.id.pay_amount_layout);
+        sheep_coin_amount = findViewById(R.id.sheep_coin_amount);
+        game_golden_amount = findViewById(R.id.game_golden_amount);
+        order_amount = findViewById(R.id.order_amount);
+        golden_sub_amount = findViewById(R.id.golden_sub_amount);
+        yiyouhui_amount = findViewById(R.id.yiyouhui_amount);
+
+        rechargeLayout = findViewById(R.id.recharge_layout);
+        directionalPayBtn = findViewById(R.id.directional_pay_btn);
         pay_commit = findViewById(R.id.pay_commit);
         TextView title_cancel = findViewById(R.id.title_cancel);
         pay_msg_tv = findViewById(R.id.pay_msg_tv);
@@ -77,7 +106,8 @@ public class ActPay extends BaseActivity {
         payOrderViewList.add(title_img_back);
         payOrderViewList.add(title_cancel);
         payOrderViewList.add(pay_msg_tv);
-        payOrderViewList.add(pay_amount);
+        payOrderViewList.add(pay_amount_layout);
+        payOrderViewList.add(rechargeLayout);
         payOrderViewList.add(pay_line);
 
         successViewList.add(pay_sheep_iv);
@@ -112,9 +142,6 @@ public class ActPay extends BaseActivity {
         pay_commit.setEnabled(false);
     }
 
-    private PayOrder payOrder;
-    private String token;
-
     @Override
     public void initData() {
         Intent intent = getIntent();
@@ -147,7 +174,8 @@ public class ActPay extends BaseActivity {
                         if (payOrder != null) {
                             status = STATUS_GET_ORDER_SUCCESS;
                             pay_commit.setEnabled(true);
-                            loadPayOrder();
+                            orderOk = true;
+                            loadAssets();
                         } else {
                             status = STATUS_GET_ORDER_SUCCESS_ERROR;
                         }
@@ -162,18 +190,68 @@ public class ActPay extends BaseActivity {
     }
 
     //加载PayOrder
-    private void loadPayOrder() {
-        ViewUtil.setText(pay_msg_tv, payOrder.getName());
-        String amountText = getString(R.string.x_yuan, NumberFormatUtils.retainMost2(payOrder.getPayMoney()));
-        ViewUtil.setColorMapText(pay_amount, amountText, "元", "#FFFFFF");
-        ViewUtil.setColorMapText(pay_amount2, amountText, "元", "#FFFFFF");
-        ViewUtil.setText(pay_info, getString(R.string.sheep_order_no, payOrder.getName(), payOrder.getOrderNo()));
+    private synchronized void loadPayOrder() {
+        if (orderOk && assetsOk) {
+            String amountText = getString(R.string.x_yuan, NumberFormatUtils.retainMost2(payOrder.getPayMoney()));
+            if (payOrder.getMerchantId() == 1001) {
+                directionalPayBtn.setVisibility(View.VISIBLE);
+                sheep_coin_amount.setText("拥有绵羊币: " + assets.getSheep_bi_total());
+                game_golden_amount.setText("拥有金丹: " + assets.getGame_golden_dan());
+                order_amount.setText(payOrder.getPayMoney() + "");
+                float subAmount = payOrder.getPayMoney() < assets.getGame_golden_dan() ? payOrder.getPayMoney() : assets.getGame_golden_dan();
+                golden_sub_amount.setText("-" + subAmount);
+                yiyouhui_amount.setText("已优惠: " + subAmount);
+                float mustPay = payOrder.getPayMoney() < assets.getGame_golden_dan() ? 0 : (payOrder.getPayMoney() - assets.getGame_golden_dan());
+                pay_amount.setText("应付金额: " + mustPay + "元");
+            } else {
+                game_golden_amount.setVisibility(View.GONE);
+                yiyouhui_amount.setVisibility(View.GONE);
+                ((View) golden_sub_amount.getParent()).setVisibility(View.GONE);
+                directionalPayBtn.setVisibility(View.GONE);
+                pay_amount.setText("应付金额: " + payOrder.getPayMoney() + "元");
+            }
+
+            ViewUtil.setText(pay_msg_tv, payOrder.getName());
+            ViewUtil.setColorMapText(pay_amount2, amountText, "元", "#FFFFFF");
+            ViewUtil.setText(pay_info, getString(R.string.sheep_order_no, payOrder.getName(), payOrder.getOrderNo()));
+        }
+    }
+
+    private void loadAssets() {
+        SheepApp.getInstance().getNetComponent().getApiService().getMyAssets()
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(this) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        assets = baseMessage.getData(UserAssets.class);
+                        assetsOk = true;
+                        loadPayOrder();
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+                });
+    }
+
+    public void onRechargeBtnClick(View v) {
+        Intent intent = new Intent(this, RechargeAct.class);
+        intent.putExtra("forResult", true);
+        startActivityForResult(intent, ACTION_FOR_RECHARGE);
+        rechargeLayout.setVisibility(View.GONE);
     }
 
     //点击底部按钮
     public void onClickBottomBtn(View view) {
         switch (status) {
             case STATUS_GET_ORDER_SUCCESS://立即支付
+                float mustPay = payOrder.getPayMoney() < assets.getGame_golden_dan() ? 0 : (payOrder.getPayMoney() - assets.getGame_golden_dan());
+                if (Float.parseFloat(assets.getSheep_bi_total()) < mustPay) {
+                    rechargeLayout.setVisibility(View.VISIBLE);
+                    return;
+                }
                 SheepApp.getInstance().getNetComponent().getApiService().sdkPayOrder(token, payOrder.getOrderNo())
                         .subscribeOn(Schedulers.io())
                         .observeOn(AndroidSchedulers.mainThread())
@@ -226,6 +304,8 @@ public class ActPay extends BaseActivity {
                 intent.putExtra(EXTRA_NAME_STATUS, status);
                 setResult(RESULT_CODE, intent);
             }
+        } else if (resultCode == 777 && requestCode == ACTION_FOR_RECHARGE) {
+            loadAssets();
         }
     }
 

+ 6 - 0
app/src/main/res/drawable/shape_red_solid_rectangle_18.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <corners android:radius="18dp" />
+    <solid android:color="#ED3C60" />
+</shape>

+ 181 - 40
app/src/main/res/layout/act_pay.xml

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="#2A3342"
-    android:fitsSystemWindows="true"
-    tools:context="com.sheep.gamegroup.view.activity.ActPay">
+    android:fitsSystemWindows="true">
 
     <ImageView
         android:id="@+id/title_img_back"
@@ -44,8 +42,6 @@
         android:layout_below="@+id/title_name_tv"
         android:background="#212936" />
 
-
-    <!--支付页面-->
     <TextView
         android:id="@+id/pay_msg_tv"
         android:layout_width="match_parent"
@@ -66,16 +62,120 @@
         android:layout_marginTop="40dp"
         android:background="#212936" />
 
-    <TextView
-        android:id="@+id/pay_amount"
+    <LinearLayout
+        android:id="@+id/pay_amount_layout"
+        android:orientation="vertical"
+        android:layout_above="@+id/bottom_btn_layout"
+        android:layout_marginBottom="6dp"
+        android:layout_marginRight="12dp"
+        android:layout_marginLeft="12dp"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@+id/pay_line"
-        android:layout_marginTop="40dp"
-        android:gravity="center"
-        android:text="@string/x_yuan"
-        android:textColor="#ffffe63c"
-        android:textSize="18sp" />
+        android:layout_height="wrap_content">
+        <LinearLayout
+            android:orientation="horizontal"
+            android:gravity="center"
+            android:layout_marginBottom="8dp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:id="@+id/sheep_coin_amount"
+                android:layout_weight="1"
+                android:text="拥有绵羊币: 0"
+                android:textColor="@android:color/white"
+                android:textSize="15sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <TextView
+                android:id="@+id/game_golden_amount"
+                android:layout_weight="1"
+                android:text="拥有金丹: 0"
+                android:textColor="@android:color/white"
+                android:textSize="15sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+        </LinearLayout>
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:background="#212936" />
+        <LinearLayout
+            android:orientation="horizontal"
+            android:gravity="center"
+            android:layout_marginTop="8dp"
+            android:layout_marginBottom="8dp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:layout_weight="1"
+                android:text="订单金额"
+                android:textColor="@android:color/white"
+                android:textSize="15sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <TextView
+                android:id="@+id/order_amount"
+                android:layout_weight="1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical|right"
+                android:text="0"
+                android:textColor="@android:color/white"
+                android:textSize="18sp" />
+        </LinearLayout>
+        <LinearLayout
+            android:orientation="horizontal"
+            android:gravity="center"
+            android:layout_marginBottom="8dp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:layout_weight="1"
+                android:text="金丹减免"
+                android:textColor="@android:color/white"
+                android:textSize="15sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <TextView
+                android:id="@+id/golden_sub_amount"
+                android:layout_weight="1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical|right"
+                android:text="0"
+                android:textColor="@android:color/white"
+                android:textSize="18sp" />
+        </LinearLayout>
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:background="#212936" />
+
+        <LinearLayout
+            android:orientation="horizontal"
+            android:gravity="center"
+            android:layout_marginTop="8dp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <TextView
+                android:id="@+id/yiyouhui_amount"
+                android:layout_weight="1"
+                android:text="已优惠: 0元"
+                android:textColor="@android:color/white"
+                android:textSize="15sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <TextView
+                android:id="@+id/pay_amount"
+                android:layout_weight="1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical|right"
+                android:text="应付金额: 0元"
+                android:textColor="#ffffe63c"
+                android:textSize="18sp" />
+        </LinearLayout>
+    </LinearLayout>
+
     <!--支付页面-->
 
 
@@ -148,38 +248,79 @@
         android:textColor="#ffffffff"
         android:textSize="12sp" />
 
-
-    <TextView
-        android:id="@+id/pay_commit"
+    <LinearLayout
+        android:id="@+id/bottom_btn_layout"
+        android:orientation="horizontal"
+        android:layout_alignParentBottom="true"
+        android:padding="6dp"
         android:layout_width="match_parent"
-        android:layout_height="36dp"
-        android:layout_above="@+id/directional_pay_btn"
-        android:layout_margin="12dp"
-        android:background="@drawable/shape_blue_solid_rectangle_18"
-        android:gravity="center"
-        android:text="立即支付"
-        android:onClick="onClickBottomBtn"
-        android:textColor="#ffffffff"
-        android:textSize="18sp" />
+        android:layout_height="wrap_content">
+        <TextView
+            android:id="@+id/pay_commit"
+            android:layout_width="match_parent"
+            android:layout_height="36dp"
+            android:layout_weight="1"
+            android:background="@drawable/shape_blue_solid_rectangle_18"
+            android:layout_marginRight="3dp"
+            android:gravity="center"
+            android:text="立即支付"
+            android:onClick="onClickBottomBtn"
+            android:textColor="#ffffffff"
+            android:textSize="16sp" />
 
-    <TextView
-        android:id="@+id/directional_pay_btn"
-        android:layout_width="match_parent"
-        android:layout_height="36dp"
-        android:layout_alignParentBottom="true"
-        android:layout_margin="12dp"
-        android:background="@drawable/shape_blue_solid_rectangle_18"
-        android:gravity="center"
-        android:text="定向优惠"
-        android:onClick="onDirectionalPayClicked"
-        android:textColor="#ffffffff"
-        android:textSize="18sp" />
+        <TextView
+            android:id="@+id/directional_pay_btn"
+            android:layout_width="match_parent"
+            android:layout_height="36dp"
+            android:layout_weight="1"
+            android:layout_marginLeft="3dp"
+            android:background="@drawable/shape_red_solid_rectangle_18"
+            android:gravity="center"
+            android:text="定向优惠"
+            android:onClick="onDirectionalPayClicked"
+            android:textColor="#ffffffff"
+            android:textSize="16sp" />
+    </LinearLayout>
 
     <View
         android:layout_width="match_parent"
         android:layout_height="1dp"
-        android:layout_above="@+id/pay_commit"
+        android:layout_above="@+id/bottom_btn_layout"
         android:layout_marginTop="40dp"
         android:background="#212936" />
-    <!--<include layout=""-->
+
+    <!--dialog-->
+
+    <LinearLayout
+        android:id="@+id/recharge_layout"
+        android:orientation="horizontal"
+        android:background="@drawable/shape_white_solid_rectangle_5"
+        android:gravity="center"
+        android:padding="16dp"
+        android:visibility="gone"
+        android:layout_centerInParent="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content">
+        <TextView
+            android:text="绵羊币不足"
+            android:textSize="14sp"
+            android:textColor="@android:color/darker_gray"
+            android:layout_marginRight="8dp"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+        <TextView
+            android:id="@+id/recharge_btn"
+            android:onClick="onRechargeBtnClick"
+            android:text="立即充值"
+            android:textSize="13sp"
+            android:paddingTop="4dp"
+            android:paddingBottom="4dp"
+            android:paddingLeft="12sp"
+            android:paddingRight="12sp"
+            android:textColor="@android:color/white"
+            android:background="@drawable/shape_red_solid_rectangle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+    </LinearLayout>
+
 </RelativeLayout>