Commit 9451a76f authored by hujun's avatar hujun

成交报告查询经纪人

parent 8c4b7f5e
......@@ -21,6 +21,7 @@ use app\model\OFinancialAudit;
use app\model\OPartialCommission;
use app\model\OPayLogModel;
use app\model\ORefundModel;
use think\Exception;
class Finance extends Basic
{
......@@ -816,23 +817,35 @@ class Finance extends Basic
}
/**
* 成交报告经纪人查询
* 成交报告经纪人查询
* 1盘方,2客方,3反签,4独家,5合作方
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchBargainAgents()
{
if (empty($this->params['bargain_id'])) {
return $this->response(101, '请求参数错误!');
$params = $this->params;
/* $params = array(
"type" => 1,//1盘方,2客方,3反签,4独家,5合作方
"order_id" => 36,
);*/
if (!isset($params["type"]) || !isset($params["order_id"])) {
return $this->response("101", "请求参数错误");
}
$bargain = new OBargainModel();
$data = $bargain->getAgentTypeByBargainId($this->params['bargain_id']);
return $this->response(200, "", $data);
try {
$order_service = new OrderLogService();
$list = $order_service->searchBargainAgents($params["type"], $params["order_id"]);
if (count($list) > 0) {
return $this->response("200", "request success", $list);
} else {
return $this->response("200", "request null");
}
} catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e);
}
}
/**
......@@ -942,70 +955,84 @@ class Finance extends Basic
// $where['b.father_id'] = ['<>', 0]; //去除税费总佣金
// $where['c.confirm_status'] = 1; //确认分佣
/**收佣日期 start**/
if (!empty($this->params['commission_start_date']) && empty($this->params['commission_end_date'])) {
$where['b.operatiof.income_time'] = [ '> time', $this->params['commission_start_time'] ];
}
if (!empty($this->params['commission_end_date']) && empty($this->params['commission_start_date'])) {
$where['f.income_time'] = [ '< time', $this->params['commission_end_time'] ];
}
if (!empty($this->params['commission_start_date']) && !empty($this->params['commission_end_date'])) {
$where['f.income_time'] = [ 'between time', [ $this->params['commission_start_date'], $this->params['commission_end_date'] ] ];
}
/**收佣日期 end**/
$month_start = date('Y-m-01');
$month_end = date('Y-m-t');
/**提交成交报告日期 start**/
if (!empty($this->params['deal_start_date']) && empty($this->params['deal_end_date'])) {
$where['a.create_time'] = [ '> time', $this->params['deal_start_date'] ] . ' 00:00:00';
}
if (!empty($this->params['deal_end_date']) && empty($this->params['deal_start_date'])) {
$where['a.create_time'] = [ '< time', $this->params['deal_end_date'] ] . '23:59:59';
}
if (!empty($this->params['deal_start_date']) && !empty($this->params['deal_end_date'])) {
$where['a.create_time'] = [ 'between time', [ $this->params['deal_start_date'] . ' 00:00:00', $this->params['deal_end_date'] . '23:59:59' ] ];
}
/**提交成交报告日期 end**/
/**开票日期 start**/
if (!empty($this->params['operation_start_date']) && empty($this->params['operation_end_date'])) {
$where_fee['b.operation_date'] = [ '> time', $this->params['operation_start_date'] ];
}
if (!empty($this->params['operation_end_date']) && empty($this->params['operation_start_date'])) {
$where_fee['b.operation_date'] = [ '> time', $this->params['operation_start_date'] ];
/**收佣日期 start**/
if (!empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) {
$where['f.income_time'] = [ '> time', $this->params['income_start_date'] ];
$month_start = $this->params['income_start_date'];
$month_end = "";
}
if (!empty($this->params['operation_start_date']) && !empty($this->params['operation_end_date'])) {
$where_fee['b.operation_date'] = [ 'between time', [ $this->params['operation_start_date'], $this->params['operation_end_date'] ] ];
if (!empty($this->params['income_end_date']) && empty($this->params['income_start_date'])) {
$where['f.income_time'] = [ '< time', $this->params['income_end_date'] ];
$month_end = $this->params['income_end_date'];
$month_start = "";
}
/**开票日期 end**/
/**经纪人手机号**/
if (!empty($this->params['phone'])) {
$where['b.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
if (empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) {
$where['f.income_time'] = [ 'between time', [ $month_start, $month_end]]; //默认收佣时间
}
/**经纪人姓名**/
if (!empty($this->params['name'])) {
$where['d.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
if (!empty($this->params['income_start_date']) && !empty($this->params['income_end_date'])){
$where['f.income_time'] = [ 'between time', [ $this->params['income_start_date'], $this->params['income_end_date']]];
$month_start = $this->params['income_start_date'];
$month_end = $this->params['income_end_date'];
}
/**部门id**/
if (!empty($this->params['district_id'])) {
$where['d.district_id'] = $this->params['district_id'];
}
/**收佣日期 end**/
/**门店名**/
if (!empty($this->params['store_name'])) {
$m_store = new AStore();
$store_id = $m_store->findStore('id', [ 'store_name' => [ 'like', '%' . $this->params['store_name'] . '%' ] ]);
$where['d.store_id'] = $store_id['id'];
}
// /**提交成交报告日期 start**/
// if (!empty($this->params['deal_start_date']) && empty($this->params['deal_end_date'])) {
// $where['a.create_time'] = [ '> time', $this->params['deal_start_date'] ] . ' 00:00:00';
// }
//
// if (!empty($this->params['deal_end_date']) && empty($this->params['deal_start_date'])) {
// $where['a.create_time'] = [ '< time', $this->params['deal_end_date'] ] . '23:59:59';
// }
//
// if (!empty($this->params['deal_start_date']) && !empty($this->params['deal_end_date'])) {
// $where['a.create_time'] = [ 'between time', [ $this->params['deal_start_date'] . ' 00:00:00', $this->params['deal_end_date'] . '23:59:59' ] ];
// }
// /**提交成交报告日期 end**/
//
// /**开票日期 start**/
// if (!empty($this->params['operation_start_date']) && empty($this->params['operation_end_date'])) {
// $where_fee['b.operation_date'] = [ '> time', $this->params['operation_start_date'] ];
// }
//
// if (!empty($this->params['operation_end_date']) && empty($this->params['operation_start_date'])) {
// $where_fee['b.operation_date'] = [ '> time', $this->params['operation_start_date'] ];
// }
//
// if (!empty($this->params['operation_start_date']) && !empty($this->params['operation_end_date'])) {
// $where_fee['b.operation_date'] = [ 'between time', [ $this->params['operation_start_date'], $this->params['operation_end_date'] ] ];
// }
//
// /**开票日期 end**/
//
// /**经纪人手机号**/
// if (!empty($this->params['phone'])) {
// $where['b.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
// }
//
// /**经纪人姓名**/
// if (!empty($this->params['name'])) {
// $where['d.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
// }
//
// /**部门id**/
// if (!empty($this->params['district_id'])) {
// $where['d.district_id'] = $this->params['district_id'];
// }
//
// /**门店名**/
// if (!empty($this->params['store_name'])) {
// $m_store = new AStore();
// $store_id = $m_store->findStore('id', [ 'store_name' => [ 'like', '%' . $this->params['store_name'] . '%' ] ]);
// $where['d.store_id'] = $store_id['id'];
// }
$m_bargain = new OBargainModel();
......@@ -1014,6 +1041,11 @@ class Finance extends Basic
$fields .= 'sum(c.service_charge) as service_charge,sum(b.fee) as fee,sum(c.real_fee) as real_fee,';
$fields .= 'd.name,d.phone';
$data['data']['list'] = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr);
foreach ($data['data']['list'] as $k=>$v) {
$data['data']['list'][$k]['month_income'] = date('Y.m.d', strtotime($month_start)) . '-' . date('Y.m.d', strtotime($month_end));
}
$data['data']['total'] = $m_bargain->getCommissionTotalListTotal($where, $whereOr);
} else {
......@@ -1027,8 +1059,8 @@ class Finance extends Basic
$data = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr);
foreach ($data as $k => $v) {
$excel_data[$k]['income_time'] = $v['income_time']; //收佣日期
$excel_data[$k]['create_time'] = $v['create_time']; //成交日期
// $excel_data[$k]['month_one'] = date('Y-m-d', ($month_one)); //收佣日期
// $excel_data[$k]['month_end'] = date('Y-m-d', strtotime($month_end)); //成交日期
$excel_data[$k]['district_store'] = $v['district_store']; //所属部门/门店
$excel_data[$k]['name'] = $v['name'] . '-' . $v['phone']; //业务员
$excel_data[$k]['should_commission'] = $v['should_commission']; //应分佣金
......
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