LotteryLog.class.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. namespace Cas\Module;
  3. use KIF\Data\Convert;
  4. use KIF\Data\ResultWrapper;
  5. use KIF\Db\Transaction;
  6. use KIF\Cache\Memcached;
  7. use Cas\Dao\LotteryEventsLog;
  8. use Cas\Dao\LotteryUserParticipateLog;
  9. /**
  10. * 抽奖模型
  11. *
  12. * @author lihuanchun
  13. *
  14. */
  15. class LotteryLog {
  16. private $objDLotteryEventsLog;
  17. private $objDLotteryUserParticipateLog;
  18. private $uid;
  19. private $eventsId;
  20. /**
  21. * 初始化
  22. */
  23. public function __construct($uid=null , $eventsId=null ) {
  24. $this->objDLotteryEventsLog = new LotteryEventsLog();// 活动日志
  25. $this->objDLotteryUserParticipateLog = new LotteryUserParticipateLog();// 用户"参与"活动日志
  26. $this->uid = $uid;
  27. $this->eventsId = $eventsId;
  28. }
  29. /**
  30. * 获取行为类型
  31. */
  32. public function getType(){
  33. return $this->objDLotteryEventsLog->getType();
  34. }
  35. /**
  36. * 添加日志
  37. */
  38. public function addLog($type,$other){
  39. $events_id = $this->eventsId?$this->eventsId:0;
  40. $uid = $this->uid?$this->uid:0;
  41. $info = array(
  42. 'events_id' => $events_id,
  43. 'uid' => $uid,
  44. 'type' => $type,
  45. 'other' => $other
  46. );
  47. return $this->objDLotteryEventsLog -> addOne($info);
  48. }
  49. /**
  50. * 获取虚拟数据【条数】
  51. */
  52. public function getLogNum($condition){
  53. return $this->objDLotteryEventsLog->totals($condition);
  54. }
  55. /**
  56. * 获取一条日志
  57. */
  58. public function getOneData($id){
  59. return $this->objDLotteryEventsLog->get($id);
  60. }
  61. /**
  62. * 获取多条日志
  63. */
  64. public function getDatas($ids){
  65. return $this->objDLotteryEventsLog->gets($ids);
  66. }
  67. /**
  68. * 获取日志列表IDs
  69. */
  70. public function findByIds ($condition , $limit , $order){
  71. return $this->objDLotteryEventsLog->findIdsBy($condition , $limit , $order);
  72. }
  73. /**
  74. * 获取日志信息
  75. */
  76. public function findData($condition , $limit , $order){
  77. $ids = $this->findByIds($condition, $limit, $order);
  78. return $this->getDatas($ids);
  79. }
  80. /**
  81. * 添加"用户参与"日志
  82. */
  83. public function addUserParticipateLog($other){
  84. $events_id = $this->eventsId?$this->eventsId:0;
  85. $uid = $this->uid?$this->uid:0;
  86. $info = array(
  87. 'events_id' => $events_id,
  88. 'uid' => $uid,
  89. 'other' => $other
  90. );
  91. return $this->objDLotteryUserParticipateLog->add($info);
  92. }
  93. /**
  94. * 获取"用户参与"虚拟数据【条数】
  95. */
  96. public function getUserParticipateLogNum($condition){
  97. return $this->objDLotteryUserParticipateLog->totals($condition);
  98. }
  99. /**
  100. * 获取一条"用户参与"日志
  101. */
  102. public function getUserParticipateOneData($id){
  103. return $this->objDLotteryUserParticipateLog->get($id);
  104. }
  105. /**
  106. * 获取多条"用户参与"日志
  107. */
  108. public function getUserParticipateDatas($ids){
  109. return $this->objDLotteryUserParticipateLog->gets($ids);
  110. }
  111. /**
  112. * 获取"用户参与"日志列表IDs
  113. */
  114. public function findByUserParticipateIds ($condition , $limit , $order){
  115. return $this->objDLotteryUserParticipateLog->findIdsBy($condition , $limit , $order);
  116. }
  117. /**
  118. * 获取"用户参与"日志信息
  119. */
  120. public function findUserParticipateData($condition , $limit , $order){
  121. $ids = $this->findByUserParticipateIds($condition, $limit, $order);
  122. return $this->getUserParticipateDatas($ids);
  123. }
  124. /**
  125. * 获取 "用户参与" 用户排重日志信息
  126. */
  127. public function findUserParticipateDataGroupByUid( $limit , $order){
  128. return $this->objDLotteryUserParticipateLog->findUserParticipateDataGroupByUid($this->eventsId,$limit,$order);
  129. }
  130. /**
  131. * 获取"用户参与"用户排重虚拟数据【条数】
  132. */
  133. public function getUserParticipateLogNumGroupByUid(){
  134. return $this->objDLotteryUserParticipateLog->getUserParticipateLogNumGroupByUid($this->eventsId);
  135. }
  136. }