123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- 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;
- }
- }
|