Commit 0104eae5 authored by hujun's avatar hujun

计算

parent 498360d6
......@@ -3443,8 +3443,9 @@ class Finance extends Basic
$custody_fee = $this->sumPayLogPriceByType(6, 1);//保管金转保管金
//保管金调整:保管金转保管金+保管金转中介费+保管金转案场费
$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']; //账上保管金
//待处理款项总计:未开业佣金+账上意向金+账上保管金
......@@ -3508,15 +3509,18 @@ class Finance extends Basic
private function sumPayLogPriceByType(int $type, int $is_adjustment = 0) {
if ($is_adjustment) {
$m_pay_adjustment = new OPayLogAdjustment();
$where['b.type'] = $type;
$where['source'] = 2;
$where['a.type'] = $type;
$where['b.source'] = 2;
$where['a.is_del'] = 0;
$where['b.is_del'] = 0;
$price = $m_pay_adjustment->sumMoney('a.money', $where, $is_adjustment);
} else {
$m_pay = new OPayLogModel();
$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{
*/
public function sumMoney($field, $where) {
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)
->sum($field);
}
......
......@@ -531,7 +531,7 @@ class OPayLogModel extends Model
*/
public function sumBargainPrice($field, $where) {
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)
->sum($field);
}
......@@ -539,20 +539,21 @@ class OPayLogModel extends Model
/**
* @param string $field
* @param array $where
* @param int $type 1 调整前 0调整后
* @return float|int|string
*/
public function sumAdjustment(string $field, array $where, int $type = 1) {
if ($type) {
$field = $this->db_->alias('a')
->join('o_paylog_adjustment b','a.id=b.paylog_id')
->where($where)
->sum($field);
} else {
$field = $this->db_->where($where)
->sum($field);
}
public function sumPayLogAdjustment(string $field, array $where) {
return $this->db_->alias('a')
->join('o_paylog_adjustment b','a.id=b.paylog_id','left')
->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