|
|
@ -406,39 +406,45 @@ class User extends BaseController |
|
|
|
public function brand() |
|
|
|
public function brand() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$type = $this->request->param('type'); |
|
|
|
$type = $this->request->param('type'); |
|
|
|
|
|
|
|
$shareId = $this->request->param('shareId') ?? 0; |
|
|
|
$start = date('Y-m-d') . ' 00:00:00'; |
|
|
|
$start = date('Y-m-d') . ' 00:00:00'; |
|
|
|
$end = date('Y-m-d') . ' 23:59:59'; |
|
|
|
$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分 |
|
|
|
if($shareId > 0) { |
|
|
|
$userModel = userModel::getDB()->where('uid', $this->user->uid)->find(); |
|
|
|
//加100分 |
|
|
|
$userModel->brand_integral += $this->brand_integral; |
|
|
|
$userModel = userModel::getDB()->where('uid',$shareId)->find(); |
|
|
|
$userModel->save(); |
|
|
|
if ($userModel) { |
|
|
|
if ($type == 2) { |
|
|
|
$userModel->brand_integral += $this->brand_integral; |
|
|
|
$memo = '分享视频获得' . $this->brand_integral . '品宣积分'; |
|
|
|
$userModel->save(); |
|
|
|
} |
|
|
|
if ($type == 2) { |
|
|
|
if ($type == 3) { |
|
|
|
$memo = '分享视频获得' . $this->brand_integral . '品宣积分'; |
|
|
|
$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('分享成功'); |
|
|
|
return app('json')->success('分享成功'); |
|
|
|