|
@@ -55,21 +55,6 @@ class account_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static function evaluate_bonus($member_id,&$money)
|
|
|
- {
|
|
|
- $param = bonus\parameters::evaluate();
|
|
|
- $type = bonus_helper::create_type_input($param);
|
|
|
- $money = $type->getTotal_amount();
|
|
|
- $ret = bonus_helper::make_bonus($param,$param['rate_money']);
|
|
|
- if($ret != false) {
|
|
|
- $type_sn = $ret['type_sn'];
|
|
|
- bonus_helper::send($type_sn,[$member_id]);
|
|
|
- return $type_sn;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public static function gain_system($to_id, $amount)
|
|
|
{
|
|
|
if(self::$stSysBonus == null) {
|
|
@@ -178,44 +163,6 @@ class account_helper
|
|
|
$pred->pay_bonus($bonus_rate);
|
|
|
}
|
|
|
|
|
|
- public static function order_cancel($order_sn,$member_id,$ignore = false)
|
|
|
- {
|
|
|
- $mod_order = Model('order');
|
|
|
- $order = $mod_order->getOrderInfo(['order_sn' => $order_sn]);
|
|
|
-
|
|
|
- $pd_amount = $order['pd_amount'];
|
|
|
- $bonus_rate = $order['bonus_rate'];
|
|
|
- if(empty($bonus_rate)) {
|
|
|
- $bonus_rate = [30 => $pd_amount];
|
|
|
- } else {
|
|
|
- $bonus_rate = unserialize($bonus_rate);
|
|
|
- }
|
|
|
-
|
|
|
- if($ignore == false)
|
|
|
- {
|
|
|
- if(intval($pd_amount * 100 + 0.5) <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $params = \bonus\parameters::order_cancel($bonus_rate);
|
|
|
- foreach ($params as $param)
|
|
|
- {
|
|
|
- $rate_money = $param['rate_money'];
|
|
|
- $ret = bonus_helper::make_bonus($param,$rate_money);
|
|
|
- $rate = $rate_money[0]['rate'];
|
|
|
- $amount = $rate_money[0]['amount'];
|
|
|
- if($ret != false) {
|
|
|
- bonus_helper::send($ret['type_sn'],[$member_id]);
|
|
|
- push_helper::order_cancel_bonus($member_id,$rate,$amount);
|
|
|
- } else {
|
|
|
- Log::record("给用户{$member_id} 退款{$amount}失败.");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Model()->table('order')->where(['order_sn' => $order_sn])->update(['pd_amount' => 0,'bonus_rate' => '']);
|
|
|
- }
|
|
|
-
|
|
|
public static function bonus_refund($type_sn,$member_id)
|
|
|
{
|
|
|
$type = bonus\type::create_by_sn($type_sn);
|
|
@@ -273,6 +220,7 @@ class account_helper
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static function appreciate($sender_id,$rate,$amount,$toid,$bless)
|
|
|
{
|
|
|
$param = \bonus\parameters::appreciate($sender_id,intval($rate),$amount,$bless);
|
|
@@ -304,24 +252,7 @@ class account_helper
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
- static public function paysuccess_bonus($buyer_id, $total_amount)
|
|
|
- {
|
|
|
- $params = \bonus\parameters::order_complete($total_amount);
|
|
|
-
|
|
|
- $val = 0.00;
|
|
|
- foreach ($params as $param)
|
|
|
- {
|
|
|
- $ret = bonus_helper::make_bonus($param,$param['rate_money']);
|
|
|
- if($ret != false) {
|
|
|
- $type_sn = $ret['type_sn'];
|
|
|
- $bonus = bonus_helper::send($type_sn,[$buyer_id]);
|
|
|
- $val += $bonus[0]['bonus_value'];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return $val;
|
|
|
- }
|
|
|
-
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
public static function onPredRefund($change_type,$member_id,$sn,$refund_id)
|
|
|
{
|
|
|
// $order_sn = $sn;
|
|
@@ -335,11 +266,19 @@ class account_helper
|
|
|
|
|
|
public static function onPredeposit($change_type,$member_id,$sn)
|
|
|
{
|
|
|
- if($change_type == 'order_pay' || $change_type == 'order_freeze') {
|
|
|
+ if($change_type == 'order_pay' || $change_type == 'order_freeze')
|
|
|
+ {
|
|
|
self::use_bonus($sn,$member_id);
|
|
|
}
|
|
|
- elseif($change_type == 'order_cancel') { //发送给该用户一个同等额度的红包
|
|
|
- self::order_cancel($sn,$member_id);
|
|
|
+ elseif($change_type == 'order_cancel')
|
|
|
+ {
|
|
|
+ //发送给该用户一个同等额度的红包
|
|
|
+ $mod_order = Model('order');
|
|
|
+ $order = $mod_order->getOrderInfo(['order_sn' => $sn,'buyer_id' => $member_id]);
|
|
|
+ if(!empty($order)) {
|
|
|
+ $pay_sn = $order['pay_sn'];
|
|
|
+ QueueClient::push('onAsyncOrderCancel',['pay_sn' => $pay_sn]);
|
|
|
+ }
|
|
|
}
|
|
|
elseif($change_type == 'refund') { //发送给该用户一个同等额度的红包
|
|
|
|
|
@@ -349,27 +288,6 @@ class account_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function onEvaluate($member_id)
|
|
|
- {
|
|
|
- if(self::evaluate_bonus($member_id,$money) != false) {
|
|
|
- push_helper::evaluation_bonus($member_id,$money);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //在发货之后,可以提醒用户留意收货,在订单中查看物流,短信通知
|
|
|
- public static function onOrderSend($order_sn,$logistics_company,$logistics)
|
|
|
- {
|
|
|
- Log::record("account_helper::onOrderSend order_sn={$order_sn} company={$logistics_company} no={$logistics}",Log::DEBUG);
|
|
|
- $mod = Model('order');
|
|
|
- $info = $mod->getOrderInfo(['order_sn' => $order_sn]);
|
|
|
- $buyer_id = intval($info['buyer_id']);
|
|
|
- if($buyer_id <= 0) return;
|
|
|
-
|
|
|
- $mem_info = new member_info($buyer_id);
|
|
|
- $mobile = $mem_info->mobile();
|
|
|
- sms_helper::send_nostore_message($mobile,Sms::order_sended,['company'=> $logistics_company,'logistics'=>$logistics,'time'=>'5']);
|
|
|
- }
|
|
|
-
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
public static function onLogin($member_id)
|
|
|
{
|
|
@@ -384,6 +302,7 @@ class account_helper
|
|
|
$fcode = new user_session\fcode();
|
|
|
$fcode->onStatus();
|
|
|
}
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
public static function onStatus($member_id)
|
|
|
{
|
|
@@ -411,8 +330,13 @@ class account_helper
|
|
|
|
|
|
public static function onAsyncStatus($member_id)
|
|
|
{
|
|
|
- $iPusher = new async_push\status($member_id);
|
|
|
- $iPusher->run();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\status($member_id);
|
|
|
+ $iPusher->run();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
}
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
public static function onRegister($member_id,$relay_id)
|
|
@@ -433,28 +357,68 @@ class account_helper
|
|
|
|
|
|
public static function onAsyncRegister($user,$inviter)
|
|
|
{
|
|
|
- $iPusher = new async_push\register($user,$inviter);
|
|
|
- $iPusher->run();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\register($user,$inviter);
|
|
|
+ $iPusher->run();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- //在支付成功之后,可以提醒用户收到货后,可以收到红包奖励。
|
|
|
- public static function onAsyncPaySuccess($pay_sn)
|
|
|
+ public static function onAsyncOrderPaied($pay_sn)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\order($pay_sn);
|
|
|
+ $iPusher->onPaied();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function onAsyncOrderSended($pay_sn,$logistics_no,$logistics_company)
|
|
|
{
|
|
|
- $iPusher = new async_push\order($pay_sn);
|
|
|
- $iPusher->onPaySuccess();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\order($pay_sn);
|
|
|
+ $iPusher->onSended($logistics_no,$logistics_company);
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static function onAsyncOrderComplete($pay_sn)
|
|
|
{
|
|
|
- $iPusher = new async_push\order($pay_sn);
|
|
|
- $iPusher->onOrderComplete();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\order($pay_sn);
|
|
|
+ $iPusher->onComplete();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- public static function onAsyncEvaluate($member_id)
|
|
|
+ public static function onAsyncOrderCancel($pay_sn)
|
|
|
{
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\order($pay_sn);
|
|
|
+ $iPusher->onCancel();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ public static function onAsyncOrderEvaluate($pay_sn)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $iPusher = new async_push\order($pay_sn);
|
|
|
+ $iPusher->onEvaluate();
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ Log::record($ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
}
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
public static function onAsyncGoodsDiscount($gid)
|