* @version : HUOSDK 8.0 */ namespace huomp\logic\finance; use huo\model\user\UserModel; use huolib\constant\CommonConst; use huolib\constant\SettleConst; use huomp\model\common\CommonModel; use huomp\model\finance\SettleLogModel; class SettleLogLogic extends CommonModel { /*添加记录*/ public function addPayLog($data) { return (new SettleLogModel())->addPayLog($data); } protected function getWhere($param = []) { $_map = []; if (!empty($param['start_time']) && !empty($param['start_time'])) { $_map['create_time'] = ['between', [strtotime($param['start_time']), CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])]]; } else if (!empty($param['start_time'])) { $_map['create_time'] = ['gt', strtotime($param['start_time'])]; } else if (!empty($param['end_time'])) { $_map['create_time'] = ['lt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])]; } if (!empty($param['type'])) { $_map['type'] = $param['type']; } if (!empty($param['agent_name'])) { $_ag_ids = (new UserModel())->getIdsByNickName($param['agent_name']); $_map['agent_id'] = ['in', $_ag_ids]; } return $_map; } /*获取打款记录*/ public function getMemLogList($param, $page = '1,10', $order = '-create_time') { $_redata = ['count' => 0, 'list' => []]; $_map = $this->getWhere($param); $_model = new SettleLogModel(); $_count = $_model->where($_map)->count('id'); if (empty($_count)) { return $_redata; } $_order = $_model->orderFilter($order); $_file = ['id', 'agent_id', 'order_id', 'amount', 'code', 'type', 'cardholder', 'banknum', 'msg', 'result', 'query_result', 'create_time']; $_list = $_model->with('agent') ->where($_map) ->field($_file) ->order($_order) ->page($page) ->select(); if (is_object($_list)) { $_list = $_list->toArray(); } if (empty($_list)) { return $_redata; } foreach ($_list as $_k => $_v) { $_list[$_k]['type'] = SettleConst::getTypesMsg($_v['type']); $_list[$_k]['agent_nickname'] = !empty($_v['agent']['user_nicename']) ? $_v['agent']['user_nicename'] : ''; unset($_list[$_k]['agent']); } $_redata['count'] = $_count; $_redata['list'] = $_list; return $_redata; } /** * 获取条件下提现人数提现人数 * * @param array $map * * @return int|string */ public function getSettleCnt($map = []) { $_model = new SettleLogModel(); $_cnt = $_model->where($map)->group('agent_id')->count(); return $_cnt; } }