main
bruce 10 months ago
parent fef956da9e
commit 49fbe21a09
  1. 34
      app/controller/api/user/User.php

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

Loading…
Cancel
Save