初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model\app\exam;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use app\api\model\app\exam\WarehouseQuestion;
|
||||
class Exercises extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_exam_exercises';
|
||||
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
public function course()
|
||||
{
|
||||
return $this->belongsTo('app\api\model\course\Course', 'bind_course', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取练习包含的题目数量
|
||||
* @param $exercisesId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getExercisesQuestionCount($exercisesId){
|
||||
$notInExercisesGroupIds = \app\api\model\app\exam\ExercisesBindWarehouseGroup::getNotInExercisesGroupIds($exercisesId);
|
||||
|
||||
return WarehouseQuestion::where([
|
||||
'group_id'=>['NOT IN',$notInExercisesGroupIds]
|
||||
])->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单中的会员卡与规格对应的信息
|
||||
* @param $cardIdSku 格式 ID_SKU
|
||||
* @return false
|
||||
*/
|
||||
public static function getPayDetail($exercisesId){
|
||||
|
||||
$data = self::where([
|
||||
'id'=>$exercisesId,
|
||||
'status'=>1,
|
||||
'sales_type'=>2
|
||||
])->field('detail',true)->find();
|
||||
|
||||
if(!$data){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
|
||||
$data['price_marking'] = $data['price'] = $data['pay_price'];
|
||||
$data['type'] = 'exercises';
|
||||
|
||||
$extendInfo = \app\common\model\goods\Handle::parseGoodsExtendInfo($data['id'],'exercises');
|
||||
|
||||
$data = array_merge($data,$extendInfo);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user