|
|
@ -48,19 +48,23 @@ class Partner extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
public function add(PartnerRoleValidate $validate) |
|
|
|
public function add(PartnerRoleValidate $validate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', 'area_id', ['status', 1]]); |
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', |
|
|
|
|
|
|
|
'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id']); |
|
|
|
$validate->check($data); |
|
|
|
$validate->check($data); |
|
|
|
if ($this->repository->fieldExists('area_id', $data['area_id'])) { |
|
|
|
if ($data['is_area'] == 1 && $this->repository->fieldExists('area_id', $data['area_id'])) { |
|
|
|
return app('json')->fail('该区域已经有了代理角色,请勿重复添加'); |
|
|
|
return app('json')->fail('该区域已经有了代理角色,请勿重复添加'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (($data['type'] == 3 && empty($data['brand_id']) || ($data['type'] == 4 && empty($data['trade_id'])))) { |
|
|
|
|
|
|
|
return app('json')->fail('请补全对应角色类型的关联数据'); |
|
|
|
|
|
|
|
} |
|
|
|
$this->repository->create($data); |
|
|
|
$this->repository->create($data); |
|
|
|
return app('json')->success('添加成功'); |
|
|
|
return app('json')->success('添加成功'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function update(PartnerRoleValidate $validate) |
|
|
|
public function update(PartnerRoleValidate $validate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', 'area_id', 'id', ['status', 1]]); |
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', |
|
|
|
|
|
|
|
'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id']); |
|
|
|
$validate->check($data); |
|
|
|
$validate->check($data); |
|
|
|
|
|
|
|
|
|
|
|
if ($data['is_area'] == 1) { |
|
|
|
if ($data['is_area'] == 1) { |
|
|
@ -74,6 +78,9 @@ class Partner extends BaseController |
|
|
|
$data['area_level'] = 0; |
|
|
|
$data['area_level'] = 0; |
|
|
|
$data['area_id'] = 0; |
|
|
|
$data['area_id'] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (($data['type'] == 3 && empty($data['brand_id']) || ($data['type'] == 4 && empty($data['trade_id'])))) { |
|
|
|
|
|
|
|
return app('json')->fail('请补全对应角色类型的关联数据'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->repository->update($data['id'], $data); |
|
|
|
$this->repository->update($data['id'], $data); |
|
|
|
|
|
|
|
|
|
|
|