rabin 2 years ago
parent
commit
6d22abc445
2 changed files with 59 additions and 26 deletions
  1. 19 24
      app/cash/lib/Order.php
  2. 40 2
      app/shop/lib/Sell.php

+ 19 - 24
app/cash/lib/Order.php

@@ -47,33 +47,28 @@ class Order
                 $update['fdate'] = $order['fdate'];
             }
         }
-        if ($info && $jstype == 3) {
-
-        } else {
-            
-            $update['type'] = $order['type'];
-            $update['type_id'] = $order['type_id'];
-            if ($order['source_type']) {
-                $update['source_type'] = $order['source_type'];
-                $update['source_id'] = $order['source_id'];
-            }
+        $update['type'] = $order['type'];
+        $update['type_id'] = $order['type_id'];
+        if ($order['source_type']) {
+            $update['source_type'] = $order['source_type'];
+            $update['source_id'] = $order['source_id'];
+        }
 
-            $update['source_order_num'] = $order['order_num'];
-            $update['num'] = $order['num'];
+        $update['source_order_num'] = $order['order_num'];
+        $update['num'] = $order['num'];
 
-            if ($refund) {
-                $update['cash'] = $refund['cash'];
-                $update['p_cash'] = isset($refund['p_cash']) ? $refund['p_cash'] : 0;
-            } else {
-                $update['cash'] = $order['price'];
-                $update['p_cash'] = $order['p_price'];
-            }
+        if ($refund) {
+            $update['cash'] = $refund['cash'];
+            $update['p_cash'] = isset($refund['p_cash']) ? $refund['p_cash'] : 0;
+        } else {
+            $update['cash'] = $order['price'];
+            $update['p_cash'] = $order['p_price'];
+        }
 
-            if ($jstype == 2) {
-                $update['cash'] = -1*$update['cash'];
-                $update['p_cash'] = -1*$update['p_cash'];
-                $update['num'] = -1*$update['num'];
-            }
+        if ($jstype == 2) {
+            $update['cash'] = -1*$update['cash'];
+            $update['p_cash'] = -1*$update['p_cash'];
+            $update['num'] = -1*$update['num'];
         }
 
         if ($info) {

+ 40 - 2
app/shop/lib/Sell.php

@@ -382,7 +382,26 @@ class Sell
                     # 还原礼品卡
                     Dever::db('card/code')->decUseCash(array('where_id' => $data['card_code_id'], 'set_use_cash' => $data['card_code_cash']));
 
-                    Dever::load('cash/lib/order')->up($data, 3, 2, false, 2);
+                    $code = Dever::db('card/code')->find($data['card_code_id']);
+                    if ($code) {
+                        $card_info = Dever::db('card/info')->find($code['card_id']);
+                        if ($card_info) {
+                            if ($code['type'] == 2) {
+                                $zhe = 0.9;
+                            } else {
+                                $zhe = $card_info['price']/$card_info['value'];
+                            }
+                            $price = round($data['card_code_cash']*$zhe, 2);
+                            $data['type'] = 1;
+                            $data['type_id'] = $data['shop_id'];
+                            $data['source_type'] = 4;
+                            $data['source_id'] = -1;
+                            $data['price'] = $price;
+                            $data['p_price'] = $data['card_code_cash'];
+
+                            Dever::load('cash/lib/order')->up($data, 3, 2, false, 2);
+                        }
+                    }
 
                 } elseif (isset($data['wallet_cash']) && $data['wallet_cash'] && $data['wallet_cash'] > 0) {
                     # 还原钱包
@@ -1331,7 +1350,26 @@ class Sell
                 $card_update['status'] = 4;
                 Dever::db('goods/card_code')->update($card_update);
 
-                Dever::load('cash/lib/order')->up($info, 3, 2, false, 2);
+                $code = Dever::db('card/code')->find($info['card_code_id']);
+                if ($code) {
+                    $card_info = Dever::db('card/info')->find($code['card_id']);
+                    if ($card_info) {
+                        if ($code['type'] == 2) {
+                            $zhe = 0.9;
+                        } else {
+                            $zhe = $card_info['price']/$card_info['value'];
+                        }
+                        $price = round($info['card_code_cash']*$zhe, 2);
+                        $info['type'] = 1;
+                        $info['type_id'] = $info['shop_id'];
+                        $info['source_type'] = 4;
+                        $info['source_id'] = -1;
+                        $info['price'] = $price;
+                        $info['p_price'] = $info['card_code_cash'];
+
+                        Dever::load('cash/lib/order')->up($info, 3, 2, false, 2);
+                    }
+                }
             }
 
             if ($info['shop_type'] == 2) {