1748153932 12 months ago
commit 70b4df7f18
  1. 28
      app/command/dayValue.php
  2. 22
      app/common/repositories/user/UserPartnerRepository.php
  3. 3
      app/controller/admin/system/admin/Partner.php
  4. 2
      app/controller/admin/user/User.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];
}

@ -73,10 +73,22 @@ 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, '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();
$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');
}
public function editPartner(int $uid, array $partner_id = [])
@ -88,7 +100,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);
}

@ -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) {

@ -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)

Loading…
Cancel
Save