From 49fbe21a09a6b4ba1fc0c2b33b070fac783a0cb0 Mon Sep 17 00:00:00 2001 From: bruce <1272542526@qq.com> Date: Fri, 26 Jan 2024 13:13:41 +0800 Subject: [PATCH] update --- app/controller/api/user/User.php | 64 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index d916455..f523516 100644 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -406,39 +406,45 @@ class User extends BaseController public function brand() { $type = $this->request->param('type'); + $shareId = $this->request->param('shareId') ?? 0; $start = date('Y-m-d') . ' 00:00:00'; $end = date('Y-m-d') . ' 23:59:59'; - //用户每天同type只能邀请10个人 多了就不加了 - $count = ValueContributionLog::getDB() - ->where('type', $type) - ->where('user_id', $this->user->uid) - ->where('ctime', '>=', $start) - ->where('ctime', '<=', $end) - ->count(); - - if (!empty($count) && $count > 10) { - return app('json')->fail('达到上限'); - } - //加100分 - $userModel = userModel::getDB()->where('uid', $this->user->uid)->find(); - $userModel->brand_integral += $this->brand_integral; - $userModel->save(); - if ($type == 2) { - $memo = '分享视频获得' . $this->brand_integral . '品宣积分'; - } - if ($type == 3) { - $memo = '分享推文获得' . $this->brand_integral . '品宣积分'; + if($shareId > 0) { + //加100分 + $userModel = userModel::getDB()->where('uid',$shareId)->find(); + if ($userModel) { + $userModel->brand_integral += $this->brand_integral; + $userModel->save(); + if ($type == 2) { + $memo = '分享视频获得' . $this->brand_integral . '品宣积分'; + } + if ($type == 3) { + $memo = '分享推文获得' . $this->brand_integral . '品宣积分'; + } + //加到log日志 + ValueContributionLog::getDB()->insert([ + 'type' => $type, + 'types_of' => 1, + 'num' => $this->brand_integral, + 'ctime' => date('Y-m-d H:i:s'), + 'memo' => $memo ?? 0, + 'user_id' => $shareId, + ]); + } + } else { + //用户每天同type只能邀请10个人 多了就不加了 + $count = ValueContributionLog::getDB() + ->where('type', $type) + ->where('user_id', $this->user->uid) + ->where('ctime', '>=', $start) + ->where('ctime', '<=', $end) + ->count(); + + if (!empty($count) && $count > 10) { + return app('json')->fail('达到上限'); + } } - //加到log日志 - ValueContributionLog::getDB()->insert([ - 'type' => $type, - 'types_of' => 1, - 'num' => $this->brand_integral, - 'ctime' => date('Y-m-d H:i:s'), - 'memo' => $memo, - 'user_id' => $this->user->uid, - ]); return app('json')->success('分享成功');