Commit 9a91f1b2 authored by hujun's avatar hujun

新增客户验证器

parent 47bd27e6
......@@ -10,6 +10,7 @@ namespace app\index\service;
use app\api_broker\service\PushMessageService;
use app\index\validate\MemberValidate;
use app\model\AAgents;
use app\model\GOperatingRecords;
use app\model\Users;
......@@ -37,6 +38,13 @@ class UserService
*/
public function editUser($id, $data, $operation_id)
{
$validate = new MemberValidate();
if (!$validate->scene('add')->check($data)) {
$result['status'] = 'fail';
$result['msg'] = $validate->getError();
return $result;
}
$this->operation_id = $operation_id;
$result = [];
$agent_id_old = $referrer_id_old = $referrer_source_old = 0;
......
......@@ -6,24 +6,47 @@ use think\Validate;
/**
* Created by PhpStorm.
* User: zhuwei
* User: zhu wei
* Date: 2018/8/29
* Time: 上午11:02
*/
class MemberValidate extends Validate
{
protected $regex = [ 'phone' => '/^1[23456789]{1}\d{9}$/' ];
protected $rule = [
'agent_id_for_bind' => 'require|number|gt:0'
'agent_id_for_bind' => 'require|number|gt:0',
'user_nick' => 'length:0,80',
'user_name' => 'length:0,80',
'user_phone' => 'require|regex:phone',
'user_pswd' => 'length:0,255',
'sex' => 'in:0,1,2',
'referrer_source' => 'in:10,20',
'source' => 'in:10,20,30',
'source_intro'=>'in:0,1,2,3,4,5,6,7',
'user_status'=>'in:0,1,-1',
'user_label' => 'in:0,1,2',
];
protected $message = [
'agent_id_for_bind.require' => 'agent_id_for_bind为必填字段',
'agent_id_for_bind.number' => 'agent_id_for_bind只能为数字',
'agent_id_for_bind.gt' => 'agent_id_for_bind必须大于0',
'agent_id_for_bind.require' => 'agent_id_for_bind为必填字段',
'agent_id_for_bind.number' => 'agent_id_for_bind只能为数字',
'agent_id_for_bind.gt' => 'agent_id_for_bind必须大于0',
'user_nick.length' => '名字字数超过限制',
'user_name.length' => '名字字数超过限制',
'user_phone.require' => '手机号必填',
'user_phone.regex' => '手机号格式错误',
'user_pswd.length' => '密码长度超过限制',
'sex.in' => '性别参数错误',
'referrer_source.in' => '邀请来源参数错误',
'source.in'=>'注册来源参数错误',
'source_intro.in' => '来源简述参数错误',
'user_status.in' => '客户状态参数错误',
'user_label.in' => '用户标签'
];
protected $scene = [
'getUserList' => [ 'agent_id_for_bind' ],
'getUserList' => [ 'agent_id_for_bind' ],
'add' => 'user_phonp,user_name,user_nick,user_pswd,sex,referrer_source,source,source_intro,user_status,user_label'
];
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment