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
e67e7d01
Commit
e67e7d01
authored
Jun 07, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work
parent
2bb1488f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
18 deletions
+92
-18
WxSdk.php
application/api/controller/WxSdk.php
+34
-7
UWxInfoValidate.php
application/api/validate/UWxInfoValidate.php
+10
-5
UWxInfo.php
application/model/UWxInfo.php
+44
-6
route.php
application/route.php
+4
-0
No files found.
application/api/controller/WxSdk.php
View file @
e67e7d01
<?php
namespace
app\api\controller
;
/**
* 微信jsSdk
* Created by zw.
...
...
@@ -10,21 +12,46 @@ namespace app\api\controller;
*/
use
app\api\extend\Basic
;
use
think\Request
;
use
app\model\UWxInfo
;
use
think\Exception
;
class
WxSdk
extends
Basic
{
private
$wxInfoModel
;
public
function
__construct
(
$request
=
null
)
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
wxInfoModel
=
new
UWxInfo
();
}
public
function
saveWxInfo
(){
$params
=
$this
->
params
;
$params
=
array
(
"wang"
);
public
function
saveWxInfo
()
{
$params
=
$this
->
params
;
/* $params = array(
"wx_open_id" => "123132123123123",
"buyer_nick" => "123123123",
"buyer_img" => "123123123",
"sex" => 1,
"province" => "123123123",
"city" => "123123123",
"source" => 1,// 0:h5邀请 1安卓 2苹果',
);*/
$checkResult
=
$this
->
validate
(
$params
,
"UWxInfoValidate.add"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
try
{
$id
=
$this
->
wxInfoModel
->
addWxInfo
(
$params
);
if
(
$id
>
0
){
return
$this
->
response
(
"200"
,
"request success"
,[
"id"
=>
$id
]);
}
}
catch
(
Exception
$exception
){
return
$this
->
response
(
"101"
,
"request error:"
.
$exception
);
}
}
}
application/api/validate/UWxInfoValidate.php
View file @
e67e7d01
...
...
@@ -14,18 +14,22 @@ use think\Validate;
class
UWxInfoValidate
extends
Validate
{
protected
$rule
=
[
'wx_open_id'
=>
'require'
,
'wx_open_id'
=>
'require
|length:10,50
'
,
'sex'
=>
'require|number'
,
'source'
=>
'require|number'
,
];
protected
$message
=
[
'wx_open_id.require'
=>
'微信open_id不能为空'
,
'sex.require'
=>
'性别为必须字段'
,
'sex.number'
=>
'性别必须是数字'
,
'wx_open_id.require'
=>
'微信open_id不能为空'
,
'wx_open_id.length:10,50'
=>
'微信open_id错误'
,
'sex.require'
=>
'性别为必须字段'
,
'sex.number'
=>
'性别必须是数字'
,
'source.require'
=>
'来源为必须字段'
,
'source.number'
=>
'来源必须是数字'
,
];
protected
$scene
=
[
'add'
=>
[
'wx_open_id'
,
'sex'
],
'add'
=>
[
'wx_open_id'
,
'sex'
,
'source'
],
'select'
=>
[
'wx_open_id'
],
];
}
\ No newline at end of file
application/model/UWxInfo.php
View file @
e67e7d01
<?php
namespace
app\model
;
use
app\api\validate\UWxInfoValidate
;
/**
* Created by PhpStorm.
...
...
@@ -9,17 +9,55 @@ use app\api\validate\UWxInfoValidate;
* Time : 17:14
* Intro:
*/
class
UWxInfo
extends
Model
{
use
think\Db
;
use
think\Exception
;
use
think\Model
;
class
UWxInfo
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'u_wx_info'
;
private
$validate_
;
public
function
__construct
()
{
$this
->
validate_
=
new
UWxInfoValidate
();
}
public
function
addWxInfo
(
$params
){
$this
->
validate_
->
validate
/**
* 新增微信拉取用户信息
* @param $params
* @return int|string
* @throws Exception
*/
public
function
addWxInfo
(
$params
)
{
$wxBin
=
$this
->
wxInfoBin
(
$params
);
Db
::
startTrans
();
try
{
$id
=
$this
->
insertGetId
(
$wxBin
);
Db
::
commit
();
return
$id
;
}
catch
(
Exception
$exception
){
Db
::
rollback
();
throw
$exception
;
}
}
private
function
wxInfoBin
(
$params
)
{
$arr
=
[];
if
(
isset
(
$params
[
"id"
]))
{
$arr
[
"wx_open_id"
]
=
$params
[
"id"
];
}
$arr
[
"wx_open_id"
]
=
$params
[
"wx_open_id"
];
$arr
[
"buyer_nick"
]
=
$params
[
"buyer_nick"
];
$arr
[
"buyer_img"
]
=
$params
[
"buyer_img"
];
$arr
[
"sex"
]
=
$params
[
"sex"
];
$arr
[
"province"
]
=
$params
[
"province"
];
$arr
[
"city"
]
=
$params
[
"city"
];
$arr
[
"source"
]
=
$params
[
"source"
];
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
return
$arr
;
}
}
application/route.php
View file @
e67e7d01
...
...
@@ -241,6 +241,7 @@ Route::group('index', [
'test'
=>
[
'index/WxTest/test'
,
[
'method'
=>
'POST|GET'
]
],
//wx
]);
...
...
@@ -316,6 +317,9 @@ Route::group('api', [
'houseTable'
=>
[
'api/TransferHouseInfo/table'
,
[
'method'
=>
'post|get'
]
],
//转商铺表
'houseImgTable'
=>
[
'api/TransferHouseInfo/houseImg'
,
[
'method'
=>
'post|get'
]
],
//转楼盘表
'agentHouse'
=>
[
'api/TransferHouseInfo/agentHouse'
,
[
'method'
=>
'post|get'
]
],
//转楼盘表
'saveWxInfo'
=>
[
'api/WxSdk/saveWxInfo'
,
[
'method'
=>
'POST|GET'
]
],
//wx
]);
Route
::
group
(
'chat'
,
[
...
...
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