CustomTemplateSendStatService.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * zhoulj
  4. * 2018-03-07
  5. */
  6. namespace App\Modules\OfficialAccount\Services;
  7. use App\Modules\OfficialAccount\Models\CustomSendMsgs;
  8. use App\Modules\OfficialAccount\Models\CustomSendDayStats;
  9. use App\Modules\OfficialAccount\Models\WechatTemplateMsgs;
  10. use App\Modules\Statistic\Services\SendStatistics;
  11. class CustomTemplateSendStatService
  12. {
  13. /**
  14. * 通过分销渠道ID和From获取每日智能推送分析
  15. */
  16. static function getCustomTemplateSendStat($stat_type,$start_date,$end_date,$get_all=false)
  17. {
  18. $result = array();
  19. \Log::info('$stat_type:'.$stat_type.' $start_date:'.$start_date.' $end_date:'.$end_date);
  20. // 基础数据
  21. switch($stat_type){
  22. case "templateMessage":
  23. $result = WechatTemplateMsgs::wechatTemplateMsgsPaginate($start_date,$end_date,$get_all);
  24. break;
  25. case "customerServiceNews":
  26. $result = CustomSendMsgs::customSendMsgsPaginate($start_date,$end_date,$get_all);
  27. break;
  28. case "intelligentRecommendation":
  29. $result = CustomSendDayStats::customSendDayStatsPaginate($start_date,$end_date,$get_all);
  30. break;
  31. default:
  32. break;
  33. }
  34. return $result;
  35. }
  36. /**
  37. * 通过分销渠道ID和From获取每日智能推送分析
  38. */
  39. static function getMainCustomTemplateSendStat($stat_type,$start_date,$end_date,$get_all=false){
  40. $base_datas = self::getCustomTemplateSendStat($stat_type,$start_date,$end_date,$get_all);
  41. \Log::info('$base_datas');\Log::info($base_datas);
  42. // die();
  43. // 目前只有智能推送有统计
  44. foreach($base_datas as $base_data){
  45. \Log::info('one_$base_data');
  46. \Log::info($base_data);
  47. // 付费等数据,统一从娃哥那边接口获取
  48. // start_date,end_date,sites,stat_type
  49. if($stat_type == 'intelligentRecommendation'){
  50. $_stat_types = array();
  51. $user_pay_stat = SendStatistics::getWechatMsgUseRecord($base_data->site_id,$stat_type,$start_date,$end_date);
  52. \Log::info('user_pay_stat');\Log::info($user_pay_stat);
  53. $base_data->uv = $user_pay_stat['uv'];
  54. $base_data->total_order_num = $user_pay_stat['order_count'];
  55. $base_data->suc_order_num = $user_pay_stat['success_order_count'];
  56. $base_data->charge_amount = $user_pay_stat['success_order_sum'];
  57. $base_data->not_first_charge_user_num = $user_pay_stat['second_pay_count'];
  58. }else{
  59. $base_data->uv = '';
  60. $base_data->total_order_num = '';
  61. $base_data->suc_order_num = '';
  62. $base_data->charge_amount = '';
  63. $base_data->not_first_charge_user_num = '';
  64. }
  65. }
  66. return $base_datas;
  67. }
  68. }