dever il y a 3 ans
Parent
commit
210232516a

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

@@ -53,7 +53,7 @@ class Order
         }
         if ($info) {
         	$update['where_id'] = $info['id'];
-        	Dever::db('cash/order')->update($update);
+        	$state = Dever::db('cash/order')->update($update);
         } else {
             $update['source_order_num'] = $order['order_num'];
             $update['num'] = $order['num'];
@@ -73,7 +73,24 @@ class Order
             }
         
         	$update['order_num'] = $this->getOrderId();
-        	Dever::db('cash/order')->insert($update);
+        	$state = Dever::db('cash/order')->insert($update);
+        }
+
+        if ($state && $jstype == 2 && $status == 2 && isset($order['status']) && $order['status'] == 8) {
+            # 如果是退款结算,同时要把主订单也结算
+            $where = array();
+            $where['source_order_id'] = $order['id'];
+            $where['jstype'] = 1;
+            $where['audit'] = 1;
+            $info = Dever::db('cash/order')->find($where);
+            if ($info) {
+                $set['status'] = 2;
+                $set['audit'] = 2;
+                $set['where_id'] = $info['id'];
+                $set['operdate'] = time();
+                $set['fdate'] = time();
+                Dever::db('cash/order')->update($set);
+            }
         }
     }
 

+ 20 - 1
app/cash/lib/Set.php

@@ -54,7 +54,26 @@ class Set
             Dever::load('shop/lib/refund')->set('buy')->action($info['refund_id'], $audit, false, false);
 
             if ($audit == 2) {
-                Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time(), 'fdate' => time()));
+                $state = Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time(), 'fdate' => time()));
+
+
+                $order = Dever::db('shop/buy_order')->find(array('id' => $info['source_order_id'], 'cache' => false));
+                if ($state && $info['jstype'] == 2 && isset($order['status']) && $order['status'] == 8) {
+                    # 如果是退款结算,同时要把主订单也结算
+                    $where = array();
+                    $where['source_order_id'] = $order['id'];
+                    $where['jstype'] = 1;
+                    $where['audit'] = 1;
+                    $info = Dever::db('cash/order')->find($where);
+                    if ($info) {
+                        $set['status'] = 2;
+                        $set['audit'] = 2;
+                        $set['where_id'] = $info['id'];
+                        $set['operdate'] = time();
+                        $set['fdate'] = time();
+                        Dever::db('cash/order')->update($set);
+                    }
+                }
             }
         }
     }

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

@@ -740,7 +740,7 @@ class Buy
                 $info['refund_cash'] = $info['refund_p_cash'];
             }
             if ($tk['process'] == 1) {
-                $process = '<a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
+                $process = '<a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn layui-btn-primary">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
             } else {
                 $process = $tk_process[$tk['process']];
             }

+ 14 - 0
app/shop/database/buy_order_goods.php

@@ -176,5 +176,19 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+
+        # 获取多条数据
+        'getTotal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
     ),
 );

+ 14 - 0
app/shop/database/sell_order_goods.php

@@ -185,5 +185,19 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+
+        # 获取多条数据
+        'getTotal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
     ),
 );

+ 5 - 1
app/shop/lib/Refund.php

@@ -269,7 +269,7 @@ class Refund
                 if ($state) {
                     $this->notice($state, $order, $info['cash']);
                     # 检查这个订单下的商品是不是都退了
-                    $total = Dever::db($this->goods_table)->total(array('order_id' => $order['id'], 'status' => 1));
+                    $total = Dever::db($this->goods_table)->getTotal(array('order_id' => $order['id'], 'status' => '1,2'));
 
                     if ($total <= 0) {
                         $update['operdate'] = time();
@@ -304,6 +304,10 @@ class Refund
 
             if ($cash && $this->type == 'buy' && $order['source_id'] && $order['source_id'] > 0) {
                 $order['num'] = $info['num'];
+                if (isset($update['status'])) {
+                    $order['status'] = $update['status'];
+                }
+                
                 Dever::load('cash/lib/order')->up($order, 2, 2, $info);
             }
         }