<?php
namespace app\index\controller;
use think\Request;
use app\index\model\Sms;
use app\index\model\Shop;
use app\index\model\Data;
use app\index\model\User;
use app\index\model\Video;
use app\index\model\likes;
use app\index\model\Fans;
use app\index\model\Order;
use app\index\model\Money;
use app\index\model\Footprint;
use think\Cookie;
use think\Session;
class Member extends \think\Controller
{
public function _initialize(){
Footprint::add();
}
public function myhome(){
footprint();
if (request()->isPost()){
$add = Data::add();
if($add){
$this->redirect('index/member/myhome');
$this->success('发布成功');
} else {
$this->error('请填写内容');
}
}
$usert = User::userselfinfo(Cookie::get('user_id'));
$data = Data::jack();
$this->assign('usert',$usert);
$this->assign('data',$data);
return view();
}
public function start(){
$user = Cookie::get('phone');
if (request()->isPost()) {
$user = Cookie::get('phone');
$registration_vip = input('registration_vip');
if (!$user) {
return "大佬!请登录";
# 没有登录 跳转到登录页面
}
$registration_user = Order::where('phone','=',$user)
->where('body','=',135)
->whereTime('create_time', 'today')
->count();
if($registration_vip and $registration_user){
return 0;die();
}
$rand = Order::where('body', 135)
->where('phone', $user)
->whereTime('create_time', 'yesterday')
->value('rand');
$rand = $rand+1;
if ($registration_user) {
# 已经签到直接提示
return "已连续签到" . $rand ."天";
}
$user = Order::create([
'body' => 135,
'subject' => "签到",
'total_fee' => 0,
'rand' => $rand,
'phone' => $user
]);
if($rand==3){
$add_vip_days = 1;
}elseif ($rand==8){
$add_vip_days = 3;
}elseif ($rand==16){
$add_vip_days = 6;
}elseif ($rand==32){
$add_vip_days = 18;
}elseif ($rand>32){
$add_vip_days = 1;
} else {
$add_vip_days = 0;
}
$rand_today = Order::where('body', 135)
->where('phone', $user)
->where('out_trade_no', '135001')
->whereTime('create_time', 'today')
->count();
if ($add_vip_days>=1 and $rand_today<=0) {
add_vip_days($add_vip_days,135001);
}
return "恭喜您,连续签到" . $rand ."天";
}
footprint();
$list = Order::where('body','=',135)
->whereTime('create_time', 'today')
->where('phone','=',$user)
->paginate(100);
$yesterday = Order::where('body','=',135)
->whereTime('create_time', 'yesterday')
->where('phone','=',$user)
->paginate(100);
$the_day_before_yesterday = Order::where('body','=',135)
->whereTime('create_time', '-7 day')
->where('phone','=',$user)
->paginate(100);
$list_all = Order::where('body','=',135)
->where('phone','=',$user)
->whereTime('create_time', '-7 day')
->paginate(100);
$cars=array("Volvo","BMW","Toyota");
for ($i=0; $i < 45 ; $i++) {
# code...
$cars[$i] = $i;
}
$firstday = '2018-7-29';
$allstart =0;
for ($i=1; $i < 46 ; $i++) {
# code...
echo "45天-之第" . $i ."天 ";
$day_a = $firstday.' 00:00:00';
$day_b = $firstday.' 23:59:59';
$everyday = Order::where('body','=',135)
->where('phone','=',$user)
->where('create_time','between time',[$day_a,$day_b])
->order('id asc')
->count();
session('s_'.$i,$everyday);
echo 'session里的结果'.session('s_'.$i);
if ($everyday) {
# code...
<br> ";
$allstart++;
}else{
<br>";
}
echo "<br >";
$firstday = date('Y-m-d',strtotime($firstday.'+1 day'));
}
echo "您总共获得星星" . $allstart;
$list_top = Order::where('body','=',135)
->where('phone','=',$user)
->order('id desc')
->paginate(50);
$this->assign('list',$list);
$this->assign('list_all',$list_all);
$this->assign('list_top',$list_top);
$this->assign('yesterday',$yesterday);
return view();
}
public function news(){
footprint();
$user_id = input('user_id');
$phone = 0;
$eq = "<>";
# code...
if ($phone) {
# 设置打开单用户搜索功能
$eq = "=";
}
$online_time = User::where('phone','<>','15966982315')
->where('phone','=',$phone)
->order('online_time desc')
->where('phone',$eq,$phone)
->limit(10)
->select();
$leraning_time = Video::order('update_time desc')
->where('phone',$eq,$phone)
->limit(10)
->select();
$money = Money::where('phone','<>','15966982315')
->where('phone','<>','0')
->field('id,phone,content, money,create_time')
->order('id desc')
->where('phone',$eq,$phone)
->limit(10)
->select();
$money_add = Money::where('phone','<>','15966982315')
->where('phone','<>','0')
->where('money','>','0')
->where('phone',$eq,$phone)
->field('id,phone, money,create_time')
->order('id desc')
->limit(10)
->select();
$pathinfo = Footprint::field('id,phone,create_time,pathinfo')
->order('id desc')
->where('phone',$eq,$phone)
->where('pathinfo','like','%'.'index/index/view'.'%')
->limit(10)
->select();
$search = Footprint::field('id,url,create_time')
->order('id desc')
->where('phone',$eq,$phone)
->where('pathinfo','=','index/index/like')
->limit(10)
->select();
$domain = Footprint::
field('id,phone,referer as domain,create_time')
->order('id desc')
->where('domain','<>','open.gaoxueya.com')
->where('domain','<>','www.tp5.com')
->where('phone',$eq,$phone)
->where('domain','<>','')
->where('domain','<>','blank')
->limit(10)
->select();
$footprint_phone = Footprint::
field('id,phone,pathinfo,create_time')
->where('phone',$eq,$phone)
->order('id desc')
->where('phone','<>','15966982315')
->where('pathinfo','<>','index/member/news')
->limit(10)
->select();
$sms = Sms::field('id,phone,create_time')
->where('phone',$eq,$phone)
->order('id desc')
->limit(10)
->select();
$total_fee = Order::
field('id,phone,body,total_fee,subject,create_time')
->where('phone','<>','15966982315')
->where('phone',$eq,$phone)
->order('id desc')
->limit(10)
->select();
$registration = Order::where('body','=',135) ->field('id,phone,create_time' )
->where('phone',$eq,$phone)
->order('id desc')
->where('phone','<>','15966982315')
->limit(10)
->select();
$new_message = Data::field('id,title,phone,create_time')
->where('phone',$eq,$phone)
->order('id desc')
->limit(10)
->select();
$this->assign('leraning_time',$leraning_time);
$this->assign('sms',$sms);
$this->assign('online_time',$online_time);
$this->assign('pathinfo',$pathinfo);
$this->assign('domain',$domain);
$this->assign('money',$money);
$this->assign('search',$search);
$this->assign('total_fee',$total_fee);
$this->assign('new_message',$new_message);
$this->assign('money_add',$money_add);
$this->assign('footprint_phone',$footprint_phone);
$this->assign('registration',$registration);
return view();
}
public function home(){
footprint();
$user = User::userselfinfo(input('user_id'));
$data = Data::jack(input('user_id'));
$this->assign('user',$user);
$this->assign('data',$data);
return view();
}
public function tip(){
footprint();
$appointment = input('appointment');
$list = Order::where('body','=',37)
->field('id,phone, total_fee,create_time,subject')
->where('phone','<>','15966982315')
->order('id desc')
->paginate(15);
$total_fee = Order::where('body','=',37)
->group('phone')
->field('id,phone, sum(`total_fee`) as total_feecount,create_time,subject')
->where('phone','<>','15966982315')
->order('total_feecount desc')
->limit(10)
->select();
$total_fee_count = Order::where('body','=',37)
->sum('total_fee');
$this->assign('total_fee',$total_fee);
$this->assign('total_fee_count',$total_fee_count);
$this->assign('list',$list);
if ($appointment) {
# code...
return view('appointment');
}
return view();
}
public function tips(){
footprint();
$list = Order::where('body','=',37)
->field('id,phone, total_fee,create_time,subject')
->where('phone','<>','15966982315')
->order('id desc')
->paginate(15);
$total_fee = Order::where('body','=',37)
->group('phone')
->field('id,phone, sum(`total_fee`) as total_feecount,create_time,subject')
->where('phone','<>','15966982315')
->order('total_feecount desc')
->limit(10)
->select();
$total_fee_count = Order::where('body','=',37)
->sum('total_fee');
$this->assign('total_fee',$total_fee);
$this->assign('total_fee_count',$total_fee_count);
$this->assign('list',$list);
return view();
}
public function top(){
footprint();
if (request()->isPost()) {
cache('online_time', NULL);
}
if (!cache('online_time')) {
# code...
$cach_time = 0;
dump("没有用缓存".$cach_time);
$online_time = User::where('phone','<>','15966982315')
->order('online_time desc')
->limit(10)
->select();
cache('online_time', $online_time, $cach_time);
$leraning_time = Video::group('phone')
->field('id,phone, sum(`title`) as title')
->order('title desc')
->limit(10)
->select();
cache('leraning_time', $leraning_time, $cach_time);
$money = Money::group('phone')
->where('phone','<>','15966982315')
->where('phone','<>','0')
->field('id,phone, sum(`money`) as money')
->order('money desc')
->limit(10)
->select();
cache('money', $money, $cach_time);
$money_add = Money::group('phone')
->where('phone','<>','15966982315')
->where('phone','<>','0')
->where('money','>','0')
->field('id,phone, sum(`money`) as money')
->order('money desc')
->limit(10)
->select();
cache('money_add', $money_add, $cach_time);
$pathinfo = Footprint::group('pathinfo')
->field('id,phone, count(`pathinfo`) as pathinfocount,Now(),pathinfo')
->order('pathinfocount desc')
->where('pathinfo','like','%'.'index/index/view'.'%')
->limit(10)
->select();
cache('pathinfo', $pathinfo, $cach_time);
$search = Footprint::group('url')
->field('id,count(`url`) as urlcount,url')
->order('urlcount desc')
->where('pathinfo','=','index/index/like')
->limit(10)
->select();
cache('search', $search, $cach_time);
$domain = Footprint::group('domain')
->field('id,phone, count(`domain`) as domaincount,domain')
->order('domaincount desc')
->where('domain','like','%'.'com'.'%')
->limit(10)
->select();
cache('domain', $domain, $cach_time);
$footprint_phone = Footprint::group('phone')
->field('id,phone, count(`phone`) as phonecount')
->order('phonecount desc')
->where('phone','<>','15966982315')
->limit(10)
->select();
cache('footprint_phone', $footprint_phone, $cach_time);
$list_top = Order::where('body','=',135)
->where('phone','<>','15966982315')
->whereTime('create_time', 'today')
->order('rand desc')
->limit(10)
->select();
cache('list_top', $list_top, $cach_time);
$total_fee = Order::where('body','=',37)
->group('phone')
->field('id,phone, sum(`total_fee`) as total_feecount')
->where('phone','<>','15966982315')
->order('total_feecount desc')
->limit(10)
->select();
cache('total_fee', $total_fee, $cach_time);
$registration = Order::where('body','=',135)
->group('phone')
->field('id,phone, count(`phone`) as phonecount')
->order('phonecount desc')
->where('phone','<>','15966982315')
->limit(10)
->select();
cache('registration', $registration, $cach_time);
$invite = User::with('sort')
->group('invite')
->field('id,invite, count(`invite`) as invitecount,phone')
->order('invitecount desc')
->where('invite','<>','0')
->limit(10)
->select();
cache('invite', $invite, $cach_time);
}
$this->assign('leraning_time',cache('leraning_time'));
$this->assign('list_top',cache('list_top'));
$this->assign('online_time',cache('online_time'));
$this->assign('pathinfo',cache('pathinfo'));
$this->assign('domain',cache('domain'));
$this->assign('search',cache('search'));
$this->assign('money',cache('money'));
$this->assign('total_fee',cache('total_fee'));
$this->assign('invite',cache('invite'));
$this->assign('money_add',cache('money_add'));
$this->assign('footprint_phone',cache('footprint_phone'));
$this->assign('registration',cache('registration'));
return view();
}
public function ajaxModelPay(){
$body = input('body');
$total_fee = input('total_fee');
$subject = input('subject');
$trade_no = input('trade_no');
$phone = Cookie::get('phone');
$admin = Cookie::get('admin');
if($admin >= 1){
dump('价格'.$total_fee);
dump('主题'.$subject);
dump('产品id'.$body);
dump('订单号'.$trade_no);
dump($phone);
}
$this->assign('total_fee',$total_fee);
$this->assign('subject',$subject);
$this->assign('body',$body);
$this->assign('trade_no',$trade_no);
return view();
}
public function payReturn(){
if (Session::get('total_fee')<=0){
dump(Session::get('total_fee'));
return "1";
die();
}else{ }
$phone = Session::get('phone');
$body = Session::get('body');
$rand = Session::get('rand');
$subject = Session::get('subject');
$total_fee = Session::get('total_fee');
$buyer_id = Session::get('buyer_id');
$buyer_email = Session::get('buyer_email');
$total_fee = Session::get('total_fee');
$out_trade_no = Session::get('out_trade_no');
$add_vip_days = '';
if (!$phone){
$phone='15966982315';
}
$map['id'] = $body;
$price = Shop::where($map)
->value('price');
if ($total_fee>=$price) { } else {
$body = 40; }
if ($body==37) {
}
if ($body==135) {
$rand_today = Order::where('body', $body)
->where('phone','<>', '15966982315')
->whereTime('create_time', 'today')
->count();
if ($rand_today<=10) {
}
$rand = Order::where('body', $body)
->where('phone', $phone)
->whereTime('create_time', 'yesterday')
->value('rand');
$rand = $rand+1;
if($rand==3){
$add_vip_days = 1;
}elseif ($rand==8){
$add_vip_days = 3;
}elseif ($rand==16){
$add_vip_days = 6;
}elseif ($rand==32){
$add_vip_days = 18;
}elseif ($rand>32){
$add_vip_days = 1;
} else {
$add_vip_days = '';
}
$rand_today = Order::where('body', $body)
->where('phone', $phone)
->where('out_trade_no', '135001')
->whereTime('create_time', 'today')
->count();
if ($add_vip_days>=1 and $rand_today<=0) {
add_vip_days($add_vip_days,135001);
}
}
$order = Order::create([
'phone' => $phone,
'body' => $body,
'rand' => $rand,
'subject' => $subject,
'total_fee' => $total_fee,
'buyer_id' => $buyer_id,
'buyer_email' => $buyer_email,
'out_trade_no' => $out_trade_no,
]);
if ($body==105) {
if($total_fee==9.9){
$add_vip_days = 30;
}elseif ($total_fee==0.02){
$add_vip_days = 1;
}elseif ($total_fee==19.9){
$add_vip_days = 300;
}elseif ($total_fee==99){
$add_vip_days = 365;
}elseif ($total_fee==399){
$add_vip_days = 186;
}elseif ($total_fee==699){
$add_vip_days = 366;
}
add_vip_days($add_vip_days,135002);
}
if ($phone == 15966982315)
{
if ($body==1008612)
{
exit('<script>top.location.href="../index/login/login/2/"</script>');
$this->redirect('index/login', ['login' => '2']);
}
exit('<script>top.location.href="../index/login/"</script>');
$this->redirect('index/login', ['login' => '0']);<script>top.location.href="../index/login/</script>');<script>top.location.href="../index/view/id/'.$body.'"</script>');
}
Session::set('total_fee','0');
Session::set('body','');
Session::set('phone','15966982315');
if ($body==1008611) {
exit('<script>top.location.href="../index/index/login/221/'.$body.'"</script>');
}
if ($body==1008611 or $body==1008611) {
exit('<script>top.location.href="../index/index/login/221/'.$body.$phone.'"</script>');
}
if ($body==135) {
exit('<script>top.location.href="../member/registration/login/135/add_vip_days/'.$rand.'"</script>');
}
if ($body==105) {
exit('<script>top.location.href="../member/vip/add_vip_days/'.$add_vip_days.'"</script>');
}
if ($body==37) {
exit('<script>top.location.href="../member/tips/login/23021/add_vip_days/'.$rand.'"</script>');
}
if ($body>=1008811) {
exit('<script>top.location.href="../index/index/login/232/'.$body.'"</script>');
}
exit('<script>top.location.href="../index/view/id/'.$body.'"</script>');
}
public function footprint_add(){
$data = Cookie::get('footprint');
if ($data) {
db('footprint')->insert($data);
}
Cookie::set('footprint','',20);
}
public function footprint(){
footprint();
$list = Footprint::whereTime('create_time', 'today')
->order('id desc,create_time')
->group('phone')
->paginate(100);
$yesterday = Footprint::whereTime('create_time', 'today')
->order('create_time desc')
->group('ip')
->paginate(100);
$list_all = Footprint::whereTime('create_time', 'today')
->order('create_time desc')
->paginate(100);
$list_top = Footprint::where('url','=',135)
->whereTime('create_time', 'today')
->order('id desc')
->paginate(50);
$this->assign('list',$list);
$this->assign('list_all',$list_all);
$this->assign('list_top',$list_top);
$this->assign('yesterday',$yesterday);
return view();
}
public function registration(){
if (request()->isPost()) {
$user = Cookie::get('phone');
$registration_vip = input('registration_vip');
if (!$user) {
return "大佬!请登录";
# 没有登录 跳转到登录页面
}
$registration_user = Order::where('phone','=',$user)
->where('body','=',135)
->whereTime('create_time', 'today')
->count();
if($registration_vip and $registration_user){
return 0;die();
}
$rand = Order::where('body', 135)
->where('phone', $user)
->whereTime('create_time', 'yesterday')
->value('rand');
$rand = $rand+1;
if ($registration_user) {
# 已经签到直接提示
return "已连续签到" . $rand ."天";
}
$user = Order::create([
'body' => 135,
'subject' => "签到",
'total_fee' => 0,
'rand' => $rand,
'phone' => $user
]);
if($rand==3){
$add_vip_days = 1;
}elseif ($rand==8){
$add_vip_days = 3;
}elseif ($rand==16){
$add_vip_days = 6;
}elseif ($rand==32){
$add_vip_days = 18;
}elseif ($rand>32){
$add_vip_days = 1;
} else {
$add_vip_days = 0;
}
$rand_today = Order::where('body', 135)
->where('phone', $user)
->where('out_trade_no', '135001')
->whereTime('create_time', 'today')
->count();
if ($add_vip_days>=1 and $rand_today<=0) {
add_vip_days($add_vip_days,135001);
}
return "恭喜您,连续签到" . $rand ."天";
}
footprint();
$list = Order::where('body','=',135)
->whereTime('create_time', 'today')
->where('phone','<>','15966982315')
->paginate(100);
$yesterday = Order::where('body','=',135)
->whereTime('create_time', 'yesterday')
->where('phone','<>','15966982315')
->paginate(100);
$the_day_before_yesterday = Order::where('body','=',135)
->whereTime('create_time', 'between', ['$the_day_before_begin', '$the_day_before_end'])
->where('phone','<>','15966982315')
->paginate(100);
$list_all = Order::where('body','=',135)
->where('phone','<>','15966982315')
->whereTime('create_time', '-7 day')
->paginate(100);
$list_top = Order::where('body','=',135)
->where('phone','<>','15966982315')
->whereTime('create_time', 'today')
->order('rand desc')
->paginate(50);
$this->assign('list',$list);
$this->assign('list_all',$list_all);
$this->assign('list_top',$list_top);
$this->assign('yesterday',$yesterday);
return view();
}
public function vip(){
footprint();
$phone = Cookie::get('phone');
if (!$phone) {
$phone = 15966982315;
}
$user = User::where('phone','=',$phone)->find();
$user = $user->toArray();
$start_time = $user['start_time'];
$expiration_time = $user['expiration_time'];
$time2 = $expiration_time;
$time1=strtotime(date("Y-m-d H:i:s")); $time2=strtotime($expiration_time); $time3=strtotime("2017-5-5");
$sub1=ceil(($time2-$time1)/3600); $sub2=ceil(($time3-$time1)/86400);
$vip_day = 1;
$secondkill = intval (date("Hi"));
if ($secondkill > "900" && $secondkill < "915") {
$secondkill = 900;
}
$this->assign('secondkill',$secondkill);
$this->assign('user',$user);
$this->assign('vip_day',$vip_day);
return view();
}
public function money(){
footprint();
$phone = Cookie::get('phone');
$money = Money::where('phone', $phone)
->sum('money');
$integral = Money::where('phone', $phone)
->where('money','>', 0)
->sum('money');
$list = Money::where('phone', $phone)
->order('id desc')
->paginate(30);
$this->assign('money',$money);
$this->assign('integral',$integral);
$this->assign('list',$list);
return view();
}
public function fgetcsv(){
$phone = Cookie::get('phone');
$file = fopen("tom666".$phone.".csv","r");
while(! feof($file))
{
dump(fgetcsv($file));
}
fclose($file);
}
public function fputcsv()
{
header("content-type:text/html; charset=utf-8");
$line = array(1,'学习—中文乱码',12345,'vb200','学习中文乱码');
foreach ($line as &$value)
{
$value = iconv("UTF-8", "GB231<br>";
}
$file = fopen("tom666.csv","w");
fputcsv($file,$line);
fclose($file);
die();
$phone = Cookie::get('phone');
$list = array
(
"thinkphp5,123456789123456789,thinkphp7,USA",
"James,Adrew,Martin,USA",
);
$list =Video::where('phone', $phone)
->order('update_time desc')
->paginate();
$file = fopen("tom666".$phone.".csv", "w");
$value = array
(
"id",
"phone",
"IP",
"...",
);
fputcsv($file,$value);
foreach ($list as $value) {
$value =$value->toarray();
fputcsv($file,$value);
}<a href=/"."tom666".$phone.".csv> 点击保存</a>";
echo 123;
fclose($file); $this->redirect("/tom666".$phone.".csv",302);
}
public function invite(){ footprint();
$body = input('id');
$phone = Cookie::get('phone');
$integral = '';
$list = '';
$money = '';
$id = User::where('phone','=',$phone)->value('id');
$invite = User::where('invite','=',$id)->count();
$invite_status = User::where('invite','=',$id)->where('status','<=',0)->count();
$money = Money::where('phone', $phone)
->sum('money');
$integral = Money::where('phone', $phone)
->where('money','>', 0)
->sum('money');
if ($invite) {
# 查询已邀请的名单
$list = User::where('invite',$id)
->order('id desc')
->paginate(20);
} $this->assign('list', $list);
$this->assign('money', $money);
$this->assign('integral', $integral);
if ($body) {
if (!$phone) {
$this->success('兑换前,请先登录', 'index/login');
}
if ($money>=10) {
$order = Order::create([
'phone' => $phone,
'body' => $body,
'subject' => "使用10学习币兑换 课程 id:".$body,
'total_fee' => 0,
'buyer_id' => $phone,
'buyer_email' => $phone,
'out_trade_no' => $phone,
]); $money = Money::create([
'phone' => $phone,
'money' => '-10',
'content' => "使用10学习币兑换 课程 id:".$body,
]);
$this->success('兑换成功^_^',url("index/view",array('id'=>$body)));die;
}else {
$this->success('无足够学习币,邀请1个好友注册双方均可获得100金币奥~', 'index/member/invite');
}
if ($invite_status=166) {
# code...
$order = Order::create([
'phone' => $phone,
'body' => $body,
'subject' => "使用兑换券兑换 课程 id:".$body,
'total_fee' => 0,
'buyer_id' => $phone,
'buyer_email' => $phone,
'out_trade_no' => $phone,
]);
$tom = User::where('invite', $id)
->where('status',0)
->limit(1)
->order('id asc')
->update(['status' => $body]);
$this->success('兑换成功^_^',url("index/view",array('id'=>$body)));die;
}else {
$this->success('无兑换券,立即邀请好友一起学习即可获得兑换券', 'index/member/invite');
}
}
$this->assign('id',$id);
$this->assign('invite',$invite);
$this->assign('invite_status',$invite_status);
return $this->fetch();
}
public function diary(){ footprint();
$body = input('id');
$phone = Cookie::get('phone');
if (!$phone){
return $this->success('查看学习进度,请先登录', 'index/login');;
}
$invite = Video::where('phone', $phone)
->where('status','>=', 1)
->count();
# 查询已邀请的名单
$list =Video::where('phone', $phone)
->order('update_time desc')
->paginate(20);
$this->assign('list', $list);
if ($body) {
if (!$phone) {
$this->success('兑换前,请先登录', 'index/login');
}
if ($invite_status) {
# code...
$order = Order::create([
'phone' => $phone,
'body' => $body,
'subject' => "使用兑换券兑换 课程 id:".$body,
'total_fee' => 0,
'buyer_id' => $phone,
'buyer_email' => $phone,
'out_trade_no' => $phone,
]);
$tom = User::where('invite', $id)
->where('status',0)
->limit(1)
->order('id asc')
->update(['status' => $body]);
$this->success('兑换成功^_^',url("index/view",array('id'=>$body)));die;
}else {
$this->success('无兑换券,立即邀请好友一起学习即可获得兑换券', 'index/member/invite');
}
}
$this->assign('invite',$invite);
return $this->fetch();
}
public function learning(){
footprint();
$body = input('id');
$phone = Cookie::get('phone');
$invite = Video::where('status', 1)
->count();
# 查询已邀请的名单
$list =Video::order('update_time desc')
->paginate(20);
$this->assign('list', $list);
if ($body) {
if (!$phone) {
$this->success('兑换前,请先登录', 'index/login');
}
if ($invite_status) {
# code...
$order = Order::create([
'phone' => $phone,
'body' => $body,
'subject' => "使用兑换券兑换 课程 id:".$body,
'total_fee' => 0,
'buyer_id' => $phone,
'buyer_email' => $phone,
'out_trade_no' => $phone,
]);
$tom = User::where('invite', $id)
->where('status',0)
->limit(1)
->order('id asc')
->update(['status' => $body]);
$this->success('兑换成功^_^',url("index/view",array('id'=>$body)));die;
}else {
$this->success('无兑换券,立即邀请好友一起学习即可获得兑换券', 'index/member/invite');
}
}
$this->assign('invite',$invite);
return $this->fetch();
}
}