123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- /**
- * GmMemLogic.php UTF-8
- *
- *
- * @date : 2018/6/6 10:45
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @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
- ];
- }
- }
|