From 3019ded56a62fb380cbd39e77fcc167443a7005f Mon Sep 17 00:00:00 2001 From: limu Date: Tue, 12 Dec 2023 17:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=94=80=E7=94=A8=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/user/UserPartnerDao.php | 43 ++++++++++++ .../user/UserPartnerRepository.php | 67 +++++++++++++++++++ .../repositories/user/UserRepository.php | 1 + app/validate/admin/PartnerRoleValidate.php | 2 +- 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 app/common/dao/user/UserPartnerDao.php create mode 100644 app/common/repositories/user/UserPartnerRepository.php diff --git a/app/common/dao/user/UserPartnerDao.php b/app/common/dao/user/UserPartnerDao.php new file mode 100644 index 0000000..fc9e824 --- /dev/null +++ b/app/common/dao/user/UserPartnerDao.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\user; + + +use app\common\dao\BaseDao; +use app\common\model\user\UserPartner as model; + +class UserPartnerDao extends BaseDao +{ + + + /** + * @return string + * @author Qinii + */ + protected function getModel(): string + { + return model::class; + } + + + public function userFieldExists($field, $value, $uid): bool + { + return (($this->getModel()::getDB())->where('uid', $uid)->where($field, $value)->count()) > 0; + } + + public function getAll(int $uid) + { + return (($this->getModel()::getDB())->where('uid', $uid)); + } +} diff --git a/app/common/repositories/user/UserPartnerRepository.php b/app/common/repositories/user/UserPartnerRepository.php new file mode 100644 index 0000000..5bc51ef --- /dev/null +++ b/app/common/repositories/user/UserPartnerRepository.php @@ -0,0 +1,67 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\user; + +use app\common\repositories\BaseRepository; +use app\common\dao\user\UserPartnerDao as dao; + +/** + * Class UserAddressRepository + * @package app\common\repositories\user + * @day 2020/6/3 + * @mixin dao + */ +class UserPartnerRepository extends BaseRepository +{ + /** + * @var dao + */ + protected $dao; + + + /** + * UserAddressRepository constructor. + * @param dao $dao + */ + public function __construct(dao $dao) + { + $this->dao = $dao; + } + + + /** + * @param int $id + * @param int $uid + * @return bool + * @author Qinii + */ + public function fieldExists(int $id, int $uid) + { + return $this->dao->userFieldExists($this->dao->getPk(), $id, $uid); + } + + + /** + * @param $uid + * @param $page + * @param $limit + * @return array + * @author Qinii + */ + public function getList($uid) + { + $list = $this->dao->getAll($uid)->order('id desc')->select(); + return compact('list'); + } +} diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index 745a1e2..d273094 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -1365,6 +1365,7 @@ class UserRepository extends BaseRepository app()->make(UserAddressRepository::class)->getSearch([])->where('uid', $uid)->delete(); app()->make(UserMerchantRepository::class)->getSearch([])->where('uid', $uid)->delete(); app()->make(UserReceiptRepository::class)->getSearch([])->where('uid', $uid)->delete(); + app()->make(UserPartnerRepository::class)->getSearch([])->where('uid', $uid)->delete(); app()->make(StoreServiceRepository::class)->getSearch([])->where('uid', $uid)->update(['uid' => 0, 'status' => 0, 'is_open' => 0]); $this->getSearch([])->where('spread_uid', $uid)->update(['spread_uid' => 0]); $this->delBrokerageTop($uid); diff --git a/app/validate/admin/PartnerRoleValidate.php b/app/validate/admin/PartnerRoleValidate.php index abfb786..7269de7 100644 --- a/app/validate/admin/PartnerRoleValidate.php +++ b/app/validate/admin/PartnerRoleValidate.php @@ -23,6 +23,6 @@ class PartnerRoleValidate extends Validate protected $rule = [ 'name|角色名称' => 'require|max:20', 'ratio|比例' => 'require', - 'status|启用状态' => 'require|in:0,1', + 'status|启用状态' => 'require|in:1,2', ]; }