You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/wap/model/topic/CertificateRelated.php

59 lines
2.4 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\wap\model\topic;
use traits\ModelTrait;
use basic\ModelBasic;
use app\wap\model\topic\ExaminationRecord;
use app\wap\model\special\Special as SpecialModel;
use app\wap\model\special\SpecialSource;
use app\wap\model\special\SpecialWatch;
/**
* 证书关联记录 Model
*/
class CertificateRelated extends ModelBasic
{
use ModelTrait;
/**检查是否存在关联
* @param $id
* @param $obtain
*/
public static function checkAssociation($id, $obtain)
{
return self::where(['related' => $id, 'obtain' => $obtain])->count() > 0 ? true : false;
}
/**检查是否达到获得证书要求
* @param $id 专题ID
* @param $is_light 是否为轻专题
* @param $obtain
*/
public static function getCertificateRelated($id, $is_light, $obtain, $uid)
{
$related = self::where(['related' => $id, 'obtain' => $obtain, 'is_show' => 1])->find();
if (!$related) return false;
$record = CertificateRecord::setWhere($uid)->where(['source_id' => $id, 'obtain' => $obtain])->find();
if ($record) return false;
if ($obtain == 1) {
$count = $is_light == 1 ? 1 : SpecialSource::where(['special_id' => $id])->count();
$watchCount = SpecialWatch::where(['special_id' => $id, 'uid' => $uid])->where('percentage', '>=', (int)$related['condition'])->count();
return $count == $watchCount ? true : false;
} else if ($obtain == 2) {
$record = ExaminationRecord::where(['test_id' => $id, 'uid' => $uid, 'type' => 2, 'is_submit' => 1])->order('id desc')->find();
if (!$record) return false;
return $record['score'] >= $related['condition'] ? true : false;
}
}
}