|
@@ -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()));
|
|
|
}
|
|
|
}
|
|
|
|