stanley-king 7 роки тому
батько
коміт
e438d0e32e
5 змінених файлів з 1376 додано та 11 видалено
  1. 8 0
      .gitignore
  2. 1281 0
      data/mobile/lrlz_staff.php
  3. 69 0
      helper/bonus/manager.php
  4. 10 0
      helper/bonus_helper.php
  5. 8 11
      test/bonus_helperTest.php

+ 8 - 0
.gitignore

@@ -1,3 +1,11 @@
 data/upload
 php_errors.log
 data/log/20170824.log
+/logs/
+/hfive/
+/data/log/
+/data/Download/
+/data/config/
+/data/session/
+/installx/
+/data/upload/

Різницю між файлами не показано, бо вона завелика
+ 1281 - 0
data/mobile/lrlz_staff.php


+ 69 - 0
helper/bonus/manager.php

@@ -290,6 +290,75 @@ class manager
         }
     }
 
+    public function send_mobile($type_sn, $mobiles)
+    {
+        sort($mobiles);
+        $mod_bonus = Model('user_bonus');
+
+        $items = $mod_bonus->getBonusList(array('user_mobile' => array('in',$mobiles),'type_sn' => $type_sn),'*','',0,0,0,'',true);
+        $ret = [];
+        foreach ($items as $item)
+        {
+            $user_mobile = $item['user_mobile'];
+            if(algorithm::binary_search($user_mobile,$mobiles) != false)
+            {
+                $pos = algorithm::lower_bonud($mobiles,$user_mobile);
+                algorithm::array_erase($mobiles,$pos);
+                $ret[] = $item;
+            }
+        }
+
+        if(!empty($mobiles))
+        {
+            $count = count($mobiles);
+            $items = $mod_bonus->getBonusList(array('bonus_status' => 0,'type_sn' => $type_sn),'*','',0,0,count($mobiles),'',true);
+            if($count != count($items)) {
+                return false;
+            }
+
+            $mod_member = Model('member');
+
+            $index = 0;
+            $bonus_values = 0.00;
+
+            $bind_num = 0;
+            foreach ($items as &$bonus)
+            {
+                $user_mobile = $mobiles[$index];
+                $infos = $mod_member->getMemberInfo(['member_mobile' => $user_mobile]);
+                if(!empty($infos)) {
+                    $minfo = new member_info($infos);
+                    $bonus['user_id'] = $user_mobile;
+                    $bonus['user_mobile'] = $minfo->mobile();
+                    $bonus['user_name'] = $minfo->nickname();
+                    $bonus['grab_time'] = time();
+                    $bonus['get_time'] = time();
+                    $bonus['bonus_status'] = 2;
+                    $bind_num++;
+                    $bonus_values += $bonus['bonus_value'];
+                } else {
+                    $bonus['user_mobile'] = $user_mobile;
+                    $bonus['grab_time'] = time();
+                    $bonus['bonus_status'] = 1;
+                }
+
+                ++$index;
+                $ret[] = $bonus;
+            }
+
+            $mod_bonus->replaceAll($items);
+            Model('bonus_type')->edit(array('type_sn' => $type_sn),
+                array('binded_num' => array('exp', "binded_num+{$bind_num}"),
+                    'grabed_num' => array('exp', "grabed_num+{$count}"),
+                    'remain_amount' => array('exp', "remain_amount-" . "{$bonus_values}")));
+            dcache($type_sn,self::type_prefix);
+
+            return $ret;
+        } else {
+            return false;
+        }
+    }
+
     public function bind_bonus($bonus_sn,$session_id,$mobile,&$new_bonus_sn)
     {
         $new_bonus_sn = $bonus_sn;

+ 10 - 0
helper/bonus_helper.php

@@ -293,6 +293,16 @@ class bonus_helper
             return false;
         }
     }
+    static public function send_mobile($type_sn, $mobiles)
+    {
+        try
+        {
+            $manager = new \bonus\manager();
+            return $manager->send_mobile($type_sn,$mobiles);
+        } catch (Exception $ex) {
+            return false;
+        }
+    }
     static public function get_share($share_id = 0) {
         return \bonus\open_sharer::instance()->get($share_id);
     }

+ 8 - 11
test/bonus_helperTest.php

@@ -13,10 +13,9 @@ require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/bonus/witholder.php');
 require_once(BASE_ROOT_PATH . '/helper/notify_helper.php');
+require_once(BASE_ROOT_PATH . '/data/mobile/lrlz_staff.php');
 
-
-
-class bonus_helperTest extends PHPUnit_Framework_TestCase
+class TestBonus extends PHPUnit_Framework_TestCase
 {
     public static function setUpBeforeClass()
     {
@@ -163,14 +162,12 @@ class bonus_helperTest extends PHPUnit_Framework_TestCase
         }
         $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 testStaff()
+    {
+        $staffs  = lrlz_staff();
+        $type_sn = '36221506503801666595';
+        bonus_helper::send_mobile($type_sn,$staffs);
     }
 
     public function testAndroidUrl()