Browse Source

员工设置密码,商铺设置资料,未审核通过不能登录

lizhen_gitee 1 year ago
parent
commit
8ad6494128

+ 30 - 4
application/api/controller/company/Staff.php

@@ -4,7 +4,7 @@ namespace app\api\controller\company;
 
 use app\common\controller\Apic;
 use think\Db;
-
+use fast\Random;
 /**
  * 员工管理
  */
@@ -25,12 +25,20 @@ class Staff extends Apic
     //新增
     public function add(){
         $data = [
-            'truename' => input('truename',''),
-            'mobile' => input('mobile',''),
+            'truename'   => input('truename',''),
+            'mobile'     => input('mobile',''),
             'company_id' => $this->auth->company_id,
-            'type' => 2,
+            'type'       => 2,
         ];
 
+        //密码
+        $password = input('password','123456');
+        $salt = Random::alnum();
+        $newpassword = $this->getEncryptPassword($password, $salt);
+        $data['password'] = $newpassword;
+        $data['salt']     = $salt;
+
+
         //检查
         $check2 = Db::name('company_staff')->where('mobile',$data['mobile'])->find();
         if($check2){
@@ -41,6 +49,17 @@ class Staff extends Apic
         $this->success('添加成功');
     }
 
+    /**
+     * 获取密码加密后的字符串
+     * @param string $password 密码
+     * @param string $salt     密码盐
+     * @return string
+     */
+    public function getEncryptPassword($password, $salt = '')
+    {
+        return md5(md5($password) . $salt);
+    }
+
     //详情
     public function info(){
         $id = input('id',0);
@@ -56,6 +75,13 @@ class Staff extends Apic
             'mobile' => input('mobile',''),
         ];
 
+        //密码
+        $password = input('password','123456');
+        $salt = Random::alnum();
+        $newpassword = $this->getEncryptPassword($password, $salt);
+        $data['password'] = $newpassword;
+        $data['salt']     = $salt;
+
         //检查
         $check2 = Db::name('company_staff')->where('id','neq',$id)->where('mobile',$data['mobile'])->find();
         if($check2){

+ 30 - 21
application/api/controller/company/User.php

@@ -114,33 +114,42 @@ class User extends Apic
      */
     public function profile()
     {
-        //检查
-        $check = Db::name('company')->where('id',$this->auth->id)->find();
-        if($check['status'] == 1){
-            $this->success('资料审核通过后需联系客服修改');
-        }
+        $field = [
+            'mobile',
+            'image',
+            'is_open',
+            'open_hours',
+        ];
 
+        $data = request_post_hub($field);
+        $data['updatetime'] = time();
+
+        $update_rs = Db::name('company')->where('id',$this->auth->company_id)->update($data);
+
+        $this->success('资料更新完成');
+    }
+
+    /**
+     * 设置店铺地址
+     */
+    public function setaddress()
+    {
         $field = [
-            'company_name',
-            'company_code',
-            'company_registerdate',
-            'company_address',
-            'company_image',
-
-            'truename',
-            'idcard',
-            'idcard_images',
-
-            'bank_name',
-            'bank_branchname',
-            'bank_account',
-            'bank_card',
+            'province_name',
+            'city_name',
+            'area_name',
+            'province_id',
+            'city_id',
+            'area_id',
+            'address',
         ];
 
         $data = request_post_hub($field);
-        $data['status'] = 0;
 
-        $update_rs = Db::name('company')->where('id',$this->auth->id)->update($data);
+        $data['full_address'] = $data['province_name'].$data['city_name'].$data['area_name'].$data['address'];
+        $data['updatetime'] = time();
+
+        $update_rs = Db::name('company')->where('id',$this->auth->company_id)->update($data);
 
         $this->success('资料更新完成');
     }

+ 4 - 0
application/common/library/Authcompany.php

@@ -244,6 +244,10 @@ class Authcompany
             if(!$companyinfo){
                 return false;
             }
+            if($companyinfo->status != 1){
+                $this->setError('当前门店未通过审核');
+                return false;
+            }
 
             Db::startTrans();
             try {