www.lightcourse.com/app/home/controller/Membercourse.php

189 lines
7.3 KiB
PHP

<?php
namespace app\home\controller;
use think\facade\View;
use think\facade\Lang;
use think\facade\Db;
/**
* ============================================================================
* 联课教育商城系统
* ============================================================================
* 版权所有 2022 刻羽互动科技有限公司,并保留所有权利。
* 网站地址: http://www.o1h.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* 控制器
*/
class Membercourse extends BaseMember {
public function initialize() {
parent::initialize();
/*if ($state == 10) {
$class = 'alt c1';
$status = 'Unpaid';
$desc = 'Please submit payment to enroll';
}
if ($state == 20) {
$class = 'alt c2';
$status = 'Submit information';
$desc = 'To enroll successfully,Students must complete all profile information ';
}
if ($state == 30) {
$class = 'alt c3';
$status = 'Application received';
$desc = 'Application received.Please await email confirmation.It usually takes 3 business days after enrollment starts';
}
if ($state == 40) {
$class = 'alt c4';
$status = 'Enrolled';
$desc = 'Congratulations! You will receive a confirmation email with course details from the course-offering school';
}
if ($state == 50) {
$class = 'alt c5';
$status = 'In progress';
$desc = 'Course has started';
}
*/
}
public function index()
{
$order_model = model('order');
$cart_model = model('cart');
$goods_model = model('goods');
$buyer = session('member_id');
$cart_list = $cart_model->getCartList('db', array('buyer_id' => $buyer));
//查看购物车信息
$course = [];
foreach ($cart_list as $val) {
$goods = $goods_model->getGoodsInfo(['goods_id' =>$val['goods_id']]);
//计算倒计时
if ($goods['enroll_start_date'] != 'Self-paced') {
$enroll = strtotime($goods['enroll_start_date']);
$diff = $enroll - time();
if ($diff <= 0) {
$day = 0;
} else {
$day = ceil(($diff / 86400));
}
} else {
$day = 0;
}
// var_dump($goods);die;
$course[] = [
'goods_id' => $val['goods_id'],
'goods_name' => $goods['goods_name'],
'code' => $goods['goods_serial'],
'school' => $goods['ke_simple_college'],
'class' => 'alt c1',
'status' => 'Unpaid',
'desc' => 'Please submit payment to enroll',
'enroll_start_date' => $goods['enroll_start_date'],
'enroll_end_date' => $goods['enroll_end_date'],
'ke_start_time' => $goods['ke_start_time'],
'day' => $day,
];
}
//查看订单信息
$order_model = model('order');
$condition = array();
$condition[]=array('buyer_id','=',session('member_id'));
$condition[]=array('order_state', '=', 20);
//查看学生信息
$memberinfo = Db::name('memberinfo')->where(['member_id' => session('member_id')])->find();
if ($memberinfo['is_submit'] != 1) {
$html_class = 'alt c2';
$html_status = "Submit information";
$html_desc = "To enroll successfully, students must complete all profile information";
} else {
$html_class = 'alt c3';
$html_status = "Application received";
$html_desc = "Application received. Please await email confirmation. It usually takes 3 business days after enrollment starts";
}
$send = [];
$order_list = $order_model->getOrderList($condition, 100, '*', 'order_id desc','', array('order_common','order_goods','ppintuanorder'));
foreach ($order_list as $val) {
//查询是否is_enroll
$is_enroll = $val['is_enroll'];
//查询订单商品
$goods = $order_model->getOrdergoodsList(['order_id' => $val['order_id']]);
foreach ($goods as $good) {
$info = $goods_model->getGoodsInfo(['goods_id' =>$good['goods_id']]);
if ($info['enroll_start_date'] != 'Self-paced') {
$enroll = strtotime($info['enroll_start_date']);
$diff = $enroll - time();
if ($diff <= 0) {
$day = 0;
} else {
$day = ceil(($diff / 86400));
}
} else {
$day = 0;
}
//查询是否enroll
if ($is_enroll == 1) {
$html_class = 'alt c4';
$html_status = "Enrolled";
$html_desc = "Congratulations! You will receive a confirmation email with course details from the course-offering school";
//查询是否开课
$ke_start_time = strtotime($info['ke_start_time']);
$curr = strtotime(date('Y-m-d'));
if ($curr >= $ke_start_time) {
$html_class = 'alt c2';
$html_status = "Course has started";
$html_desc = "The course has begun";
}
}
$send[] = [
'goods_id' => $good['goods_id'],
'goods_name' => $info['goods_name'],
'code' => $info['goods_serial'],
'school' => $info['ke_simple_college'],
'class' => $html_class,
'status' => $html_status,
'desc' => $html_desc,
'enroll_start_date' => $info['enroll_start_date'],
'enroll_end_date' => $info['enroll_end_date'],
'ke_start_time' => $info['ke_start_time'],
'day' => $day,
];
}
}
View::assign('membercourse', array_merge($course, $send));
return View::fetch($this->template_dir.'index');
}
}