123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- namespace App\Http\Controllers\Channel\OfficialAccount;
- use App\Modules\OfficialAccount\Models\CustomMsgSwitchs;
- use App\Modules\OfficialAccount\Services\CustomMsgService;
- use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
- use App\Modules\OfficialAccount\Services\CustomSendStatsService;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomSendStatsTransformers;
- use Illuminate\Http\Request;
- class CustomSendStatsController extends ChannelBaseController
- {
-
-
- function customSendDayStatsByChannelAndFrom(Request $request) {
- $distribution_channel_id = $this->getChannelId();
- $from = $request->has('from') ? $request->input('from') : '';
- if(empty($from)) {
- return response()->error("PARAM_EMPTY");
- }
- \Log::info('日推送智能分析 渠道ID:'.$distribution_channel_id);
- \Log::info('日推送智能分析 类型:'.$from);
- $customMsgService = CustomSendStatsService::customSendDayStatsByChannelAndFrom($distribution_channel_id,$from);
- if (!empty($customMsgService)) {
-
- return response()->pagination(new CustomSendStatsTransformers(), $customMsgService);
- }else{
- $customMsgService['distribution_channel_id'] = $distribution_channel_id;
- $customMsgService['date'] = date("Y-m-d");
- $customMsgService['push_user_num'] = 0;
- $customMsgService['click_num'] = 0;
- $customMsgService['amount'] = 0;
- $customMsgService['success_pay_num'] = 0;
- $customMsgService['success_pay_rate'] = 0;
- $customMsgService['click_rate'] = 0;
- $customMsgService['from'] = $from;
- return response()->item(new CustomSendStatsTransformers(), $customMsgService);
- }
-
- }
-
- function customSendStatsByChannelAndFrom(Request $request) {
- $distribution_channel_id = $this->getChannelId();
- $from = $request->has('from') ? $request->input('from') : '';
- if(empty($from)) {
- return response()->error("PARAM_EMPTY");
- }
- \Log::info('日推送智能分析 渠道ID:'.$distribution_channel_id);
- \Log::info('日推送智能分析 类型:'.$from);
- $customMsgService = CustomSendStatsService::customSendStatsByChannelAndFrom($distribution_channel_id,$from);
- if (!empty($customMsgService)) {
-
- return response()->item(new CustomSendStatsTransformers(), $customMsgService);
- }else{
- $customMsgService['distribution_channel_id'] = $distribution_channel_id;
- $customMsgService['date'] = date("Y-m-d");
- $customMsgService['push_user_num'] = 0;
- $customMsgService['click_num'] = 0;
- $customMsgService['amount'] = 0;
- $customMsgService['success_pay_num'] = 0;
- $customMsgService['success_pay_rate'] = 0;
- $customMsgService['click_rate'] = 0;
- $customMsgService['from'] = $from;
- return response()->item(new CustomSendStatsTransformers(), $customMsgService);
- }
-
- }
-
-
- function customSendStatsFromTypes(Request $request) {
- $customMsgSwitchs = CustomMsgSwitchs::getCustomMsgSwitchs();
- return response()->success($customMsgSwitchs);
- }
-
- }
|