ソースを参照

fix order cancel bonus

stanley-king 7 年 前
コミット
82492523f4
3 ファイル変更31 行追加3 行削除
  1. 11 0
      crontab/control/command.php
  2. 9 3
      helper/account_helper.php
  3. 11 0
      test/TestOrder.php

+ 11 - 0
crontab/control/command.php

@@ -15,6 +15,7 @@ require_once(BASE_DATA_PATH . '/mobile/omsid.php');
 require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/bonus/witholder.php');
 require_once(BASE_ROOT_PATH . '/helper/notify_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
 require_once(BASE_ROOT_PATH . '/data/mobile/lrlz_staff.php');
 
 
@@ -32,4 +33,14 @@ class commandControl extends BaseCronControl
         $type_sn = '76341506502791044726';
         bonus_helper::send_mobile($type_sn,$staffs,2);
     }
+    public function refund0928BonusOp()
+    {
+        $items = Model()->query('SELECT * FROM lrlz_order WHERE pd_amount=0 AND LENGTH(bonus_rate) > 0 AND add_time > UNIX_TIMESTAMP(DATE (\'2016-09-28 00:00:00\')) AND order_state = 0');
+        if(empty($item)) return;
+        foreach ($items as $item) {
+            $order_sn = $item['order_sn'];
+            $member_id = intval($item['buyer_id']);
+            account_helper::order_cancel($order_sn,$member_id,true);
+        }
+    }
 }

+ 9 - 3
helper/account_helper.php

@@ -191,7 +191,7 @@ class account_helper
         $pred->pay_bonus($bonus_rate);
     }
 
-    public static function order_cancel($order_sn,$member_id)
+    public static function order_cancel($order_sn,$member_id,$ignore = false)
     {
         $mod_order = Model('order');
         $order = $mod_order->getOrderInfo(array('order_sn' => $order_sn));
@@ -204,7 +204,13 @@ class account_helper
             $bonus_rate = unserialize($bonus_rate);
         }
 
-        if(intval($pd_amount * 100 + 0.5) <= 0) return;
+        if($ignore == false)
+        {
+            if(intval($pd_amount * 100 + 0.5) <= 0) {
+                return;
+            }
+        }
+
         $params = \bonus\parameters::order_cancel($bonus_rate);
         foreach ($params as $param)
         {
@@ -326,7 +332,7 @@ class account_helper
     public static function withhold_bonus($rate,$amount,$member_id)
     {
         $rates = array(intval($rate) => doubleval($amount));
-        $ret = bonus_helper::withold($member_id,$rates);
+        $ret = bonus_helper::withold($member_id,$rates,bonus_helper::send_bonus_withold);
         if($ret) {
             $pred = new predeposit_helper($member_id);
             $pred->reduce_pred($amount);

+ 11 - 0
test/TestOrder.php

@@ -151,4 +151,15 @@ class TestOrder extends PHPUnit_Framework_TestCase
         $data = 'a:2:{i:50;d:5.1799999999999997;i:30;d:17.59;}';
         $x = unserialize($data);
     }
+    public function testRefund()
+    {
+        //SELECT * FROM lrlz_order WHERE add_time > UNIX_TIMESTAMP(DATE ('2017-09-28 00:00:00')) AND order_state = 0;
+
+        $items = Model()->query('SELECT * FROM lrlz_order WHERE pd_amount=0 AND LENGTH(bonus_rate) > 0 AND add_time > UNIX_TIMESTAMP(DATE (\'2017-09-01 00:00:00\')) AND order_state = 0');
+        foreach ($items as $item) {
+            $order_sn = $item['order_sn'];
+            $member_id = intval($item['buyer_id']);
+            account_helper::order_cancel($order_sn,$member_id,true);
+        }
+    }
 }