select($moneyRecordSelect) -> where($moneyRecordWhere) -> whereBetween('money_time', $moneyRecordBetween) -> offset($begin) -> limit($pageSize) -> orderBy($orderBy) -> get(); return $result; } /** * 盈亏记录总数 * * @access public * @param mixed $moneyRecordWhere 查询条件 * @param mixed $moneyRecordBetween 查询条件区间 * @return array JsonString */ public function moneyRecordTotal($moneyRecordWhere, $moneyRecordBetween) { $result = $this -> where($moneyRecordWhere) -> whereBetween('money_time', $moneyRecordBetween) -> count(); return $result; } /** * 盈亏记录 * * @access public * @param mixed $moneyRecordSelect 查询参数 * @param mixed $moneyRecordWhere 查询条件 * @param mixed $moneyRecordBetween 查询条件区间 * @param mixed $orWhere or查询 * @return array JsonString */ public function moneyRecordAll($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $orWhere=[]) { $result = $this -> select($moneyRecordSelect) -> where($moneyRecordWhere); if ($moneyRecordBetween) { $result = $result-> whereBetween('money_time', $moneyRecordBetween); } if ($orWhere) { // 循环获取or查询. foreach ($orWhere as $value) { $result = $result->where( function ($query) use ($value) { foreach ($value as $k => $v) { if ($k === 0) { $query = $query->where([$v[0] => $v[1]]); } else { $query = $query->orWhere([$v[0] => $v[1]]); } } } ); } } $result = $result->get()->toArray(); return $result; } }