Commit cc2e279b authored by hujun's avatar hujun

新增经纪人重写

parent 2c481061
......@@ -116,42 +116,58 @@ class Agent extends Basic
* @throws \think\exception\DbException
*/
public function saveAgent(){
$group_id = $this->request->param('id');
$table = new AAgents();
$m_agent = new AAgents();
if ($this->request->isPost()) {
$data = input('post.');
//新增或者编辑数据
if(empty($data['id'])) {
if(empty($this->params['id'])) {
$data['create_time'] = date( 'Y-m-d H:i:s',time());
$data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = '';
$id = 0;
} else {
$data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = $data['id'];
$id = $this->params['id'];
}
//判断name是否重复
if($table->repetition('phone',$data['phone']) && empty($id)) {
return $this->response(100, '存在重复值');
if(empty($id)) {
$num = $m_agent->getListDistrictTotal(['phone'=> $this->params['phone']]);
if ($num > 0) {
return $this->response(101, '手机号重复');
}
}
if (empty($this->params['store_id'])) {
return $this->response(100, '门店id为空!');
return $this->response(101, '门店id为空!');
}
$store = new AStore();
$data['district_id'] = $store->getStoreKeyById('district_id', ['id'=>$this->params['store_id']]);
$data['password'] = md5(substr($data['phone'], -6));
if ($table->editData($data,$id)) {
if (empty($data['password'])) {
$data['password'] = md5(substr($this->params['password'], -6));
} else {
$data['password'] = md5($this->params['password']);
}
$data['name'] = trim($this->params['name']);
$data['store_id'] = $this->params['store_id'];
$data['phone'] = trim($this->params['phone']);
$data['admin_off'] = $this->params['admin_off'];
$data['sex'] = $this->params['sex'];
$data['remarks'] = $this->params['remarks'];
$data['auth_group_id'] = $this->params['auth_group_id'];
dump($this->params);die;
if ($m_agent->editData($data, $id)) {
return $this->response(200, '成功');
} else {
return $this->response(100, '无修改');
return $this->response(101, '无修改');
}
} else {
//查看
$info = $table->where('id',$group_id)->find();
$info = $m_agent->where('id',$group_id)->find();
return $this->response(200, '查看', $info);
}
}
......
This diff is collapsed.
......@@ -98,28 +98,6 @@ class AAgents extends BaseModel
return $data;
}
/**检查重复
* @param $name
* @param $key
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function repetition($name, $key)
{
$r = $this->field($name)
->where($name, '=', $key)
->select();
//$this->getLastSql();
if ($r) {
return true;
} else {
return false;
}
}
//更新数据
public function saveStatus($name, $key, $ids)
{
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
[% }else{ %]
<a class="btn1 btn-default" data-toggle="modal" data-id='[%= it[item]["id"] %]'>离职</a>
[% } %]
<a href="#modal-user" class="btn1 btn-danger" href="#modal-edit" data-toggle="modal" data-id='[%= it[item]["id"] %]'>角色设置</a>
</td>
</tr>
[% } %]
......
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