1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types = 1);
- namespace app\store\model\member;
- use app\common\enum\member\GoldType;
- use app\common\model\member\GoldRice as GoldRiceModel;
- /**
- * 商品服务与承诺模型
- * Class Service
- */
- class GoldRice extends GoldRiceModel
- {
- // 全部
- const LIST_TYPE_ALL = 'all';
- // 收入
- const LIST_TYPE_IN = 'in';
- // 支出
- const LIST_TYPE_OUT = 'out';
- /**
- * 获取列表记录
- * @param string $dataType 类型
- * @param array $param
- * @return \think\Paginator
- * @throws \think\db\exception\DbException
- */
- // public function getList(string $dataType = self::LIST_TYPE_ALL,array $param = [])
- // {
- // // 检索查询条件
- // $filter = $this->getFilter($param);
- // // 设置订单类型条件
- // $dataTypeFilter = $this->getFilterDataType($dataType);
- // return $this->where($dataTypeFilter)
- // ->where($filter)
- // ->order('id','desc')
- // ->paginate();
- // }
- /**
- * 获取查询条件
- * @param array $param
- * @return array
- */
- private function getFilter(array $param = [])
- {
- // 默认查询参数
- $params = $this->setQueryDefaultValue($param, ['userId' => 0]);
- // 检索查询条件
- $filter = [];
- $params['userId']>0 && $filter[] = ['user_id', $params['userId']];
- return $filter;
- }
- /**
- * 设置类型条件
- * @param string $dataType
- * @return array
- */
- private function getFilterDataType(string $dataType = self::LIST_TYPE_ALL): array
- {
- // 数据类型
- $filter = [];
- switch ($dataType) {
- case self::LIST_TYPE_ALL:
- $filter = [];
- break;
- case self::LIST_TYPE_IN:
- $filter = [
- ['type', '=', GoldType::IN],
- ];
- break;
- case self::LIST_TYPE_OUT:
- $filter = [
- ['type', '=', GoldType::OUT],
- ];
- break;
- }
- return $filter;
- }
- }
|