基础配置与底层修改
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-09-30 17:32:46
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-11-11 17:24:20
|
||||
* @LastEditTime: 2020-11-17 10:15:51
|
||||
*/
|
||||
|
||||
return [
|
||||
@@ -27,7 +27,21 @@ return [
|
||||
'port' => 3306,
|
||||
'dbname' => 'hualianyun',
|
||||
'username' => 'root',
|
||||
'password' => '123456789'
|
||||
'password' => '123456789',
|
||||
],
|
||||
// 线上数据库连接
|
||||
'formal_db' => [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'dbname' => 'hualianyun',
|
||||
'username' => 'root',
|
||||
'password' => 'qaz123!@#',
|
||||
],
|
||||
//线上地址
|
||||
'formal_origin' => [
|
||||
'http://www.juip.com',
|
||||
'http://juip.com',
|
||||
'http://hl957admin.juip.com',
|
||||
],
|
||||
// 跨域请求
|
||||
'origin' => [
|
||||
@@ -45,5 +59,5 @@ return [
|
||||
'app_crt' => APP_PATH . 'config/alicrts/appCertPublicKey_2021002102631089.crt',
|
||||
'root_crt' => APP_PATH . 'config/alicrts/alipayRootCert.crt',
|
||||
'public_crt' => APP_PATH . 'config/alicrts/alipayCertPublicKey_RSA2.crt',
|
||||
]
|
||||
],
|
||||
];
|
||||
40
enum/user/User.php
Normal file
40
enum/user/User.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-22 15:35:49
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-11-16 11:42:15
|
||||
*/
|
||||
namespace enum\user;
|
||||
|
||||
class User
|
||||
{
|
||||
// 1待跟进-未购买 2跟进超时-未购买 3待跟进-消费减少 4跟进超时-消费减少 5流失-需求减少 6流失-暂时不用 7流失-价格问题 8流失-产品问题 9流失-也可自定义 10高意向客户 11已完成
|
||||
public static $FollowStatus = [
|
||||
1 => '待跟进-未购买',
|
||||
2 => '跟进超时-未购买',
|
||||
3 => '待跟进-消费减少',
|
||||
4 => '跟进超时-消费减少',
|
||||
5 => '流失-需求减少',
|
||||
6 => '流失-暂时不用',
|
||||
7 => '流失-价格问题',
|
||||
8 => '流失-产品问题',
|
||||
9 => '流失-也可自定义',
|
||||
10 => '高意向客户',
|
||||
11 => '已完成',
|
||||
];
|
||||
|
||||
public static function getFormatList($arr)
|
||||
{
|
||||
$format_list = [];
|
||||
foreach ($arr as $k => $v) {
|
||||
$data['value'] = $k;
|
||||
$data['label'] = $v;
|
||||
$format_list[] = $data;
|
||||
}
|
||||
return $format_list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,7 +136,15 @@ class Fastphp
|
||||
//配置数据库信息
|
||||
public function setDbConfig()
|
||||
{
|
||||
if (isset($this->config['db'])) {
|
||||
$formal_origin = $this->config['formal_origin']; //跨域访问的时候才会存在此字段
|
||||
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
|
||||
if (in_array($origin, $formal_origin)) {
|
||||
define('DB_HOST', $this->config['formal_db']['host']);
|
||||
define('DB_PORT', $this->config['formal_db']['port']);
|
||||
define('DB_NAME', $this->config['formal_db']['dbname']);
|
||||
define('DB_USER', $this->config['formal_db']['username']);
|
||||
define('DB_PASS', $this->config['formal_db']['password']);
|
||||
} else {
|
||||
define('DB_HOST', $this->config['db']['host']);
|
||||
define('DB_PORT', $this->config['db']['port']);
|
||||
define('DB_NAME', $this->config['db']['dbname']);
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-09-30 17:32:46
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-11-12 19:17:36
|
||||
*/
|
||||
|
||||
namespace fastphp\base;
|
||||
|
||||
@@ -30,8 +38,12 @@ class Controller
|
||||
$getPayload=$jwt->verifyToken($token);
|
||||
|
||||
} else {
|
||||
if(isset($_SERVER['HTTP_TOKEN'])){
|
||||
$jwt = new Jwt('etor_yh_lzh_20f_2020_YES');
|
||||
$getPayload=$jwt->verifyToken($_SERVER['HTTP_TOKEN']);
|
||||
} else {
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2020-09-30 17:32:46
|
||||
* @LastEditTime: 2020-10-26 10:33:22
|
||||
* @LastEditTime: 2020-11-16 16:09:31
|
||||
* @LastEditors: kangkang
|
||||
* @Description: In User Settings Edit
|
||||
* @FilePath: /phptest/fastphp/base/Model.php
|
||||
@@ -40,6 +40,16 @@ class Model extends Sql
|
||||
return $this->field('count(1) as count')->where($where)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取所有的列表
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
*/
|
||||
public function getList($where = [],$fields = '*', $order = 'id desc')
|
||||
{
|
||||
return $this->field($fields)->where($where)->order($order)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照页数获取数据
|
||||
* @param $fields 'id,count(1)...'
|
||||
@@ -59,7 +69,7 @@ class Model extends Sql
|
||||
*/
|
||||
public function getOne($where = [], $fields = '*')
|
||||
{
|
||||
return $this->field($fields)->where($where)->limit('1')->fetch();
|
||||
return $this->field($fields)->where($where)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +77,9 @@ class Model extends Sql
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
*/
|
||||
public function getNewOne($fields = '*'){
|
||||
return $this->field($fields)->order('id desc')->limit(1)->fetch();
|
||||
public function getNewOne($fields = '*')
|
||||
{
|
||||
return $this->field($fields)->order('id desc')->fetch();
|
||||
}
|
||||
/**
|
||||
* @description: 更新一条数据
|
||||
|
||||
@@ -39,11 +39,12 @@ class Sql
|
||||
$this->filter .= $where;
|
||||
} else {
|
||||
$flag = true;
|
||||
$ins = ['in', 'IN', 'not in', 'NOT IN'];
|
||||
foreach ($where as $key => $value) {
|
||||
if ($flag) {
|
||||
$flag = false;
|
||||
if (is_array($value)) {
|
||||
if($value[0] == 'in'){
|
||||
if (in_array($value[0], $ins)) {
|
||||
$this->filter .= ' `' . $key . '` ' . $value[0] . '(' . implode(',', $value[1]) . ')';
|
||||
} else {
|
||||
$param_key = $this->paramIsExit($key, $this->param);
|
||||
@@ -56,7 +57,7 @@ class Sql
|
||||
}
|
||||
} else {
|
||||
if (is_array($value)) {
|
||||
if($value[0] == 'in'){
|
||||
if (in_array($value[0], $ins)) {
|
||||
$this->filter .= ' AND `' . $key . '` ' . $value[0] . '(' . implode(',', $value[1]) . ')';
|
||||
} else {
|
||||
$param_key = $this->paramIsExit($key, $this->param);
|
||||
@@ -74,7 +75,8 @@ class Sql
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function paramIsExit($key,$param){
|
||||
public function paramIsExit($key, $param)
|
||||
{
|
||||
if (!isset($param[$key])) {
|
||||
return $key;
|
||||
} else {
|
||||
@@ -103,11 +105,11 @@ class Sql
|
||||
* @return $this
|
||||
* $group=['sex','name']
|
||||
*/
|
||||
public function group($group = [])
|
||||
public function group($group = [], $having = '')
|
||||
{
|
||||
if ($group) {
|
||||
$this->filter .= ' GROUP BY ';
|
||||
$this->filter .= ' ' . implode(' ,', $group) . ' ';
|
||||
$this->filter .= ' ' . implode(' ,', $group) . ' ' . $having . ' ';
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -159,7 +161,7 @@ class Sql
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$sql = sprintf('SELECT %s FROM `%s` %s', $this->field, $this->table, $this->filter);
|
||||
$sql = sprintf('SELECT %s FROM `%s` %s LIMIT 1', $this->field, $this->table, $this->filter);
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
@@ -176,7 +178,7 @@ class Sql
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$sql = sprintf('DELETE FROM `%s` %s', $this->table, $this->filter);
|
||||
$sql = sprintf('DELETE FROM `%s` %s LIMIT 1', $this->table, $this->filter);
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
@@ -225,7 +227,7 @@ class Sql
|
||||
$sql = sprintf('UPDATE `%s` SET %s %s', $this->table, $this->formatUpdate($data), $this->filter);
|
||||
$this->filter = '';
|
||||
$sth = Db::pdo()->prepare($sql);
|
||||
$sth = $this->formatParam($sth, $data);
|
||||
$sth = $this->formatUpdateParam($sth, $data);
|
||||
$sth = $this->formatParam($sth, $this->param);
|
||||
$this->param = [];
|
||||
$sth->execute();
|
||||
@@ -248,6 +250,20 @@ class Sql
|
||||
return $sth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定具体变量值update
|
||||
* @param PDOStatement $sth
|
||||
* @param array $params
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public function formatUpdateParam(PDOStatement $sth, $params = [])
|
||||
{
|
||||
foreach ($params as $param => &$value) {
|
||||
$param = ':' . ltrim($param, ':').'update';
|
||||
$sth->bindParam($param, $value);
|
||||
}
|
||||
return $sth;
|
||||
}
|
||||
/**
|
||||
* 将数组转化为插入格式的sql语句
|
||||
* @param $data
|
||||
@@ -295,8 +311,8 @@ class Sql
|
||||
{
|
||||
$fields = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$fields[] = sprintf('`%s`=:%s', $key, $key);
|
||||
$this->param[$key] = $value;
|
||||
$fields[] = sprintf('`%s`=:%s', $key, $key.'update');
|
||||
$this->param[$key.'update'] = $value;
|
||||
}
|
||||
return implode(',', $fields);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-09-30 17:32:46
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-10-16 11:14:25
|
||||
* @LastEditTime: 2020-11-14 10:35:30
|
||||
*/
|
||||
/**
|
||||
* 浏览器友好的变量输出
|
||||
|
||||
Reference in New Issue
Block a user