james 8 gadi atpakaļ
vecāks
revīzija
de3cf24615
34 mainītis faili ar 702 papildinājumiem un 445 dzēšanām
  1. 27 23
      admin/control/stat_anotice.php
  2. 9 7
      admin/templates/default/stat.anotice.favorite.list.php
  3. 17 21
      admin/templates/default/stat.anotice.fcode.list.php
  4. 9 7
      admin/templates/default/stat.anotice.list.php
  5. 0 1
      core/framework/db/mysql.php
  6. 142 122
      core/framework/db/mysqli.php
  7. 4 7
      core/framework/libraries/log.php
  8. 1 2
      core/framework/libraries/model.php
  9. 14 3
      core/framework/libraries/sendmembermsg.php
  10. 12 8
      crontab/control/date.php
  11. 1 0
      data/resource/mobile/activity/css/count_down.css
  12. 28 7
      data/resource/mobile/fcode/css/main.css
  13. BIN
      data/resource/mobile/fcode/images/error.png
  14. BIN
      data/resource/mobile/fcode/images/goods_img.png
  15. BIN
      data/resource/mobile/fcode/images/loading_icon.gif
  16. BIN
      data/resource/mobile/fcode/images/success.png
  17. 88 156
      data/resource/mobile/fcode/js/fcode.js
  18. 10 1
      helper/account_helper.php
  19. 6 4
      helper/fcode/generator.php
  20. 10 4
      helper/fcode/operator.php
  21. 1 1
      helper/goods_helper.php
  22. 2 1
      helper/http_header.php
  23. 1 0
      helper/model/goods_summary.php
  24. 1 2
      mobile/control/control.php
  25. 48 12
      mobile/control/fcode.php
  26. 1 1
      mobile/control/member_favorites.php
  27. 6 17
      mobile/control/search.php
  28. 0 1
      mobile/templates/default/activity/limit_entra.php
  29. 101 22
      mobile/templates/default/fcode/bind.php
  30. 54 0
      mobile/templates/default/fcode/error.php
  31. 29 11
      mobile/templates/default/fcode/index.php
  32. 70 0
      mobile/templates/default/fcode/success.php
  33. 9 0
      test/TestFcode.php
  34. 1 4
      test/redisTest.php

+ 27 - 23
admin/control/stat_anotice.php

@@ -68,35 +68,39 @@ class stat_anoticeControl extends SystemControl
 
     public function fcodeOp()
     {
-        $batch_code = trim($_REQUEST['batch_code']);
-        $mod_fcode = Model('goods_fcode');
-        $cond = [];
-        if (empty($batch_code)) {
-            $cond = '';
-        } else {
-            $cond = array('batch_code'=>"{$batch_code}");
-        }
 
-        $result = $mod_fcode->field('goods_commonid,fc_state,batch_code,fc_code,count(*) as nc_count')->where($cond)->group('batch_code,fc_state')->select();
+        $mod_goods = Model('goods');
+        $mod_fcode = Model('goods_fcode');
+        $items = $mod_fcode->field('goods_commonid,batch_code,count(*) as nc_count')->group('goods_commonid,batch_code')->select();
 
-        foreach ($result as $item=>$value)
+        $result = [];
+        foreach ($items as $item)
         {
-            $data[$value['batch_code']]['batch_code']= $value['batch_code'];
-            $data[$value['batch_code']]['fc_sum'] += $value['nc_count'];
-            if ($value['fc_state'] == '0')  {
-                $data[$value['batch_code']]['unused_quantity']= $value['nc_count'];
-            } else if ($value['fc_state'] == '1') {
-                $data[$value['batch_code']]['used_quantity']= $value['nc_count'];
-            }
-            $data[$value['batch_code']]['goods_commonid']= $value['goods_commonid'];
-            if (empty($data[$value['batch_code']]['fc_link']))
-            {
-                $url = BASE_SITE_URL . '/mobile/index.php?act=fcode&op=index' . "&common_id={$value['goods_commonid']}&batch_code={$value['batch_code']}";
-                $data[$value['batch_code']]['fc_link'] = $url;
+            $val = [];
+
+            $val['goods_commonid'] = $item['goods_commonid'];
+            $val['batch_code'] = $item['batch_code'];
+            $val['count'] = $item['nc_count'];
+
+            $unused = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'fc_state' => 0))->count();
+            $binded  = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'grab_state' => 2))->count();
+
+            $val['used'] = $item['nc_count'] - $unused;
+            $val['binded'] = $binded;
+
+            $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$item['goods_commonid']}&batch_code={$item['batch_code']}";
+            $val['fc_link'] = $url;
+            $goods = $mod_goods->where(array('goods_commonid' => $item['goods_commonid']))->limit(1)->select();
+            if(empty($goods)) {
+                $val['goods_name'] = "不存在了!";
+            } else {
+                $val['goods_name'] = $goods[0]['goods_name'];
             }
+
+            $result[] = $val;
         }
 
-        Tpl::output('list', $data);
+        Tpl::output('list', $result);
         Tpl::showpage('stat.anotice.fcode.list');
     }
 }

+ 9 - 7
admin/templates/default/stat.anotice.favorite.list.php

@@ -68,18 +68,20 @@
                 <th colspan="15" class="nobg"><?php echo $lang['nc_list'];?></th>
             </tr>
             <tr class="thead">
-                <th class="align-center">商品ID</th>
-                <th class="align-center">商品名称</th>
-                <th class="align-center">被收藏次数</th>
+                <th class="w60 align-left">编号</th>
+                <th class="w60 align-left">商品ID</th>
+                <th class="w200 align-left">商品名称</th>
+                <th class="w60 align-left">被收藏次数</th>
             </tr>
             </thead>
             <tbody>
-            <?php if(!empty($output['list']) && is_array($output['list'])){ ?>
+            <?php if(!empty($output['list']) && is_array($output['list'])){ $i=1; ?>
                 <?php foreach($output['list'] as $item){ ?>
                     <tr class="hover">
-                        <td class="w300 align-center"><?php echo $item['goods_id'];?></td>
-                        <td class="w300"><?php echo $item['goods_name'];?></td>
-                        <td class="nowrap w300 align-center"><?php echo $item['nc_count'];?></td>
+                        <td class="w60 align-left"><?php echo $i?></td>
+                        <td class="w60 align-left"><?php echo $item['goods_id'];?></td>
+                        <td class="w200 align-left"><?php echo $item['goods_name'];?></td>
+                        <td class="nowrap w60 align-left"><?php echo $item['nc_count'];?></td>
                     </tr>
                 <?php } ?>
             <?php }else { ?>

+ 17 - 21
admin/templates/default/stat.anotice.fcode.list.php

@@ -56,32 +56,28 @@
                 <th colspan="15" class="nobg"><?php echo $lang['nc_list'];?></th>
             </tr>
             <tr class="thead">
-                <th class="align-center">F码批次</th>
-                <th class="align-center">F码生成地址</th>
-                <th class="align-center">生成数量</th>
-                <th class="align-center">已使用</th>
-                <th class="align-center">未使用</th>
+                <th class="w60 align-left">编号</th>
+                <th class="w60 align-left">平台编码</th>
+                <th class="w60 align-left">F码批次</th>
+                <th class="w200 align-left">商品名称</th>
+                <th class="w60 align-left">生成数量</th>
+                <th class="w60 align-left">已使用</th>
+                <th class="w60 align-left">已领取</th>
+                <th class="w300 align-left">F码生成地址</th>
             </tr>
             </thead>
             <tbody>
-            <?php if(!empty($output['list']) && is_array($output['list'])){ ?>
+            <?php if(!empty($output['list']) && is_array($output['list'])){  $i = 1;?>
                 <?php foreach($output['list'] as $item){ ?>
                     <tr class="hover">
-                        <td class="w300 align-center"><?php echo $item['batch_code'];?></td>
-                        <td class="w300"><?php echo $item['fc_link'];?></td>
-                        <td class="align-center"><?php echo $item['fc_sum']?></td>
-                        <td class="nowrap w300 align-center"><?php
-                            if (empty($item['used_quantity']))
-                                echo 0;
-                            else
-                                echo $item['used_quantity'];
-                            ?></td>
-                        <td class="align-center"><?php
-                            if (empty($item['unused_quantity']))
-                                echo 0;
-                            else
-                                echo $item['unused_quantity'];
-                            ?></td>
+                        <td class="w60 align-left"><?php echo $i++;?></td>
+                        <td class="w60 align-left"><?php echo $item['goods_commonid'];?></td>
+                        <td class="w60 align-left"><?php echo $item['batch_code'];?></td>
+                        <td class="w200 align-left"><?php echo $item['goods_name'];?></td>
+                        <td class="w60 align-left"><?php echo $item['count'];?></td>
+                        <td class="w60 align-left"><?php echo $item['used'];?></td>
+                        <td class="w60 align-left"><?php echo $item['binded'];?></td>
+                        <td class="w300 align-left"><?php echo $item['fc_link'];?></td>
                     </tr>
                 <?php } ?>
             <?php }else { ?>

+ 9 - 7
admin/templates/default/stat.anotice.list.php

@@ -68,18 +68,20 @@
                 <th colspan="15" class="nobg"><?php echo $lang['nc_list'];?></th>
             </tr>
             <tr class="thead">
-                <th class="align-center">商品ID</th>
-                <th class="align-center">商品名称</th>
-                <th class="align-center">到货通知订阅次数</th>
+                <th class="w60 align-left">编号</th>
+                <th class="w60 align-left">商品ID</th>
+                <th class="w200 align-left">商品名称</th>
+                <th class="align-left w60">到货通知订阅次数</th>
             </tr>
             </thead>
             <tbody>
-            <?php if(!empty($output['list']) && is_array($output['list'])){ ?>
+            <?php if(!empty($output['list']) && is_array($output['list'])){ $i=1;?>
                 <?php foreach($output['list'] as $item){ ?>
                     <tr class="hover">
-                        <td class="w300 align-center"><?php echo $item['goods_id'];?></td>
-                        <td class="w300"><?php echo $item['goods_name'];?></td>
-                        <td class="nowrap w300 align-center"><?php echo $item['nc_count'];?></td>
+                        <td class="w60 align-left"><?php echo $i++;?></td>
+                        <td class="w60 align-left"><?php echo $item['goods_id'];?></td>
+                        <td class="w200 align-left"><?php echo $item['goods_name'];?></td>
+                        <td class="nowrap w60 align-left"><?php echo $item['nc_count'];?></td>
                     </tr>
                 <?php } ?>
             <?php }else { ?>

+ 0 - 1
core/framework/db/mysql.php

@@ -129,7 +129,6 @@ class Db
 			    throw_exception($error.'<br/>'.$sql);
 			} else {
 			    Log::record($error."\r\n".$sql,Log::ERR);
-			    Log::record($sql,Log::SQL);
 			    return false;
 			}
 		} else {

+ 142 - 122
core/framework/db/mysqli.php

@@ -13,49 +13,34 @@ require_once(BASE_CORE_PATH . '/framework/function/statistic_tm.php');
 
 class Db
 {
+    const ErrUnConnect = 2006;
+
 	private static $link = array();
 	private static $iftransacte = true;
-    const reconnect_time = 3600;
 
 	private function __construct()
 	{
 		if (!extension_loaded('mysqli')) {
 			throw_exception("Db Error: mysqli is not install");
 		}
+		else {
+            self::init_link();
+        }
 	}
 
-	private static function connect($host = 'slave')
-	{
-        static $connect_time = 0;
-		if((time() - $connect_time > self::reconnect_time) && $connect_time > 0)
-		{
-		    if(is_object(self::$link[$host]) && self::$link[$host]->ping()) {
-		        return;
-            } else {
-                self::closeLink('master');
-                self::closeLink('slave');
-            }
-		}
-
-		if (C('db.master') == C('db.slave'))
-		{
-			if (is_object(self::$link['slave'])){
-				self::$link['master'] = &self::$link['slave'];
-				return ;
-			}
-			elseif(is_object(self::$link['master'])){
-				self::$link['slave'] = &self::$link['master'];
-				return ;
-			}
-		}
-
-		if (!in_array($host,array('master','slave'))) {
-		    $host = 'slave';
+	private static function init_link()
+    {
+        if(!isset(self::$link['master']) || is_object(self::$link['master']) == false) {
+            self::connect('master');
         }
+        if(!isset(self::$link['slave']) || is_object(self::$link['slave']) == false) {
+            self::connect('slave');
+        }
+    }
 
-		if (is_object(self::$link[$host])) {
-			return;
-		}
+	private static function connect($host = 'slave')
+	{
+        self::closeLink($host);
 
         $conf = C('db.'.$host);
         self::$link[$host] = @new mysqli($conf['dbhost'], $conf['dbuser'], $conf['dbpwd'], $conf['dbname'], $conf['dbport']);
@@ -65,7 +50,6 @@ class Db
 		    throw_exception("Db Error: database connect failed errno={$err_no} err={$error}");
         }
 
-        $connect_time = time();
         switch (strtoupper($conf['dbcharset']))
 		{
 			case 'UTF-8':
@@ -105,16 +89,16 @@ class Db
 
 	private static function closeLink($host)
 	{
-		if(is_object(self::$link[$host])){
+		if(isset(self::$link[$host]) && is_object(self::$link[$host])) {
 			self::$link[$host]->close();
 		}
         self::$link[$host] = null;
     }
 
-    public static function ping($host = 'master') {
+    public static function ping($host = 'master')
+    {
         if (is_object(self::$link[$host])) {
-            self::$link[$host]->close();
-            self::$link[$host] = null;
+            return self::$link[$host]->ping();
         }
     }
 
@@ -126,27 +110,45 @@ class Db
 	 */
 	public static function query($sql, $host = 'master')
 	{
-		self::connect($host);
-		$staer = new statistic_tm();
-		$query = self::$link[$host]->query($sql);
-		$staer->end();
-
-		if ($query === false)
-		{
-		    $error = 'Db Error: no=' . mysqli_errno(self::$link[$host]) . ' error=' .mysqli_error(self::$link[$host]);
-			if (C('debug')) {
-			    throw_exception($error.'<br/>'.$sql);
-			} else {
-			    Log::record($error."\r\n".$sql,Log::ERR);
-			    Log::record($sql,Log::SQL);
-			    return false;
-			}
-		}
-		else
-		{
-			Log::record($sql . " [ RunTime:" . $staer->elapsed(6) . "s ]", Log::SQL);
-			return $query;
-		}
+	    self::init_link();
+
+	    $count = 0;
+	    do
+        {
+            $staer = new statistic_tm();
+            $query = self::$link[$host]->query($sql);
+            $staer->end();
+
+            if ($query === false)
+            {
+                $errno = mysqli_errno(self::$link[$host]);
+                $error = "Db Error: no= error={$errno}" . mysqli_error(self::$link[$host]);
+                Log::record($error."\r\n".$sql,Log::ERR);
+
+                if($errno == self::ErrUnConnect)
+                {
+                    if($count > 0) return false;
+                    self::closeLink($host);
+                    self::connect($host);
+                    $count++;
+                }
+                else
+                {
+                    if (C('debug')) {
+                        throw_exception($error.'<br/>'.$sql);
+                        return false;
+                    } else {
+                        return false;
+                    }
+                }
+            }
+            else
+            {
+                Log::record($sql . " [ RunTime:" . $staer->elapsed(6) . "s ]", Log::SQL);
+                return $query;
+            }
+        }
+        while(true);
 	}
 
 	/**
@@ -157,7 +159,6 @@ class Db
 	 */
 	public static function getAll($sql, $host = 'slave')
     {
-		self::connect($host);
         $result = self::query($sql, $host);
         if ($result === false) return array();
 		$array = array();
@@ -174,35 +175,37 @@ class Db
      * @param object $obj_page 分类对象
      * @return array
      */
-	public static function select($param, $obj_page='', $host = 'slave'){
-		self::connect($host);
+	public static function select($param, $obj_page='', $host = 'slave')
+    {
 		static $_cache = array();
-
 		if (empty($param)) throw_exception('Db Error: select param is empty!');
 
-		if (empty($param['field'])){
+		if (empty($param['field'])) {
 			$param['field'] = '*';
 		}
-		if (empty($param['count'])){
+		if (empty($param['count'])) {
 			$param['count'] = 'count(*)';
 		}
 
-		if (isset($param['index'])){
+		if (isset($param['index'])) {
 			$param['index'] = 'USE INDEX ('.$param['index'].')';
 		}
 
-		if (trim($param['where']) != ''){
-			if (strtoupper(substr(trim($param['where']),0,5)) != 'WHERE'){
+		if (trim($param['where']) != '')
+		{
+			if (strtoupper(substr(trim($param['where']),0,5)) != 'WHERE')
+			{
 				if (strtoupper(substr(trim($param['where']),0,3)) == 'AND'){
 					$param['where'] = substr(trim($param['where']),3);
 				}
 				$param['where'] = 'WHERE '.$param['where'];
 			}
-		}else {
+		} else {
 			$param['where'] = '';
 		}
+
 		$param['where_group'] = '';
-		if (!empty($param['group'])){
+		if (!empty($param['group'])) {
 			$param['where_group'] .= ' group by '.$param['group'];
 		}
 		$param['where_order'] = '';
@@ -212,7 +215,8 @@ class Db
 
 		//判断是否是联表
 		$tmp_table = explode(',',$param['table']);
-		if (!empty($tmp_table) && count($tmp_table) > 1){
+		if (!empty($tmp_table) && count($tmp_table) > 1)
+		{
 			//判断join表数量和join条件是否一致
 			if ((count($tmp_table)-1) != count($param['join_on'])){
 				throw_exception('Db Error: join number is wrong!');
@@ -232,30 +236,36 @@ class Db
 
 			//如果有分页,那么计算信息总数
 			$count_sql = 'SELECT '.$param['count'].' as count FROM `'.DBPRE.$tmp_table[0].'` as `'.$tmp_table[0].'` '.$tmp_sql.' '.$param['where'].$param['where_group'];
-		}else {
+		}
+		else {
 			$sql = 'SELECT '.$param['field'].' FROM `'.DBPRE.$param['table'].'` as `'.$param['table'].'` '.$param['index'].' '.$param['where'].$param['where_group'].$param['where_order'];
 			$count_sql = 'SELECT '.$param['count'].' as count FROM `'.DBPRE.$param['table'].'` as `'.$param['table'].'` '.$param['index'].' '.$param['where'];
 		}
+
 		//limit ,如果有分页对象的话,那么优先分页对象
-		if ($obj_page instanceof Page ){
+		if ($obj_page instanceof Page )
+		{
 			$count_query = self::query($count_sql,$host);
 			$count_fetch = mysqli_fetch_array($count_query,MYSQLI_ASSOC);
 			$obj_page->setTotalNum($count_fetch['count']);
 			$param['limit'] = $obj_page->getLimitStart().",".$obj_page->getEachNum();
 		}
-		if ($param['limit'] != ''){
+
+		if ($param['limit'] != '') {
 			$sql .= ' limit '.$param['limit'];
 		}
-		if ($param['cache'] !== false){
+		if ($param['cache'] !== false)
+		{
 			$key =  is_string($param['cache_key'])?$param['cache_key']:md5($sql);
 			if (isset($_cache[$key])) return $_cache[$key];
 		}
+
 		$result = self::query($sql,$host);
 		if ($result === false) $result = array();
-		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
+		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
 			$array[] = $tmp;
 		}
-		if ($param['cache'] !== false && !isset($_cache[$key])){
+		if ($param['cache'] !== false && !isset($_cache[$key])) {
 			$_cache[$key] = $array;
 		}
 		return $array;
@@ -268,12 +278,12 @@ class Db
 	 * @param array $insert_array 待插入数据
 	 * @return mixed
 	 */
-	public static function insert($table_name, $insert_array=array(), $host = 'master'){
-		self::connect($host);
+	public static function insert($table_name, $insert_array=array(), $host = 'master')
+    {
 		if (!is_array($insert_array)) return false;
 		$fields = array();
 		$value = array();
-		foreach ($insert_array as $key => $val){
+		foreach ($insert_array as $key => $val) {
 			$fields[] = self::parseKey($key);
 			$value[] = self::parseValue($val);
 		}
@@ -294,12 +304,12 @@ class Db
 	 */
 	public static function insertAll($table_name, $insert_array=array(), $host = 'master')
     {
-		self::connect($host);
 		if (!is_array($insert_array[0])) return false;
 		$fields = array_keys($insert_array[0]);
 		array_walk($fields,array(self,'parseKey'));
 		$values = array();
-		foreach ($insert_array as $data) {
+		foreach ($insert_array as $data)
+		{
 			$value = array();
 			foreach ($data as $key=>$val) {
 				$val = self::parseValue($val);
@@ -309,6 +319,7 @@ class Db
 			}
 			$values[] = '('.implode(',',$value).')';
 		}
+
 		$sql = 'INSERT INTO `'.DBPRE.$table_name.'` ('.implode(',',$fields).') VALUES '.implode(',',$values);
 		$result = self::query($sql,$host);
 		$insert_id = self::getLastId($host);
@@ -325,10 +336,10 @@ class Db
 	 */
 	public static function update($table_name, $update_array = array(), $where = '', $host = 'master')
     {
-		self::connect($host);
 		if (!is_array($update_array)) return false;
 		$string_value = '';
-		foreach ($update_array as $k => $v){
+		foreach ($update_array as $k => $v)
+		{
 			if (is_array($v)){
 				switch ($v['sign']){
 					case 'increase': $string_value .= " $k = $k + ". $v['value'] .","; break;
@@ -336,14 +347,16 @@ class Db
 					case 'calc': $string_value .= " $k = ". $v['value'] .","; break;
 					default: $string_value .= " $k = ". self::parseValue($v['value']) .",";
 				}
-			}else {
+			} else {
 				$string_value .= " $k = ". self::parseValue($v) .",";
 			}
 		}
 
 		$string_value = trim(trim($string_value),',');
-		if (trim($where) != ''){
-			if (strtoupper(substr(trim($where),0,5)) != 'WHERE'){
+		if (trim($where) != '')
+		{
+			if (strtoupper(substr(trim($where),0,5)) != 'WHERE')
+			{
 				if (strtoupper(substr(trim($where),0,3)) == 'AND'){
 					$where = substr(trim($where),3);
 				}
@@ -364,9 +377,10 @@ class Db
 	 */
 	public static function delete($table_name, $where = '', $host = 'master')
     {
-		self::connect($host);
-		if (trim($where) != ''){
-			if (strtoupper(substr(trim($where),0,5)) != 'WHERE'){
+		if (trim($where) != '')
+		{
+			if (strtoupper(substr(trim($where),0,5)) != 'WHERE')
+			{
 				if (strtoupper(substr(trim($where),0,3)) == 'AND'){
 					$where = substr(trim($where),3);
 				}
@@ -374,7 +388,7 @@ class Db
 			}
 			$sql = 'DELETE FROM `'.DBPRE.$table_name.'` '.$where;
 			return self::query($sql, $host);
-		}else {
+		} else {
 			throw_exception('Db Error: the condition of delete is empty!');
 		}
 	}
@@ -384,8 +398,8 @@ class Db
 	 *
 	 * @return int
 	 */
-	public static function getLastId($host = 'master'){
-		self::connect($host);
+	public static function getLastId($host = 'master')
+    {
 		$id = mysqli_insert_id(self::$link[$host]);
 		if (!$id){
 		    $result = self::query('SELECT last_insert_id() as id',$host);
@@ -405,18 +419,19 @@ class Db
 	 */
 	public static function getRow($param, $fields = '*', $host = 'slave')
     {
-		self::connect($host);
 		$table = $param['table'];
 		$wfield = $param['field'];
 		$value = $param['value'];
 
-		if (is_array($wfield)){
+		if (is_array($wfield))
+		{
 			$where = array();
 			foreach ($wfield as $k => $v){
 				$where[] = $v."='".$value[$k]."'";
 			}
 			$where = implode(' and ',$where);
-		}else {
+		}
+		else {
 			$where = $wfield."='".$value."'";
 		}
 
@@ -435,7 +450,6 @@ class Db
 	 */
 	public static function replace($table_name, $replace_array = array(), $host = 'master')
     {
-		self::connect($host);
 		if (!empty($replace_array))
 		{
 			$string_field = '';
@@ -460,9 +474,8 @@ class Db
 	 */
 	public static function getCount($table, $condition = null, $host = 'slave')
     {
-		self::connect($host);
-
-		if (!empty($condition) && is_array($condition)){
+		if (!empty($condition) && is_array($condition))
+		{
 			$where = '';
 			foreach ($condition as $key=>$val) {
 				self::parseKey($key);
@@ -470,13 +483,16 @@ class Db
 				$where .= ' AND '.$key.'='.$val;
 			}
 			$where = ' WHERE '.substr($where,4);
-		}elseif(is_string($condition)){
+		}
+		elseif(is_string($condition))
+        {
 			if (strtoupper(substr(trim($condition),0,3)) == 'AND'){
 				$where = ' WHERE '.substr(trim($condition),4);
 			}else{
 				$where = ' WHERE '.$condition;
 			}
 		}
+
 		$sql = 'SELECT COUNT(*) as `count` FROM `'.DBPRE.$table.'` as `'.$table.'` '.(isset($where) ? $where : '');
 		$result = self::query($sql,$host);
 		if ($result === false) return 0;
@@ -491,7 +507,6 @@ class Db
 	 * @return
 	 */
 	public static function execute($sql, $host = 'master'){
-		self::connect($host);
 		$result = self::query($sql,$host);
 		return $result;
 	}
@@ -501,8 +516,8 @@ class Db
 	 *
 	 * @return array
 	 */
-	public static function showTables($host = 'slave'){
-		self::connect($host);
+	public static function showTables($host = 'slave')
+    {
 		$sql = 'SHOW TABLES';
 		$result = self::query($sql,$host);
 		if ($result === false) return array();
@@ -519,8 +534,8 @@ class Db
 	 * @param string $table
 	 * @return string
 	 */
-	public static function showCreateTable($table, $host = 'slave'){
-		self::connect($host);
+	public static function showCreateTable($table, $host = 'slave')
+    {
 		$sql = 'SHOW CREATE TABLE `'.DBPRE.$table.'`';
 		$result = self::query($sql,$host);
 		if ($result === false) return '';
@@ -534,13 +549,15 @@ class Db
 	 * @param string $table
 	 * @return array
 	 */
-	public static function showColumns($table, $host = 'slave'){
-		self::connect($host);
+	public static function showColumns($table, $host = 'slave')
+    {
 		$sql = 'SHOW COLUMNS FROM `'.DBPRE.$table.'`';
 		$result = self::query($sql,$host);
 		if ($result === false) return array();
 		$array = array();
-		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
+
+		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC))
+        {
             $array[$tmp['Field']] = array(
                 'name'    => $tmp['Field'],
                 'type'    => $tmp['Type'],
@@ -559,7 +576,7 @@ class Db
 	 * @return string
 	 */
 	public static function getServerInfo($host = 'slave'){
-		self::connect($host);
+        self::init_link();
 		$result = mysqli_get_server_info(self::$link[$host]);
 		return $result;
 	}
@@ -591,26 +608,29 @@ class Db
 
     public static function beginTransaction($host = 'master')
     {
-    	self::connect($host);
-    	if (self::$iftransacte){
-    		self::$link[$host]->autocommit(false);//关闭自动提交
+        self::init_link();
+        if (self::$iftransacte)
+        {
+    		$result = self::$link[$host]->autocommit(false);
+    		if($result == false)
+    		{
+                $errno = mysqli_errno(self::$link[$host]);
+                $error = "Db Error autocommit no= error={$errno}" . mysqli_error(self::$link[$host]);
+                Log::record($error."\r\n",Log::ERR);
+
+                if($errno == self::ErrUnConnect) {
+                    self::closeLink($host);
+                    self::connect($host);
+                }
+                self::$link[$host]->autocommit(false);
+            }
     	}
     	self::$iftransacte = false;
     }
 
-    public static function start_transaction($falg,$host = 'master')
-    {
-        self::connect($host);
-        if (self::$iftransacte){
-            self::$link[$host]->autocommit(false);//关闭自动提交
-            self::$iftransacte = false;
-        }
-        self::$link[$host]->begin_transaction($falg);
-    }
-
     public static function commit($host = 'master')
     {
-    	if (!self::$iftransacte){
+    	if (!self::$iftransacte) {
     		$result = self::$link[$host]->commit();
     		self::$link[$host]->autocommit(true);//开启自动提交
     		self::$iftransacte = true;

+ 4 - 7
core/framework/libraries/log.php

@@ -37,25 +37,22 @@ class Log
         }
     }
 
-    //public static function record($message, $lev = self::ERR,$module = 'default')
     public static function record($message, $lev = self::ERR)
     {
-//        if(!in_array($lev,self::$moduls) && $lev < self::ERR ) {
-//            return;
-//        }
         $now = @date('Y-m-d H:i:s', time());
+        $pid = posix_getpid();
 
         if($lev == self::WAIT_HANDLE) {
             $level = 'WAIT_HANDLE';
             $log_file = BASE_DATA_PATH.'/log/'.date('Ymd',time()).'-wait.log';
-            $content = "[{$now}] {$level}: {$message}\r\n";
+            $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
             file_put_contents($log_file,$content, FILE_APPEND);
             return;
         }
 
         if($lev == self::SQL) {
             $level = 'SQL';
-            $content = "[{$now}] {$level}: {$message}\r\n";
+            $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
             if(self::open_sql) {
                 $log_file = BASE_DATA_PATH.'/log/'.date('Ymd',time()).'.log';
                 file_put_contents($log_file,$content, FILE_APPEND);
@@ -67,7 +64,7 @@ class Log
         if($lev >= self::cur_level && $lev <= self::RUN) {
             $level = self::get_level($lev);
             $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '.log';
-            $content = "[{$now}] {$level}: {$message}\r\n";
+            $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
             file_put_contents($log_file, $content, FILE_APPEND);
         }
 

+ 1 - 2
core/framework/libraries/model.php

@@ -414,7 +414,6 @@ class Model
     public function affected_rows()
     {
         return $this->db->affected_rows();
-
     }
 
 	/**
@@ -533,7 +532,7 @@ class Model
      *
      * @return int
      */
-    public function getLastId() {
+    private function getLastId() {
         return $this->db->getLastId();
     }
     /**

+ 14 - 3
core/framework/libraries/sendmembermsg.php

@@ -5,7 +5,8 @@
  *
  * @package    library* www.33hao.com 专业团队 提供售后服务
  */
-class sendMemberMsg {
+class sendMemberMsg
+{
     private $code = '';
     private $member_id = 0;
     private $member_info = array();
@@ -18,11 +19,19 @@ class sendMemberMsg {
      * @param mixed $key
      * @param mixed $value
      */
+
     public function set($key,$value){
         $this->$key = $value;
     }
 
-    public function send($param = array()) {
+    public function send($param = array())
+    {
+
+    }
+
+
+    public function send_back($param = array())
+    {
         $msg_tpl = rkcache('member_msg_tpl', true);
         if (!isset($msg_tpl[$this->code]) || $this->member_id <= 0) {
             return false;
@@ -31,7 +40,8 @@ class sendMemberMsg {
         $tpl_info = $msg_tpl[$this->code];
 
         $setting_info = Model('member_msg_setting')->getMemberMsgSettingInfo(array('mmt_code' => $this->code, 'member_id' => $this->member_id), 'is_receive');
-        if (empty($setting_info) || $setting_info['is_receive']) {
+        if (empty($setting_info) || $setting_info['is_receive'])
+        {
             // 发送站内信
             if ($tpl_info['mmt_message_switch']) {
                 $message = ncReplaceText($tpl_info['mmt_message_content'],$param);
@@ -83,6 +93,7 @@ class sendMemberMsg {
         $insert_arr['member_id'] = $this->member_id;
         $insert_arr['msg_content'] = $message;
         $insert_arr['message_type'] = 1;
+
         $model_message->saveMessage($insert_arr);
     }
 

+ 12 - 8
crontab/control/date.php

@@ -80,8 +80,7 @@ class dateControl extends BaseCronControl
         //更新商品促销到期状态
         $this->_goods_promotion_state_update();
 
-        //商品到货通知提醒
-        $this->_arrival_notice();
+
 
         //更新浏览量
         $this->_goods_browse_update();
@@ -103,6 +102,9 @@ class dateControl extends BaseCronControl
     {
         //已领取但未使用的红包过期通知
         $this->bonus_expire_notify();
+
+        //商品到货通知提醒
+        $this->_arrival_notice();
     }
 
     /**
@@ -483,9 +485,10 @@ class dateControl extends BaseCronControl
     /**
      * 商品到货通知提醒
      */
-    private function _arrival_notice() {
-        $strat_time = strtotime("-30 day"); // 只通知最近30天的记录
-    
+    private function _arrival_notice()
+    {
+        $strat_time = strtotime("-60 day"); // 只通知最近60天的记录
+
         $model_arrtivalnotice = Model('arrival_notice');
         // 删除30天之前的记录
         $model_arrtivalnotice->delArrivalNotice(array('an_addtime' => array('lt', $strat_time), 'an_type' => 1));
@@ -493,8 +496,8 @@ class dateControl extends BaseCronControl
         $count = $model_arrtivalnotice->getArrivalNoticeCount(array());
         $times = ceil($count/self::ARRIVAL_NOTICE_NUM);
         if ($times == 0) return false;
-        for ($i = 0; $i <= $times; $i++) {
-    
+        for ($i = 0; $i <= $times; $i++)
+        {
             $notice_list = $model_arrtivalnotice->getArrivalNoticeList(array(), '*', $i.','.self::ARRIVAL_NOTICE_NUM);
             if (empty($notice_list)) continue;
     
@@ -517,7 +520,8 @@ class dateControl extends BaseCronControl
             $notice_list = $model_arrtivalnotice->getArrivalNoticeList(array('goods_id' => array('in', $goodsid_array)), '*');
             if (empty($notice_list)) continue;
     
-            foreach ($notice_list as $val) {
+            foreach ($notice_list as $val)
+            {
                 $param = array();
                 $param['code'] = 'arrival_notice';
                 $param['member_id'] = $val['member_id'];

+ 1 - 0
data/resource/mobile/activity/css/count_down.css

@@ -67,6 +67,7 @@ img {
     overflow: hidden;
     text-overflow: ellipsis;
     line-height: 0.39rem;
+    margin: 0.3rem 0;
 }
 .count_goods_price {
     margin-top: 0.15rem;

+ 28 - 7
data/resource/mobile/fcode/css/main.css

@@ -1,7 +1,6 @@
 html,
 body {
     height: 100%;
-    max-height: 100%;
     color: #fff;
     font-family: "PingFang SC","Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;;
 }
@@ -35,6 +34,7 @@ body {
 }
 .p_absolute {
     position: absolute;
+    bottom: 0;
 }
 .p_fixed {
     position: fixed;
@@ -59,9 +59,6 @@ body {
     border-radius: 10px;
     margin-top: 0.5rem;
 }
-.block_goods {
-
-}
 .block_goods_msg {
     margin-top: 0.32rem;
 }
@@ -69,7 +66,17 @@ body {
 .bg_write {
     background: #fff;
 }
-
+.bg_red {
+    background: #FF4E4E;
+}
+.fcode_init_bg {
+    background: #D0D0D0;
+    color: #000;
+}
+.fcode_success_bg {
+    background: #FF4E4E;
+    color: #fff;
+}
 .bit_img {
     background: url("../images/index_bg.png") #FF4E4E bottom left no-repeat;
     background-size: 10rem 4.4rem;
@@ -234,8 +241,6 @@ input,button,.btn {
     width: 5.05rem;
     height: 1.08rem;
     line-height: 1.08rem;
-    background: #D0D0D0;
-    color: #000000;
     font-size: 16px;
     border-radius: 80px;
     margin-top: 1.1rem;
@@ -297,4 +302,20 @@ input,button,.btn {
 .btn_pressed {
     box-shadow: 5px 5px 30px #ccc;
     -webkit-box-shadow: 5px 5px 30px #ccc;
+}
+.receive_state {
+    width: 2.13rem;
+    height: 2.13rem;
+    margin-top: 0.91rem;
+    margin-bottom: 0.57rem;
+}
+.loading {
+    display: none;
+    width:100%;
+    height: 100%;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: 999;
+    background: url("../images/loading_icon.gif") rgba(255,255,255,0.5) no-repeat center;
 }

BIN
data/resource/mobile/fcode/images/error.png


BIN
data/resource/mobile/fcode/images/goods_img.png


BIN
data/resource/mobile/fcode/images/loading_icon.gif


BIN
data/resource/mobile/fcode/images/success.png


+ 88 - 156
data/resource/mobile/fcode/js/fcode.js

@@ -1,161 +1,93 @@
-$(function(){
-    var tel={
-        //总入口
-        init:function(){
-            var that=this;
-            that.validate('#hack',that.msg.no_tel);
-            that.time('#hack');
-            that.active();
-            that.blurValidatetel('keyup');
-            that.blurValidatetel('blur');
-            that.focu(document);
-        },
 
-        //弹出信息
-        msg:{
-            no_tel:'请认真填写你的手机号',
-            no_yanz:'请填写验证码',
-            yanz_err:'验证码错误',
-            lg:'该手机已经领取过红包',
-            no_lq:'该手机不能领取红包',
-            remove:'获取验证码哦',
-            over:'该手机已经领取过红包',
-            no_pass:'该手机号不能领取红包'
-        },
-        //判断验证顺序
-        b:false,
-        //插入验证结构
-        validate:function(id,msg,btnmsg,sj){
-            var that=this;
-            $(id).on('tap',function(e){
-                e.preventDefault();//阻止浏览器默认事件
-                var telVal=$('#tel_number').val(),
-                    tel=new RegExp("^[1][3-8]+\\d{9}");
-                //验证输入手机规则
-                if(telVal==''||(!tel.test(telVal))){
-                    alert(msg);
-                    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 false;
-                }
-                else {
-                    that.b=true;
-                }
-            })
-        },
-        //留言
-        input_msg:function(){
-            var   dom='<div class="layer_box" id="bomb">'+
-                '<div class="layer" style="padding-bottom: 2px">'+
-                '<div class="top_msg" style="padding: 0 20px;line-height: 126px">'+
-                '<div><textarea id="pass_msg" placeholder="写下你想说的话" style="width:98%;height:50px;font-size: 0.4rem;line-height: 0.4rem;"></textarea></div>'+
-                '</div>'+
-                '<div class="bottom_btn center" style="background: #fff;">'+
-                '<p id="go" class="post_btn" style="float: left;width: 50%;border-top: 1px solid #bfbfbf;color: #000;">取消</p>'+
-                '<p id="post" style="float:left; color: #ff4e4e;width: 49.5%;border-top: 1px solid #bfbfbf;border-left: 1px solid #bfbfbf;">发送</p>'+
-                '</div>'+
-                '</div>'+
-                '</div>';
-            $('body').append(dom);
-        },
-        //倒计时
-        time:function(id,msg,btnmsg){
-            var that=this,
-                times=function(){
-                    if(that.b==false){
-                        return;
-                    }
-                    tel = $("#tel_number").val();
-                    var url_host=window.location.hostname;
-                    $.post("/mobile/index.php?act=login&op=getcode&type=getfcode&client_type=ajax", {
-                        mobile: 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('tap', function () {
-                //判断倒计时是否开始了
-                var text = $(this).text();
-                if (text == '重新发送' || text == '获取验证码') {
-                    times();
-                }
-                else {
-                    return;
-                }
-            })
-        },
-        //验证码验证
-        active: function ()
-        {
-            var that = this;
-            $('#bind').on('tap', function () {
-                var b = that.b;
-                if (b == false) {
-                    alert(that.msg.no_tel);
-                }
-                else {
-                    if (yanzVal == '') {
-                        alert(that.msg.no_yanz);
-                    }
+var Validate = function()
+{
+    this.required = function(id)
+    {
+        var inputVal=$(id).val();
+        if(inputVal=="") {
+            return false;
+        } else {
+            return true;
+        }
+    };
+    this.mobile = function (id)
+    {
+        var inputVal=$(id).val();
+        var tel=new RegExp("^[1][3-8]+\\d{9}");
+        if(tel.test(inputVal)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+};
 
-                    else {
-                        var yanzVal = $("#yanz").val();
-                        var tel = $("#tel_number").val();
-                        $.ajax({
-                            type:'post',
-                            dataType:'json',
-                            url:'/mobile/index.php?act=fcode&op=bind&client_type=ios',
-                            data:{
-                                mobile: tel,
-                                code: yanzVal
-                            },
-                            success:function(data)
-                            {
-                                if (data.code==200) {
-                                    alert('领取成功');
-                                }
-                                else {
-                                    alert(that.msg.yanz_err);
-                                }
-                            }
-                        });
-                    }
-                }
-            })
-        },
-        //收起键盘
-        focu:function(id){
-            $(id).on('tap',function(event){
-                var eventName=event.target.localName;
-                if(eventName.indexOf('input')!==-1||eventName.indexOf('button')!==-1){
-                    return;
+var CountDown = function(time)
+{
+    if(isNaN(time)) {
+        return;
+    }
+    
+    this.time = time;
+    this.countDown = function()
+    {
+        if(this.isStart())
+        {
+            return false;
+        }
+        else
+        {
+            var that=this;
+            var target=event.target;
+            var time = parseInt(that.time);
+            var a = setInterval(function()
+            {
+                time = time - 1;
+                target.innerHTML = time;
+                if(time <= 0) {
+                    clearInterval(a);
+                    target.innerHTML = '重新发送';
                 }
-                $('input').blur();
-            })
+            },1000);
         }
     };
-    tel.init();
-});
+    this.isStart = function()
+    {
+        var target = event.target;
+        if(target.innerHTML == '重新发送' || target.innerHTML == '获取验证码') {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+};
+
+var ajaxServer = function(type,url,data,callback)
+{
+    $.ajax({
+        type:type,
+        dataType:'json',
+        url:url,
+        data:data,
+        success:callback
+    });
+};
+
+
+var app = function()
+{
+    var app=navigator.userAgent.toLowerCase(),//判断设备
+        app_nav=navigator.appVersion.toLowerCase(),
+        href='';
+    if (app_nav.indexOf('iphone')>-1&&app.indexOf('iphone')){
+        href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lrlz.beautyshop';
+    } else if (app.indexOf('micromessenger')>-1 && app_nav.indexOf('android')>-1) {
+        href = "http://p.lrlz.com/hfive/android_down/index.html";
+    }
+    else {
+        href="javascript:void(0)";
+    }
+    return href;
+};
+

+ 10 - 1
helper/account_helper.php

@@ -404,6 +404,15 @@ class account_helper
     public static function onLogin($member_id)
     {
         relation_helper::onLogin($member_id);
+
+        $anotice  = new user_session\anotice();
+        $anotice->onStatus();
+
+        $favorate = new user_session\favorite();
+        $favorate->onLogin();
+
+        $fcode = new user_session\fcode();
+        $fcode->onStatus();
     }
 
     public static function onEvaluate($member_id)
@@ -458,7 +467,7 @@ class account_helper
         if(empty($pay_sn)) {
             Log::record("account_helper::onOrderSuccess $order_id error.",Log::ERR);
         } else {
-            Log::record("account_helper::onOrderSuccess $order_id={$order_id}.",Log::ERR);
+            Log::record("account_helper::onOrderSuccess $order_id={$order_id}.",Log::DEBUG);
         }
 
         $mod_order = Model('order');

+ 6 - 4
helper/fcode/generator.php

@@ -8,6 +8,8 @@
 
 namespace fcode;
 
+use Log;
+
 class generator
 {
     private $mCommonId;
@@ -19,7 +21,7 @@ class generator
     public function __construct($commonid, $num, $batch_code, $usable_days)
     {
         $this->mCommonId = $commonid;
-        $this->mNumber = $num;
+        $this->mNumber = intval($num);
 
         if(empty($batch_code)) {
             $this->mBatchCode = 'XMMZ';
@@ -38,7 +40,7 @@ class generator
     public function make()
     {
         $mod_fcode = Model('goods_fcode');
-        for ($i = 0; $i <  $this->mNumber;)
+        for ($i = 0; $i < $this->mNumber;)
         {
             $fc_code = sprintf("%06s%04d%06d",$this->mBatchCode,$this->mCommonId,mt_rand(100000, 999999));
 
@@ -52,13 +54,13 @@ class generator
 
             $ret = $mod_fcode->insert($data);
             $affect_rows = $mod_fcode->affected_rows();
-
+            Log::record("fcode make i={$i} ret={$ret} rows={$affect_rows}",Log::DEBUG);
             if($ret != false && $affect_rows > 0) {
                 ++$i;
             }
         }
 
-        $url = BASE_SITE_URL . '/mobile/index.php?act=fcode&op=open' . "&common_id={$this->mCommonId}&batch_code={$this->mBatchCode}";
+        $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$this->mCommonId}&batch_code={$this->mBatchCode}";
         return $url;
     }
 }

+ 10 - 4
helper/fcode/operator.php

@@ -28,17 +28,23 @@ class operator
         $this->mod_fcode = Model('goods_fcode');
     }
 
-    public function grabed()
+    public function grabed($mobile = null)
     {
         $cond = [];
         $cond['goods_commonid'] = $this->mCommonID;
         $cond['batch_code'] = $this->mBatchCode;
 
-        if(session_helper::logined()) {
-            $cond['session_id|mobile'] = array('_multi'=>true,session_helper::session_id(),session_helper::cur_mobile());
+        if($mobile == null)
+        {
+            if(session_helper::logined()) {
+                $cond['mobile|session_id'] = array('_multi'=>true,session_helper::cur_mobile(),session_helper::session_id());
+            }
+            else {
+                $cond['session_id'] = session_helper::session_id();
+            }
         }
         else {
-            $cond['session_id'] = session_helper::session_id();
+            $cond['mobile|session_id'] = array('_multi'=>true,$mobile,session_helper::session_id());
         }
 
         $fcode = $this->mod_fcode->getGoodsFCode($cond);

+ 1 - 1
helper/goods_helper.php

@@ -18,7 +18,7 @@ class goods_helper
 {
     const fieldstr = 'goods_id,goods_commonid,goods_state,store_id,brand_id,gc_id,goods_name,goods_price,goods_marketprice,goods_promotion_price,goods_jingle,
                   goods_image,goods_salenum,evaluation_good_star,evaluation_count,goods_storage,goods_storage_alarm,is_virtual,is_presell,
-                  is_fcode,have_gift,goods_mobile_name,goods_spec,
+                  is_fcode,have_gift,goods_mobile_name,goods_spec,goods_collect,
                   goods_addtime,goods_edittime';
 
     public function __construct() {

+ 2 - 1
helper/http_header.php

@@ -197,7 +197,8 @@ class http_header
     private function newline_check($string)
     {
         $datas = str_split($string);
-        foreach($datas as $val) {
+        foreach($datas as $val)
+        {
             if($val == '\r' || $val == '\n') {
                 Log::record("Header may not contain more than a single header, new line detected",Log::ERR);
                 return false;

+ 1 - 0
helper/model/goods_summary.php

@@ -104,6 +104,7 @@ class goods_summary
         $summary['goods_state'] = intval($this->goods_info['goods_state']);
         $summary['goods_salenum'] = intval($this->goods_info['goods_salenum']);
         $summary['goods_storage'] = intval($this->goods_info['goods_storage']);
+        $summary['goods_collect'] = intval($this->goods_info['goods_collect']);
         $summary['is_new'] = $this->is_new();
 
         $have_gift = intval($this->goods_info['have_gift']) == 1 ? true : false;

+ 1 - 2
mobile/control/control.php

@@ -79,9 +79,8 @@ class mobileControl
     protected function check_app_type()
     {
         $client = strtolower(trim($_SERVER['HTTP_CLIENT_TYPE']));
-        $client = strtolower($client);
-
         $version = trim($_SERVER['HTTP_CLIENT_VERSION']);
+
         if (empty($client)) {
             $client = $_POST['client_type'];
         } else {

+ 48 - 12
mobile/control/fcode.php

@@ -21,18 +21,29 @@ class fcodeControl extends mobileControl
     {
         $common_id = intval($_GET['common_id']);
         $batch_code = $_GET['batch_code'];
+        $sid = $_SESSION['MPHPSESSID'];
+        $status = intval($_GET['status']);
+        $mobile = $_GET['mobile'];
 
         if($common_id <= 0 || empty($batch_code)) {
-            return self::outerr(errcode::ErrParamter,"错误的参数");
+            return self::outerr(errcode::ErrParamter,"错误的参数","fcode/error");
         }
 
         $oper = new fcode\operator($common_id,$batch_code);
-        $fcode = $oper->grabed();
+        if(empty($mobile)) {
+            $fcode = $oper->grabed();
+        } else {
+            $fcode = $oper->grabed($mobile);
+        }
+
+        $goods = $this->goods($common_id);
         if($fcode == false)
         {
-            $goods = $this->goods($common_id);
             if(empty($goods)) {
-                //出错
+                return self::outsuccess(array('error' => "商品已经下架,请关注其它F码"),"fcode/error",'wap');
+            }
+            elseif($status < 0) {
+                return self::outsuccess(array('error' => "该商品F码已经被抢光~"),"fcode/error",'wap');
             }
             else {
                 $name = $goods['goods_name'];
@@ -40,16 +51,22 @@ class fcodeControl extends mobileControl
                 $image = $goods['goods_image'];
                 $image = cthumb($image, 1280, 6);
                 return self::outsuccess(array('name' => $name,'price' => $price,'image' => $image,
-                    'common_id' => $common_id,'batch_code' => $batch_code), "fcode/index",'wap');
+                    'common_id' => $common_id,'batch_code' => $batch_code,'sid' => $sid), "fcode/index",'wap');
             }
         }
         else
         {
+            $name = $goods['goods_name'];
+            $price = $goods['goods_price'];
+            $image = $goods['goods_image'];
+            $image = cthumb($image, 1280, 6);
+
             $fcoder = new \fcode\mfcode($fcode);
             if($fcoder->binded()) {
+                return self::outsuccess(array('fcode' => $fcode,'sid' => $sid,'name' => $name,'price' => $price,'image' => $image),"fcode/success",'wap');
 
             } else {
-                return self::outsuccess(array('fcode' => $fcode),"fcode/bind");
+                return self::outsuccess(array('fcode' => $fcode,'sid' => $sid,'name' => $name,'price' => $price,'image' => $image),"fcode/bind",'wap');
             }
         }
     }
@@ -66,9 +83,11 @@ class fcodeControl extends mobileControl
     {
         $common_id = intval($_GET['common_id']);
         $batch_code = $_GET['batch_code'];
+        $sid = $_SESSION['MPHPSESSID'];
 
         if($common_id <= 0 || empty($batch_code)) {
-            return self::outerr(errcode::ErrParamter,"错误的参数");
+            $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}";
+            return self::outsuccess(array('url' => $url));
         }
 
         $oper = new fcode\operator($common_id,$batch_code);
@@ -78,18 +97,24 @@ class fcodeControl extends mobileControl
         {
             $fcode = $oper->grab();
             if($fcode == false) {
-                self::outsuccess(errcode::ErrParamter,"该F码已经被抢光");
+                $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}&status=-1";
+                return self::outsuccess(array('url' => $url));
             }
         }
 
-        $sid = $_SESSION['MPHPSESSID'];
         $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}";
-
         return self::outsuccess(array('url' => $url));
     }
 
     public function bindOp()
     {
+        $common_id = intval($_GET['common_id']);
+        $batch_code = $_GET['batch_code'];
+
+        if($common_id <= 0 || empty($batch_code)) {
+            return self::outerr(errcode::ErrParamter,"错误的参数");
+        }
+
         $mobile = $_GET['mobile'];
         $validator = new Validator();
         $validator->setValidate(Validator::verify_mobile($mobile));
@@ -98,6 +123,17 @@ class fcodeControl extends mobileControl
             return self::outerr(errcode::ErrParamter, $err);
         }
 
+        $oper = new fcode\operator($common_id,$batch_code);
+        $fcode = $oper->grabed($mobile);
+        if($fcode == false) {
+            return self::outerr(errcode::ErrParamter, "您没有该批次商品的F码.");
+        }
+
+        $fcoder = new \fcode\mfcode($fcode);
+        if($fcoder->binded()) {
+            return self::outsuccess(null);
+        }
+
         if(!isset($_GET['code']) || empty($_GET['code'])) {
             return self::outerr(errcode::ErrParamter, "请输入验证码.");
         }
@@ -108,8 +144,8 @@ class fcodeControl extends mobileControl
         }
         else
         {
-
+            $oper->bind($fcode,$mobile);
+            return self::outsuccess(null);
         }
-        
     }
 }

+ 1 - 1
mobile/control/member_favorites.php

@@ -56,7 +56,7 @@ class member_favoritesControl extends mbMemberControl
         }
 
         $helper = new goods_helper();
-        $ret = $helper->cart_summary($gids,$related_goods);
+        $ret = $helper->get_summary($gids,$related_goods);
         $block = special_formater::format_goods($gids,'我的商品',$ret['sort_summary']);
         $blocks[] = $block;
 

+ 6 - 17
mobile/control/search.php

@@ -271,7 +271,6 @@ class searchControl extends mobileHomeControl
 
     public function guesslike()
     {
-//        $goodslist = Model('goods_browse')->getGuessLikeGoods($_SESSION['member_id'],10);
         $goods_list = activity_helper::recomoned_goodsids();
 
         if(empty($goods_list)) {
@@ -279,7 +278,7 @@ class searchControl extends mobileHomeControl
         }
         else
         {
-            $goods_ids = [];
+            $gids = [];
             $count = count($goods_list);
             $len = mt_rand(1,$count);
 
@@ -287,29 +286,19 @@ class searchControl extends mobileHomeControl
             {
                 $pos = intval(mt_rand(0,$count - 1));
                 $gid = $goods_list[$pos];
-                if(in_array($gid,$goods_ids)) {
+                if(in_array($gid,$gids)) {
                     continue;
                 } else {
-                    $goods_ids[] = $gid;
+                    $gids[] = $gid;
                 }
-                if($len == count($goods_ids)) {
+                if($len == count($gids)) {
                     break;
                 }
             }
-//            foreach ($goodslist as $value)
-//            {
-//                if (intval($value) > 0) {
-//                    $goods_ids[] = intval($value);
-//                }
-//            }
-
-            $model_goods = Model('goods');
-            $goods_list = $model_goods->getGoodsListByColorDistinct(array('goods_id' => array('in',$goods_ids)), goods_helper::fieldstr);
 
             $helper = new goods_helper();
-            $ret = $helper->get_summaryex($goods_list,$related_goods);
-            $block = special_formater::format_goods($goods_ids,"猜你喜欢",$ret['sort_summary']);
-
+            $ret = $helper->get_summary($gids,$related_goods);
+            $block = special_formater::format_goods($gids,"猜你喜欢",$ret['sort_summary']);
 
             return array('special_list' => array($block),
                 'summary'  => $ret['summary'],

+ 0 - 1
mobile/templates/default/activity/limit_entra.php

@@ -34,7 +34,6 @@
                     <span class="gount_price">¥<?php echo($output['goods_promotion_price']); ?></span>
                     <span class="purchase_price"><?php echo($output['goods_price']); ?></span>
                 </div>
-                <div class="find_btn">查看更多</div>
             </div>
             <div class="count_down_image">
                 <img src="<?php echo ($output['goods_image_url']); ?>" alt="限时购"/>

+ 101 - 22
mobile/templates/default/fcode/bind.php

@@ -14,13 +14,13 @@
     </div>
     <div class="prompt_text t_left">
         <ul class="layout_center">
-            <li>1.领取后进入APP“F码专场”兑换</li>
-            <li>2.请在F码有效期内兑换,过期不补</li>
-            <li>3.如果商品退货F码不退</li>
+            <li>1.领取后进入APP“F码专区”购买</li>
+            <li>2.请注意F码使用有效期</li>
+            <li>3.商品退货F码不退</li>
         </ul>
     </div>
     <div class="bind_tel_box p_absolute bg_write">
-        <div class="fcode t_center layout_center"><?php echo $output['fcode']['fc_code']; ?></div>
+        <div class="fcode t_center layout_center fcode_init_bg"><?php echo $output['fcode']['fc_code']; ?></div>
         <div class="tel layout_center">
             <div class="mobile_box p_relative"><input type="number" placeholder="手机号" class="mobile block" id="tel_number"/></div>
             <div class="overflow get_box p_relative">
@@ -32,7 +32,8 @@
             <button class="btn btn_submit block t_center layout_center" id="bind">提交领取</button>
         </div>
     </div>
-    <div class="p_fixed advert">
+
+    <div class="p_absolute advert bg_write">
         <div class="f_left logo">
             <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/logo.png" alt="logo"/>
         </div>
@@ -47,29 +48,107 @@
 </div>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/js/fcode.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/wx_share.js?<?php echo bonus_version(); ?>"></script>
 <script type="text/javascript">
     $(function(){
-        function app()
+        $('#link').attr('href',app());
+
+        $('body').height($('body')[0].clientHeight);
+
+        $('#hack').on('tap',function()
+        {
+            var validate = new Validate();
+            var mobile=validate.mobile('#tel_number');
+            if(!mobile)
+            {
+                alert('请输入正确的电话号码');
+                return;
+            }
+            else
+            {
+                var data = {
+                    mobile:$('#tel_number').val(),
+                    act:'login',
+                    op:'getcode',
+                    type:'getfcode',
+                    client_type:'ajax'
+                };
+                var countTime = new CountDown(60);
+                countTime.countDown();
+                ajaxServer('post','/mobile/index.php',data,function(data)
+                {
+                    if (data.code != 200) {
+                        alert(data.message);
+                    }
+                });
+            }
+        });
+
+        $('#bind').on('tap',function ()
         {
-            var app=navigator.userAgent.toLowerCase(),//判断设备
-                    app_nav=navigator.appVersion.toLowerCase(),
-                    href='';
-            if (app_nav.indexOf('iphone')>-1&&app.indexOf('iphone')){
-                href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lrlz.beautyshop';
-            } else if (app.indexOf('micromessenger')>-1 && app_nav.indexOf('android')>-1) {
-                href = "http://p.lrlz.com/hfive/android_down/index.html";
+            var validate = new Validate();
+            var fmobile = validate.mobile('#tel_number');
+            var fcode = validate.required('#yanz');
+            var commonid = '<?php echo $output['fcode']['goods_commonid']; ?>';
+            var batch_code = '<?php echo $output['fcode']['batch_code']; ?>';
+            var sid = '<?php echo $output['sid']; ?>';
+
+            if(!fmobile) {
+                alert('请输入正确的电话号码');
+                return;
             }
-            else {
-                href="javascript:void(0)";
+            if(!fcode) {
+                alert('请输入正确的验证码');
+                return;
             }
-            return href;
-        }
 
-        function href() {
-            $('#link').attr('href',app());
-        }
-        href();
-    })
+            var mobile = $('#tel_number').val();
+            var code   = $('#yanz').val();
+
+            var data = {
+                act:'fcode',
+                op:'bind',
+                client_type:'ajax',
+                common_id:commonid,
+                batch_code:batch_code,
+                mobile:mobile,
+                code:code
+            };
+            ajaxServer('post','/mobile/index.php',data,function(data)
+            {
+                if (data.code == 200)
+                {
+                    var url = "/mobile/index.php?act=fcode&op=index&common_id=" + commonid + "&batch_code=" + batch_code + "&HPHPSESSID=" + sid +"&mobile=" + mobile;
+                    location.replace(url);
+                }
+                else {
+                    alert(data.message);
+                }
+            });
+        });
+
+        $(document).on('tap',function()
+        {
+            var eventName=event.target.localName;
+            if(eventName.indexOf('input') !== -1 || eventName.indexOf('button') !== -1){
+                return;
+            }
+            $('input').blur();
+        });
+
+        var shareData = (function()
+        {
+            var url = '<?php echo BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&client_type=wap&common_id={$output['fcode']['goods_commonid']}&batch_code={$output['fcode']['batch_code']}"; ?>';
+            return  {
+                title:"领取熊猫美妆F码",
+                desc:'享<?php echo "{$output['price']}元购{$output['name']}"; ?>福利',
+                link:url,
+                imgUrl:"<?php echo $output['image']; ?>"
+            };
+        })();
+        weiXinShare.init(shareData);
+    });
 </script>
 </body>
 </html>

+ 54 - 0
mobile/templates/default/fcode/error.php

@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>熊猫美妆F码</title>
+    <meta name="format-detection" content="telephone=no" />
+    <script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/flexible.js?<?php echo bonus_version(); ?>"></script>
+    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/css/main.css?<?php echo bonus_version(); ?>"/>
+</head>
+<body>
+<div class="container-fluid bg_write layout_center p_relative">
+    <div>
+        <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/content_bg.png" alt="熊猫美妆"/>
+    </div>
+    <div class="prompt_text t_left">
+        <ul class="layout_center">
+            <li>1.领取后进入APP“F码专区”购买</li>
+            <li>2.请注意F码使用有效期</li>
+            <li>3.商品退货后F码不退</li>
+        </ul>
+    </div>
+
+    <!--领取状态显示-->
+    <div class="bind_tel_box p_absolute bg_write">
+        <div class="receive_state layout_center">
+            <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/error.png" alt=""/>
+        </div>
+        <h4 class="t_center"><?php echo $output['error']; ?></h4>
+    </div>
+
+    <div class="p_absolute advert bg_write">
+        <div class="f_left logo">
+            <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/logo.png" alt="logo"/>
+        </div>
+        <div class="f_left">
+            <h4>熊猫美妆</h4>
+            <p>专柜美妆&nbsp;&nbsp;内买平台</p>
+        </div>
+        <div class="f_right">
+            <a href="javascript:void(0)" class="btn btn_down block t_center" id="link">立即下载</a>
+        </div>
+    </div>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/js/fcode.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript">
+    $(function(){
+        $('#link').attr('href',app());
+
+        $('body').height($('body')[0].clientHeight);
+    })
+</script>
+</body>
+</html>

+ 29 - 11
mobile/templates/default/fcode/index.php

@@ -25,18 +25,22 @@
     <div class="receive">
         <a href="javascript:void(0)" class="btn btn_receive block layout_center t_center btn_pressed" id="receive">立即领取</a>
     </div>
+    <div class="loading"></div>
 </div>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/wx_share.js?<?php echo bonus_version(); ?>"></script>
 <script type="text/javascript">
-    $(function(){
+    $(function()
+    {
         $('#receive').on('touchstart',function(){
             $(this).removeClass('btn_pressed');
         });
-        $('#receive').on('touchend',function(){
-            $(this).addClass('btn_pressed');
-        });
-        $('#receive').on('tap',function ()
+
+        $('#receive').on('touchend',function()
         {
+            $(this).addClass('btn_pressed');
+            $('.loading').css('display','block');
             $.ajax({
                 type:'get',
                 dataType:'json',
@@ -47,15 +51,29 @@
                 },
                 success:function(data)
                 {
-                    console.log(data);
-                    if(data.code == 200)
-                    {
-                        location.reload(data.url);
+                    if(data.code == 200) {
+                        $('.loading').css('display','none');
+                        location.replace(data.datas.url);
+                    } else {
+                        $('.loading').css('display','none');
+                        alert('请检查网络');
                     }
                 }
             })
-        })
-    })
+        });
+
+        var shareData = (function()
+        {
+            var url = '<?php echo BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&client_type=wap&common_id={$output['common_id']}&batch_code={$output['batch_code']}"; ?>';
+            return  {
+                title:"领取熊猫美妆F码",
+                desc:'享<?php echo "{$output['price']}元购{$output['name']}"; ?>福利',
+                link:url,
+                imgUrl:"<?php echo $output['image']; ?>"
+            };
+        })();
+        weiXinShare.init(shareData);
+    });
 </script>
 </body>
 </html>

+ 70 - 0
mobile/templates/default/fcode/success.php

@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>熊猫美妆F码</title>
+    <meta name="format-detection" content="telephone=no" />
+    <script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/flexible.js?<?php echo bonus_version(); ?>"></script>
+    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/css/main.css?<?php echo bonus_version(); ?>"/>
+</head>
+<body>
+<div class="container-fluid bg_write layout_center p_relative">
+    <div>
+        <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/content_bg.png" alt="熊猫美妆"/>
+    </div>
+    <div class="prompt_text t_left">
+        <ul class="layout_center">
+            <li>1.领取后进入APP“F码专区”购买</li>
+            <li>2.请注意F码使用有效期</li>
+            <li>3.商品退货后F码不退</li>
+        </ul>
+    </div>
+
+    <!--领取状态显示-->
+    <div class="bind_tel_box p_absolute bg_write">
+        <div class="fcode t_center layout_center fcode_success_bg"><?php echo $output['fcode']['fc_code']; ?></div>
+        <div class="receive_state layout_center">
+            <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/success.png" alt="成功"/>
+        </div>
+        <h4 class="t_center">恭喜你领取成功!</h4>
+        <p class="t_center">请在APP<我的F码>中查看</p>
+    </div>
+
+    <div class="p_absolute advert bg_write">
+        <div class="f_left logo">
+            <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/logo.png" alt="logo"/>
+        </div>
+        <div class="f_left">
+            <h4>熊猫美妆</h4>
+            <p>专柜美妆&nbsp;&nbsp;内买平台</p>
+        </div>
+        <div class="f_right">
+            <a href="javascript:void(0)" class="btn btn_down block t_center" id="link">立即下载</a>
+        </div>
+    </div>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/js/fcode.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/wx_share.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript">
+    $(function()
+    {
+        $('#link').attr('href',app());
+        $('body').height($('body')[0].clientHeight);
+
+        var shareData = (function()
+        {
+            var url = '<?php echo BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&client_type=wap&common_id={$output['fcode']['goods_commonid']}&batch_code={$output['fcode']['batch_code']}"; ?>';
+            return  {
+                title:"领取熊猫美妆F码",
+                desc:'享<?php echo "{$output['price']}元购{$output['name']}"; ?>福利',
+                link:url,
+                imgUrl:"<?php echo $output['image']; ?>"
+            };
+        })();
+        weiXinShare.init(shareData);
+    });
+</script>
+</body>
+</html>

+ 9 - 0
test/TestFcode.php

@@ -43,4 +43,13 @@ class TestFcode extends PHPUnit_Framework_TestCase
 
     }
 
+
+    public function testString()
+    {
+        $num = "30";
+        for($i = 0; $i < $num; ++$i) {
+            $data = $i;
+        }
+    }
+
 }

+ 1 - 4
test/redisTest.php

@@ -96,19 +96,16 @@ class redisTest extends PHPUnit_Framework_TestCase
         $redis->close();
     }
 
-
     public function testSubscribe()
     {
         $redis = new Redis();
         $redis->pconnect('127.0.0.1',6379);
         $data = $redis->pubsub('numsub');
-
         $data = $redis->pubsub('numsub',array('chan-1'));
         $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'sub_callback');
+
         $data = $redis->pubsub('numsub');
         $data = $redis->pubsub('numpat');
-
-        //$x = 5;
     }
 
     public function testFcode()