Commit 0104eae5 authored by hujun's avatar hujun

计算

parent 498360d6
...@@ -3443,8 +3443,9 @@ class Finance extends Basic ...@@ -3443,8 +3443,9 @@ class Finance extends Basic
$custody_fee = $this->sumPayLogPriceByType(6, 1);//保管金转保管金 $custody_fee = $this->sumPayLogPriceByType(6, 1);//保管金转保管金
//保管金调整:保管金转保管金+保管金转中介费+保管金转案场费 //保管金调整:保管金转保管金+保管金转中介费+保管金转案场费
$data['custody_adjustment'] = $agent_fee + $case_fee + $custody_fee;//保管金调整 $data['custody_adjustment'] = $agent_fee + $case_fee + $custody_fee;//保管金调整
$data['custody_refund'] = 0;//保管金转定 $data['custody_refund'] = $this->sumPayLogRefundByType(3, 0, 0);//保管金转定
//意向金入账-意向金调整-意向金退款 $data['custody_refund'] += $this->sumPayLogRefundByType(2, 0, 0);//保管金转定
//意向金入账-意向金调整-意向金退款
$data['total_custody_recorded'] = $data['custody_recorded'] - $data['custody_adjustment'] - $data['custody_refund']; //账上保管金 $data['total_custody_recorded'] = $data['custody_recorded'] - $data['custody_adjustment'] - $data['custody_refund']; //账上保管金
//待处理款项总计:未开业佣金+账上意向金+账上保管金 //待处理款项总计:未开业佣金+账上意向金+账上保管金
...@@ -3508,15 +3509,18 @@ class Finance extends Basic ...@@ -3508,15 +3509,18 @@ class Finance extends Basic
private function sumPayLogPriceByType(int $type, int $is_adjustment = 0) { private function sumPayLogPriceByType(int $type, int $is_adjustment = 0) {
if ($is_adjustment) { if ($is_adjustment) {
$m_pay_adjustment = new OPayLogAdjustment(); $m_pay_adjustment = new OPayLogAdjustment();
$where['b.type'] = $type; $where['a.type'] = $type;
$where['source'] = 2; $where['b.source'] = 2;
$where['a.is_del'] = 0;
$where['b.is_del'] = 0;
$price = $m_pay_adjustment->sumMoney('a.money', $where, $is_adjustment); $price = $m_pay_adjustment->sumMoney('a.money', $where, $is_adjustment);
} else { } else {
$m_pay = new OPayLogModel(); $m_pay = new OPayLogModel();
$where['type'] = $type; $where['type'] = $type;
$price = $m_pay->sumAdjustment('real_money', $where, $is_adjustment); $where['is_del'] = 0;
$price = $m_pay->sumPayLog('real_money', $where);
} }
return empty($price) ? '' : $price; return $price;
} }
/** /**
......
...@@ -180,7 +180,7 @@ class OPayLogAdjustment extends BaseModel{ ...@@ -180,7 +180,7 @@ class OPayLogAdjustment extends BaseModel{
*/ */
public function sumMoney($field, $where) { public function sumMoney($field, $where) {
return $this->db_->alias('a') return $this->db_->alias('a')
->join('o_paylog b','a.new_paylog_id=b.id') ->join('o_paylog b','a.new_paylog_id=b.id', 'left')
->where($where) ->where($where)
->sum($field); ->sum($field);
} }
......
...@@ -531,7 +531,7 @@ class OPayLogModel extends Model ...@@ -531,7 +531,7 @@ class OPayLogModel extends Model
*/ */
public function sumBargainPrice($field, $where) { public function sumBargainPrice($field, $where) {
return $this->db_->alias('a') return $this->db_->alias('a')
->join('o_bargain b','a.order_id=b.order_id') ->join('o_bargain b','a.order_id=b.order_id', 'left')
->where($where) ->where($where)
->sum($field); ->sum($field);
} }
...@@ -539,20 +539,21 @@ class OPayLogModel extends Model ...@@ -539,20 +539,21 @@ class OPayLogModel extends Model
/** /**
* @param string $field * @param string $field
* @param array $where * @param array $where
* @param int $type 1 调整前 0调整后
* @return float|int|string * @return float|int|string
*/ */
public function sumAdjustment(string $field, array $where, int $type = 1) { public function sumPayLogAdjustment(string $field, array $where) {
if ($type) { return $this->db_->alias('a')
$field = $this->db_->alias('a') ->join('o_paylog_adjustment b','a.id=b.paylog_id','left')
->join('o_paylog_adjustment b','a.id=b.paylog_id') ->where($where)
->where($where) ->sum($field);
->sum($field); }
} else {
$field = $this->db_->where($where)
->sum($field);
}
return $field; /**
* @param string $field
* @param array $where
* @return float|int
*/
public function sumPayLog(string $field, array $where) {
return $this->db_->where($where)->sum($field);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment