stanley-king 8 лет назад
Родитель
Сommit
24484133e5

+ 20 - 20
helper/account_helper.php

@@ -105,7 +105,7 @@ class account_helper
             self::admin_param($param);
             $param['make_type'] = \bonus\type::MakeShakeGainType;
             $param['type_name'] = "从熊猫美妆摇来的红包";
-            $ret = bonus_helper::make_bonusex($param,$rates);
+            $ret = bonus_helper::make_bonus($param,$rates);
             if($ret != false) {
                 $type_sn = $ret['type_sn'];
                 self::$stSysBonus->reset($type_sn);
@@ -161,7 +161,7 @@ class account_helper
         $param['type_name'] = "从{$name}摇来的红包";
 
         $rate_moneys = self::make_rate($amount,1,$rate);
-        $ret = bonus_helper::make_bonusex($param,$rate_moneys);
+        $ret = bonus_helper::make_bonus($param,$rate_moneys);
         if($ret != false)
         {
             $to_minfo = new member_info($to_id);
@@ -199,7 +199,7 @@ class account_helper
         $param['type_name'] = "{$name}摇飞的红包";
 
         $rate_moneys = self::make_rate($amount,1,$rate);
-        $ret = bonus_helper::make_bonusex($param,$rate_moneys);
+        $ret = bonus_helper::make_bonus($param,$rate_moneys);
         if($ret != false)
         {
             $to_info = new member_info($to_id);
@@ -216,19 +216,19 @@ class account_helper
 
     private static function pay_refund($member_id,$amount,$bonus_name)
     {
-        $param = self::base_param($amount,1);
-        self::admin_param($param);
-        $param['make_type'] = \bonus\type::MakePayRefundType;
-        $param['type_name'] = $bonus_name;
-
-        $ret = bonus_helper::make_bonus($param);
-        if($ret != false)
-        {
-            bonus_helper::send($ret['type_sn'],array($member_id));
-            push_helper::order_refund_bonus($member_id,$amount);
-        } else {
-            Log::record("给用户 {$member_id} 退款{$amount}失败.");
-        }
+//        $param = self::base_param($amount,1);
+//        self::admin_param($param);
+//        $param['make_type'] = \bonus\type::MakePayRefundType;
+//        $param['type_name'] = $bonus_name;
+//
+//        $ret = bonus_helper::make_bonus($param);
+//        if($ret != false)
+//        {
+//            bonus_helper::send($ret['type_sn'],array($member_id));
+//            push_helper::order_refund_bonus($member_id,$amount);
+//        } else {
+//            Log::record("给用户 {$member_id} 退款{$amount}失败.");
+//        }
     }
 
     private static function pay_bonus($order_sn,$member_id)
@@ -269,7 +269,7 @@ class account_helper
             $param['make_type'] = \bonus\type::MakeOrderCancelType;
             $param['type_name'] = '订单退款';
             $rate_moneys = self::make_rate($amount,1,$rate);
-            $ret = bonus_helper::make_bonusex($param,$rate_moneys);
+            $ret = bonus_helper::make_bonus($param,$rate_moneys);
 
             if($ret != false) {
                 bonus_helper::send($ret['type_sn'],array($member_id));
@@ -294,7 +294,7 @@ class account_helper
         $param['type_name'] = "发送红包过期退款";
 
         $rate_moneys = self::make_rate($amount,1,$rate);
-        $ret = bonus_helper::make_bonusex($param,$rate_moneys);
+        $ret = bonus_helper::make_bonus($param,$rate_moneys);
         if($ret != false)
         {
             $bonus = bonus_helper::send($ret['type_sn'],array($member_id));
@@ -335,7 +335,7 @@ class account_helper
             $param['make_type'] = \bonus\type::MakeRegister;
             $param['type_name'] = "新人红包";
 
-            $ret = bonus_helper::make_bonusex($param,array($rate));
+            $ret = bonus_helper::make_bonus($param,array($rate));
             if($ret != false) {
                 bonus_helper::send($ret['type_sn'],array($member_id));
                 $total += $amount;
@@ -389,7 +389,7 @@ class account_helper
             $param['make_type'] = bonus\type::MakePayType;
             $param['type_name'] = "支付奖励红包";
 
-            $ret = bonus_helper::make_bonusex($param,array($rate_money));
+            $ret = bonus_helper::make_bonus($param,array($rate_money));
             if($ret != false) {
                 $type_sn = $ret['type_sn'];
                 $bonus = bonus_helper::send($type_sn,array($buyer_id));

+ 2 - 1
helper/bonus/manager.php

@@ -315,7 +315,8 @@ class manager
         $binded_bonus = array();
         $ret = Model('user_bonus')->bind($type_id,$bonus_id,$session_id,$mobile,$binded_bonus);
         if($ret == true)
-        { //bind 一个新红包
+        {
+            //bind 一个新红包
             $bonus_val = $user_bonus->bonus_value();
             Model('bonus_type')->edit(array('type_id' => $type_id),
                 array('binded_num' => array('exp', 'binded_num+1'),

+ 2 - 1
helper/bonus/sender.php

@@ -30,7 +30,8 @@ class sender
         }
 
         if(intval($param['share_id']) <= 0) {
-            $param['share_id'] = bonus_share::instance()->get();
+            $share = bonus_share::instance()->get();
+            $param['share_id'] = $share['share_id'];
         }
         $share_id = intval($param['share_id']);
 

+ 3 - 3
helper/bonus/type.php

@@ -214,13 +214,13 @@ class type
         return $amount / 100;
     }
     public function bonus_rate() {
-        return intval($this->mParamer['bonus_rate']);
+        return intval($this->mParam['bonus_rate']);
     }
     // 为了兼容老版本,提供设置红包折扣率接口
     public function set_rate($rate)
     {
-        if(empty($rate) && $rate > 0) {
-            $this->mParamer['bonus_rate'] = intval($rate);
+        if(!empty($rate) && intval($rate) > 0) {
+            $this->mParam['bonus_rate'] = intval($rate);
         }
     }
     public function share_id() {

+ 4 - 12
helper/bonus/util.php

@@ -10,15 +10,7 @@ namespace bonus;
 
 function make_sn()
 {
-    if(isset($_SESSION['member_id']) && !empty((int) $_SESSION['member_id'])) {
-        return mt_rand(10,99)
-        . sprintf('%010d',time() - 946656000)
-        . sprintf('%03d', (float) microtime() * 1000)
-        . sprintf('%03d', (int) $_SESSION['member_id'] % 1000);
-    } else {
-        return mt_rand(10,99)
-        . sprintf('%010d',time() - 946656000)
-        . sprintf('%03d', (float) microtime() * 1000)
-        . sprintf('%03d', mt_rand(100,999));
-    }
-}
+    return mt_rand(10,99)
+        . sprintf('%010d',time())
+        . sprintf('%06d', (float) microtime() * 1000000);
+}

+ 2 - 2
helper/bonus/witholder.php

@@ -79,8 +79,8 @@ class witholder
         foreach ($bounses as $bonus)
         {
             if($bonus_sn == $bonus->bonus_sn()) {
-                $left = $bonus->remain_amount() * 100 + 0.5;
-                $money = $money * 100 + 0.5;
+                $left  = intval($bonus->remain_amount() * 100 + 0.5);
+                $money = intval($money * 100 + 0.5);
                 $left = $left - $money;
                 $left = $left >= 0 ? $left / 100 : 0.00;
 

+ 1 - 8
helper/bonus_helper.php

@@ -78,14 +78,7 @@ class bonus_helper
         return \bonus\type::crate_by_input($param);
     }
 
-    static public function make_bonus($param)
-    {
-        return false;
-//        $ret = \bonus\factory::make_bonus($param);
-//        return $ret;
-    }
-
-    static public function make_bonusex($param,$rate_moneys)
+    static public function make_bonus($param, $rate_moneys)
     {
         $ret = \bonus\factory::make_bonus($param,$rate_moneys);
         return $ret;

+ 4 - 4
helper/predeposit_helper.php

@@ -404,7 +404,7 @@ class predeposit_helper
 
     public function make_bonusone($param,$rate_moneys,$bonus_sn)
     {
-        $result = bonus_helper::make_bonusex($param,$rate_moneys);
+        $result = bonus_helper::make_bonus($param,$rate_moneys);
         if($result == false) return false;
 
         foreach ($rate_moneys as $item) {
@@ -426,7 +426,7 @@ class predeposit_helper
 
     public function make_bonus($param,$rate_moneys)
     {
-        $result = bonus_helper::make_bonusex($param,$rate_moneys);
+        $result = bonus_helper::make_bonus($param,$rate_moneys);
         if($result == false) return false;
 
         $rates = [];
@@ -487,7 +487,7 @@ class predeposit_helper
         $item['rate'] = $bonus->bonus_rate();
         $rate_moneys[] = $item;
 
-        $result = bonus_helper::make_bonusex($param,$rate_moneys);
+        $result = bonus_helper::make_bonus($param,$rate_moneys);
         if($result == false) {
             return false;
         }
@@ -504,7 +504,7 @@ class predeposit_helper
 
     public function admin_make_bonus($param,$rate_moneys)
     {
-        return bonus_helper::make_bonusex($param,$rate_moneys);
+        return bonus_helper::make_bonus($param,$rate_moneys);
     }
 
     public function bonus_expire($bouns)

+ 5 - 5
mobile/control/member_bonus.php

@@ -14,7 +14,6 @@ require_once (BASE_ROOT_PATH . '/helper/ranklist_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/special_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus_share.php');
 
-
 class member_bonusControl extends mbMemberControl
 {
     private $mPred;
@@ -52,6 +51,7 @@ class member_bonusControl extends mbMemberControl
         } else {
             $result['bonus_rate'] = $rates_money;
         }
+        $result['avatar'] = session_helper::avatar();
 
         return self::outsuccess($result);
     }
@@ -101,7 +101,7 @@ class member_bonusControl extends mbMemberControl
             $img_url = $share['img_url'];
 
             return self::outsuccess(array('type_sn' => $ret, 'url' => "{$url}",
-                'title' => $title,'sub_title' => $sub_title,'img_url' => $img_url,'avatar' => session_helper::avatar()));
+                'title' => $title,'sub_title' => $sub_title,'img_url' => $img_url));
         }
     }
 
@@ -125,8 +125,8 @@ class member_bonusControl extends mbMemberControl
         $param['sender_name'] = session_helper::nickname();
         $type = bonus_helper::create_type($param);
 
-        $type_amount  = $type->getTotal_amount() * 100 + 0.5;
-        $bonus_amount = $bonus->remain_amount()  * 100 + 0.5;
+        $type_amount  = intval($type->getTotal_amount() * 100 + 0.5);
+        $bonus_amount = intval($bonus->remain_amount()  * 100 + 0.5);
         if($type_amount > $bonus_amount) {
             return self::outerr(errcode::ErrBonusNotEnough,'该红包余额不足发送红包');
         }
@@ -154,7 +154,7 @@ class member_bonusControl extends mbMemberControl
             $img_url = $share['img_url'];
 
             return self::outsuccess(array('type_sn' => $ret, 'url' => "{$url}",
-                'title' => $title,'sub_title' => $sub_title,'img_url' => $img_url,'avatar' => session_helper::avatar()));
+                'title' => $title,'sub_title' => $sub_title,'img_url' => $img_url));
         }
     }
 

+ 36 - 0
test/bonus_helperTest.php

@@ -126,6 +126,42 @@ class bonus_helperTest extends PHPUnit_Framework_TestCase
 
     }
 
+//    private function make_sn($count)
+//    {
+//        return mt_rand(10000,99999)
+//        . sprintf('%04d',(time() - 946656000)/1000000)
+//        . sprintf('%06d', (float) microtime() * 1000000)
+//        . sprintf('%03d', $count++);
+//    }
+
+    private function make_sn()
+    {
+        return mt_rand(10,99)
+        . sprintf('%010d',time())
+        . sprintf('%06d', (float) microtime() * 1000000);
+
+    }
+
+    public function testMakeSn()
+    {
+//        $t = (float) microtime();
+//        $x = sprintf('%03d', (float) microtime() * 1000);
+        $sns = [];
+        for ($index = 0; $index < 100000; $index++) {
+            $sns[] = $this->make_sn();
+        }
+        $sns = array_unique($sns);
+        $count = count($sns);
+
+//        $txxx = [];
+//        for ($index = 0; $index < 1000; $index++) {
+//            $x1 = (float) microtime();
+//            $txxx[] = intval($x1 * 1000000);
+//        }
+//        $txxx = array_unique($txxx);
+//        $XYYY = count($txxx);
+    }
+
     public function testAndroidUrl()
     {
         $url = BASE_SITE_URL . '/data/upload/package/xmmz_release.apk';