12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Services;
- use App\Models\PlayletConfig;
- use App\Models\VpAccount;
- use App\Models\VpPlayletCampaign;
- class PlayletPromoteService
- {
- /**
- * 获取账号已设置的推广计划
- * @param $appId string 公众账号AppId
- * @param $startDate string 计划创建开始时间
- * @param $endDate string 计划创建结束时间
- * @param $page integer 当前页码数
- * @param $pageSize integer 每页显示条数
- * */
- public static function promoteList($appId, $startDate, $endDate, $page, $pageSize)
- {
- list($list, $count) = VpPlayletCampaign::getPromoteList($appId, $startDate, $endDate, $page, $pageSize);
- return [$list, $count];
- }
- /**
- * 短剧作品朋友圈推广数据趋势
- * @param $playletId string 短剧ID
- * @param $startDate string 计划创建开始时间
- * @param $endDate string 计划创建结束时间
- * @param $page integer 当前页码数
- * @param $pageSize integer 每页显示条数
- * */
- public static function promoteData($playletId, $startDate, $endDate, $page, $pageSize)
- {
- list($list, $count) = VpPlayletCampaign::getPromoteData($playletId, $startDate, $endDate, $page, $pageSize);
- # 获取公众账号消息
- $accountList = VpAccount::select(['app_id', 'nickname'])->where('enable', 1)->get();
- foreach ($list as $item) {
- # 访问uv
- $viewUv = isset($item->view_uv_total) ? $item->view_uv_total : 0;
- # 付费率
- $item->charge_rate = $viewUv ? round($item->pay_uv_total / $viewUv, 5) * 100 . '%' : '0%';
- # 总充值
- $item->charge_total = $item->charge_total / 10000;
- # 今日充值
- $item->charge_today = $item->charge_today / 10000;
- # 公众账号
- $accountInfo = $accountList->where('app_id', $item->app_id)->first();
- $item->nickname = isset($accountInfo->nickname) ? $accountInfo->nickname : '';
- }
- return [$list, $count];
- }
- }
|