瀏覽代碼

add to local

stanley-king 8 年之前
父節點
當前提交
35ef8e294d

+ 2 - 4
data/model/user_bonus.model.php

@@ -248,8 +248,7 @@ class user_bonusModel extends Model
         $cond['notify_time'] = array(array('eq',0), array('elt',$cur_time - $period_secs),'or');
         $cond['expired'] = 0;
         $cond['remain_amount'] = array('gt','0.00');
-
-        $ret = $this->getBonusList($cond,'*');
+        $ret = $this->getBonusList($cond,'*','usable_time asc',0,0,1000);
         if(empty($ret)) {
             return false;
         } else {
@@ -260,8 +259,7 @@ class user_bonusModel extends Model
     public function getExpired()
     {
         $cond = array('expired' => 0, 'remain_amount' => array('gt','0.00'),'bonus_status' => 3,'usable_time' => array('elt',time()));
-        $ret = $this->getBonusList($cond,"*");
-
+        $ret = $this->getBonusList($cond,'*','usable_time asc',0,0,1000);
         return $ret;
     }
 }

+ 7 - 1
helper/bonus/type.php

@@ -115,6 +115,9 @@ class type
     public function isRandomAmount() {
         return (intval($this->mParam['send_type']) == self::random_amount);
     }
+    public function send_type() {
+        return intval($this->mParam['send_type']);
+    }
     public function getType_id() {
         return intval($this->mParam['type_id']);
     }
@@ -136,6 +139,9 @@ class type
     public function get_param() {
         return $this->mParam;
     }
+    public function bless() {
+        return $this->mParam['type_bless'];
+    }
     public function sender_name() {
         return $this->mParam['sender_name'];
     }
@@ -224,7 +230,7 @@ class type
         return new type($paramer,self::create_type);
     }
 
-    static public function crate_by_paramer($paramer)
+    static public function create_by_paramer($paramer)
     {
         return new type($paramer,self::load_type);
     }

+ 1 - 1
helper/bonus_helper.php

@@ -30,7 +30,7 @@ class bonus_helper
 
     static public function filter_type($type_info)
     {
-        $type = \bonus\type::crate_by_paramer($type_info);
+        $type = \bonus\type::create_by_paramer($type_info);
         $fileds = 'type_sn,type_bless,send_type,sender_name,total_amount,remain_amount,total_num,max_amount,bonus_rate,grabed_num,binded_num,send_start_date,send_end_date,binded_over,binded_period,grab_lastime,make_type';
         $ret = array();
         field_helper::copy_column($ret,$type_info,$fileds);

+ 30 - 4
helper/notify_helper.php

@@ -9,6 +9,7 @@
 require_once (BASE_ROOT_PATH . '/helper/account_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/predeposit_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/push_helper.php');
 
 
 class notify_helper
@@ -25,15 +26,29 @@ class notify_helper
         $items = $mod_bonus->getNeedWarn($warn_remain_days, $warn_interval_days);
         if($items == false) return;
 
+        $member_amount = [];
+        $member_day = [];
         $ids = [];
-        foreach ($items as $key => $val) {
+        foreach ($items as $key => $val)
+        {
             $bonus = bonus\user_bonus::create_by_param($val);
             $leftsecs = $bonus->usable_time() - time();
             $remain_days = self::secs_days($leftsecs);
             $amount = $bonus->remain_amount();
-            push_helper::notice_expring($bonus->user_id(),$amount,$remain_days);
+
+            if(array_key_exists($bonus->user_id(),$member_amount) == false) {
+                $member_amount[$bonus->user_id()] = $amount;
+                $member_day[$bonus->user_id()] = $remain_days;
+            } else {
+                $member_amount[$bonus->user_id()] += $amount;
+            }
+
             $ids[] = $bonus->bonus_id();
         }
+        foreach ($member_amount as $member_id => $amount) {
+            $remain_days = $member_day[$member_id];
+            push_helper::notice_expring($member_id,$amount,$remain_days);
+        }
 
         if (!empty($ids)) {
             $mod_bonus->edit(array('bonus_id' => array('in', $ids)),array("notify_time" => time()));
@@ -46,6 +61,7 @@ class notify_helper
         $items = $mod_bonus->getExpired();
 
         $ids = array();
+        $member_amount = [];
         foreach ($items as $key => $val) {
             $bonus = bonus\user_bonus::create_by_param($val);
             $user_id = $bonus->user_id();
@@ -53,8 +69,19 @@ class notify_helper
 
             $pred = new predeposit_helper($user_id);
             $pred->bonus_expire($val);
-            push_helper::notice_expired($user_id,$amount);
             array_push($ids,$bonus->bonus_id());
+
+            if(array_key_exists($bonus->user_id(),$member_amount) == false) {
+                $member_amount[$bonus->user_id()] = $amount;
+            } else {
+                $member_amount[$bonus->user_id()] += $amount;
+            }
+        }
+
+        foreach ($member_amount as $member_id => $amount) {
+            push_helper::notice_expired($member_id,$amount);
+            $pred = new predeposit_helper($member_id);
+            $pred->inc_rate_version();
         }
 
         if (!empty($ids)) {
@@ -78,7 +105,6 @@ class notify_helper
             try
             {
                 $pred = new predeposit_helper($type['sender_id']);
-
                 Model::beginTransaction();
                 $bonus_type->edit(array('type_id' =>$type['type_id']),array('is_refund' => 1,'refund_time' => time()));
                 if ($bonus_type->affected_rows() <= 0) {

+ 1 - 1
helper/predeposit_helper.php

@@ -511,7 +511,7 @@ class predeposit_helper
 
     public function bonus_refund($bonus_type)
     {
-        $types = bonus\type::crate_by_paramer($bonus_type);
+        $types = bonus\type::create_by_paramer($bonus_type);
         $log_data = array();
         $log_data['member_id']   = $types->sender_id();
         $log_data['member_name'] = $types->sender_name();

+ 2 - 2
helper/special_helper.php

@@ -224,10 +224,10 @@ class special_helper
         $result['item_title'] = $title;
         $result['item_type'] = 'home_type';
 
-        foreach ($type_infos as $bonus) {
+        foreach ($type_infos as $type) {
             $item['image'] = "";
             $item['type'] = 'bonus_type';
-            $item['data'] = $bonus['type_sn'];
+            $item['data'] = $type['type_sn'];
             $item['title'] = '';
 
             $result['items'][] = $item;

+ 14 - 14
mobile/control/bonusex.php

@@ -58,7 +58,7 @@ class bonusexControl extends mobileControl
             return self::outerr(errcode::ErrBonus,"无此红包.");
         }
         $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
-        $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+        $type = \bonus\type::create_by_paramer($type_infos['type_info']);
 
         $isMineType = $this->isMineType($type);
         if($type->isStart() == false) {
@@ -128,7 +128,7 @@ class bonusexControl extends mobileControl
         }
         $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
 
-        $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+        $type = \bonus\type::create_by_paramer($type_infos['type_info']);
         if($type->isStart() == false) {
             return self::outsuccess(array('type_info' => $type_info),"bonus/unstart");
         }
@@ -154,7 +154,7 @@ class bonusexControl extends mobileControl
         }
         $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
 
-        $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+        $type = \bonus\type::create_by_paramer($type_infos['type_info']);
         if($type->isStart() == false) {
             return self::outsuccess(array('type_info' => $type_info),"bonus/unstart");
         }
@@ -245,7 +245,7 @@ class bonusexControl extends mobileControl
 
         $type_sn = $bonus_obj->type_sn();
         $type_infos = bonus_helper::get_typeinfo($type_sn);
-        $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+        $type = \bonus\type::create_by_paramer($type_infos['type_info']);
         if($type->isEnd()) {
             return self::outsuccess(array('type_info' => $type_infos['type_info']),"bonus/end");
         }
@@ -314,7 +314,7 @@ class bonusexControl extends mobileControl
         {
             $type_sn = $bonus_obj->type_sn();
             $type_infos = bonus_helper::get_typeinfo($type_sn);
-            $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+            $type = \bonus\type::create_by_paramer($type_infos['type_info']);
             if($type->isEnd()) {
                 return self::outsuccess(errcode::ErrBonus,"该红包已经过期,不能再摇啦~");
             }
@@ -373,7 +373,7 @@ class bonusexControl extends mobileControl
 function bonus_output_unstart($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
 
     $local_tm = time();
     $start_tm = $type->get_start_time();
@@ -388,7 +388,7 @@ function bonus_output_unstart($output)
 function bonus_output_end($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
     $start_tm = $type->get_start_time();
     $end_time = $type->get_end_time();
 
@@ -403,7 +403,7 @@ function bonus_output_end($output)
 function bonus_output_grabinfo($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
 
     if($type->binded_over()) {
         echo("<p>手慢了,红包被领完了</p>");
@@ -431,7 +431,7 @@ function bonus_output_sender($output)
 {
     $type_info = $output['type_info'];
     if(!empty($type_info)) {
-        $type = \bonus\type::crate_by_paramer($type_info);
+        $type = \bonus\type::create_by_paramer($type_info);
         echo($type->sender_name());
     } else {
         echo("");
@@ -441,7 +441,7 @@ function bonus_output_sender($output)
 function bonus_output_openurl($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
     $type_sn = $type->getType_sn();
 
     $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}";
@@ -451,7 +451,7 @@ function bonus_output_openurl($output)
 function bonus_output_detailurl($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
     $type_sn = $type->getType_sn();
 
     $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&type_sn={$type_sn}&client_type=wap";
@@ -461,7 +461,7 @@ function bonus_output_detailurl($output)
 function bonus_output_graburl($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
     $type_sn = $type->getType_sn();
     $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=grab&client_type=wap&type_sn={$type_sn}";
     return $url;
@@ -471,7 +471,7 @@ function bonus_output_type($output)
 {
     echo '<p class="p p_name" style="color:#454545">';
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
     echo($type_info['sender_name'] . "的红包");
     if($type->isRandomAmount()) {
         echo '<s class="icon_pin"></s>';
@@ -564,7 +564,7 @@ function bonus_out_bindedtime($period)
 function bonus_output_bindedinfo($output)
 {
     $type_info = $output['type_info'];
-    $type = \bonus\type::crate_by_paramer($type_info);
+    $type = \bonus\type::create_by_paramer($type_info);
 
     echo('<div class="prompt text_left">');
 

+ 47 - 4
mobile/control/member_bonus.php

@@ -167,7 +167,7 @@ class member_bonusControl extends mbMemberControl
 
     public function send_listexOp()
     {
-        $type_infos = $this->send_list($pages);
+        $type_infos = $this->send_listex($pages);
         if($this->page_no() == 1) {
             $tip_blocks = $this->tip_block('send',count($type_infos));
         } else {
@@ -195,7 +195,7 @@ class member_bonusControl extends mbMemberControl
                 }
             }
 
-            $block = special_helper::format_bonus($type_infos);
+            $block = special_helper::format_type($type_infos);
             $blocks[] = $block;
 
             return self::outsuccess(array('special_list' => $blocks,
@@ -208,6 +208,49 @@ class member_bonusControl extends mbMemberControl
         }
     }
 
+    private function send_listex(&$pages)
+    {
+        $mod_type = Model('bonus_type');
+        $cond = array('sender_id' => $_SESSION['member_id'],'make_type' => bonus\type::MakeSendType);
+        $count = $mod_type->getTypeCount($cond);
+        if($count == 0) {
+            $pages = 0;
+            return null;
+        }
+
+        $items = $mod_type->getTypeList($cond,$this->page_size(),'*','type_id desc');
+        $type_infos = [];
+        foreach($items as $val)
+        {
+            $type = \bonus\type::create_by_paramer($val);
+
+            $item["type_sn"] = $type->getType_sn();
+            $item["type_bless"] = $type->bless();
+            $item["send_type"] = $type->send_type();
+            $item["sender_name"] = $type->sender_name();
+            $item["total_amount"] = $type->getTotal_amount();
+            $item["total_num"] = $type->getTotal_num();
+            $item["remain_amount"] = $type->remain_amount();
+            $item["bonus_rate"]  =  $type->bonus_rate();
+            $item["binded_num"] = $type->binded_num();
+            $item["send_start_date"] = $type->get_start_time();
+            $item["send_end_date"] = $type->get_end_time();
+            $item["make_type"] = $type->make_type();
+            $item["is_end"] = $type->isEnd();
+
+            $type_sn = $type->getType_sn();
+            $open_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn={$type_sn}";
+            $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
+
+            $item["open_url"] = $open_url;
+            $item["detail_url"] = $detail_url;
+            $type_infos[] = $item;
+        }
+
+        $pages = $this->pages($count);
+        return $type_infos;
+    }
+
     private function send_list(&$pages)
     {
         $mod_type = Model('bonus_type');
@@ -392,7 +435,7 @@ class member_bonusControl extends mbMemberControl
         $types = array();
         $type_items = Model('bonus_type')->getTypeList(array('type_id' => array('in',$type_ids)));
         foreach ($type_items as $val) {
-            $type = bonus\type::crate_by_paramer($val);
+            $type = bonus\type::create_by_paramer($val);
             $types[$type->getType_id()] = $type;
         }
 
@@ -485,7 +528,7 @@ class member_bonusControl extends mbMemberControl
                 $user_bonus = bonus\user_bonus::create_by_param($bonus);
                 $type_info = bonus_helper::get_typeinfo($user_bonus->type_sn());
                 $type_info = $type_info['type_info'];
-                $type = bonus\type::crate_by_paramer($type_info);
+                $type = bonus\type::create_by_paramer($type_info);
 
                 $item = array();
                 if($_SESSION['member_id'] == $user_bonus->user_id()) {

+ 1 - 1
mobile/templates/default/bonus/open.php

@@ -20,7 +20,7 @@
                     <p class="name"><?php echo($output['type_info']['sender_name']); ?></p>
                     <p class="msg"><?php
                         $type_info = $output['type_info'];
-                        $type = \bonus\type::crate_by_paramer($type_info);
+                        $type = \bonus\type::create_by_paramer($type_info);
                         if($type->isRandomAmount()) {
                             $str = '发了一个红包,金额随机';
                         } else {