|
|
|
@ -49,11 +49,23 @@ class Partner extends BaseController |
|
|
|
|
public function add(PartnerRoleValidate $validate) |
|
|
|
|
{ |
|
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', |
|
|
|
|
'area_id', ['status', 1], ['type', 1], ['max_role_num', 1], 'brand_id', 'trade_id', 'region_id']); |
|
|
|
|
'province_id', 'city_id', 'district_id', ['status', 1], ['type', 1], ['max_role_num', 1], |
|
|
|
|
'brand_id', 'trade_id', 'region_id']); |
|
|
|
|
$validate->check($data); |
|
|
|
|
if ($data['is_area'] == 1 && $this->repository->fieldExists('area_id', $data['area_id'])) { |
|
|
|
|
if ($data['is_area'] == 1) { |
|
|
|
|
if (!empty($data['district_id'])) { |
|
|
|
|
$data['area_id'] = $data['district_id']; |
|
|
|
|
} elseif (!empty($data['city_id'])) { |
|
|
|
|
$data['area_id'] = $data['city_id']; |
|
|
|
|
} elseif (!empty($data['province_id'])) { |
|
|
|
|
$data['area_id'] = $data['province_id']; |
|
|
|
|
} else { |
|
|
|
|
return app('json')->fail('请选择区域'); |
|
|
|
|
} |
|
|
|
|
if ($this->repository->fieldExists('area_id', $data['area_id'])) { |
|
|
|
|
return app('json')->fail('该区域已经有了代理角色,请勿重复添加'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ( |
|
|
|
|
($data['type'] == 3 && empty($data['brand_id'])) |
|
|
|
|
|| ($data['type'] == 4 && empty($data['trade_id'])) |
|
|
|
@ -69,14 +81,21 @@ class Partner extends BaseController |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', |
|
|
|
|
'province_id', 'city_id', 'district_id', |
|
|
|
|
'area_id', ['status', 1], ['type', 1], 'brand_id', 'trade_id', 'id', 'region_id']); |
|
|
|
|
$validate->check($data); |
|
|
|
|
|
|
|
|
|
if ($data['is_area'] == 1) { |
|
|
|
|
if (empty($data['area_id']) && empty($data['area_level'])) { |
|
|
|
|
return app('json')->fail('请选择所属区域'); |
|
|
|
|
if (!empty($data['district_id'])) { |
|
|
|
|
$data['area_id'] = $data['district_id']; |
|
|
|
|
} elseif (!empty($data['city_id'])) { |
|
|
|
|
$data['area_id'] = $data['city_id']; |
|
|
|
|
} elseif (!empty($data['province_id'])) { |
|
|
|
|
$data['area_id'] = $data['province_id']; |
|
|
|
|
} else { |
|
|
|
|
return app('json')->fail('请选择区域'); |
|
|
|
|
} |
|
|
|
|
if ($this->repository->fieldExists('area_id', $data['area_id'], $data['id'])) { |
|
|
|
|
if ($this->repository->fieldExists('area_id', $data['area_id'])) { |
|
|
|
|
return app('json')->fail('该区域已经有了代理角色,请勿重复添加'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|