lizhi 3 miesięcy temu
rodzic
commit
ae8ccf2e8f

+ 53 - 99
protected/components/Controller.php

@@ -10,121 +10,75 @@ class Controller extends CController
 	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
 	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
 	 */
 	 */
 	public $layout='//layouts/column1';
 	public $layout='//layouts/column1';
-	/**
-	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
-	 */
-	public $menu=array();
-	/**
-	 * @var array the breadcrumbs of the current page. The value of this property will
-	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
-	 * for more details on how to specify this property.
-	 */
-	public $breadcrumbs=array();
-
-	public $user_id=0;
-	public $global_data = [];
 
 
-    public function option()
+    /**
+     * 检查请求方是否合法
+     * @return void
+     * @throws CHttpException
+     */
+    private function _checkRequest(): void
     {
     {
-        header("Access-Control-Allow-Origin: *");
+        if (LWM_ENV == 'dev') {
+            header("Access-Control-Allow-Origin: *");
+        } else {
+            if (!str_contains(Yii::app()->request->hostInfo, Yii::app()->params['url'])) {
+                throw new CHttpException(403, '非法访问');
+            }
+            header("Access-Control-Allow-Origin:" . Yii::app()->request->hostInfo);
+        }
+        
         header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
         header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
         header("Access-Control-Allow-Headers: Content-Type, Authorization, Cookie");
         header("Access-Control-Allow-Headers: Content-Type, Authorization, Cookie");
         if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
         if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
             exit(0); // 预检请求直接返回
             exit(0); // 预检请求直接返回
         }
         }
     }
     }
-	public function beforeAction($action)
-    {
-        $this->option();
-        Yii::app()->language = 'zh_cn';
-		$controller = Yii::app()->controller->id;
-		$action = $this->getAction()->getId();
-        $path = strtolower($controller . '/'. $action);
-		if(!in_array($path, LewaimaiAdminPingtaiAuth::$noLoginRouters) && Yii::app()->user->isGuest){
-            // Helper::error('请先登入1', 401);
-		}
-		if (!LewaimaiAdminPingtaiAuth::adminAuth($controller, $action) && (!Yii::app()->user->isGuest && Yii::app()->user->_id != 1)) {
-            Helper::error('您没有相应的权限');
-		}
-		return true;
-	}
 
 
-    /**
-     * Redirects the browser to the specified URL or route (controller/action).
-     * @param mixed $url the URL to be redirected to. If the parameter is an array,
-     * the first element must be a route to a controller action and the rest
-     * are GET parameters in name-value pairs.
-     * @param boolean $terminate whether to terminate the current application after calling this method. Defaults to true.
-     * @param integer $statusCode the HTTP status code. Defaults to 302. See {@link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html}
-     * for details about HTTP status code.
-     */
-    public function redirect($url,$terminate=true,$statusCode=302)
+    private function _checkSign()
     {
     {
-        if(is_array($url))
-        {
-            $route=isset($url[0]) ? $url[0] : '';
-            $url=$this->createUrl($route,array_splice($url,1));
+        if (!\Yii::app()->request->isPostRequest) {
+            return true;
         }
         }
-        header('Location: ' . $url, true, $statusCode);
-    }
-
-    public function jsonReturn($data)
-    {
-        echo CJSON::encode($data);
+        if (!isset($_POST['sign'])) {
+            return false;
+        }
+        $paramArray = [];
+        unset($paramArray['sign']); // 签名不计算sign
+        $stringArray = []; // 对参与签名的参数进行排序
+        foreach ($_POST as $k => $v) {
+            $stringArray[] = "{$k}={$v}";
+        }
+        sort($stringArray, SORT_STRING);
+        $query = implode('&', $stringArray) . 'v1wqe21wmjhop';
+        $sign = strtoupper(hash('sha256', $query));
+        Logger::errorMult($query, $sign, $sign == $_POST['sign']);
+        return $_POST['sign'] == $sign;
     }
     }
 
 
     /**
     /**
-     * 获取当前 page,用于列表跳转到其他页面后返回
-     * @return int
-     * @author lizhi <1458705589@qq.com>
-     * @date   2021/9/29
+     * @throws CHttpException
      */
      */
-    protected function getPage()
+    public function beforeAction($action): bool
     {
     {
-        $c = Yii::app()->getRequest()->getCookies()->itemAt('return_page');
-        return $c ? $c->value : 1;
-    }
+        $this->_checkRequest();
 
 
-    /**
-     * 记录当前 page,用于列表跳转到其他页面后返回
-     * @author lizhi <1458705589@qq.com>
-     * @date   2021/9/29
-     */
-    protected function setPage($name = 'page')
-    {
-        $page = Yii::app()->request->getParam($name, 1);
-        Yii::app()->getRequest()->cookies['return_page'] = new CHttpCookie('return_page', $page, ['expire' => time() + 600]);
-    }
+        Yii::app()->language = 'zh_cn';
+		$controller = Yii::app()->controller->id;
+		$action = $this->getAction()->getId();
+        $path = strtolower($controller . '/'. $action);
 
 
-    protected function response($data = [])
-    {
-        $arr = [
-            'errcode' => 0,
-            'msg'     => "ok",
-            'data'    => $data
-        ];
-        echo json_encode($arr);
-        Yii::app()->end();
-        exit;
-    }
-    
-    /*
-    * 请求失败的时候返回
-    * $errcode 错误代码
-    * $errmsg 错误信息
-    */
-    protected function errorResponse($errcode, $errmsg = "")
-    {
-        // if ($errcode < 10001) {
-        //     $errcode = 99999;
-        // }
-        
-        $arr = [
-            'errcode' => $errcode,
-            'msg'     => $errmsg,
-        ];
-        echo json_encode($arr);
-        Yii::app()->end();
-        exit;
-    }
+		if($controller != 'common'
+            &&!in_array($path, LewaimaiAdminPingtaiAuth::$noLoginRouters)
+            && Yii::app()->user->isGuest
+        ){
+            Helper::error('请先登入', 401);
+		}
+
+		if (!LewaimaiAdminPingtaiAuth::adminAuth($controller, $action)
+            && (!Yii::app()->user->isGuest && Yii::app()->user->_id != 1)
+        ) {
+            Helper::error('您没有相应的权限');
+		}
+		return true;
+	}
 }
 }

+ 2 - 2
protected/components/DB.php

@@ -161,14 +161,14 @@ class DB
         return true;
         return true;
     }
     }
 
 
-    public static function updateById($tableName, $filters, $id)
+    public static function updateById($tableName, $info, $id)
     {
     {
         $id = intval($id);
         $id = intval($id);
         if ($id <= 0) {
         if ($id <= 0) {
             return false;
             return false;
         }
         }
         $db = self::getDbCommand();
         $db = self::getDbCommand();
-        $db->update(self::formTableName($tableName), $filters, "id=:id", [':id' => $id]);
+        $db->update(self::formTableName($tableName), $info, "id=:id", [':id' => $id]);
 
 
         return true;
         return true;
     }
     }

+ 3 - 3
protected/components/UserIdentity.php

@@ -20,7 +20,7 @@ class UserIdentity extends CUserIdentity
 	
 	
 	public function authenticate()
 	public function authenticate()
 	{
 	{
-		$record = Useradmin::model()->findByAttributes(array('username' => $this->username));
+		$record = Useradmin::model()->findByAttributes(array('username' => $this->username, 'status' => 1));
 		if ($record === null){
 		if ($record === null){
 			$this->errorCode = self::ERROR_USERNAME_INVALID;
 			$this->errorCode = self::ERROR_USERNAME_INVALID;
 		}
 		}
@@ -32,8 +32,8 @@ class UserIdentity extends CUserIdentity
 			$this->_id=$record->id;
 			$this->_id=$record->id;
 			$this->setState('_id', $record->id);
 			$this->setState('_id', $record->id);
 		
 		
-			$this->setState('username', $record->username); //这个用户生成激活码判断
-			$this->setState('password', $record->password); //这个用户生成激活码判断
+			$this->setState('username', $record->username);
+			$this->setState('password', $record->password);
 			$this->errorCode = self::ERROR_NONE;
 			$this->errorCode = self::ERROR_NONE;
 		}
 		}
 		return !$this->errorCode;
 		return !$this->errorCode;

+ 1 - 1
protected/controllers/CommonController.php

@@ -3,7 +3,7 @@ class CommonController extends Controller
 {
 {
     public function actionSendCode()
     public function actionSendCode()
     {
     {
-        $phone = Helper::getPostString('phone', '13129996214');
+        $phone = Helper::getPostString('phone', '');
         if (!Helper::isPhone($phone)) {
         if (!Helper::isPhone($phone)) {
             Helper::error('手机号码格式错误');
             Helper::error('手机号码格式错误');
         }
         }

+ 3 - 2
protected/controllers/UseradminController.php

@@ -72,13 +72,14 @@ class UseradminController extends Controller
         $filters = [
         $filters = [
             'username' => $name,
             'username' => $name,
             'u.id' => '!=1',
             'u.id' => '!=1',
+            'u.status' => '1',
             'role_id' => Helper::getPostInt('role_id')?:null,
             'role_id' => Helper::getPostInt('role_id')?:null,
             'phone' => Helper::getPostString('phone')?:null,
             'phone' => Helper::getPostString('phone')?:null,
         ];
         ];
         $cri = DbCriteria::simpleCompareWithPage($filters)
         $cri = DbCriteria::simpleCompareWithPage($filters)
             ->setAlias('u')
             ->setAlias('u')
             ->setDebugUntil('234', '-1')
             ->setDebugUntil('234', '-1')
-            ->setSelect('u.id, u.username, r.name as role_name, u.is_using, u.sex, u.phone, u.create_date, u.avatar, u.update_date')
+            ->setSelect('u.id, u.username, r.name as role_name, u.status, u.sex, u.phone, u.create_date, u.avatar, u.update_date')
             ->setJoin('left join wx_role r on u.role_id = r.id');
             ->setJoin('left join wx_role r on u.role_id = r.id');
         $data = DB::getListWithCriteria('useradmin', $cri);
         $data = DB::getListWithCriteria('useradmin', $cri);
         if (!empty($data['records'])) {
         if (!empty($data['records'])) {
@@ -153,7 +154,7 @@ class UseradminController extends Controller
         if ($id < 1) {
         if ($id < 1) {
             Helper::error('参数错误');
             Helper::error('参数错误');
         }
         }
-        DB::deleteById('useradmin', $id);
+        DB::updateById('useradmin', ['status' => 0], $id);
         Helper::ok();
         Helper::ok();
     }
     }
 
 

+ 5 - 5
protected/models/Role.php

@@ -7,7 +7,7 @@
  * @property integer $id
  * @property integer $id
  * @property string $name
  * @property string $name
  * @property string $auth_ids
  * @property string $auth_ids
- * @property integer $is_using
+ * @property integer $status
  * @property string $descr
  * @property string $descr
  * @property string $create_date
  * @property string $create_date
  * @property string $update_date
  * @property string $update_date
@@ -31,13 +31,13 @@ class Role extends CActiveRecord
 		// will receive user inputs.
 		// will receive user inputs.
 		return array(
 		return array(
 			array('name, create_date, update_date', 'required'),
 			array('name, create_date, update_date', 'required'),
-			array('is_using', 'numerical', 'integerOnly'=>true),
+			array('status', 'numerical', 'integerOnly'=>true),
 			array('name', 'length', 'max'=>20),
 			array('name', 'length', 'max'=>20),
 			array('descr', 'length', 'max'=>255),
 			array('descr', 'length', 'max'=>255),
 			array('auth_ids', 'safe'),
 			array('auth_ids', 'safe'),
 			// The following rule is used by search().
 			// The following rule is used by search().
 			// @todo Please remove those attributes that should not be searched.
 			// @todo Please remove those attributes that should not be searched.
-			array('id, name, auth_ids, is_using, descr, create_date, update_date', 'safe', 'on'=>'search'),
+			array('id, name, auth_ids, status, descr, create_date, update_date', 'safe', 'on'=>'search'),
 		);
 		);
 	}
 	}
 
 
@@ -61,7 +61,7 @@ class Role extends CActiveRecord
 			'id' => 'ID',
 			'id' => 'ID',
 			'name' => '角色名',
 			'name' => '角色名',
 			'auth_ids' => '权限ID(用逗号隔开)',
 			'auth_ids' => '权限ID(用逗号隔开)',
-			'is_using' => '是否可用,默认1表示可用,0表示已经删除',
+			'status' => '是否可用,默认1表示可用,0表示已经删除',
 			'descr' => '简介',
 			'descr' => '简介',
 			'create_date' => '创建时间',
 			'create_date' => '创建时间',
 			'update_date' => '更新时间',
 			'update_date' => '更新时间',
@@ -89,7 +89,7 @@ class Role extends CActiveRecord
 		$criteria->compare('id',$this->id);
 		$criteria->compare('id',$this->id);
 		$criteria->compare('name',$this->name,true);
 		$criteria->compare('name',$this->name,true);
 		$criteria->compare('auth_ids',$this->auth_ids,true);
 		$criteria->compare('auth_ids',$this->auth_ids,true);
-		$criteria->compare('is_using',$this->is_using);
+		$criteria->compare('status',$this->status);
 		$criteria->compare('descr',$this->descr,true);
 		$criteria->compare('descr',$this->descr,true);
 		$criteria->compare('create_date',$this->create_date,true);
 		$criteria->compare('create_date',$this->create_date,true);
 		$criteria->compare('update_date',$this->update_date,true);
 		$criteria->compare('update_date',$this->update_date,true);

+ 4 - 4
protected/models/Useradmin.php

@@ -8,7 +8,7 @@
  * @property string $username
  * @property string $username
  * @property string $password
  * @property string $password
  * @property string $email
  * @property string $email
- * @property string $is_using
+ * @property string $status
  * @property string $role_id
  * @property string $role_id
  * @property string $avatar
  * @property string $avatar
  * @property string $descr
  * @property string $descr
@@ -43,10 +43,10 @@ class Useradmin extends CActiveRecord
 			array('password', 'length', 'max'=>50),
 			array('password', 'length', 'max'=>50),
             array('verifypassword', 'length', 'max'=>50),
             array('verifypassword', 'length', 'max'=>50),
             array('verifypassword', 'compare', 'compareAttribute'=>'password', 'message'=>'请再输入确认密码', 'on'=>'register'),
             array('verifypassword', 'compare', 'compareAttribute'=>'password', 'message'=>'请再输入确认密码', 'on'=>'register'),
-			array('auth, is_using', 'safe'),
+			array('auth, status', 'safe'),
 			// The following rule is used by search().
 			// The following rule is used by search().
 			// @todo Please remove those attributes that should not be searched.
 			// @todo Please remove those attributes that should not be searched.
-			array('id, username, password, auth, is_using, verifypassword, phone,email', 'safe', 'on'=>'search'),
+			array('id, username, password, auth, status, verifypassword, phone,email', 'safe', 'on'=>'search'),
 
 
             //找回密码相关
             //找回密码相关
             // array('username', 'safe', 'on'=>'findpassword'),
             // array('username', 'safe', 'on'=>'findpassword'),
@@ -179,7 +179,7 @@ class Useradmin extends CActiveRecord
 	{
 	{
 		$criteria=new CDbCriteria;
 		$criteria=new CDbCriteria;
 
 
-		$criteria->addCondition('is_using=1');
+		$criteria->addCondition('status=1');
 		return new CActiveDataProvider($this, array(
 		return new CActiveDataProvider($this, array(
 			'criteria'=>$criteria,
 			'criteria'=>$criteria,
             'pagination'=>['pageSize'=>20]
             'pagination'=>['pageSize'=>20]

+ 153 - 2
script/upgrade/1.0.0.sql

@@ -1,10 +1,11 @@
+--------------------------------------- 用户角色
 CREATE TABLE `wx_admin` (
 CREATE TABLE `wx_admin` (
   `id` INT(11) NOT NULL AUTO_INCREMENT,
   `id` INT(11) NOT NULL AUTO_INCREMENT,
   `username` VARCHAR(20) NOT NULL,
   `username` VARCHAR(20) NOT NULL,
   `password` VARCHAR(50) NOT NULL,
   `password` VARCHAR(50) NOT NULL,
   `role_id` INT(11) NOT NULL COMMENT '角色id',
   `role_id` INT(11) NOT NULL COMMENT '角色id',
   `sex` TINYINT(4) NOT NULL default 0 COMMENT '性别 0-男 1-女',
   `sex` TINYINT(4) NOT NULL default 0 COMMENT '性别 0-男 1-女',
-  `is_using` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '是否可用,默认1表示可用,0表示已经删除',
+  `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '是否可用,默认1表示可用,0表示已经删除',
   `phone` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '手机号',
   `phone` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '手机号',
   `descr` VARCHAR(24) NOT NULL DEFAULT '' COMMENT '简介',
   `descr` VARCHAR(24) NOT NULL DEFAULT '' COMMENT '简介',
   `avatar` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '头像',
   `avatar` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '头像',
@@ -19,10 +20,160 @@ CREATE TABLE `wx_role` (
   `name` VARCHAR(20) NOT NULL COMMENT '角色名',
   `name` VARCHAR(20) NOT NULL COMMENT '角色名',
   `auth_ids` text COMMENT '权限ID(用逗号隔开)',
   `auth_ids` text COMMENT '权限ID(用逗号隔开)',
   `show_ids` text COMMENT '权限ID(用逗号隔开) 用于前端展示',
   `show_ids` text COMMENT '权限ID(用逗号隔开) 用于前端展示',
-  `is_using` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '是否可用,默认1表示可用,0表示已经删除',
+  `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '是否可用,默认1表示可用,0表示已经删除',
   `descr` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '简介',
   `descr` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '简介',
   `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
   `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
   `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
   `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
   PRIMARY KEY (`id`)
   PRIMARY KEY (`id`)
 ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='角色表';
 ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='角色表';
 
 
+--------------------------------------- 学校
+CREATE TABLE `wx_school` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `province` VARCHAR(16) NOT NULL COMMENT '省',
+  `city` VARCHAR(32) NOT NULL COMMENT '市',
+  `area` VARCHAR(32) NOT NULL COMMENT '区',
+  `address` VARCHAR(255) NOT NULL COMMENT '详细地址',
+  `person_num` VARCHAR(32) NOT NULL COMMENT '在校人数',
+  `bind_user_id` int(11) NOT NULL default 0 COMMENT '负责人',
+  `is_eleme_in_school` TINYINT(4) NOT NULL default 0 COMMENT '是否有饿了么校内站 0-无 1-有',
+  `is_eleme_out_school` TINYINT(4) NOT NULL default 0 COMMENT '是否有饿了么校外站 0-无 1-有',
+  `is_meituan_in_school` TINYINT(4) NOT NULL default 0 COMMENT '是否有美团校内站 0-无 1-有',
+  `is_meituan_out_school` TINYINT(4) NOT NULL default 0 COMMENT '是否有美团校外站 0-无 1-有',
+  `can_go_upstairs` TINYINT(4) NOT NULL default 0 COMMENT '是否能上楼 0-能 1-不能',
+  `is_cooperate` TINYINT(4) NOT NULL default 0 COMMENT '是否合作 0-无 1-有',
+  `can_ride` TINYINT(4) NOT NULL default 0 COMMENT '是否允许骑电动车 0-能 1-不能',
+  `dormitory_distribution` VARCHAR(1000) default '' COMMENT '宿舍分布情况',
+  `qucan_station_distribution` VARCHAR(1000) default '' COMMENT '校门口取餐点离宿舍情况',
+  `out_business_description` VARCHAR(1000) default '' COMMENT '校外商圈情况',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校表';
+
+CREATE TABLE `wx_school_contact` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `school_id` int(11) NOT NULL default 0 COMMENT '学校ID',
+  `phone` VARCHAR(20) NOT NULL COMMENT '手机号',
+  `weixin` VARCHAR(20) NOT NULL default '' COMMENT '微信号',
+  `position` VARCHAR(20) NOT NULL default '' COMMENT '职位',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  key `idx_school` (`school_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校联系人表';
+
+CREATE TABLE `wx_school_follow` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `school_id` int(11) NOT NULL default 0 COMMENT '学校ID',
+  `contact_id` int(11) NOT NULL default 0 COMMENT '学校联系人ID',
+  `user_id` int(11) NOT NULL default 0 COMMENT '跟进人ID',
+  `chat_imgs` text COMMENT '聊天图片',
+  `detail` text COMMENT '详情',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  key `idx_school_contact` (`school_id`, `contact_id`) using btree,
+  key `idx_user` (`user_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校跟进表';
+
+--------------------------------------- 学校食堂
+CREATE TABLE `wx_canteen` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `school_id` int(11) NOT NULL default 0 COMMENT '学校ID',
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `stall_num` int(11) NOT NULL default 0 COMMENT '档口数量',
+  `is_direct` TINYINT(4) NOT NULL default 0 COMMENT '是否直营 0-不是 1-是',
+  `stall_imgs` text COMMENT '档口照片',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  key `idx_school` (`school_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校食堂表';
+
+CREATE TABLE `wx_canteen_contact` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `canteen_id` int(11) NOT NULL default 0 COMMENT '食堂ID',
+  `school_id` int(11) NOT NULL default 0 COMMENT '学校ID',
+  `phone` VARCHAR(20) NOT NULL COMMENT '手机号',
+  `weixin` VARCHAR(20) NOT NULL default '' COMMENT '微信号',
+  `position` VARCHAR(20) NOT NULL default '' COMMENT '职位',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  key `idx_school` (`school_id`) using btree,
+  key `idx_canteen` (`canteen_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校食堂联系人表';
+
+CREATE TABLE `wx_canteen_follow` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `school_id` int(11) NOT NULL default 0 COMMENT '学校ID',
+  `canteen_id` int(11) NOT NULL default 0 COMMENT '食堂ID',
+  `user_id` int(11) NOT NULL default 0 COMMENT '跟进人ID',
+  `chat_imgs` text COMMENT '聊天图片',
+  `detail` text COMMENT '详情',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  key `idx_school` (`school_id`) using btree,
+  key `idx_canteen` (`canteen_id`) using btree,
+  key `idx_user` (`user_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='学校食堂跟进表';
+
+--------------------------------------- 餐饮公司
+CREATE TABLE `wx_company` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `province` VARCHAR(16) NOT NULL COMMENT '省',
+  `city` VARCHAR(32) NOT NULL COMMENT '市',
+  `area` VARCHAR(32) NOT NULL COMMENT '区',
+  `address` VARCHAR(255) NOT NULL COMMENT '详细地址',
+  `bind_user_id` int(11) NOT NULL default 0 COMMENT '负责人',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='餐饮公司表';
+
+CREATE TABLE `wx_companycontact` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `name` VARCHAR(20) NOT NULL COMMENT '名称',
+  `company_id` int(11) NOT NULL default 0 COMMENT '餐饮公司ID',
+  `phone` VARCHAR(20) NOT NULL COMMENT '手机号',
+  `weixin` VARCHAR(20) NOT NULL default '' COMMENT '微信号',
+  `position` VARCHAR(20) NOT NULL default '' COMMENT '职位',
+  `canteen_ids` VARCHAR(255) NOT NULL default '' COMMENT '食堂ID字符串(用逗号隔开)',
+  `memo` VARCHAR(255) default '' COMMENT '备注',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  `update_date` datetime  NOT NULL DEFAULT now() COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  key `idx_company` (`company_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='餐饮公司联系人表';;
+
+CREATE TABLE `wx_company_follow` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `company_id` int(11) NOT NULL default 0 COMMENT '餐饮公司ID',
+  `company_contact_id` int(11) NOT NULL default 0 COMMENT '餐饮公司联系人ID',
+  `user_id` int(11) NOT NULL default 0 COMMENT '跟进人ID',
+  `chat_imgs` text COMMENT '聊天图片',
+  `detail` text COMMENT '详情',
+  `create_date` datetime NOT NULL DEFAULT now() COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  key `idx_company` (`company_id`) using btree,
+  key `idx_user` (`user_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='餐饮公司跟进表';
+
+--------------------------------------- 餐饮公司和食堂关联表
+CREATE TABLE `wx_company_canteen_ relation` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `company_id` int(11) NOT NULL default 0 COMMENT '餐饮公司ID',
+  `canteen_id` int(11) NOT NULL default 0 COMMENT '食堂ID',
+  PRIMARY KEY (`id`),
+  key `idx_school` (`company_id`) using btree,
+  key `idx_canteen` (`canteen_id`) using btree
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci comment='餐饮公司和食堂关联表';

+ 2 - 2
web/src/typings/api.d.ts

@@ -101,7 +101,7 @@ declare namespace Api {
       roles?: string[]
       roles?: string[]
       sex: number
       sex: number
       role_name?: string
       role_name?: string
-      is_using?: 0 | 1
+      status?: 0 | 1
       avatar?: string
       avatar?: string
       descr?: string
       descr?: string
       email?: string
       email?: string
@@ -122,7 +122,7 @@ declare namespace Api {
       avatar: string
       avatar: string
       create_date: string
       create_date: string
       update_date: string
       update_date: string
-      is_using: '0' | '1' // 1-正常 0-拉黑
+      status: '0' | '1' // 1-正常 0-拉黑
       username: string
       username: string
       sex: '0' | '1' // 1-女 0-男
       sex: '0' | '1' // 1-女 0-男
       phone: string
       phone: string

+ 18 - 0
web/src/utils/http/index.ts

@@ -3,6 +3,7 @@ import { useUserStore } from '@/store/modules/user'
 import { ApiStatus } from './status'
 import { ApiStatus } from './status'
 import { HttpError, handleError, showError } from './error'
 import { HttpError, handleError, showError } from './error'
 import { $t } from '@/locales'
 import { $t } from '@/locales'
+import CryptoJS from 'crypto-js';
 
 
 /** 请求配置常量 */
 /** 请求配置常量 */
 const REQUEST_TIMEOUT = 15000
 const REQUEST_TIMEOUT = 15000
@@ -199,6 +200,23 @@ async function request<T = any>(config: ExtendedAxiosRequestConfig): Promise<T>
   }
   }
 }
 }
 
 
+/**
+ * 参数签名工具
+ * @param {Object} params 待签名参数对象
+ * @returns {string} MD5签名结果
+ */
+function getSign(params:Object) {
+  const filteredParams = Object.fromEntries(
+      Object.entries(params).filter(([_, v]) => v !== null && v !== undefined)
+  );
+  const sortedKeys = Object.keys(filteredParams).sort();
+  const queryString = sortedKeys
+      .map(key => `${key}=${filteredParams[key]}`)
+      .join('&');
+  console.log(`%c queryString == `, 'background:#41b883 ; padding:1px; color:#fff', queryString);
+  return CryptoJS.sha256(queryString).toString().toUpperCase();
+}
+
 /** API方法集合 */
 /** API方法集合 */
 const api = {
 const api = {
   get<T>(config: ExtendedAxiosRequestConfig) {
   get<T>(config: ExtendedAxiosRequestConfig) {

+ 1 - 59
web/src/views/auth/login/index.vue

@@ -43,18 +43,7 @@
             @keyup.enter="handleSubmit"
             @keyup.enter="handleSubmit"
             style="margin-top: 25px"
             style="margin-top: 25px"
           >
           >
-            <ElFormItem prop="account">
-              <ElSelect v-model="formData.account" @change="setupAccount" class="account-select">
-                <ElOption
-                  v-for="account in accounts"
-                  :key="account.key"
-                  :label="account.label"
-                  :value="account.key"
-                >
-                  <span>{{ account.label }}</span>
-                </ElOption>
-              </ElSelect>
-            </ElFormItem>
+
             <ElFormItem prop="username">
             <ElFormItem prop="username">
               <ElInput :placeholder="$t('login.placeholder[0]')" v-model.trim="formData.username" />
               <ElInput :placeholder="$t('login.placeholder[0]')" v-model.trim="formData.username" />
             </ElFormItem>
             </ElFormItem>
@@ -137,40 +126,6 @@
   import { useSettingStore } from '@/store/modules/setting'
   import { useSettingStore } from '@/store/modules/setting'
   import type { FormInstance, FormRules } from 'element-plus'
   import type { FormInstance, FormRules } from 'element-plus'
 
 
-  type AccountKey = 'super' | 'admin' | 'user'
-
-  export interface Account {
-    key: AccountKey
-    label: string
-    userName: string
-    password: string
-    roles: string[]
-  }
-
-  const accounts = computed<Account[]>(() => [
-    {
-      key: 'super',
-      label: t('login.roles.super'),
-      userName: 'lizhi',
-      password: '123456',
-      roles: ['R_SUPER']
-    },
-    {
-      key: 'admin',
-      label: t('login.roles.admin'),
-      userName: 'Admin',
-      password: '123456',
-      roles: ['R_ADMIN']
-    },
-    {
-      key: 'user',
-      label: t('login.roles.user'),
-      userName: 'User',
-      password: '123456',
-      roles: ['R_USER']
-    }
-  ])
-
   const settingStore = useSettingStore()
   const settingStore = useSettingStore()
   const { isDark } = storeToRefs(settingStore)
   const { isDark } = storeToRefs(settingStore)
 
 
@@ -185,7 +140,6 @@
   const formRef = ref<FormInstance>()
   const formRef = ref<FormInstance>()
 
 
   const formData = reactive({
   const formData = reactive({
-    account: '',
     username: '',
     username: '',
     password: '',
     password: '',
     rememberPassword: true
     rememberPassword: true
@@ -198,18 +152,6 @@
 
 
   const loading = ref(false)
   const loading = ref(false)
 
 
-  onMounted(() => {
-    setupAccount('super')
-  })
-
-  // 设置账号
-  const setupAccount = (key: AccountKey) => {
-    const selectedAccount = accounts.value.find((account: Account) => account.key === key)
-    formData.account = key
-    formData.username = selectedAccount?.userName ?? ''
-    formData.password = selectedAccount?.password ?? ''
-  }
-
   // 登录
   // 登录
   const handleSubmit = async () => {
   const handleSubmit = async () => {
     if (!formRef.value) return
     if (!formRef.value) return

+ 2 - 2
web/src/views/system/user/index.vue

@@ -132,10 +132,10 @@
           formatter: (row) => row.sex ? '女' : '男'
           formatter: (row) => row.sex ? '女' : '男'
         },
         },
         {
         {
-          prop: 'is_using',
+          prop: 'status',
           label: '状态',
           label: '状态',
           formatter: (row) => {
           formatter: (row) => {
-            const statusConfig = getUserStatusConfig(row.is_using)
+            const statusConfig = getUserStatusConfig(row.status)
             return h(ElTag, { type: statusConfig.type }, () => statusConfig.text)
             return h(ElTag, { type: statusConfig.type }, () => statusConfig.text)
           }
           }
         },
         },