Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

89 wiersze
2.5 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm ActivityRedPack.php
  13. * Create By 2016/12/6 10:19 $
  14. */
  15. namespace Activity\Model;
  16. use Base\Tool\DbTable;
  17. class ActivityRedPack extends DbTable
  18. {
  19. public $db = 'CST';
  20. public $tab = 'activity_redpack';
  21. /**
  22. * Function Description:获取某用户获得的某类红包总数数
  23. * Function Name: getCountByOpenId
  24. * @param $openid string 用户微信openid
  25. * @param int $activity_id 红包类型 1:关注送红包活动
  26. *
  27. * @return string
  28. *
  29. * @author 倪宗锋
  30. */
  31. public function getCountByOpenId($openid, $activity_id = 1)
  32. {
  33. $sql = ''
  34. . "SELECT count(1)
  35. from activity_redpack
  36. where openid ='{$openid}' and activity_id ={$activity_id}";
  37. $result = $this->fetchOne($sql);
  38. return $result;
  39. }
  40. /**
  41. * Function Description:获取某用户的某类红包当天领取总数
  42. * Function Name: getCountByOpenidForToday
  43. * @param $openid
  44. * @param int $activity_id
  45. *
  46. * @return string
  47. *
  48. * @author 倪宗锋
  49. */
  50. public function getCountByOpenidForToday($openid, $activity_id = 1)
  51. {
  52. $sql = ''
  53. ."SELECT count(1)
  54. from activity_redpack
  55. where openid ='{$openid}'
  56. and create_time >= DATE_FORMAT(NOW(),'%Y-%m-%d')
  57. and create_time < DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),'%Y-%m-%d')
  58. and activity_id= {$activity_id} ";
  59. $result = $this->fetchOne($sql);
  60. return $result;
  61. }
  62. /**
  63. * Function Description:
  64. * Function Name: getTotalNum
  65. * @param $activity_id
  66. *
  67. * @return string
  68. *
  69. * @author 倪宗锋
  70. */
  71. public function getTotalNum($activity_id)
  72. {
  73. $sql = ''
  74. . "SELECT count(1)
  75. from activity_redpack
  76. where activity_id={$activity_id}
  77. ";
  78. $result = $this->fetchOne($sql);
  79. return $result;
  80. }
  81. }