* @version : H5IOS 1.0 */ namespace huosdk\h5ios\core\logic; use huo\model\common\CommonModel; use huosdk\h5ios\core\constant\CommonConst; use huosdk\h5ios\core\model\GamePriceModel; class GamePriceLogic extends CommonModel { protected $base_field = []; /** * 转换查询条件 * * @param array $param * * @return array */ public function getWhere($param = []) { $_map = []; /* 时间搜索 */ if (!empty($param['start_time']) && !empty($param['end_time'])) { $_map['create_time'] = [ 'between', [ strtotime($param['start_time']), CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time']) ] ]; } elseif (!empty($param['start_time'])) { $_map['create_time'] = ['egt', strtotime($param['start_time'])]; } elseif (!empty($param['end_time'])) { $_map['create_time'] = ['elt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])]; } /* 删除状态搜索 */ if (!empty($param['is_delete'])) { $_map['is_delete'] = $param['is_delete']; } /* 计费点code搜索 */ if (!empty($param['product_code'])) { $_map['product_code'] = $param['product_code']; } /* 应用ID搜索 */ if (!empty($param['app_id'])) { $_map['app_id'] = $param['app_id']; } /* 渠道ID搜索 */ if (!empty($param['agent_id'])) { $_map['agent_id'] = $param['agent_id']; if (CommonConst::CONST_ADMIN_SEARCH_ZERO == $param['agent_id']) { $_map['agent_id'] = CommonConst::CONST_ZERO; } } return $_map; } /** * 获取列表底层函数 * * @param array $where 搜索条件 * @param string $page 列表个数 * @param string $order 排序 * @param array $field 附加字段 * * @return array ['count'=>0,'list'=>[]] */ public function getList($where = [], $page = '1,10', $order = '', $field = []) { $_map = $where; $_field = $field; $_model = new GamePriceModel(); $_count = $_model->where($_map)->count(); if (empty($_count)) { return [ 'count' => 0, 'list' => [] ]; } $_order = $this->orderFilter($order); $_datas = $_model->field($_field)->where($_map)->order($_order)->page($page)->select(); if (is_object($_datas)) { $_datas = $_datas->toArray(); } if (empty($_datas)) { return [ 'count' => 0, 'list' => [] ]; } return [ 'count' => $_count, 'list' => $_datas ]; } /** * 获取后台列表 * * @param array $where 搜索条件 * @param string $page 列表个数 * @param string $order 排序 * @param array $field 附加字段 * * @return array ['count'=>0,'list'=>[]] */ public function getAdminList($where = [], $page = '1,10', $order = '-product_price,-app_id', $field = []) { $_map = $this->getWhere($where); $_field = $this->base_field; if (!empty($field)) { $_field = array_merge($_field, $field);/* 获取后台字段 */ } return $this->getList($_map, $page, $order, $_field); } }