main
bruce 10 months ago
parent fef956da9e
commit 49fbe21a09
  1. 64
      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('分享成功');

Loading…
Cancel
Save