Prechádzať zdrojové kódy

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

root 9 rokov pred
rodič
commit
ab1fe0ddf0

+ 5 - 1
crontab/crawl/fetch_goods.php

@@ -27,6 +27,8 @@ require_once (BASE_CRONTAB_PATH . '/crawl/upload_file.php');
 require_once (BASE_CRONTAB_PATH . '/crawl/upload_control.php');
 require_once (BASE_CRONTAB_PATH . '/crawl/tm_pagereq.php');
 require_once(BASE_CRONTAB_PATH . '/crawl/brand_operator.php');
+require_once(BASE_CRONTAB_PATH . '/crawl/importer_check.php');
+
 
 
 //require_once (BASE_CORE_PATH . '/framework/libraries/uploadfile.php');
@@ -49,7 +51,6 @@ function not_null($str)
     return (empty($str)) ? '' : $str;
 }
 
-
 //$tmreq = new tmrequest();
 //$tmreq->proc();
 
@@ -70,3 +71,6 @@ $importer->proc_shop();
 
 
 $brander->update_brand();
+
+//$ichecker = new importer_check();
+//$ichecker->proc();

+ 111 - 0
crontab/crawl/importer_check.php

@@ -0,0 +1,111 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/1/19
+ * Time: 下午10:50
+ */
+class importer_check
+{
+    private $goods;
+    private $goods_common;
+    private $goods_images;
+    private $album_pic;
+
+    public function __construct()
+    {
+        $this->goods = Model('goods');
+        $this->goods_common = Model('goods_common');
+        $this->goods_images = Model('goods_images');
+        $this->album_pic = Model('album_pic');
+    }
+
+    private function check_goods($comm_id)
+    {
+        $goods = $this->goods->field('goods_id,color_id')->where(array('goods_commonid' => $comm_id))->limit(false)->select();
+        if(empty($goods)) {
+            return false;
+        }
+
+        if(count($goods) == 0) {
+            return false;
+        }
+
+        return $goods;
+    }
+
+    private function check_goods_common($comm_id)
+    {
+        $goods = $this->goods_common->field('goods_commonid')->where(array('goods_commonid' => $comm_id))->select();
+        if(empty($goods)) {
+            return false;
+        }
+
+        if(count($goods) == 0) {
+            return false;
+        }
+
+        return $goods;
+    }
+
+    private function check_images($comm_id)
+    {
+        $goods = $this->goods->field('goods_image_id,color_id')->where(array('goods_commonid' => $comm_id))->group('filesig')->limit(false)->select();
+        if(empty($goods)) {
+            return false;
+        }
+
+        if(count($goods) == 0) {
+            return false;
+        }
+
+        return $goods;
+    }
+
+    public function proc()
+    {
+        $commonids = $this->goods_common->field('goods_commonid')->limit(false)->select();
+        if(empty($commonids)) {
+            Log::record("cannot find any goods from goods_common table.",Log::DEBUG);
+            return;
+        }
+
+        foreach($commonids as $val)
+        {
+            $cid = $val['goods_commonid'];
+            $goods = $this->check_goods($cid);
+            $images = $this->check_images($cid);
+
+            if($goods == false || $images == false) {
+                $this->goods_common->where(array('goods_commonid' => $cid))->delete();
+                $this->goods->where(array('goods_commonid' => $cid))->delete();
+                $this->goods_images->where(array('goods_commonid' => $cid))->delete();
+
+                Log::record("delete goods when goods_commonid = {$cid}",Log::DEBUG);
+            }
+        }
+
+        $commonids = $this->goods->field('goods_commonid')->group('goods_commonid')->limit(false)->select();
+
+        if(empty($commonids)) {
+            Log::record("cannot find any goods_commonid from goods table.",Log::DEBUG);
+            return;
+        }
+
+        foreach($commonids as $val)
+        {
+            $cid = $val['goods_commonid'];
+            $goods  = $this->check_goods_common($cid);
+            $images = $this->check_images($cid);
+
+            if($goods == false || $images == false) {
+                $this->goods_common->where(array('goods_commonid' => $cid))->delete();
+                $this->goods->where(array('goods_commonid' => $cid))->delete();
+                $this->goods_images->where(array('goods_commonid' => $cid))->delete();
+
+                Log::record("delete goods when goods_commonid = {$cid}",Log::DEBUG);
+            }
+        }
+    }
+}

+ 72 - 38
mobile/control/login.php

@@ -229,6 +229,46 @@ class loginControl extends mobileHomeControl
         }
     }
 
+    public function registerOp()
+    {
+        $mobile = trim($_POST['mobile']);
+        $password = trim($_POST['password']);
+        $code = trim($_POST['code']);
+
+        $validator = new Validate();
+        $validator->setValidate(Validate::verify_mobile($mobile));
+        $validator->setValidate(Validate::verify_password($password));
+        $validator->setValidate(Validate::smscode($code));
+        $err = $validator->validate();
+        if ($err != '') {
+            return joutput_error(errcode::ErrParamter, $err);
+        }
+
+        $model = Model('member');
+        $ret = $model->where(array('member_mobile' => $mobile))->find();
+        if(!empty($ret)) {
+            return joutput_error(errcode::ErrUserExisted, "用户已经存在.");
+        }
+        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) {
+                    return joutput_data(NULL);
+                } else {
+                    return joutput_error(errcode::ErrDB,"DB error.");
+                }
+            }
+            else
+            {
+                return joutput_error(errcode::ErrSmscode,"错误的验证码.");
+            }
+        }
+    }
+
     public function getinfoOp()
     {
         static $field = 'member_id,member_mobile,member_name,member_truename,member_avatar,member_sex,member_birthday,member_email,member_email_bind';
@@ -277,7 +317,7 @@ class loginControl extends mobileHomeControl
         if ($result) {
             return $token;
         } else {
-            return null;
+            return NULL;
         }
     }
 
@@ -287,24 +327,18 @@ class loginControl extends mobileHomeControl
         return $key;
     }
 
+    public static function gen_mobile_code($mobile)
+    {
+        $key = 'mobile:' . $mobile;
+        return $key;
+    }
 
     public function getcodeOp()
     {
         $mobile = trim($_POST['mobile']);
 
-        $token = trim($_POST['token']);
-        if (empty($token)) {
-            return joutput_error(errcode::ErrParamter, 'Token cannot empty.');
-        }
-
-        $userid = token_uid($token);
-        if ($userid == -1) {
-            return joutput_error(errcode::ErrTokenExpire);
-        }
-
         $validator = new Validate();
         $validator->setValidate(Validate::verify_mobile($mobile));
-
         $err = $validator->validate();
         if ($err != '') {
             return joutput_error(errcode::ErrParamter, $err);
@@ -312,10 +346,10 @@ class loginControl extends mobileHomeControl
 
         $sms = new Sms();
         $code = makeSmscode();
-
         $status = $sms->send($mobile, array('code' => $code, 'type' => Sms::register_code, 'time' => '5'));
+
         if ($status == 0) {
-            $key = $this->gen_token_code($token);
+            $key = $this->gen_mobile_code($mobile);
             wcache($key, array('code' => $code, 'mobile' => $mobile), 'member', self::code_expire);
             joutput_data(NULL);
         } else {
@@ -355,28 +389,28 @@ class loginControl extends mobileHomeControl
         }
     }
 
-    public function registerOp()
-    {
-        $model_member = Model('member');
-
-        $register_info = array();
-        $register_info['username'] = $_POST['username'];
-        $register_info['password'] = $_POST['password'];
-        $register_info['password_confirm'] = $_POST['password_confirm'];
-
-        $register_info['checkcode'] = $_POST['password_confirm'];
-        $register_info['email'] = $_POST['email'];
-
-        $member_info = $model_member->register($register_info);
-        if (!isset($member_info['error'])) {
-            $token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
-            if ($token) {
-                output_data(array('username' => $member_info['member_name'], 'key' => $token));
-            } else {
-                output_error('注册失败');
-            }
-        } else {
-            output_error($member_info['error']);
-        }
-    }
+//    public function registerOp()
+//    {
+//        $model_member = Model('member');
+//
+//        $register_info = array();
+//        $register_info['username'] = $_POST['username'];
+//        $register_info['password'] = $_POST['password'];
+//        $register_info['password_confirm'] = $_POST['password_confirm'];
+//
+//        $register_info['checkcode'] = $_POST['password_confirm'];
+//        $register_info['email'] = $_POST['email'];
+//
+//        $member_info = $model_member->register($register_info);
+//        if (!isset($member_info['error'])) {
+//            $token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
+//            if ($token) {
+//                output_data(array('username' => $member_info['member_name'], 'key' => $token));
+//            } else {
+//                output_error('注册失败');
+//            }
+//        } else {
+//            output_error($member_info['error']);
+//        }
+//    }
 }

+ 2 - 1
mobile/util/errcode.php

@@ -15,6 +15,7 @@ class errcode extends SplEnum
     const ErrSmscodeExpire = 10006;
     const ErrSmscode = 10007;
     const ErrIDbinded = 10008;
+    const ErrUserExisted = 10009;
 
     const ErrSpecial  = 10100;
     const ErrCart  = 10200;
@@ -46,7 +47,7 @@ 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 '�����������.';
 
             case errcode::ErrDB : return 'ErrorDB';
             case errcode::ErrSms : return 'ErrSms,Send sms error.';

+ 1 - 0
util.php

@@ -12,6 +12,7 @@ require_once (BASE_ROOT_PATH . '/fooder.php');
 require_once (BASE_UTIL_PATH . '/sku_mapper.php');
 
 
+
 define('StartTime', microtime(true));
 define('TIMESTAMP', time());
 Base::run_test();