main
limu 1 year ago
parent 7a498cb4eb
commit efcff69f71
  1. 5
      app/common/repositories/system/admin/PartnerRepository.php
  2. 19
      app/common/repositories/user/UserPartnerRepository.php
  3. 6
      app/controller/admin/system/admin/Partner.php
  4. 27
      app/controller/admin/user/User.php
  5. 16
      config/partner.php
  6. 3
      route/admin/role.php

@ -142,5 +142,10 @@ class PartnerRepository extends BaseRepository
}
public function roleExists(int $id)
{
return UserPartner::getDB()->where('id', '=', $id)->where('uid','=','')->find();
}
}

@ -75,7 +75,7 @@ class UserPartnerRepository extends BaseRepository
/** @var UserLabelRepository $make */
$list = $this->dao->getAll($uid)->column('partner_id') ?? [];
$data = ['partner_id' => $list, 'uid' => $uid];
$url = 'sys/user/partner/'.$uid;
$url = 'sys/user/partner/' . $uid;
$res = Elm::createForm($url, [
Elm::input('uid', '用户 ID', '')->disabled(true)->required(true),
Elm::selectMultiple('partner_id', '用户合作人角色')->options(function () {
@ -92,18 +92,17 @@ class UserPartnerRepository extends BaseRepository
return $res;
}
public function editPartner(int $uid, array $partner_id = [])
public function editPartner(int $uid, array $user_role_id = [])
{
return Db::transaction(function () use ($uid, $partner_id) {
return Db::transaction(function () use ($uid, $user_role_id) {
//先清空
UserPartner::getInstance()->where('uid', $uid)->delete();
//再插入
if (!empty($partner_id)) {
$data = [];
foreach ($partner_id as $k => $v) {
$data[] = ['uid' => $uid, 'partner_id' => $v, 'create_time' => date("Y-m-d H:i:s")];
UserPartner::getInstance()->where('uid', $uid)->update(['partner_id' => '']);
//再更新
if (!empty($user_role_id)) {
foreach ($user_role_id as $k => $v) {
UserPartner::getInstance()->where('id', '=', $v)
->update(['uid' => $uid, 'create_time' => date("Y-m-d H:i:s")]);
}
UserPartner::getInstance()->insertAll($data);
}
});
}

@ -113,4 +113,10 @@ class Partner extends BaseController
$this->repository->delete($id);
return app('json')->success('删除成功');
}
public function getArea()
{
$data = config('partner.region_type');
return app('json')->success($data);
}
}

@ -142,7 +142,7 @@ class User extends BaseController
$data['pwd'] = $this->repository->encodePassword($data['repwd']);
unset($data['repwd']);
if ($data['is_promoter']) $data['promoter_time'] = date('Y-m-d H:i:s');
$this->repository->create('h5',$data);
$this->repository->create('h5', $data);
return app('json')->success('添加成功');
}
@ -164,7 +164,7 @@ class User extends BaseController
return app('json')->fail('密码不一致');
$data['pwd'] = $this->repository->encodePassword($data['repwd']);
unset($data['repwd']);
$this->repository->update($id,$data);
$this->repository->update($id, $data);
return app('json')->success('修改成功');
}
@ -219,7 +219,7 @@ class User extends BaseController
$data['label_id'] = implode(',', $label_id);
if ($data['is_promoter'])
$data['promoter_time'] = date('Y-m-d H:i:s');
if(!$data['birthday']) unset($data['birthday']);
if (!$data['birthday']) unset($data['birthday']);
$this->repository->update($id, $data);
@ -562,7 +562,7 @@ class User extends BaseController
public function memberForm($id)
{
return app('json')->success(formToData($this->repository->memberForm($id,1)));
return app('json')->success(formToData($this->repository->memberForm($id, 1)));
}
public function memberSave($id)
@ -576,7 +576,7 @@ class User extends BaseController
public function spreadLevelForm($id)
{
return app('json')->success(formToData($this->repository->memberForm($id,0)));
return app('json')->success(formToData($this->repository->memberForm($id, 0)));
}
public function spreadLevelSave($id)
@ -595,8 +595,8 @@ class User extends BaseController
public function svipUpdate($id)
{
$data = $this->request->params(['is_svip','add_time','type']);
$this->repository->svipUpdate($id, $data,$this->request->adminId());
$data = $this->request->params(['is_svip', 'add_time', 'type']);
$this->repository->svipUpdate($id, $data, $this->request->adminId());
return app('json')->success('修改成功');
}
@ -608,18 +608,25 @@ class User extends BaseController
return app('json')->success(formToData($partnerRepository->changePartnerForm($id)));
}
public function changePartner(PartnerRepository $partnerRepository,UserPartnerRepository $userPartnerRepository)
public function changePartner(PartnerRepository $partnerRepository, UserPartnerRepository $userPartnerRepository)
{
$partner_id = (array)$this->request->param('partner_id', []);
$user_role_id = (array)$this->request->param('user_role_id', []);
$partner_ids = $user_role_ids = [];
$id = (int)$this->request->param('uid', '');
if (!$this->repository->exists($id))
return app('json')->fail('数据不存在');
foreach ($partner_id as $k => $value) {
$partner_id[$k] = (int)$value;
$partner_ids[$k] = (int)$value;
if (!$partnerRepository->exists((int)$value))
return app('json')->fail('所选合作人角色不存在');
}
$userPartnerRepository->editPartner($id, $partner_id);
foreach ($user_role_id as $k => $value) {
$user_role_id[$k] = (int)$value;
if (!$partnerRepository->roleExists((int)$value))
return app('json')->fail('该位置已分配,请重新选择');
}
$userPartnerRepository->editPartner($id, $user_role_id);
return app('json')->success('修改成功');
}

@ -13,6 +13,8 @@
// | 控制台配置
// +----------------------------------------------------------------------
return [
//贡献池系统用户id
'gongxian_admin_id' => 9,
// 社区等级配置
'community_level' => [
[
@ -61,37 +63,37 @@ return [
[
'id' => 1,
'name' => '华东地区',
'province_ids' => [13,12,14,15,2,16,2768,21],
'province_ids' => [13, 12, 14, 15, 2, 16, 2768, 21],
],
[
'id' => 2,
'name' => '华南地区',
'province_ids' => [19,20,52993,23],
'province_ids' => [19, 20, 52993, 23],
],
[
'id' => 3,
'name' => '华北地区',
'province_ids' => [1,3,5,6,11],
'province_ids' => [1, 3, 5, 6, 11],
],
[
'id' => 4,
'name' => '华中地区',
'province_ids' => [7,17,18],
'province_ids' => [7, 17, 18],
],
[
'id' => 5,
'name' => '西南地区',
'province_ids' => [25,22,24,26,4],
'province_ids' => [25, 22, 24, 26, 4],
],
[
'id' => 6,
'name' => '西北地区',
'province_ids' => [27,28,29,30,31],
'province_ids' => [27, 28, 29, 30, 31],
],
[
'id' => 7,
'name' => '东北地区',
'province_ids' => [8,9,10],
'province_ids' => [8, 9, 10],
],
],
];

@ -152,6 +152,9 @@ Route::group(function () {
Route::get('delete/:id', '.Partner/delete')->name('systemPartnerDel')->option([
'_alias' => '删除合作人角色',
]);
Route::get('region', '.Partner/getArea')->name('systemPartnerArea')->option([
'_alias' => '读取合作人大区',
]);
})->prefix('admin.system.admin')->option([
'_path' => 'self',
'_auth' => true,

Loading…
Cancel
Save