add
This commit is contained in:
53
app/api/model/CourseDetails.php
Normal file
53
app/api/model/CourseDetails.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\library\DatabaseRoute;
|
||||
use app\common\model\Common;
|
||||
use ba\Random;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use think\Model;
|
||||
|
||||
class CourseDetails extends Model
|
||||
{
|
||||
|
||||
|
||||
public static function courseSets($courseId, $isPrice, $wholesalePrice)
|
||||
{
|
||||
|
||||
$db = Db::connect(DatabaseRoute::getConnection('course_details', ['course_id' => $courseId]));
|
||||
$courseDetailsSetVos = $db->name('course_details')
|
||||
->alias('c')
|
||||
->field([
|
||||
'c.course_id' => 'courseId',
|
||||
'c.course_details_id' => 'courseDetailsId',
|
||||
'c.course_details_name' => 'courseDetailsName',
|
||||
'c.video_url' => 'videoUrl',
|
||||
'c.price' => 'price',
|
||||
'c.sort' => 'sort',
|
||||
'c.is_price' => 'isPrice',
|
||||
'c.title_img' => 'titleImg',
|
||||
'c.good_num' => 'goodNum',
|
||||
])
|
||||
->where('c.course_id', $courseId)
|
||||
->order('c.sort', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
$db->close();
|
||||
foreach ($courseDetailsSetVos as $k => &$v) {
|
||||
$v['courseId'] = (string) $v['courseId'];
|
||||
$v['courseDetailsId'] = (string) $v['courseDetailsId'];
|
||||
if(empty($wholesalePrice)) {
|
||||
$v['wholesalePrice'] = 0;
|
||||
}else {
|
||||
$v['wholesalePrice'] = $wholesalePrice;
|
||||
}
|
||||
if($isPrice != 1) {
|
||||
$v['isPrice'] = 2;
|
||||
}
|
||||
}
|
||||
return $courseDetailsSetVos;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user