main
limu 11 months ago
parent dc0fb04302
commit de279962db
  1. 12
      app/common/repositories/system/admin/PartnerRepository.php
  2. 11
      app/controller/admin/system/admin/Partner.php
  3. 8
      app/controller/admin/user/User.php

@ -114,24 +114,24 @@ class PartnerRepository extends BaseRepository
$area_data = CityArea::getDB()->where('id', $data['area_id'])->find()->toArray();
$ids = explode("/", $area_data['path']);
if ($area_data['level'] == 1) {
$data['province_id'] = $data['area_id'];
$data['province_id'] = (int)$data['area_id'];
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray();
$data['province_name'] = $name_data['name'];
} elseif ($area_data['level'] == 2) {
$data['province_id'] = $ids[1];
$data['province_id'] = (int)$ids[1];
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray();
$data['province_name'] = $name_data['name'];
$data['city_id'] = $data['area_id'];
$data['city_id'] = (int)$data['area_id'];
$name_data1 = CityArea::getDB()->where('id', $data['city_id'])->find()->toArray();
$data['city_name'] = $name_data1['name'];
} elseif ($area_data['level'] == 3) {
$data['province_id'] = $ids[1];
$data['province_id'] = (int)$ids[1];
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray();
$data['province_name'] = $name_data['name'];
$data['city_id'] = $ids[2];
$data['city_id'] = (int)$ids[2];
$name_data1 = CityArea::getDB()->where('id', $data['city_id'])->find()->toArray();
$data['city_name'] = $name_data1['name'];
$data['district_id'] = $data['area_id'];
$data['district_id'] = (int)$data['area_id'];
$name_data2 = CityArea::getDB()->where('id', $data['district_id'])->find()->toArray();
$data['district_name'] = $name_data2['name'];
}

@ -14,6 +14,7 @@
namespace app\controller\admin\system\admin;
use app\common\model\user\UserPartner;
use app\common\repositories\system\admin\PartnerRepository;
use crmeb\basic\BaseController;
use app\validate\admin\PartnerRoleValidate;
@ -73,6 +74,9 @@ class Partner extends BaseController
) {
return app('json')->fail('请补全对应角色类型的关联数据');
}
unset($data['district_id']);
unset($data['province_id']);
unset($data['city_id']);
$this->repository->create($data);
return app('json')->success('添加成功');
}
@ -82,7 +86,8 @@ 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']);
'area_id', ['status', 1], ['type', 1], 'brand_id', 'trade_id', 'id', 'region_id',
['max_role_num', 1]]);
$validate->check($data);
if ($data['is_area'] == 1) {
@ -109,7 +114,9 @@ class Partner extends BaseController
) {
return app('json')->fail('请补全对应角色类型的关联数据');
}
unset($data['district_id']);
unset($data['province_id']);
unset($data['city_id']);
$this->repository->update($data['id'], $data);
return app('json')->success('编辑成功');

@ -14,6 +14,8 @@
namespace app\controller\admin\user;
use app\common\model\system\admin\Partner;
use app\common\model\user\UserPartner;
use app\common\repositories\store\ExcelRepository;
use app\common\repositories\user\UserSpreadLogRepository;
use app\common\repositories\user\UserVisitRepository;
@ -626,6 +628,12 @@ class User extends BaseController
if (!$partnerRepository->exists((int)$value)) {
return app('json')->fail('所选合作人角色不存在');
}
$role_info = Partner::getDB()->where('id',$value)->find();
$role_count = UserPartner::getDB()->where('partner_id',$value)->count() ?? 0;
if($role_info->max_role_num <= $role_count){
return app('json')->fail('角色分配以到上限');
}
}
if($is_cf){
return app('json')->fail('请勿给用户设置重复的角色');

Loading…
Cancel
Save