AdVisitStatService.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. echo $model->getCurrentTable();
  21. try{
  22. $model->uid = $uid;
  23. $model->bid = $bid;
  24. $model->cid = $cid;
  25. $model->type = $type;
  26. $model->save();
  27. //$model->create(compact('uid','bid','cid','type'));
  28. }catch (\Exception $e){
  29. }
  30. }
  31. public static function getInfo($uid,$cid,$type){
  32. $model = new AdVisitStat();
  33. $time = date('Ym');
  34. if($time == '201905'){
  35. $model->setCurrentTable();
  36. }else{
  37. $model->setCurrentTable($time);
  38. }
  39. return AdVisitStat::where('uid',$uid)->where('cid',$cid)->where('type',$type)->first();
  40. }
  41. public static function getInfoV2($uid,$cid,$type){
  42. $model = new AdVisitStat();
  43. $time = date('Ym');
  44. if($time == '201905'){
  45. $model->setCurrentTable();
  46. }else{
  47. $model->setCurrentTable($time);
  48. }
  49. return $model->where('uid',$uid)->where('cid',$cid)->whereIn('type',$type)->first();
  50. }
  51. public static function getByUid($uid){
  52. $model = new AdVisitStat();
  53. $time = date('Ym');
  54. if($time == '201905'){
  55. $model->setCurrentTable();
  56. }else{
  57. $model->setCurrentTable($time);
  58. }
  59. return $model->where('uid',$uid)->select('id','type')->where('id','<=',12723415)->first();
  60. }
  61. }