// +---------------------------------------------------------------------- namespace app\services\user\member; use app\dao\user\SecurityCodeRecordDao; use app\dao\user\SecurityCategoryDao; use app\services\BaseServices; use crmeb\exceptions\AdminException; /** * Class MemberRightServices * @package app\services\user */ class SecurityCategoryServices extends BaseServices { /** * MemberCardServices constructor. * @param securityCategoryDao $securityCategoryDao */ public function __construct(SecurityCategoryDao $securityCategoryDao) { $this->dao = $securityCategoryDao; } /** * @param array $where * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getSearchList(array $where = []) { [$page, $limit] = $this->getPageValue(); $list = $this->dao->getSearchList($where, $page, $limit); $count = $this->dao->count($where); return compact('list', 'count'); } /** * 编辑保存 * @param int $id * @param array $data */ public function save(int $id, array $data) { if (!$data['point']) throw new AdminException(400630); if (!$data['name'] || !$data['price']) throw new AdminException(400631); //TODO $save没有使用 if ($id>0) { $data['update_time'] = time(); return $this->dao->update($id, $data); } else { $data['add_time'] = time(); $data['status'] = 1; return $this->dao->save($data); } } /** * 列表操作 * @param int $id * @param array $data */ public function setValue(int $id, array $data) { if (!is_numeric($id) || !$id) throw new AdminException(100100); if (!isset($data['field']) || !isset($data['value']) || !$data['field']) throw new AdminException(100100); $this->dao->update($id, [$data['field'] => $data['value']]); } /** * 获取单条信息 * @param array $where * @return array|bool|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getOne(array $where) { if (!$where) return false; return $this->dao->getOne($where); } /** * 查看某权益是否开启 * @param $rightType * @return bool */ public function getMemberRightStatus($rightType) { if (!$rightType) return false; $status = $this->dao->value(['right_type' => $rightType], 'status'); if ($status) return true; return false; } }