$aid, 'invite_code' => $invite_code, 'create_time' => date("Y-m-d H:i:s",time()) ]; if (!empty($rebate_ratio)) { $save['rebate_ratio'] = $rebate_ratio / 100; } $model->save($save); } /** * 递归获取验证码(不重复) * @return string * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function returnInviteCode() { $invite_code = generate_random_str(6); $query = AgentInfo::withTrashed()->where('invite_code',$invite_code)->field('id')->find(); if ($query) { return self::returnInviteCode(); } return $invite_code; } /** * 修改返点占比 * @param $aid * @param $rebate_ratio * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function updateRebateRatio($aid,$rebate_ratio) { $AgentInfo = new AgentInfo(); $AgentInfoRes = $AgentInfo->where('aid',$aid)->find(); $AgentInfoRes->rebate_ratio = $rebate_ratio / 100; $AgentInfoRes->update_time = date("Y-m-d H:i:s",time()); $AgentInfoRes->save(); } }