|
|
|
@ -406,22 +406,14 @@ 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('达到上限'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($shareId > 0) { |
|
|
|
|
//加100分 |
|
|
|
|
$userModel = userModel::getDB()->where('uid', $this->user->uid)->find(); |
|
|
|
|
$userModel = userModel::getDB()->where('uid',$shareId)->find(); |
|
|
|
|
if ($userModel) { |
|
|
|
|
$userModel->brand_integral += $this->brand_integral; |
|
|
|
|
$userModel->save(); |
|
|
|
|
if ($type == 2) { |
|
|
|
@ -436,9 +428,23 @@ class User extends BaseController |
|
|
|
|
'types_of' => 1, |
|
|
|
|
'num' => $this->brand_integral, |
|
|
|
|
'ctime' => date('Y-m-d H:i:s'), |
|
|
|
|
'memo' => $memo, |
|
|
|
|
'user_id' => $this->user->uid, |
|
|
|
|
'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('达到上限'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return app('json')->success('分享成功'); |
|
|
|
|