|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm ActivityRedPack.php
- * Create By 2016/12/6 10:19 $
- */
-
-
- namespace Activity\Model;
-
-
- use Base\Tool\DbTable;
-
- class ActivityRedPack extends DbTable
- {
- public $db = 'CST';
- public $tab = 'activity_redpack';
-
- /**
- * Function Description:获取某用户获得的某类红包总数数
- * Function Name: getCountByOpenId
- * @param $openid string 用户微信openid
- * @param int $activity_id 红包类型 1:关注送红包活动
- *
- * @return string
- *
- * @author 倪宗锋
- */
- public function getCountByOpenId($openid, $activity_id = 1)
- {
- $sql = ''
- . "SELECT count(1)
- from activity_redpack
- where openid ='{$openid}' and activity_id ={$activity_id}";
- $result = $this->fetchOne($sql);
- return $result;
- }
- /**
- * Function Description:获取某用户的某类红包当天领取总数
- * Function Name: getCountByOpenidForToday
- * @param $openid
- * @param int $activity_id
- *
- * @return string
- *
- * @author 倪宗锋
- */
- public function getCountByOpenidForToday($openid, $activity_id = 1)
- {
- $sql = ''
- ."SELECT count(1)
- from activity_redpack
- where openid ='{$openid}'
- and create_time >= DATE_FORMAT(NOW(),'%Y-%m-%d')
- and create_time < DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),'%Y-%m-%d')
- and activity_id= {$activity_id} ";
- $result = $this->fetchOne($sql);
- return $result;
- }
-
- /**
- * Function Description:
- * Function Name: getTotalNum
- * @param $activity_id
- *
- * @return string
- *
- * @author 倪宗锋
- */
- public function getTotalNum($activity_id)
- {
- $sql = ''
- . "SELECT count(1)
- from activity_redpack
- where activity_id={$activity_id}
- ";
- $result = $this->fetchOne($sql);
- return $result;
- }
-
- }
|