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
c141c95d
Commit
c141c95d
authored
Oct 17, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增编辑经纪人
parent
9a69d1e8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
226 additions
and
0 deletions
+226
-0
BrokerService.php
application/index/service/BrokerService.php
+53
-0
AAgentValidate.php
application/index/validate/AAgentValidate.php
+66
-0
AAgents.php
application/model/AAgents.php
+107
-0
No files found.
application/index/service/BrokerService.php
0 → 100644
View file @
c141c95d
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/10/17
* Time: 14:48
*/
namespace
app\index\service
;
use
app\index\validate\AAgentValidate
;
use
app\model\AAgents
;
class
BrokerService
{
public
$m_agent
;
public
function
__construct
()
{
$this
->
m_agent
=
new
AAgents
();
}
/**
* 新增或编辑经纪人
*
* @param array $data
* @param int $operation_id
* @return mixed
*/
public
function
saveAgentData
(
array
$data
,
int
$operation_id
)
{
$result
[
'status'
]
=
'fail'
;
$validate
=
new
AAgentValidate
();
$check
=
$validate
->
scene
(
'add'
)
->
check
(
$data
);
if
(
!
$check
)
{
$result
[
'msg'
]
=
$validate
->
getError
();
return
$result
;
}
$id
=
$this
->
m_agent
->
saveAgent
(
$data
);
if
(
$id
>
0
)
{
$result
[
'status'
]
=
'successful'
;
$result
[
'data'
]
=
[
'id'
=>
$id
];
}
else
{
$result
[
'msg'
]
=
'新增或编辑失败'
;
}
return
$result
;
}
}
\ No newline at end of file
application/index/validate/AAgentValidate.php
0 → 100644
View file @
c141c95d
<?php
/**
* Created by PhpStorm.
* User: 43897
* Date: 2018/10/17
* Time: 14:50
*/
namespace
app\index\validate
;
use
think\Validate
;
class
AAgentValidate
extends
Validate
{
protected
$rule
=
[
'id'
=>
'require|between:1,9999999999'
,
'device_id'
=>
'require|length:1,50'
,
'store_id'
=>
'require|between:1,9999999999'
,
'auth_group_id'
=>
'require|between:1,9999999999'
,
'district_id'
=>
'require|between:1,9999999999'
,
'level'
=>
'require|in:10,20,30,40'
,
'name'
=>
'require|length:1,60'
,
'phone'
=>
'require|length:1,20'
,
'password'
=>
'require|length:1,50'
,
'sex'
=>
'require|in:0,1,2'
,
'img'
=>
'length:1,255'
,
'status'
=>
'require|in:0,1,2,3'
,
'inviter_id'
=>
'between:1,9999999999'
,
'admin_off'
=>
'require|in:0,1'
,
'remarks'
=>
'length:0,255'
,
];
protected
$message
=
[
'id.require'
=>
'缺少id'
,
'id.between'
=>
'id参数错误'
,
'device_id.require'
=>
'缺少设备id'
,
'device_id.length'
=>
'设备id参数错误'
,
'store_id.require'
=>
'缺少门店id'
,
'store_id.between'
=>
'门店id参数错误'
,
'district_id.require'
=>
'缺少部门id'
,
'district_id.between'
=>
'部门id错误'
,
'auth_group_id.require'
=>
'缺少角色id'
,
'auth_group_id.between'
=>
'角色id参数错误'
,
'level.require'
=>
'用户等级'
,
'level.in'
=>
'用户等级参数错误'
,
'name.require'
=>
'名字必填'
,
'name.length'
=>
'名字参数错误'
,
'phone.require'
=>
'手机号必填'
,
'phone.length'
=>
'手机参数错误'
,
'password.require'
=>
'手机号必填'
,
'password.length'
=>
'手机参数错误'
,
'sex.require'
=>
'缺少性别'
,
'sex.in'
=>
'性别参数错误'
,
'img.length'
=>
'头像参数错误'
,
'status.require'
=>
'缺少用户状态'
,
'status.in'
=>
'用户状态错误'
,
'inviter_id.between'
=>
'邀请人id参数错误'
,
'admin_off.require'
=>
'缺少访问后台参数'
,
'admin_off.in'
=>
'访问后台参数参数错误'
,
'remarks.length'
=>
'备注参数错误'
];
protected
$scene
=
[
'add'
=>
'name,phone,store_id,district_id,level,password,sex,status,admin_off'
];
}
\ No newline at end of file
application/model/AAgents.php
View file @
c141c95d
...
@@ -1256,4 +1256,110 @@ class AAgents extends BaseModel
...
@@ -1256,4 +1256,110 @@ class AAgents extends BaseModel
->
where
(
$where
)
->
where
(
$where
)
->
select
();
->
select
();
}
}
/**
* @param $params
* @return int|string
*/
public
function
saveAgent
(
$params
)
{
$save_data
=
[];
//设备id
if
(
!
empty
(
$params
[
'device_id'
]))
{
$save_data
[
'device_id'
]
=
$params
[
'device_id'
];
}
//门店id
if
(
!
empty
(
$params
[
'store_id'
]))
{
$save_data
[
'store_id'
]
=
$params
[
'store_id'
];
}
//角色id
if
(
!
empty
(
$params
[
'auth_group_id'
]))
{
$save_data
[
'auth_group_id'
]
=
$params
[
'auth_group_id'
];
}
//部门id
if
(
!
empty
(
$params
[
'district_id'
]))
{
$save_data
[
'district_id'
]
=
$params
[
'district_id'
];
}
//部门id
if
(
!
empty
(
$params
[
'district_id'
]))
{
$save_data
[
'district_id'
]
=
$params
[
'district_id'
];
}
//等级 10业务员 20店长 30总监 40店长和总监
if
(
!
empty
(
$params
[
'level'
]))
{
$save_data
[
'level'
]
=
$params
[
'level'
];
}
//业务员姓名
if
(
!
empty
(
$params
[
'name'
]))
{
$save_data
[
'level'
]
=
$params
[
'level'
];
}
//业务员手机号
if
(
!
empty
(
$params
[
'phone'
]))
{
$save_data
[
'phone'
]
=
$params
[
'phone'
];
}
//密码
if
(
!
empty
(
$params
[
'password'
]))
{
$save_data
[
'password'
]
=
md5
(
$params
[
'password'
]);
}
//性别 0保密 1男 2女
if
(
isset
(
$params
[
'sex'
]))
{
$save_data
[
'sex'
]
=
$params
[
'sex'
];
}
//头像
if
(
!
empty
(
$params
[
'img'
]))
{
$save_data
[
'img'
]
=
$params
[
'img'
];
}
//账号状态,0正常 1冻结 2离职 3转勤
if
(
isset
(
$params
[
'status'
]))
{
$save_data
[
'status'
]
=
$params
[
'status'
];
}
//邀请人id
if
(
!
empty
(
$params
[
'inviter_id'
]))
{
$save_data
[
'inviter_id'
]
=
$params
[
'inviter_id'
];
}
//0可以访问后台,1不可以
if
(
!
empty
(
$params
[
'admin_off'
]))
{
$save_data
[
'admin_off'
]
=
$params
[
'admin_off'
];
}
//备注
if
(
!
empty
(
$params
[
'remarks'
]))
{
$save_data
[
'remarks'
]
=
$params
[
'remarks'
];
}
//ip存入数字 php ip2long和long2ip转换
if
(
!
empty
(
$params
[
'last_login_ip'
]))
{
$save_data
[
'last_login_ip'
]
=
$params
[
'last_login_ip'
];
}
//最后登录时间
if
(
!
empty
(
$params
[
'last_login_time'
]))
{
$save_data
[
'last_login_time'
]
=
$params
[
'last_login_time'
];
}
//离职日期
if
(
!
empty
(
$params
[
'quit_time'
]))
{
$save_data
[
'quit_time'
]
=
$params
[
'quit_time'
];
}
if
(
empty
(
$params
[
'id'
]))
{
$id
=
$this
->
insertGetId
(
$save_data
);
}
else
{
$num
=
$this
->
where
(
'id'
,
$params
[
'id'
])
->
update
(
$save_data
);
$id
=
$num
>
0
?
$params
[
'id'
]
:
0
;
}
return
$id
;
}
}
}
\ No newline at end of file
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