Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
070391f2
Commit
070391f2
authored
Nov 21, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推广
parent
7ab06c84
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
0 deletions
+150
-0
SpreadUser.php
application/api_broker/controller/SpreadUser.php
+100
-0
Basic.php
application/api_broker/extend/Basic.php
+1
-0
USpreadUser.php
application/model/USpreadUser.php
+49
-0
No files found.
application/api_broker/controller/SpreadUser.php
0 → 100644
View file @
070391f2
<?php
namespace
app\api_broker\controller
;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2018-11-21
* Time: 10:43:58
*/
use
app\api_broker\extend\Basic
;
use
app\model\USpreadUser
;
use
think\Request
;
class
SpreadUser
extends
Basic
{
protected
$uSpreadUser
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
uSpreadUser
=
new
USpreadUser
();
}
/**
* 推广手机号码记录
* User: 朱伟
* Date: 2018-11-21
* Time: 10:43:58
*/
public
function
addSpreadUser
(){
$params
=
$this
->
params
;
$user_ip
=
$this
->
ip
();
$params
=
array
(
"type"
=>
1
,
"phone"
=>
18112347151
,
"ip"
=>
$user_ip
);
if
(
!
isset
(
$params
[
"phone"
])
or
!
isset
(
$params
[
"ip"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
//先判断是否已经存在数据
$field
=
'phone,ip,create_time'
;
$where
[
'ip'
]
=
$params
[
"ip"
];
$where_or
[
'phone'
]
=
$params
[
"phone"
];
$res
=
$this
->
uSpreadUser
->
getSpreadUser
(
$field
,
$where
,
$where_or
);
if
(
$res
){
//如果存在
dump
(
$res
);
if
(
$res
){
}
else
{
}
return
$this
->
response
(
"101"
,
"30分钟内不允许重复提交"
);
}
else
{
//不存在则新增数据
$insert
[
"phone"
]
=
$params
[
'phone'
];
$insert
[
"ip"
]
=
$params
[
'ip'
];
$insert
[
"type"
]
=
$params
[
'type'
];
$res
=
$this
->
uSpreadUser
->
saveSpreadUser
(
$insert
);
//int(1)
}
if
(
$res
)
{
return
$this
->
response
(
"200"
,
"成功"
);
}
else
{
return
$this
->
response
(
"101"
,
"失败"
);
}
}
public
function
ip
()
{
//strcasecmp 比较两个字符,不区分大小写。返回0,>0,<0。
if
(
getenv
(
'HTTP_CLIENT_IP'
)
&&
strcasecmp
(
getenv
(
'HTTP_CLIENT_IP'
),
'unknown'
))
{
$ip
=
getenv
(
'HTTP_CLIENT_IP'
);
}
elseif
(
getenv
(
'HTTP_X_FORWARDED_FOR'
)
&&
strcasecmp
(
getenv
(
'HTTP_X_FORWARDED_FOR'
),
'unknown'
))
{
$ip
=
getenv
(
'HTTP_X_FORWARDED_FOR'
);
}
elseif
(
getenv
(
'REMOTE_ADDR'
)
&&
strcasecmp
(
getenv
(
'REMOTE_ADDR'
),
'unknown'
))
{
$ip
=
getenv
(
'REMOTE_ADDR'
);
}
elseif
(
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
&&
$_SERVER
[
'REMOTE_ADDR'
]
&&
strcasecmp
(
$_SERVER
[
'REMOTE_ADDR'
],
'unknown'
))
{
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
$res
=
preg_match
(
'/[\d\.]{7,15}/'
,
$ip
,
$matches
)
?
$matches
[
0
]
:
''
;
return
$res
;
//dump(phpinfo());//所有PHP配置信息
}
}
\ No newline at end of file
application/api_broker/extend/Basic.php
View file @
070391f2
...
@@ -58,6 +58,7 @@ class Basic extends Controller
...
@@ -58,6 +58,7 @@ class Basic extends Controller
'broker/getBusinessAll'
,
'broker/getBusinessAll'
,
"broker/getSiteListApp"
,
"broker/getSiteListApp"
,
"broker/addUserCallAgentV2"
,
"broker/addUserCallAgentV2"
,
"broker/addSpreadUser"
,
);
);
/**
/**
...
...
application/model/USpreadUser.php
0 → 100755
View file @
070391f2
<?php
namespace
app\model
;
use
think\Db
;
use
think\Model
;
class
USpreadUser
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'u_spread_user'
;
public
function
saveSpreadUser
(
$data
)
{
$time
=
date
(
"Y-m-d H:i:s"
,
time
());
$data
[
'create_time'
]
=
$time
;
$data
[
'update_time'
]
=
$time
;
return
$this
->
insert
(
$data
);
}
/**
* 查询数据
* 朱伟 2018-11-21 10:41:44
*/
public
function
getSpreadUser
(
$field
,
$params
,
$where_or
)
{
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
//->alias('a')
->
where
(
$params
)
->
whereOr
(
$where_or
)
->
select
();
echo
$this
->
getLastSql
();
return
$result
;
}
/**
* 更新数据
* 朱伟 2018-11-21 10:41:44
*/
public
function
updateSpreadUser
(
$params
)
{
$result
=
$this
->
update
(
$params
);
//dump($this->getLastSql());
return
$result
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment