Browse Source

modify show binded time

stanley-king 9 years atrás
parent
commit
58a19ad2df
2 changed files with 33 additions and 2 deletions
  1. 1 1
      data/model/bonus_type.model.php
  2. 32 1
      mobile/control/bonusex.php

+ 1 - 1
data/model/bonus_type.model.php

@@ -25,7 +25,7 @@ class bonus_typeModel extends Model
     }
     public function get($condition,$field='*')
     {
-        return $this->where($condition)->field($field)->select();
+        return $this->where($condition)->field($field)->order('type_id desc')->select();
     }
 
     public function save($data, &$id)

+ 32 - 1
mobile/control/bonusex.php

@@ -348,6 +348,37 @@ function bonus_output_mine($output)
     }
 }
 
+function bonus_out_bindedtime($period)
+{
+    $min = 60;
+    $hour = 3600;
+    $day = 24 * 3600;
+
+    $days = intval($period / $day);
+    $period = $period % $day;
+    $houres = intval($period / $hour);
+    $period = $period % $hour;
+    $mins = intval($period / $min);
+
+    if($period % $min > 0) {
+        $mins += 1;
+    }
+
+    $time_str = '';
+    if($days > 0) {
+        $time_str .= "{$days}天";
+    }
+    if($houres > 0) {
+        $time_str .= "{$houres}小时";
+    }
+    if($mins > 0) {
+        $time_str .= "{$mins}分钟";
+    }
+
+    $time_str .= "领完.";
+    return $time_str;
+}
+
 function bonus_output_bindedinfo($output)
 {
     $type_info = $output['type_info'];
@@ -359,7 +390,7 @@ function bonus_output_bindedinfo($output)
         $prompt = "{$type->getTotal_num()}个红包";
         $prompt .= ",";
         $period = $type_info['binded_period'];
-        $prompt .= "{$period}分钟领完.";
+        $prompt .= bonus_out_bindedtime($period);
     } else {
         $prompt = "领取 {$type->binded_num()}/{$type->getTotal_num()}";
     }