pull/5/head
zengyyh 3 months ago
parent 3e1bdfe479
commit 8851983a77
  1. 3
      .gitignore
  2. 58
      app/api/controller/Invite.php

3
.gitignore vendored

@ -9,4 +9,5 @@ sftp-config.json
.env
/public/admin/
/public/store/
dump.rdb
dump.rdb
/public/nginx.htaccess

@ -11,6 +11,10 @@ use app\common\model\invite\InviteConfig;
use cores\exception\BaseException;
use think\db\exception\DbException;
use think\response\Json;
use app\common\model\UploadFile;
use app\common\model\store\Setting;
use app\store\model\User;
use app\store\model\user\GradeLog;
class Invite extends Controller
{
@ -105,6 +109,11 @@ class Invite extends Controller
->where(['status' => $status])
->order('id desc')
->paginate(15);
foreach ($list as &$item) {
$item['avatar_url'] = (UploadFile::withoutGlobalScope()->where('file_id',$item['avatar_id'])->find())['preview_url'];
$item['desensitization_mobile'] = hide_mobile($item['mobile']);
}
$data['list'] = $list->items();
$data['total'] = $list->total();
//审核通过
@ -114,4 +123,53 @@ class Invite extends Controller
}
return $this->renderSuccess($data);
}
//立即升级服务商
public function upgradeWholesaler(): Json
{
$storeId = $this->storeId;
//1.查询需要的邀请人数是多少
$setting = Setting::withoutGlobalScope()->where(['key'=>'trade','store_id'=>$storeId])->field('values')->find();
$invite_num = $setting['values']['order']['invite_num']??10;
//2.查询当前用户邀请的人数,判断比较
$model = new InviteLog();
$user_ids = $model->inviteeUserIds();
// 获取当前日期时间
$now = time();
// 获取明年今天的日期时间
$nextYearToday = strtotime("+1 year", $now);
// 格式化日期时间为 Y-m-d H:i:s
$formattedDate = date("Y-m-d", $nextYearToday);
if ($user_ids) {
$applyModel = new Apply();
$list_count = $applyModel->whereIn('user_id', $user_ids)
->with(['avatarImg'])
->where(['status' => 20])
->order('id desc')
->count();
if($list_count > $invite_num){
$data = [
'user_type' => 30,
'fx_effective_time' => $formattedDate,
'update_time'=>time()
];
User::withoutGlobalScope()->where('user_id',$this->user['user_id'])->where('store_id',$storeId)->save($data);
$gradeLog = [
'user_id' => $this->user['user_id'],
'store_id' => $storeId,
'change_type' => 20,
'remark' => '邀请人数达到升级服务商',
'create_time' => time(),
];
GradeLog::withoutGlobalScope()->insert($gradeLog);
return $this->renderSuccess('升级成功');
}
}
return $this->renderSuccess('升级失败,邀请人数不够');
}
}
Loading…
Cancel
Save