123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Bear
- * Date: 2018/12/13
- * Time: 下午4:59
- */
- namespace app\main\service;
- use app\common\library\Redis;
- use app\common\library\Ssdb;
- use app\common\model\UserCollect;
- use app\main\constants\AdminConstants;
- use app\main\constants\ApiConstants;
- use app\main\constants\CacheConstants;
- use app\main\constants\UserConstants;
- use app\main\helper\ArrayHelper;
- use app\main\helper\NumberHelper;
- use app\main\helper\StringHelper;
- /**
- * 用户统计分析
- * Class UserCollectService
- * @package app\main\service
- */
- class UserCollectService extends BaseService
- {
- protected $default = [
- 'follow' => 0,
- 'recharge' => 0,
- 'increase' => 0,
- 'increase_m' => 0,
- 'increase_f' => 0,
- 'increase_fllow' => 0,
- 'increase_recharge' => 0,
- 'unfollow_num' => 0,
- 'net_follow_num' => 0,
- 'day_recharge_user_money' => 0,
- 'day_recharge_user_count' => 0,
- ];
- protected $replaceFields = [
- 'adminId' => 'admin_id',
- 'increaseM' => 'increase_m',
- 'increaseF' => 'increase_f',
- 'increaseFllow' => 'increase_fllow',
- 'unfollowNum' => 'unfollow_num',
- 'netFollowNum' => 'net_follow_num',
- 'increaseRecharge' => 'increase_recharge',
- 'dayRechargeUserCount' => 'day_recharge_user_count',
- 'dayRechargeUserMoney' => 'day_recharge_user_money',
- 'date' => 'createdate',
- ];
- /**
- * @var UserCollectService
- */
- protected static $self = NULL;
- /**
- * @return UserCollectService
- */
- public static function instance()
- {
- if (self::$self == NULL) {
- self::$self = new self();
- }
- return self::$self;
- }
- /**
- * @return UserCollect
- */
- public function getUserCollectModel()
- {
- return model('UserCollect');
- }
- /**
- * 获取今日数据
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getMigrateTodayData($admin_id)
- {
- $default = $this->default;
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_USER_TODAY, ['adminId' => $admin_id])->data;
- if (!$data) {
- return $this->setData($default)->getReturn();
- }
- $replaceFields = $this->replaceFields;
- $data = ArrayHelper::array_replace_key($data, $replaceFields);
- $data = array_merge($default, $data);
- return $this->setData($data)->getReturn();
- }
- /**
- * 获取今天的用户统计数据
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectToday($admin_id)
- {
- $admin_id = (array)AdminService::instance()->getAdminId($admin_id)->data;
- $default = $this->default;
- $fields = [
- 'IFNULL(SUM(increase),0)' => 'increase',
- 'IFNULL(SUM(increase_m),0)' => 'increase_m',
- 'IFNULL(SUM(increase_f),0)' => 'increase_f',
- 'IFNULL(SUM(increase_fllow),0)' => 'increase_fllow',
- 'IFNULL(SUM(increase_recharge),0)' => 'increase_recharge',
- 'IFNULL(SUM(guide_follow_num),0)' => 'guide_follow_num',
- 'IFNULL(SUM(unfollow_num),0)' => 'unfollow_num',
- 'IFNULL(SUM(net_follow_num),0)' => 'net_follow_num',
- 'IFNULL(SUM(day_recharge_user_money),0)' => 'day_recharge_user_money',
- 'IFNULL(SUM(day_recharge_user_count),0)' => 'day_recharge_user_count',
- ];
- try {
- //取数据库数据
- $where = [
- 'type' => UserConstants::USER_COLLECT_TYPE_DAY,
- 'createdate' => date('Ymd', time()),
- 'admin_id' => ['in', $admin_id],
- ];
- $data = $this->getUserCollectModel()
- ->where($where)
- ->field($fields)
- ->find()
- ->toArray();
- if ($data) {
- if ($data['increase']) {
- $data['follow'] = NumberHelper::getFloat($data['increase_fllow'] * 100 / $data['increase']);
- $data['recharge'] = NumberHelper::getFloat($data['increase_recharge'] * 100 / $data['increase']);
- $data['guide_follow_num_percent'] = NumberHelper::getFloat($data['guide_follow_num'] * 100 / $data['increase']);
- $data['unfollow_num_percent'] = NumberHelper::getFloat($data['unfollow_num'] * 100 / $data['increase']);
- $data['net_follow_num_percent'] = NumberHelper::getFloat($data['net_follow_num'] * 100 / $data['increase']);
- } else {
- $data['follow'] = 0;
- $data['recharge'] = 0;
- $data['guide_follow_num_percent'] = 0;
- $data['unfollow_num_percent'] = 0;
- $data['net_follow_num_percent'] = 0;
- }
- } else {
- $data = $default;
- }
- $pay = intval($data['increase_recharge'] ?? 0);
- //算 支付比例
- if ($pay && $data['increase']) {
- $data['recharge'] = round($pay * 100 / $data['increase'], 2);
- }
- return $this->setData($data)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData($default)->getReturn();
- }
- }
- /**
- * 获取昨日统计数据
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectYesterday($admin_id)
- {
- $admin_id = (array)AdminService::instance()->getAdminId($admin_id)->data;
- $default = $this->default;
- $fields = [
- 'IFNULL(SUM(increase),0)' => 'increase',
- 'IFNULL(SUM(increase_m),0)' => 'increase_m',
- 'IFNULL(SUM(increase_f),0)' => 'increase_f',
- 'IFNULL(SUM(increase_fllow),0)' => 'increase_fllow',
- 'IFNULL(SUM(increase_recharge),0)' => 'increase_recharge',
- 'IFNULL(SUM(guide_follow_num),0)' => 'guide_follow_num',
- 'IFNULL(SUM(unfollow_num),0)' => 'unfollow_num',
- 'IFNULL(SUM(net_follow_num),0)' => 'net_follow_num',
- 'IFNULL(SUM(day_recharge_user_money),0)' => 'day_recharge_user_money',
- 'IFNULL(SUM(day_recharge_user_count),0)' => 'day_recharge_user_count',
- ];
- try {
- $where = [
- 'type' => UserConstants::USER_COLLECT_TYPE_DAY,
- 'createdate' => date('Ymd', strtotime('-1 days')),
- 'admin_id' => ['in', $admin_id],
- ];
- $data = $this->getUserCollectModel()
- ->where($where)
- ->whereIn('admin_id', $admin_id)
- ->field($fields)
- ->find()
- ->toArray();
- if (!$data) {
- $data = $default;
- }
- return $this->setData($data)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData($default)->getReturn();
- }
- }
- /**
- * 获取月度统计数据
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectMonth($admin_id)
- {
- $admin_id = (array)AdminService::instance()->getAdminId($admin_id)->data;
- $default = $this->default;
- $fields = [
- 'IFNULL(SUM(increase),0)' => 'increase',
- 'IFNULL(SUM(increase_m),0)' => 'increase_m',
- 'IFNULL(SUM(increase_f),0)' => 'increase_f',
- 'IFNULL(SUM(increase_fllow),0)' => 'increase_fllow',
- 'IFNULL(SUM(increase_recharge),0)' => 'increase_recharge',
- 'IFNULL(SUM(guide_follow_num),0)' => 'guide_follow_num',
- 'IFNULL(SUM(unfollow_num),0)' => 'unfollow_num',
- 'IFNULL(SUM(net_follow_num),0)' => 'net_follow_num',
- 'IFNULL(SUM(day_recharge_user_money),0)' => 'day_recharge_user_money',
- 'IFNULL(SUM(day_recharge_user_count),0)' => 'day_recharge_user_count',
- ];
- try {
- $where = [
- 'type' => UserConstants::USER_COLLECT_TYPE_DAY,
- 'admin_id' => ['in', $admin_id],
- ];
- $data = $this->getUserCollectModel()
- ->where($where)
- ->where("createdate>=" . date('Ym') . "01")
- ->where("createdate<=" . date('Ymd', strtotime('-1 days')))
- ->field($fields)
- ->find()
- ->toArray();
- if (!$data) {
- $data = $default;
- }
- return $this->setData($data)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData($default)->getReturn();
- }
- }
- /**
- * 获取总数据
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getTotalData($admin_id)
- {
- $admin_id = (array)AdminService::instance()->getAdminId($admin_id)->data;
- $default = $this->default;
- $fields = [
- 'IFNULL(SUM(increase),0)' => 'increase',
- 'IFNULL(SUM(increase_m),0)' => 'increase_m',
- 'IFNULL(SUM(increase_f),0)' => 'increase_f',
- 'IFNULL(SUM(increase_fllow),0)' => 'increase_fllow',
- 'IFNULL(SUM(increase_recharge),0)' => 'increase_recharge',
- 'IFNULL(SUM(guide_follow_num),0)' => 'guide_follow_num',
- 'IFNULL(SUM(unfollow_num),0)' => 'unfollow_num',
- 'IFNULL(SUM(net_follow_num),0)' => 'net_follow_num',
- 'IFNULL(SUM(day_recharge_user_money),0)' => 'day_recharge_user_money',
- 'IFNULL(SUM(day_recharge_user_count),0)' => 'day_recharge_user_count',
- ];
- try {
- $where = [
- 'type' => UserConstants::USER_COLLECT_TYPE_DAY,
- 'admin_id' => ['in', $admin_id],
- ];
- $data = $this->getUserCollectModel()
- ->field($fields)
- ->where($where)
- ->where("createdate<=" . date('Ymd', strtotime('-1 days')))
- ->find()
- ->toArray();
- if (!$data) {
- $data = $default;
- }
- return $this->setData($data)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData($default)->getReturn();
- }
- }
- /**
- * 获取渠道30日数据
- * @param $admin_id
- * @param $where
- * @param $sort
- * @param $order
- * @param $offset
- * @param $limit
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectDateListData($admin_id, $where = '', $sort = 'createdate', $order = 'desc', $offset = 0, $limit = 10, $group = AdminConstants::ADMIN_GROUP_ID_CHANNEL)
- {
- try {
- $total = 0;
- $list = [];
- if ($group == AdminConstants::ADMIN_GROUP_ID_SUPER_ADMIN) {
- $admin_id = 0;
- }
- if (VisitLimitService::instance()->checkMigratedV2()) {
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_USER_TOTAL, ['adminId' => $admin_id])->data;
- if ($data) {
- $list = [];
- foreach ($data['thirty'] as $item) {
- if ($item['date'] == date('Ymd')) {
- continue;
- }
- $date = ArrayHelper::array_replace_key($item, $this->replaceFields);
- $list[] = array_merge($this->default, $date);
- }
- usort($list, function($v1, $v2){
- return $v1['createdate'] < $v2['createdate'];
- });
- $total = count($list);
- $list = array_slice($list, $offset, $limit);
- }
- } else {
- $beginDate = date('Ymd', strtotime('-31 days'));
- $endDate = date('Ymd', strtotime('-1 days'));
- $total = $this->getUserCollectModel()
- ->where($where)
- ->where('admin_id', $admin_id)
- ->where('createdate', '>=', $beginDate)
- ->where('createdate', '<=', $endDate)
- ->where(['type' => UserConstants::USER_COLLECT_TYPE_DAY])
- ->count();
- //总的数据
- $list = $this->getUserCollectModel()
- ->where($where)
- ->where('admin_id', $admin_id)
- ->where(['type' => UserConstants::USER_COLLECT_TYPE_DAY])
- ->where('createdate', '>=', $beginDate)
- ->where('createdate', '<=', $endDate)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- }
- $result = ["total" => $total, "rows" => $list];
- return $this->setData($result)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData([
- 'total' => 0,
- 'rows' => [],
- ])->getReturn();
- }
- }
- /**
- * 获取VIP30日数据汇总
- * @param $admin_id
- * @param int $offset
- * @param int $limit
- * @return \app\main\model\object\ReturnObject
- */
- public function getMigratedUserCollectDateAggsListData($admin_id, $offset = 0, $limit = 10)
- {
- $total = 0;
- $list = [];
- $admin_ids = (array)AdminService::instance()->getAdminId($admin_id)->data;
- if ($admin_ids != [-1]) {
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_VIP_USER_TOTAL, ['ids' => $admin_ids])->data;
- if ($data) {
- $list = [];
- foreach ($data['thirty'] as $item) {
- if ($item['date'] == date('Ymd')) {
- continue;
- }
- $date = ArrayHelper::array_replace_key($item, $this->replaceFields);
- $list[] = array_merge($this->default, $date);
- }
- usort($list, function ($v1, $v2) {
- return $v1['createdate'] < $v2['createdate'];
- });
- $total = count($list);
- $list = array_slice($list, $offset, $limit);
- }
- }
- $result = ["total" => $total, "rows" => $list];
- return $this->setData($result)->getReturn();
- }
- /**
- * @param $admin_id
- * @param $where
- * @param $sort
- * @param $order
- * @param $offset
- * @param $limit
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectDateAggsListData($admin_id, $offset = 0, $limit = 10)
- {
- $fields = [
- 'IFNULL(SUM(increase),0)' => 'increase',
- 'IFNULL(SUM(increase_m),0)' => 'increase_m',
- 'IFNULL(SUM(increase_f),0)' => 'increase_f',
- 'IFNULL(SUM(increase_fllow),0)' => 'increase_fllow',
- 'IFNULL(SUM(increase_recharge),0)' => 'increase_recharge',
- 'IFNULL(SUM(guide_follow_num),0)' => 'guide_follow_num',
- 'IFNULL(SUM(unfollow_num),0)' => 'unfollow_num',
- 'IFNULL(SUM(net_follow_num),0)' => 'net_follow_num',
- 'IFNULL(SUM(day_recharge_user_money),0)' => 'day_recharge_user_money',
- 'IFNULL(SUM(day_recharge_user_count),0)' => 'day_recharge_user_count',
- 'DATE_FORMAT(createdate,"%Y-%m-%d")' => 'createdate',
- ];
- try {
- $total = 0;
- $list = [];
- $admin_id = (array)AdminService::instance()->getAdminId($admin_id)->data;
- if ($admin_id != [-1]) {
- $beginDate = date('Ymd', strtotime('-31 days'));
- $endDate = date('Ymd', strtotime('-1 days'));
- $total = $this->getUserCollectModel()
- ->whereIn('admin_id', $admin_id)
- ->where('createdate', '>=', $beginDate)
- ->where('createdate', '<=', $endDate)
- ->where(['type' => UserConstants::USER_COLLECT_TYPE_DAY])
- ->group('createdate')
- ->count();
- //总的数据
- $list = $this->getUserCollectModel()
- ->whereIn('admin_id', $admin_id)
- ->where(['type' => UserConstants::USER_COLLECT_TYPE_DAY])
- ->where('createdate', '>=', $beginDate)
- ->where('createdate', '<=', $endDate)
- ->order('createdate', 'desc')
- ->limit($offset, $limit)
- ->group('createdate')
- ->field($fields)
- ->select();
- foreach ($list as $key => $val) {
- if ($val['increase']) {
- $list[$key]['follow'] = NumberHelper::getFloat($val['increase_fllow']/ $val['increase']* 100);
- $list[$key]['recharge'] = NumberHelper::getFloat($val['increase_recharge']/ $val['increase']* 100);
- $list[$key]['guide_follow_num_percent'] = NumberHelper::getFloat($val['guide_follow_num']/ $val['increase']* 100);
- $list[$key]['unfollow_num_percent'] = NumberHelper::getFloat($val['unfollow_num']/ $val['increase']* 100);
- $list[$key]['net_follow_num_percent'] = NumberHelper::getFloat($val['net_follow_num']/ $val['increase']* 100);
- } else {
- $list[$key]['follow'] = 0;
- $list[$key]['recharge'] = 0;
- $list[$key]['guide_follow_num_percent'] = 0;
- $list[$key]['unfollow_num_percent'] = 0;
- $list[$key]['net_follow_num_percent'] = 0;
- }
- }
- }
- $result = ["total" => $total, "rows" => $list];
- return $this->setData($result)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData([
- 'total' => 0,
- 'rows' => [],
- ])->getReturn();
- }
- }
- /**
- * 获取指定渠道今日数据
- * @param $admin_ids
- * @return \app\main\model\object\ReturnObject
- */
- public function getMigrateUserCollectChannelListDetail($admin_ids)
- {
- $list = [];
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_VIP_USER_TODAY, ['ids' => $admin_ids])->data;
- $admins = AdminService::instance()->getAdminConfigModel()->field([
- 'replace(JSON_EXTRACT(json,"$.authorizer_info.nick_name"),\'"\',\'\')' => 'wx_nickname',
- 'admin_id' => 'admin_id',
- ])->whereIn('admin_id', $admin_ids)->select();
- $names = [];
- foreach ($admins as $admin) {
- $names[$admin['admin_id']] = $admin['wx_nickname'];
- }
- foreach ($data as $item) {
- $date = ArrayHelper::array_replace_key($item, $this->replaceFields);
- if (array_key_exists($item['adminId'], $names) && $names[$item['adminId']]) {
- $date['wx_nickname'] = $names[$item['adminId']];
- $list[] = array_merge($this->default, $date);
- }
- }
- return $this->setData($list)->getReturn();
- }
- /**
- * 获取单页渠道数据
- * @param $admin_id
- * @param int $offset
- * @param int $limit
- * @return \app\main\model\object\ReturnObject
- */
- public function getMigrateUserCollectChannelList($admin_id, $offset = 0, $limit = 10)
- {
- $admin_ids = (array)AdminService::instance()->getAdminId($admin_id)->data;
- //手动分页
- $filterIds = array_slice($admin_ids, $offset, $limit);
- $result = $this->getMigrateUserCollectChannelListDetail($filterIds)->data;
- $total = count($result);
- $result = ["total" => $total, "rows" => $result];
- return $this->setData($result)->getReturn();
- }
- /**
- * 获取渠道商今日用户统计
- * @param $admin_id
- * @param $offset
- * @param $limit
- * @return \app\main\model\object\ReturnObject
- */
- public function getUserCollectChannelList($admin_id, $offset = 0, $limit = 10)
- {
- try {
- $admin_ids = (array)AdminService::instance()->getAdminId($admin_id)->data;
- $today = date('Ymd');
- //查询总数量
- $total = AdminService::instance()->getAdminConfigModel()
- ->join('user_collect',
- "user_collect.admin_id = admin_config.admin_id and user_collect.type = 1 and createdate = '$today'", 'left')
- ->where(['admin_config.admin_id' => ['in', $admin_ids]])
- ->count();
- #region 从数据库中取出列表数据
- $list = AdminService::instance()->getAdminConfigModel()
- ->join('user_collect',
- "user_collect.admin_id = admin_config.admin_id and user_collect.type = 1 and createdate = '$today'", 'left')
- ->where(['admin_config.admin_id' => ['in', $admin_ids]])
- ->field([
- 'replace(JSON_EXTRACT(admin_config.json,"$.authorizer_info.nick_name"),\'"\',\'\')' => 'wx_nickname',
- 'admin_config.admin_id' => 'admin_id',
- 'increase',
- 'increase_m',
- 'increase_f',
- 'increase_fllow',
- 'increase_recharge',
- 'guide_follow_num',
- 'unfollow_num',
- 'net_follow_num',
- 'day_recharge_user_money',
- 'day_recharge_user_count',
- ])
- ->limit($offset, $limit)
- ->select();
- $result = [];
- foreach ($list as $item) {
- $tmp = [
- 'wx_nickname' => $item['wx_nickname'],
- 'admin_id' => $item['admin_id'],
- 'increase' => (int)$item['increase'],
- 'increase_m' => (int)$item['increase_m'],
- 'increase_f' => (int)$item['increase_f'],
- 'increase_fllow' => (int)$item['increase_fllow'],
- 'increase_recharge' => (int)$item['increase_recharge'],
- 'guide_follow_num' => (int)$item['guide_follow_num'],
- 'unfollow_num' => (int)$item['unfollow_num'],
- 'net_follow_num' => (int)$item['net_follow_num'],
- 'day_recharge_user_count' => (int)$item['day_recharge_user_count'],
- 'day_recharge_user_money' => (float)$item['day_recharge_user_money'],
- ];
- $result[] = $tmp;
- }
- $result = ["total" => $total, "rows" => $result];
- return $this->setData($result)->getReturn();
- } catch (\Exception $e) {
- LogService::exception($e);
- return $this->setData([])->getReturn();
- }
- }
- /**
- * 获取渠道-VIP-admin数据汇总-新
- * @param $admin_id
- * @param $group
- * @return \app\main\model\object\ReturnObject
- */
- public function getMigrateCollectData($admin_id, $group)
- {
- $default = $this->default;
- $result = [
- 'todayData' => $default,
- 'yesterdayData' => $default,
- 'totalData' => $default,
- 'monthData' => $default,
- ];
- $replaceFields = $this->replaceFields;
- //超管按照单渠道数据统计
- if (in_array($group, [AdminConstants::ADMIN_GROUP_ID_SUPER_ADMIN])) {
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_USER_TOTAL, ['adminId' => 0])->data;
- } else {
- //获取关联的渠道
- $admin_ids = (array)AdminService::instance()->getAdminId($admin_id)->data;
- //没有关联渠道直接返回默认值
- if ($admin_ids == [-1]) {
- return $this->setData($result)->getReturn();
- }
- //渠道数据为1则按照渠道数据查询
- if (count($admin_ids) == 1) {
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_USER_TOTAL, ['adminId' => $admin_ids[0]])->data;
- //多个渠道按照渠道数据汇总
- } else {
- $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_VIP_USER_TOTAL, ['ids' => $admin_ids])->data;
- }
- }
- if ($data) {
- $all = ArrayHelper::array_replace_key($data['all'], $replaceFields);
- $result['totalData'] = array_merge($default, $all);
- $month = ArrayHelper::array_replace_key($data['month'], $replaceFields);
- $result['monthData'] = array_merge($default, $month);
- if (!empty($data['thirty'])) {
- foreach ($data['thirty'] as $date) {
- if ($date['date'] == date('Ymd')) {
- $date = ArrayHelper::array_replace_key($date, $replaceFields);
- $result['todayData'] = array_merge($default, $date);
- }else if ($date['date'] == date('Ymd', time() - 86400)) {
- $date = ArrayHelper::array_replace_key($date, $replaceFields);
- $result['yesterdayData'] = array_merge($default, $date);
- }
- }
- }
- }
- return $this->setData($result)->getReturn();
- }
- /**
- * 获取渠道-VIP-admin汇总数据-旧
- * @param $admin_id
- * @return \app\main\model\object\ReturnObject
- */
- public function getCollectData($admin_id)
- {
- $return = [];
- $return['totalData'] = UserCollectService::instance()->getTotalData($admin_id)->data;
- $return['todayData'] = UserCollectService::instance()->getUserCollectToday($admin_id)->data;
- $return['yesterdayData'] = UserCollectService::instance()->getUserCollectYesterday($admin_id)->data;
- $return['monthData'] = UserCollectService::instance()->getUserCollectMonth($admin_id)->data;
- return $this->setData($return)->getReturn();
- }
- }
|