Browse Source

fix thief tip

stanley-king 7 years ago
parent
commit
5fc091a7b7
1 changed files with 11 additions and 5 deletions
  1. 11 5
      helper/bonus/thief_vilator.php

+ 11 - 5
helper/bonus/thief_vilator.php

@@ -33,7 +33,16 @@ class thief_vilator
             $error = ['code' => errcode::ErrBonus,'msg' => '每天只能偷一次好友的红包'];
             return false;
         }
-        $amount = $this->calc_amount();
+
+        $pred = new predeposit_helper($this->mFromID);
+        $usable_amount = $pred->total_bonus();
+        $cents = intval($usable_amount * 100 + 0.5);
+        if($cents == 0) {
+            $error = ['code' => errcode::ErrBonus,'msg' => '他比你更穷,还是选择富人下手吧~'];
+            return false;
+        }
+
+        $amount = $this->calc_amount($usable_amount);
         if($amount == false) {
             $error = ['code' => errcode::ErrBonus,'msg' => '今日不能偷该用户的红包~'];
             return false;
@@ -45,11 +54,8 @@ class thief_vilator
         return $amount;
     }
 
-    private function calc_amount()
+    private function calc_amount($usable_amount)
     {
-        $pred = new predeposit_helper($this->mFromID);
-        $usable_amount = $pred->total_bonus();
-
         $policy = new gain_policy(5, $usable_amount);
         return $policy->calculate();
     }