rabin 3 年之前
父节点
当前提交
6567296b72
共有 3 个文件被更改,包括 24 次插入12 次删除
  1. 4 1
      app/mshop/lib/Buy.php
  2. 19 11
      app/shop/lib/Refund.php
  3. 1 0
      app/shop/lib/Sell.php

+ 4 - 1
app/mshop/lib/Buy.php

@@ -2079,7 +2079,7 @@ class Buy
         return false;
     }
     */
-    public function createOrder($data)
+    public function createOrder($data, $order_cdate = false)
     {
         $where['parent_type'] = $data['order_type'];
         $where['parent_order_id'] = $data['order_id'];
@@ -2109,6 +2109,9 @@ class Buy
             $insert['num'] = $data['num'];
             $insert['refund_cash'] = 0;
             $insert['refund_p_cash'] = 0;
+            if ($order_cdate) {
+                $insert['cdate'] = $order_cdate;
+            }
             $id = $state = Dever::db('shop/buy_order')->insert($insert);
             if ($id) {
                 $goods['order_id'] = $id;

+ 19 - 11
app/shop/lib/Refund.php

@@ -158,6 +158,15 @@ class Refund
                         $num = $info['num'];   
                     }
                     $info['total_price'] = $info['price'] * $num;
+
+                    if (isset($info['discount_cash']) && $info['discount_cash']) {
+                        $info['total_price'] = $info['total_price'] - $info['discount_cash'];
+                    }
+
+                    if (isset($info['coupon_cash']) && $info['coupon_cash']) {
+                        $info['total_price'] = $info['total_price'] - $info['coupon_cash'];
+                    }
+
                     if (isset($data['card_code_cash']) && $data['card_code_cash']) {
                         $kou = $data['card_code_cash'] + $data['wallet_cash'];
                     
@@ -172,19 +181,15 @@ class Refund
                     }
 
                     if (isset($data['record_cash']) && $data['record_cash']) {
-                        $info['total_price'] = $info['total_price'] - $data['record_cash'];
-                    }
-
-                    if (isset($info['discount_cash']) && $info['discount_cash']) {
-                        $info['total_price'] = $info['total_price'] - $info['discount_cash'];
+                        if ($info['total_price'] >= $data['record_cash']) {
+                            $info['total_price'] = $info['total_price'] - $data['record_cash'];
+                        } else {
+                            $re_cash = $info['total_price'];
+                            $info['total_price'] = 0;
+                        }
                     }
 
-                	if (isset($info['coupon_cash']) && $info['coupon_cash']) {
-                		$cash = $info['total_price'] - $info['coupon_cash'];
-                	} else {
-                		$cash = $info['total_price'];
-                	}
-                    
+                    $cash = $info['total_price'];
 
                     if (isset($info['p_price'])) {
                         $p_cash = $info['p_price'] * $num;
@@ -204,6 +209,9 @@ class Refund
                 if (!$data['refund_cash']) {
                     $data['refund_cash'] = 0;
                 }
+                if ($data['price'] <= 0 && isset($data['p_price'])) {
+                    $data['price'] = $data['p_price'];
+                }
                 $cash = $data['price'] - $data['refund_cash'];
                 $num = $data['num'] - $data['refund_num'];
                 if (isset($data['p_price']) && isset($data['refund_p_cash'])) {

+ 1 - 0
app/shop/lib/Sell.php

@@ -2254,6 +2254,7 @@ class Sell
                 foreach ($v as $k1 => $v1) {
                     $v1['order_num'] .= '_' . $i;
 
+                    //$state = Dever::load('mshop/lib/buy')->createOrder($v1, $order['cdate']);
                     $state = Dever::load('mshop/lib/buy')->createOrder($v1);
                     $send[$state] = $v1;
                 }