dever 3 tahun lalu
induk
melakukan
c078f2202b
1 mengubah file dengan 23 tambahan dan 218 penghapusan
  1. 23 218
      service/agent/src/My.php

+ 23 - 218
service/agent/src/My.php

@@ -75,7 +75,7 @@ class My extends Core
     # 设置门店
     public function setShop()
     {
-        $id = Dever::input('id');
+        $id = Dever::input('id', $this->uid);
         $shop_id = Dever::input('shop_id');
         $this->data['info'] = Dever::db('agent/member')->find($id);
         if ($this->data['info'] && $this->data['info']['idcard'] == $this->user['idcard']) {
@@ -109,13 +109,6 @@ class My extends Core
         if ($this->data['user']['role']) {
             if ($this->data['user']['role']['levelup'] == 1) {
                 $this->data['button']['up'] = 1;
-                if ($this->data['user']['role']['type'] == 2 && $this->data['user']['role']['area'] == 1) {
-                    $temp = explode(',', $this->data['user']['area']);
-                    $city = Dever::db('area/city')->find($temp[1]);
-                    if ($city && $city['level'] == 1) {
-                        $this->data['button']['up'] = 2;
-                    }
-                }
             }
             if ($this->data['user']['role']['isbuy'] == 1) {
                 $this->data['button']['buy'] = 2;//不允许购买新区域
@@ -128,58 +121,13 @@ class My extends Core
     # 账号与代理区域
     public function getUpInfo()
     {
-        $this->data['user'] = Dever::load('agent/lib/member')->getInfo($this->user);
-
-        if ($this->data['user']['role']['type'] == 2) {
-            $temp = explode(',', $this->data['user']['area']);
-
-            # 如果当前是城市,只能升级为更高级的城市
-            if ($this->data['user']['role']['area'] == 1) {
-                $city = Dever::db('area/city')->find($temp[1]);
-                if ($city && $city['level_id'] == 1) {
-                    $this->data['role'] = array();
-                } else {
-                    $this->data['role'] = Dever::db('setting/role')->getInfo(array('isbuy' => 1, 'type' => 2, 'area' => 1));
-                }
-            }
-            # 如果当前是区县,可以升级为城市和更高级的区县
-            if ($this->data['user']['role']['area'] == 2) {
-                $area = '1,2';
-                $county = Dever::db('area/county')->find($temp[2]);
-                if ($county && $county['level'] == 1) {
-                    $area = '1';
-                }
-                $this->data['role'] = Dever::db('setting/role')->getInfo(array('isbuy' => 1, 'type' => 2, 'area' => $area));
-            }
-            # 如果当前是街道,都可以升级
-            if ($this->data['user']['role']['area'] == 3) {
-                $area = '1,2,3';
-                $town = Dever::db('area/town')->find($temp[3]);
-                if ($town && $town['type'] == 3) {
-                    $area = '1,2';
-                }
-
-                $this->data['role'] = Dever::db('setting/role')->getInfo(array('isbuy' => 1, 'type' => 2, 'area' => $area));
-            }
-        } else {
-            $this->data['role'] = Dever::db('setting/role')->getInfo(array('isbuy' => 1, 'type' => 2));
-        }
-
-        $this->data['level_total'] = count($this->data['role']) + 1;
-
+        $this->data['user'] = $this->getInfo();
+        $this->data['role'] = Dever::db('setting/role')->getInfo(array('isbuy' => 1, 'type' => 2));
         $this->data['config'] = Dever::db('setting/base')->find();
 
         return $this->data;
     }
 
-    # 根据角色获取打款金额
-    public function getPrice()
-    {
-        $this->data = Dever::load('agent/lib/order')->getPrice($this->uid);
-
-        return $this->data;
-    }
-
     # 购买新区域 & 账号升级
     public function buyArea()
     {
@@ -389,162 +337,32 @@ class My extends Core
         return $this->data;
     }
 
-    # 获取我的资金
-    public function getCash()
-    {
-        $this->data['user'] = $this->user;
-        $this->data['type'] = Dever::db('bill/cash')->config['set']['type'];
-        $this->data['status'] = Dever::db('bill/cash')->config['set']['status'];
-
-        $where['mid'] = $this->uid;
-        $type = Dever::input('type');
-        if ($type) {
-            $where['type'] = $type;
-        }
-        $this->data['list'] = Dever::db('bill/cash')->getData($where);
-        if ($this->data['list']) {
-            foreach ($this->data['list'] as $k => $v) {
-                $this->data['list'][$k]['type_name'] = $this->data['type'][$v['type']];
-                $this->data['list'][$k]['status_name'] = $this->data['status'][$v['status']];
-                $this->data['list'][$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
-                if ($v['cash'] > 0) {
-                    $this->data['list'][$k]['cash'] = '+' . $v['cash'];
-                }
-            }
-        }
-
-        return $this->data;
-    }
-
-    public function getCashView()
-    {
-        $where['mid'] = $this->uid;
-        $where['id'] = Dever::input('id');
-        $this->data['info'] = Dever::db('bill/cash')->find($where);
-
-        $config = Dever::db('bill/cash')->config['set'];
-
-        if ($this->data['info']) {
-            $this->data['info']['type_name'] = $config['type'][$this->data['info']['type']];
-            $this->data['info']['status_name'] = $config['status'][$this->data['info']['status']];
-
-            $this->data['info']['cdate'] = date('Y-m-d H:i', $this->data['info']['cdate']);
-            if ($this->data['info']['cash'] > 0) {
-                $this->data['info']['cash'] = '+' . $this->data['info']['cash'];
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 获取我的业绩统计
-    public function getSell()
-    {
-        $this->data['user'] = $this->user;
-        $where['mid'] = $this->uid;
-        $this->data['list'] = Dever::db('bill/sell_stat')->getData($where);
-        if ($this->data['list']) {
-            foreach ($this->data['list'] as $k => $v) {
-                $this->data['list'][$k]['month'] = date('Y年m月', $v['month']);
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 提现详情
-    public function tixianInfo()
-    {
-        $this->data['user'] = $this->user;
-        $this->data['config'] = Dever::db('setting/base')->one();
-        $this->data['config']['tax'] = $this->data['config']['tax']/100;
-        $this->data['bank'] = Dever::db('setting/bank')->select();
-
-        # 获取上次提现记录
-        $this->data['mybank'] = Dever::db('bill/tixian')->getNew(array('mid' => $this->uid));
-
-        return $this->data;
-    }
-
-    # 确定提现
-    public function tixian_commit()
-    {
-        $cash = Dever::input('cash');
-        if ($cash > $this->user['cash']) {
-            Dever::alert('您的可提现金额不足');
-        }
-        $name = Dever::input('name');
-        if (!$name) {
-            Dever::alert('姓名不能为空');
-        }
-        $bank = Dever::input('bank');
-        if (!$bank) {
-            Dever::alert('银行不能为空');
-        }
-        $bankname = Dever::input('bankname');
-        if (!$bankname) {
-            Dever::alert('开户行不能为空');
-        }
-        $card = Dever::input('card');
-        if (!$card) {
-            Dever::alert('银行卡号不能为空');
-        }
-        $ycard = Dever::input('ycard');
-        if (!$ycard) {
-            Dever::alert('确认银行卡号不能为空');
-        }
-        if ($card != $ycard) {
-            Dever::alert('银行卡号和确认银行卡号不同');
-        }
-
-        $config = Dever::db('setting/base')->one();
-        $tax = $config['tax']/100;
-        $ycash = $cash;
-        $cash = $cash - $cash*$tax;
-
-        $id = Dever::load('bill/lib/tixian')->up($this->uid, $ycash, $cash, $name, $bank, $bankname, $card);
-
-        if ($id) {
-            $cash_id = Dever::load('bill/lib/cash')->up($this->uid, 11, $ycash, $this->user['role'], $id, '提现到'.substr($card, -4).'银行卡', 1);
-
-            Dever::db('bill/tixian')->update(array('where_id' => $id, 'cash_id' => $cash_id));
-
-            $where['where_id'] = $this->uid;
-            $where['cash'] = -1*$ycash;
-            Dever::db('agent/member')->upCash($where);
-        }
-
-        return 'ok';
-    }
-
-    # 修改密码
+    # 密码设置
     public function setPass()
     {
-        $pass = Dever::input('pass');
-        if (!$pass) {
+        $where['where_id'] = $this->uid;
+        $where['password'] = Dever::input('password');
+        if (!$where['password']) {
             Dever::alert('请输入密码');
         }
-
-        $where['where_id'] = $this->uid;
-        $where['password'] = $pass;
-
+        $where['password'] = sha1($where['password']);
         Dever::db('agent/member')->update($where);
 
-        return Dever::db('agent/member')->find(array('id' => $this->uid, 'clear' => true));
+        return Dever::db('agent/member')->find(array('id' => $this->id, 'clear' => true));
     }
 
     # 修改资料
     public function setInfo()
     {
         $where = array();
-        $name = Dever::input('name');
-        if ($name) {
-            $where['name'] = $name;
-        }
         $avatar = Dever::input('avatar');
         if ($avatar) {
             $where['avatar'] = $avatar;
         }
+        $name = Dever::input('name');
+        if ($name) {
+            $where['name'] = $name;
+        }
         $username = Dever::input('username');
         if ($username) {
             $where['username'] = $username;
@@ -553,38 +371,25 @@ class My extends Core
         if ($birthday) {
             $where['birthday'] = Dever::maketime($birthday);
         }
-
         if ($where) {
             $where['where_id'] = $this->uid;
             Dever::db('agent/member')->update($where);
         }
+        
 
-        return Dever::db('agent/member')->find(array('id' => $this->uid, 'clear' => true));
+        return Dever::db('agent/member')->find(array('id' => $this->id, 'clear' => true));
     }
 
-    # 发送邮件
-    public function sendEmail()
+    # 邮箱设置
+    public function setEmail()
     {
-        $email = Dever::input('email');
-        if ($email) {
-            if (!preg_match(Dever::rule('email'), $email)) {
-                Dever::alert('请输入正确的邮箱');
-            }
-
-            $check = Dever::db('agent/member')->find(array('email' => $email));
-            if ($check) {
-                Dever::alert('该邮箱已被认证,请更换');
-            }
-
-            $code = Dever::load('passport/reg')->code(false, false);
-
-            $email = base64_encode($email);
-            //return Dever::load('agent/lib/email')->renzheng($this->uid, $email, $code);
-            Dever::daemon('lib/email.renzheng?mid='.$this->uid.'&email=' . $email . '&code=' . $code, 'agent');
-
-            return '邮件已经发送成功!请到您的邮箱里查看。';
-        } else {
+        $where['where_id'] = $this->uid;
+        $where['email'] = Dever::input('email');
+        if (!$where['email']) {
             Dever::alert('请输入邮箱');
         }
+        Dever::db('agent/member')->update($where);
+
+        return Dever::db('agent/member')->find(array('id' => $this->id, 'clear' => true));
     }
 }