|
@@ -191,4 +191,52 @@ class user_bonusModel extends Model
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function expired_warn()
|
|
|
+ {
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function expired_action()
|
|
|
+ {
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|