dever 3 years ago
parent
commit
1d29410187
1 changed files with 24 additions and 26 deletions
  1. 24 26
      service/option/lib/Cash.php

+ 24 - 26
service/option/lib/Cash.php

@@ -238,37 +238,35 @@ class Cash
     # 确认期权价值
     public function setValue_commit($info)
     {
-        $state = Dever::db('option/bill_jiaofu')->upYes(array('where_end' => $info['jiaofu_date'], 'where_aid' => $info['aid'], 'where_status' => 2, 'set_agreement_id' => $info['id'], 'set_status' => 1, 'set_qdate' => time()));
-
-        if ($state) {
-            $account_cash = Dever::db('option/cash')->select(array('aid' => $info['aid']));
-            if ($account_cash) {
-                foreach ($account_cash as $k => $v) {
-                    $cash = Dever::db('option/bill_jiaofu')->getTotal(array('where_end' => $info['jiaofu_date'], 'where_type' => $v['type'], 'where_aid' => $info['aid'], 'where_status' => 2));
-                    if ($cash) {
-                        $update = array();
-                        $update['where_id'] = $v['id'];
-                        $update['daijiaofu'] = $v['daijiaofu'] - $cash['total'];
-                        $update['jiaofu'] = $v['jiaofu'] + $cash['total'];
-                        if ($update['daijiaofu'] < 0) {
-                            $update['daijiaofu'] = 0;
-                        }
-                        $update['clear'] = true;
-                        Dever::db('option/cash')->update($update);
-
-                        # 获取待发放数据 对之前发放的数据进行发放
-                        $fafang = Dever::db('option/bill_fafang')->find(array('status' => 2, 'type' => $v['type'], 'aid' => $info['aid']));
-                        if ($fafang) {
-                            foreach ($fafang as $v1) {
-                                if ($cash['total'] >= $v1['cash']) {
-                                    Dever::db('option/bill_fafang')->update(array('where_id' => $v['id'], 'status' => 1));
-                                    $cash['total'] -= $v1['cash'];
-                                }
+        $account_cash = Dever::db('option/cash')->select(array('aid' => $info['aid']));
+        if ($account_cash) {
+            foreach ($account_cash as $k => $v) {
+                $cash = Dever::db('option/bill_jiaofu')->getTotal(array('where_end' => $info['jiaofu_date'], 'where_type' => $v['type'], 'where_aid' => $info['aid'], 'where_status' => 2));
+                if ($cash) {
+                    $update = array();
+                    $update['where_id'] = $v['id'];
+                    $update['daijiaofu'] = $v['daijiaofu'] - $cash['total'];
+                    $update['jiaofu'] = $v['jiaofu'] + $cash['total'];
+                    if ($update['daijiaofu'] < 0) {
+                        $update['daijiaofu'] = 0;
+                    }
+                    $update['clear'] = true;
+                    Dever::db('option/cash')->update($update);
+
+                    # 获取待发放数据 对之前发放的数据进行发放
+                    $fafang = Dever::db('option/bill_fafang')->find(array('status' => 2, 'type' => $v['type'], 'aid' => $info['aid']));
+                    if ($fafang) {
+                        foreach ($fafang as $v1) {
+                            if ($cash['total'] >= $v1['cash']) {
+                                Dever::db('option/bill_fafang')->update(array('where_id' => $v['id'], 'status' => 1));
+                                $cash['total'] -= $v1['cash'];
                             }
                         }
                     }
                 }
             }
+
+            Dever::db('option/bill_jiaofu')->upYes(array('where_end' => $info['jiaofu_date'], 'where_aid' => $info['aid'], 'where_status' => 2, 'set_agreement_id' => $info['id'], 'set_status' => 1, 'set_qdate' => time()));
         }
     }