|
@@ -13,6 +13,8 @@ class user_bonusModel extends Model
|
|
|
const send_bonus = 1;
|
|
|
const grab_bonus = 2;
|
|
|
|
|
|
+ const TopupState = 3;
|
|
|
+
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -192,15 +194,28 @@ class user_bonusModel extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function get_expired_soon_notify_bonus($warn_remain_days, $warn_interval_days)
|
|
|
+ public function getNeedWarn($left_days, $interval_days)
|
|
|
{
|
|
|
- $field = 'bonus_id,user_id,type_sn,(usable_time-unix_timestamp(now())) as seconds';
|
|
|
- $condition = 'usable_time > unix_timestamp(now()) and usable_time-unix_timestamp(now()) <= {$warn_remain_days} and (isnull(notify_time) or unix_timestamp(now()) - notify_time >= {$warn_interval_days})';
|
|
|
+ if(!isset($left_days) || !isset($interval_days)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cur_time = time();
|
|
|
+ $field = "bonus_id,user_id,type_sn,(usable_time-{$cur_time}) as leftsecs";
|
|
|
+ $day_secs = 24 * 3600;
|
|
|
+ $left_warn_secs = intval($left_days) * $day_secs;
|
|
|
+ $period_secs = intval($interval_days) * $day_secs;
|
|
|
+
|
|
|
+ $condition = "bonus_status = 3 and usable_time > {$cur_time} and usable_time-{$cur_time} <= {$left_warn_secs} and (isnull(notify_time) or {$cur_time} - notify_time >= {$period_secs})";
|
|
|
$ret = $this->field($field)->where($condition)->limit(false)->select();
|
|
|
- return $ret;
|
|
|
+ if(empty($ret)) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public function get_already_expired_bonus()
|
|
|
+ public function getexpired_bonus()
|
|
|
{
|
|
|
$field = 'bonus_id,user_id,type_sn';
|
|
|
$condition = 'usable_time <= unix_timestamp(now())';
|