* @version : HUOSDK 8.0 */ namespace huo\controller\agent; use huo\controller\common\Base; use huo\logic\agent\AgentDayLogic; use huo\logic\agent\AgentLogic; use huolib\constant\AgentConst; use huolib\status\CommonStatus; class Data extends Base { /** * 获取渠道平台币充值记录 * * @param int $agent_id * @param array $where * @param string $page * @param string $order * * @return array */ public function getTgDataIndex($agent_id, $where, $page = '1,10', $order = '-date') { $_map['agent_id'] = ['in', (new AgentLogic())->getAgentIds($agent_id, true)]; $_map = $_map + $where; $_rdata = (new AgentDayLogic())->getGroupList([], $_map, $page, $order); $_code = CommonStatus::NO_ERROR; return $this->huoSuccess($_code, CommonStatus::getMsg($_code), $_rdata); } /** * @param int $agent_id * @param string $field sum_money user_cnt reg_cnt pay_user_cnt * @param string $start_date * @param string $ent_date * * @return array */ public function getTgReportData($agent_id, $field = 'sum_money', $start_date = '', $ent_date = '') { $_map['start_time'] = $start_date; $_map['end_time'] = $ent_date; $_agent_ids = (new AgentLogic())->getAgentIds($agent_id); if (1 == count($_agent_ids)) { $_map['agent_id'] = $_agent_ids[0]; } elseif (1 < count($_agent_ids)) { $_map['agent_id'] = ['in', $_agent_ids]; } else { $_code = CommonStatus::INVALID_PARAMS; return $this->huoSuccess($_code, CommonStatus::getMsg($_code)); } $_role_type = (new Agent())->getRoleType($agent_id); $_group = ''; if (AgentConst::ROLE_TYPE_AGENT == $_role_type) { $_field = $field.' as data_value'; } else { $_field = 'sum('.$field.') as data_value'; $_group = 'date'; } $_rdata = (new AgentDayLogic())->getDataByField($_field, $_map, $_group); $_code = CommonStatus::NO_ERROR; return $this->huoSuccess($_code, CommonStatus::getMsg($_code), $_rdata); } }