LotteryDeliveryChannels.class.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Cas\Dao;
  3. use KIF\Dao\DBAgileDev;
  4. use KIF\Core\Request;
  5. use KIF\Cache\Memcached;
  6. /**
  7. *
  8. * 活动 投放渠道
  9. *
  10. * @author lihuanchun@qq.com
  11. *
  12. */
  13. class LotteryDeliveryChannels extends DBAgileDev {
  14. protected $tableName = 'lottery_delivery_channels';
  15. /**
  16. * 数据库里的真实字段
  17. * @var array
  18. */
  19. protected $other_field = array(
  20. 'str_name',
  21. 'events_id',
  22. 'platform_id',
  23. 'pv_num'
  24. );
  25. /**
  26. * 添加一个PV
  27. */
  28. public function addOnePV($id){
  29. $data = $this->get($id);
  30. $info = array(
  31. 'pv_num' => $data['pv_num'] + 1
  32. );
  33. return $this->modify($info,array('id' => $id));
  34. }
  35. /**
  36. * 添加默认渠道用cache 计数
  37. */
  38. public function addDefaultEventOnePV($schemeDomain,$events_id,$platform_id){
  39. $key = $schemeDomain.'_'.$events_id.'_'.$platform_id;
  40. $objMemcached = new Memcached();
  41. $num = $objMemcached->get($key);
  42. $time = time();
  43. if($num){
  44. if (strstr($num, '||')) {
  45. $temp = explode('||', $num);
  46. $num = $temp[0];
  47. $num = $num + 1;
  48. } else {
  49. $num = $num + 1;
  50. }
  51. $value = $num . '||' . $time;
  52. $objMemcached->set($key,$value);
  53. }else{
  54. $objMemcached->set($key,1 . '||' . $time);
  55. }
  56. }
  57. /**
  58. * 获取默认渠道用cache 计数
  59. */
  60. public function getDefaultEventOnePV($schemeDomain,$events_id,$platform_id){
  61. $key = $schemeDomain.'_'.$events_id.'_'.$platform_id;
  62. $objMemcached = new Memcached();
  63. return $objMemcached->get($key);
  64. }
  65. }