Просмотр исходного кода

Merge branch 'bonus_timeout' into sess_0306

stanley-king 9 лет назад
Родитель
Сommit
b0c60c8539

+ 23 - 0
data/resource/mobile/bonus/css/common.css

@@ -178,4 +178,27 @@ a {
 }
 .gold_coin{
     -webkit-animation: coin 1s ease-out ;
+}
+.time_over {
+    margin-top: 75px;
+    font-size: 1.4rem;
+    line-height: 1.8rem;
+}
+.bottom_pro {
+    position: absolute;
+    bottom: 8%;
+    left: 0;
+    width: 100%;
+    color: #fff;
+    font-size: 10px;
+    line-height:1.1rem;
+}
+.icon_logo {
+    display: inline-block;
+    width: 0.8rem;
+    height: 0.8rem;
+    background: url("../imgaes/icon_logo.png") no-repeat;
+    background-size: 100% 100%;
+    vertical-align: middle;
+    margin-right: 0.3rem;
 }

+ 7 - 3
helper/bonus/type.php

@@ -29,7 +29,7 @@ class type
     const def_maxamount = 200.00;
     const def_minnum = 1;
 
-    const def_period_day = 10;
+    const def_period_day = 1;
 //    private $type_id;      // '表ID\n',
 //    private $type_sn;      // '对应的唯一识别号码',
 //    private $type_name;      // '红包名称',
@@ -61,7 +61,8 @@ class type
         }
         $this->mParam['type_name'] = sprintf("%s发的红包.",$this->mParam['sender_name']);
         $this->mParam['send_start_date'] = time();
-        $this->mParam['send_end_date'] = time() + self::def_period_day * 60 * 60 * 24;
+        //$this->mParam['send_end_date'] = time() + self::def_period_day * 60 * 60 * 24;
+        $this->mParam['send_end_date'] = time() + 5 * 60;
 
         if($this->isFixedAmount()) {
             $this->mParam['min_amount'] = 0;
@@ -121,6 +122,9 @@ class type
     public function sender_name() {
         return $this->mParam['sender_name'];
     }
+    public function sender_id() {
+        return $this->mParam['sender_id'];
+    }
     public function isStart() {
         $start_time = intval($this->mParam['send_start_date']);
         if($start_time === 0) {
@@ -139,7 +143,7 @@ class type
             return false;
         }
         else {
-            return time() > $end_time;
+            return time() >= $end_time;
         }
     }
     public function binded_num() {

+ 4 - 3
helper/bonus/user_bonus.php

@@ -31,7 +31,9 @@ class user_bonus
     public function isBinded() {
         return (intval($this->mParamer['bonus_status']) >= 2);
     }
-    public function isGrabed() {
+    public function grab_time()
+    {
+        return intval($this->mParamer['grab_time']);
     }
     public function bonus_sn() {
         return $this->mParamer['bonus_sn'];
@@ -46,7 +48,6 @@ class user_bonus
         $val = intval(floatval($this->mParamer['bonus_value']) * 100 + 0.5);
         return floatval($val) / 100;
     }
-
     public function type_sn() {
         return $this->mParamer['type_sn'];
     }
@@ -76,7 +77,7 @@ class user_bonus
         $get_time = $this->mParamer['get_time'];
         return strftime("%m-%d %H:%M",$get_time);
     }
-
+    
     static public function create_by_param($param) {
         return new user_bonus($param);
     }

+ 66 - 11
mobile/control/bonusex.php

@@ -38,9 +38,6 @@ class bonusexControl extends mobileControl
         }
     }
 
-    //打开红包页面:
-    //1:如果已经被抢光,显示已经被抢光界面
-    //2:
     public function openOp()
     {
         if(!isset($_GET['type_sn']) || empty($_GET['type_sn'])) {
@@ -70,14 +67,24 @@ class bonusexControl extends mobileControl
             $data = array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info);
             if($bonus->isBinded()) {
                 return self::outsuccess($data,"bonus/content");
-            } else {
-                return self::outsuccess($data,"bonus/bind");
+            }
+            else
+            {
+                $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+                if($type->isEnd()) {
+                    return self::outsuccess(NULL,"bonus/end");
+                } else {
+                    return self::outsuccess($data,"bonus/bind");
+                }
             }
         }
         else
-        {
+        { //我没有抢过的情况
             $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
-            if($type->binded_over()) {
+            if($type->isEnd()) {
+                return self::outsuccess(NULL,"bonus/end");
+            }
+            else if($type->binded_over()) {
                 return self::outsuccess(array('type_info' => $type_info,'msg' => "手慢了,红包派完了"),"bonus/over");
             } else {
                 return self::outsuccess(array('type_info' => $type_info),"bonus/open");
@@ -116,17 +123,21 @@ class bonusexControl extends mobileControl
         if(empty($type_infos)) {
             return self::outerr(errcode::ErrBonus,"无此红包.");
         }
-        $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
 
+        $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
         $mine_bonus = bonus_helper::get_mine_by_typesn($type_sn);
         if($mine_bonus != false)
         { //显示我抢到的红包,按照状态进行判断
             $bonus_obj = \bonus\user_bonus::create_by_param($mine_bonus);
             $mine_bonus = bonus_helper::filter_bonus($mine_bonus);
+            $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
 
             if($bonus_obj->isBinded()) {
                 return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info),"bonus/content");
             }
+            elseif($type->isEnd()) {
+                 return self::outsuccess(array('type_info' => $type_info),"bonus/end");
+            }
             else
             {
                 if(user_helper::isVerfiyMobile())
@@ -146,11 +157,14 @@ class bonusexControl extends mobileControl
         else
         {
             $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
-            if($type->binded_over()) {
+            if($type->isEnd()) {
+                return self::outsuccess(array('type_info' => $type_info),"bonus/end");
+            }
+            elseif($type->binded_over()) {
                 return self::outsuccess(array('type_info' => $type_info,'msg' => "手慢了,红包派完了"),"bonus/over");
             }
             else
-            {//从库里抢一个红包逻辑
+            {
                 $bonus = bonus_helper::grab_bonus($type_sn);
                 if($bonus == false) {
                     return self::outsuccess(array('type_info' => $type_info,'msg' => "手慢了,红包派完了"),"bonus/over");
@@ -198,7 +212,13 @@ class bonusexControl extends mobileControl
             return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info),"bonus/content");
         }
 
-        if(user_helper::isVerfiyMobile()) {
+        $type_sn = $bonus_obj->type_sn();
+        $type_infos = bonus_helper::get_typeinfo($type_sn);
+        $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+        if($type->isEnd()) {
+            return self::outsuccess(array('type_info' => $type_infos['type_info']),"bonus/end");
+        }
+        elseif(user_helper::isVerfiyMobile()) {
             $mobile = user_helper::cur_mobile();
         }
         else
@@ -282,6 +302,17 @@ function bonus_output_grabinfo($output)
     }
 }
 
+function bonus_output_sender($output)
+{
+    $type_info = $output['type_info'];
+    if(!empty($type_info)) {
+        $type = \bonus\type::crate_by_paramer($type_info);
+        return $type->sender_name();
+    } else {
+        return "";
+    }
+}
+
 function bonus_output_openurl($output)
 {
     $type_info = $output['type_info'];
@@ -348,6 +379,30 @@ function bonus_output_mine($output)
     }
 }
 
+function bonus_out_bindtimeout($output)
+{
+    $mine_bonus = $output['mine_bonus'];
+    if(!empty($mine_bonus))
+    {
+        $bonus = \bonus\user_bonus::create_by_param($mine_bonus);
+        $grab_time = $bonus->grab_time();
+        $time_out = 600;
+
+        if($grab_time > 0)
+        {
+            if($grab_time + $time_out <= time() - 60) {
+                return '您的红包随时可能被抢走,抓紧领啊~';
+            } else {
+                $left_time = $grab_time + $time_out - time();
+                $mins = $left_time / 60;
+                return "请{$mins}分钟内,输入手机号领取红包";
+            }
+        }
+    }
+
+    return '';
+}
+
 function bonus_out_bindedtime($period)
 {
     $min  = 60;

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

@@ -25,7 +25,7 @@
 
     <div class="linqu_box" id="bind_link">
         <div>
-            <p class="prompt tel_pro">请十分钟内,输入手机号领取红包</p>
+            <p class="prompt tel_pro"><?php bonus_out_bindtimeout($output); ?></p>
         </div>
         <div class="tel_box">
             <div class="tel">

+ 32 - 0
mobile/templates/default/bonus/end.php

@@ -0,0 +1,32 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>熊猫美妆红包</title>
+    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
+    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/css/common.css"/>
+    <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js"></script>
+</head>
+
+<body>
+<div class="maincontent">
+    <div class="bg_position cloud_left"></div>
+    <div class="bg_position cloud_right"></div>
+    <div class="bg_position dot_left"></div>
+    <div class="bg_position dot_right"></div>
+    <div class="content center">
+        <div class="msg_box">
+            <p class="name"><?php bonus_output_sender($output); ?></p>
+        </div>
+        <div class="time_over">
+            <p>该红包已超过24小时。如已</p>
+            <p>领取,可在“我的红包”中查看</p>
+        </div>
+    </div>
+    <div class="bottom_pro center">
+        <p class="">独家运营70多个知名化妆品品牌的天猫官方旗舰店</p>
+        <p><s class="icon_logo"></s>丽人丽妆股份有限公司出品</p>
+    </div>
+</div>
+</body>
+</html>