123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- /**
- * GamePriceLogic.php UTF-8
- *
- *
- * @date : 2020/9/15 15:09
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @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);
- }
- }
|