소스 검색

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

stanley-king 9 년 전
부모
커밋
4a895a3f8f

+ 15 - 49
data/logic/payment.logic.php

@@ -36,19 +36,29 @@ class paymentLogic
         $condition['pay_sn'] = $pay_sn;
         $order_list = $model_order->getNormalOrderList($condition);
 
+        // 使用红包(预存款)
+        $usebonus = $_GET['usebonus'];
+        // 获取余额数据
+        $obj_member = Model('member');
+        $pd_amount = $obj_member->getPdAmount($member_id);
         //计算本次需要在线支付的订单总金额
         $pay_amount = 0;
         if (!empty($order_list)) {
             foreach ($order_list as $order_info) {
+                if (intval($usebonus) === 1) {  // 使用全部预存款(红包逻辑)
+                    if (floatval($pd_amount) > floatval($order_info['order_amount'])) {
+                        // 余额大于订单金额的情况
+                        $order_info['pd_amount'] = floatval($order_info['order_amount']);
+                        $pd_amount = floatval($pd_amount) - floatval($order_info['pd_amount']);
+                    } else if (floatval($pd_amount) > 0) {    // 余额小于等于订单金额的情况, $pd_amount不能等于0
+                        $order_info['pd_amount'] = floatval($pd_amount);
+                        $pd_amount = 0;
+                    }
+                }
                 $pay_amount += ncPriceFormat(floatval($order_info['order_amount']) - floatval($order_info['pd_amount']));
             }
         }
 
-        $usebonus = $_GET['usebonus'];
-        if (intval($usebonus) === 1) {
-            $pay_amount = $this->getAndUpdateBonus($member_id,$pay_amount);
-        }
-
         $order_pay_info['api_pay_amount'] = $pay_amount;
         $order_pay_info['order_list'] = $order_list;
 
@@ -56,50 +66,6 @@ class paymentLogic
     }
 
     /**
-     * @param $user_id  用户ID
-     * @param $pay_amount 需要支付金额
-     * @return value  扣除红包后需要支付金额
-     */
-    public function getAndUpdateBonus($user_id,$pay_amount){
-
-        // 获取所有红包 红包类型为 1 ,user_id = member_id,当前时间小于结束时间(暂时未作为参数)
-        $condition['user_id'] = $user_id;
-        $condition['bonus_type_id'] = 1;
-        $bonus_list = Model()->table("user_bonus")->where($condition)->select();
-
-        $ret_value = 0;
-        if (!empty($bonus_list))
-        {
-            foreach ($bonus_list as $value)
-            {
-                $bonus_value = doubleval($value['bonus_value']);  // 红包金额
-
-                // 支付金额大于红包金额-需要继续选择红包
-                if (($pay_amount - $bonus_value) > 0.0000001) {
-
-                    $data['bonus_value'] = 0;  // 更新为0
-                    $ret = Model()->table('user_bonus')->where(array('bonus_id' => $value['bonus_id']))->update($data);
-
-                    if($ret){
-                        $pay_amount -= $bonus_value;
-                    }
-                } else {
-
-                    $data['bonus_value'] = $bonus_value - $pay_amount;
-                    $ret = Model()->table('user_bonus')->where(array('bonus_id' => $value['bonus_id']))->update($data);
-
-                    if($ret) {
-                        $pay_amount = 0;
-                    }
-                    break;
-                }
-            }
-        }
-
-        return $pay_amount;
-    }
-
-    /**
      * 取得虚拟订单所需支付金额等信息
      * @param int $order_sn
      * @param int $member_id

+ 96 - 0
data/model/member.model.php

@@ -734,4 +734,100 @@ class memberModel extends Model
         }
         return $grade_arr;
     }
+
+    /**
+     * @param $user_id  用户ID
+     * @return value  获取用户预存款金额
+     */
+    public function getPdAmount($member_id){
+
+        //查询会员信息
+        $member_id = intval($member_id);
+        $member_info = $this->getMemberInfo(array('member_id'=>$member_id));
+
+        if (!is_array($member_info) || count($member_info)<=0){
+            return 0;  // 用户信息不对
+        }
+        $available_predeposit=floatval($member_info['available_predeposit']);
+        return $available_predeposit;
+    }
+
+    /**
+     * @param $user_id  用户ID
+     * @return value  获取用户预存款订单列表(图片, 名字, 数量, 订单时间, 订单号)
+     */
+    public function getPdOrderList($member_id){
+
+        //查询预存款订单列表
+        $member_id = intval($member_id);
+        $member_info = $this->getMemberInfo(array('member_id'=>$member_id));
+
+        if (!is_array($member_info) || count($member_info)<=0){
+            return array();  // 用户信息不对
+        }
+
+        // 预存款订单查询条件
+        $condition = 'lg_freeze_amount=0.0 and lg_av_amount<0.0 and lg_member_name=\'' . $member_info['member_name'] . '\'';
+        
+        $model_pd = Model('predeposit');
+        $tmp_log_list = array();
+        //$pd_log_list =$this->getPdLogList($condition,20,'*','lg_id desc');
+        $pd_log_list = $model_pd->getPdLogList($condition,'','*','lg_id desc');
+
+        // 订单数据查询条件, 生成订单查询语句, 在详细查询阶段进行批量查询
+        $condition_order = "order_id in(";
+        foreach ($pd_log_list as $key => $value) {
+            $use_list = array();
+            $match = '';
+            preg_match('/\d+/',$value['lg_desc'], $match);
+            $order_id = $match[0];
+            $use_list['order_id'] = $order_id;
+            $use_list['order_add_time'] = $value['lg_add_time'];
+            $use_list['order_value'] = $value['lg_av_amount'];
+
+            if (empty($tmp_log_list)) {
+                $condition_order .= '\''.$order_id .'\'';
+            } else {
+                $condition_order .=  "," . '\''. $order_id .'\'';
+            }
+            // 获取订单数据
+            $tmp_log_list[$order_id] = $use_list;
+        }
+        
+        // 查询订单详细数据
+        $condition_order .= ")";
+        $model_order = Model('order');
+        //$order_list = $model_order->getOrderList($condition_order, 20, '*', 'order_id desc','', array('order_common','order_goods','store'));
+        $order_list = $model_order->getOrderList($condition_order, '', '*', 'order_id desc','', array('order_common','order_goods','store'));
+
+        // 订单列表处理
+        foreach ($order_list as $key => $value) {
+            $item = array();
+            // 查询订单
+            // 图片, 名字, 数量
+            $order_id = $value['order_id'];
+            $use_list = $tmp_log_list[$order_id];
+            if (empty($use_list)) continue; // 该订单为其他消耗, 非购买商品
+
+            $item['goods_name'] = $value['goods_name'];
+            $item['goods_num'] = $value['goods_num'];
+            $item['goods_image'] = $value['goods_image'];
+            array_push($use_list['item'], $item);
+            array_push($tmp_log_list[$order_id], $item);
+        }
+
+        // 最终结果组装
+        $pd_result_list = array();
+        foreach ($tmp_log_list as $key => $value) {
+            $use_list = array();
+            $use_list['order_id']= $value['order_id'];
+            $use_list['order_add_time']= $value['order_add_time'];
+            $use_list['order_value']= $value['order_value'];
+            $use_list['item']= $value['item'];
+
+            array_push($pd_result_list, $use_list);
+        }
+
+        return $pd_result_list;
+    }
 }

+ 1 - 0
fcgi_run.php

@@ -6,6 +6,7 @@ define('MOBILE_SERVER',true);
 require_once (BASE_ROOT_PATH . '/fooder.php');
 require_once (BASE_ROOT_PATH . '/helper/http_header.php');
 require_once (BASE_ROOT_PATH . '/helper/session.php');
+require_once (BASE_ROOT_PATH . '/helper/func.php');
 
 function pays_execute($file)
 {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 34 - 34
mobile/control/app_pay.php


+ 8 - 17
mobile/control/app_update.php

@@ -15,7 +15,13 @@ class app_updateControl extends mobileHomeControl
         parent::__construct();
     }
 
-    // 验证版本
+    /**
+     * 版本验证
+     *
+     * 输入参数:
+     * ver_code:版本号
+     * platform: 平台
+     */
     public function checkVersionOp()
     {
         $ver_code = $_GET['ver_code'];
@@ -23,35 +29,24 @@ class app_updateControl extends mobileHomeControl
 
         if (isset($app_platform) && isset($ver_code)) {
 
-            // cache中读取
             $ret = rcache(self::CACHE_KEY, self::CACHE_CHECK_VERSION_ID);
-
             if (empty($ret)) {
-
                 $model = Model();
                 $data = $model->table('app_update')->where(array('cur_version' => '1', 'enable' => '1', 'platform' => $app_platform))->limit(1)->select();
-
                 if (empty($data)) {
-                    return joutput_error('系统错误!');
+                    return joutput_error(errcode::ErrDB);
                 }
-
-                // 写入cache
                 wcache(self::CACHE_KEY, array("cur_version" => serialize($data)), self::CACHE_CHECK_VERSION_ID);
-
             } else {
                 $data = unserialize($ret['cur_version']);
             }
 
             $result = array();
-
             $lowest_compatible_version = intval($data[0]['lowest_compatible_version']);
-
             if ($ver_code === $data[0]['ver_code']) {
                 $result['latest'] = 0;
             } else {
                 $result['latest'] = 1;
-
-                // 强制升级
                 if ($lowest_compatible_version > intval($ver_code)) {
                     $result['force_update'] = 1;
                 } else {
@@ -63,15 +58,11 @@ class app_updateControl extends mobileHomeControl
                 $update_info['app_path'] = $data[0]['app_path'];
                 $update_info['release_note'] = $data[0]['release_note'];
                 $update_info['remind_time'] = $data[0]['remind_time'];
-
                 $parse_url = parse_url($update_info['app_path']);
                 $update_info['md5_file'] = md5_file(BASE_ROOT_PATH . $parse_url['path']);
-
                 $result['update_info'] = $update_info;
             }
-
             joutput_data($result);
-
         } else {
             output_error('请输入平台和版本号!');
         }

+ 3 - 0
mobile/control/attribute.php

@@ -16,6 +16,9 @@ class attributeControl extends mobileHomeControl
         parent::__construct();
     }
 
+    /**
+     * 查询功效列表(已废)
+     */
     public function effectOp()
     {
         $goods_attr_index_list = Model()->table('goods_attr_index')->field('attr_id')->distinct('attr_id')->where('1=1')->select();

+ 116 - 120
mobile/control/bonus.php

@@ -1,121 +1,117 @@
-<?php
-/**
- * 红包管理
- *
- *
- *
- ***/
-defined('InShopNC') or exit('Access Invalid!');
-
-class bonusControl extends mobileMemberExControl
-{
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    public function bonus_listOp()
-    {
-        // 检验token
-        $token = $_GET['key'];
-
-        if (empty($token)) {
-            return joutput_error(errcode::ErrInputParam, '输入参数有误');
-        }
-
-        if ($this->checkToken($token) != errcode::Success) {
-            return joutput_error($this->err_code, errcode::msg($this->err_code));
-        }
-
-        // 根据token获取用户ID
-        $condition['user_id'] = $this->member_info['member_id'];
-
-        if (!empty($condition['user_id'])) {
-
-            $ret = Model()->table("user_bonus")->where($condition)->select();
-
-            $total_value = 0;
-            $ret_array = array();
-            foreach ($ret as $value) {
-
-                $bonus_type = Model()->table('bonus_type')->where(array('type_id' => $value['bonus_type_id']))->limit(1)->select();
-
-                if (!empty($bonus_type)) {
-                    $result['type_name'] = $bonus_type[0]['type_name'];
-                    $result['use_start_date'] = $bonus_type[0]['use_start_date'];
-                    $result['use_end_date'] = $bonus_type[0]['use_end_date'];
-                }
-
-                $result['bonus_sn'] = $value['bonus_sn'];
-                $result['bonus_value'] = $value['bonus_value'];
-                $result['get_time'] = $value['get_time'];
-
-                $result['left_time'] = $result['use_end_date'] - time();
-
-                $total_value += intval($value[bonus_value]);
-
-                array_push($ret_array, $result);
-            }
-
-            joutput_data(array('total_value' => $total_value, 'bonus_list' => $ret_array));
-        }
-    }
-
-    // 红包绑定
-    public function bind_bonusOp()
-    {
-        // 检验token
-        $token = $_GET['key'];
-
-        if (empty($token)) {
-            return joutput_error(errcode::ErrInputParam, '输入参数有误');
-        }
-
-        if ($this->checkToken($token) != errcode::Success) {
-            return joutput_error($this->err_code, errcode::msg($this->err_code));
-        }
-
-        // 获取user_id
-        $condition['member_id'] = $this->member_info['member_id'];
-
-        if (!empty($condition['member_id'])) {
-
-            // get member_mobile 获取用户手机号
-            $member = Model()->table("member")->field("member_mobile")->where($condition)->select();
-
-            if (!empty($member)) {
-
-                $user_bonus = Model()->table("user_bonus")->where(array('user_mobile' => $member[0]['member_mobile'], 'user_id' => 0))->select();
-
-                // 更新user_bonus
-                if (!empty($user_bonus)) {
-
-                    $bonus_info = array();
-                    foreach ($user_bonus as $value) {
-
-                        $bonus_type = Model()->table('bonus_type')->where(array('type_id' => $value['bonus_type_id']))->limit(1)->select();
-
-                        $info = [];
-                        $info['sender'] = $bonus_type[0]['sender'];
-                        $info['type_name'] = $bonus_type[0]['type_name'];
-                        $info['bonus_value'] = $value['bonus_value'];
-
-                        array_push($bonus_info, $info);
-                    }
-                    // 更新为已领取
-                    $data['user_id'] = $this->member_info['member_id'];
-                    $ret = Model()->table('user_bonus')->where(array('user_mobile' => $member[0]['member_mobile']))->update($data);
-
-                    // 返回存在红包
-                    joutput_data(array('have_bonus' => 1, 'bonus_info' => $bonus_info));
-
-                } else {
-                    joutput_data(array('have_bonus' => 0, 'bonus_info' => null));
-                }
-
-            } else {
-                return joutput_error(errcode::ErrTokenExpire, "用户手机号没绑定");
-            }
-        }
-    }
+<?php
+/**
+ * 绾㈠寘绠$悊
+ *
+ *
+ *
+ ***/
+defined('InShopNC') or exit('Access Invalid!');
+
+class bonusControl extends mobileMemberExControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * 鑾峰彇绾㈠寘鍒楄〃
+     */
+    public function bonus_listOp()
+    {
+        // 妫€楠宼oken
+        $token = $_GET['key'];
+
+        if (empty($token)) {
+            return joutput_error(errcode::ErrInputParam);
+        }
+        if ($this->checkToken($token) != errcode::Success) {
+            return joutput_error($this->err_code);
+        }
+
+        $condition['user_id'] = $this->member_info['member_id'];
+        if (!empty($condition['user_id'])) {
+
+            $ret = Model()->table("user_bonus")->where($condition)->select();
+            // 红包总值(直接等于预存款值)
+            $obj_member = Model('member');
+            $total_value = $obj_member->getPdAmount($condition['user_id']);
+            $ret_array = array();
+
+            // 鑾峰彇浣跨敤鍒楄〃
+            $ret_array['use_list'] = $obj_member->getPdOrderList($condition['user_id']);
+            // 缁勮�绾㈠寘鍒楄〃
+            $ret_array['bonus_list'] = array();
+            $bonus_list = array();
+            foreach ($ret as $value) {
+                $bonus_type = Model()->table('bonus_type')->where(array('type_id' => $value['bonus_type_id']))->limit(1)->select();
+
+                if (!empty($bonus_type)) {
+                    $result['type_name'] = $bonus_type[0]['type_name'];
+                    $result['use_start_date'] = $bonus_type[0]['use_start_date'];
+                    $result['use_end_date'] = $bonus_type[0]['use_end_date'];
+                }
+
+                $result['bonus_sn'] = $value['bonus_sn'];
+                //获取用户预存款(之前为获取红包接口)
+                $result['bonus_value'] = $value['bonus_value'];
+                $result['get_time'] = $value['get_time'];
+                $result['left_time'] = $result['use_end_date'] - time();
+
+                //$total_value += intval($value[bonus_value]);
+                //array_push($ret_array, $result);
+                // 绾㈠寘鍒楄〃
+                array_push($bonus_list, $result);
+            }
+            $ret_array['bonus_list'] = $bonus_list;
+            joutput_data(array('total_value' => $total_value, "ret_array" => $ret_array));
+        }
+    }
+
+    // 绾㈠寘缁戝畾
+    public function bind_bonusOp()
+    {
+        // 妫€楠宼oken
+        $token = $_GET['key'];
+        if (empty($token)) {
+            return joutput_error(errcode::ErrInputParam);
+        }
+
+        if ($this->checkToken($token) != errcode::Success) {
+            return joutput_error($this->err_code);
+        }
+
+        $condition['member_id'] = $this->member_info['member_id'];
+        if (!empty($condition['member_id'])) {
+
+            // get member_mobile 获取用户手机号
+            $member = Model()->table("member")->field("member_mobile")->where($condition)->select();
+            if (!empty($member)) {
+                $user_bonus = Model()->table("user_bonus")->where(array('user_mobile' => $member[0]['member_mobile'], 'user_id' => 0))->select();
+                // 鏇存柊user_bonus
+                if (!empty($user_bonus)) {
+
+                    $bonus_info = array();
+                    foreach ($user_bonus as $value) {
+
+                        $bonus_type = Model()->table('bonus_type')->where(array('type_id' => $value['bonus_type_id']))->limit(1)->select();
+                        $info = [];
+                        $info['sender'] = $bonus_type[0]['sender'];
+                        $info['type_name'] = $bonus_type[0]['type_name'];
+                        $info['bonus_value'] = $value['bonus_value'];
+                        array_push($bonus_info, $info);
+                    }
+                    // 鏇存柊涓哄凡棰嗗彇
+                    $data['user_id'] = $this->member_info['member_id'];
+                    $ret = Model()->table('user_bonus')->where(array('user_mobile' => $member[0]['member_mobile']))->update($data);
+                    // 杩斿洖瀛樺湪绾㈠寘
+                    joutput_data(array('have_bonus' => 1, 'bonus_info' => $bonus_info));
+                } else {
+                    joutput_data(array('have_bonus' => 0, 'bonus_info' => null));
+                }
+            } else {
+                return joutput_error(errcode::ErrTokenExpire);
+            }
+        }
+    }
 }

+ 12 - 7
mobile/control/control.php

@@ -127,11 +127,17 @@ class mbMemberControl extends mobileControl
 
     public function checkToken($token)
     {
-        $model_mb_user_token = Model('mb_user_token');
-        $mb_user_token_info = $model_mb_user_token->getMbUserTokenInfoByToken($token);
-        if (empty($mb_user_token_info)) {
-            $this->err_code = errcode::ErrLogin;
-            return false;
+        $key = func::gen_token_key($token);
+        $ret = rcache($key);
+        if (empty($ret)) {
+            $model_mb_user_token = Model('mb_user_token');
+            $mb_user_token_info = $model_mb_user_token->getMbUserTokenInfoByToken($token);
+            if (empty($mb_user_token_info)) {
+                $this->err_code = errcode::ErrLogin;
+                return false;
+            }
+        } else {
+            $mb_user_token_info = unserialize($ret['info']);
         }
 
         // 读取买家信息
@@ -143,12 +149,11 @@ class mbMemberControl extends mobileControl
             return false;
         }
 
-        //读取卖家信息
+        // 读取卖家信息
         $seller_info = Model('seller')->getSellerInfo(array('member_id' => $this->member_info['member_id']));
         $this->member_info['store_id'] = $seller_info['store_id'];
 
         $this->err_code = errcode::Success;
-
         return true;
     }
 }

+ 3 - 5
mobile/control/crash_log.php

@@ -12,11 +12,13 @@ class crash_logControl extends mobileHomeControl
         parent::__construct();
     }
 
+    /**
+     * 上传日志接口
+     */
     public function uploadOp()
     {
         $crash_content = $_POST['content'];
         if (!empty($crash_content)) {
-
             $platform = $_GET['client'];
             if (!empty($platform)) {
                 $path = BASE_DATA_PATH . '/log/' . $platform . '/';
@@ -34,15 +36,11 @@ class crash_logControl extends mobileHomeControl
             }
 
             if (!is_dir($path)) mkdir($path);
-
             $file_name = date('Ymd', TIMESTAMP) . '-' . random(4) . '.crash.log';
-
             file_put_contents($path . $file_name, $crash_content, FILE_APPEND);
-
         } else {
             return joutput_error(errcode::ErrInputParam, '无crash内容');
         }
-
         joutput_data();
     }
 }

+ 0 - 5
mobile/control/efficacy.php

@@ -12,10 +12,6 @@ class efficacyControl extends mobileHomeControl
         parent::__construct();
     }
 
-    public function indexOp(){
-
-    }
-
     /**
      * 获取功效列表
      */
@@ -27,7 +23,6 @@ class efficacyControl extends mobileHomeControl
         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));

+ 0 - 3
mobile/control/find.php

@@ -19,7 +19,6 @@ class findControl extends mobileHomeControl
     public function category_listOp()
     {
         $category_list = Model()->table('category_item')->where(array('enable' => '1'))->order('sort asc')->select();
-
         $result = array();
         foreach ($category_list as $value) {
 
@@ -27,10 +26,8 @@ class findControl extends mobileHomeControl
             $item['name'] = $value['name'];
             $item['type'] = $value['category_type'];
             $item['gc_id'] = $value['gc_id'];
-
             array_push($result, $item);
         }
         joutput_data(array("category" => $result));
     }
-
 }

+ 82 - 139
mobile/control/goods.php

@@ -18,6 +18,9 @@ class goodsControl extends mobileHomeControl
         parent::__construct();
     }
 
+    /**
+     * 初始化分页
+     */
     public function _initpage()
     {
         if (!empty($_GET['page'])) {
@@ -37,50 +40,40 @@ class goodsControl extends mobileHomeControl
     }
 
     /**
-     * 商品列表
+     * 商品列表接口
+     *
+     * 请求参数:
+     * key:
+     * order: 1-升序 2-降序
+     * page: 每页数量
+     * curpage: 当前页码
+     * gc_id: 分类编码
+     * keyword:搜索关键字
+     * brand_id: 品牌
+     * efficacy_id:功效查询
+     *
      */
     public function goods_listOp()
     {
         $model_goods = Model('goods');
-
         $this->_initpage();
-
         $condition = array();
-        if (!empty($_GET['gc_id'])) {
+        if (!empty(trim($_GET['gc_id']))) {
             $condition['gc_id'] = intval($_GET['gc_id']);
         }
-
-        // 关键字git
-        if (!empty($_GET['keyword'])) {
+        // 关键字
+        if (!empty(trim($_GET['keyword']))) {
             $condition['goods_name|goods_jingle'] = array('like', '%' . urldecode($_GET['keyword']) . '%');
         }
-
         // 品牌查询
-        if (!empty($_GET['brand_id'])) {
+        if (!empty(trim($_GET['brand_id']))) {
             $condition['brand_id'] = intval($_GET['brand_id']);
         }
-
         // 功效查询
-        if (!empty($_GET['efficacy_id'])) {
+        if (!empty(trim($_GET['efficacy_id']))) {
             $condition['efficacy_id'] = intval($_GET['efficacy_id']);
         }
 
-        // 彩妆护肤查询
-//        if (!empty($_GET['gc_id']) && !empty($_GET['type_id'])) {
-//
-//            $type_id = intval($_GET['type_id']);
-//            $gc_id = intval($_GET['gc_id']);
-//
-//            $goods_id_list = Model()->table('goods_attr_index')->field('distinct goods_id as goods_id')->where(array('type_id' => $type_id, 'gc_id' => $gc_id))->select();
-//
-//            $array_list = array();
-//            foreach ($goods_id_list as $value) {
-//                array_push($array_list, $value['goods_id']);
-//            }
-//
-//            $condition['goods_id'] = array('in',$array_list);
-//        }
-
         //所需字段
         $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,goods_storage,goods_storage_alarm";
 
@@ -152,7 +145,6 @@ class goodsControl extends mobileHomeControl
      */
     private function _goods_list_extend($goods_list)
     {
-        //获取商品列表编号数组
         $commonid_array = array();
         $goodsid_array = array();
         foreach ($goods_list as $key => $value) {
@@ -160,7 +152,7 @@ class goodsControl extends mobileHomeControl
             $goodsid_array[] = $value['goods_id'];
 
             // image 切换为goods_common 表中数据
-            $condition['goods_commonid']=$value['goods_commonid'];
+            $condition['goods_commonid'] = $value['goods_commonid'];
             $goods_image = Model()->table('goods_common')->where($condition)->field('goods_image')->select();
             $goods_list[$key]['goods_image'] = $goods_image[0]['goods_image'];
         }
@@ -189,7 +181,7 @@ class goodsControl extends mobileHomeControl
             $goods_list[$key]['goods_image_url'] = cthumb($value['goods_image'], 360, $value['store_id']);
 
             unset($goods_list[$key]['store_id']);
-//            unset($goods_list[$key]['goods_commonid']);
+            //unset($goods_list[$key]['goods_commonid']);
             unset($goods_list[$key]['nc_distinct']);
             unset($goods_list[$key]['gc_id']);
             unset($goods_list[$key]['goods_marketprice']);
@@ -204,24 +196,22 @@ class goodsControl extends mobileHomeControl
             unset($goods_list[$key]['group_flag']);
             unset($goods_list[$key]['xianshi_flag']);
 
-            // 增加 品牌名
+            // 品牌名
             $brand = Model()->table("brand")->find($value['brand_id']);
             if (!empty($brand)) {
                 $value['brand_name'] = $brand['brand_name'];
             }
 
-            // 增加分类
+            // 分类
             $gc_info = Model()->table('goods_class')->find($value['gc_id']);
             if (!empty($gc_info)) {
                 $value['gc_name'] = $gc_info['gc_name'];
             }
 
-            // 增加功效列表
+            // 功效列表
             $goods_common = Model('goods');
             $goods_common_info = $goods_common->getGoodeCommonInfoByID($value['goods_commonid']);
             if (!empty($goods_common_info)) {
-
-                // 仅获取功效
                 $value['goods_attr'] = $this->_parse_for_efficacy(unserialize($goods_common_info['goods_attr']));
             }
         }
@@ -231,22 +221,23 @@ class goodsControl extends mobileHomeControl
 
     /**
      * 商品详细页扩展
+     *
+     * 输入参数:
+     * goods_id:商品id
+     *
      */
     public function goods_commonOp()
     {
         $goods_id = intval($_GET ['goods_id']);
-        if(empty($_GET ['goods_id']) || $goods_id < 0) {
-            return joutput_error(errcode::ErrParamter,"goods_id = {$goods_id} must be > 0.");
+        if (empty($_GET ['goods_id']) || $goods_id < 0) {
+            return joutput_error(errcode::ErrParamter, "goods_id = {$goods_id} must be > 0.");
         }
-
         // 商品详细信息
         $model_goods = Model('goods')->cls();
         $goods_detail = $model_goods->getGoodsSku($goods_id);
         if (empty($goods_detail)) {
-            Log::record("goods_commonOp return NULL 1",Log::DEBUG);
-            return joutput_error(errcode::ErrGoodsNotExist,'商品不存在');
+            return joutput_error(errcode::ErrGoodsNotExist);
         }
-
         //推荐商品
         $model_store = Model('store')->cls();
         $store_info = $model_store->getStoreInfoByID($goods_detail['goods_info']['store_id']);
@@ -283,7 +274,7 @@ class goodsControl extends mobileHomeControl
         unset($goods_detail['goods_info']['brand_name']);
         unset($goods_detail['goods_info']['type_id']);
         unset($goods_detail['goods_info']['goods_image']);
-//        unset($goods_detail['goods_info']['goods_body']);
+        //unset($goods_detail['goods_info']['goods_body']);
         unset($goods_detail['goods_info']['mobile_body']);
         unset($goods_detail['goods_info']['goods_state']);
         unset($goods_detail['goods_info']['goods_stateremark']);
@@ -301,7 +292,7 @@ class goodsControl extends mobileHomeControl
         unset($goods_detail['goods_info']['spec_value']);
         unset($goods_detail['goods_info']['spec_name']);
         unset($goods_detail['goods_info']['goods_spec']);
-//        unset($goods_detail['goods_info']['goods_attr']);
+        //unset($goods_detail['goods_info']['goods_attr']);
 
         unset($goods_detail['groupbuy_info']);
         unset($goods_detail['xianshi_info']);
@@ -311,6 +302,10 @@ class goodsControl extends mobileHomeControl
 
     /**
      * 商品详细页
+     *
+     * 输入参数:
+     * goods_id: 商品id
+     * from:目前说明是来自app还是h5
      */
     public function goods_detailOp()
     {
@@ -321,10 +316,10 @@ class goodsControl extends mobileHomeControl
         $model_goods = Model('goods');
         $goods_detail = $model_goods->getGoodsDetail($goods_id);
         if (empty($goods_detail)) {
-            return joutput_error(errcode::ErrGoodsNotExist,'商品不存在');
+            return joutput_error(errcode::ErrGoodsNotExist);
         }
 
-        //推荐商品
+        // 推荐商品
         $model_store = Model('store');
         $hot_sales = $model_store->getHotSalesList($goods_detail['goods_info']['store_id'], 6);
         $goods_commend_list = array();
@@ -357,14 +352,11 @@ class goodsControl extends mobileHomeControl
             $goods_detail['goods_info']['goods_spec_obj'] = $this->_parse_goods_spec($goods_detail['goods_info']['goods_spec']);
             $goods_detail['UPLOAD_SITE_URL'] = $GLOBALS['setting_config']['upload_site_url'];
         }
-
-
         //v3-b11 抢购商品是否开始
         $goods_info = $goods_detail['goods_info'];
         //print_r($goods_info);
         $IsHaveBuy = 0;
-        if (!empty($_COOKIE['username']))
-        {
+        if (!empty($_COOKIE['username'])) {
             $model_member = Model('member');
             $member_info = $model_member->getMemberInfo(array('member_name' => $_COOKIE['username']));
             $buyer_id = $member_info['member_id'];
@@ -396,7 +388,6 @@ class goodsControl extends mobileHomeControl
         }
         $goods_detail['IsHaveBuy'] = $IsHaveBuy;
         //v3-b11 end
-
         joutput_data($goods_detail);
     }
 
@@ -443,11 +434,20 @@ class goodsControl extends mobileHomeControl
         unset($goods_detail['goods_info']['cart']);
         unset($goods_detail['goods_info']['buynow_text']);
         unset($goods_detail['groupbuy_info']);
-//        unset($goods_detail['xianshi_info']);
+        //unset($goods_detail['xianshi_info']);
 
         return $goods_detail;
     }
 
+    /**
+     * 解析spec字段
+     *
+     * @param $spec_name
+     * @param $spec_value
+     * @param array $spec_image
+     * @param array $spec_list
+     * @return array
+     */
     private function _parse_spec($spec_name, $spec_value, $spec_image = [], $spec_list = [])
     {
         $spec = [];
@@ -471,6 +471,12 @@ class goodsControl extends mobileHomeControl
         return $spec;
     }
 
+    /**
+     * 解析商品属性字段
+     *
+     * @param $goods_attr
+     * @return array
+     */
     private function _parse_attributes($goods_attr)
     {
         $attributes = [];
@@ -495,14 +501,17 @@ class goodsControl extends mobileHomeControl
         return $attributes;
     }
 
-    // 从 attribute 中取得功效
+    /**
+     * 解析功效
+     *
+     * @param $goods_attr
+     * @return mixed
+     */
     private function _parse_for_efficacy($goods_attr)
     {
         foreach ($goods_attr as $key => $val) {
-
             $attr_item['goods_attr_id'] = intval($key);
             $attr_item['goods_attr_name'] = $val['name'];
-
             if ($attr_item['goods_attr_name'] === '功效') {
                 $goods_attr_value = array();
                 foreach ($val as $id => $name) {
@@ -513,13 +522,18 @@ class goodsControl extends mobileHomeControl
                     }
                 }
                 $attr_item['goods_attr_value'] = $goods_attr_value;
-
                 break;
             }
         }
         return $attr_item;
     }
 
+    /**
+     * 商品规格序列化解析
+     *
+     * @param $goods_spec
+     * @return array
+     */
     private function _parse_goods_spec($goods_spec)
     {
         $goods_spec_obj = [];
@@ -533,12 +547,13 @@ class goodsControl extends mobileHomeControl
     }
 
     /**
-     * 商品详细页
+     * 商品详细页(未启用)
      */
     public function goods_bodyOp()
     {
-        $goods_id = intval($_GET ['goods_id']);
+        return joutput_error(errcode::ErrProtocolDisabled);
 
+        $goods_id = intval($_GET ['goods_id']);
         $out_type = $_GET ['type'];
         $model_goods = Model('goods');
 
@@ -564,102 +579,30 @@ class goodsControl extends mobileHomeControl
     }
 
     /**
-     * 手机商品详细页
-     *
+     * 获取detail(未启用)
      */
-    public function wap_goods_bodyOp()
-    {
-        $goods_id = intval($_GET ['goods_id']);
-
-        $model_goods = Model('goods');
-
-        $goods_info = $model_goods->getGoodsInfoByID($goods_id, 'goods_id');
-        $goods_common_info = $model_goods->getMobileBodyByCommonID($goods_info['goods_commonid']);
-        Tpl:
-        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) {
-
-        }
-    }
-
     public function detailOp()
     {
+        return joutput_error(errcode::ErrProtocolDisabled);
+
         $goods_id = intval($_GET['goods_id']);
-        if(empty($_GET['goods_id']) || $goods_id <= 0)
-        {
-            if(!empty($_GET['goods_commonid'])) {
+        if (empty($_GET['goods_id']) || $goods_id <= 0) {
+            if (!empty($_GET['goods_commonid'])) {
                 $commonid = intval($_GET['goods_commonid']);
             }
-        }
-        else
-        {
+        } else {
             $items = Model()->table('goods')->field('goods_commonid')->where(array('goods_id' => $goods_id))->limit(1)->select();
-            if(!empty($items) && count($items) > 0) {
+            if (!empty($items) && count($items) > 0) {
                 $commonid = intval($items[0]['goods_commonid']);
             }
         }
 
-
-        if(isset($commonid) && $commonid > 0)
-        {
+        if (isset($commonid) && $commonid > 0) {
             $items = Model()->table('goods_common')->field('goods_body')->where(array('goods_commonid' => $commonid))->select();
-            if(!empty($items) && count($items) > 0) {
-                Tpl::output('goods_body',$items[0]['goods_body']);
+            if (!empty($items) && count($items) > 0) {
+                Tpl::output('goods_body', $items[0]['goods_body']);
             }
         }
-
         Tpl::showpage('goods_detail');
     }
 }

+ 2 - 2
mobile/control/index.php

@@ -112,7 +112,7 @@ class indexControl extends mobileHomeControl
             $ret = array();
             foreach ($tops as $id => $val) {
                 $item['id'] = $id;
-//                $item['image'] = UPLOAD_SITE_URL. DS.substr($val['img_name'],0,-4);
+                //$item['image'] = UPLOAD_SITE_URL. DS.substr($val['img_name'],0,-4);
                 $item['image'] = UPLOAD_SITE_URL . DS . $val['img_name'];
                 $item['title'] = $val['recommend']['name'];
                 $goods_list = $val['goods_list'];
@@ -153,7 +153,7 @@ class indexControl extends mobileHomeControl
                 $item['id'] = $id;
                 $img = $val['img_name'];
                 if (!empty($img)) {
-//                    $item['image'] = UPLOAD_SITE_URL. DS. substr($img,0,-4);
+                    //$item['image'] = UPLOAD_SITE_URL. DS. substr($img,0,-4);
                     $item['image'] = UPLOAD_SITE_URL . DS . $img;
                     $item['title'] = $val['recommend']['name'];
                     array_push($ret, $item);

+ 58 - 53
mobile/control/member_address.php

@@ -15,16 +15,18 @@ class member_addressControl extends mobileMemberControl
 {
     const MAX_ADDRESS_COUNT = 10;
 
-	public function __construct() {
-		parent::__construct();
-	}
+    public function __construct()
+    {
+        parent::__construct();
+    }
 
     /**
      * 地址列表
      */
-    public function address_listOp() {
-		$model_address = Model('address');
-        $address_list = $model_address->getAddressList(array('member_id'=>$this->member_info['member_id']));
+    public function address_listOp()
+    {
+        $model_address = Model('address');
+        $address_list = $model_address->getAddressList(array('member_id' => $this->member_info['member_id']));
         joutput_data(array('address_list' => $address_list));
     }
 
@@ -33,9 +35,9 @@ class member_addressControl extends mobileMemberControl
      */
     public function address_infoOp()
     {
-		$address_id = intval($_POST['address_id']);
+        $address_id = intval($_POST['address_id']);
 
-        if(empty($_POST['address_id']) || $address_id < 0) {
+        if (empty($_POST['address_id']) || $address_id < 0) {
             return joutput_error(errcode::ErrParamter, "address_id = {$address_id}. must > 0.");
         }
 
@@ -43,7 +45,7 @@ class member_addressControl extends mobileMemberControl
         $condition = array();
         $condition['address_id'] = $address_id;
         $address_info = $model_address->getAddressInfo($condition);
-        if(!empty($address_id) && $address_info['member_id'] == $this->member_info['member_id']) {
+        if (!empty($address_id) && $address_info['member_id'] == $this->member_info['member_id']) {
 //            joutput_data(array('address_info' => $address_info));
             joutput_data($address_info);
         } else {
@@ -54,24 +56,25 @@ class member_addressControl extends mobileMemberControl
     /**
      * 删除地址
      */
-    public function address_delOp() {
-		$address_id = intval($_POST['address_id']);
+    public function address_delOp()
+    {
+        $address_id = intval($_POST['address_id']);
 
-        if(empty($_POST['address_id']) || $address_id < 0) {
+        if (empty($_POST['address_id']) || $address_id < 0) {
             return joutput_error(errcode::ErrParamter, "address_id = {$address_id}. must > 0.");
         }
 
-		$model_address = Model('address');
+        $model_address = Model('address');
 
         $condition = array();
         $condition['address_id'] = $address_id;
         $condition['member_id'] = $this->member_info['member_id'];
         $model_address->delAddress($condition);
-        $default_address_info = $model_address->getDefaultAddressInfo(array('member_id'=>$this->member_info['member_id']));
-        if(intval($default_address_info['is_default']) === 0){
+        $default_address_info = $model_address->getDefaultAddressInfo(array('member_id' => $this->member_info['member_id']));
+        if (intval($default_address_info['is_default']) === 0) {
             $this->_set_default($default_address_info['address_id'], 1);
         }
-        joutput_data(array('result'=>'1'));
+        joutput_data(array('result' => '1'));
     }
 
     /**
@@ -82,36 +85,36 @@ class member_addressControl extends mobileMemberControl
         $model_address = Model('address');
 
         $err = '';
-        $address_info = $this->_address_valid($err,$err_code);
-        if($err != '') {
-            return joutput_error($err_code,$err);
+        $address_info = $this->_address_valid($err, $err_code);
+        if ($err != '') {
+            return joutput_error($err_code, $err);
         }
 
         $addr_acount = $model_address->field('count(*) as address_count')->where(array('member_id' => $this->member_info['member_id']))->select();
 
-        if(intval($addr_acount[0]['address_count']) >= self::MAX_ADDRESS_COUNT){
-            return joutput_error(errcode::ErrAddress,'地址数量已达上限');
+        if (intval($addr_acount[0]['address_count']) >= self::MAX_ADDRESS_COUNT) {
+            return joutput_error(errcode::ErrAddress, '地址数量已达上限');
         }
 
         $result = $model_address->addAddress($address_info);
-        if($result)
-        {
+        if ($result) {
             $address_count = $model_address->field('count(*) as address_count')->where(array('member_id' => $this->member_info['member_id']))->select();
-            if(!empty($address_count) && count($address_count) > 0 && intval($address_count[0]['address_count']) === 1){
+            if (!empty($address_count) && count($address_count) > 0 && intval($address_count[0]['address_count']) === 1) {
                 $this->_set_default($result, 1);
             }
             joutput_data(array('address_id' => $result));
         } else {
-            return joutput_error(errcode::ErrAddress,'保存失败');
+            return joutput_error(errcode::ErrAddress, '保存失败');
         }
     }
 
     /**
      * 编辑地址
      */
-    public function address_editOp() {
+    public function address_editOp()
+    {
         $address_id = intval($_POST['address_id']);
-        if(empty($_POST['address_id']) || $address_id < 0) {
+        if (empty($_POST['address_id']) || $address_id < 0) {
             return joutput_error(errcode::ErrParamter, "address_id = {$address_id}. must > 0.");
         }
 
@@ -120,12 +123,12 @@ class member_addressControl extends mobileMemberControl
         $address_info = $model_address->getOneAddress($address_id);
         if ($address_info['member_id'] != $this->member_info['member_id']) {
             return joutput_error(errcode::ErrAddress, '参数错误');
-        }else{
+        } else {
             $address_info = $this->_address_valid();
 
             $result = $model_address->editAddress($address_info, array('address_id' => $address_id));
-            if($result) {
-                joutput_data(array('result'=>'1'));
+            if ($result) {
+                joutput_data(array('result' => '1'));
             } else {
                 return joutput_error(errcode::ErrAddress, '保存失败');
             }
@@ -135,17 +138,17 @@ class member_addressControl extends mobileMemberControl
     /**
      * 验证地址数据
      */
-    private function _address_valid(&$err,&$errcode)
+    private function _address_valid(&$err, &$errcode)
     {
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(
-            array("input"=>$_POST["true_name"],"require"=>"true","message"=>'姓名不能为空'),
-            array("input"=>$_POST["area_info"],"require"=>"true","message"=>'地区不能为空'),
-            array("input"=>$_POST["address"],"require"=>"true","message"=>'地址不能为空'),
-            array("input"=>$_POST['tel_phone'].$_POST['mob_phone'],'require'=>'true','message'=>'联系方式不能为空')
+            array("input" => $_POST["true_name"], "require" => "true", "message" => '姓名不能为空'),
+            array("input" => $_POST["area_info"], "require" => "true", "message" => '地区不能为空'),
+            array("input" => $_POST["address"], "require" => "true", "message" => '地址不能为空'),
+            array("input" => $_POST['tel_phone'] . $_POST['mob_phone'], 'require' => 'true', 'message' => '联系方式不能为空')
         );
         $err = $obj_validate->validate();
-        if ($err != ''){
+        if ($err != '') {
             $errcode = errcode::ErrAddress;
             return NULL;
         }
@@ -176,47 +179,48 @@ class member_addressControl extends mobileMemberControl
         $address_info = $model_address->getOneAddress($address_id);
         if ($address_info['member_id'] != $this->member_info['member_id']) {
             return joutput_error(errcode::ErrAddress, '参数错误');
-        }else{
-            if($this->_set_default($address_id, $is_default)){
-                joutput_data(array('result'=>'1'));
+        } else {
+            if ($this->_set_default($address_id, $is_default)) {
+                joutput_data(array('result' => '1'));
             }
         }
     }
 
-    private function _set_default($address_id, $is_default){
+    private function _set_default($address_id, $is_default)
+    {
         $member_id = $this->member_info['member_id'];
         $model_address = Model('address');
-        if($is_default === 1){
-            if($model_address->where(array('member_id' => $member_id))->update(array('is_default' => '0'))){
+        if ($is_default === 1) {
+            if ($model_address->where(array('member_id' => $member_id))->update(array('is_default' => '0'))) {
                 $result = $model_address->where(array('address_id' => $address_id))->update(array('is_default' => '1'));
-            }else{
+            } else {
                 return joutput_error(errcode::ErrAddress, '保存失败');
             }
         } else {
             $result = $model_address->where(array('address_id' => $address_id))->update(array('is_default' => '0'));
         }
 
-        if($result) {
+        if ($result) {
             return $result;
         } else {
             return joutput_error(errcode::ErrAddress, '保存失败');
         }
-
     }
 
     /**
      * 地区列表
      */
-    public function area_listOp() {
+    public function area_listOp()
+    {
         $area_id = intval($_POST['area_id']);
         $from = $_POST['from'];
-        if($from === 'app'){
+        if ($from === 'app') {
             $area_list = $this->_get_area_list($area_id);
-        }else{
+        } else {
             $model_area = Model('area');
 
             $condition = array();
-            if($area_id > 0) {
+            if ($area_id > 0) {
                 $condition['area_parent_id'] = $area_id;
             } else {
                 $condition['area_deep'] = 1;
@@ -226,19 +230,20 @@ class member_addressControl extends mobileMemberControl
         joutput_data(array('area_list' => $area_list));
     }
 
-    private function _get_area_list($area_id){
+    private function _get_area_list($area_id)
+    {
         $model_area = Model('area');
 
         $condition = array();
-        if($area_id > 0) {
+        if ($area_id > 0) {
             $condition['area_parent_id'] = $area_id;
         } else {
             $condition['area_deep'] = 1;
         }
         $area_list = $model_area->getAreaList($condition, 'area_id,area_name');
-        foreach($area_list as $k => $area){
+        foreach ($area_list as $k => $area) {
             $area_list_by_id = $this->_get_area_list($area['area_id']);
-            if(count($area_list_by_id) > 0){
+            if (count($area_list_by_id) > 0) {
                 $area_list[$k]['area_list'] = $area_list_by_id;
             }
         }

+ 22 - 26
mobile/control/member_info.php

@@ -1,77 +1,74 @@
 <?php
 /**
- * 红包管理
- *
- *
- *
+ * 获取用户信息
  ***/
 defined('InShopNC') or exit('Access Invalid!');
 
-class member_infoControl extends mobileMemberExControl
+class member_infoControl extends mbMemberControl
 {
     public function __construct()
     {
         parent::__construct();
     }
 
+    /**
+     * 获取用户信息
+     *
+     * 输入参数:
+     * key: token
+     */
     public function getinfoOp()
     {
         $token = $_GET['key'];
-
         if (empty($token)) {
-            return joutput_error(errcode::ErrInputParam, '输入参数有误');
+            return joutput_error(errcode::ErrInputParam);
         }
-
         if ($this->checkToken($token) != errcode::Success) {
-            return joutput_error($this->err_code, errcode::msg($this->err_code));
+            return joutput_error($this->err_code);
         }
-
         $member_id = $this->member_info['member_id'];
-
         $model = Model('member');
         $member_info = $model->getMemberInfoByID($member_id, 'member_name,member_sex');
 
         $ret = array();
         if (!empty($member_info)) {
-
             $ret['member_name'] = $member_info['member_name'];
-
-            if(empty($member_info['member_name'])){
+            if (empty($member_info['member_name'])) {
                 $ret['member_name'] = '新用户';
             }
-
             if ($member_info['member_sex'] == 1) {
                 $ret['member_sex'] = '1';
             } else {
                 $ret['member_sex'] = '0';
             }
         }
-
         joutput_data($ret);
     }
 
+    /**
+     * 更新用户信息
+     *
+     * 输入:
+     * key token
+     * member_name 用户名
+     * member_sex 用户性别
+     */
     public function updateinfoOp()
     {
         $member_name = urldecode($_GET['member_name']);
         $member_sex = urldecode($_GET['member_sex']);
-
         if (empty($member_name) && empty($member_sex)) {
-            return joutput_error(errcode::ErrInputParam, '输入参数有误');
+            return joutput_error(errcode::ErrInputParam);
         }
-
         $token = $_GET['key'];
         if ($this->checkToken($token) != errcode::Success) {
-            return joutput_error($this->err_code, errcode::msg($this->err_code));
+            return joutput_error($this->err_code);
         }
-
         $member_id = $this->member_info['member_id'];
-
         $condition = array('member_id' => $member_id);
         $updateinfo = array('member_name' => $member_name, 'member_sex' => $member_sex);
-
         $ret = Model('member')->where($condition)->update($updateinfo);
-
-        dcache($member_id,'member');
+        dcache($member_id, 'member');
 
         $result = array();
         if ($ret) {
@@ -79,7 +76,6 @@ class member_infoControl extends mobileMemberExControl
         } else {
             $result['ret'] = 1;
         }
-
         joutput_data($result);
     }
 }

+ 70 - 11
mobile/control/member_login.php

@@ -24,7 +24,12 @@ class member_loginControl extends mbMemberControl
         parent::__construct();
     }
 
-    // 获取验证码
+    /**
+     * 获取验证码
+     *
+     * 输入参数:
+     * mobile: 手机号
+     */
     public function getacodeOp()
     {
         $mobile = trim($_POST['mobile']);
@@ -46,7 +51,14 @@ class member_loginControl extends mbMemberControl
         joutput_data(NULL);
     }
 
-    // 注册
+    /**
+     * 用户注册
+     *
+     * 输入参数:
+     * mobile:手机号
+     * code: 验证码
+     * passwd: 密码
+     */
     public function registerOp()
     {
         $mobile = trim($_GET['mobile']);
@@ -85,7 +97,15 @@ class member_loginControl extends mbMemberControl
         joutput_data(null);
     }
 
-    // 登陆
+    /**
+     * 用户登陆
+     *
+     * 输入参数:
+     * type: 手机登陆:0 微信登陆:1
+     * client: android ios
+     * passwd: 密码
+     * openid: 微信id
+     */
     public function loginOp()
     {
         $login_type = trim($_GET['type']);
@@ -140,11 +160,18 @@ class member_loginControl extends mbMemberControl
         }
     }
 
-    // 微信绑定账号
+    /**
+     * 微信绑定
+     *
+     * 输入参数:
+     * wx_openid 微信id
+     * token:需要修改为token
+     * user_info: 用户信息
+     */
     public function bindOp()
     {
         $wx_openid = trim($_GET['wx_openid']);
-        $token = trim($_GET['token']);
+        $token = trim($_GET['key']);
         $user_info = trim($_GET['user_info']);
 
         $key = func::gen_token_key($token);
@@ -159,7 +186,14 @@ class member_loginControl extends mbMemberControl
         return joutput_data(null);
     }
 
-    // 修改密码(目前没有使用)
+    /**
+     * 修改密码
+     *
+     * 输入参数:
+     * mobile: 手机号
+     * oldpasswd: 原密码
+     * newpasswd: 新密码
+     */
     public function chpasswdOp()
     {
         $mobile = trim($_GET['mobile']);
@@ -176,7 +210,14 @@ class member_loginControl extends mbMemberControl
         return joutput_data(null);
     }
 
-    // 手机验证码找回密码
+    /**
+     * 找回密码
+     *
+     * 输入参数:
+     * mobile:
+     * code:验证码
+     * passwd: 密码
+     */
     public function getpasswdOp()
     {
         $mobile = trim($_GET['mobile']);
@@ -204,16 +245,30 @@ class member_loginControl extends mbMemberControl
         joutput_data(null);
     }
 
-    // 登出
+    /**
+     * 登出
+     *
+     * 输入参数:
+     * key:token
+     */
     public function logoutOp()
     {
-        $token = trim($_GET['token']);
+        $token = trim($_GET['key']);
+        $condition = array();
+        $condition['token'] = $token;
+        $model = Model('mb_user_token');
+        $model->delMbUserToken($token);
         $key = func::gen_token_key($token);
         dcache($key);
         joutput_data(null);
     }
 
-    // 验证校验码
+    /**
+     * 检验校验码
+     * @param $mobile: 手机号
+     * @param $acode:验证码
+     * @return bool
+     */
     public function checkacode($mobile, $acode)
     {
         $key = func::gen_auth_code_key($mobile);
@@ -228,7 +283,11 @@ class member_loginControl extends mbMemberControl
         }
     }
 
-    // 通过token获取信息
+    /**
+     * 获取token信息
+     *
+     * @return int|mixed
+     */
     public function getInfoByToken()
     {
         $token = trim($_GET['token']);

+ 51 - 49
mobile/control/member_payment.php

@@ -12,20 +12,23 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 
-class member_paymentControl extends mobileMemberControl {
+class member_paymentControl extends mobileMemberControl
+{
 
     private $payment_code = 'alipay';
 
-	public function __construct() {
-		parent::__construct();
-        $this->payment_code = isset($_GET['payment_code']) && trim($_GET['payment_code']) != '' ? trim($_GET['payment_code']) :'alipay';
-	}
+    public function __construct()
+    {
+        parent::__construct();
+        $this->payment_code = isset($_GET['payment_code']) && trim($_GET['payment_code']) != '' ? trim($_GET['payment_code']) : 'alipay';
+    }
 
     /**
      * 实物订单支付
      */
-    public function payOp() {
-	    $pay_sn = $_GET['pay_sn'];
+    public function payOp()
+    {
+        $pay_sn = $_GET['pay_sn'];
 
         $model_mb_payment = Model('mb_payment');
         $logic_payment = Logic('payment');
@@ -33,14 +36,13 @@ class member_paymentControl extends mobileMemberControl {
         $condition = array();
         $condition['payment_code'] = $this->payment_code;
         $mb_payment_info = $model_mb_payment->getMbPaymentOpenInfo($condition);
-        if(!$mb_payment_info) {
+        if (!$mb_payment_info) {
             output_error('系统不支持选定的支付方式');
         }
 
         //重新计算所需支付金额
         $result = $logic_payment->getRealOrderInfo($pay_sn, $this->member_info['member_id']);
-
-        if(!$result['state']) {
+        if (!$result['state']) {
             output_error($result['msg']);
         }
 
@@ -51,72 +53,72 @@ class member_paymentControl extends mobileMemberControl {
     /**
      * 虚拟订单支付
      */
-    public function vr_payOp() {
+    public function vr_payOp()
+    {
         $order_sn = $_GET['pay_sn'];
-    
+
         $model_mb_payment = Model('mb_payment');
         $logic_payment = Logic('payment');
-    
+
         $condition = array();
         $condition['payment_code'] = $this->payment_code;
         $mb_payment_info = $model_mb_payment->getMbPaymentOpenInfo($condition);
-        if(!$mb_payment_info) {
+        if (!$mb_payment_info) {
             output_error('系统不支持选定的支付方式');
         }
-    
+
         //重新计算所需支付金额
         $result = $logic_payment->getVrOrderInfo($order_sn, $this->member_info['member_id']);
-    
-        if(!$result['state']) {
+
+        if (!$result['state']) {
             output_error($result['msg']);
         }
-    
+
         //第三方API支付
         $this->_api_pay($result['data'], $mb_payment_info);
     }
 
-	/**
-	 * 第三方在线支付接口
-	 *
-	 */
-	private function _api_pay($order_pay_info, $mb_payment_info) {
-        $inc_file = BASE_PATH.DS.'api'.DS.'payment'.DS.$this->payment_code.DS.$this->payment_code.'.php';
-    	if(!is_file($inc_file)){
+    /**
+     * 第三方在线支付接口
+     *
+     */
+    private function _api_pay($order_pay_info, $mb_payment_info)
+    {
+        $inc_file = BASE_PATH . DS . 'api' . DS . 'payment' . DS . $this->payment_code . DS . $this->payment_code . '.php';
+        if (!is_file($inc_file)) {
             output_error('支付接口不存在');
-    	}
-		if($payment_info['payment_code'] == 'wxpay') {
-			$wxpayurl=BASE_SITE_URL.'/mobile/api/payment/wxpay/wxpay.php?pay_sn='.$order_pay_info['pay_sn'].'&pay_amount='.$order_pay_info['api_pay_amount'];
-    		redirect($wxpayurl);
-    		//@header("Location: ".ApiUrl.'/api/paymentpaypay.php?pay_sn='.$order_pay_info['pay_sn'].'&pay_amount='.$order_pay_info['api_pay_amount']);
-    	} else {
-			require($inc_file);
-			$param = array();
-			$param = $mb_payment_info['payment_config'];
-			$param['order_sn'] = $order_pay_info['pay_sn'];
-			$param['order_amount'] = $order_pay_info['api_pay_amount'];
-			$param['order_type'] = ($order_pay_info['order_type'] == 'real_order' ? 'r' : 'v');
-			$payment_api = new $this->payment_code();
-			$return = $payment_api->submit($param);
-			echo $return;
-    	}
-    	exit();
-	}
+        }
+        if ($payment_info['payment_code'] == 'wxpay') {
+            $wxpayurl = BASE_SITE_URL . '/mobile/api/payment/wxpay/wxpay.php?pay_sn=' . $order_pay_info['pay_sn'] . '&pay_amount=' . $order_pay_info['api_pay_amount'];
+            redirect($wxpayurl);
+            //@header("Location: ".ApiUrl.'/api/paymentpaypay.php?pay_sn='.$order_pay_info['pay_sn'].'&pay_amount='.$order_pay_info['api_pay_amount']);
+        } else {
+            require($inc_file);
+            $param = array();
+            $param = $mb_payment_info['payment_config'];
+            $param['order_sn'] = $order_pay_info['pay_sn'];
+            $param['order_amount'] = $order_pay_info['api_pay_amount'];
+            $param['order_type'] = ($order_pay_info['order_type'] == 'real_order' ? 'r' : 'v');
+            $payment_api = new $this->payment_code();
+            $return = $payment_api->submit($param);
+            echo $return;
+        }
+        exit();
+    }
 
     /**
-     * 可用支付参数列表
+     * 获取可用参数列表
      */
-    public function payment_listOp() {
+    public function payment_listOp()
+    {
         $model_mb_payment = Model('mb_payment');
-
         $payment_list = $model_mb_payment->getMbPaymentOpenList();
-
         $payment_array = array();
-        if(!empty($payment_list)) {
+        if (!empty($payment_list)) {
             foreach ($payment_list as $value) {
                 $payment_array[] = $value['payment_code'];
             }
         }
-
         output_data(array('payment_list' => $payment_array));
     }
 }

+ 1 - 1
mobile/control/member_voucher.php

@@ -19,7 +19,7 @@ class member_voucherControl extends mobileMemberControl {
 	}
 
     /**
-     * 地址列表
+     * 代金券列表
      */
     public function voucher_listOp() {
 		$model_voucher = Model('voucher');

+ 0 - 1
mobile/control/payment.php

@@ -33,7 +33,6 @@ class paymentControl extends mobileHomeControl{
 
     }
 
-
     /**
      * 支付回调
      */

+ 0 - 1
mobile/control/shop.php

@@ -21,7 +21,6 @@ class shopControl extends mobileHomeControl {
         $this->_get_Own_Store_List();
     }
 
-
     private  function  _get_Own_Store_List(){
 
         //获取自营店列表

+ 13 - 20
mobile/control/type.php

@@ -16,72 +16,65 @@ class typeControl extends mobileHomeControl
         parent::__construct();
     }
 
+    /**
+     * 关键字获取类型
+     * 输入参数:
+     * id: 需要返回
+     * keyword: 关键字
+     */
     public function searchOp()
     {
         $id = $_GET['id'];
-
         if (!empty($_GET['keyword'])) {
-
             $keyword = urldecode($_GET['keyword']);
-
             $gc_1 = Model()->table('goods_class')->where(array('gc_name' => array('like', '%' . $keyword . '%')))->limit(1)->select();
-
             $goods_class = array();
             if (!empty($gc_1)) {
-
                 $gc_2 = Model()->table('goods_class')->where(array('gc_parent_id' => $gc_1[0]['gc_id']))->select();
                 foreach ($gc_2 as $value) {
-
                     $gc_item_2['gc_id'] = $value['gc_id'];
                     $gc_item_2['gc_name'] = $value['gc_name'];
-
                     $gc_3 = Model()->table('goods_class')->where(array('gc_parent_id' => $value['gc_id']))->select();
                     if (!empty($gc_3)) {
-
                         $gc_3_array = array();
                         foreach ($gc_3 as $item) {
-
                             $gc_3_item['gc_id'] = $item['gc_id'];
                             $gc_3_item['gc_name'] = $item['gc_name'];
                             $gc_3_item['type_id'] = $item['type_id'];
-
                             array_push($gc_3_array, $gc_3_item);
                         }
-
                         $gc_item_2['data'] = $gc_3_array;
                         array_push($goods_class, $gc_item_2);
                     }
                 }
             }
             joutput_data(array("data" => $goods_class, "id" => $id));
-
         } else {
             return joutput_error(1001, "keyword is must!");
         }
     }
 
+    /**
+     * 通过gc_id获取类型
+     * 输入参数:
+     * id: 需要传回参数
+     * gc_id: 用户组类型
+     */
     public function typeBygcidOp()
     {
         $id = $_GET['id'];
         $gc_id = $_GET['gc_id'];
-
         if (!empty($gc_id)) {
-
             $gc_2 = Model()->table('goods_class')->where(array('gc_parent_id' => $gc_id))->select();
-
             $gc_2_array = array();
             foreach ($gc_2 as $value) {
-
                 $gc_item_2['gc_id'] = $value['gc_id'];
                 $gc_item_2['gc_name'] = $value['gc_name'];
-
-                array_push($gc_2_array,$gc_item_2);
+                array_push($gc_2_array, $gc_item_2);
             }
             joutput_data(array("data" => $gc_2_array, "id" => $id));
-
         } else {
             return joutput_error(1001, "gc_id is must!");
         }
     }
-
 }

+ 14 - 0
mobile/util/errcode.php

@@ -6,6 +6,8 @@ class errcode extends SplEnum
     
     const Success = 200;
 
+    const ErrProtocolDisabled      = 300;
+
     const ErrApptype  = 10000;
     const ErrParamter = 10001;
     const ErrLogin    = 10002;
@@ -21,11 +23,19 @@ class errcode extends SplEnum
 
     const ErrSpecial  = 10100;
     const ErrCart  = 10200;
+
+    // 订单错误内容
     const ErrOrder  = 10300;
+    const ErrOrderCanNotCancel  = 10301;
+    const ErrOrderNotExist  = 10301;
     const ErrAddress  = 10400;
     const ErrInvoice  = 10500;
     const ErrPayment = 10600;
 
+    // 快递内容
+    const ErrExpress = 10700;
+    const ErrExpressNotExist = 10701;
+
     const ErrDB      = 11000;
     const ErrSms 	 = 12000;
 
@@ -42,6 +52,7 @@ class errcode extends SplEnum
     {
         switch ($code) {
             case errcode::Success: return 'Success';
+            case errcode::ErrProtocolDisabled: return 'ErrProtocolDisabled';
             case errcode::ErrApptype : return 'ErrApptype';
             case errcode::ErrLogin : return 'ErrLogin error password or phone';
             case errcode::ErrGenuser : return 'ErrGenuser';
@@ -60,6 +71,9 @@ class errcode extends SplEnum
             case errcode::ErrPasswd: return '密码错误';
             case errcode::ErrWxNotExist: return '微信账号不存在';
             case errcode::ErrLoginType: return '登陆类型错误';
+            case errcode::ErrOrderCanNotCancel: return '订单已支付或已发送,不能取消';
+            case errcode::ErrOrderNotExist: return '订单不存在';
+            case errcode::ErrExpress: return '查询快递出错';
 
             case errcode::ErrDB : return 'ErrorDB';
             case errcode::ErrSms : return 'ErrSms,Send sms error.';

+ 91 - 23
shop/control/h5_hb.php

@@ -1,6 +1,6 @@
 <?php
 /**
- *
+ * Ʒ�ƻ�ȡ
  */
 
 
@@ -11,7 +11,9 @@ class h5_hbControl extends BaseH5Control
     const home_url = SHOP_SITE_URL . "/index.php";
     const code_expire = 5; // 验证码获取时间
 
-
+    /**
+     * 首页-获取红包
+     */
     public function modeOp()
     {
         $type_id = $_GET['type_id'];
@@ -28,6 +30,71 @@ class h5_hbControl extends BaseH5Control
         }
     }
 
+    /**
+     * 添加减少冻结恢复余额(带参数)
+     */
+    private function _add_money_ex($member_id, $pointsnum, $order_sn, $pointsdesc, $operatetype){
+        
+            $obj_validate = new Validate();
+            $obj_validate->validateparam = array(
+                array("input"=>$member_id, "require"=>"true", "message"=>Language::get('admin_points_member_error_again')),
+                array("input"=>$pointsnum, "require"=>"true",'validator'=>'Compare','operator'=>' >= ','to'=>1,"message"=>Language::get('admin_points_points_min_error'))
+            );
+            $error = $obj_validate->validate();
+            if ($error != ''){
+                return -1;
+            }
+            
+            $money = abs(floatval($pointsnum));
+            $memo=trim($pointsdesc);
+            if ($money <= 0) {
+                return -2;  // 输入的金额必需大于0
+            }
+            //查询会员信息
+            $obj_member = Model('member');
+            $member_id = intval($member_id);
+            $member_info = $obj_member->getMemberInfo(array('member_id'=>$member_id));
+
+            if (!is_array($member_info) || count($member_info)<=0){
+                return -3;  // 用户信息不对
+            }
+            $available_predeposit=floatval($member_info['available_predeposit']);
+            $freeze_predeposit=floatval($member_info['freeze_predeposit']);
+            if ($operatetype == 2 && $money > $available_predeposit){
+                return -4; // 预存款不足,会员当前预存款
+            }
+            if ($operatetype == 3 && $money > $available_predeposit){
+                return -5; // 可冻结预存款不足,会员当前预存款
+            }
+            if ($operatetype == 4 && $money > $freeze_predeposit){
+                return -6; // 可恢复冻结预存款不足,会员当前冻结预存款
+            }
+            $model_pd = Model('predeposit');
+            //$order_sn = $model_pd->makeSn();  // ??? 技术债务
+           
+            try {
+                //$model_pd->beginTransaction();
+                //扣除冻结的预存款
+                $data = array();
+                $data['member_id'] = $member_info['member_id'];
+                $data['member_name'] = $member_info['member_name'];
+                $data['amount'] = $money;
+                $data['order_sn'] = $order_sn;
+                $data['admin_name'] = $admininfo['name'];
+                $data['pdr_sn'] = $order_sn;
+                $data['lg_desc'] = $memo;
+                $model_pd->changePd($admin_act,$data);
+                //$model_pd->commit();
+                return 0; // 操作成功
+            } catch (Exception $e) {
+                //$model_pd->rollback();
+                return -7;  // 操作异常
+            }
+    }
+
+    /**
+     * 绑定手机号
+     */
     public function bindtelOp()
     {
         $type_id = $_GET['type_id'];
@@ -39,9 +106,6 @@ class h5_hbControl extends BaseH5Control
         Tpl::showpage('mode', 'h5_hb/bindtel');
     }
 
-    /**
-     * 获取验证码
-     */
     public function getVerifyCodeOp()
     {
         $mobile = trim($_POST['phone_num']);
@@ -94,7 +158,6 @@ class h5_hbControl extends BaseH5Control
     public function getOneBonus($type_id, $phone_num)
     {
         try {
-
             Model::beginTransaction();
             // 查找一条记录
             $condition['status'] = 0;
@@ -102,26 +165,31 @@ class h5_hbControl extends BaseH5Control
 
             // 此时记得加载lock
             $result = Model()->table('user_bonus')->where($condition)->limit(1)->lock(true)->order('bonus_id asc')->select();
+            if (empty($result)) {
+                 Model::rollback();
+                    return null;
+            }
 
-            if (!empty($result)) {
-
-                // 更新掉
-                $cond2['bonus_id'] = $result[0]['bonus_id'];
-                $update_info['get_time'] = time();
-                $update_info['user_mobile'] = $phone_num;
-                $update_info['status'] = 1;
-                $ret = Model()->table('user_bonus')->where($cond2)->update($update_info);
-
-                if ($ret) {
-                    Model::commit();
-                    $return_value['bonus_value'] = $result[0]['bonus_value'];
-                    return $return_value;
-                } else {
-                    Model::rollback();
-                }
-            } else {
+            // 添加预存款
+            $ret = $this->_add_money_ex($update_info["user_id"], $result[0]['bonus_value'], $result[0]["bonus_sn"], "");
+            if (0 != $ret) {
+                Model::rollback();
+                return null;
+            }
+            
+            // 更新掉
+            $cond2['bonus_id'] = $result[0]['bonus_id'];
+            $update_info['get_time'] = time();
+            $update_info['user_mobile'] = $phone_num;
+            $update_info['status'] = 1;
+            $ret = Model()->table('user_bonus')->where($cond2)->update($update_info);
+            if (0 == $ret) {
                 Model::rollback();
+                return null;
             }
+            Model::commit();
+            $return_value['bonus_value'] = $result[0]['bonus_value'];
+            return $return_value;
         } catch (Exception $e) {
             Model::rollback();
         }

+ 1 - 1
shop/templates/default/h5_hb/mode.php

@@ -16,7 +16,7 @@
                 <p>送了你一个熊猫美妆红包</p>
             </div>
             <div class="bag_center center">
-                <a href=<?php echo("http://192.168.1.136/h5_hb/bindtel.php") ?> class="just_btn inline center font17">立即领取</a>
+                <a href=<?php echo("") ?> class="just_btn inline center font17">立即领取</a>
             </div>
         </div>
         <div class="footer"></div>