stanley-king 9 лет назад
Родитель
Сommit
5b61c0e462
52 измененных файлов с 2392 добавлено и 217 удалено
  1. 13 12
      core/framework/db/mysqli.php
  2. 6 0
      core/framework/libraries/model.php
  3. 0 2
      data/logic/buy.logic.php
  4. 77 22
      data/model/user_bonus.model.php
  5. 403 0
      data/resource/mobile/bonus/css/base.css
  6. 160 0
      data/resource/mobile/bonus/css/bindtel.css
  7. 50 0
      data/resource/mobile/bonus/css/bomb.css
  8. 117 0
      data/resource/mobile/bonus/css/common.css
  9. 71 0
      data/resource/mobile/bonus/css/index_commcon.css
  10. 60 0
      data/resource/mobile/bonus/css/over.css
  11. 127 0
      data/resource/mobile/bonus/css/success.css
  12. BIN
      data/resource/mobile/bonus/image/bag_head.png
  13. BIN
      data/resource/mobile/bonus/image/bomb_bg.png
  14. BIN
      data/resource/mobile/bonus/image/close.png
  15. BIN
      data/resource/mobile/bonus/image/content.png
  16. BIN
      data/resource/mobile/bonus/image/down.png
  17. BIN
      data/resource/mobile/bonus/image/foot_bg.png
  18. BIN
      data/resource/mobile/bonus/image/icon.png
  19. BIN
      data/resource/mobile/bonus/image/loadicon.png
  20. BIN
      data/resource/mobile/bonus/image/price_bg.png
  21. BIN
      data/resource/mobile/bonus/image/rcope.png
  22. BIN
      data/resource/mobile/bonus/image/rcope02.png
  23. BIN
      data/resource/mobile/bonus/image/tel_icon.png
  24. BIN
      data/resource/mobile/bonus/image/top_bg.png
  25. BIN
      data/resource/mobile/bonus/imgaes/cloud.png
  26. BIN
      data/resource/mobile/bonus/imgaes/icon_open.png
  27. BIN
      data/resource/mobile/bonus/imgaes/logo.png
  28. BIN
      data/resource/mobile/bonus/imgaes/top_bg.png
  29. 157 0
      data/resource/mobile/bonus/js/rem.js
  30. 165 0
      data/resource/mobile/bonus/js/tel.js
  31. 112 0
      data/resource/mobile/bonus/js/tel_bak.js
  32. 161 0
      data/resource/mobile/bonus/js/touch.js
  33. 2 0
      data/resource/mobile/bonus/js/zepto.js
  34. 1 0
      data/sales/home_goods.txt
  35. 4 3
      helper/bonus/factory.php
  36. 12 8
      helper/bonus/generator.php
  37. 17 7
      helper/bonus/grab.php
  38. 254 1
      helper/bonus/manager.php
  39. 7 0
      helper/bonus/type.php
  40. 64 1
      helper/bonus/user_bonus.php
  41. 62 83
      helper/bonus_helper.php
  42. 31 1
      helper/user_helper.php
  43. 1 1
      mobile/control/bonus.php
  44. 85 71
      mobile/control/bonusex.php
  45. 1 0
      mobile/control/config.php
  46. 0 1
      mobile/control/index.php
  47. 125 1
      mobile/control/member_bonus.php
  48. 2 0
      mobile/control/member_refund.php
  49. 1 1
      mobile/control/test.php
  50. 39 0
      mobile/templates/default/bonus/open.php
  51. 3 0
      mobile/util/errcode.php
  52. 2 2
      shop/control/h5_hb.php

+ 13 - 12
core/framework/db/mysqli.php

@@ -11,14 +11,13 @@ defined('InShopNC') or exit('Access Invalid!');
 
 require_once(BASE_CORE_PATH . '/framework/function/statistic_tm.php');
 
-
 class Db
 {
 	private static $link = array();
 	private static $iftransacte = true;
 
 	private static $connect_time = 0;
-	const reconnect_time = 1800;
+	const reconnect_time = 10;
 
 	private function __construct()
 	{
@@ -30,7 +29,8 @@ class Db
 	private static function connect($host = 'slave')
 	{
 		if((time() - self::$connect_time > self::reconnect_time) && defined('MOBILE_SERVER') && self::$connect_time > 0) {
-			self::closeLink();
+			self::closeLink('master');
+			self::closeLink('slave');
 		}
 
 		if (C('db.master') == C('db.slave'))
@@ -90,14 +90,11 @@ class Db
 		}
 	}
 
-	private static function closeLink()
+	private static function closeLink($host)
 	{
-		foreach(self::$link as $key => $db){
-			if(is_object($db)){
-				mysqli_close($db);
-			}
-
-			unset(self::$link[$key]);
+		if(is_object(self::$link[$host])){
+			self::$link[$host]->close();
+			self::$link[$host] = null;
 		}
 	}
 
@@ -215,6 +212,7 @@ class Db
 			}
 
 			//拼join on 语句
+			$tmp_sql = '';
 			for ($i=1;$i<count($tmp_table);$i++){
 				$tmp_sql .= $param['join_type'].' `'.DBPRE.$tmp_table[$i].'` as `'.$tmp_table[$i].'` ON '.$param['join_on'][$i-1].' ';
 			}
@@ -421,7 +419,10 @@ class Db
 	 */
 	public static function replace($table_name, $replace_array = array(), $host = 'master'){
 		self::connect($host);
-		if (!empty($replace_array)){
+		if (!empty($replace_array))
+		{
+			$string_field = '';
+			$string_value = '';
 			foreach ($replace_array as $k => $v){
 				$string_field .= " $k ,";
 				$string_value .= " '". $v ."',";
@@ -598,6 +599,6 @@ class Db
 
 	public static function affected_rows($host = 'master') {
 		self::connect($host);
-		return self::$link[$host]->mysqli_affected_rows();
+		return self::$link[$host]->affected_rows;
 	}
 }

+ 6 - 0
core/framework/libraries/model.php

@@ -381,6 +381,12 @@ class Model
         return $result;
     }
 
+    public function affected_rows()
+    {
+        return $this->db->affected_rows();
+
+    }
+
 	/**
 	 * 插入
 	 *

+ 0 - 2
data/logic/buy.logic.php

@@ -97,7 +97,6 @@ class buyLogic {
         $store_cart_list = $this->_getStoreCartList($cart_list);
 
         return callback(true, '', array('goods_list' => $goods_list, 'store_cart_list' => $store_cart_list));
-
     }
 
     /**
@@ -824,7 +823,6 @@ class buyLogic {
         //delete by stanley
         //$order_list = $this->_post_data;
 
-
         //使用充值卡支付
         if (!empty($this->_post_data['rcb_pay'])) {
             $order_list = $this->_logic_buy_1->rcbPay($this->_order_data['order_list'], $this->_post_data, $buyer_info);

+ 77 - 22
data/model/user_bonus.model.php

@@ -18,12 +18,35 @@ class user_bonusModel extends Model
     {
         parent::__construct('user_bonus');
     }
+
+    public function get($condition,$fields='*')
+    {
+        return $this->where($condition)->field($fields)->limit(false)->select();
+    }
+
+    public function lasted_binded($condition) {
+        $items = $this->where($condition)->field('get_time')->order('get_time desc')->limit(1)->select();
+        if(count($items) == 1) {
+            return $items[0]['get_time'];
+        } else {
+            return false;
+        }
+    }
+
+    //public function luckey
+
     public function add($datas) {
         return $this->insert($datas);
     }
 
+    public function getTypeBinded($condition,$fields = '*')
+    {
+        $condition['status'] = array('in',array(2,3));
+        return $this->where($condition)->field($fields)->limit(false)->select();
+    }
+
     public function getAllBind($mobile,$fields = '*') {
-        return  $this->where(array('user_mobile' => $mobile, 'status' => 2))->field($fields)->order('bonus_type_id')->select();
+        return  $this->where(array('user_mobile' => $mobile, 'status' => 2))->field($fields)->order('type_id')->select();
     }
 
     public function getStatus($bonus_sn) {
@@ -36,55 +59,87 @@ class user_bonusModel extends Model
     }
 
     private function getBind($mobile,$type_id,$fields = '*') {
-        return  $this->where(array('user_mobile' => $mobile, 'bonus_type_id' => $type_id,'status' => 2))->field($fields)->find();
+        return  $this->where(array('user_mobile' => $mobile, 'type_id' => $type_id,'status' => 2))->field($fields)->find();
     }
 
-    public function topuped($bonus_id)
+    public function edit($condition,$datas)
     {
-        return $this->where(array('bonus_id' => $bonus_id))->update(array('status' => 3));
+        return $this->where($condition)->update($datas);
     }
 
-    public function grab($type_id,$time_out,$mobile,$sess_id)
+    public function comment($bonus_id,$comment) {
+        return $this->where(array('bonus_id' => $bonus_id))->update(array('user_comment' => $comment));
+    }
+
+    //返回单个红包
+    public function grab($type_id,$time_out,$mobile,$sess_id,&$isNew)
     {
+        $isNew = false;
         try
         {
-            $fields = '*';//"bonus_id,bonus_sn,bonus_value,status";
+            $fields = '*';
+            //如果已经绑定手机
             if(!empty($mobile))
             {
-                $ret = $this->getBind($mobile,$type_id,$fields);
+                $bonus = $this->getBind($mobile,$type_id,$fields);
                 if(!empty($ret)) {
-                    return $ret;
+                    return $bonus;
                 }
             }
 
             $this->beginTransaction();
-            $ret = $this->where(array( 'bonus_type_id' => $type_id,'session_id' => $sess_id))->field($fields)->order('status,bonus_id')->limit(1)->find();
-            if(empty($ret))
+            $bonus = $this->where(array('type_id' => $type_id,'session_id' => $sess_id))->field($fields)->order('status,bonus_id')->limit(1)->find();
+            if(empty($bonus))
             {
-                $condition = array( 'bonus_type_id' => $type_id,
+                $condition = array( 'type_id' => $type_id,
                                     'status' => array('in', array(0,1)),
                                     'grab_time' => array('lt',time() - $time_out));
-                $ret = $this->where($condition)->field($fields)->order('status,bonus_id')->limit(1)->find();
-                if(!empty($ret)) {
-                    $datas = array('status' => 1,
-                        'grab_time' => time(),
-                        'session_id' => $sess_id);
-                    $this->where(array('bonus_type_id' => $type_id,'bonus_id' => $ret['bonus_id']))->update($datas);
+                $bonus = $this->where($condition)->field($fields)->order('status,bonus_id')->limit(1)->find();
+                if(!empty($bonus))
+                {
+                    $isNew = true;
+                    if(user_helper::isLogin()) { // 如果是登录状态直接绑定
+                        $datas = array('status' => 2,
+                            'grab_time' => time(),
+                            'get_time'  => time(),
+                            'session_id' => $sess_id,
+                            'user_id' => $_SESSION['member_id'],
+                            'user_mobile' => $_SESSION['member_mobile'],
+                            'user_name' => user_helper::nickname());
+                    } else {
+                        $datas = array('status' => 1,
+                            'grab_time' => time(),
+                            'session_id' => $sess_id);
+                    }
+
+                    $ret = $this->where(array('type_id' => $type_id,'bonus_id' => $bonus['bonus_id']))->update($datas);
+                    if($ret) {
+                        $bonus = array_merge($bonus,$datas);
+                    }
                 }
             }
-
             $this->commit();
 
-            return $ret;
+            return $bonus;
         } catch (Exception $ex) {
             $this->rollback();
             return array();
         }
     }
 
-    public function bind($bonus_sn,$session_id,$mobile)
+    public function bind($condition,$mobile)
     {
-        $ret = $this->where(array('bonus_sn' => $bonus_sn,'session_id' => $session_id,'status' => 1))->update(array('status' => 2,'user_mobile' => $mobile));
-        return $ret;
+        $condition['status'] = 1;
+
+        $datas = array('status' => 2,
+            'user_mobile' => $mobile,
+            'get_time' => time());
+        if(user_helper::isLogin()) {
+            $datas['user_name'] = user_helper::nickname();
+            $datas['user_id'] = $_SESSION['member_id'];
+        }
+
+        $ret = $this->where($condition)->update(array($datas));
+        return ($ret);
     }
 }

+ 403 - 0
data/resource/mobile/bonus/css/base.css

@@ -0,0 +1,403 @@
+@charset "UTF-8";
+/**
+ * base.css
+ * @author hgang
+ * Created 2015-12-30.
+ */
+/* line 5, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed,
+figure, figcaption, footer, header, hgroup,
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+  margin: 0;
+  padding: 0;
+  border: 0;
+  font: inherit;
+  font-size: 100%;
+  vertical-align: baseline;
+}
+
+/* line 22, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+html {
+  line-height: 1;
+}
+
+/* line 24, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+ol, ul {
+  list-style: none;
+}
+
+/* line 26, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+table {
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+
+/* line 28, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+caption, th, td {
+  text-align: left;
+  font-weight: normal;
+  vertical-align: middle;
+}
+
+/* line 30, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+q, blockquote {
+  quotes: none;
+}
+/* line 103, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+q:before, q:after, blockquote:before, blockquote:after {
+  content: "";
+  content: none;
+}
+
+/* line 32, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+a img {
+  border: none;
+}
+
+/* line 116, C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
+article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary {
+  display: block;
+}
+
+/**
+ * _font.scss
+ * @author Huwj
+ * Created 2015-08-18 16:40.
+ */
+/* 设置各种字号 */
+/* font-size: 11px; */
+/* line 9, ../../sass/_tool/_font.scss */
+.font9 {
+  font-size: 9px;
+}
+
+/* line 10, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font9 {
+  font-size: 27px;
+}
+
+/* line 13, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font9 {
+  font-size: 18px;
+}
+
+.font10 {
+  font-size: 10px;
+}
+
+/* line 10, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font10 {
+  font-size: 30px;
+}
+
+/* line 13, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font10 {
+  font-size: 20px;
+}
+
+.font11 {
+  font-size: 11px;
+}
+
+/* line 10, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font11 {
+  font-size: 33px;
+}
+
+/* line 13, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font11 {
+  font-size: 22px;
+}
+
+/* font-size: 12px; */
+/* line 17, ../../sass/_tool/_font.scss */
+.font12 {
+  font-size: 12px;
+}
+
+/* line 18, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font12 {
+  font-size: 36px;
+}
+
+/* line 21, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font12 {
+  font-size: 24px;
+}
+
+/* font-size: 14px; */
+/* line 26, ../../sass/_tool/_font.scss */
+.font14 {
+  font-size: 14px;
+}
+
+/* line 27, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font14 {
+  font-size: 42px;
+}
+
+/* line 30, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font14 {
+  font-size: 28px;
+}
+
+/* line 33, ../../sass/_tool/_font.scss */
+.font15 {
+  font-size: 15px;
+}
+
+/* line 34, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font15 {
+  font-size: 45px;
+}
+
+/* line 37, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font15 {
+  font-size: 30px;
+}
+
+/* font-size: 16px; */
+/* line 42, ../../sass/_tool/_font.scss */
+.font16 {
+  font-size: 16px;
+}
+
+/* line 43, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font16 {
+  font-size: 48px;
+}
+
+/* line 46, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font16 {
+  font-size: 32px;
+}
+
+.font17 {
+  font-size: 17px;
+}
+
+html[data-dpi="3"] body.iPhone .font17 {
+  font-size:51px;
+}
+
+/* line 55, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font17 {
+  font-size: 34px;
+}
+/* font-size: 18px; */
+/* line 51, ../../sass/_tool/_font.scss */
+.font18 {
+  font-size: 18px;
+}
+
+/* line 52, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font18 {
+  font-size: 54px;
+}
+
+/* line 55, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font18 {
+  font-size: 36px;
+}
+
+/* font-size: 20px; */
+/* line 60, ../../sass/_tool/_font.scss */
+.font20 {
+  font-size: 20px;
+}
+
+/* line 61, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font20 {
+  font-size: 60px;
+}
+
+/* line 64, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font20 {
+  font-size: 40px;
+}
+
+/* font-size: 22px; */
+/* line 69, ../../sass/_tool/_font.scss */
+.font22 {
+  font-size: 22px;
+}
+
+/* line 70, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font22 {
+  font-size: 66px;
+}
+
+/* line 73, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font22 {
+  font-size: 44px;
+}
+
+/* font-size: 24px; */
+/* line 78, ../../sass/_tool/_font.scss */
+.font24 {
+  font-size: 24px;
+}
+
+/* line 79, ../../sass/_tool/_font.scss */
+html[data-dpi="3"] body.iPhone .font24 {
+  font-size: 72px;
+}
+
+/* line 82, ../../sass/_tool/_font.scss */
+html[data-dpi="2"] body.iPhone .font24 {
+  font-size: 48px;
+}
+
+.font28 {
+  font-size:28px;
+}
+
+html[data-dpi="2"] body.iPhone .font28 {
+  font-size: 56px;
+}
+
+html[data-dpi="3"] body.iPhone .font28 {
+  font-size: 84px;
+}
+
+.font24 {
+  font-size:24px;
+}
+
+html[data-dpi="2"] body.iPhone .font24 {
+  font-size: 48px;
+}
+
+html[data-dpi="3"] body.iPhone .font24 {
+  font-size: 72px;
+}
+
+.font34 {
+  font-size:34px;
+}
+
+html[data-dpi="2"] body.iPhone .font34 {
+  font-size: 68px;
+}
+
+html[data-dpi="3"] body.iPhone .font34 {
+  font-size: 102px;
+}
+
+
+/* line 3, ../../sass/_tool/_footer.scss */
+footer {
+  background: #eeeeee;
+  text-align: center;
+}
+/* line 6, ../../sass/_tool/_footer.scss */
+footer .index_foot_content {
+  margin: 0 0 .47rem;
+  display: inline-block;
+}
+/* line 9, ../../sass/_tool/_footer.scss */
+footer .index_foot_content .version {
+  color: #989898;
+  margin-left: .4rem;
+}
+/* line 13, ../../sass/_tool/_footer.scss */
+footer .index_foot_content .line {
+  border-right: 1px solid #A99F9F;
+  padding-right: .4rem;
+}
+
+input[type="button"], input[type="submit"], input[type="reset"] {
+  -webkit-appearance: none;
+}
+
+textarea {  -webkit-appearance: none;}
+input {
+  vertical-align: middle;
+  border: none;
+}
+/* line 11, ../../sass/base/base.scss */
+img {
+  width: 100%;
+  height:100%;
+}
+
+select {
+  border: none;
+  -webkit-appearance: none;
+}
+/* line 15, ../../sass/base/base.scss */
+* {
+  box-sizing: border-box;
+}
+
+/* line 18, ../../sass/base/base.scss */
+html,
+body {
+  width: 100%;
+  min-height: 100%;
+  height: auto;
+}
+
+/* line 24, ../../sass/base/base.scss */
+.fullPage {
+  overflow: hidden;
+  width: 10rem;
+  height: auto;
+  margin: 0 auto;
+}
+
+/* line 30, ../../sass/base/base.scss */
+a {
+  text-decoration: none;
+}
+
+/*# sourceMappingURL=base.css.map */
+/*去除点击a btn 出现一个浅色的遮罩*/
+a,button,input,textarea{
+  /*-webkit-tap-highlight-color: rgba(0,0,0,0);*/
+/*-webkit-user-modify:read-write-plaintext-only;*/
+}
+/*禁止用户选择文字*/
+html{
+  -webkit-user-select:none
+}
+
+.center {
+  text-align: center;
+}
+
+
+.left {
+  float: left;
+}
+
+.middle {
+  vertical-align: middle;
+}
+.right {
+  float: right;
+}
+
+.price {
+  color: #f6467a;
+}
+.clear {
+  clear: both;
+}
+.inline {
+  display: inline-block;
+}
+
+
+
+

+ 160 - 0
data/resource/mobile/bonus/css/bindtel.css

@@ -0,0 +1,160 @@
+html {
+    background: #faf9d7;
+}
+.top {
+    height: 13.4rem;
+    width: 10rem;
+    background: url("../image/top_bg.png") no-repeat;
+    background-size: 100%;
+    padding-top: 2.42rem;
+    position: relative;
+    color: #fff;
+}
+.center_box {
+    width: 7.91rem;
+    margin: 0 auto;
+    overflow: hidden;
+    background: #e64774;
+    border-radius: 1rem;
+    padding-top: 0.64rem;
+    padding-bottom: 2.94rem;
+}
+.ropes {
+    width: 7.64rem;
+    height: 0.73rem;
+    line-height: 0.73rem;
+    margin: 0 auto;
+    background: url("../image/rcope02.png") no-repeat;
+    background-size: 100%;
+    color: #e86d97;
+}
+.tel {
+    width: 0.3rem;
+    height: 0.5rem;
+    background: url("../image/tel_icon.png") no-repeat;
+    background-size: 100%;
+    margin-right: 0.2rem;
+}
+.just_btn {
+    width: 4.8rem;
+    height: 1.3rem;
+    line-height: 1.3rem;
+    color: #c12b26;
+    background: #f6c36e;
+    border-radius: 0.31rem;
+    margin-top: 0.47rem;
+    box-shadow: 0 0.16rem 0 #c93666;
+}
+
+.amount_box {
+    margin-top: 0.66rem;
+    position: relative;
+}
+.amount_box p {
+    width: 6rem;
+    margin: 0 auto;
+    line-height: 0.5rem;
+}
+/*.amount_title {*/
+    /*width: 0.5rem;*/
+    /*position: absolute;*/
+    /*left: 0.35rem;*/
+    /*top: 0.1rem;*/
+    /*color: #84264c;*/
+/*}*/
+
+/*.amount {*/
+    /*width: 6.2rem;*/
+    /*height: 1.19rem;*/
+    /*line-height: 1.19rem;*/
+    /*border-radius: 5px;*/
+    /*letter-spacing: 0.05rem;*/
+    /*color: #d6356d;*/
+    /*background: -webkit-linear-gradient(left, #c3c4c4,#f9f9f9,#c3c4c4); /!* Safari 5.1 - 6.0 *!/*/
+    /*background: -o-linear-gradient(right, #c3c4c4,#f9f9f9,#c3c4c4); /!* Opera 11.1 - 12.0 *!/*/
+    /*background: -moz-linear-gradient(right, #c3c4c4,#f9f9f9,#c3c4c4); /!* Firefox 3.6 - 15 *!/*/
+    /*background: linear-gradient(to right,#c3c4c4,#f9f9f9,#c3c4c4); /!* ±ê×¼µÄÓï·¨ *!/*/
+/*}*/
+.input_tel,.validate {
+    width: 6.2rem;
+    height: 0.97rem;
+    line-height: 0.97rem;
+    margin: 0 auto;
+    padding-left: 0.2rem;
+    background: #fff;
+    color: #f2a2c1;
+    border-radius: 5px;
+}
+.input_tel input{
+    width: 4rem;
+}
+.validate {
+    margin-top: 0.25rem;
+}
+.input_box {
+    margin-top: 0.63rem;
+}
+.validate input {
+    width: 1.8rem;
+}
+.input_box input {
+    border: none;
+    color: #f2a2c1;
+}
+.go_validate {
+    background: #f5b7d0;
+    color: #fff;
+    border-radius: 10px;
+    height: 0.8rem;
+    width: 1.84rem;
+    line-height: 0.8rem;
+    margin-top: 0.1rem;
+    margin-right: 0.1rem;
+}
+.validate input,.input_box input{
+    height: 0.8rem;
+    background: #fff;
+    padding-left: 0.1rem;
+}
+.footer {
+    height: 2.3rem;
+    width: 100%;
+    background: url("../image/foot_bg.png") no-repeat;
+    background-size: 100% 100%;
+    position: fixed;
+    bottom: 0;
+    left: 0;
+}
+
+
+
+.banner {
+    width: 100%;
+    height: 1.88rem;
+    line-height: 1.88rem;
+    background-color: rgba(247,195,110,0.8);
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    color:#fff;
+}
+.banner_title {
+    width: 4.59rem;
+    line-height: 0.55rem;
+}
+.logo {
+    width: 1.5rem;
+    height: 1.5rem;
+    margin-top: 0.3rem;
+    margin-left: 0.73rem;
+    background: url("../image/icon.png") no-repeat;
+    background-size: 100%;
+}
+.down {
+    width: 1.25rem;
+    height: 1.25rem;
+    margin-top: 0.3rem;
+    margin-right: 0.73rem;
+    background: url("../image/down.png") no-repeat;
+    background-size: 100%;
+}

+ 50 - 0
data/resource/mobile/bonus/css/bomb.css

@@ -0,0 +1,50 @@
+.bomb {
+    height: 100%;
+    width: 100%;
+    background: rgba(0,0,0,0.5);
+    position: absolute;
+    top: 0;
+    left: 0;
+    z-index: 999;
+}
+.bomb_box {
+    width: 8.16rem;
+    height: 3.88rem;
+    margin: 0 auto;
+    background:url("../image/bomb_bg.png") no-repeat;
+    background-size: 100%;
+    position: relative;
+    margin-top: 1.69rem;
+    padding-top: 1.09rem;
+}
+.bomb_box p {
+    color: #858585;
+}
+.close {
+    width: 0.59rem;
+    height: 0.59rem;
+    position: absolute;
+    right: 0.2rem;
+    top: 0.2rem;
+    background: url('../image/close.png') no-repeat;
+    background-size: 100%
+}
+.btn div {
+    overflow: hidden;
+    margin-top: 0.5rem ;
+}
+.btn div a {
+    width: 2.44rem;
+    height: 0.94rem;
+    margin: 0 auto;
+    line-height: 0.94rem;
+    border-radius: 5px;
+}
+a.no {
+    background:#f6c36e;
+    color: #fff;
+}
+a.remove {
+    background: #e64774;
+    color: #fff;
+}

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

@@ -0,0 +1,117 @@
+html,
+body,
+p,
+a,
+img
+{
+    padding: 0;
+    margin: 0;
+}
+html,body {
+    height: 100%;
+    width: 100%;
+}
+img {border: none}
+@media screen and (max-width: 319px){
+    html {
+        font-size: 12px;
+    }
+}
+@media screen and (min-width: 320px) and (max-width:374px){
+    html {
+        font-size: 13px;
+    }
+}
+@media screen and (min-width: 375px){
+    html {
+        font-size: 14px;
+    }
+}
+a {
+    -webkit-tap-highlight-color:rgba(0,0,0,0);
+}
+.maincontent {
+    width: 100%;
+    height: 100%;
+    background: #ff4e4e;
+    position: relative;
+    color: #ffeeaa;
+}
+.bg_position {
+    position: absolute;
+}
+.cloud_left,.cloud_right {
+    width: 44px;
+    height: 17px;
+    background: url("../imgaes/cloud.png") no-repeat;
+    background-size: 100% 100%;
+}
+.cloud_left {
+    bottom: 3%;
+    left: 4%;
+}
+.cloud_right {
+    bottom: 3%;
+    right: 4%;
+}
+.dot_right,.dot_left {
+    width: 5px;
+    height: 5px;
+    border-radius: 10px;
+    background: #ff8a6b;
+    z-index: 999;
+}
+.dot_left {
+    top: 2%;
+    left: 3%;
+}
+.dot_right {
+    top: 2%;
+    right: 3%;
+}
+.center {
+    text-align: center;
+}
+.content {
+    width: 100%;
+    height: 60%;
+    background: url("../imgaes/top_bg.png") no-repeat;
+    background-size: 100% 100%;
+    position: relative;
+    padding-top: 4rem;
+}
+.open{
+    position: absolute;
+    width: 100px;
+    height: 100px;
+    left: 50%;
+    bottom: 0;
+    margin-left: -50px;
+    margin-bottom: -50px;
+    background: url("../imgaes/icon_open.png") no-repeat;
+    background-size: 100% 100%;
+}
+.logo {
+    width: 135px;
+    height: 25px;
+    background: url("../imgaes/logo.png") no-repeat;
+    background-size: 100% 100%;
+    margin: 0 auto;
+}
+.msg_box {
+    margin-top: 10%;
+    line-height: 2.4rem;
+}
+.name {
+    font-size: 1.8rem;
+}
+.msg {
+    font-size: 1.2rem;
+    color: #ffd39b;
+}
+.msg_bottom {
+    margin-top: 15%;
+}
+.msg_bottom p {
+    font-size: 2.2rem;
+}

+ 71 - 0
data/resource/mobile/bonus/css/index_commcon.css

@@ -0,0 +1,71 @@
+body {
+    background: #faf9d7;
+}
+.top {
+    height: 13.4rem;
+    width: 10rem;
+    background: url("../image/top_bg.png") no-repeat;
+    background-size: 100%;
+    padding-top: 2.42rem;
+    position: relative;
+    color: #fff;
+}
+.rope {
+    width: 0.38rem;
+    height: 3.1rem;
+    position: absolute;
+    left: 4.83rem;
+    top: 0;
+    background: url("../image/rcope.png") no-repeat;
+    background-size: 100%;
+}
+.bag_header {
+    width: 7.75rem;
+    height: 4.81rem;
+    margin: 0 auto;
+    background: url("../image/bag_head.png") no-repeat;
+    background-size: 100%;
+    font-weight: normal;
+    padding-top: 1.13rem;
+}
+.bag_header p {
+    margin-bottom: 0.22rem;
+}
+
+.bag_center {
+    width: 7.75rem;
+    height: 6rem;
+    margin: -1px auto;
+    padding-top: 1.5rem;
+    padding-bottom: 2.66rem;
+    background: #e54674;
+    border-bottom-left-radius: 1.1rem;
+    border-bottom-right-radius: 1.1rem;
+}
+.just_btn {
+    width: 4.8rem;
+    height: 1.3rem;
+    line-height: 1.3rem;
+    color: #c12b26;
+    background: #f6c36e;
+    border-radius: 0.31rem;
+    box-shadow: 0 0.16rem 0 #c93666;
+}
+.recommend_box p {
+    width: 2.2rem;
+    height: 0.6rem;
+    margin: 0 auto;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    text-align: left;
+}
+.footer {
+     height: 2.3rem;
+     width: 100%;
+     background: url("../image/foot_bg.png") no-repeat;
+     background-size: 100% 100%;
+     position: fixed;
+     bottom: 0;
+     left: 0;
+ }

+ 60 - 0
data/resource/mobile/bonus/css/over.css

@@ -0,0 +1,60 @@
+.top {
+    height: auto;
+}
+.bag_center {
+    padding-top: 0.1rem;
+    padding-bottom: 0.8rem;
+}
+.pro p {
+    line-height: 0.5rem;
+}
+
+.ropes {
+    width: 7.64rem;
+    height: 0.73rem;
+    line-height: 0.73rem;
+    margin: 0 auto;
+    background: url("../image/rcope02.png") no-repeat;
+    background-size: 100%;
+    color: #e86d97;
+}
+.recommend {
+    height: auto;
+    width: 6.34rem;
+    margin: 0 auto;
+    overflow: hidden;
+    background: #d6356d;
+    border-radius:5px;
+    padding-top: 0.2rem;
+    padding-bottom: 0.2rem;
+}
+.recommend_box {
+    width: 50%;
+}
+.recommend_box p {
+    line-height: 0.6rem;
+}
+.img_box {
+    width: 2.08rem;
+    height: 2.08rem;
+    margin: 0 auto;
+    padding: 0.17rem;
+    background: #f6c26e;
+    border-radius: 10px;
+}
+.img_border {
+    width: 1.7rem;
+    height: 1.7rem;
+    border: 2px solid #fff;
+}
+.ropes {
+    margin-top: 0.15rem;
+    margin-bottom: 0.2rem;
+}
+.price_box {
+    margin-top: -0.66rem;
+}
+.later {
+    text-decoration: line-through;
+    color: #e377a3;
+}

+ 127 - 0
data/resource/mobile/bonus/css/success.css

@@ -0,0 +1,127 @@
+html {
+    background: #faf9d7;
+}
+.top {
+   height: auto;
+}
+.bag_header p {
+    width: 5.7rem;
+    line-height: 0.5rem;
+    margin:0 auto 0.22rem auto;
+}
+.price_b {
+    color:#f7c36f;
+}
+.fullPage {
+    position: relative;
+}
+
+
+
+
+.bag_center {
+    padding-top: 0.1rem;
+    padding-bottom: 0.8rem;
+}
+
+
+.ropes {
+    width: 7.64rem;
+    height: 0.73rem;
+    line-height: 0.73rem;
+    margin: 0 auto;
+    background: url("../image/rcope02.png") no-repeat;
+    background-size: 100%;
+    color: #e86d97;
+}
+.recommend {
+    height: auto;
+    width: 6.34rem;
+    margin: 0 auto;
+    overflow: hidden;
+    background: #d6356d;
+    border-radius:5px;
+    padding-top: 0.2rem;
+}
+.recommend_box {
+    width: 50%;
+    padding-bottom: 0.2rem;
+}
+.recommend_box p {
+    width: 2.2rem;
+    height: 0.6rem;
+    margin: 0 auto;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    text-align: left;
+    line-height: 0.6rem;
+    color: #f8dfe8;
+}
+.recommend_title {
+    width: 2.2rem;
+    height: 0.6rem;
+    line-height: 0.6rem;
+    overflow: hidden;
+    margin: 0 auto;
+}
+.img_box {
+    width: 2.08rem;
+    height: 2.08rem;
+    margin: 0 auto;
+    padding: 0.17rem;
+    background: #f6c26e;
+    border-radius: 10px;
+}
+.img_border {
+    width: 1.7rem;
+    height: 1.7rem;
+    border: 2px solid #fff;
+}
+.ropes {
+    margin-top: 0.15rem;
+    margin-bottom: 0.2rem;
+}
+.price_box {
+    margin-top: -0.66rem;
+}
+.later {
+    text-decoration: line-through;
+    color: #e377a3;
+    padding-left: 0.1rem;
+}
+
+
+
+.banner {
+    width: 100%;
+    height: 1.88rem;
+    line-height: 1.88rem;
+    background-color: rgba(247,195,110,0.8);
+    position:fixed;
+    bottom: 0;
+    left: 0;
+    color:#fff;
+}
+.banner_title {
+    width: 4.59rem;
+    line-height: 0.55rem;
+}
+.logo {
+    width: 1.5rem;
+    height: 1.5rem;
+    margin-top: 0.3rem;
+    margin-left: 0.73rem;
+    background: url("../image/icon.png") no-repeat;
+    background-size: 100%;
+}
+.down {
+    width: 1.25rem;
+    height: 1.25rem;
+    margin-top: 0.3rem;
+    margin-right: 0.73rem;
+    background: url("../image/down.png") no-repeat;
+    background-size: 100%;
+}
+
+

BIN
data/resource/mobile/bonus/image/bag_head.png


BIN
data/resource/mobile/bonus/image/bomb_bg.png


BIN
data/resource/mobile/bonus/image/close.png


BIN
data/resource/mobile/bonus/image/content.png


BIN
data/resource/mobile/bonus/image/down.png


BIN
data/resource/mobile/bonus/image/foot_bg.png


BIN
data/resource/mobile/bonus/image/icon.png


BIN
data/resource/mobile/bonus/image/loadicon.png


BIN
data/resource/mobile/bonus/image/price_bg.png


BIN
data/resource/mobile/bonus/image/rcope.png


BIN
data/resource/mobile/bonus/image/rcope02.png


BIN
data/resource/mobile/bonus/image/tel_icon.png


BIN
data/resource/mobile/bonus/image/top_bg.png


BIN
data/resource/mobile/bonus/imgaes/cloud.png


BIN
data/resource/mobile/bonus/imgaes/icon_open.png


BIN
data/resource/mobile/bonus/imgaes/logo.png


BIN
data/resource/mobile/bonus/imgaes/top_bg.png


+ 157 - 0
data/resource/mobile/bonus/js/rem.js

@@ -0,0 +1,157 @@
+/**
+ *  鉴于移动端设备参差不齐,
+ *  给页面排版带来了很多不便,
+ *  现在为了统一设置,
+ *  判断不同设备,
+ *  根据不同设备的分辨率,
+ *  以及其自身的DPI,
+ *  设置一个合适当前设备的rem值。
+ **/
+!function(window){
+
+    /*console.log(typeof define);
+     console.log(typeof module);
+     console.log(typeof exports);*/
+    var
+    // 使用一些文档原本就有的参数
+    //location = window.location,
+        document = window.document,
+    //docElm = document.documentElement,
+    // 设置版本号
+        setRem_version = '1.0.0',
+    //注册方法名
+        setRem = window.setRem || {};
+    //方法实现
+    setRem = {
+        init: function(opts){
+            /*console.log(opts);*/
+            //var def = opts === false ? false : true;
+            //if(def){
+            //    this.set();
+            //   // this.isComplete();
+            //    //this.test();
+            //}
+            //var def = ;
+            this.set(opts);
+        },
+        // isComplete: function(){
+        //     document.addEventListener('DOMContentLoaded', function(){
+        //         console.log('done');
+        //         if(document.getElementsByClassName){
+        //             console.log('zhichi');
+        //             // document.getElementsByClassName('fullpage')[0].style.height = '100%';
+        //         };
+
+        //     }, !1); 
+        // },
+        tool: function(){
+            //定义获得的dom存放对象
+            var domArr = {};
+            domArr.html = document.getElementsByTagName('html')[0];
+            domArr.head = document.getElementsByTagName('head')[0];
+            domArr.body = document.getElementsByTagName('body')[0];
+            return domArr;
+        },
+        device: function(){
+            //获取当前设备相关参数
+            var deviceArg = {};
+            //是什么设备iPhone OR Android OR iPad OR other
+            deviceArg.name = navigator.appVersion.indexOf('iPhone') > -1 ? 'iPhone' : 'other';
+            deviceArg.name = navigator.appVersion.indexOf('Android') > -1 ? 'Android' : deviceArg.name;
+            deviceArg.name = navigator.appVersion.indexOf('iPad') > -1 ? 'iPad' : deviceArg.name;
+            //当前设备的dpi是几何
+            deviceArg.dpi = window.devicePixelRatio;
+            //当前设备的宽度(单位px,但是是设备宽度,而非其分辨率)
+            //deviceArg.width = window.screen.width;
+
+            //getBoundingClientRect取到的是什么,
+            //为什么用这个,因为android设备取到的不准确特么的
+            deviceArg.width = document.getElementsByTagName('body')[0].getBoundingClientRect().width;
+            deviceArg.height = document.getElementsByTagName('body')[0].getBoundingClientRect().height;
+            //deviceArg.w = document.body.clientWidth;
+            //返回相关信息
+            //console.log(deviceArg);
+            //console.log(deviceArg);
+            return deviceArg;
+        },
+        create: function(opts, type, width,height, dpi){
+            //设置相关参数,拼接meta
+            var domVal = this.tool(),
+                remVal,
+                remHeight,
+                viewport = document.querySelector('meta[name="viewport"]');
+
+            //此属性为当前设备的dpi
+            domVal.html.setAttribute('data-dpi', dpi);
+            remVal = type === 'iPhone' ? width * dpi / 10
+                : (dpi > 1) && (width < 540) ? width / 10 : 540 / 10;
+            remHeight = type === 'iPhone' ? height * dpi / 10
+                : (dpi > 1) && (height < 540) ? height / 10 : 540 / 10;
+            dpi = type === 'iPhone' ? dpi : 1;
+            if (opts.redraw && type === 'iPhone'){
+                remVal = remVal / dpi;
+            }
+            domVal.html.style.fontSize = remVal+ 'px';
+
+            //console.log(remVal);
+            //这里不是dpi,,模仿淘宝,另有深意,粗浅的理解大概是设置的缩放比例。
+            domVal.html.setAttribute('data-dpr', dpi);
+
+            //为不同设备添加一个区分class
+            domVal.body.setAttribute('class', type + ' ' + type + '-height-' + height +' '+ type+ '-width-' +width);
+            //设置 viewport 各个属性
+            //viewport.setAttribute('name', 'viewport');
+            viewport.setAttribute('content', 'width=device-width'
+                + ', initial-scale='+ 1 / dpi
+                + ', maximum-scale=' + 1 / dpi
+                + ', minimum-scale=' + 1 / dpi
+                + ', user-scalable=no');
+            domVal.head.appendChild(viewport);
+
+
+        },
+        set: function(opts){
+
+            // console.log('go on');
+            var deviceVal = this.device();
+            if( deviceVal.name == 'iPhone' ){
+                this.create(opts, 'iPhone', deviceVal.width,deviceVal.height, deviceVal.dpi);
+            }else if( deviceVal.name == 'iPad' ){
+                this.create(opts, 'iPad', deviceVal.width,deviceVal.height, deviceVal.dpi);
+            }else if( deviceVal.name == 'Android' ){
+                this.create(opts, 'Android', deviceVal.width,deviceVal.height, deviceVal.dpi);
+            }else{
+                this.create(opts, 'other', deviceVal.width,deviceVal.height, deviceVal.dpi);
+            }
+            //t = setTimeout(function(){
+            //    document.getElementsByClassName('fullpage')[0].style.height = '100%';
+            //},100);
+            window.setRem = 'end';
+        }
+        // ,
+        // test: function(){
+        //  var testArr = {};
+        //  testArr.android = window.navigator.appVersion.match(/android/gi);
+        //  testArr.iphone = window.navigator.appVersion.match(/iphone/gi);
+        //  testArr.ai = (testArr.android, testArr.iphone);
+        //  console.log(testArr);
+        // }
+    };
+
+    // window.setRem = setRem;
+    setRem.init({redraw: false});
+    addEventListener('resize', function () {
+        setRem.init({redraw: true});
+    }, false);
+    //设置AMD模块依赖
+    if (typeof define === 'function' && define.amd) {
+        define('rem', [], function () {
+            return setRem;
+        })
+    }
+}(window);
+
+
+
+
+

+ 165 - 0
data/resource/mobile/bonus/js/tel.js

@@ -0,0 +1,165 @@
+$(function(){
+    tel={
+        //总入口
+        init:function(){
+            var that=this;
+            that.validate('#hack',that.msg.no_tel,that.btnname.just_white);
+            //that.validate('#bind',that.msg.no_tel,that.btnname.just_white);
+            that.time('#hack');
+            that.close('#close');
+            that.close('#go');
+            that.active();
+            that.blurValidatetel('keyup');
+            that.blurValidatetel('blur');
+        },
+        //弹出信息
+        msg:{
+            no_tel:'请认真填写你的手机号',
+            no_yanz:'请填写验证码',
+            yanz_err:'验证码错误',
+            lg:'该手机已经领取过红包',
+            no_lq:'该手机不能领取红包',
+            remove:'获取验证码哦',
+            over:'该手机已经领取过红包',
+            no_pass:'该手机号不能领取红包'
+        },
+        //按钮信息
+        btnname:{
+            just_white:'这就写',
+            rewrite:'重新填写',
+            check:'知道了'
+        },
+        //判断验证顺序
+        b:false,
+        //插入验证结构
+        validate:function(id,msg,btnmsg,sj){
+            var that=this;
+            $(id).on('touchstart',function(e){
+                e.preventDefault();//阻止浏览器默认事件
+                var telVal=$('#tel_number').val(),
+                    tel=new RegExp("^[1][3-8]+\\d{9}");
+                //console.log(tel.test(telVal));
+                //验证输入手机规则
+                if(telVal==''||(!tel.test(telVal))){
+                    that.appendDom(msg,btnmsg);//插入HTML弹窗结构
+                    that.b=false;
+                }
+                else{
+                    that.b=true;
+                    return;
+                }
+            })
+        },
+        blurValidatetel:function(eve){
+            var that=this;
+            $("#tel_number").on(eve,function(){
+                var thisVal=$(this).val(),
+                    tel=new RegExp("^[1][3-8]+\\d{9}");
+                if(thisVal==''||(!tel.test(thisVal))){
+                    that.b=false;
+                    return;
+                }
+                else {
+                    that.b=true;
+                }
+            })
+        },
+        //dom结构
+        appendDom:function(msg,btnmsg){
+            var dom='<div class="bomb" id="bomb">'+
+                '<div class="bomb_box">'+
+                '<p class="center font14">'+msg+'</p>'+
+                '<div class="btn center">'+
+                '<div>'+
+                '<a href="javascript:void(0)" class="remove inline font14" id="go">'+btnmsg+'</a>'+
+                '</div>'+
+                '</div>'+
+                '<div class="close" id="close"></div>'+
+                '</div>'+
+                '</div>';
+            $('#fullPage').append(dom);
+        },
+        //关闭弹出
+        close:function(id){
+            $(id).live('touchstart',function(e){
+                e.preventDefault();
+                $('#bomb').remove();
+            });
+        },
+        //倒计时
+        time:function(id,msg,btnmsg){
+            var that=this,
+                times=function(){
+                    if(that.b==false){
+                        return;
+                    }
+                    tel = $("#tel_number").val();
+                    $.post($("#get_code_link").val(), {
+                        phone_num: tel
+                    }), function (data, status) {
+                        return;
+                    };
+
+                    var yzVal = $('#yanz').val(),
+                        time = 60,
+                        a = setInterval(function () {
+                            time = time - 1;
+                            $(id).text(time);
+                            if (time == 0) {
+                                clearInterval(a);
+                                $(id).text('重新发送');
+                            }
+                        }, 1000);
+                };
+            $(id).on('touchstart', function () {
+                //判断倒计时是否开始了
+                var text = $(this).text();
+                if (text == '重新发送' || text == '去获取') {
+                    times();
+                }
+                else {
+                    return;
+                }
+            })
+        },
+        //验证码验证
+        active: function () {
+            var that = this;
+            $('#bind').on('touchstart', function () {
+                var b = that.b,
+                    yanzVal = $('#yanz').val();
+                if (b == false && yanzVal == '') {
+                    that.appendDom(that.msg.no_tel, that.btnname.just_white);
+                }
+                else {
+                    if (yanzVal == '') {
+                        that.appendDom(that.msg.no_yanz, that.btnname.just_white);
+                    }
+                    else {
+                        var yanzVal = $("#yanz").val();
+                        var tel = $("#tel_number").val();
+                        var alink = $("#url").val();
+
+                        $.post($("#verify_code_link").val(), {
+                            phone_num: tel,
+                            verifyCode: yanzVal
+                        }, function (data, status) {
+                            //alert(data+status);
+
+                            if (data) {
+                                location.href = alink + "&phone_num=" + tel + "&verifyCode=" + yanzVal;
+                            } else {
+                                that.appendDom(that.msg.yanz_err, that.btnname.rewrite);
+                            }
+                        });
+
+                        return;
+                    }
+                }
+
+
+           })
+        }
+    };
+    tel.init();
+});

+ 112 - 0
data/resource/mobile/bonus/js/tel_bak.js

@@ -0,0 +1,112 @@
+$(function(){
+    tel={
+        //总入口
+        init:function(){
+            var that=this;
+            that.validate('#hack',that.msg.no_tel,that.btnname.just_white);
+            that.validate('#bind',that.msg.no_tel,that.btnname.just_white);
+            that.time('#hack');
+            that.close('#close');
+            that.close('#go');
+            that.active();
+        },
+        //弹出信息
+        msg:{
+            no_tel:'请认真填写你的手机号',
+            no_yanz:'请填写验证码',
+            lg:'该手机已经领取过红包',
+            no_lq:'该手机不能领取红包',
+            remove:'获取验证码哦',
+            over:'该手机已经领取过红包',
+            no_pass:'该手机号不能领取红包'
+        },
+        //按钮信息
+        btnname:{
+            just_white:'这就写',
+            check:'知道了'
+        },
+        //判断验证顺序
+        b:false,
+        //插入验证结构
+        validate:function(id,msg,btnmsg){
+            var that=this;
+            $(id).on('touchstart',function(e){
+                e.preventDefault();//阻止浏览器默认事件
+                var telVal=$('#tel_number').val(),
+                    tel=new RegExp("^[1][3-8]+\\d{9}");
+                //console.log(tel.test(telVal));
+                //验证输入手机规则
+                if(telVal==''||(!tel.test(telVal))){
+                    that.appendDom(msg,btnmsg);//插入HTML弹窗结构
+                    that.b=false;
+                }
+                else{
+                    that.b=true;
+                    return;
+                }
+            })
+        },
+        //dom结构
+        appendDom:function(msg,btnmsg){
+            var dom='<div class="bomb" id="bomb">'+
+                '<div class="bomb_box">'+
+                '<p class="center font14">'+msg+'</p>'+
+                '<div class="btn center">'+
+                '<div>'+
+                '<a href="javascript:void(0)" class="remove inline font14" id="go">'+btnmsg+'</a>'+
+                '</div>'+
+                '</div>'+
+                '<div class="close" id="close"></div>'+
+                '</div>'+
+                '</div>';
+            $('#fullPage').append(dom);
+        },
+        //关闭弹出
+        close:function(id){
+            $(id).live('touchstart',function(e){
+                e.preventDefault();
+                $('#bomb').remove();
+            });
+        },
+        //倒计时
+        time:function(id,msg,btnmsg){
+            var that=this,
+                times=function(){
+                    if(that.b==false){
+                        return;
+                    }
+                    var yzVal=$('#yanz').val(),
+                        time=60,
+                        a=setInterval(function(){
+                            time=time-1;
+                            $(id).text(time);
+                            if(time==0) {
+                                clearInterval(a);
+                                $(id).text('重新发送');
+                            }
+                        },1000);
+                };
+            $(id).on('touchstart',function(){
+                //判断倒计时是否开始了
+                var text=$(this).text();
+                if(text=='重新发送'||text=='去获取'){
+                    times();
+                }
+                else{
+                    return;
+                }
+            })
+        },
+        //验证码验证
+        active:function(){
+            var that=this;
+           $('#bind').on('touchstart',function(){
+               if(that.b==true&&$('#yanz').val()==''){
+                   that.appendDom(that.msg.no_yanz,that.btnname.just_white);
+               }
+
+           })
+        }
+    };
+    tel.init();
+});

+ 161 - 0
data/resource/mobile/bonus/js/touch.js

@@ -0,0 +1,161 @@
+;(function($){
+    var touch = {},
+        touchTimeout, tapTimeout, swipeTimeout, longTapTimeout,
+        longTapDelay = 750,
+        gesture
+
+    function swipeDirection(x1, x2, y1, y2) {
+        return Math.abs(x1 - x2) >=
+        Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
+    }
+
+    function longTap() {
+        longTapTimeout = null
+        if (touch.last) {
+            touch.el.trigger('longTap')
+            touch = {}
+        }
+    }
+
+    function cancelLongTap() {
+        if (longTapTimeout) clearTimeout(longTapTimeout)
+        longTapTimeout = null
+    }
+
+    function cancelAll() {
+        if (touchTimeout) clearTimeout(touchTimeout)
+        if (tapTimeout) clearTimeout(tapTimeout)
+        if (swipeTimeout) clearTimeout(swipeTimeout)
+        if (longTapTimeout) clearTimeout(longTapTimeout)
+        touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
+        touch = {}
+    }
+
+    function isPrimaryTouch(event){
+        return (event.pointerType == 'touch' ||
+            event.pointerType == event.MSPOINTER_TYPE_TOUCH)
+            && event.isPrimary
+    }
+
+    function isPointerEventType(e, type){
+        return (e.type == 'pointer'+type ||
+        e.type.toLowerCase() == 'mspointer'+type)
+    }
+
+    $(document).ready(function(){
+        var now, delta, deltaX = 0, deltaY = 0, firstTouch, _isPointerType
+
+        if ('MSGesture' in window) {
+            gesture = new MSGesture()
+            gesture.target = document.body
+        }
+
+        $(document)
+            .bind('MSGestureEnd', function(e){
+                var swipeDirectionFromVelocity =
+                    e.velocityX > 1 ? 'Right' : e.velocityX < -1 ? 'Left' : e.velocityY > 1 ? 'Down' : e.velocityY < -1 ? 'Up' : null;
+                if (swipeDirectionFromVelocity) {
+                    touch.el.trigger('swipe')
+                    touch.el.trigger('swipe'+ swipeDirectionFromVelocity)
+                }
+            })
+            .on('touchstart MSPointerDown pointerdown', function(e){
+                if((_isPointerType = isPointerEventType(e, 'down')) &&
+                    !isPrimaryTouch(e)) return
+                firstTouch = _isPointerType ? e : e.touches[0]
+                if (e.touches && e.touches.length === 1 && touch.x2) {
+                    // Clear out touch movement data if we have it sticking around
+                    // This can occur if touchcancel doesn't fire due to preventDefault, etc.
+                    touch.x2 = undefined
+                    touch.y2 = undefined
+                }
+                now = Date.now()
+                delta = now - (touch.last || now)
+                touch.el = $('tagName' in firstTouch.target ?
+                    firstTouch.target : firstTouch.target.parentNode)
+                touchTimeout && clearTimeout(touchTimeout)
+                touch.x1 = firstTouch.pageX
+                touch.y1 = firstTouch.pageY
+                if (delta > 0 && delta <= 250) touch.isDoubleTap = true
+                touch.last = now
+                longTapTimeout = setTimeout(longTap, longTapDelay)
+                // adds the current touch contact for IE gesture recognition
+                if (gesture && _isPointerType) gesture.addPointer(e.pointerId);
+            })
+            .on('touchmove MSPointerMove pointermove', function(e){
+                if((_isPointerType = isPointerEventType(e, 'move')) &&
+                    !isPrimaryTouch(e)) return
+                firstTouch = _isPointerType ? e : e.touches[0]
+                cancelLongTap()
+                touch.x2 = firstTouch.pageX
+                touch.y2 = firstTouch.pageY
+
+                deltaX += Math.abs(touch.x1 - touch.x2)
+                deltaY += Math.abs(touch.y1 - touch.y2)
+            })
+            .on('touchend MSPointerUp pointerup', function(e){
+                if((_isPointerType = isPointerEventType(e, 'up')) &&
+                    !isPrimaryTouch(e)) return
+                cancelLongTap()
+
+                // swipe
+                if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
+                    (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
+
+                    swipeTimeout = setTimeout(function() {
+                        touch.el.trigger('swipe')
+                        touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
+                        touch = {}
+                    }, 0)
+
+                // normal tap
+                else if ('last' in touch)
+                // don't fire tap when delta position changed by more than 30 pixels,
+                // for instance when moving to a point and back to origin
+                    if (deltaX < 30 && deltaY < 30) {
+                        // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
+                        // ('tap' fires before 'scroll')
+                        tapTimeout = setTimeout(function() {
+
+                            // trigger universal 'tap' with the option to cancelTouch()
+                            // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
+                            var event = $.Event('tap')
+                            event.cancelTouch = cancelAll
+                            touch.el.trigger(event)
+
+                            // trigger double tap immediately
+                            if (touch.isDoubleTap) {
+                                if (touch.el) touch.el.trigger('doubleTap')
+                                touch = {}
+                            }
+
+                            // trigger single tap after 250ms of inactivity
+                            else {
+                                touchTimeout = setTimeout(function(){
+                                    touchTimeout = null
+                                    if (touch.el) touch.el.trigger('singleTap')
+                                    touch = {}
+                                }, 250)
+                            }
+                        }, 0)
+                    } else {
+                        touch = {}
+                    }
+                deltaX = deltaY = 0
+
+            })
+            // when the browser window loses focus,
+            // for example when a modal dialog is shown,
+            // cancel all ongoing events
+            .on('touchcancel MSPointerCancel pointercancel', cancelAll)
+
+        // scrolling the window indicates intention of the user
+        // to scroll, not tap or swipe, so cancel all ongoing events
+        $(window).on('scroll', cancelAll)
+    })
+
+    ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown',
+        'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
+            $.fn[eventName] = function(callback){ return this.on(eventName, callback) }
+        })
+})(Zepto)

Разница между файлами не показана из-за своего большого размера
+ 2 - 0
data/resource/mobile/bonus/js/zepto.js


+ 1 - 0
data/sales/home_goods.txt

@@ -0,0 +1 @@
+1993,1994,1996,1997,1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012,2014,2015,2016,2017,2018,2019,2020,2022,2030,2031,2032

+ 4 - 3
helper/bonus/factory.php

@@ -17,6 +17,7 @@ class factory
         try
         {
             $type = type::crate_by_paramer($paramer);
+
             $iGen = create_generator($type);
             $iGen->make_type();
             if(!$ret = $iGen->make_bonus()) {
@@ -34,17 +35,17 @@ class factory
         }
     }
 
-    static public function grab_bonus($paramer) //数组类型的参数
+    static public function grab_bonus($paramer,&$isNew) //数组类型的参数
     {
         try
         {
             $type = type::create_by_sn($paramer['type_sn']);
             $iGrab = create_grab($type);
-            $bonus = $iGrab->get_bonus($paramer);
+            $bonus = $iGrab->get_bonus($paramer,$isNew);
             if(empty($bonus)) {
                 return false;
             } else {
-                return array('type_info' => $type->get_param(),'bonus_info' => $bonus);
+                return $bonus;
             }
         } catch (Exception $ex) {
             return false;

+ 12 - 8
helper/bonus/generator.php

@@ -62,16 +62,18 @@ class GeneralGenerator extends IGenerator
         $paramer = $this->mType->get_param();
         $type_id = $this->mType->getType_id();
         $total_num = $this->mType->getTotal_num();
+        $type_sn = $this->mType->getType_sn();
 
         if($this->mType->isRandomAmount())
         {
             $moneys = $this->separate_money($paramer);
             foreach($moneys as $val)
             {
-                $datas['bonus_sn'] = make_sn();
-                $datas['bonus_value'] = $val;
-                $datas['bonus_type_id'] = $type_id;
-                $datas['status'] = 0;
+                $datas = array('bonus_sn' => make_sn(),
+                    'bonus_value' => $val,
+                    'type_id' => $type_id,
+                    'status' => 0,
+                    'type_sn' => $type_sn);
                 $ret = $mod_bonus->add($datas);
                 if($ret <= 0) {
                     Log::record("insert user_bonus err: {$type_id}.");
@@ -83,10 +85,12 @@ class GeneralGenerator extends IGenerator
         {
             $val =  $paramer['fixed_money'];
             for($i = 0; $i < $total_num; $i++) {
-                $datas['bonus_sn'] = make_sn();
-                $datas['bonus_value'] = $val;
-                $datas['bonus_type_id'] = $type_id;
-                $datas['status'] = 0;
+                $datas = array( 'bonus_sn' => make_sn(),
+                    'bonus_value' => $val,
+                    'type_id' => $type_id,
+                    'status' => 0,
+                    'type_sn' => $type_sn);
+
                 $ret = $mod_bonus->add($datas);
                 if($ret <= 0) {
                     Log::record("insert user_bonus err: {$type_id}.");

+ 17 - 7
helper/bonus/grab.php

@@ -20,7 +20,7 @@ abstract class IGrab
         $this->mType = $type;
     }
 
-    abstract public function get_bonus($paramer);
+    abstract public function get_bonus($paramer,&$isNew);
 }
 
 class DirectGrab extends IGrab
@@ -29,7 +29,7 @@ class DirectGrab extends IGrab
         parent::__construct($type);
     }
 
-    public function get_bonus($type)
+    public function get_bonus($type,&$isNew)
     {
         throw new Exception("指定人群的红包不用抢,直接领就好",errcode::ErrBonusType);
     }
@@ -41,7 +41,7 @@ class general_grab extends IGrab
         parent::__construct($paramer);
     }
 
-    public function get_bonus($paramer) //($type_sn,$time_out,$sess_id)
+    public function get_bonus($paramer,&$isNew) //($type_sn,$time_out,$sess_id)
     {
         $time_out = $paramer['time_out'];
         $session_id = $paramer['session_id'];
@@ -49,13 +49,23 @@ class general_grab extends IGrab
         $type_id = $this->mType->getType_id();
 
         $user_bonus = Model('user_bonus');
-        $bonus = $user_bonus->grab($type_id,$time_out,$mobile,$session_id);
+        $isNew = false;
+        $bonus = $user_bonus->grab($type_id,$time_out,$mobile,$session_id,$isNew);
+        $user_bonus = \user_bonus::create_by_param($bonus);
         if(!empty($bonus))
         {
-            if($bonus['status'] == 0) {
-                Model('bonus_type')->edit(array('type_id' => $type_id), array('grabed_num' => array('exp', 'grabed_num+1')));
+            if($isNew == true)
+            {
+                $bonus_val = $user_bonus->bonus_value();
+                if($user_bonus->isBinded()) {
+                    Model('bonus_type')->edit(array('type_id' => $type_id), array('grabed_num' => array('exp', 'grabed_num+1'),
+                        'binded_num' => array('exp', 'binded_num+1'),
+                        'remain_amount' => array('exp', "remain_amount-" . "{$bonus_val}")));
+                } else {
+                    Model('bonus_type')->edit(array('type_id' => $type_id), array('grabed_num' => array('exp', 'grabed_num+1')));
+                }
             }
-            return $bonus;
+            return $user_bonus;
         } else {
             return array();
         }

+ 254 - 1
helper/bonus/manager.php

@@ -4,4 +4,257 @@
  * User: stanley-king
  * Date: 16/4/17
  * Time: 下午11:34
- */
+ */
+
+namespace bonus;
+
+use \errcode;
+use \Model;
+
+class manager
+{
+    //红包抢到不绑定手机的过期时间
+    const grab_period_timeout = 10 * 60;
+
+    //红包的四种状态
+    const bonus_state_ungrab = 0; //未抢
+    const bonus_state_grabed = 1; //已抢到
+    const bonus_state_binded = 2; //已绑定手机
+    const bonus_state_topuped= 3; //已经充值
+
+    public function __construct() {
+
+    }
+
+    const type_prefix = 'bonus_type';
+
+    public function get_typeinfo($type_sn)
+    {
+        $bonus_info = rcache($type_sn, self::type_prefix, '*');
+        if (empty($bonus_info)) {
+            $type = type::create_by_sn($type_sn);
+            $user_bonus = Model('user_bonus');
+            $bonus_ex= $user_bonus->getTypeBinded(array('type_id' => $type->getType_id()));
+            $type_info = $type->get_param();
+
+            if($type->binded_over())
+            {
+                $lasted_time = Model('user_bonus')->lasted_binded(array('type_id' => $type->getType_id()));
+                if($lasted_time > 0) {
+                    $period = $lasted_time - $type->get_start_time();
+                    $type_info['binded_period'] = intval($period / 60);
+                }
+            } else {
+                $type_info['binded_period'] = 0;
+            }
+
+            $bonus_info = array('type_info' => $type->get_param(),'binded_info' => $bonus_ex);
+            wcache($type_sn,array('infos' => serialize($bonus_info)),self::type_prefix);
+        }
+        else {
+            $bonus_info = unserialize($bonus_info['infos']);
+        }
+        return $bonus_info;
+    }
+
+    public function get_mine($type_sn)
+    {
+        $bonus = $this->read_session($type_sn);
+        if(empty($bonus))
+        {
+            $mod_bonus = Model('user_bonus');
+
+            $session_id = $_SESSION['PHPSESSID'];
+            if(isset($_SESSION['member_mobile']) && !empty($_SESSION['member_mobile'])) {
+                $condition = array('type_sn' => $type_sn,
+                                    array('session_id' => $session_id,
+                                          'user_mobile' => $_SESSION['member_mobile'],
+                                          '_op' => 'or'));
+            } else {
+                $condition = array('session_id' => $session_id,'type_sn' => $type_sn);
+            }
+
+            $bonusex = $mod_bonus->get($condition);
+            if(empty($bonusex)) {
+                return false;
+            }
+
+            if(count($bonusex) > 1)
+            {
+                foreach($bonusex as $val)
+                {
+                    if($val['user_mobile'] == $_SESSION['member_mobile']) {
+                        $this->write_session($val);
+                        return $val;
+                    }
+                }
+            }
+            else {
+                $this->write_session($bonusex[0]);
+                return $bonusex[0];
+            }
+        }
+
+        return $bonus;
+    }
+
+    public function grab_bonus($type_sn)
+    {
+        $bonus = $this->read_session($type_sn);
+        if($bonus === false)
+        {
+            $param = array( 'type_sn' => $type_sn,
+                'session_id' => $_SESSION['PHPSESSID'],
+                'time_out' => self::grab_period_timeout,
+                'member_mobile' => $_SESSION['member_mobile']);
+
+            $isNew = false; // 是否是一个新的红包
+            $bonus = factory::grab_bonus($param,$isNew);
+            if($bonus == false) {
+                return array();
+            }
+            else
+            {
+                $this->write_session($bonus->get_param());
+                if($isNew && $bonus->isBinded()) {
+                    dcache($bonus->type_sn(),self::type_prefix);
+                }
+            }
+        }
+
+        return $bonus;
+    }
+
+    public function topup($mod_user_bonus,&$bonus)
+    {
+        $datas = array('status' => 3,
+            'user_id' => $_SESSION['member_id'],
+            'user_name' => user_helper::nickname());
+
+        $ret = $mod_user_bonus->edit(array('bonus_id' => $bonus['bonus_id']))->update($datas);
+        if($ret == true) {
+            array_merge($bonus,$datas);
+            $this->write_session($bonus);
+        }
+        return $ret;
+    }
+
+    public function bind_bonus($bonus_sn,$session_id,$mobile)
+    {
+        $bonus_info = self::read_session('',$bonus_sn);
+        if(!empty($bonus_info))
+        {
+            $user_bonus = user_bonus::create_by_param($bonus_info);
+            if($user_bonus->isBinded()) {
+                return true;
+            } else {
+                $bonus_id = $user_bonus->bonus_id();
+                $type_id = $user_bonus->type_id();
+            }
+        }
+
+        if(!isset($type_id))
+        {
+            $user_bonus = user_bonus::create_by_sn($bonus_sn);
+            if($user_bonus->isBinded())
+            {
+                if($user_bonus->user_mobile() == $mobile) {
+                    return true;
+                } else {
+                    return array('code' => errcode::ErrBonusBinded,'msg' => "该红包已经被别人领走.");
+                }
+            }
+
+            $bonus_id = $user_bonus->bonus_id();
+            $type_id = $user_bonus->type_id();
+        }
+
+        $condition = array('type_id' => $type_id,'bonus_id' => $bonus_id,'session_id' => $session_id);
+        $ret = Model('user_bonus')->bind($condition,$mobile);
+        if($ret == true) {
+            $bonus_val = $user_bonus->bonus_value();
+            Model('bonus_type')->edit(array('type_id' => $type_id,
+                'binded_num' => array('exp', 'binded_num+1'),
+                'remain_amount' => array('exp', "remain_amount-" . "{$bonus_val}")));
+
+            $this->clear_session($bonus_sn);
+            dcache($user_bonus->type_sn(),self::type_prefix);
+        }
+
+        return true;
+    }
+
+    public function comment($bonus_sn,$content)
+    {
+        if(empty($bonus_sn)) return false;
+
+        $condition = array('user_mobile' => $_SESSION['member_mobile'],
+            'bonus_sn' => $bonus_sn,
+            'status' => array('in',array(2,3)));
+        $ret = Model('user_bonus')->edit($condition)->update(array('user_comment' => $content));
+        if($ret == true) {
+            $user_bonus = user_bonus::create_by_sn($bonus_sn);
+            dcache($user_bonus->type_sn(),self::type_prefix);
+        }
+    }
+
+    //个人抢到的红包,放到个人的Session 里面.
+    private function read_session($type_sn,$b_sn = '')
+    {
+        if(!isset($_SESSION['bonus'])) return false;
+
+        $bonusex = $_SESSION['bonus'];
+        foreach($bonusex as $bonus_sn => $val)
+        {
+            if($bonus_sn == $b_sn) return $val;
+            if($val['type_sn'] == $type_sn)
+            {
+                $status = $val['status'];
+                if ($status == self::bonus_state_binded) {
+                    return $val;
+                }
+                else if ($status == self::bonus_state_grabed)
+                {
+                    $grab_time = $val['grab_time'];
+                    if ($grab_time > time() - self::grab_period_timeout) {
+                        return $val;
+                    } else {
+                        unset ($_SESSION['bonus'][$bonus_sn]);
+                        return false; // 需要重新抢
+                    }
+                }
+                else {
+                    return $val;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    private function write_session($bonus)
+    {
+        if(!isset($_SESSION['bonus'])) {
+            $_SESSION['bonus'] = array();
+        }
+
+        $bonus_sn = $bonus['bonus_sn'];
+        $_SESSION['bonus'][$bonus_sn] = $bonus;
+    }
+
+    private function clear_session($bonus_sn = '')
+    {
+        if(!empty($bonus_sn))
+        {
+            if(isset($_SESSION['bonus']) && isset($_SESSION['bonus'][$bonus_sn]))  {
+                unset($_SESSION['bonus'][$bonus_sn]);
+            }
+        }
+        else
+        {
+            if(!isset($_SESSION['bonus'])) {
+                unset($_SESSION['bonus']);
+            }
+        }
+    }
+}

+ 7 - 0
helper/bonus/type.php

@@ -78,6 +78,7 @@ class type
             $max = $max_def > $max_val ?  $max_val : $max_def;
             $this->mParam['max_amount'] = floatval($max) / 100;
         }
+        $this->mParam['remain_amount'] = $this->mParam['total_amount'];
     }
 
     public function user_type() {
@@ -125,6 +126,9 @@ class type
             return time() > $start_time;
         }
     }
+    public function get_start_time() {
+        return intval($this->mParam['send_start_date']);
+    }
     public function isEnd() {
         $end_time = intval($this->mParam['send_end_date']);
         if($end_time === 0) {
@@ -134,6 +138,9 @@ class type
             return time() > $end_time;
         }
     }
+    public function binded_over() {
+        return intval($this->mParam['total_num']) == intval($this->mParam['binded_num']);
+    }
 
     static public function crate_by_paramer($paramer)
     {

+ 64 - 1
helper/bonus/user_bonus.php

@@ -4,4 +4,67 @@
  * User: stanley-king
  * Date: 16/4/17
  * Time: 下午7:03
- */
+ */
+
+//  `bonus_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+//  `type_id` tinyint(3) unsigned NOT NULL DEFAULT '0',
+//  `bonus_sn` bigint(20) unsigned NOT NULL DEFAULT '0',
+//  `bonus_value` decimal(10,2) NOT NULL DEFAULT '0.00',
+//  `user_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
+//  `user_mobile` varchar(20) NOT NULL DEFAULT '',
+//  `user_name` varchar(45) NOT NULL,
+//  `user_comment` varchar(45) NOT NULL DEFAULT '',
+//  `get_time` int(11) unsigned NOT NULL DEFAULT '0',
+//  `status` int(2) NOT NULL DEFAULT '0' COMMENT '0 没有被抢,1,被抢,2 被领',
+//  `grab_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '抢红包时间点',
+//  `session_id` varchar(45) NOT NULL DEFAULT '',
+
+class user_bonus
+{
+    private $mParamer;
+
+    private function __construct($param) {
+        $this->mParamer = $param;
+    }
+    public function isBinded() {
+        return (intval($this->mParamer['status']) >= 2);
+    }
+    public function isGrabed() {
+    }
+    public function bonus_sn() {
+        return $this->mParamer['bonus_sn'];
+    }
+    public function bonus_id() {
+        return intval($this->mParamer['bonus_id']);
+    }
+    public function type_id() {
+        return intval($this->mParamer['type_id']);
+    }
+    public function bonus_value() {
+        $val = intval(floatval($this->mParamer['bonus_value']) * 100);
+        return floatval($val) / 100;
+    }
+    public function type_sn() {
+        return $this->mParamer['type_sn'];
+    }
+    public function get_param() {
+        return $this->mParamer;
+    }
+    public function user_mobile() {
+        return $this->mParamer['user_mobile'];
+    }
+
+    static public function create_by_param($param) {
+        return new user_bonus($param);
+    }
+    static public function create_by_sn($bonus_sn) {
+        $mod_bonus = Model('user_bonus');
+        $items = $mod_bonus->get(array('bonus_sn' => $bonus_sn));
+
+        if(empty($items)) {
+            throw new Exception("错误的红包SN号.",errcode::ErrBonusSN);
+        }
+        return new user_bonus($items[0]);
+    }
+
+}

+ 62 - 83
helper/bonus_helper.php

@@ -8,33 +8,34 @@
 
 require_once (BASE_ROOT_PATH . '/helper/bonus/util.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/type.php');
+require_once (BASE_ROOT_PATH . '/helper/bonus/user_bonus.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/generator.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/grab.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/bind.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/factory.php');
+require_once (BASE_ROOT_PATH . '/helper/bonus/manager.php');
+
 require_once (BASE_ROOT_PATH . '/helper/field_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/predeposit_helper.php');
 
 class bonus_helper
 {
-    //红包抢到不绑定手机的过期时间
-    const grab_period_timeout = 10 * 60;
-
-    //红包的四种状态
-    const bonus_state_ungrab = 0; //未抢
-    const bonus_state_grabed = 1; //已抢到
-    const bonus_state_binded = 2; //已绑定手机
-    const bonus_state_topuped= 3; //已经充值
+    static public function filter_type($type_info) {
+        $fileds = 'type_sn,type_bless,send_type,sender_name,total_amount,total_num,grabed_num,binded_num,send_start_date';
+        $ret = array();
+        field_helper::copy_column($ret,$type_info,$fileds);
+        $ret['time_out'] = \bonus\manager::grab_period_timeout;
 
-    static public function check_make_paramer($param)
-    {
-        try
-        {
-            $type = \bonus\type::crate_by_paramer($param);
-        } catch (Exception $ex) {
+        return $ret;
+    }
 
-        }
+    static public function filter_bonus($bonus_info) {
+        $fileds = 'bonus_sn,bonus_value,user_name,user_comment,get_time,status';
+        $ret = array();
+        field_helper::copy_column($ret,$bonus_info,$fileds);
+        return $ret;
     }
+
     static public function isFixed($send_type) {
         return ($send_type == \bonus\type::fixed_amount);
     }
@@ -45,56 +46,78 @@ class bonus_helper
     static public function make_bonus($param)
     {
         $ret = \bonus\factory::make_bonus($param);
-
         return $ret;
     }
 
-    static public function grab_bonus($param)
+    static public function get_typeinfo($type_sn)
     {
-        $ret =\bonus\factory::grab_bonus($param);
-        return $ret;
+        $manager = new \bonus\manager();
+        return $manager->get_typeinfo($type_sn);
     }
 
-    static public function bind_bonus($bonus_sn,$session_id,$mobile) {
-        return Model('user_bonus')->bind($bonus_sn,$session_id,$mobile);
+    static public function get_mine($type_sn) {
+        $manager = new \bonus\manager();
+        return $manager->get_mine($type_sn);
     }
 
-    static public function topup_bonus($mobile)
+    static public function grab_bonus($type_sn)
     {
-        $mod_bonus = Model('user_bonus');
-        $ret = $mod_bonus->getAllBind($mobile);
-        if(empty($ret)) {
+        $manager = new \bonus\manager();
+        return $manager->grab_bonus($type_sn);
+    }
+
+    static public function bind_bonus($bonus_sn,$session_id,$mobile)
+    {
+        try
+        {
+            $manager = new \bonus\manager();
+            return $manager->bind_bonus($bonus_sn,$session_id,$mobile);
+        } catch (Exception $ex) {
+            return array($ex->getCode(),$ex->getMessage());
+        }
+    }
+    static public function comment($bonus_sn,$comment)
+    {
+        try
+        {
+            $manager = new \bonus\manager();
+            return $manager->comment($bonus_sn,$comment);
+        } catch (Exception $ex) {
             return false;
         }
+    }
 
-        $type_ids = array();
-        foreach($ret as $val) {
-            array_push($type_ids,intval($val['bonus_type_id']));
+    static public function topup_bonus($mobile)
+    {
+        $mod_bonus = Model('user_bonus');
+        $bind_bonus = $mod_bonus->getAllBind($mobile);
+        if(empty($bind_bonus)) {
+            return false;
         }
 
-        array_unique($type_ids);
-        $types = \bonus\type::create_by_ids($type_ids);
-
+        $manager = new \bonus\manager();
         $pd_helper = new predeposit_helper();
+
         $bonusex = array();
-        foreach($ret as $val)
+        foreach($bind_bonus as $val)
         {
-            $type_id = $val['bonus_type_id'];
+            $type_id = $val['type_id'];
+            $type = \bonus\type::create_by_ids($type_id);
             $bonus = array();
-            field_helper::copy_column($bonus,$types[$type_id]->get_param(),'type_sn,type_name,type_bless,sender_name,total_amount,total_num,grabed_num,binded_num,send_end_date');
-            field_helper::copy_column($bonus,$val,'bonus_sn,bonus_value,grab_time,get_time,status');
-            $info = sprintf("来自%s的红包.",$bonus['sender_name']);
+            $bonus['type_info'] = $type->get_param();
+            $bonus['mine_bonus'] = $val;
 
             try
             {
+                $info = sprintf("来自%s的红包.",$bonus['sender_name']);
                 Db::beginTransaction();
                 $pd_helper->bonus_add_money($bonus['bonus_value'],$bonus['bonus_sn'],$bonus['type_name'],$info);
-                if($mod_bonus->topuped() === false) {
+                if($manager->topup($mod_bonus,$val) === false) {
                     throw new Exception();
+                } else {
+                    array_push($bonusex,$bonus);
                 }
                 Db::commit();
-
-                array_push($bonusex,$bonus);
             } catch (Exception $ex) {
                 Db::rollback();
             }
@@ -106,48 +129,4 @@ class bonus_helper
             return $bonusex;
         }
     }
-
-    static public function check_insession($type_sn)
-    {
-        if(isset($_SESSION['bonus'][$type_sn]))
-        {
-            $cur_bonus = &$_SESSION['bonus'][$type_sn];
-            $status = intval($cur_bonus['status']);
-            if ($status == self::bonus_state_binded) {
-                return $cur_bonus;
-            }
-            else if ($status == self::bonus_state_grabed) {
-                $grab_time = $cur_bonus['grab_time'];
-                if ($grab_time > time() - self::grab_period_timeout) {
-                    return $cur_bonus;
-                }
-            }
-        }
-
-        return false;
-    }
-
-    static public function add_session($type_info,$bonus_info)
-    {
-        if(!isset($_SESSION['bonus'])) {
-            $_SESSION['bonus'] = array();
-        }
-
-        $type_sn = $type_info['type_sn'];
-        $_SESSION['bonus'][$type_sn] = array();
-
-        $bonus = &$_SESSION['bonus'][$type_sn];
-
-        field_helper::copy_column($bonus,$type_info,'type_sn,type_name,type_bless,sender_name,total_amount,total_num,grabed_num,binded_num,send_end_date');
-        field_helper::copy_column($bonus,$bonus_info,'bonus_sn,bonus_value,grab_time,get_time,status');
-
-        return $bonus;
-    }
-
-    static public function clear_session()
-    {
-        if(!isset($_SESSION['bonus']))  {
-            unset($_SESSION['bonus']);
-        }
-    }
 }

+ 31 - 1
helper/user_helper.php

@@ -4,4 +4,34 @@
  * User: stanley-king
  * Date: 16/4/17
  * Time: 下午6:46
- */
+ */
+
+class user_helper
+{
+    static public function nickname()
+    {
+        if(isset($_SESSION['member_nickname']) && !empty($_SESSION['member_nickname'])) {
+            return $_SESSION['member_nickname'];
+        }
+
+        if(isset($_SESSION['member_truename']) && !empty($_SESSION['member_truename'])) {
+            return $_SESSION['member_truename'];
+        }
+
+        if(isset($_SESSION['member_mobile']) && !empty($_SESSION['member_mobile']))
+        {
+            $mobile = $_SESSION['member_mobile'];
+            if(strlen($mobile) == 11) {
+                $arData = str_split($mobile,4);
+                return sprintf("mob%s****%s",$arData[0],$arData[2]);
+            }
+        }
+
+        return '';
+    }
+
+    static public function isLogin()
+    {
+        return ($_SESSION['is_login'] == 1);
+    }
+}

+ 1 - 1
mobile/control/bonus.php

@@ -159,7 +159,7 @@ class bonusControl extends mobileHomeControl
                     $bonus_info = array();
                     foreach ($user_bonus as $value) {
                         $info = [];
-                        $bonus_type = $this->getBonusType(strval($value['bonus_type_id']));
+                        $bonus_type = $this->getBonusType(strval($value['type_id']));
                         $info['sender'] = $bonus_type['sender'];
                         $info['type_name'] = $bonus_type['type_name'];
                         $info['bonus_value'] = $value['bonus_value'];

+ 85 - 71
mobile/control/bonusex.php

@@ -10,69 +10,79 @@ defined('InShopNC') or exit('Access Invalid!');
 
 require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/predeposit_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/user_helper.php');
 
 
 class bonusexControl extends mobileControl
 {
-    const def_bless = '恭喜发财大吉大利';
-
     public function __construct() {
         parent::__construct();
     }
 
-    public function makeOp()
+    private function fileter_typeinfos($type_infos,&$type_info,&$binded_info)
     {
-        if($_SESSION['is_login'] != 1) {
-            return self::outerr(errcode::ErrUnLogin);
+        $type_info = bonus_helper::filter_type($type_infos['type_info']);
+
+        $binded_info = array();
+        $binded_infos = $type_infos['binded_info'];
+        if(is_array($binded_infos)) {
+            foreach($binded_infos as $val) {
+                $user_info = bonus_helper::filter_bonus($val);
+                array_push($binded_info,$user_info);
+            }
         }
+    }
 
-        $param = array();
-        $send_type = intval($_GET['send_type']);
-        if(!in_array($send_type,array(1,2))) {
-            return self::outerr(errcode::ErrParamter,"请输入正确的红包类型.");
+    //打开红包页面:
+    //1:如果已经被抢光,显示已经被抢光界面
+    //2:
+    public function openOp()
+    {
+        if(!isset($_GET['type_sn']) || empty($_GET['type_sn'])) {
+            return self::outerr(errcode::ErrParamter,"需要红包 type_sn 参数.");
         }
-        $param['send_type'] = $send_type; // '红包类型,1为随机红包,2为固定额度红包'
-        $param['type_bless'] = isset($_GET['type_bless']) && !empty($_GET['type_bless']) ? $_GET['type_bless'] : self::def_bless;
+        $type_sn = $_GET['type_sn'];
 
-        $param['total_num'] = intval($_GET['total_num']);
-        if($param['total_num'] <= 0) {
-            return self::outerr(errcode::ErrParamter,"红包个数不能小于1.");
+        $type_infos = bonus_helper::get_typeinfo($type_sn);
+        if(empty($type_infos)) {
+            return self::outerr(errcode::ErrBonus,"无此红包.");
         }
+        $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
 
-        if(bonus_helper::isFixed($send_type))
-        {
-            $fixed_mondey = floatval($_GET['fixed_money']);
-            if ($fixed_mondey * 100 < 1) {
-                return self::outerr(errcode::ErrParamter, "红包额度不能小于一分钱.");
-            }
-            $param['total_amount'] = $fixed_mondey * $param['total_num'];
-            $param['fixed_money'] = $fixed_mondey;
+        $mine_bonus = bonus_helper::get_mine($type_sn);
+        if($mine_bonus != false) { //显示我抢到的红包,按照状态进行判断
+            $mine_bonus = bonus_helper::filter_bonus($mine_bonus);
+            return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info));
         }
-        else if (bonus_helper::isRandom($send_type))
+        else
         {
-            $total_amount = floatval($_GET['total_amount']);
-            if($total_amount * 100 < $param['total_num']) {
-                return self::outerr(errcode::ErrParamter,"金额不够.");
+            $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+            if($type->binded_over()) {
+                return self::outerr(errcode::ErrBonusGrabNull,"红包已经被抢光");
+            } else {
+                return self::outsuccess(array('type_info' => $type_info),"bonus/open");
             }
-            $param['total_amount'] = $total_amount;
         }
-        $param['use_type'] = 1;
-        $param['user_type'] = 2;
-        $pre_helper = new predeposit_helper();
-        if(!$pre_helper->is_enough($param['total_amount'])) {
-            return self::outerr(errcode::ErrBonusNotEnough,"余额不够发送红包.");
+    }
+    public function detailOp()
+    {
+        if(!isset($_GET['type_sn']) || empty($_GET['type_sn'])) {
+            return self::outerr(errcode::ErrParamter,"需要红包 type_sn 参数.");
         }
+        $type_sn = $_GET['type_sn'];
 
-        $param['sender_id'] = $_SESSION['member_id'];
-        $param['sender_mobile'] = $_SESSION['member_mobile'];
-        $param['sender_name'] = $_SESSION['member_name'];
+        $type_infos = bonus_helper::get_typeinfo($type_sn);
+        if(empty($type_infos)) {
+            return self::outerr(errcode::ErrBonus,"无此红包.");
+        }
 
-        $ret = bonus_helper::make_bonus($param);
-        if($ret === false) {
-            return self::outerr(errcode::ErrBonus,"生成红包失败.");
-        } else {
-            return self::outsuccess(array('type_sn' => $ret,'url' => ""));
+        $mine_bonus = bonus_helper::get_mine($type_sn);
+        $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
+        if(!empty($mine_bonus)) { //显示我抢到的红包,按照状态进行判断
+            $mine_bonus = bonus_helper::filter_bonus($mine_bonus);
         }
+
+        return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info));
     }
 
     public function grabOp()
@@ -80,26 +90,30 @@ class bonusexControl extends mobileControl
         if(!isset($_GET['type_sn']) || empty($_GET['type_sn'])) {
             return self::outerr(errcode::ErrParamter,"需要红包 type_sn 参数.");
         }
-
         $type_sn = $_GET['type_sn'];
-        $bonus = bonus_helper::check_insession($type_sn);
-        if($bonus === false)
+
+        $type_infos = bonus_helper::get_typeinfo($type_sn);
+        if(empty($type_infos)) {
+            return self::outerr(errcode::ErrBonus,"无此红包.");
+        }
+
+        $mine_bonus = bonus_helper::get_mine($type_sn);
+        $this->fileter_typeinfos($type_infos,$type_info,$binded_info);
+        if(!empty($mine_bonus)) { //显示我抢到的红包,按照状态进行判断
+            $mine_bonus = bonus_helper::filter_bonus($mine_bonus);
+            return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info));
+        }
+        else
         {
-            $time_out = bonus_helper::grab_period_timeout;
-            $param = array( 'type_sn' => $type_sn,
-                'session_id' => $_SESSION['PHPSESSID'],
-                'time_out' => $time_out,
-                'member_mobile' => $_SESSION['member_mobile']);
-
-            $bonus_info = bonus_helper::grab_bonus($param);
-            if(empty($bonus_info)) {
-                return self::outerr(errcode::ErrBonusGrabNull,"红包已经被抢光了!"); //被领光
+            $type = \bonus\type::crate_by_paramer($type_infos['type_info']);
+            if($type->binded_over()) {
+                return self::outerr(errcode::ErrBonusGrabNull,"红包已经被抢光");
             } else {
-                $bonus = bonus_helper::add_session($bonus_info['type_info'],$bonus_info['bonus_info']);
+                $mine_bonus = bonus_helper::grab_bonus($type_sn);
+                $mine_bonus = bonus_helper::filter_bonus($mine_bonus->get_param());
+                return self::outsuccess(array('type_info' => $type_info, 'mine_bonus' => $mine_bonus,'binded_info' => $binded_info));
             }
         }
-
-        return self::outsuccess($bonus);
     }
 
     public function bindOp()
@@ -112,11 +126,13 @@ class bonusexControl extends mobileControl
         if($_SESSION['is_login'] == 1) {
             $mobile = $_SESSION['member_mobile'];
         }
-        else {
+        else
+        {
             if (!isset($_GET['mobile']) || empty($_GET['mobile'])) {
                 return self::outerr(errcode::ErrParamter,"请输入手机号码.");
             } else {
                 $mobile = $_GET['mobile'];
+                $_SESSION['member_mobile'] = $mobile;
             }
         }
 
@@ -133,31 +149,29 @@ class bonusexControl extends mobileControl
         }
 
         $ret = bonus_helper::bind_bonus($bonus_sn,$_SESSION['PHPSESSID'],$mobile);
-        if($ret) {
-            bonus_helper::clear_session();
+        if($ret == true) {
             return self::outsuccess(NULL);
         } else {
-            return self::outerr(errcode::ErrBonus,"红包绑定失败.");
+            return self::outerr($ret['code'],$ret['msg']);
         }
     }
 
-    public function topupOp()
+    //红包留言
+    public function commentOp()
     {
-        if($_SESSION['is_login'] != 1) {
-            return self::outerr(errcode::ErrUnLogin);
+        if(!isset($_GET['bonus_sn']) || empty($_GET['bonus_sn'])) {
+            return self::outerr(errcode::ErrParamter,"请输入红包序列号.");
+        }
+        $bonus_sn = $_GET['bonus_sn'];
+        if(!isset($_GET['comment']) || empty($_GET['comment'])) {
+            return self::outerr(errcode::ErrParamter,"请输入留言.");
         }
+        $comment = $_GET['comment'];
 
-        $bonus = bonus_helper::topup_bonus($_SESSION['member_mobile']);
-        if($bonus === false) {
-            bonus_helper::clear_session();
+        if(bonus_helper::comment($bonus_sn,$comment) == true) {
             return self::outsuccess(array());
         } else {
-            return self::outsuccess($bonus);
+            return self::outerr(errcode::ErrBonusComment,"留言失败.");
         }
     }
-
-    public function send_listOp()
-    {
-
-    }
 }

+ 1 - 0
mobile/control/config.php

@@ -37,6 +37,7 @@ class configControl extends mobileHomeControl
             foreach ($result as $value) {
                 $ret[$value['name']] = array('value'=>$value['value']);
             }
+            $ret['feed_back_url'] = array('value'=> 'http://p.lrlz.com/' . '/mobile/index.php?act=member_feedback&op=add&client_type=ios');
         }
         return self::outsuccess($ret);
     }

+ 0 - 1
mobile/control/index.php

@@ -213,7 +213,6 @@ class indexControl extends mobileHomeControl
     {
         $goods_ids = rkcache('home_goods',true);
 
-
         $ret = array_chunk($goods_ids,$this->page_size());
         $pages = count($ret);
         $page_no = $pages >= $this->page_no() ? $this->page_no() : $pages;

+ 125 - 1
mobile/control/member_bonus.php

@@ -4,4 +4,128 @@
  * User: stanley-king
  * Date: 16/4/16
  * Time: 下午6:08
- */
+ */
+
+require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/predeposit_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/user_helper.php');
+
+
+class member_bonusControl extends mbMemberControl
+{
+    const def_bless = '恭喜发财大吉大利';
+
+    public function makeOp()
+    {
+        $param = array();
+        $send_type = intval($_GET['send_type']);
+        if(!in_array($send_type,array(1,2))) {
+            return self::outerr(errcode::ErrParamter,"请输入正确的红包类型.");
+        }
+        $param['send_type'] = $send_type; // '红包类型,1为随机红包,2为固定额度红包'
+        $param['type_bless'] = isset($_GET['type_bless']) && !empty($_GET['type_bless']) ? $_GET['type_bless'] : self::def_bless;
+
+        $param['total_num'] = intval($_GET['total_num']);
+        if($param['total_num'] <= 0) {
+            return self::outerr(errcode::ErrParamter,"红包个数不能小于1.");
+        }
+
+        if(bonus_helper::isFixed($send_type))
+        {
+            $fixed_mondey = floatval($_GET['fixed_money']);
+            if ($fixed_mondey * 100 < 1) {
+                return self::outerr(errcode::ErrParamter, "红包额度不能小于一分钱.");
+            }
+            $param['total_amount'] = $fixed_mondey * $param['total_num'];
+            $param['fixed_money'] = $fixed_mondey;
+        }
+        else if (bonus_helper::isRandom($send_type))
+        {
+            $total_amount = floatval($_GET['total_amount']);
+            if($total_amount * 100 < $param['total_num']) {
+                return self::outerr(errcode::ErrParamter,"金额不够.");
+            }
+            $param['total_amount'] = $total_amount;
+        }
+        $param['use_type'] = 1;
+        $param['user_type'] = 2;
+        $pre_helper = new predeposit_helper();
+        if(!$pre_helper->is_enough($param['total_amount'])) {
+            return self::outerr(errcode::ErrBonusNotEnough,"余额不够发送红包.");
+        }
+
+        $param['sender_id'] = $_SESSION['member_id'];
+        $param['sender_mobile'] = $_SESSION['member_mobile'];
+        $param['sender_name'] = user_helper::nickname();
+
+        $ret = bonus_helper::make_bonus($param);
+
+        if($ret === false) {
+            return self::outerr(errcode::ErrBonus,"生成红包失败.");
+        }
+        else
+        {
+            if(isset($_SESSION['send_bonus'])) {
+                unset($_SESSION['send_bonus']);
+            }
+            $url = BASE_SITE_URL . "mobile/index.php?act=bonusex&op=open&type_sn={$ret}";
+            return self::outsuccess(array('type_sn' => $ret,'url' => "{$url}"));
+        }
+    }
+
+    public function topupOp()
+    {
+        $bonus = bonus_helper::topup_bonus($_SESSION['member_mobile']);
+        if($bonus === false) {
+            return self::outsuccess(array("bonusex" => array()));
+        }
+        else
+        {
+            $bonusex = array();
+            foreach($bonus as $val)
+            {
+                $all_type_info = bonus_helper::get_typeinfo($val['type_sn']);
+                if(!empty($all_type_info) && !empty($all_type_info['type_info']))
+                {
+                    $type_info = bonus_helper::filter_type($all_type_info['type_info']);
+                    $bonus_info = bonus_helper::filter_bonus($val);
+
+                    array_push($bonusex,array('type_info' => $type_info,'bonus_info' => $bonus_info));
+                }
+            }
+
+            return self::outsuccess(array("bonusex" => $bonusex));
+        }
+    }
+
+    //我已经发送的红包
+    public function send_listOp()
+    {
+        if(!isset($_SESSION['send_bonus'])) {
+            $mod_type = Model('bonus_type');
+            $items = $mod_type->get(array('sender_id' => $_SESSION['member_id']));
+            $_SESSION['send_bonus'] = $items;
+        }
+        else {
+            $items = $_SESSION['send_bonus'];
+        }
+
+        if(empty($items)) {
+            return self::outsuccess(array('bonus_types' => array(), 'mobile_page' => mobile_page(0)));
+        }
+
+
+        $ret = array_chunk($items,$this->page_size());
+        $pages = count($ret);
+        $page_no = $pages >= $this->page_no() ? $this->page_no() : $pages;
+        $bonus_types = $ret[$page_no - 1];
+
+        $type_infos = array();
+        foreach($bonus_types as $val) {
+            $type_info = bonus_helper::filter_type($val);
+            array_push($type_infos,$type_info);
+        }
+
+        return self::outsuccess(array('type_infos' => $type_infos, 'mobile_page' => mobile_page($pages)));
+    }
+}

+ 2 - 0
mobile/control/member_refund.php

@@ -82,6 +82,7 @@ class member_refundControl extends mbMemberControl
         }
     }
 
+    //该函数用来返回退款具体信息。已经付款,未发货时退款,退货。
     public function refund_one_infoOp()
     {
         $order_info = Model('order')->getOrderInfo(array('order_sn' => $_GET['order_sn']));
@@ -138,6 +139,7 @@ class member_refundControl extends mbMemberControl
         return self::outsuccess(array('ret' => 1, 'reason_list' => $reason_list,'goods' => $goods));
     }
 
+    //已经付款,未发货时退款,退货。只能单品退款
     public function add_refund_oneOp()
     {
         if(!isset($_GET['refund_type']) || empty($_GET['refund_type'])

+ 1 - 1
mobile/control/test.php

@@ -99,7 +99,7 @@ class testControl extends mobileHomeControl
     public function getAndUpdateBonus($user_id,$pay_amount){
 
         $condition['user_id'] = $user_id;
-        $condition['bonus_type_id'] = 1;
+        $condition['type_id'] = 1;
         $bonus_list = Model()->table("user_bonus")->where($condition)->select();
 
         $ret_value = 0;

+ 39 - 0
mobile/templates/default/bonus/open.php

@@ -0,0 +1,39 @@
+<!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"/>
+</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="logo"></div>
+                <div class="msg_box">
+                    <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);
+                        if($type->isRandomAmount()) {
+                            $str = '发了一个红包,金额随机';
+                        } else {
+                            $str = '发了一个红包,金额固定';
+                        }
+                        echo($str); ?></p>
+                </div>
+                <div class="msg_bottom">
+                    <p><?php echo($output['type_info']['type_bless']); ?></p>
+                </div>
+            <div>
+                <a href="javascript:void(0)" target="_self" class="open"></a>
+            </div>
+        </div>
+    </div>
+</body>
+</html>

+ 3 - 0
mobile/util/errcode.php

@@ -59,6 +59,9 @@ class errcode extends SplEnum
     const ErrBonusMake = 10802;
     const ErrBonusGrabNull = 10803;
     const ErrBonusNotEnough = 10804;
+    const ErrBonusSN = 10805;
+    const ErrBonusBinded = 10806;
+    const ErrBonusComment = 10807;
 
     //套装
     const ErrBLUnExist = 10900;

+ 2 - 2
shop/control/h5_hb.php

@@ -100,7 +100,7 @@ class h5_hbControl extends BaseH5Control
             Model::beginTransaction();
             // 查找一条记录
             $condition['status'] = 0;
-            $condition['bonus_type_id'] = $type_id;
+            $condition['type_id'] = $type_id;
 
             // 此时记得加载lock
             $result = Model()->table('user_bonus')->where($condition)->limit(1)->lock(true)->order('bonus_id asc')->select();
@@ -143,7 +143,7 @@ class h5_hbControl extends BaseH5Control
         }
 
         $condition['user_mobile'] = $phone_num;
-        $condition['bonus_type_id'] = $type_id;
+        $condition['type_id'] = $type_id;
         $ret = Model()->table('user_bonus')->where($condition)->select();
 
         if (!empty($ret)) {