|
@@ -10,6 +10,7 @@
|
|
require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
|
|
require_once (BASE_ROOT_PATH . '/helper/bonus_helper.php');
|
|
require_once (BASE_ROOT_PATH . '/helper/model_helper.php');
|
|
require_once (BASE_ROOT_PATH . '/helper/model_helper.php');
|
|
require_once (BASE_ROOT_PATH . '/helper/push_helper.php');
|
|
require_once (BASE_ROOT_PATH . '/helper/push_helper.php');
|
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/sms_helper.php');
|
|
|
|
|
|
class sys_bonus
|
|
class sys_bonus
|
|
{
|
|
{
|
|
@@ -510,15 +511,14 @@ class account_helper
|
|
$money = intval($order_amount/100) * 100;
|
|
$money = intval($order_amount/100) * 100;
|
|
|
|
|
|
$rate_moneys = [];
|
|
$rate_moneys = [];
|
|
- if(intval($money / 2) > 0) {
|
|
|
|
- $item['amount'] = intval($money / 2);
|
|
|
|
- $item['num'] = 10;
|
|
|
|
|
|
+ if(intval($money / 4) > 0) {
|
|
|
|
+ $item['amount'] = intval($money / 4);
|
|
|
|
+ $item['num'] = 5;
|
|
$item['rate'] = 40;
|
|
$item['rate'] = 40;
|
|
$rate_moneys[] = $item;
|
|
$rate_moneys[] = $item;
|
|
}
|
|
}
|
|
|
|
|
|
if($money == 0) $money = 100;
|
|
if($money == 0) $money = 100;
|
|
-
|
|
|
|
{
|
|
{
|
|
$item['amount'] = $money;
|
|
$item['amount'] = $money;
|
|
$item['num'] = 10;
|
|
$item['num'] = 10;
|
|
@@ -528,6 +528,7 @@ class account_helper
|
|
|
|
|
|
return $rate_moneys;
|
|
return $rate_moneys;
|
|
}
|
|
}
|
|
|
|
+
|
|
static public function paysuccess_bonus($buyer_id, $total_amount)
|
|
static public function paysuccess_bonus($buyer_id, $total_amount)
|
|
{
|
|
{
|
|
$rate_moneys = self::make_rates($total_amount);
|
|
$rate_moneys = self::make_rates($total_amount);
|
|
@@ -544,7 +545,7 @@ class account_helper
|
|
$param['send_start_date'] = time();
|
|
$param['send_start_date'] = time();
|
|
$param['send_end_date'] = $param['send_start_date'] + self::period_hour * 3600;
|
|
$param['send_end_date'] = $param['send_start_date'] + self::period_hour * 3600;
|
|
$param['make_type'] = bonus\type::MakePayType;
|
|
$param['make_type'] = bonus\type::MakePayType;
|
|
- $param['type_name'] = "支付奖励红包";
|
|
|
|
|
|
+ $param['type_name'] = "支付奖励红包(可分享)";
|
|
|
|
|
|
$ret = bonus_helper::make_bonus($param,array($rate_money));
|
|
$ret = bonus_helper::make_bonus($param,array($rate_money));
|
|
|
|
|
|
@@ -552,14 +553,10 @@ class account_helper
|
|
$type_sn = $ret['type_sn'];
|
|
$type_sn = $ret['type_sn'];
|
|
$bonus = bonus_helper::send($type_sn,array($buyer_id));
|
|
$bonus = bonus_helper::send($type_sn,array($buyer_id));
|
|
$val += $bonus[0]['bonus_value'];
|
|
$val += $bonus[0]['bonus_value'];
|
|
- Log::record("type_sn={$type_sn} value={$val}");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- push_helper::paysuccess_bonus($buyer_id,$val);
|
|
|
|
- Model('member')->inc_rate_version($buyer_id);
|
|
|
|
-
|
|
|
|
- return array('money' => $val,'total_num' => self::total_number,'sender_name' => '熊猫美妆');
|
|
|
|
|
|
+ return $val;
|
|
}
|
|
}
|
|
|
|
|
|
public static function onPredRefund($change_type,$member_id,$sn,$refund_id)
|
|
public static function onPredRefund($change_type,$member_id,$sn,$refund_id)
|
|
@@ -662,46 +659,54 @@ class account_helper
|
|
}
|
|
}
|
|
|
|
|
|
//在支付成功之后,可以提醒用户收到货后,可以收到红包奖励。
|
|
//在支付成功之后,可以提醒用户收到货后,可以收到红包奖励。
|
|
- public static function onPaySuccess($member_id)
|
|
|
|
|
|
+ public static function onPaySuccess($pay_sn)
|
|
{
|
|
{
|
|
- Log::record("account_helper::onOrderSuccess {$member_id}",Log::DEBUG);
|
|
|
|
|
|
+ Log::record("account_helper::onOrderSuccess pay_sn={$pay_sn}",Log::DEBUG);
|
|
|
|
+ $mod = Model('order');
|
|
|
|
+ $info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
|
|
|
|
+ $buyer_id = intval($info['buyer_id']);
|
|
|
|
+ push_helper::paysuccess($buyer_id);
|
|
}
|
|
}
|
|
|
|
|
|
//在发货之后,可以提醒用户留意收货,在订单中查看物流,短信通知
|
|
//在发货之后,可以提醒用户留意收货,在订单中查看物流,短信通知
|
|
- public static function onOrderSend($member_id)
|
|
|
|
|
|
+ public static function onOrderSend($order_sn,$logistics_company,$logistics)
|
|
{
|
|
{
|
|
- Log::record("account_helper::onOrderSend {$member_id}",Log::DEBUG);
|
|
|
|
|
|
+ Log::record("account_helper::onOrderSend order_sn={$order_sn} company={$logistics_company} no={$logistics}",Log::DEBUG);
|
|
|
|
+ $mod = Model('order');
|
|
|
|
+ $info = $mod->getOrderInfo(array('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,array('company'=> $logistics_company,'logistics'=>$logistics,'time'=>'5'));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- public static function onOrderSuccess($pay_sn)
|
|
|
|
|
|
+ public static function onOrderSuccess($order_id)
|
|
{
|
|
{
|
|
- $data = &$result['data'];
|
|
|
|
- $order_amount = 0.0;
|
|
|
|
- $goods_amount = 0.0;
|
|
|
|
- if(is_array($data['order_list']))
|
|
|
|
- {
|
|
|
|
- foreach($data['order_list'] as $key => $order) {
|
|
|
|
- $order_amount += doubleval($order['order_amount']);
|
|
|
|
- $goods_amount += doubleval($order['goods_amount']);
|
|
|
|
- }
|
|
|
|
|
|
+ if(empty($pay_sn)) {
|
|
|
|
+ Log::record("account_helper::onOrderSuccess $order_id error.",Log::ERR);
|
|
|
|
+ } else {
|
|
|
|
+ Log::record("account_helper::onOrderSuccess $order_id={$order_id}.",Log::ERR);
|
|
|
|
+ }
|
|
|
|
|
|
- $mod = Model('order');
|
|
|
|
- $info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
|
|
|
|
- $buyer_id = intval($info['buyer_id']);
|
|
|
|
- $goods_amount = intval($info['goods_amount']);
|
|
|
|
|
|
+ $mod_order = Model('order');
|
|
|
|
+ $order = $mod_order->getOrderInfo(array('order_id' => $order_id));
|
|
|
|
|
|
- $ret = account_helper::paysuccess_bonus($buyer_id,$goods_amount);
|
|
|
|
- if($ret == false) {
|
|
|
|
- Log::record("向用户发送购物后分享红包失败",log::ERR);
|
|
|
|
- return false;
|
|
|
|
- } else {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+ $buyer_id = intval($order['buyer_id']);
|
|
|
|
+ $goods_amount = intval($order['goods_amount']);
|
|
|
|
+ if($buyer_id <= 0) {
|
|
|
|
+ Log::record("account_helper::onOrderSuccess err buyer_id.",Log::ERR);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- return false;
|
|
|
|
|
|
+
|
|
|
|
+ $bonus_amount = account_helper::paysuccess_bonus($buyer_id,$goods_amount);
|
|
|
|
+ if(intval($bonus_amount * 100) + 0.5 > 10)
|
|
|
|
+ {
|
|
|
|
+ push_helper::paysuccess_bonus($buyer_id,$bonus_amount);
|
|
|
|
+ $mem_info = new member_info($buyer_id);
|
|
|
|
+ $mobile = $mem_info->mobile();
|
|
|
|
+ sms_helper::send_nostore_message($mobile,Sms::order_received,array('time'=>'5'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|