|
@@ -52,71 +52,4 @@ class bonus_typeModel extends Model
|
|
|
public function edit($condition,$data) {
|
|
|
$this->where($condition)->update($data);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取已过期的余额列表
|
|
|
- */
|
|
|
- private function get_endbonus_list()
|
|
|
- {
|
|
|
- $one_hour = 60 * 60;
|
|
|
- $condition = array('remain_amount' => array('gt',0),'is_refund' => 0,'send_end_date' =>array('lt',time() - $one_hour));
|
|
|
- return $this->where($condition)->field('type_id,type_sn,sender_id,sender_name,remain_amount')->limit(false)->select();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 红包退款
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function bonus_refund()
|
|
|
- {
|
|
|
- $results = $this->get_endbonus_list();
|
|
|
- if(empty($results)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- $model_predeposit = Model('predeposit');
|
|
|
- foreach($results as $result)
|
|
|
- {
|
|
|
- Model::beginTransaction();
|
|
|
- try
|
|
|
- {
|
|
|
- //将没抢完的钱退还到用户余额
|
|
|
- $log_data = array();
|
|
|
- $log_data['member_id'] = $result['sender_id'];
|
|
|
- $log_data['member_name'] = $result['sender_name'];
|
|
|
- $log_data['amount'] = $result['remain_amount'];
|
|
|
- $log_data['type_sn'] = $result['type_sn'];
|
|
|
-
|
|
|
- $model_predeposit->changePd('bonus_refund',$log_data);
|
|
|
-
|
|
|
- //更新红包状态
|
|
|
- $this->where(array('type_id' =>$result['type_id']))->update(array('is_refund' => 1,'refund_time' => time()));
|
|
|
- if ($this->affected_rows() <= 0) {
|
|
|
- Model::rollback();
|
|
|
-
|
|
|
- $sresult = implode(',',$result);
|
|
|
- Log::record("bonus refund 更新状态失败,result:{$sresult}.");
|
|
|
- } else {
|
|
|
- $condition = array('type_id' =>$result['type_id'],'bonus_status' => array('in','0,1'));
|
|
|
- Model('user_bonus')->where($condition)->delete();
|
|
|
- Model::commit();
|
|
|
-
|
|
|
- $param['member_id'] = $result['sender_id'];
|
|
|
- $amount = $result['remain_amount'];
|
|
|
- $param['text'] = "红包退还通知:您发送的红包已超过24小时,退还未被领取的金额{$amount}元,请在收支明细中查看.";
|
|
|
- $param['go_type'] = 'bonus';
|
|
|
- QueueClient::push('upushSendMsg',$param);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception $e)
|
|
|
- {
|
|
|
- Model::rollback();
|
|
|
-
|
|
|
- $sresult = implode(',',$result);
|
|
|
- Log::record('bonus refund : error:' . $e->getMessage() . " result:{$sresult}.");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
}
|