|
@@ -192,51 +192,19 @@ class user_bonusModel extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function expired_warn()
|
|
|
+ public function get_expired_soon_notify_bonus($warn_remain_days, $warn_interval_days)
|
|
|
{
|
|
|
- $field = 'user_bonus.user_id,user_bonus.type_sn,(bonus_type.send_end_date-unix_timestamp(now())) as seconds';
|
|
|
- $condition = 'bonus_type.send_end_date > unix_timestamp(now())';
|
|
|
- $ret = Model()->table('user_bonus,bonus_type')->field($field)->join()->on('user_bonus.type_id=bonus_type.type_id')->where($condition)->limit(false)->select();
|
|
|
- foreach ($ret as $key=>$val)
|
|
|
- {
|
|
|
- $user_id = $val["user_id"];
|
|
|
- $remain_days = intval($val["seconds"]) < 86400 ? 1 : (intval($val["seconds"])/86400) + 1;
|
|
|
-
|
|
|
- $param = array();
|
|
|
- $param['member_id'] = $user_id;
|
|
|
- $param['text'] = "红包过期通知:您领取的红包将在{$remain_days}天内过期.";
|
|
|
- $param['go_type'] = 'bonus';
|
|
|
- QueueClient::push('upushSendMsg',$param);
|
|
|
- }
|
|
|
+ $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})';
|
|
|
+ $ret = $this->field($field)->where($condition)->limit(false)->select();
|
|
|
+ return $ret;
|
|
|
}
|
|
|
|
|
|
- public function expired_action()
|
|
|
+ public function get_already_expired_bonus()
|
|
|
{
|
|
|
- $field = 'user_bonus.user_id,user_bonus.type_sn,user_bonus.bonus_id';
|
|
|
- $condition = 'bonus_type.send_end_date <= unix_timestamp(now())';
|
|
|
- $ret = Model()->table('user_bonus,bonus_type')->field($field)->join()->on('user_bonus.type_id=bonus_type.type_id')->where($condition)->limit(false)->select();
|
|
|
-
|
|
|
- $push_array = array();
|
|
|
- $bonus_ids = array();
|
|
|
-
|
|
|
- foreach ($ret as $key=>$val)
|
|
|
- {
|
|
|
- $user_id = $val["user_id"];
|
|
|
- $param = array();
|
|
|
- $param['member_id'] = $user_id;
|
|
|
- $param['text'] = "红包过期通知:您领取的红包已经过期.";
|
|
|
- $param['go_type'] = 'bonus';
|
|
|
-
|
|
|
- $push_array[] = $param;
|
|
|
- $bonus_ids[] = $val["bonus_id"];
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($push_array)) {
|
|
|
- $this->where(array('bonus_id'=>array('in', $bonus_ids)))->delete();
|
|
|
- foreach ($push_array as $key)
|
|
|
- {
|
|
|
- QueueClient::push('upushSendMsg',$key);
|
|
|
- }
|
|
|
- }
|
|
|
+ $field = 'bonus_id,user_id,type_sn';
|
|
|
+ $condition = 'usable_time <= unix_timestamp(now())';
|
|
|
+ $ret = $this->field($field)->where($condition)->limit(false)->select();
|
|
|
+ return $ret;
|
|
|
}
|
|
|
}
|