72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?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;
|
|
}
|
|
} |