| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- declare (strict_types=1);
- namespace app\model\api;
- use library\basic\BaseModel;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class RechargeConfig extends BaseModel
- {
- /**
- * 获取充值配置列表
- * @param array $where 查询条件
- * @param string $field 查询字段
- * @param int $page 页码
- * @param int $pageCount 每页数量
- * @param string $order 排序
- * @return array
- */
- public function getList($where = [], $field = '*', $page = 1, $pageCount = 20, $order = 'sort asc,id asc')
- {
- $data = $this
- ->where($where)
- ->field($field)
- ->order($order)
- ->paginate(['list_rows' => $pageCount, 'page' => $page])
- ->toArray();
- return [$data['total'], $data['data']];
- }
- /**
- * 获取显示的充值配置
- * @return array
- */
- public function getShowList()
- {
- return $this
- ->where('is_show', 1)
- ->order('sort asc,id asc')
- ->select()
- ->toArray();
- }
- /**
- * 获取默认充值配置
- * @return array|null
- */
- public function getDefault()
- {
- return $this
- ->where('is_default', 1)
- ->where('is_show', 1)
- ->find();
- }
- /**
- * 根据ID获取充值配置
- * @param int $id 配置ID
- * @return array|null
- */
- public function getById($id)
- {
- return $this->where('id', $id)->find();
- }
- /**
- * 保存充值配置
- * @param array $data 数据
- * @return bool|int
- */
- public function saveData($data)
- {
- return $this->insert($data);
- }
- /**
- * 更新充值配置
- * @param int $id 配置ID
- * @param array $data 数据
- * @return bool
- */
- public function updateConfig($id, $data): bool
- {
- return $this->where('id', $id)->update($data) !== false;
- }
- /**
- * 删除充值配置
- * @param int $id 配置ID
- * @return bool
- */
- public function deleteData($id)
- {
- return $this->where('id', $id)->delete();
- }
- }
|