Commit 4a7565c1 authored by hujun's avatar hujun

开票税费列表

parent e7ae76db
......@@ -606,7 +606,7 @@ class Finance extends Basic
return $this->response(101, '查询开票税费参数错误!');
}
$m_fee = new OFee();
$field = 'a.id,a.fee,a.operation_date,b.scale,c.name,c.phone';
$field = 'a.id,a.fee,a.operation_date,b.scale,c.name,c.phone,b.role';
$data = $m_fee->getBargainFeeDetail($this->params['bargain_id'], 1, $field);
return $this->response("200", "request success", $data);
}
......
......@@ -72,19 +72,34 @@ class OFee extends BaseModel
* @param int $bargain_id
* @param int $type
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainFeeDetail(int $bargain_id, int $type = 0, string $field) {
return $this->field($field)
$data = $this->field($field)
->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->join('a_agents c', 'b.agent_id = c.id', 'left')
->where('bargain_id', $bargain_id)
->where('type', $type)
->select();
$grouped = [];
foreach ($data as $value) {
$grouped[$value['operation_date']][] = $value;
}
foreach ($grouped as $k=>$v) {
$total = 0;
foreach ($v as $kk=>$vv) {
$total += $vv['fee'];
}
$grouped[$k]['total'] = $total;
}
return $grouped;
}
/**
......
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