|
@@ -62,6 +62,7 @@ class account_helper
|
|
|
$push_param['member_id'] = $from_id;
|
|
|
$push_param['text'] = "{$thief}偷走了您{$amount}元的红包.";
|
|
|
$push_param['go_type'] = 'bonus';
|
|
|
+
|
|
|
QueueClient::push('upushSendMsg',$push_param);
|
|
|
|
|
|
return $bonusex;
|
|
@@ -142,36 +143,86 @@ class account_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static function order_cancel($member_id,$amount,$bonus_name)
|
|
|
+ private static function pay_bonus($order_sn,$member_id)
|
|
|
{
|
|
|
- $param = self::base_param($amount,1);
|
|
|
- self::admin_param($param);
|
|
|
- $param['make_type'] = \bonus\type::MakeOrderCancelType;
|
|
|
- $param['type_name'] = $bonus_name;
|
|
|
+ $mod_order = Model('order');
|
|
|
+ $order = $mod_order->getOrderInfo(array('order_sn' => $order_sn));
|
|
|
|
|
|
- $ret = bonus_helper::make_bonus($param);
|
|
|
- if($ret != false)
|
|
|
- {
|
|
|
- bonus_helper::send($ret['type_sn'],array($member_id));
|
|
|
+ $pd_amount = $order['pd_amount'];
|
|
|
+ $bonus_rate = $order['bonus_rate'];
|
|
|
+ if(empty($bonus_rate)) {
|
|
|
+ $bonus_rate = array(30 => $pd_amount);
|
|
|
+ } else {
|
|
|
+ $bonus_rate = unserialize($bonus_rate);
|
|
|
+ }
|
|
|
|
|
|
- $push_param = array();
|
|
|
- $push_param['member_id'] = $member_id;
|
|
|
- $push_param['text'] = "取消订单退款通知:金额{$amount}元.";
|
|
|
- $push_param['go_type'] = 'bonus';
|
|
|
- QueueClient::push('upushSendMsg',$push_param);
|
|
|
+ $pred = new predeposit_helper($member_id);
|
|
|
+ $pred->pay_bonus($bonus_rate);
|
|
|
+ Model('member')->inc_rate_version($member_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static function order_cancel($order_sn,$member_id)
|
|
|
+ {
|
|
|
+ $mod_order = Model('order');
|
|
|
+ $order = $mod_order->getOrderInfo(array('order_sn' => $order_sn));
|
|
|
+
|
|
|
+ $pd_amount = $order['pd_amount'];
|
|
|
+ $bonus_rate = $order['bonus_rate'];
|
|
|
+ if(empty($bonus_rate)) {
|
|
|
+ $bonus_rate = array(30 => $pd_amount);
|
|
|
} else {
|
|
|
- Log::record("给用户 {$member_id} 退款{$amount}失败.");
|
|
|
+ $bonus_rate = unserialize($bonus_rate);
|
|
|
}
|
|
|
+
|
|
|
+ foreach ($bonus_rate as $rate => $amount)
|
|
|
+ {
|
|
|
+ $param = self::base_param($amount,1);
|
|
|
+ self::admin_param($param);
|
|
|
+ $param['make_type'] = \bonus\type::MakeOrderCancelType;
|
|
|
+ $param['type_name'] = '订单退款';
|
|
|
+
|
|
|
+ $rate_moneys = [];
|
|
|
+ $item['amount'] = $amount;
|
|
|
+ $item['num'] = 1;
|
|
|
+ $item['rate'] = $rate;
|
|
|
+ $rate_moneys[] = $item;
|
|
|
+
|
|
|
+ $ret = bonus_helper::make_bonusex($param,$rate_moneys);
|
|
|
+ if($ret != false)
|
|
|
+ {
|
|
|
+ bonus_helper::send($ret['type_sn'],array($member_id));
|
|
|
+
|
|
|
+ $push_param = array();
|
|
|
+ $push_param['member_id'] = $member_id;
|
|
|
+ $push_param['text'] = "取消订单退款通知:抵扣率{$rate}%,金额{$amount}元.";
|
|
|
+ $push_param['go_type'] = 'bonus';
|
|
|
+ QueueClient::push('upushSendMsg',$push_param);
|
|
|
+ } else {
|
|
|
+ Log::record("给用户{$member_id} 退款{$amount}失败.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Model('member')->inc_rate_version($member_id);
|
|
|
}
|
|
|
|
|
|
- private static function bonus_refund($member_id,$amount,$bonus_name)
|
|
|
+ public static function bonus_refund($type_sn,$member_id)
|
|
|
{
|
|
|
+ $type = \bonus\type::create_by_sn($type_sn);
|
|
|
+ $amount = $type->remain_amount();
|
|
|
+ $rate = $type->bonus_rate();
|
|
|
+ if(empty($rate)) $rate = 30;
|
|
|
+
|
|
|
$param = self::base_param($amount,1);
|
|
|
self::admin_param($param);
|
|
|
$param['make_type'] = \bonus\type::MakeBonusRefundType;
|
|
|
- $param['type_name'] = $bonus_name;
|
|
|
+ $param['type_name'] = "发送红包过期退款";
|
|
|
|
|
|
- $ret = bonus_helper::make_bonus($param);
|
|
|
+ $rate_moneys = [];
|
|
|
+ $item['amount'] = $amount;
|
|
|
+ $item['num'] = 1;
|
|
|
+ $item['rate'] = $rate;
|
|
|
+ $rate_moneys[] = $item;
|
|
|
+
|
|
|
+ $ret = bonus_helper::make_bonusex($param,$rate_moneys);
|
|
|
if($ret != false)
|
|
|
{
|
|
|
$bonus = bonus_helper::send($ret['type_sn'],array($member_id));
|
|
@@ -182,56 +233,80 @@ class account_helper
|
|
|
$push_param['go_type'] = 'bonus';
|
|
|
QueueClient::push('upushSendMsg',$push_param);
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
Log::record("给用户 {$member_id} 红包退款{$amount}失败.");
|
|
|
}
|
|
|
+ Model('member')->inc_rate_version($member_id);
|
|
|
}
|
|
|
|
|
|
- public static function register_bonus($member_id,$amount)
|
|
|
+ public static function register_bonus($member_id)
|
|
|
{
|
|
|
- $param = self::base_param($amount,1);
|
|
|
- self::admin_param($param);
|
|
|
- $param['make_type'] = \bonus\type::MakeRegister;
|
|
|
- $param['type_name'] = "新用户注册红包";
|
|
|
+ $rate_moneys = [];
|
|
|
+ {
|
|
|
+ $item['amount'] = 30;
|
|
|
+ $item['num'] = 1;
|
|
|
+ $item['rate'] = 40;
|
|
|
+ $rate_moneys[] = $item;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ $item['amount'] = 50;
|
|
|
+ $item['num'] = 1;
|
|
|
+ $item['rate'] = 30;
|
|
|
+ $rate_moneys[] = $item;
|
|
|
+ }
|
|
|
|
|
|
- $ret = bonus_helper::make_bonus($param);
|
|
|
- if($ret != false)
|
|
|
+ $total = 0;
|
|
|
+ foreach ($rate_moneys as $rate)
|
|
|
{
|
|
|
- $bonus = bonus_helper::send($ret['type_sn'],array($member_id));
|
|
|
- return $bonus;
|
|
|
+ $amount = $rate['amount'];
|
|
|
+ $param = self::base_param($amount,1);
|
|
|
+ self::admin_param($param);
|
|
|
+ $param['make_type'] = \bonus\type::MakeRegister;
|
|
|
+ $param['type_name'] = "新人红包";
|
|
|
+
|
|
|
+ $ret = bonus_helper::make_bonusex($param,array($rate));
|
|
|
+ if($ret != false) {
|
|
|
+ bonus_helper::send($ret['type_sn'],array($member_id));
|
|
|
+ $total += $amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Model('member')->inc_rate_version($member_id);
|
|
|
+ if(($total * 100 + 0.5) > 0 ) {
|
|
|
+ return $total;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function onPredeposit($change_type,$member_id,$pd_amount,$sn)
|
|
|
+ public static function onPredRefund($change_type,$member_id,$sn,$refund_id)
|
|
|
{
|
|
|
- Log::record("onPredeposit {$change_type},{$member_id},{$pd_amount}",Log::DEBUG);
|
|
|
+// $order_sn = $sn;
|
|
|
+// $order = order::create_by_sn($order_sn);
|
|
|
+// if($order == false) {
|
|
|
+// self::pay_refund($member_id,$pd_amount,"退款红包");
|
|
|
+// } else {
|
|
|
+// self::pay_refund($member_id,$order->pd_amount(),"退款红包");
|
|
|
+// }
|
|
|
+ }
|
|
|
|
|
|
- if($change_type == 'order_pay') {
|
|
|
- bonus_helper::withold($member_id,$pd_amount);
|
|
|
- }
|
|
|
- elseif($change_type == 'order_freeze') {
|
|
|
- bonus_helper::withold($member_id,$pd_amount);
|
|
|
- }
|
|
|
- elseif($change_type == 'order_comb_pay') {
|
|
|
|
|
|
+ public static function onPredeposit($change_type,$member_id,$sn)
|
|
|
+ {
|
|
|
+ if($change_type == 'order_pay' || $change_type == 'order_freeze') {
|
|
|
+ self::pay_bonus($sn,$member_id);
|
|
|
}
|
|
|
elseif($change_type == 'order_cancel') { // 发送给该用户一个同等额度的红包
|
|
|
- self::order_cancel($member_id,$pd_amount,"退款红包");
|
|
|
+ self::order_cancel($sn,$member_id);
|
|
|
}
|
|
|
elseif($change_type == 'refund')
|
|
|
- { // 发送给该用户一个同等额度的红包
|
|
|
- $order_sn = $sn;
|
|
|
- $order = order::create_by_sn($order_sn);
|
|
|
- if($order == false) {
|
|
|
- self::pay_refund($member_id,$pd_amount,"退款红包");
|
|
|
- } else {
|
|
|
- self::pay_refund($member_id,$order->pd_amount(),"退款红包");
|
|
|
- }
|
|
|
+ {
|
|
|
+ // 发送给该用户一个同等额度的红包
|
|
|
+
|
|
|
}
|
|
|
elseif($change_type == 'bonus_refund') { // 发送给该用户一个同等额度的红包
|
|
|
- self::bonus_refund($member_id,$pd_amount,"红包过期未领退款");
|
|
|
+ self::bonus_refund($sn,$member_id);
|
|
|
}
|
|
|
}
|
|
|
}
|