1748153932 12 months ago
commit d39aa1a6f8
  1. 10
      app/common/dao/system/admin/PartnerDao.php
  2. 3
      app/common/repositories/system/admin/PartnerRepository.php
  3. 30
      app/common/repositories/user/UserPartnerRepository.php
  4. 8
      route/admin/user.php

@ -63,5 +63,15 @@ class PartnerDao extends BaseDao
->find(); ->find();
} }
public function getAll()
{
return Partner::getDB()->where('status', 1)->order('id desc')->field('')->select()->toArray();
}
public function exists(int $id)
{
return $this->existsWhere(['id' => $id]);
}
} }

@ -113,7 +113,10 @@ class PartnerRepository extends BaseRepository
public function existsUser(int $id) public function existsUser(int $id)
{ {
return $this->dao->existsUser($id); return $this->dao->existsUser($id);
} }
} }

@ -13,8 +13,13 @@
namespace app\common\repositories\user; namespace app\common\repositories\user;
use app\common\model\user\UserPartner;
use app\common\repositories\BaseRepository; use app\common\repositories\BaseRepository;
use app\common\dao\user\UserPartnerDao as dao; use app\common\dao\user\UserPartnerDao as dao;
use app\common\dao\system\admin\PartnerDao;
use FormBuilder\Factory\Elm;
use think\facade\Db;
use think\facade\Route;
/** /**
* Class UserAddressRepository * Class UserAddressRepository
@ -64,4 +69,29 @@ class UserPartnerRepository extends BaseRepository
$list = $this->dao->getAll($uid)->order('id desc')->select(); $list = $this->dao->getAll($uid)->order('id desc')->select();
return compact('list'); return compact('list');
} }
public function changePartnerForm($uid)
{
/** @var UserLabelRepository $make */
$list = $this->dao->getAll($uid)->column('partner_id');
$partnerForm = new PartnerDao();
$option = $partnerForm->getAll();
return compact('list', 'option');
}
public function editPartner(int $uid, array $partner_id = [])
{
return Db::transaction(function () use ($uid, $partner_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()->insertAll($data);
}
});
}
} }

@ -176,6 +176,14 @@ Route::group(function () {
Route::post('svip/:id', '/svipUpdate')->name('systemUserSvipUpdate')->option([ Route::post('svip/:id', '/svipUpdate')->name('systemUserSvipUpdate')->option([
'_alias' => '用户标签编辑', '_alias' => '用户标签编辑',
]); ]);
//合作人角色
Route::get('partner/:id', '/getPartner')->name('systemUserGetPartner')->option([
'_alias' => '获取合作人角色',
]);
Route::post('partner/edit', '/changePartner')->name('systemUserChangePartner')->option([
'_alias' => '用户合作人角色编辑',
]);
})->prefix('admin.user.User')->option([ })->prefix('admin.user.User')->option([
'_path' => '/user/list', '_path' => '/user/list',

Loading…
Cancel
Save