AdVisitStatService.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/1/7
  6. * Time: 14:22
  7. */
  8. namespace App\Modules\Statistic\Services;
  9. use App\Modules\Statistic\Models\AdVisitStat;
  10. class AdVisitStatService
  11. {
  12. public static function create($uid,$bid,$cid,$type){
  13. $model = new AdVisitStat();
  14. $time = date('Ym');
  15. if($time == '201905'){
  16. $model->setCurrentTable();
  17. }else{
  18. $model->setCurrentTable($time);
  19. }
  20. try{
  21. $model->uid = $uid;
  22. $model->bid = $bid;
  23. $model->cid = $cid;
  24. $model->type = $type;
  25. $model->save();
  26. //$model->create(compact('uid','bid','cid','type'));
  27. }catch (\Exception $e){
  28. }
  29. }
  30. public static function getInfo($uid,$cid,$type){
  31. $model = new AdVisitStat();
  32. $time = date('Ym');
  33. if($time == '201905'){
  34. $model->setCurrentTable();
  35. }else{
  36. $model->setCurrentTable($time);
  37. }
  38. return AdVisitStat::where('uid',$uid)->where('cid',$cid)->where('type',$type)->first();
  39. }
  40. public static function getInfoV2($uid,$cid,$type){
  41. $model = new AdVisitStat();
  42. $time = date('Ym');
  43. if($time == '201905'){
  44. $model->setCurrentTable();
  45. }else{
  46. $model->setCurrentTable($time);
  47. }
  48. return $model->where('uid',$uid)->where('cid',$cid)->whereIn('type',$type)->first();
  49. }
  50. public static function getByUid($uid){
  51. $model = new AdVisitStat();
  52. $time = date('Ym');
  53. if($time == '201905'){
  54. $model->setCurrentTable();
  55. }else{
  56. $model->setCurrentTable($time);
  57. }
  58. return $model->where('uid',$uid)->select('id','type')->where('id','<=',12723415)->first();
  59. }
  60. }