Browse Source

Merge branch 'goods' of 121.43.114.153:/home/git/repositories/shopnc into goods

Wan Xin 9 years ago
parent
commit
2874173ed1

+ 10 - 9
core/framework/function/core.php

@@ -62,7 +62,7 @@ function checkSeccode($nchash,$value){
 }
 
 /**
- * 设置cookie QQ wap 登录 by 33h ao.co m 
+ * 设置cookie QQ wap 登录 by 33h ao.co m
  *
  * @param string $name cookie 的名称
  * @param string $value cookie 的值
@@ -437,7 +437,7 @@ function Model($model = null, $base_path = null)
 	if (!is_null($model) && isset($_cache[$cache_key])) {
         return $_cache[$cache_key];
     }
-    
+
 	$base_path = $base_path == null ? BASE_DATA_PATH : $base_path;
 	$file_name = $base_path.'/model/'.$model.'.model.php';
 	$class_name = $model.'Model';
@@ -1218,13 +1218,13 @@ function import($libname,$file_ext='.php'){
 		$path = str_replace('#','.',$path);
 	}
 	//返回安全路径
-    
+
 	if(preg_match('/^[\w\d\/_.]+$/i', $path)){
-		$file = realpath($base_dir.$path.$file_ext);        
+		$file = realpath($base_dir.$path.$file_ext);
 	}else{
 		$file = false;
 	}
-    
+
 	if (!$file){
 		exit($path.$file_ext.' isn\'t exists!');
 	}else{
@@ -1472,6 +1472,7 @@ function pagecmd($cmd ='', $arg = ''){
 		case 'seteachnum':		$page->setEachNum($arg);break;
 		case 'settotalnum': 	$page->setTotalNum($arg);break;
 		case 'setnowpage': 	    $page->setNowPage($arg);break;
+		case 'settotalpage': 	$page->setTotalPage();break;
 		case 'setstyle': 		$page->setStyle($arg);break;
 		case 'show': 			return $page->show($arg);break;
 		case 'obj':				return $page;break;
@@ -1689,8 +1690,8 @@ function rcache($key = null, $prefix = '', $fields = '*')
     if ($cache_info === false) {
         //取单个字段且未被缓存
         $data  = array();
-    } 
-    elseif (is_array($cache_info)) 
+    }
+    elseif (is_array($cache_info))
     {
         //如果有一个键值为false(即未缓存),则整个函数返回空,让系统重新生成全部缓存
         $data = $cache_info;
@@ -1701,7 +1702,7 @@ function rcache($key = null, $prefix = '', $fields = '*')
                 break;
             }
         }
-    } 
+    }
     else
     {
         //string 取单个字段且被缓存
@@ -1749,7 +1750,7 @@ function dcache($key = null, $prefix = '')
     if ($key===null || !C('cache_open')) {
     	return true;
     }
-    
+
     $ins = Cache::getInstance('cacheredis');
     return $ins->hdel($key, $prefix);
 }

+ 16 - 11
core/framework/libraries/log.php

@@ -1,34 +1,39 @@
 <?php
 /**
- * 记录日志 
+ * 记录日志
  ***/
 defined('InShopNC') or exit('Access Invalid!');
-class Log{
 
-    const SQL       = 'SQL';
-    const ERR       = 'ERR';
-    private static $log =   array();
+class Log
+{
 
-    public static function record($message,$level=self::ERR) {
-        $now = @date('Y-m-d H:i:s',time());
+    const SQL = 'SQL';
+    const ERR = 'ERR';
+    private static $log = array();
+
+    public static function record($message, $level = self::ERR)
+    {
+        $now = @date('Y-m-d H:i:s', time());
         switch ($level) {
             case self::SQL:
                 self::$log[] = "[{$now}] {$level}: {$message}\r\n";
+
                 $log_file = BASE_DATA_PATH.'/log/'.date('Ymd',TIMESTAMP).'.log';
                 $content = "[{$now}] {$level}: {$message}\r\n";
                 file_put_contents($log_file,$content, FILE_APPEND);
                 break;
             case self::ERR:
-                $log_file = BASE_DATA_PATH.'/log/'.date('Ymd',TIMESTAMP).'.log';
+                $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', TIMESTAMP) . '.log';
                 $url = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
                 $url .= " ( act={$_GET['act']}&op={$_GET['op']} ) ";
                 $content = "[{$now}] {$url}\r\n{$level}: {$message}\r\n";
-                file_put_contents($log_file,$content, FILE_APPEND);
+                file_put_contents($log_file, $content, FILE_APPEND);
                 break;
         }
     }
 
-    public static function read(){
-    	return self::$log;
+    public static function read()
+    {
+        return self::$log;
     }
 }

+ 6 - 3
data/config/config.ini.php

@@ -4,12 +4,15 @@
 $config = array();
 
 const test_srv_host = 'http://121.43.114.153';
+const stanley_host = 'http://192.168.1.131';
+const stanley_home = 'http://192.168.1.12';
 const stanley_host = 'http://192.168.1.105';
 const stanley_home = 'http://192.168.1.4';
 const boss_host = 'http://172.40.2.14';
 
 const jeff_office = 'http://192.168.1.128';
-$SRV_HOST = jeff_office;
+const liax_office = 'http://192.168.1.136';
+$SRV_HOST = test_srv_host;
 
 $config['base_site_url']        = $SRV_HOST;
 $config['shop_site_url'] 		= $SRV_HOST.'/shop';
@@ -28,11 +31,11 @@ $config['version'] 		= '201502020388';
 $config['setup_date'] 	= '2015-08-22 15:52:34';
 $config['gip'] 			= 0;
 $config['dbdriver'] 	= 'mysqli';
-$config['tablepre']		= '33hao_';
+$config['tablepre']		= 'lrlz_';
 $config['db']['1']['dbhost']       = '127.0.0.1';
 $config['db']['1']['dbport']       = '3306';
 $config['db']['1']['dbuser']       = 'root';
-$config['db']['1']['dbpwd']        = '55668899';
+$config['db']['1']['dbpwd']        = 'jeff1104';
 $config['db']['1']['dbname']       = '33hao';
 $config['db']['1']['dbcharset']    = 'UTF-8';
 $config['db']['slave']                  = $config['db']['master'];

+ 67 - 1
mobile/control/app_pay.php

@@ -16,6 +16,7 @@ require_once (WXPAY_PATH . '/lib/WxPay.Notify.php');
 
 class app_payControl extends mobileHomeControl
 {
+
     public function uniorderOp()
     {
 //        $desc = $_POST['desc'];
@@ -34,9 +35,74 @@ class app_payControl extends mobileHomeControl
         $input->SetTrade_type("APP");//JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里,MICROPAY--刷卡支付,刷卡支付有单独的支付接口,不调用统一下单接口
         $order = WxPayApi::unifiedOrder($input);
 
-        joutput_data($order);
+        //$ret = $this->handle_order($order);
+
+        $ret = array();
+        $ret['appid'] = $order["appid"];
+        $ret['noncestr'] = WxPayApi::getNonceStr();
+        $ret['package'] = 'Sign=WXPay';
+        $ret['partnerid'] = WxPayConfig::MCHID;
+        $ret['prepayid'] = $order['prepay_id'];
+        $timeStamp = time();
+        $ret['timestamp'] = "$timeStamp";
+
+        $sign = $this->make_sign($ret);
+        $ret['sign'] = $sign;
+
+
+        joutput_data($ret);
     }
 
+    /**
+     * 格式化参数格式化成url参数
+     */
+    private function to_url_params($values)
+    {
+        $buff = "";
+        foreach ($values as $k => $v)
+        {
+            if($k != "sign" && $v != "" && !is_array($v)){
+                $buff .= $k . "=" . $v . "&";
+            }
+        }
+
+        $buff = trim($buff, "&");
+        return $buff;
+    }
+
+    private function make_sign($values)
+    {
+        //签名步骤一:按字典序排序参数
+        ksort($values);
+        $string = $this->to_url_params($values);
+        //签名步骤二:在string后加入KEY
+        $string = $string . "&key=".WxPayConfig::KEY;
+        //签名步骤三:MD5加密
+        $string = md5($string);
+        //签名步骤四:所有字符转为大写
+        $result = strtoupper($string);
+        return $result;
+    }
+
+//    private function handle_order($order)
+//    {
+//        $jsapi = new WxPayJsApiPay();
+//        $jsapi->SetAppid($order["appid"]);
+//        $timeStamp = time();
+//        $jsapi->SetTimeStamp("$timeStamp");
+//        $jsapi->SetNonceStr(WxPayApi::getNonceStr());
+//        $jsapi->SetPackage('Sign=WXPay');
+//        //$jsapi->SetPackage("prepay_id=" . $order['prepay_id']);
+//        //$jsapi->SetSignType("MD5");
+//        $jsapi->SetPaySign($jsapi->MakeSign());
+//        //$sign = $jsapi->MakeSign();
+//        $jsapi->SetSign();
+//
+//        $jsapi->SetPaySign($jsapi->MakeSign());
+//
+//        return $jsapi->GetValues();
+//    }
+
     public function notifyOp()
     {
 

+ 3 - 1
mobile/control/brand.php

@@ -11,7 +11,9 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class brandControl extends mobileHomeControl
 {
-
+    public function __construct() {
+        parent::__construct();
+    }
 
     public function indexOp()
     {

+ 36 - 0
mobile/control/efficacy.php

@@ -0,0 +1,36 @@
+<?php
+/**
+ * 前台品牌分类
+ *
+ *
+ *
+ ***/
+
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class efficacyControl extends mobileHomeControl
+{
+    public function __construct() {
+        parent::__construct();
+    }
+
+    public function indexOp(){
+
+    }
+
+    public function efficacy_listOp()
+    {
+        $efficacy_list = Model()->table('goods_efficacy')->order('sort asc')->select();
+
+        $result = array();
+        foreach ($efficacy_list as $value) {
+
+            $item['efficacy_id'] = $value['efficacy_id'];
+            $item['efficacy_name']=$value['efficacy_name'];
+
+            array_push($result,$item);
+        }
+        joutput_data(array("efficacy"=>$result));
+    }
+}

+ 73 - 11
mobile/control/goods.php

@@ -18,7 +18,6 @@ class goodsControl extends mobileHomeControl
         parent::__construct();
     }
 
-
     /**
      * 商品列表
      */
@@ -28,20 +27,29 @@ class goodsControl extends mobileHomeControl
         $model_goods = Model('goods');
         $model_search = Model('search');
 
-        if(!empty($_GET['curpage'])){
-            pagecmd('setnowpage',$_GET['curpage']);
+        if (!empty($_GET['page'])) {
+            pagecmd('seteachnum',$_GET['page']);
+        }
+
+        if (!empty($_GET['curpage'])) {
+            pagecmd('setnowpage', $_GET['curpage']);
         }
 
+        pagecmd('settotalnum',1);
+        pagecmd('settotalpage');
+
         //查询条件
         $condition = array();
         if (!empty($_GET['gc_id']) && intval($_GET['gc_id']) > 0) {
             $condition['gc_id'] = $_GET['gc_id'];
         } elseif (!empty($_GET['keyword'])) {
             $condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%');
+        } elseif (!empty($_GET['brand_id']) && intval($_GET['brand_id'])) {
+            $condition['brand_id'] = $_GET['brand_id'];
         }
 
         //所需字段
-        $fieldstr = "goods_id,goods_commonid,goods_commonid,store_id,brand_id,gc_id,goods_name,goods_price,goods_marketprice,goods_image,goods_salenum,evaluation_good_star,evaluation_count";
+        $fieldstr = "goods_id,goods_commonid,store_id,brand_id,gc_id,goods_name,goods_price,goods_marketprice,goods_image,goods_salenum,evaluation_good_star,evaluation_count";
 
         // 添加3个状态字段
         $fieldstr .= ',is_virtual,is_presell,is_fcode,have_gift';
@@ -69,7 +77,7 @@ class goodsControl extends mobileHomeControl
         //处理商品列表(抢购、限时折扣、商品图片)
         $goods_list = $this->_goods_list_extend($goods_list);
 
-        joutput_data(array('goods_list' => $goods_list,'mobile_page' => mobile_page($page_count)));
+        joutput_data(array('goods_list' => $goods_list, 'mobile_page' => mobile_page($page_count)));
     }
 
     /**
@@ -119,8 +127,7 @@ class goodsControl extends mobileHomeControl
         //促销
         $groupbuy_list = Model('groupbuy')->getGroupbuyListByGoodsCommonIDString(implode(',', $commonid_array));
         $xianshi_list = Model('p_xianshi_goods')->getXianshiGoodsListByGoodsString(implode(',', $goodsid_array));
-        foreach ($goods_list as $key => &$value)
-        {
+        foreach ($goods_list as $key => &$value) {
             //抢购
             if (isset($groupbuy_list[$value['goods_commonid']])) {
                 $goods_list[$key]['goods_price'] = $groupbuy_list[$value['goods_commonid']]['groupbuy_price'];
@@ -146,13 +153,13 @@ class goodsControl extends mobileHomeControl
 
             // 增加 品牌名
             $brand = Model()->table("brand")->find($value['brand_id']);
-            if(!empty($brand)){
+            if (!empty($brand)) {
                 $value['brand_name'] = $brand['brand_name'];
             }
 
             // 增加分类
             $gc_info = Model()->table('goods_class')->find($value['gc_id']);
-            if(!empty($gc_info)){
+            if (!empty($gc_info)) {
                 $value['gc_name'] = $gc_info['gc_name'];
             }
 
@@ -450,9 +457,9 @@ class goodsControl extends mobileHomeControl
         $out_type = $_GET ['type'];
         $model_goods = Model('goods');
 
-        if(empty($_GET ['goods_commonid'])) {
+        if (empty($_GET ['goods_commonid'])) {
             $goods_info = $model_goods->getGoodsInfoByID($goods_id, 'goods_commonid');
-        }else{
+        } else {
             $goods_info['goods_commonid'] = intval($_GET ['goods_commonid']);
         }
         $goods_common_info = $model_goods->getGoodeCommonInfoByID($goods_info['goods_commonid']);
@@ -487,4 +494,59 @@ class goodsControl extends mobileHomeControl
         output('goods_common_info', $goods_common_info);
         Tpl::showpage('goods_body');
     }
+
+    // 通过品牌列表获取商品
+    public function goods_list_by_brand()
+    {
+        $model_goods = Model('goods');
+
+        if (!empty($_GET['curpage'])) {
+            pagecmd('setnowpage', $_GET['curpage']);
+        }
+
+        //查询条件
+        $condition = array();
+        if (!empty($_GET['gc_id']) && intval($_GET['gc_id']) > 0) {
+            $condition['gc_id'] = $_GET['gc_id'];
+        } elseif (!empty($_GET['keyword'])) {
+            $condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%');
+        }
+
+        //所需字段
+        $fieldstr = "goods_id,goods_commonid,goods_commonid,store_id,brand_id,gc_id,goods_name,goods_price,goods_marketprice,goods_image,goods_salenum,evaluation_good_star,evaluation_count";
+
+        // 添加3个状态字段
+        $fieldstr .= ',is_virtual,is_presell,is_fcode,have_gift';
+
+        //排序方式
+        $order = $this->_goods_list_order($_GET['key'], $_GET['order']);
+
+        //优先从全文索引库里查找
+
+        $goods_list = $model_goods->getGoodsListByColorDistinct($condition, $fieldstr, $order, $this->page);
+        $page_count = $model_goods->gettotalpage();
+
+        //处理商品列表(抢购、限时折扣、商品图片)
+        $goods_list = $this->_goods_list_extend($goods_list);
+
+        joutput_data(array('goods_list' => $goods_list, 'mobile_page' => mobile_page($page_count)));
+    }
+
+
+    public function goods_searchOp()
+    {
+        // 属性ID,类型ID
+        $attr_value_id = intval($_GET['attr_value_id']);
+        $type_id = intval($_GET['type_id']);
+
+        $fields = "distinct goods_commonid as goods_commonid";
+
+        // 功效
+        $goods_attr = Model()->table('goods_attr_index')->field($fields)->where(array('type_id' => $type_id, 'attr_value_id' => $attr_value_id))->select();
+
+        foreach ($goods_attr as $value) {
+
+        }
+
+    }
 }

+ 1 - 1
mobile/control/type.php

@@ -51,7 +51,7 @@ class typeControl extends mobileHomeControl
                     }
                 }
             }
-            joutput_data($goods_class);
+            joutput_data(array("data"=>$goods_class));
 
         } else {
             joutput_error(1001, "keyword is must!");