68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\common\repository;
|
|
|
|
use app\common\newmodel\SubscriptionModel;
|
|
|
|
class SubscriptionReposotpry extends SubscriptionModel
|
|
{
|
|
|
|
/**
|
|
* 根据Uid和Articleid查询部分Chapterid function
|
|
*
|
|
* @author dotdotdot <6383846@qq.com>
|
|
* @date 2022-08-17
|
|
* @param array $fields
|
|
* @param integer $uid
|
|
* @param integer $articleid
|
|
* @param array $chapterid
|
|
* @return array
|
|
*/
|
|
public function selectByUidAndArticleidInChapterid(array $fields, int $uid, int $articleid, array $chapterid): array
|
|
{
|
|
return SubscriptionModel::field($fields)->where(['uid' => $uid, 'articleid' => $articleid])->whereIn('chapterid', $chapterid)->group('id')->select()->toArray();
|
|
}
|
|
|
|
/**
|
|
* 查询单集解锁 function
|
|
*
|
|
* @author dotdotdot <6383846@qq.com>
|
|
* @date 2022-08-17
|
|
* @param integer $uid
|
|
* @param integer $articleid
|
|
* @param integer $chapterid
|
|
* @return integer
|
|
*/
|
|
public function selectUnlockOnce(int $uid, int $articleid, int $chapterid): int
|
|
{
|
|
return SubscriptionModel::where(['uid' => $uid, 'articleid' => $articleid, 'chapterid' => $chapterid, 'buytype' => 1])->count('id');
|
|
}
|
|
|
|
/**
|
|
* 查询全部解锁 function
|
|
*
|
|
* @author dotdotdot <6383846@qq.com>
|
|
* @date 2022-08-17
|
|
* @param integer $uid
|
|
* @param integer $articleid
|
|
* @return integer
|
|
*/
|
|
public function selectUnlockAll(int $uid, int $articleid): int
|
|
{
|
|
return SubscriptionModel::where(['uid' => $uid, 'articleid' => $articleid, 'chapterid' => 0, 'buytype' => 2])->count('id');
|
|
}
|
|
|
|
/**
|
|
* 插入数据 function
|
|
*
|
|
* @author dotdotdot <6383846@qq.com>
|
|
* @date 2022-08-17
|
|
* @param array $data
|
|
* @return integer
|
|
*/
|
|
public function insert(array $data): int
|
|
{
|
|
return SubscriptionModel::insert($data);
|
|
}
|
|
}
|