Commit fa234e4e authored by hujun's avatar hujun

实收汇总优化-税费

parent fef09fb3
......@@ -1640,6 +1640,7 @@ class Finance extends Basic
}
$m_partial = new OPartialCommission();
$m_tax = new OTaxes();
$fields = 'd.income_time,c.create_time,c.id,a.agent_id,b.name,b.phone';
$commission_fields = 'sum(practical_fee) as practical_fee,sum(cash) as cash,sum(real_fee) as real_fee,sum(service_charge) as service_charge,
......@@ -1649,6 +1650,9 @@ class Finance extends Basic
}
$commission_where['b.income_time'] = ['between time', [ $operation_start_data, $operation_end_data ]];
$commission_where['confirm_status'] = 1;
$tax_where['operation_date'] = ['between time', [ $operation_start_data, $operation_end_data ]];
$tax_where['is_del'] = 0;
if (empty($this->params['excel']) && $this->params['excel'] != 1) {
$result_data = $m_partial->getCommissionTotalListV2($pageNo, $pageSize, 'a.agent_id desc', $fields, $where, $operation_start_data, $operation_end_data);
if ($result_data['status'] == 'successful') {
......@@ -1664,7 +1668,11 @@ class Finance extends Basic
$list[$k]['real_fee'] = $commission_data['real_fee'];
$list[$k]['service_charge'] = $commission_data['service_charge'];
$list[$k]['charity_fund'] = $commission_data['charity_fund'];
$list[$k]['over_fee'] = $commission_data['practical_fee'] - $v['fee'];
$tax_where['agent_id'] = $v['agent_id'];
$fee = $m_tax->sumField('fee', $tax_where);
$list[$k]['fee'] = $fee;
$list[$k]['over_fee'] = $commission_data['practical_fee'] - $fee;
}
$data['data']['list'] = $list;
$data['data']['total'] = $m_partial->getCommissionTotalListTotalV2($where);
......@@ -1693,8 +1701,11 @@ class Finance extends Basic
$excel_data[$k]['cash'] = $commission_data['cash']; //现金奖
$excel_data[$k]['charity_fund'] = $commission_data['charity_fund']; //慈善基金
$excel_data[$k]['practical_fee'] = $commission_data['practical_fee']; //实收佣金
$excel_data[$k]['fee'] = $v['fee']; //税费
$excel_data[$k]['over_fee'] = $commission_data['practical_fee'] - $v['fee'];
$tax_where['agent_id'] = $v['agent_id'];
$fee = $m_tax->sumField('fee', $tax_where);
$excel_data[$k]['fee'] = $fee;
$excel_data[$k]['over_fee'] = $commission_data['practical_fee'] - $fee;
}
$num = count($excel_data) + 2;
......
......@@ -308,12 +308,6 @@ class OPartialCommission extends BaseModel
$district_store = $m_agent->getStoreDistrict('store_name,district_name', [ 'a.id' => $v['agent_id'] ]);
$data[$k]['district_store'] = $district_store['district_name'] . '-' . $district_store['store_name'];
//税费
$data[$k]['fee'] = $m_tax->where('operation_date', 'between time', [ $operation_start_data, $operation_end_data ])
->where('agent_id', $v['agent_id'])
->where('is_del',0)
->sum('fee');
//去除多次应分佣金
$should_commission = $this->where('confirm_date', 'between time', [ $operation_start_data, $operation_end_data ])
->where('agent_id', $v['agent_id'])
......
......@@ -279,4 +279,8 @@ class OTaxes extends BaseModel
$result = $this->where($where_)->update($update_dta);
return $result;
}
public function sumField($field, $where) {
return $this->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