浏览代码

modify trans

stanley-king 3 年之前
父节点
当前提交
6b6e0635e5
共有 2 个文件被更改,包括 14 次插入6 次删除
  1. 13 5
      data/logic/buy_virtual.logic.php
  2. 1 1
      helper/refill/RefillBase.php

+ 13 - 5
data/logic/buy_virtual.logic.php

@@ -86,7 +86,7 @@ class buy_virtualLogic
      * @param int $member_id
      * @param int $member_id
      * @return array
      * @return array
      */
      */
-    public function buyStep3($post, $member_id,$calc_vorder_amount = null,$merchant = false)
+    public function buyStep3($post, $member_id,$calc_vorder_amount = null,$merchant = false,$use_trans = true)
     {
     {
         $fRefill = $merchant;
         $fRefill = $merchant;
         $result = $this->getBuyStepData($post['goods_id'], $post['quantity'], $member_id, $fRefill);
         $result = $this->getBuyStepData($post['goods_id'], $post['quantity'], $member_id, $fRefill);
@@ -116,7 +116,10 @@ class buy_virtualLogic
         {
         {
             $model_goods = Model('goods');
             $model_goods = Model('goods');
             //开始事务
             //开始事务
-            $trans = new trans_wapper($model_goods,__METHOD__);
+            if($use_trans) {
+                $trans = new trans_wapper($model_goods,__METHOD__);
+            }
+
             $member_info = Model('member')->getMemberInfo(['member_id' => $member_id]);
             $member_info = Model('member')->getMemberInfo(['member_id' => $member_id]);
             $order_info = $this->_createOrder($input,$goods_info,$member_info,$fRefill);
             $order_info = $this->_createOrder($input,$goods_info,$member_info,$fRefill);
             if (!empty($post['password']))
             if (!empty($post['password']))
@@ -144,12 +147,17 @@ class buy_virtualLogic
             else {
             else {
                 Log::record('',Log::DEBUG);
                 Log::record('',Log::DEBUG);
             }
             }
-            //提交事务
-            $trans->commit();
+            if($use_trans) {
+                //提交事务
+                $trans->commit();
+            }
         }
         }
         catch (Exception $e)
         catch (Exception $e)
         {
         {
-            $trans->rollback();
+            if($use_trans) {
+                $trans->rollback();
+            }
+            
             return callback(false, $e->getMessage());
             return callback(false, $e->getMessage());
         }
         }
 
 

+ 1 - 1
helper/refill/RefillBase.php

@@ -348,7 +348,7 @@ class RefillBase
             try
             try
             {
             {
                 $trans = new trans_wapper($mod_refill,'RefillBase::add');
                 $trans = new trans_wapper($mod_refill,'RefillBase::add');
-                $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true);
+                $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true,false);
 
 
                 if ($result['state'] === true)
                 if ($result['state'] === true)
                 {
                 {