rabin 1 год назад
Родитель
Сommit
590f1f764d
3 измененных файлов с 43 добавлено и 1 удалено
  1. 14 0
      database/profit.php
  2. 11 0
      database/profit_log.php
  3. 18 1
      lib/Profit.php

+ 14 - 0
database/profit.php

@@ -153,5 +153,19 @@ return array
                 'ycash' => array('yes', '+='),
             ),
         ),
+
+        # 更新
+        'incTcash' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'tcash' => array('yes', '+='),
+            ),
+        ),
     )
 );

+ 11 - 0
database/profit_log.php

@@ -115,6 +115,17 @@ return array
             'list'      => true,
         ),
 
+        'tcash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '已结算退还金额',
+            'default'   => '0',
+            'desc'      => '已结算退还金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
         'desc'      => array
         (
             'type'      => 'varchar-600',

+ 18 - 1
lib/Profit.php

@@ -209,7 +209,7 @@ class Profit
         $data['status'] = $status;
         if ($log) {
             # 结算
-            if ($cash > 0 && $log['cash'] != $cash) {
+            if ($status < 5 && $cash > 0 && $log['cash'] != $cash) {
                 $status = 3;
                 if ($cash > $log['cash']) {
                     $cash = $log['cash'];
@@ -223,6 +223,15 @@ class Profit
                 $data['ycash'] = $log['ycash'] + $cash;
             } elseif ($status == 4) {
                 $data['ycash'] = 0;
+            } elseif ($status == 5) {
+                if ($log['status'] == 4) {
+                    return;
+                }
+                $data['status'] = 3;
+                if ($cash == $log['cash']) {
+                    $data['status'] = 4;
+                }
+                $data['tcash'] = $cash;
             }
             $id = $data['where_id'] = $log['id'];
             Dever::db('account/profit_log')->update($data);
@@ -250,6 +259,14 @@ class Profit
                 # 同步钱包
                 Dever::load('account/lib/info.up_commit', $uid, $data['ycash'], 'shouyi', $config, $name, $source, $source_id, 1);
             }
+            if (isset($data['tcash']) && $data['tcash']) {
+                $update['where_id'] = $profit_id;
+                $update['set_tcash'] = $data['tcash'];
+                Dever::db('account/profit')->incTcash($update);
+
+                # 同步钱包
+                Dever::load('account/lib/info.up_commit', $uid, $data['tcash'], 'shouyi_tuikuan', $config, $name, $source, $source_id, 1);
+            }
         }
     }
 }