parent
63bf6801dc
commit
b94e54aec7
|
@ -206,9 +206,9 @@ class Common extends Api
|
||||||
public function get_week_by_time(){
|
public function get_week_by_time(){
|
||||||
$time = $this->request->get('time/s','');
|
$time = $this->request->get('time/s','');
|
||||||
|
|
||||||
if(empty($time)){
|
// if(empty($time)){
|
||||||
$this->error(__('缺少必要参数'));
|
// $this->error(__('缺少必要参数'));
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
$res = (new Virtual)->getWeekByTime($time);
|
$res = (new Virtual)->getWeekByTime($time);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\Api;
|
||||||
|
use app\common\model\style\HomeImages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信工具类接口
|
||||||
|
*/
|
||||||
|
class WechatUtil extends Api
|
||||||
|
{
|
||||||
|
protected $noNeedLogin = ['scheme'];
|
||||||
|
protected $noNeedRight = ['*'];
|
||||||
|
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->success('请求成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiTitle(微信小程序生成url-scheme)
|
||||||
|
* @ApiSummary(微信小程序生成url-scheme)
|
||||||
|
* @ApiRoute(/api/wechat_util/scheme)
|
||||||
|
* @ApiMethod(POST)
|
||||||
|
* @ApiParams (name="id", type="integer", required=true, description="会员ID")
|
||||||
|
* @ApiParams (name="name", type="string", required=true, description="用户名")
|
||||||
|
* @ApiParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
|
||||||
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
||||||
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
||||||
|
* @ApiReturn({
|
||||||
|
"code" => 1,
|
||||||
|
"msg" => "获取成功",
|
||||||
|
"data" => {}
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function scheme() {
|
||||||
|
|
||||||
|
$home_data = [];
|
||||||
|
$home_data['top_image'] = [
|
||||||
|
'type' => config('site.home_top_type'),
|
||||||
|
'image' => cdnurl(config('site.home_top_image'), true),
|
||||||
|
'url' => config('site.home_top_url'),
|
||||||
|
];
|
||||||
|
//首页轮播图
|
||||||
|
$home_data['top_images'] = HomeImages::allList(1, 20);
|
||||||
|
$base_info = [
|
||||||
|
"site_name"=>config('site.name'),
|
||||||
|
// "site_logo"=>cdnurl(config('site.logo'), true),
|
||||||
|
"site_beian"=>config('site.beian'),
|
||||||
|
"site_version"=>''.config('site.version'),
|
||||||
|
"site_city"=>config('site.the_city'),
|
||||||
|
"site_timezone"=>config('site.timezone'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->success('',["base_info"=>$base_info,"home_data"=>$home_data]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -85,13 +85,15 @@ class Classes extends Base
|
||||||
*/
|
*/
|
||||||
public function detail(){
|
public function detail(){
|
||||||
$id = $this->request->get('id/d','');
|
$id = $this->request->get('id/d','');
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
if(empty($id)){
|
if(empty($id)){
|
||||||
$this->error(__('缺少必要参数'));
|
$this->error(__('缺少必要参数'));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $this->model->detail($id);
|
$res = $this->model->detail($id,$user_id);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
// Log::log($e->getMessage());
|
// Log::log($e->getMessage());
|
||||||
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
||||||
|
@ -113,13 +115,15 @@ class Classes extends Base
|
||||||
*/
|
*/
|
||||||
public function people(){
|
public function people(){
|
||||||
$id = $this->request->get('id/d','');
|
$id = $this->request->get('id/d','');
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
if(empty($id)){
|
if(empty($id)){
|
||||||
$this->error(__('缺少必要参数'));
|
$this->error(__('缺少必要参数'));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $this->model->virtualParticipants($id);
|
$res = $this->model->virtualParticipants($id,$user_id);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
// Log::log($e->getMessage());
|
// Log::log($e->getMessage());
|
||||||
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
||||||
|
@ -258,6 +262,7 @@ class Classes extends Base
|
||||||
* @ApiParams(name = "new", type = "string",required=false,description = "平台最新:0=否,1=是")
|
* @ApiParams(name = "new", type = "string",required=false,description = "平台最新:0=否,1=是")
|
||||||
* @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
|
* @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
|
||||||
* @ApiParams(name = "feel", type = "string",required=false,description = "是否免费:0=否,1=是")
|
* @ApiParams(name = "feel", type = "string",required=false,description = "是否免费:0=否,1=是")
|
||||||
|
* @ApiParams(name = "collect", type = "int",required=false,description = "是否专查我的收藏(需登录):1=是")
|
||||||
* @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先")
|
* @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先")
|
||||||
* @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)")
|
* @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)")
|
||||||
* @ApiParams(name = "latitude", type = "string",required=false,description = "latitude")
|
* @ApiParams(name = "latitude", type = "string",required=false,description = "latitude")
|
||||||
|
@ -272,6 +277,8 @@ class Classes extends Base
|
||||||
$user = $this->auth->getUser();//登录用户
|
$user = $this->auth->getUser();//登录用户
|
||||||
if($user)$user_id = $user['id'];
|
if($user)$user_id = $user['id'];
|
||||||
$params =[];
|
$params =[];
|
||||||
|
$params["my_user_id"] = $user_id;
|
||||||
|
$params["collect"] = $this->request->get('collect/d', 0); //页数
|
||||||
$params["page"] = $this->request->get('page/d', 1); //页数
|
$params["page"] = $this->request->get('page/d', 1); //页数
|
||||||
$params["limit"] = $this->request->get('limit/d', 10); //条数
|
$params["limit"] = $this->request->get('limit/d', 10); //条数
|
||||||
$params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
|
$params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
|
||||||
|
@ -320,4 +327,39 @@ class Classes extends Base
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiTitle( 设置课程收藏和取消收藏)
|
||||||
|
* @ApiSummary(设置课程收藏和取消收藏)
|
||||||
|
* @ApiRoute(/api/school/classes/collect)
|
||||||
|
* @ApiMethod(POST)
|
||||||
|
* @ApiParams(name = "id", type = "int",required=true,description = "课程id")
|
||||||
|
* @ApiParams(name = "is_collect", type = "int",required=true,description = "收藏操作:0取消收藏,1收藏")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function collect(){
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
|
|
||||||
|
$id = $this->request->post('id/d', 0); //搜索关键字
|
||||||
|
$collect = $this->request->post('is_collect/d', 0); //搜索关键字
|
||||||
|
|
||||||
|
try{
|
||||||
|
$res = $this->model->collect($id,$user_id,$collect,'user',$user_id,true);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
$this->success('查询成功', $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -169,6 +169,8 @@ class HourOrder extends Base
|
||||||
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
|
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
|
||||||
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
|
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
|
||||||
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
|
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
|
||||||
|
* @ApiParams(name = "start_time", type = "string",required=false,description = "按开始时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)")
|
||||||
|
* @ApiParams(name = "createtime", type = "string",required=false,description = "按创建时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)")
|
||||||
* @ApiReturn({
|
* @ApiReturn({
|
||||||
*
|
*
|
||||||
*})
|
*})
|
||||||
|
@ -184,11 +186,15 @@ class HourOrder extends Base
|
||||||
$status = $this->request->get('status/s', ''); //搜索关键字
|
$status = $this->request->get('status/s', ''); //搜索关键字
|
||||||
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
|
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
|
||||||
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
|
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
|
||||||
|
|
||||||
|
$start_time = $this->request->get('start_time/s', ''); //搜索关键字
|
||||||
|
$createtime = $this->request->get('createtime/s', ''); //搜索关键字
|
||||||
|
|
||||||
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
||||||
|
|
||||||
try{
|
try{
|
||||||
//当前申请状态
|
//当前申请状态
|
||||||
$res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_order_id,$classes_lib_ids);
|
$res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_order_id,$classes_lib_ids,$start_time,$createtime);
|
||||||
// if($user_id =='670153'){
|
// if($user_id =='670153'){
|
||||||
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
|
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -86,9 +86,9 @@ class Shop extends Base
|
||||||
$params["images"] = $this->request->post('images/s','');
|
$params["images"] = $this->request->post('images/s','');
|
||||||
$params["yyzz_images"] = $this->request->post('yyzz_images/s','');
|
$params["yyzz_images"] = $this->request->post('yyzz_images/s','');
|
||||||
|
|
||||||
if(empty($id)){
|
// if(empty($id)){
|
||||||
$this->error(__('缺少必要参数'));
|
// $this->error(__('缺少必要参数'));
|
||||||
}
|
// }
|
||||||
$type = "2";
|
$type = "2";
|
||||||
$user_id = 0;
|
$user_id = 0;
|
||||||
$user = $this->auth->getUser();//登录用户
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
|
|
@ -267,6 +267,8 @@ class HourOrder extends Base
|
||||||
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
|
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
|
||||||
* @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
|
* @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
|
||||||
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
|
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
|
||||||
|
* @ApiParams(name = "start_time", type = "string",required=false,description = "按开始时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)")
|
||||||
|
* @ApiParams(name = "createtime", type = "string",required=false,description = "按创建时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)")
|
||||||
* @ApiReturn({
|
* @ApiReturn({
|
||||||
*
|
*
|
||||||
*})
|
*})
|
||||||
|
@ -274,17 +276,25 @@ class HourOrder extends Base
|
||||||
public function order_list()
|
public function order_list()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
|
|
||||||
$page = $this->request->get('page/d', 0); //页数
|
$page = $this->request->get('page/d', 0); //页数
|
||||||
$limit = $this->request->get('limit/d', 0); //条数
|
$limit = $this->request->get('limit/d', 0); //条数
|
||||||
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
|
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
|
||||||
$status = $this->request->get('status/s', ''); //搜索关键字
|
$status = $this->request->get('status/s', ''); //搜索关键字
|
||||||
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
|
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
|
||||||
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
|
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
|
||||||
|
|
||||||
|
$start_time = $this->request->get('start_time/s', ''); //搜索关键字
|
||||||
|
$createtime = $this->request->get('createtime/s', ''); //搜索关键字
|
||||||
|
|
||||||
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
||||||
|
|
||||||
try{
|
try{
|
||||||
//当前申请状态
|
//当前申请状态
|
||||||
$res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids);
|
$res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids,$start_time,$createtime);
|
||||||
// if($user_id =='670153'){
|
// if($user_id =='670153'){
|
||||||
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
|
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -74,13 +74,33 @@ class Virtual
|
||||||
//得到当前日期所在周几
|
//得到当前日期所在周几
|
||||||
$week = date("w",$time);
|
$week = date("w",$time);
|
||||||
$week = $week == 0 ? '7' : $week;
|
$week = $week == 0 ? '7' : $week;
|
||||||
|
$sub = abs(7-( 7-$week)) -1; //绝对值
|
||||||
$sub = 7 -$week;
|
|
||||||
|
|
||||||
$start_time = $time - ($sub*86400);
|
$start_time = $time - ($sub*86400);
|
||||||
date("Y-m-d",$start_time);
|
// var_dump( date("Y-m-d",$start_time));
|
||||||
|
$titles = ["周一","周二","周三","周四","周五","周六","周日"];
|
||||||
return ;
|
//循环7天
|
||||||
|
$week_arr = [];
|
||||||
|
for($i=0;$i<7;$i++){
|
||||||
|
$week_arr[$i]['active'] = false;
|
||||||
|
$week_arr[$i]['start_time'] = $start_time + ($i*86400);
|
||||||
|
$week_arr[$i]['end_time'] = strtotime("+1 day",$week_arr[$i]['start_time']) -1 ;
|
||||||
|
|
||||||
|
$week_arr[$i]['start_date'] = date("Y/m/d H:i:s",$week_arr[$i]['start_time']);
|
||||||
|
$week_arr[$i]['end_date'] = date("Y/m/d H:i:s",$week_arr[$i]['end_time']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$week_arr[$i]['day_text'] = date("m.d",$week_arr[$i]['start_time']);
|
||||||
|
|
||||||
|
|
||||||
|
$week_arr[$i]['week'] = $i+1;
|
||||||
|
$week_arr[$i]['week_text'] = $titles[$i];
|
||||||
|
if($week_arr[$i]['week'] == $week){
|
||||||
|
$week_arr[$i]['active'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $week_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,13 @@ class BaseModel extends Model
|
||||||
{
|
{
|
||||||
$timeKey = $this->timeKey;
|
$timeKey = $this->timeKey;
|
||||||
if(static::$staticTimeKey)$timeKey =static::$staticTimeKey;
|
if(static::$staticTimeKey)$timeKey =static::$staticTimeKey;
|
||||||
|
|
||||||
|
if(is_array($value)){
|
||||||
|
$timeKey = $value[0];
|
||||||
|
$value = $value[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ($value) {
|
switch ($value) {
|
||||||
case 'today':
|
case 'today':
|
||||||
case 'week':
|
case 'week':
|
||||||
|
|
|
@ -272,12 +272,32 @@ class ClassesLib extends BaseModel
|
||||||
* @return ClassesLib|null
|
* @return ClassesLib|null
|
||||||
* @throws \think\exception\DbException
|
* @throws \think\exception\DbException
|
||||||
*/
|
*/
|
||||||
public function detail($id){
|
public function detail($id,$user_id=0){
|
||||||
$self = $this->get($id,['shop','teacher']);
|
$self = $this->get($id,['shop','teacher']);
|
||||||
|
|
||||||
|
//是否收藏
|
||||||
|
$self['is_collect'] = 0;
|
||||||
|
//是否购买
|
||||||
|
$self['have_buy'] = 0;
|
||||||
|
if($user_id){
|
||||||
|
//判断是否收藏
|
||||||
|
$self['is_collect'] = Collect::where("user_id",$user_id)->where("classes_lib_id",$id)->count();
|
||||||
|
|
||||||
|
//判断用户是否已报名
|
||||||
|
$self['have_buy'] = \app\common\model\school\classes\order\Order::where("classes_lib_id",$id)
|
||||||
|
->where("user_id",$user_id)
|
||||||
|
->where("status","in",["3","6","9"])
|
||||||
|
->count() ? 1 : 0 ;
|
||||||
|
//$self['virtual_people'] = $self['virtual_people'] + 1;
|
||||||
|
//有用户进来,参与人数+1
|
||||||
|
if(!$self['have_buy'])$self['virtual_people'] = $self['virtual_people'] + 1;
|
||||||
|
}
|
||||||
//下架判断
|
//下架判断
|
||||||
// if($self['status'] != '1'){
|
// if($self['status'] != '1'){
|
||||||
// $this->error("该课程已下架");
|
// $this->error("该课程已下架");
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
//参与人数 = 虚拟人数 + 平台人数
|
//参与人数 = 虚拟人数 + 平台人数
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -288,13 +308,34 @@ class ClassesLib extends BaseModel
|
||||||
* @param $id
|
* @param $id
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function virtualParticipants($id){
|
public function virtualParticipants($id,$user_id=0){
|
||||||
//虚拟用户生成数量
|
//虚拟用户生成数量
|
||||||
$v_num = 10;
|
$v_num = 10;
|
||||||
$unpaid_user_data = $paid_user_data = [];
|
$unpaid_user_data = $paid_user_data = [];
|
||||||
|
|
||||||
|
$selfuser = null;
|
||||||
|
if($user_id){
|
||||||
|
$selfuser = User::get($user_id);
|
||||||
|
}
|
||||||
|
$user_unpaid_order = $user_paid_order =null;
|
||||||
|
if($selfuser){
|
||||||
|
$user_unpaid_order = \app\common\model\school\classes\order\Order::where("classes_lib_id",$id)
|
||||||
|
->where("status","in",["0",'-3'])
|
||||||
|
->where("user_id",$user_id)
|
||||||
|
->order("createtime desc")
|
||||||
|
->value("createtime");
|
||||||
|
$user_paid_order = \app\common\model\school\classes\order\Order::where("classes_lib_id",$id)
|
||||||
|
->where("status","in",["3",'6','9'])
|
||||||
|
->where("user_id",$user_id)
|
||||||
|
->order("createtime desc")
|
||||||
|
->value("createtime");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//参与者头像
|
//参与者头像
|
||||||
//先从订单里取出最新的10个未支付和使用中的用户,不足的用虚拟用户填充
|
//先从订单里取出最新的10个未支付的用户,不足的用虚拟用户填充
|
||||||
$user_ids = \app\common\model\school\classes\order\Order::where("classes_lib_id",$id)->where("status","in",["0",'3'])->order("createtime desc")->limit($v_num)->column("createtime","user_id");
|
$user_ids = \app\common\model\school\classes\order\Order::where("classes_lib_id",$id)->where("status","in",["0",'-3'])->order("createtime desc")->limit($v_num)->column("createtime","user_id");
|
||||||
if($user_ids){
|
if($user_ids){
|
||||||
$users = User::where("id","in",array_keys($user_ids))->select();
|
$users = User::where("id","in",array_keys($user_ids))->select();
|
||||||
foreach ($users as $user){
|
foreach ($users as $user){
|
||||||
|
@ -308,6 +349,32 @@ class ClassesLib extends BaseModel
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!$user_paid_order && $selfuser){
|
||||||
|
if($user_unpaid_order){
|
||||||
|
$unpaid_user_data[] = [
|
||||||
|
"nickname"=>$selfuser['nickname'],
|
||||||
|
"head_image"=>$selfuser['avatar'],
|
||||||
|
"classes_lib_id"=>$id,
|
||||||
|
"time"=>$user_unpaid_order,
|
||||||
|
"jointype"=>'1',
|
||||||
|
"havetype"=>'0'
|
||||||
|
];
|
||||||
|
$user_ids[$selfuser['id']] = $user_unpaid_order;
|
||||||
|
}else{
|
||||||
|
$unpaid_user_data[] = [
|
||||||
|
"nickname"=>$selfuser['nickname'],
|
||||||
|
"head_image"=>$selfuser['avatar'],
|
||||||
|
"classes_lib_id"=>$id,
|
||||||
|
"time"=>time(),
|
||||||
|
"jointype"=>'1',
|
||||||
|
"havetype"=>'0'
|
||||||
|
];
|
||||||
|
$user_ids[$selfuser['id']] = time();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//计算需要生成的虚拟用户数量
|
//计算需要生成的虚拟用户数量
|
||||||
$v_num = $v_num - count($user_ids);
|
$v_num = $v_num - count($user_ids);
|
||||||
if($v_num<0)$v_num =0;
|
if($v_num<0)$v_num =0;
|
||||||
|
@ -513,6 +580,8 @@ class ClassesLib extends BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($self_label_tag) && $self_label_tag) {
|
if (isset($self_label_tag) && $self_label_tag) {
|
||||||
$self_label_tag = implode("|",explode(',',$self_label_tag));
|
$self_label_tag = implode("|",explode(',',$self_label_tag));
|
||||||
$selfetch = $selfetch->whereRaw(" {$a}self_label_tag REGEXP '({$self_label_tag})'");
|
$selfetch = $selfetch->whereRaw(" {$a}self_label_tag REGEXP '({$self_label_tag})'");
|
||||||
|
@ -530,6 +599,19 @@ class ClassesLib extends BaseModel
|
||||||
$classes_label_ids = implode("|",explode(',',$classes_label_ids));
|
$classes_label_ids = implode("|",explode(',',$classes_label_ids));
|
||||||
$selfetch = $selfetch->whereRaw(" {$a}classes_label_ids REGEXP '({$classes_label_ids})'");
|
$selfetch = $selfetch->whereRaw(" {$a}classes_label_ids REGEXP '({$classes_label_ids})'");
|
||||||
}
|
}
|
||||||
|
$collect_classes_lib_ids = [];
|
||||||
|
//需登录查询条件:
|
||||||
|
if(isset($my_user_id) && $my_user_id){
|
||||||
|
//得到我收藏的课程ids
|
||||||
|
$collect_classes_lib_ids = Collect::where("user_id",$my_user_id)->column("classes_lib_id");
|
||||||
|
//专查我的收藏
|
||||||
|
if(isset($collect) && $collect){
|
||||||
|
$selfetch = $selfetch->where("{$a}id","in",$collect_classes_lib_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -569,8 +651,12 @@ class ClassesLib extends BaseModel
|
||||||
|
|
||||||
|
|
||||||
$selfetch = $selfetch->paginate($per_page);
|
$selfetch = $selfetch->paginate($per_page);
|
||||||
// var_dump(self::getLastSql());
|
|
||||||
//额外附加数据
|
//额外附加数据
|
||||||
|
foreach ($selfetch as $row) { //迭代器魔术方法遍历,填值自动引用传值
|
||||||
|
//设置是否已收藏
|
||||||
|
$row->is_collect = in_array($row->id,$collect_classes_lib_ids) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $selfetch;
|
return $selfetch;
|
||||||
}
|
}
|
||||||
|
@ -614,4 +700,58 @@ class ClassesLib extends BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**设置收藏
|
||||||
|
* @param $id
|
||||||
|
* @param int $user_id
|
||||||
|
* @param int $collect 0取消收藏 1收藏
|
||||||
|
* @param bool $check
|
||||||
|
* @param bool $trans
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function collect($id,$user_id,$collect,$oper_type='user',$oper_id=0,$trans=false){
|
||||||
|
$classes_lib = self::where("id",$id)->find();
|
||||||
|
if(!$classes_lib)throw new \Exception("找不到课程!");
|
||||||
|
//判断逻辑
|
||||||
|
if($trans){
|
||||||
|
self::beginTrans();
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
//事务逻辑
|
||||||
|
$where = [
|
||||||
|
"user_id"=>$user_id,
|
||||||
|
"classes_lib_id"=>$id,
|
||||||
|
"weigh"=>$classes_lib["weigh"],
|
||||||
|
];
|
||||||
|
//查询是否已收藏
|
||||||
|
$res1 = Collect::where($where)->find();
|
||||||
|
if($collect){
|
||||||
|
if(!$res1){
|
||||||
|
//未收藏,添加收藏
|
||||||
|
$res1 = new Collect();
|
||||||
|
$res1->allowField(true)->save($where);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//取消收藏
|
||||||
|
$res1 = Collect::where($where)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($trans){
|
||||||
|
self::commitTrans();
|
||||||
|
}
|
||||||
|
}catch (\Exception $e){
|
||||||
|
if($trans){
|
||||||
|
self::rollbackTrans();
|
||||||
|
}
|
||||||
|
throw new \Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
$where["is_collect"] = $collect;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ class Order extends BaseModel
|
||||||
$tableFields = (new static)->getTableFields();
|
$tableFields = (new static)->getTableFields();
|
||||||
foreach ($tableFields as $fields)
|
foreach ($tableFields as $fields)
|
||||||
{
|
{
|
||||||
if(in_array($fields, ['status','classes_lib_id']))continue;
|
if(in_array($fields, ['createtime','start_time','status','classes_lib_id']))continue;
|
||||||
// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
|
// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,13 +185,19 @@ class Order extends BaseModel
|
||||||
if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
|
if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
|
||||||
if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
|
if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
|
||||||
if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id", '=', $whereData['keywords']);
|
if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id", '=', $whereData['keywords']);
|
||||||
if (isset($whereData['time'])&&$whereData['time']){
|
if (isset($whereData['createtime'])&&$whereData['createtime']){
|
||||||
|
|
||||||
$model = $model->time($whereData['time']);
|
$model = $model->time(["createtime",$whereData['createtime']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($whereData['start_time'])&&$whereData['start_time']){
|
||||||
|
|
||||||
|
$model = $model->time(["start_time",$whereData['start_time']]);
|
||||||
}
|
}
|
||||||
if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']);
|
if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']);
|
if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']);
|
||||||
if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']);
|
if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']);
|
||||||
return $model;
|
return $model;
|
||||||
|
@ -247,7 +253,7 @@ class Order extends BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function allList($user_id,$page, $limit,$keywords,$status,$classes_order_id=0,$classes_lib_id = []){
|
public static function allList($user_id,$page, $limit,$keywords,$status,$classes_order_id=0,$classes_lib_id = [],$start_time = null,$createtime = null){
|
||||||
$with_field = [
|
$with_field = [
|
||||||
'user'=>['nickname','mobile','avatar','realname'],
|
'user'=>['nickname','mobile','avatar','realname'],
|
||||||
'base'=>['*'],
|
'base'=>['*'],
|
||||||
|
@ -261,7 +267,7 @@ class Order extends BaseModel
|
||||||
$FINISH = '3';
|
$FINISH = '3';
|
||||||
$alisa = (new self)->getWithAlisaName();
|
$alisa = (new self)->getWithAlisaName();
|
||||||
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
|
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
|
||||||
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,'classes_lib_id'=>$classes_lib_id];
|
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,'classes_lib_id'=>$classes_lib_id,"start_time"=>$start_time,"createtime"=>$createtime];
|
||||||
// if($type)$serch_where['type'] = $type;
|
// if($type)$serch_where['type'] = $type;
|
||||||
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
|
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +311,7 @@ class Order extends BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function workList($page, $limit,$keywords,$status,$classes_order_id=0,$user_id=0,$classes_lib_id = [],$classes_lib_ids = []){
|
public static function workList($page, $limit,$keywords,$status,$classes_order_id=0,$user_id=0,$classes_lib_id = [],$classes_lib_ids = [],$start_time = null,$createtime = null){
|
||||||
$with_field = [
|
$with_field = [
|
||||||
'user'=>['nickname','mobile','avatar','realname'],
|
'user'=>['nickname','mobile','avatar','realname'],
|
||||||
'base'=>['*'],
|
'base'=>['*'],
|
||||||
|
@ -319,7 +325,7 @@ class Order extends BaseModel
|
||||||
$FINISH = '3';
|
$FINISH = '3';
|
||||||
$alisa = (new self)->getWithAlisaName();
|
$alisa = (new self)->getWithAlisaName();
|
||||||
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
|
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
|
||||||
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids];
|
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"start_time"=>$start_time,"createtime"=>$createtime];
|
||||||
// if($type)$serch_where['type'] = $type;
|
// if($type)$serch_where['type'] = $type;
|
||||||
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
|
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue