Commit d6af116d authored by hujun's avatar hujun

删除税费

parent 05b1290a
...@@ -1259,6 +1259,31 @@ class Finance extends Basic ...@@ -1259,6 +1259,31 @@ class Finance extends Basic
return $this->response("200", "request success", $data); return $this->response("200", "request success", $data);
} }
/**
* 开票税费查询
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTallAgeV2()
{
if (empty($this->params['bargain_id'])) {
return $this->response(101, '查询开票税费参数错误!');
}
$m_fee = new OTaxes();
$field = 'id,total_fee,operation_date,bargain_id';
$data = $m_fee->getBargainFeeDetailV2($this->params['bargain_id'], $field);
$where['a.is_del'] = 0;
foreach ($data as $k=>$v) {
$where['a.father_id'] = $v['id'];
$where['a.bargain_id'] = $v['bargain_id'];
$data[$k]['fee_list'] = $m_fee->getTaxesAgent('a.id as fee_id,a.fee,b.phone,b.name,a.role,a.scale', $where);
}
return $this->response("200", "request success", $data);
}
/** /**
* 新增开票 * 新增开票
...@@ -2099,8 +2124,15 @@ class Finance extends Basic ...@@ -2099,8 +2124,15 @@ class Finance extends Basic
*/ */
public function delPartialCommission() public function delPartialCommission()
{ {
if (empty($this->params['partial_id'])) if (empty($this->params['partial_id'])) {
return $this->response(101, '参数错误'); return $this->response(101, '参数错误');
}
$agent_id = $this->m_bargain->getFieldValue('agent_id', ['id'=>$this->params['partial_id'],'is_del'=>0]);
if (empty($agent_id)) {
return $this->response(101, '没有该记录');
}
$partial_id = $this->params['partial_id']; $partial_id = $this->params['partial_id'];
$data['status'] = 30; $data['status'] = 30;
...@@ -2111,6 +2143,9 @@ class Finance extends Basic ...@@ -2111,6 +2143,9 @@ class Finance extends Basic
$m_partial->editData(['is_del'=>1], $this->params['partial_id'], 'bargain_id'); $m_partial->editData(['is_del'=>1], $this->params['partial_id'], 'bargain_id');
$this->updatePerformance($this->params['partial_id']); $this->updatePerformance($this->params['partial_id']);
$m_tax = new OTaxes();
$m_tax->updateData(['is_del'=>1],['agent_id'=>$agent_id,'bargain_id'=>$partial_id]);
$result['code'] = 200; $result['code'] = 200;
$result['msg'] = '删除成功'; $result['msg'] = '删除成功';
} else { } else {
......
...@@ -1224,14 +1224,14 @@ class OBargainModel extends Model ...@@ -1224,14 +1224,14 @@ class OBargainModel extends Model
if (empty($bargain_id_arr[0])) { if (empty($bargain_id_arr[0])) {
$data = $this->field('role,agent_id,scale,scale_fee') $data = $this->field('role,agent_id,scale,scale_fee')
->where('id', $bargain_id) ->where('','EXP','id='.$bargain_id.' OR father_id='.$bargain_id)
->whereOr('father_id', $bargain_id) ->where('is_del', 0)
->select(); ->select();
} else { } else {
$data = $this->field('role,agent_id,scale,scale_fee') $data = $this->field('role,agent_id,scale,scale_fee')
->where('id', $bargain_id) ->where('id', $bargain_id)
->where('id', 'not in', implode(',', $bargain_id_arr)) ->where('id', 'not in', implode(',', $bargain_id_arr))
// ->whereOr('father_id', $bargain_id) ->whereOr('is_del', 0)
->select(); ->select();
} }
......
...@@ -199,8 +199,8 @@ class OPartialCommission extends BaseModel ...@@ -199,8 +199,8 @@ class OPartialCommission extends BaseModel
public function getBragainScale(int $bargain_id) public function getBragainScale(int $bargain_id)
{ {
$sql = 'SELECT a.bargain_id,a.scale,b.scale_fee,a.agent_id,a.role,substring_index(group_concat(a.id ORDER BY a.id DESC),",",1) AS id $sql = 'SELECT a.bargain_id,a.scale,b.scale_fee,a.agent_id,a.role,substring_index(group_concat(a.id ORDER BY a.id DESC),",",1) AS id
FROM o_partial_commission a LEFT JOIN o_bargain b on a.bargain_id=b.id WHERE a.bargain_id = ' . $bargain_id . ' FROM o_partial_commission a LEFT JOIN o_bargain b on a.bargain_id=b.id WHERE a.is_del = 0 and (a.bargain_id = ' . $bargain_id . '
and b.id= ' . $bargain_id . ' OR b.father_id=' . $bargain_id . ' GROUP BY role'; and b.id= ' . $bargain_id . ' OR b.father_id=' . $bargain_id . ') GROUP BY role';
return $this->query($sql); return $this->query($sql);
} }
......
...@@ -115,6 +115,41 @@ class OTaxes extends BaseModel ...@@ -115,6 +115,41 @@ class OTaxes extends BaseModel
return $result; return $result;
} }
/**
* 根据成交报告-实收佣金 或 税费开票 查询详情
*
* @param int $bargain_id
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainFeeDetailV2(int $bargain_id, string $field)
{
return $this->field($field)
->where('bargain_id', $bargain_id)
->where('father_id', 0)
->where('is_del', 0)
->select();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTaxesAgent($field, $where) {
return $this->field($field)
->alias('a')
->join('a_agents b', 'a.agent_id = b.id', 'left')
->where($where)
->select();
}
/** /**
* 根据id 查询详情 zw * 根据id 查询详情 zw
* *
...@@ -302,4 +337,8 @@ class OTaxes extends BaseModel ...@@ -302,4 +337,8 @@ class OTaxes extends BaseModel
->where($where) ->where($where)
->sum($field); ->sum($field);
} }
public function updateData($data, $where) {
return $this->where($where)->update($data);
}
} }
\ No newline at end of file
...@@ -250,7 +250,7 @@ Route::group('index', [ ...@@ -250,7 +250,7 @@ Route::group('index', [
'selectReportAll' => ['index/Finance/selectReportAll', ['method' => 'get|post']], //时间轴 'selectReportAll' => ['index/Finance/selectReportAll', ['method' => 'get|post']], //时间轴
'partialCommissionList' => ['index/Finance/partialCommissionList', ['method' => 'get']], //分佣提成明细表 'partialCommissionList' => ['index/Finance/partialCommissionList', ['method' => 'get']], //分佣提成明细表
'addRealIncome' => ['index/Finance/addRealIncome', ['method' => 'POST']], //增加和编辑实收佣金 'addRealIncome' => ['index/Finance/addRealIncome', ['method' => 'POST']], //增加和编辑实收佣金
'getTallAge' => ['index/Finance/getTallAge', ['method' => 'GET']], //开票税费查询 'getTallAge' => ['index/Finance/getTallAgeV2', ['method' => 'GET']], //开票税费查询
'addTallAge' => ['index/Finance/addTallAge', ['method' => 'POST']], //新增和编辑开票税费 'addTallAge' => ['index/Finance/addTallAge', ['method' => 'POST']], //新增和编辑开票税费
'searchBargainAgents' => ['index/Finance/searchBargainAgents', ['method' => 'GET']], //成交报告id获取盘方,客方,反签,独家,合作方 'searchBargainAgents' => ['index/Finance/searchBargainAgents', ['method' => 'GET']], //成交报告id获取盘方,客方,反签,独家,合作方
'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方 'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方
......
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