From 1a9a6e8f3a3748fbfa6989bc6fba45cc4893ea4b Mon Sep 17 00:00:00 2001 From: limu Date: Tue, 19 Dec 2023 15:42:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/dayValue.php | 28 +++++++++++++++++++ app/controller/admin/system/admin/Partner.php | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/command/dayValue.php b/app/command/dayValue.php index 3a4f543..eb55c62 100644 --- a/app/command/dayValue.php +++ b/app/command/dayValue.php @@ -35,7 +35,35 @@ class dayValue extends Command protected function execute(Input $input, Output $output) { + $currentDate = date('Y-m-01'); // 获取当前月的第一天 + //判断当月第一天 + if (date('Y-m-d') === $currentDate) { + //获取上个月时间 + list($start, $end) = $this->getLastMonth(); + //根据社区等级分配贡献值 + //重置社区等级 + } + } + public function getLastMonth() + { + // 获取当前日期 + $currentDate = date('Y-m-d'); + // 提取当前日期的年、月和日 + $currentYear = date('Y', strtotime($currentDate)); + $currentMonth = date('m', strtotime($currentDate)); + // 计算上个月的年份和月份 + $lastMonthYear = $currentYear - 1; + $lastMonth = $currentMonth - 1; + // 处理特殊情况:如果上个月的月份小于1,则年份减1,月份设为12 + if ($lastMonth < 1) { + $lastMonthYear--; + $lastMonth = 12; + } + // 获取上个月的第一天和最后一天 + $firstDayOfLastMonth = date('Y-m-01', strtotime("$lastMonthYear-$lastMonth-01")); + $lastDayOfLastMonth = date('Y-m-t', strtotime("$lastMonthYear-$lastMonth-01")); + return [$firstDayOfLastMonth, $lastDayOfLastMonth]; } diff --git a/app/controller/admin/system/admin/Partner.php b/app/controller/admin/system/admin/Partner.php index 1c0ee3a..24b51ae 100644 --- a/app/controller/admin/system/admin/Partner.php +++ b/app/controller/admin/system/admin/Partner.php @@ -63,8 +63,9 @@ class Partner extends BaseController public function update(PartnerRoleValidate $validate) { + $data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', - 'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id']); + 'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id','id']); $validate->check($data); if ($data['is_area'] == 1) { From 902b7c9bc42ddaa6ac5b9bb86c2bcef141950d47 Mon Sep 17 00:00:00 2001 From: limu Date: Tue, 19 Dec 2023 16:04:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/user/UserPartnerRepository.php | 16 +++++++++++----- app/controller/admin/system/admin/Partner.php | 2 +- app/controller/admin/user/User.php | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/common/repositories/user/UserPartnerRepository.php b/app/common/repositories/user/UserPartnerRepository.php index aa8f7ca..4caf383 100644 --- a/app/common/repositories/user/UserPartnerRepository.php +++ b/app/common/repositories/user/UserPartnerRepository.php @@ -73,10 +73,16 @@ class UserPartnerRepository extends BaseRepository 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'); + $list = $this->dao->getAll($uid)->column('partner_id') ?? []; + $data = ['partner_id' => $list]; + return Elm::createForm(Route::buildUrl('systemUserChangePartner', compact('uid'))->build(), [ + Elm::selectMultiple('partner_id', '用户合作人角色')->options(function () { + $partnerForm = new PartnerDao(); + $option = $partnerForm->getAll(); + return $option; + }), + ])->setTitle('编辑合作人角色')->formData($data); + //return compact('list', 'option'); } public function editPartner(int $uid, array $partner_id = []) @@ -88,7 +94,7 @@ class UserPartnerRepository extends BaseRepository 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")]; + $data[] = ['uid' => $uid, 'partner_id' => $v, 'create_time' => date("Y-m-d H:i:s")]; } UserPartner::getInstance()->insertAll($data); } diff --git a/app/controller/admin/system/admin/Partner.php b/app/controller/admin/system/admin/Partner.php index 24b51ae..06622b1 100644 --- a/app/controller/admin/system/admin/Partner.php +++ b/app/controller/admin/system/admin/Partner.php @@ -63,7 +63,7 @@ class Partner extends BaseController public function update(PartnerRoleValidate $validate) { - + $data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', 'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id','id']); $validate->check($data); diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index 134c0c9..13540bf 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -605,7 +605,7 @@ class User extends BaseController { if (!$this->repository->exists($id)) return app('json')->fail('数据不存在'); - return app('json')->success($partnerRepository->changePartnerForm($id)); + return app('json')->success(formToData($partnerRepository->changePartnerForm($id))); } public function changePartner(PartnerRepository $partnerRepository,UserPartnerRepository $userPartnerRepository) From 073ddd507a413d9bf0388ff6a7b92c86e9e79e03 Mon Sep 17 00:00:00 2001 From: limu Date: Tue, 19 Dec 2023 16:25:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/user/UserPartnerRepository.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/user/UserPartnerRepository.php b/app/common/repositories/user/UserPartnerRepository.php index 4caf383..6ae49dd 100644 --- a/app/common/repositories/user/UserPartnerRepository.php +++ b/app/common/repositories/user/UserPartnerRepository.php @@ -74,12 +74,18 @@ class UserPartnerRepository extends BaseRepository { /** @var UserLabelRepository $make */ $list = $this->dao->getAll($uid)->column('partner_id') ?? []; - $data = ['partner_id' => $list]; + $data = ['partner_id' => $list, 'uid' => $uid]; return Elm::createForm(Route::buildUrl('systemUserChangePartner', compact('uid'))->build(), [ + Elm::input('uid', '用户 ID', '')->disabled(true)->required(true), Elm::selectMultiple('partner_id', '用户合作人角色')->options(function () { $partnerForm = new PartnerDao(); - $option = $partnerForm->getAll(); - return $option; + $data = $partnerForm->getAll(); + foreach ($data as $value => $label) { + $name = (string)$label['id']; + $value = $label['name']; + $options[] = compact('value', 'name'); + } + return $options; }), ])->setTitle('编辑合作人角色')->formData($data); //return compact('list', 'option');