LotteryEventsLetters.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 LotteryEventsLetters extends DBAgileDev {
  14. protected $tableName = 'lottery_events_letters';
  15. /**
  16. * 数据库里的真实字段
  17. * @var array
  18. */
  19. protected $other_field = array(
  20. 'events_id',
  21. 'ABC_name',
  22. 'img_1',
  23. 'img_2',
  24. 'num'
  25. );
  26. public function getEventData($events_id){
  27. $condition = array('events_id' => $events_id);
  28. $ids = $this->findIdsBy($condition);
  29. $returnData = $this->gets($ids);
  30. return $returnData;
  31. }
  32. /**
  33. * 对已抽中的数量进行修改
  34. */
  35. public function upLettersWinningNum($id ,$num){
  36. $data = $this->get($id);
  37. $info = array(
  38. 'winning_num' => $data['winning_num'] + $num
  39. );
  40. return $this->modify($info,array('id' => $id));
  41. }
  42. /**
  43. * 获取当天已经发放的数量
  44. */
  45. public function getTodayHasWinTotal($letters_id){
  46. $thisTime = time();
  47. $objMemcached = new Memcached();
  48. $key = date('Y_m_d',$thisTime).'_'.$letters_id.'_is_winning_num';
  49. $num = $objMemcached ->get($key);
  50. if(!$num){
  51. $num = 0;
  52. }
  53. return $num;
  54. }
  55. /**
  56. * 累加 获取当天已经发放的数量
  57. */
  58. public function cumulativeTodayHasWinTotal($letters_id){
  59. $thisTime = time();
  60. $objMemcached = new Memcached();
  61. $key = date('Y_m_d',$thisTime).'_'.$letters_id.'_is_winning_num';
  62. $num = $objMemcached ->get($key);
  63. if(!$num){
  64. $num = 1;
  65. }else{
  66. $num ++;
  67. }
  68. $objMemcached ->set($key,$num,60 * 60 * 24);
  69. return $num;
  70. }
  71. }