Commit b06ce52d authored by hujun's avatar hujun

add

parent 168cbe75
......@@ -17,6 +17,7 @@ use app\model\OfficeOPayLogModel;
use app\model\OfficeOrderModel;
use app\model\OfficeORefundModel;
use app\model\OfficeOReportModel;
use app\model\OfficeOTaxes;
use think\Request;
class OfficePayLog extends Basic
......@@ -1341,4 +1342,56 @@ class OfficePayLog extends Basic
return $this->response($data['code'], $data['msg'], $data['data']);
}
/**
* 成交报告详情-分佣提成
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function commissionList()
{
$data['code'] = 200;
$data['msg'] = "";
$data['data'] = [];
if (empty($this->params['id'])) {
$data['code'] = 101;
$data['msg'] = 'Id is null.';
} else {
$fields = 'a.id,a.role,a.agent_id,a.scale,a.scale_fee,a.father_id';
$where[0] = [ 'EXP', "a.id = {$this->params['id']} or a.father_id = {$this->params['id']}" ];
$where['a.status'] = [ '<>', 30 ];
$data['data'] = $this->m_bargain->getBargainPartial(1, 100, 'a.id desc', $fields, $where, $this->params['id']);
}
return $this->response($data['code'], $data['msg'], $data['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 OfficeOTaxes();
$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);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/5/21
* Time: 10:20
*/
namespace app\model;
class OfficeOTaxes extends BaseModel
{
/**
* 税费开票 查询
*
* @param int $bargain_id
* @param int $type
* @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 getBargainTaxes(int $bargain_id, $field = 'id as fee_id,fee,operation_date')
{
$params["bargain_id"] = $bargain_id;
$params["father_id"] = array("neq",0);
return $this->field($field)
->where($params)
->where('is_del', 0)
->select();
}
/**
* 税费开票 查询数量
*
* @param int $bargain_id
* @param int $type
* @return int|string
*/
public function getBargainFeeTotal(int $bargain_id, int $type = 0)
{
return $this->where('bargain_id', $bargain_id)
->where('type', $type)
->count();
}
/**
* 新增实收佣金 或 税费开票
*
* @param $data
* @param $bargain_id
* @param int $type
* @param int $agent_id
* @param int $father_id
* @param int $total_fee
* @param string $operation_date
* @return array|false
* @throws \Exception
*/
public function addTaxes($data, $bargain_id, int $agent_id, $father_id = 0, $total_fee = 0, $operation_date = '')
{
$insert_data = [];
foreach ($data as $k => $v) {
$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;
$insert_data[$k]['father_id'] = $father_id;
$insert_data[$k]['total_fee'] = $total_fee;
$insert_data[$k]['operation_date'] = $operation_date;
$insert_data[$k]['agent_id'] = $v['agent_id'];
$insert_data[$k]['agent_name'] = $v['agent_name'];
$insert_data[$k]['role'] = $v['role'];
$insert_data[$k]['scale'] = $v['scale'];
}
return $this->saveAll($insert_data);
}
/**
* 根据成交报告-实收佣金 或 税费开票 查询详情
*
* @param int $bargain_id
* @param string $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainFeeDetail(int $bargain_id, string $field)
{
$data = $this->field($field)
->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->where('bargain_id', $bargain_id)
->where('a.father_id', 0)
->where('a.is_del', 0)
->select();
$result = [];
foreach ($data as $k => $v) {
$result[$k] = $v;
if (isset($v['id']) && $v['bargain_id']) {
$result[$k]['fee_list'] = $this->field('a.id as fee_id,a.fee,b.phone,b.name,a.role,a.scale')
->alias('a')
->join('a_agents b', 'a.agent_id = b.id', 'left')
->where('a.father_id', $v['id'])
->where('a.bargain_id', $v['bargain_id'])
->select();
}
}
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
*
* @param int $taxesId
* @param string $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTaxesId(int $taxesId, string $field)
{
$params["father_id"] = $taxesId;
$params["is_del"] = 0;
$data = $this->field($field)
->where($params)
->select();
$m_agent = new AAgents();
$result = [];
foreach ($data as $k => $v) {
if (isset($v['role'])) {
$agent_name = $m_agent->getAgentInfo('id,name,phone', $v['agent_id']);
$result[$k]['id'] = $v['id'];
$result[$k]['agent_id'] = $agent_name['id'];
$result[$k]['name'] = $agent_name['name'];
$result[$k]['phone'] = $agent_name['phone'];
$result[$k]['role'] = $v['role'];
$result[$k]['scale'] = $v['scale'];
$result[$k]['fee'] = $v['fee'];
$result[$k]['total_fee'] = $v['total_fee'];
$result[$k]['operation_date'] = $v['operation_date'];
switch ($v['role']) {
case 1 :
$result[$k]['role_name'] = '盘方';
break;
case 2 :
$result[$k]['role_name'] = '客方';
break;
case 3 :
$result[$k]['role_name'] = '反签';
break;
case 4 :
$result[$k]['role_name'] = '独家';
break;
case 5 :
$result[$k]['role_name'] = '合作方';
break;
}
}
}
return $result;
}
/**
* 税费承担明细表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTaxesList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '')
{
$data = $this->field($field)->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->join('o_order c', 'b.order_id = c.id', 'left')
->join('g_houses d', 'c.house_id = d.id', 'left')
->join('a_agents e', 'a.agent_id = e.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
$m_agent = new AAgents();
foreach ($data as $k => $v) {
if (isset($v['agent_id'])) {
$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'];
}
}
return $data;
}
/**
* 税费承担明细表总数
*
* @param $params
* @return int|string
*/
public function getTaxesListTotal($params)
{
$data = $this->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->join('o_order c', 'b.order_id = c.id', 'left')
->join('g_houses d', 'c.house_id = d.id', 'left')
->join('a_agents e', 'b.agent_id = e.id', 'left')
->where($params)
->count();
return $data;
}
/**
* 税费承担明细表总和
*
* @param $params
* @return int|string
*/
public function getTaxesListTotalFee($params)
{
$data = $this->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->join('o_order c', 'b.order_id = c.id', 'left')
->join('g_houses d', 'c.house_id = d.id', 'left')
->join('a_agents e', 'a.agent_id = e.id', 'left')
->where($params)
->sum("a.fee");
return $data;
}
/**
* 查询分佣或开票
*
* @param string $field
* @param array $where
* @return array
*/
public function getFeeListColumn(string $field, array $where)
{
return $this->where($where)
->column($field);
}
/**
* 修改信息
*
* @param $where
* @param $params
* @return OTaxes
*/
public function updateTaxesById($where, $params)
{
$update_dta = [];
if (isset($params['is_del'])) {
$update_dta['is_del'] = 1;
}
if (isset($where['id_or_father_id'])) {
$where_[] = ['EXP', 'id ='.$where['id_or_father_id']. ' or father_id='.$where['id_or_father_id']];
}
$update_dta["update_time"] = date("Y-m-d H:i:s", time());
$result = $this->where($where_)->update($update_dta);
return $result;
}
/**
* @param $field
* @param $where
* @return float|int
*/
public function sumField($field, $where) {
return $this->where($where)->sum($field);
}
/**
* @param string $field
* @param $where
* @return float|int
*/
public function sumBargainFee($field = 'a.fee', $where) {
return $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($where)
->sum($field);
}
public function updateData($data, $where) {
return $this->where($where)->update($data);
}
}
\ No newline at end of file
......@@ -1050,7 +1050,9 @@ Route::group('office_index', [
'refundPayLog' => ['index/officePayLog/refundPayLog', ['method' => 'POST']],//退款
'delPayLog' => ['index/officePayLog/delPayLog', ['method' => 'POST']],//删除收款
'delAdjustment' => ['index/officePayLog/delAdjustment', ['method' => 'post']],//撤销调整
'bargainInfo' => ['index/officePayLog/bargainInfo', ['method' => 'post']],//成交报告详情
'bargainInfo' => ['index/officePayLog/bargainInfo', ['method' => 'post']],//成交报告详情
'commissionList' => ['index/officePayLog/commissionList', ['method' => 'post']],//成交报告分佣提成
'getTallAge' => ['index/officePayLog/getTallAgeV2', ['method' => 'post']],//成交报告分佣提成
]);
......
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