* @version : HUOSDK 8.0 */ namespace huo\logic\finance; use huo\logic\member\MemberLogic; use huo\model\common\CommonModel; use huo\model\finance\GmMemModel; use huolib\constant\CommonConst; class GmMemLogic extends CommonModel { /** * @param array $param * * @return array */ protected function getWhere($param = []) { $_map = []; if (!empty($param['start_time']) && !empty($param['end_time'])) { $_map['gm_mem_model.create_time'] = ['between', [strtotime($param['start_time']), CommonConst::CONST_DAY_SECONDS + strtotime( $param['end_time'] )]]; } else if (!empty($param['start_time'])) { $_map['gm_mem_model.create_time'] = ['gt', strtotime($param['start_time'])]; } else if (!empty($param['end_time'])) { $_map['gm_mem_model.create_time'] = ['lt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])]; } if (!empty($param['mem_id'])) { $_map['mem_id'] = $param['mem_id']; } if (!empty($param['username'])) { $_mem_ids = (new MemberLogic())->getIdsByUsername($param['username']); $_map['mem_id'] = ['in', $_mem_ids]; } if (!empty($param['app_id'])) { $_map['app_id'] = $param['app_id']; } return $_map; } public function getField($agent_id) { return []; } /** * 获取记录 * * @param $param * @param string $page * @param string $order * * @return array */ public function getMemList($param = [], $page = '1,10', $order = '-create_time') { $_map = $this->getWhere($param); $_field = [ 'mem_id', 'app_id', 'sum_money', 'total', 'remain', ]; return $this->getList($_field, $_map, $page, $order); } /** * 获取列表 * * @param array $field * @param array $where * @param string $page * @param string $order * * @return array */ public function getList($field = [], $where, $page = '1,10', $order = '-create_time') { $_map = $where; $_model = new GmMemModel(); $_count = $_model->alias('gm_mem_model')->where($_map)->count(); if (empty($_count)) { return [ 'count' => 0, 'list' => [] ]; } $_field = $field; if (empty($field)) { $_field = []; } $_order = $_model->orderFilter($order); $_datas = $_model ->alias('gm_mem_model') ->with('mem') ->with('game') ->where($where) ->field($_field) ->order($_order) ->page($page) ->select(); if (is_object($_datas)) { $_datas = $_datas->toArray(); } if (empty($_datas)) { return [ 'count' => $_count, 'list' => [] ]; } return [ 'count' => $_count, 'list' => $_datas ]; } }