Your Name 2 vuotta sitten
vanhempi
commit
9d646a37d9

+ 1 - 1
app/shop/database/info.php

@@ -601,7 +601,7 @@ return array
             'default'   => '0',
             'desc'      => '资金账户',
             'match'     => 'option',
-            'update'    => 'text',
+            // 'update'    => 'text',
         ),
 
         'stat_type'        => array

+ 4 - 0
app/shop/database/record.php

@@ -70,6 +70,10 @@ $config = array
     'config_type' => $type,
     'config_status' => $status,
     'info' => $info,
+    'start' => array
+    (
+        'insert' => 'shop/lib/record.insertRecord',
+    ),
     'end' => array
     (
     	'insert' => 'shop/lib/record.updateRecord', 

+ 36 - 30
app/shop/lib/Record.php

@@ -47,6 +47,18 @@ class Record
         Dever::db('shop/info')->upCash($update);
     	return $ids;
     }
+    public function insertRecord($id,$name,$data){
+        $sid= Dever::param('sid',$data);
+        $type = Dever::param('type',$data);
+        $price = Dever::param('price',$data);
+        $shop = Dever::db('shop/info')->find(array('sid'=>$sid));
+        
+        if($type && $type == 2 && $price){
+            if($shop['price']<$price){
+                Dever::alert('提现大于余额');
+            }
+        }
+    }
     #充值和提现
     public function updateRecord($id,$name,$data){
     	$audit = Dever::input('audit',$data);
@@ -54,15 +66,7 @@ class Record
         $type = Dever::input('type',$data);
         $price = Dever::input('price',$data);
         $info = Dever::db('shop/record')->find($id);
-       	$shop = Dever::db('shop/info')->find(array('sid'=>$info['sid']));
-        if($type && $type == 2 && $price){
-           $insert['price'] = -1*$price;
-            
-        }else{
-           if(isset($data['add_type']) && $data['add_type'] == 2 && isset($data['add_price']) && $data['add_price']){
-                $insert['price'] = -1*$data['add_price'];
-           }
-        }
+       	$shop = Dever::db('shop/info')->find(array('sid'=>$info['sid']));        
         if ($info) {
             $where['where_id'] = $shop['id'];
             $where['price'] = $info['price'];
@@ -70,11 +74,14 @@ class Record
             	if($info['price']>$shop['price']){
             		Dever::alert('提现大于余额');
             	}
-                $info['price'] = -1*$info['price'];
-            	$where['price'] = 0;
-            	$insert['yue'] = $shop['price'];
+                
+            	$insert['yue'] = $shop['price']+(-1*$info['price']);
 
             	$insert['type_id'] = Dever::load('bill/lib/tixian')->up($shop['id'], $info['price'], $info['price'], $info['pic'], 2,$id);
+                
+                $info['price'] = -1*$info['price'];
+                $where['price'] = $info['price'];
+                
             }
             Dever::db('shop/info')->upCash($where);
             $ids = Dever::db('shop/info')->find(array('sid'=>$info['sid'],'s'=>1));
@@ -88,13 +95,12 @@ class Record
             	$insert['status'] = 2;
             	$insert['operdate'] = time();
             }elseif($info['type'] == 2){
-                
+                $insert['price'] =$info['price'];
             	$insert['status'] = 1;
             	$insert['audit'] = 1;
             	$insert['fafang'] = 1;
-            }
-            // print_R($insert);die;
-            
+            }   
+            // print_R($insert);die;         
             Dever::db('shop/record')->update($insert);
         }
     }
@@ -126,7 +132,7 @@ class Record
                     	}
                     	$where['price'] = $info['price'];
                     	
-                		$yue = $shop['price'] + $where['price'];
+                		$yue = $shop['price'];
                 		Dever::db('shop/record')->update(array('where_id' => $id, 'yue'=>$yue,'status' => 2, 'operdate' => time()));
                 		$tixian = Dever::db('bill/tixian')->find($info['type_id']);
                 		if($tixian){
@@ -136,17 +142,17 @@ class Record
                     	$where['price'] = $info['price'];
                     	Dever::db('shop/record')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
                     }
-                    
-                    Dever::db('shop/info')->upCash($where);
                 }
             }else {
                 #作废
-                Dever::db('shop/record')->update(array('where_id' => $id, 'status' => 3, 'operdate' => time()));
+                
                 $info = Dever::db('shop/record')->find($id);
                 if ($info && $info['type'] == 2) {
                     $where['where_id'] = $info['shop_id'];
-                    $where['cash'] = -1*$info['price'];
-                    Dever::db('shop/info')->upCash($where);
+                    $where['set_price'] = -1*$info['price'];
+                    $ids = Dever::db('shop/info')->upCash($where);
+                    $shop = Dever::db('shop/info')->find($ids);
+                    Dever::db('shop/record')->update(array('where_id' => $id, 'status' => 3, 'operdate' => time(),'yue'=>$shop['price']));
                 }
             }
         }
@@ -182,14 +188,14 @@ class Record
 		}else{
 			$audit_name = '已作废';
 		}
-		$f_name = '-';
-		if($info['fafang'] == 1){
-			$f_name = '待发放';
-		}elseif($info['fafang'] == 2){
-			$f_name = '已发放';
-		}else{
-			$f_name = '已作废';
-		}
+		// $f_name = '-';
+		// if($info['fafang'] == 1){
+		// 	$f_name = '待发放';
+		// }elseif($info['fafang'] == 2){
+		// 	$f_name = '已发放';
+		// }else{
+		// 	$f_name = '已作废';
+		// }
 		
     	$result = array();
     	$result['门店信息'] = array

+ 5 - 1
service/bill/lib/Manage.php

@@ -158,14 +158,18 @@ class Manage
                     $where['audit_admin'] = $admin['id'];
                     Dever::db('bill/tixian')->update(array('where_id' => $id, 'status' => 3, 'audit_admin' => $where['audit_admin'],'operdate' => time()));
                     $w = array();
-                    $w['where_id'] = $info['mid'];
+                    
                     if ($tixian['type'] == 1) {
+                        $w['where_id'] = $info['mid'];
                         $w['cash'] = -1*$tixian['ycash'];
                         Dever::db('agent/member')->upCash($w);
                     } elseif ($tixian['type'] == 2) {
+                        $w['where_id'] = $info['shop_id'];
                         $w['price'] = -1*$tixian['ycash'];
                         Dever::db('shop/info')->upCash($w);
+                        Dever::db($table)->update(array('where_id' => $info['id'], 'status' => 3, 'operdate' => time()));
                     } elseif ($tixian['type'] == 3) {
+                        $w['where_id'] = $info['uid'];
                         $w['cash'] = -1*$tixian['ycash'];
                         Dever::db('passport/user')->upCash($w);
                     }