123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Modules\OfficialAccount\Models;
- use Illuminate\Database\Eloquent\Model;
- use DB;
- class CustomSendDayStats extends Model
- {
- protected $tables = 'custom_send_day_stats';
- protected $fillable = ['distribution_channel_id','date','push_user_num','click_num','amount','success_pay_num','success_pay_rate','from','click_rate'];
- static function customSendDayStatsByChannelAndFrom($distribution_channel_id,$from)
- {
-
- return self::where(['distribution_channel_id'=>$distribution_channel_id,'from'=>$from])->orderBy('date','desc')->paginate();
-
- }
- static function customSendDayStatsByChannelAndFromAndDay($distribution_channel_id,$from,$day)
- {
-
- return self::where(['distribution_channel_id'=>$distribution_channel_id,'from'=>$from,'date'=>$day])->first();
-
- }
-
- /**
- * 根据分页获取智能推送消息
- */
- static function customSendDayStatsPaginate($start_time,$end_time,$is_all=false)
- {
- $search_obj = self::select('custom_send_day_stats.distribution_channel_id as site_id',
- 'custom_send_day_stats.from as task_name',
- 'custom_send_day_stats.date as created_date',
- 'custom_send_day_stats.updated_at as send_time',
- 'custom_send_day_stats.push_user_num as suc_send_num',
- DB::raw('"" as template_name'),
- DB::raw('"" as tag'),
- DB::raw('(select group_concat(nickname) from official_accounts where distribution_channel_id=custom_send_day_stats.distribution_channel_id group by distribution_channel_id) as official_account_name')//official_account_name
- )
- ->where('custom_send_day_stats.created_at','>=',$start_time)
- ->where('custom_send_day_stats.created_at','<',$end_time)
- ->orderBy('custom_send_day_stats.id','desc');
-
- if($is_all)
- {
- return $search_obj->get();
- }else{
- return $search_obj->paginate();
- }
- }
- }
|