dever %!s(int64=3) %!d(string=hai) anos
pai
achega
42375341dd
Modificáronse 4 ficheiros con 16 adicións e 9 borrados
  1. 2 1
      app/cash/database/shop.php
  2. 3 0
      app/cash/lib/Shop.php
  3. 8 5
      app/mshop/lib/Buy.php
  4. 3 3
      app/shop/lib/Refund.php

+ 2 - 1
app/cash/database/shop.php

@@ -163,6 +163,7 @@ return array
             'match'     => 'is_numeric',
             'option'    => $audit,
             'search'    => 'select',
+            'update'    => 'radio',
             'list'      => 'Dever::load("cash/lib/manage.info", "{audit_type}", "{audit}")',
         ),
 
@@ -230,7 +231,7 @@ return array
 
         'list_button' => array
         (
-            'fast' => array('审核', '"shop&where_id={id}&col=audit,desc&oper_save_jump=shop&oper_table=shop&oper_parent=shop"', '{audit_type} == 2'),
+            'fast' => array('审核', '"shop&where_id={id}&col=audit,desc&oper_save_jump=shop&oper_table=shop&oper_parent=shop"', '{audit_type} == 2 && {audit} == 1'),
         ),
     ),
 

+ 3 - 0
app/cash/lib/Shop.php

@@ -19,6 +19,9 @@ class Shop
         $update['buy_order_num'] = $order['order_num'];
         $update['num'] = $order['num'];
         $update['cash'] = $order['price'];
+        if ($type == 2) {
+            $update['cash'] = -1*$update['cash'];
+        }
         $update['status'] = $status;
         $update['audit'] = $audit;
         $update['audit_type'] = $audit_type;

+ 8 - 5
app/mshop/lib/Buy.php

@@ -817,7 +817,7 @@ class Buy
 
         if ($type == 1) {
             # 门店结算单
-            $cash_order = Dever::db('cash/shop')->select(array('shop_id' => $order['type_id'], 'buy_order_id' => $info['id']));
+            $cash_order = Dever::db('cash/shop')->select(array('shop_id' => $info['type_id'], 'buy_order_id' => $info['id']));
         } elseif ($type == 2) {
             # 工厂结算单
         }
@@ -988,6 +988,9 @@ class Buy
             } else {
                 if (!$yes) {
                     Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'state' => 2));
+                    if ($order['type'] == 1) {
+                        Dever::load('cash/lib/shop')->up($order, 1, 1, 3, 1);
+                    }
                 } else {
                     $price = 0;
                     $num = 0;
@@ -997,13 +1000,13 @@ class Buy
                         $num += $v['num'];
                     }
 
-                    $price = $order['price'] - $price;
-                    $num = $order['num'] - $num;
-                    Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'price' => $price, 'num' => $num));
+                    $order['price'] = $order['price'] - $price;
+                    $order['num'] = $order['num'] - $num;
+                    Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'price' => $order['price'], 'num' => $order['num']));
                     Dever::load('shop/lib/refund')->set('buy')->apply(1, $shop['id'], $order_id, false, 3, 0, '供货商库存不足');
 
                     if ($order['type'] == 1) {
-                        Dever::load('cash/lib/shop')->up($order, 2, 1, 1, 2);
+                        Dever::load('cash/lib/shop')->up($order, 1, 1, 3, 1);
                     }
                 }
             }

+ 3 - 3
app/shop/lib/Refund.php

@@ -189,7 +189,7 @@ class Refund
     }
 
     # 确认退款
-    public function action($info, $process, $order = false)
+    public function action($info, $process, $order = false, $cash = true)
     {
         if (!is_array($info)) {
             $info = Dever::db($this->refund_table)->find($info);
@@ -230,7 +230,7 @@ class Refund
                 Dever::db($this->goods_table)->update(array('where_id' => $info['order_goods_id'], 'status' => 1));
             }
 
-            if ($this->type == 'buy' && $order['type'] == 1) {
+            if ($cash && $this->type == 'buy' && $order['type'] == 1) {
                 Dever::load('cash/lib/shop')->up($order, 2, 1, 3, 2);
             }
         } else {
@@ -267,7 +267,7 @@ class Refund
                 }
             }
 
-            if ($this->type == 'buy' && $order['type'] == 1) {
+            if ($cash && $this->type == 'buy' && $order['type'] == 1) {
                 Dever::load('cash/lib/shop')->up($order, 2, 2, 2, 2);
             }
         }