LotteryPrize.class.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace Cas\Dao;
  3. use KIF\Dao\DBAgileDev;
  4. /**
  5. *
  6. * 抽奖奖品表
  7. *
  8. * @author lihuanchun@qq.com
  9. *
  10. */
  11. class LotteryPrize extends DBAgileDev {
  12. protected $tableName = 'lottery_prize';
  13. /**
  14. * 数据库里的真实字段
  15. * @var array
  16. */
  17. protected $other_field = array(
  18. 'events_id',// 所属活动
  19. 'prize_name',//奖品名称
  20. 'prize_num',// 奖品数量
  21. 'prize_winning_num',// 已经抽中的数量
  22. 'type',// 实物类:1 虚拟类:2
  23. 'display' // 0 :不显示【关闭】 1:显示【正常】
  24. );
  25. /**
  26. * PRIZE_DISPLAY_SHOW 显示
  27. * @var int
  28. */
  29. const PRIZE_DISPLAY_SHOW = 1;
  30. /**
  31. * PRIZE_DISPLAY_HIDE 隐藏
  32. * @var int
  33. */
  34. const PRIZE_DISPLAY_HIDE = 0;
  35. public static $display= array(
  36. self::PRIZE_DISPLAY_SHOW => array(
  37. 'desc' => '正常',
  38. 'kw' => 'PRIZE_DISPLAY_SHOW',
  39. ),
  40. self::PRIZE_DISPLAY_HIDE => array(
  41. 'desc' => '关闭',
  42. 'kw' => 'PRIZE_DISPLAY_HIDE',
  43. ),
  44. );
  45. /**
  46. * 奖项显示状态
  47. * @return array
  48. */
  49. public static function getDisplay() {
  50. return self::$display;
  51. }
  52. /**
  53. * EXPRESS_TRUE 需要快递
  54. * @var int
  55. */
  56. const EXPRESS_TRUE = 1;
  57. /**
  58. * EXPRESS_FALSE 不需要快递
  59. * @var int
  60. */
  61. const EXPRESS_FALSE = 2;
  62. public static $express= array(
  63. self::EXPRESS_TRUE => array(
  64. 'desc' => '需要',
  65. 'kw' => 'EXPRESS_TRUE',
  66. ),
  67. self::EXPRESS_FALSE => array(
  68. 'desc' => '不需要',
  69. 'kw' => 'EXPRESS_FALSE',
  70. ),
  71. );
  72. /**
  73. * 获取是否需要快递
  74. * @return array
  75. */
  76. public static function getExpress(){
  77. return self::$express;
  78. }
  79. /**
  80. * TYPE_VIRTUAL 实物类
  81. * @var int
  82. */
  83. const TYPE_VIRTUAL = 1;
  84. /**
  85. * TYPE_ENTITY 虚拟类
  86. * @var int
  87. */
  88. const TYPE_ENTITY = 2;
  89. public static $type = array(
  90. self::TYPE_VIRTUAL => array(
  91. 'desc' => '实物',
  92. 'kw' => 'TYPE_VIRTUAL',
  93. ),
  94. self::TYPE_ENTITY => array(
  95. 'desc' => '虚拟',
  96. 'kw' => 'TYPE_ENTITY',
  97. )
  98. );
  99. /**
  100. * 获取奖项类型:实物类:1 虚拟类:2
  101. * @return array
  102. */
  103. public static function getType() {
  104. return self::$type;
  105. }
  106. /**
  107. * 对已抽中的数量进行修改
  108. */
  109. public function upPrizeWinningNum($id ,$num){
  110. $data = $this->get($id);
  111. $info = array(
  112. 'prize_winning_num' => $data['prize_winning_num'] + $num
  113. );
  114. return $this->modify($info,array('id' => $id));
  115. }
  116. /**
  117. * 对总数量进行修改
  118. */
  119. public function upPrizeNum($id ,$num){
  120. $data = $this->get($id);
  121. $info = array(
  122. 'prize_num' => $data['prize_num'] + $num
  123. );
  124. return $this->modify($info,array('id' => $id));
  125. }
  126. }