root 9 lat temu
rodzic
commit
8d2eec2a38

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

@@ -6,7 +6,7 @@
  *
  * @package    core* www.abc.com 专业团队 提供售后服务
  */
-class Model 
+class Model
 {
 	protected $name = '';
 	protected $table_prefix = '';

+ 6 - 8
mobile/control/brand.php

@@ -8,7 +8,8 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class brandControl extends mobileHomeControl
 {
-    public function __construct() {
+    public function __construct()
+    {
         parent::__construct();
     }
 
@@ -22,13 +23,10 @@ class brandControl extends mobileHomeControl
         $brand_c_list = $model->table('brand')->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
 
         $brands = array();
-        foreach ($brand_area_list as $brand_area)
-        {
-            foreach ($brand_c_list as $brand)
-            {
+        foreach ($brand_area_list as $brand_area) {
+            foreach ($brand_c_list as $brand) {
                 $brand['brand_pic'] = $this->_formatBrandPic($brand['brand_pic']);
-                if ($brand['brand_area_id'] == $brand_area['area_id'])
-                {
+                if ($brand['brand_area_id'] == $brand_area['area_id']) {
                     if (empty($brand_area['data'])) {
                         $brand_area['data'] = array();
                     }
@@ -50,6 +48,6 @@ class brandControl extends mobileHomeControl
      */
     private function _formatBrandPic($filename)
     {
-        return UPLOAD_SITE_URL . '/shop/brand/' . 'rect_'.$filename;
+        return UPLOAD_SITE_URL . '/shop/brand/' . 'rect_' . $filename;
     }
 }

+ 43 - 0
mobile/control/control.php

@@ -109,4 +109,47 @@ class mobileMemberExControl extends mobileControl
 
         return true;
     }
+}
+
+
+/**
+ * Class mbMemberControl
+ */
+class mbMemberControl extends mobileControl
+{
+    protected $member_info = array();
+
+    public $err_code = errcode::Success;
+
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    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;
+        }
+
+        // 读取买家信息
+        $model_member = Model('member');
+        $this->member_info = $model_member->getMemberInfoByID($mb_user_token_info['member_id']);
+        $this->member_info['client_type'] = $mb_user_token_info['client_type'];
+        if (empty($this->member_info)) {
+            $this->err_code = errcode::ErrMemberNotExist;
+            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;
+    }
 }

+ 21 - 31
mobile/control/login.php

@@ -246,25 +246,20 @@ class loginControl extends mobileHomeControl
 
         $model = Model('member');
         $ret = $model->where(array('member_mobile' => $mobile))->find();
-        if(!empty($ret)) {
+        if (!empty($ret)) {
             return joutput_error(errcode::ErrUserExisted, "用户已经存在.");
-        }
-        else
-        {
+        } else {
             $key = self::gen_mobile_code($mobile);
             $ret = rcache($key, 'member');
-            if (!empty($ret) && $ret['code'] == $code)
-            {
-                $success = $model->insert(array('member_mobile' => $mobile,'member_type' => 0,'member_passwd' => md5($password)));
-                if($success) {
+            if (!empty($ret) && $ret['code'] == $code) {
+                $success = $model->insert(array('member_mobile' => $mobile, 'member_type' => 0, 'member_passwd' => md5($password)));
+                if ($success) {
                     return joutput_data(NULL);
                 } else {
-                    return joutput_error(errcode::ErrDB,"DB error.");
+                    return joutput_error(errcode::ErrDB, "DB error.");
                 }
-            }
-            else
-            {
-                return joutput_error(errcode::ErrSmscode,"错误的验证码.");
+            } else {
+                return joutput_error(errcode::ErrSmscode, "错误的验证码.");
             }
         }
     }
@@ -286,27 +281,22 @@ class loginControl extends mobileHomeControl
 
         $model = Model('member');
         $member_info = $model->where(array('member_mobile' => $mobile))->find();
-        if(empty($member_info) || count($member_info) == 0) {
+        if (empty($member_info) || count($member_info) == 0) {
             return joutput_error(errcode::ErrUserExisted, "用户不存在.");
-        }
-        else
-        {
+        } else {
             $key = self::gen_mobile_code($mobile);
             $ret = rcache($key, 'member');
-            if (!empty($ret) && $ret['code'] == $code)
-            {
-                $success = $model->where(array('member_mobile' => $mobile))->update(array('member_type' => 0,'member_passwd' => md5($password)));
-                if($success) {
+            if (!empty($ret) && $ret['code'] == $code) {
+                $success = $model->where(array('member_mobile' => $mobile))->update(array('member_type' => 0, 'member_passwd' => md5($password)));
+                if ($success) {
                     $key = $this->gen_openid_uid($mobile, 0);
                     dcache($key, 'member');
                     return joutput_data(NULL);
                 } else {
-                    return joutput_error(errcode::ErrDB,"DB error.");
+                    return joutput_error(errcode::ErrDB, "DB error.");
                 }
-            }
-            else
-            {
-                return joutput_error(errcode::ErrSmscode,"错误的验证码.");
+            } else {
+                return joutput_error(errcode::ErrSmscode, "错误的验证码.");
             }
         }
     }
@@ -383,7 +373,7 @@ class loginControl extends mobileHomeControl
 
     public function getcodeOp()
     {
-        static $types = array('register','resetpass','getbonus');
+        static $types = array('register', 'resetpass', 'getbonus');
 
         $mobile = trim($_POST['mobile']);
         $type = trim($_POST['type']);
@@ -394,15 +384,15 @@ class loginControl extends mobileHomeControl
         if ($err != '') {
             return joutput_error(errcode::ErrParamter, $err);
         }
-        if(!in_array($type,$types)) {
+        if (!in_array($type, $types)) {
             return joutput_error(errcode::ErrParamter, "错误的类型参数: type={$type}");
         }
 
-        if($type == 'register') {
+        if ($type == 'register') {
             $itype = Sms::register_code;
-        } elseif($type == 'resetpass') {
+        } elseif ($type == 'resetpass') {
             $itype = Sms::resetpass_code;
-        } elseif($type == 'getbonus') {
+        } elseif ($type == 'getbonus') {
             $itype = Sms::bonus_code;
         }
 

+ 86 - 94
mobile/control/member_cart.php

@@ -5,7 +5,7 @@
  *
  *
  *
- 
+
  */
 
 //use Shopnc\Tpl;
@@ -14,32 +14,33 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class member_cartControl extends mobileMemberControl
 {
-	public function __construct() {
-		parent::__construct();
-	}
+    public function __construct()
+    {
+        parent::__construct();
+    }
 
     /**
      * 购物车列表
      */
-    public function cart_listOp() {
+    public function cart_listOp()
+    {
         $model_cart = Model('cart');
         $model_goods = Model('goods');
 
         $condition = array('buyer_id' => $this->member_info['member_id']);
-        $cart_list	= $model_cart->listCart('db', $condition);
+        $cart_list = $model_cart->listCart('db', $condition);
         $sum = 0;
-        foreach ($cart_list as $key => $value)
-        {
+        foreach ($cart_list as $key => $value) {
             $goods_id = $value['goods_id'];
             $goods_promotion = $model_goods->getGoodsInfoAndPromotionById($goods_id);
             $goods_storage = $model_goods->getGoodsStorageById($goods_id);
             $promotion_type = '';
             $promotion_price = '0.00';
-            if(!empty( $goods_promotion['groupbuy_info'])){
+            if (!empty($goods_promotion['groupbuy_info'])) {
                 $promotion_type = '抢购';
                 $promotion_price = $goods_promotion['groupbuy_info']['groupbuy_price'];
             }
-            if(!empty( $goods_promotion['xianshi_info'])){
+            if (!empty($goods_promotion['xianshi_info'])) {
                 $promotion_type = '限时折扣';
                 $promotion_price = $goods_promotion['xianshi_info']['xianshi_price'];
             }
@@ -69,45 +70,45 @@ class member_cartControl extends mobileMemberControl
     {
         $goods_id = intval($_POST['goods_id']);
         $quantity = intval($_POST['quantity']);
-        if($goods_id <= 0 || $quantity <= 0) {
+        if ($goods_id <= 0 || $quantity <= 0) {
             return joutput_error(errcode::ErrCart, '参数错误');
         }
 
         $model_goods = Model('goods');
-        $model_cart	= Model('cart');
+        $model_cart = Model('cart');
         $logic_buy_1 = Logic('buy_1');
 
         $goods_info = $model_goods->getGoodsOnlineInfoAndPromotionById($goods_id);
 
         //验证是否可以购买
-		if(empty($goods_info)) {
+        if (empty($goods_info)) {
             return joutput_error(errcode::ErrCart, '商品已下架或不存在');
-		}
+        }
 
-		//抢购
-		$logic_buy_1->getGroupbuyInfo($goods_info);
-		
-		//限时折扣
-		$logic_buy_1->getXianshiInfo($goods_info,$quantity);
+        //抢购
+        $logic_buy_1->getGroupbuyInfo($goods_info);
+
+        //限时折扣
+        $logic_buy_1->getXianshiInfo($goods_info, $quantity);
 
         if ($goods_info['store_id'] == $this->member_info['store_id']) {
             return joutput_error(errcode::ErrCart, '不能购买自己发布的商品');
-		}
-		if(intval($goods_info['goods_storage']) < 1 || intval($goods_info['goods_storage']) < $quantity) {
+        }
+        if (intval($goods_info['goods_storage']) < 1 || intval($goods_info['goods_storage']) < $quantity) {
             return joutput_error(errcode::ErrCart, '库存不足');
-		}
+        }
 
         $param = array();
-        $param['buyer_id']	= $this->member_info['member_id'];
-        $param['store_id']	= $goods_info['store_id'];
-        $param['goods_id']	= $goods_info['goods_id'];
+        $param['buyer_id'] = $this->member_info['member_id'];
+        $param['store_id'] = $goods_info['store_id'];
+        $param['goods_id'] = $goods_info['goods_id'];
         $param['goods_name'] = $goods_info['goods_name'];
         $param['goods_price'] = $goods_info['goods_price'];
         $param['goods_image'] = $goods_info['goods_image'];
         $param['store_name'] = $goods_info['store_name'];
 
         $result = $model_cart->addCart($param, 'db', $quantity);
-        if($result) {
+        if ($result) {
             joutput_data(array('result' => '1'));
         } else {
             return joutput_error(errcode::ErrCart, '添加购物车失败!');
@@ -117,11 +118,9 @@ class member_cartControl extends mobileMemberControl
     public function cart_editOp()
     {
         $cart_list = explode(',', urldecode($_POST['cart_list']));
-        $new_cart_list= array();
-        if (is_array($cart_list))
-        {
-            foreach ($cart_list as $value)
-            {
+        $new_cart_list = array();
+        if (is_array($cart_list)) {
+            foreach ($cart_list as $value) {
                 if (preg_match_all('/^(\d{1,10})\|(\d{1,6})$/', $value, $match)) {
                     if (intval($match[2][0]) > 0) {
                         $new_cart_list[$match[1][0]] = $match[2][0];
@@ -131,44 +130,37 @@ class member_cartControl extends mobileMemberControl
 
             $model_cart = Model('cart');
             $condition = array('buyer_id' => $this->member_info['member_id']);
-            $original_cart_list	= $model_cart->listCart('db', $condition);
+            $original_cart_list = $model_cart->listCart('db', $condition);
             $quantity_error = array();
-            foreach ($original_cart_list as $key => $value)
-            {
-                if(array_key_exists($value['cart_id'], $new_cart_list))
-                {
+            foreach ($original_cart_list as $key => $value) {
+                if (array_key_exists($value['cart_id'], $new_cart_list)) {
                     $quantity = intval($new_cart_list[$value['cart_id']]);
-                    if(intval($value['goods_num']) !== $quantity)
-                    {
-                        if(!$this->_check_goods_storage($value, $quantity, $this->member_info['member_id'])) {
-                            array_push($quantity_error, array('cart_id' => $value['cart_id'], 'quantity' => $quantity,'err_info'=>'库存不足'));
-                        }
-                        else
-                        {
+                    if (intval($value['goods_num']) !== $quantity) {
+                        if (!$this->_check_goods_storage($value, $quantity, $this->member_info['member_id'])) {
+                            array_push($quantity_error, array('cart_id' => $value['cart_id'], 'quantity' => $quantity, 'err_info' => '库存不足'));
+                        } else {
                             $data = array();
                             $data['goods_num'] = $quantity;
-                            $update = $model_cart->editCart($data, array('cart_id'=> $value['cart_id']));
-                            if(!$update) {
+                            $update = $model_cart->editCart($data, array('cart_id' => $value['cart_id']));
+                            if (!$update) {
                                 return joutput_error(errcode::ErrCart, '购物车修改失败');
                             }
                         }
                     }
-                }
-                else
-                {
-                    $delete = $model_cart->delCart('db', array('cart_id'=>$value['cart_id']));
-                    if(!$delete) {
+                } else {
+                    $delete = $model_cart->delCart('db', array('cart_id' => $value['cart_id']));
+                    if (!$delete) {
                         return joutput_error(errcode::ErrCart, '购物车修改失败');
                     }
                 }
             }
 
-            if(count($quantity_error) > 0) {
-                joutput_data(array('result'=> '0', 'quantity_error' => $quantity_error));
+            if (count($quantity_error) > 0) {
+                joutput_data(array('result' => '0', 'quantity_error' => $quantity_error));
             } else {
                 joutput_data(array('result' => '1'));
             }
-        }else{
+        } else {
             return joutput_error(errcode::ErrCart, '购物车列表格式错误');
         }
     }
@@ -182,7 +174,7 @@ class member_cartControl extends mobileMemberControl
 
         $model_cart = Model('cart');
 
-        if($cart_id > 0) {
+        if ($cart_id > 0) {
             $condition = array();
             $condition['buyer_id'] = $this->member_info['member_id'];
             $condition['cart_id'] = $cart_id;
@@ -198,38 +190,38 @@ class member_cartControl extends mobileMemberControl
      */
     public function cart_edit_quantityOp()
     {
-		$cart_id = intval(abs($_POST['cart_id']));
-		$quantity = intval(abs($_POST['quantity']));
-		if(empty($cart_id) || empty($quantity)) {
+        $cart_id = intval(abs($_POST['cart_id']));
+        $quantity = intval(abs($_POST['quantity']));
+        if (empty($cart_id) || empty($quantity)) {
             return joutput_error(errcode::ErrCart, '参数错误');
-		}
+        }
 
-		$model_cart = Model('cart');
+        $model_cart = Model('cart');
 
-        $cart_info = $model_cart->getCartInfo(array('cart_id'=>$cart_id, 'buyer_id' => $this->member_info['member_id']));
+        $cart_info = $model_cart->getCartInfo(array('cart_id' => $cart_id, 'buyer_id' => $this->member_info['member_id']));
 
         //检查是否为本人购物车
-        if($cart_info['buyer_id'] != $this->member_info['member_id']) {
+        if ($cart_info['buyer_id'] != $this->member_info['member_id']) {
             return joutput_error(errcode::ErrCart, '参数错误');
         }
 
         //检查库存是否充足
-        if(!$this->_check_goods_storage($cart_info, $quantity, $this->member_info['member_id'])) {
+        if (!$this->_check_goods_storage($cart_info, $quantity, $this->member_info['member_id'])) {
             return joutput_error(errcode::ErrCart, '库存不足');
         }
 
-		$data = array();
+        $data = array();
         $data['goods_num'] = $quantity;
-        $update = $model_cart->editCart($data, array('cart_id'=>$cart_id));
-		if ($update) {
-		    $return = array();
+        $update = $model_cart->editCart($data, array('cart_id' => $cart_id));
+        if ($update) {
+            $return = array();
             $return['quantity'] = $quantity;
-			$return['goods_price'] = ncPriceFormat($cart_info['goods_price']);
-			$return['total_price'] = ncPriceFormat($cart_info['goods_price'] * $quantity);
+            $return['goods_price'] = ncPriceFormat($cart_info['goods_price']);
+            $return['total_price'] = ncPriceFormat($cart_info['goods_price'] * $quantity);
             joutput_data($return);
-		} else {
+        } else {
             return joutput_error(errcode::ErrCart, '修改失败');
-		}
+        }
     }
 
     /**
@@ -237,39 +229,39 @@ class member_cartControl extends mobileMemberControl
      */
     private function _check_goods_storage($cart_info, $quantity, $member_id)
     {
-		$model_goods= Model('goods');
+        $model_goods = Model('goods');
         $model_bl = Model('p_bundling');
         $logic_buy_1 = Logic('buy_1');
 
-		if ($cart_info['bl_id'] == '0') {
+        if ($cart_info['bl_id'] == '0') {
             //普通商品
-		    $goods_info	= $model_goods->getGoodsOnlineInfoAndPromotionById($cart_info['goods_id']);
+            $goods_info = $model_goods->getGoodsOnlineInfoAndPromotionById($cart_info['goods_id']);
 
-		    //抢购
-		    $logic_buy_1->getGroupbuyInfo($goods_info);
+            //抢购
+            $logic_buy_1->getGroupbuyInfo($goods_info);
 
-		    //限时折扣
-		    $logic_buy_1->getXianshiInfo($goods_info,$quantity);
+            //限时折扣
+            $logic_buy_1->getXianshiInfo($goods_info, $quantity);
 
-		    if(intval($goods_info['goods_storage']) < $quantity) {
+            if (intval($goods_info['goods_storage']) < $quantity) {
                 return false;
-		    }
-		} else {
-		    //优惠套装商品
-		    $bl_goods_list = $model_bl->getBundlingGoodsList(array('bl_id' => $cart_info['bl_id']));
-		    $goods_id_array = array();
-		    foreach ($bl_goods_list as $goods) {
-		        $goods_id_array[] = $goods['goods_id'];
-		    }
-		    $bl_goods_list = $model_goods->getGoodsOnlineListAndPromotionByIdArray($goods_id_array);
-
-		    //如果有商品库存不足,更新购买数量到目前最大库存
-		    foreach ($bl_goods_list as $goods_info) {
-		        if (intval($goods_info['goods_storage']) < $quantity) {
+            }
+        } else {
+            //优惠套装商品
+            $bl_goods_list = $model_bl->getBundlingGoodsList(array('bl_id' => $cart_info['bl_id']));
+            $goods_id_array = array();
+            foreach ($bl_goods_list as $goods) {
+                $goods_id_array[] = $goods['goods_id'];
+            }
+            $bl_goods_list = $model_goods->getGoodsOnlineListAndPromotionByIdArray($goods_id_array);
+
+            //如果有商品库存不足,更新购买数量到目前最大库存
+            foreach ($bl_goods_list as $goods_info) {
+                if (intval($goods_info['goods_storage']) < $quantity) {
                     return false;
-		        }
-		    }
-		}
+                }
+            }
+        }
         return true;
     }
 }

+ 6 - 1
mobile/util/errcode.php

@@ -30,6 +30,9 @@ class errcode extends SplEnum
     const ErrGoodsNotExist = 13000;
     const ErrMemberNotExist = 13001;
     const ErrInputParam = 13002;
+    const ErrVerifyCode = 13003;
+    const ErrMemberExist = 13004;
+
 
     static function msg($code) 
     {
@@ -47,7 +50,9 @@ class errcode extends SplEnum
             case errcode::ErrPayment: return 'ErrPayment.';
             case errcode::ErrGoodsNotExist: return 'ErrGoodsNotExist.';
             case errcode::ErrMemberNotExist: return 'ErrMemberExist.';
-            case errcode::ErrInputParam: return '�����������.';
+            case errcode::ErrInputParam: return 'error input param';
+            case errcode::ErrVerifyCode: return 'error verify code';
+            case errcode::ErrMemberExist: return '用户已经存在';
 
             case errcode::ErrDB : return 'ErrorDB';
             case errcode::ErrSms : return 'ErrSms,Send sms error.';