Commit b08a2361 authored by hujun's avatar hujun

开票税费列表

parent d63768b1
......@@ -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,b.role';
$field = 'a.id,a.total_fee,a.operation_date';
$data = $m_fee->getBargainFeeDetail($this->params['bargain_id'], 1, $field);
return $this->response("200", "request success", $data);
}
......@@ -641,7 +641,7 @@ class Finance extends Basic
$insert_data['operation_id'] = $this->userId;
$insert_data['operation_date'] = $operation_date;
$insert_data['type'] = 1;
$m_fee->editData($insert_data, $this->params['total_id']);
$m_fee->editData($insert_data, $this->params['id']);
$father_id = $m_fee->id;
$data = $m_fee->addFee($tax, $bargain_id, 1, $this->userId, $father_id, $this->params['total_fee'], $operation_date);
return $this->response("200", "request success", $data);
......
......@@ -58,7 +58,7 @@ class OFee extends BaseModel
public function addFee($data, $bargain_id, $type = 0, int $agent_id, $father_id = 0, $total_fee = 0, $operation_date = '') {
$insert_data = [];
foreach ($data as $k => $v) {
$insert_data[$k]['id'] = $v['id'];
$insert_data[$k]['id'] = $v['fee_id'];
$insert_data[$k]['bargain_id'] = $bargain_id;
$insert_data[$k]['fee'] = $v['fee'];
$insert_data[$k]['operation_id'] = $agent_id;
......@@ -92,25 +92,24 @@ class OFee extends BaseModel
$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)
->where('a.father_id', 0)
->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'];
$result = [];
foreach ($data as $k => $v) {
$result[$k] = $v;
if (isset($v['id'])) {
$result[$k]['fee_list'] = $this->field('a.id as feed_id,a.fee,c.phone,c.name,b.role,b.scale')
->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->join('a_agents c', 'b.agent_id = c.id', 'left')
->where('a.father_id', $v['id'])->select();
}
$grouped[$k]['total'] = $total;
}
return $grouped;
return $result;
}
/**
......
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