Commit 513c16f3 authored by clone's avatar clone

bug

parent ff92a238
...@@ -32,7 +32,8 @@ class Finance extends Basic ...@@ -32,7 +32,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function reportList() { public function reportList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
$result = ''; $result = '';
...@@ -40,16 +41,20 @@ class Finance extends Basic ...@@ -40,16 +41,20 @@ class Finance extends Basic
switch ($this->params['check_status']) { switch ($this->params['check_status']) {
case 1 : case 1 :
//未结单 //未结单
$result = view('finance/account_statement');break; $result = view('finance/account_statement');
break;
case 4 : case 4 :
//已结单 //已结单
$result = view('finance/statement');break; $result = view('finance/statement');
break;
case 5 : case 5 :
//待撤销 //待撤销
$result = view('finance/wait_backOut');break; $result = view('finance/wait_backOut');
break;
case 6 : case 6 :
//已撤销 //已撤销
$result = view('finance/statement_backOut');break; $result = view('finance/statement_backOut');
break;
} }
return $result; return $result;
...@@ -62,35 +67,35 @@ class Finance extends Basic ...@@ -62,35 +67,35 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$fields = 'a.id,a.create_time,b.user_phone,b.user_name,d.internal_title,d.internal_address,a.commission,a.practical_fee,a.scale_fee,a.order_no,content,house_number'; $fields = 'a.id,a.create_time,b.user_phone,b.user_name,d.internal_title,d.internal_address,a.commission,a.practical_fee,a.scale_fee,a.order_no,content,house_number';
$where['a.father_id'] = 0; $where['a.father_id'] = 0;
$where['c.is_del'] = 0; $where['c.is_del'] = 0;
$where['a.status'] = 10; $where['a.status'] = 10;
$order = 'e.id desc'; $order = 'e.id desc';
if(!empty($this->params['create_time']) && empty($this->params['end_time'])) { if (!empty($this->params['create_time']) && empty($this->params['end_time'])) {
$where['e.create_time'] = ['> time', $this->params['create_time'] . ' 00:00:00']; $where['e.create_time'] = [ '> time', $this->params['create_time'] . ' 00:00:00' ];
} }
if(!empty($this->params['end_time']) && empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && empty($this->params['create_time'])) {
$where['e.create_time'] = ['< time', $this->params['create_time'] . ' 23:59:59']; $where['e.create_time'] = [ '< time', $this->params['create_time'] . ' 23:59:59' ];
} }
if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) {
$where['e.create_time'] = ['between time', [$this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59']]; $where['e.create_time'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ];
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%']; $where['d.internal_address'] = [ 'like', '%' . $this->params['internal_address'] . '%' ];
} }
if (!empty($this->params['user_phone'])) { if (!empty($this->params['user_phone'])) {
$where['b.user_phone'] = ['like', '%'.$this->params['user_phone'].'%']; $where['b.user_phone'] = [ 'like', '%' . $this->params['user_phone'] . '%' ];
} }
if (!empty($this->params['house_number'])) { if (!empty($this->params['house_number'])) {
$where['a.house_number'] = ['like', '%'.$this->params['house_number'].'%']; $where['a.house_number'] = [ 'like', '%' . $this->params['house_number'] . '%' ];
} }
switch ($this->params['check_status']) { switch ($this->params['check_status']) {
...@@ -105,27 +110,27 @@ class Finance extends Basic ...@@ -105,27 +110,27 @@ class Finance extends Basic
case 4 : case 4 :
//成交报告列表-已结单 //成交报告列表-已结单
$where['a.account_statement'] = 1; $where['a.account_statement'] = 1;
$where['a.status'] = 11; $where['a.status'] = 11;
break; break;
/* case 5 : /* case 5 :
//成交报告列表-待撤销 //成交报告列表-待撤销
$where['a.status'] = 20; $where['a.status'] = 20;
break; break;
case 6 : case 6 :
//成交报告列表-已撤销 //成交报告列表-已撤销
$where['a.status'] = 21; $where['a.status'] = 21;
break;*/ break;*/
default : default :
//成交报告列表-第一级审核 //成交报告列表-第一级审核
$where['e.audit_level'] = NULL; $where['e.audit_level'] = NULL;
$order = 'a.id DESC'; $order = 'a.id DESC';
} }
if (!empty($this->params['status'])) { if (!empty($this->params['status'])) {
$where['a.status'] = 20; $where['a.status'] = 20;
} }
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$data['data']['list'] = $bargain->getBargain($pageNo, $pageSize, $order, $fields, $where); $data['data']['list'] = $bargain->getBargain($pageNo, $pageSize, $order, $fields, $where);
$data['data']['total'] = $bargain->getBargainTotal($where); $data['data']['total'] = $bargain->getBargainTotal($where);
$data['data']['step'] = $this->params['check_status']; $data['data']['step'] = $this->params['check_status'];
...@@ -140,23 +145,24 @@ class Finance extends Basic ...@@ -140,23 +145,24 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function checkReport() { public function checkReport()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
$bargain = new OBargainModel(); $bargain = new OBargainModel();
if (empty($this->params['id']) || empty($this->params['source']) || empty($this->params['status'])) { if (empty($this->params['id']) || empty($this->params['source']) || empty($this->params['status'])) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id is null'; $data['msg'] = 'Id is null';
} else { } else {
$params['audit_id'] = $this->userId; $params['audit_id'] = $this->userId;
$params['audit_name'] = $this->userName; $params['audit_name'] = $this->userName;
$params['audit_id'] = $this->userId; $params['audit_id'] = $this->userId;
$params['audit_level'] = $this->params['check_status']; $params['audit_level'] = $this->params['check_status'];
$params['remark'] = $this->params['remark']; $params['remark'] = $this->params['remark'];
$status = $bargain->addCheckBargain($this->params['id'], $params, $this->params['source'], $this->params['status']); $status = $bargain->addCheckBargain($this->params['id'], $params, $this->params['source'], $this->params['status']);
if (empty($status)) { if (empty($status)) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = '审核失败'; $data['msg'] = '审核失败';
...@@ -173,7 +179,8 @@ class Finance extends Basic ...@@ -173,7 +179,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function bargainInfo() { public function bargainInfo()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -182,11 +189,11 @@ class Finance extends Basic ...@@ -182,11 +189,11 @@ class Finance extends Basic
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id is null.'; $data['msg'] = 'Id is null.';
} else { } else {
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$fields = 'a.id,a.create_time,b.user_phone,b.user_name,d.internal_title,d.internal_address,a.is_open,a.order_id,'; $fields = 'a.id,a.create_time,b.user_phone,b.user_name,d.internal_title,d.internal_address,a.is_open,a.order_id,';
$fields .= 'a.trade_type,a.house_number,a.commission,a.content,d.shop_type'; $fields .= 'a.trade_type,a.house_number,a.commission,a.content,d.shop_type';
$where['a.id'] = $this->params['id']; $where['a.id'] = $this->params['id'];
$data['data'] = $bargain->getBargainInfo($fields, $where); $data['data'] = $bargain->getBargainInfo($fields, $where);
} }
return $this->response($data['code'], $data['msg'], $data['data']); return $this->response($data['code'], $data['msg'], $data['data']);
...@@ -198,7 +205,8 @@ class Finance extends Basic ...@@ -198,7 +205,8 @@ class Finance extends Basic
* @return \think\Response * @return \think\Response
* @throws \Exception * @throws \Exception
*/ */
public function editBargainInfo() { public function editBargainInfo()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -206,6 +214,9 @@ class Finance extends Basic ...@@ -206,6 +214,9 @@ class Finance extends Basic
if (empty($this->params['id'])) { if (empty($this->params['id'])) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id is null.'; $data['msg'] = 'Id is null.';
} elseif (count($this->params['practical_fee']) > 5) {
$data['code'] = 101;
$data['msg'] = '实收佣金最多5条记录';
} else { } else {
$update_data = []; $update_data = [];
...@@ -234,13 +245,41 @@ class Finance extends Basic ...@@ -234,13 +245,41 @@ class Finance extends Basic
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
$m_real = new ORealIncome(); $m_real = new ORealIncome();
$data['data'] = $m_bargain->updateBargainById($this->params['id'], $update_data); $data['data'] = $m_bargain->updateBargainById($this->params['id'], $update_data);
if ($data['data'] == 1) { if ($data['data'] == 1) {
//新增实收佣金 array 5 //新增实收佣金 array 5 todo feel_id 大于0 的表示新增 否则修改
$m_real->addRealIncome($this->params['practical_fee'], $this->params['id'], $this->userId); // $m_real->addRealIncome($this->params['practical_fee'], $this->params['id'], $this->userId);
$practical_fee_arr = $this->params["practical_fee"];
$bargain_id = $this->params["id"];
$add_real_arr = $update_real_arr = [];
$i = $j = 0;
foreach ($practical_fee_arr as $item) {
if ($item["feel_id"] > 0) {
$update_real_arr[$i]['id'] = $item['fee_id'];
$update_real_arr[$i]['bargain_id'] = $bargain_id;
$update_real_arr[$i]['operation_id'] = $this->userId;
$update_real_arr[$i]['money'] = $item['fee'];
$update_real_arr[$i]['income_time'] = $item['operation_date'];
$i++;
}else{
$add_real_arr[$j]['bargain_id'] = $bargain_id;
$add_real_arr[$j]['operation_id'] = $this->userId;
$add_real_arr[$j]['money'] = $item['fee'];
$add_real_arr[$j]['income_time'] = $item['operation_date'];
$j++;
}
}
if($i > 0 ){
$m_real->addRealIncome($update_real_arr);
}
if($j > 0){
$m_real->addRealIncome($add_real_arr);
}
} else { } else {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Modify the failure.'; $data['msg'] = 'Modify the failure.';
...@@ -256,7 +295,8 @@ class Finance extends Basic ...@@ -256,7 +295,8 @@ class Finance extends Basic
* @return \think\Response * @return \think\Response
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function addBargain() { public function addBargain()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -265,7 +305,7 @@ class Finance extends Basic ...@@ -265,7 +305,7 @@ class Finance extends Basic
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = '提交信息错误!'; $data['msg'] = '提交信息错误!';
} else { } else {
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$data['data'] = $bargain->addBargainCommission($this->params['id'], $this->userId, $this->params['agent_id'], $data['data'] = $bargain->addBargainCommission($this->params['id'], $this->userId, $this->params['agent_id'],
$this->params['role'], $this->params['scale_fee'], $this->params['scale']); $this->params['role'], $this->params['scale_fee'], $this->params['scale']);
...@@ -286,7 +326,8 @@ class Finance extends Basic ...@@ -286,7 +326,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function commissionList() { public function commissionList()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -295,9 +336,9 @@ class Finance extends Basic ...@@ -295,9 +336,9 @@ class Finance extends Basic
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id is null.'; $data['msg'] = 'Id is null.';
} else { } else {
$m_comm = new OBargainModel(); $m_comm = new OBargainModel();
$fields = 'a.id,a.role,a.agent_id,a.scale,a.scale_fee'; $fields = 'a.id,a.role,a.agent_id,a.scale,a.scale_fee';
$where[0] = ['EXP',"a.id = {$this->params['id']} or a.father_id = {$this->params['id']}"]; $where[0] = [ 'EXP', "a.id = {$this->params['id']} or a.father_id = {$this->params['id']}" ];
$data['data'] = $m_comm->getBargainPartial(1, 100, 'a.id desc', $fields, $where); $data['data'] = $m_comm->getBargainPartial(1, 100, 'a.id desc', $fields, $where);
} }
...@@ -312,7 +353,8 @@ class Finance extends Basic ...@@ -312,7 +353,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function payLogList() { public function payLogList()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -321,13 +363,13 @@ class Finance extends Basic ...@@ -321,13 +363,13 @@ class Finance extends Basic
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id is null.'; $data['msg'] = 'Id is null.';
} else { } else {
$bargain = new OPayLogModel(); $bargain = new OPayLogModel();
$fields = 'create_time,money,type,pay_type,agent_id'; $fields = 'create_time,money,type,pay_type,agent_id';
$where = "report_id = {$this->params['id']}"; $where = "report_id = {$this->params['id']}";
$data['data'] = $bargain->selectPayLogByOrderNo($fields, $where); $data['data'] = $bargain->selectPayLogByOrderNo($fields, $where);
$agent = new AAgents(); $agent = new AAgents();
foreach ($data['data'] as $k => $v) { foreach ($data['data'] as $k => $v) {
$data['data'][$k]['agent_name'] = $agent->getAgentsById($v['agent_id'],'name'); $data['data'][$k]['agent_name'] = $agent->getAgentsById($v['agent_id'], 'name');
} }
} }
...@@ -351,7 +393,7 @@ class Finance extends Basic ...@@ -351,7 +393,7 @@ class Finance extends Basic
} }
$service_ = new OrderLogService(); $service_ = new OrderLogService();
$data = $service_->selectListByOrderNo($params["order_id"]); $data = $service_->selectListByOrderNo($params["order_id"]);
return $this->response("200", "request success", $data); return $this->response("200", "request success", $data);
} }
...@@ -364,26 +406,27 @@ class Finance extends Basic ...@@ -364,26 +406,27 @@ class Finance extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function overRule() { public function overRule()
{
if (empty($this->params['id'])) { if (empty($this->params['id'])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$is = $bargain->ifBargainNumByOrderId(['id' => $this->params['id']]); $is = $bargain->ifBargainNumByOrderId([ 'id' => $this->params['id'] ]);
if ($is < 1) { if ($is < 1) {
return $this->response("101", "没有成交报告信息"); return $this->response("101", "没有成交报告信息");
} }
$bargain->updateBargainById($this->params['id'], ['status'=>12]); $bargain->updateBargainById($this->params['id'], [ 'status' => 12 ]);
$params['audit_id'] = $this->userId; $params['audit_id'] = $this->userId;
$params['audit_name'] = $this->userName; $params['audit_name'] = $this->userName;
$params['audit_id'] = $this->userId; $params['audit_id'] = $this->userId;
$params['audit_level'] = $this->params['check_status']; $params['audit_level'] = $this->params['check_status'];
$params['remark'] = $this->params['remark']; $params['remark'] = $this->params['remark'];
$status = $bargain->addCheckBargain($this->params['id'], $params, 2, 2); $status = $bargain->addCheckBargain($this->params['id'], $params, 2, 2);
if ($status) { if ($status) {
$data['code'] = 200; $data['code'] = 200;
...@@ -404,7 +447,8 @@ class Finance extends Basic ...@@ -404,7 +447,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function refundList() { public function refundList()
{
//显示视图 //显示视图
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
...@@ -418,7 +462,7 @@ class Finance extends Basic ...@@ -418,7 +462,7 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$check_status = [0,1,2,3]; $check_status = [ 0, 1, 2, 3 ];
if (in_array($this->params['check_status'], $check_status)) { if (in_array($this->params['check_status'], $check_status)) {
switch ($this->params['check_status']) { switch ($this->params['check_status']) {
...@@ -436,16 +480,16 @@ class Finance extends Basic ...@@ -436,16 +480,16 @@ class Finance extends Basic
break; break;
default : default :
//退款列表-专员审核 //退款列表-专员审核
$where['e.audit_level'] = ['NULL']; $where['e.audit_level'] = [ 'NULL' ];
} }
} else { } else {
$where['e.audit_level'] = ['NULL']; $where['e.audit_level'] = [ 'NULL' ];
} }
$where['a.status'] = 1; $where['a.status'] = 1;
$refund = new ORefundModel(); $refund = new ORefundModel();
$fields = 'a.id,a.agent_name,a.name,a.bank,a.card_no,a.create_time,a.refund_money,b.report_agent_name,b.user_name,a.order_id'; $fields = 'a.id,a.agent_name,a.name,a.bank,a.card_no,a.create_time,a.refund_money,b.report_agent_name,b.user_name,a.order_id';
$data['data']['list'] = $refund->getCheckRefundList($pageNo, $pageSize, 'a.id DESC', $fields, $where); $data['data']['list'] = $refund->getCheckRefundList($pageNo, $pageSize, 'a.id DESC', $fields, $where);
$data['data']['total'] = $refund->getCheckRefundListTotal($where); $data['data']['total'] = $refund->getCheckRefundListTotal($where);
...@@ -460,16 +504,17 @@ class Finance extends Basic ...@@ -460,16 +504,17 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function refundOrderList() { public function refundOrderList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('refund_order_list'); return view('refund_order_list');
} }
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$where = []; $where = [];
$refund = new ORefundModel(); $refund = new ORefundModel();
$field = 'a.id,a.agent_name,a.name,a.bank,a.card_no,a.create_time,a.refund_money,b.report_agent_name,b.user_name'; $field = 'a.id,a.agent_name,a.name,a.bank,a.card_no,a.create_time,a.refund_money,b.report_agent_name,b.user_name';
$where['status'] = 2; //退款成功 $where['status'] = 2; //退款成功
$data['data']['list'] = $refund->selectRefundByOrderNoPage($pageNo, $pageSize, 'id desc', $field, $where); $data['data']['list'] = $refund->selectRefundByOrderNoPage($pageNo, $pageSize, 'id desc', $field, $where);
...@@ -485,46 +530,47 @@ class Finance extends Basic ...@@ -485,46 +530,47 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function partialCommissionList() { public function partialCommissionList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('commission'); return view('commission');
} }
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$where = []; $where = [];
$where['a.confirm_status'] = 1; $where['a.confirm_status'] = 1;
$where['a.is_del'] = 0; $where['a.is_del'] = 0;
if(!empty($this->params['create_time']) && empty($this->params['end_time'])) { if (!empty($this->params['create_time']) && empty($this->params['end_time'])) {
$where['a.confirm_date'] = ['>= time', $this->params['create_time'] . ' 00:00:00']; $where['a.confirm_date'] = [ '>= time', $this->params['create_time'] . ' 00:00:00' ];
} }
if(!empty($this->params['end_time']) && empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && empty($this->params['create_time'])) {
$where['a.confirm_date'] = ['<= time', $this->params['create_time'] . ' 23:59:59']; $where['a.confirm_date'] = [ '<= time', $this->params['create_time'] . ' 23:59:59' ];
} }
if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) {
$where['a.confirm_date'] = ['between time', [$this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59']]; $where['a.confirm_date'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ];
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%']; $where['d.internal_address'] = [ 'like', '%' . $this->params['internal_address'] . '%' ];
} }
if (!empty($this->params['phone'])) { if (!empty($this->params['phone'])) {
$where['e.phone'] = ['like', '%'.$this->params['phone'].'%']; $where['e.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
} }
if (!empty($this->params['name'])) { if (!empty($this->params['name'])) {
$where['e.name'] = ['like', '%'.$this->params['name'].'%']; $where['e.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
} }
if (!empty($this->params['house_number'])) { if (!empty($this->params['house_number'])) {
$where['b.house_number'] = ['like', '%'.$this->params['house_number'].'%']; $where['b.house_number'] = [ 'like', '%' . $this->params['house_number'] . '%' ];
} }
$field = 'a.id,b.id as bargain_id,a.confirm_date,a.practical_fee,b.scale_fee,d.internal_address,b.agent_id,b.house_number'; $field = 'a.id,b.id as bargain_id,a.confirm_date,a.practical_fee,b.scale_fee,d.internal_address,b.agent_id,b.house_number';
$m_commission = new OPartialCommission(); $m_commission = new OPartialCommission();
$data['data']['list'] = $m_commission->getCommissionBargainList($pageNo, $pageSize, 'a.id desc', $field, $where); $data['data']['list'] = $m_commission->getCommissionBargainList($pageNo, $pageSize, 'a.id desc', $field, $where);
...@@ -539,38 +585,39 @@ class Finance extends Basic ...@@ -539,38 +585,39 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function exportExcel() { public function exportExcel()
$pageNo = 1; {
$pageSize = 250000; $pageNo = 1;
$where = []; $pageSize = 250000;
$where = [];
$where['a.confirm_status'] = 1; $where['a.confirm_status'] = 1;
$where['a.is_del'] = 0; $where['a.is_del'] = 0;
if(!empty($this->params['create_time']) && empty($this->params['end_time'])) { if (!empty($this->params['create_time']) && empty($this->params['end_time'])) {
$where['a.confirm_date'] = ['>= time', $this->params['create_time'] . ' 00:00:00']; $where['a.confirm_date'] = [ '>= time', $this->params['create_time'] . ' 00:00:00' ];
} }
if(!empty($this->params['end_time']) && empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && empty($this->params['create_time'])) {
$where['a.confirm_date'] = ['<= time', $this->params['create_time'] . ' 23:59:59']; $where['a.confirm_date'] = [ '<= time', $this->params['create_time'] . ' 23:59:59' ];
} }
if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) {
$where['a.confirm_date'] = ['between time', [$this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59']]; $where['a.confirm_date'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ];
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%']; $where['d.internal_address'] = [ 'like', '%' . $this->params['internal_address'] . '%' ];
} }
if (!empty($this->params['phone'])) { if (!empty($this->params['phone'])) {
$where['e.phone'] = ['like', '%'.$this->params['phone'].'%']; $where['e.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
} }
if (!empty($this->params['name'])) { if (!empty($this->params['name'])) {
$where['e.name'] = ['like', '%'.$this->params['name'].'%']; $where['e.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
} }
if (!empty($this->params['house_number'])) { if (!empty($this->params['house_number'])) {
$where['b.house_number'] = ['like', '%'.$this->params['house_number'].'%']; $where['b.house_number'] = [ 'like', '%' . $this->params['house_number'] . '%' ];
} }
$field = 'a.id,a.confirm_date,a.practical_fee,b.scale_fee,d.internal_address,b.agent_id,cash,service_charge,charity_fund,real_fee'; $field = 'a.id,a.confirm_date,a.practical_fee,b.scale_fee,d.internal_address,b.agent_id,cash,service_charge,charity_fund,real_fee';
...@@ -580,9 +627,9 @@ class Finance extends Basic ...@@ -580,9 +627,9 @@ class Finance extends Basic
$data = $m_commission->getCommissionBargainColumn($pageNo, $pageSize, 'a.id desc', $field, $where); $data = $m_commission->getCommissionBargainColumn($pageNo, $pageSize, 'a.id desc', $field, $where);
$export = new ExportExcelUntil(); $export = new ExportExcelUntil();
$title = ['收佣日期','所属部门/门店','业务员','应分佣金(元)','实分佣金(元)','手续费(元)','慈善基金(元)','现金奖(元)','实收佣金(元)']; $title = [ '收佣日期', '所属部门/门店', '业务员', '应分佣金(元)', '实分佣金(元)', '手续费(元)', '慈善基金(元)', '现金奖(元)', '实收佣金(元)' ];
$export->exportTable('分佣提成明细',$data, 8, '分佣提成明细表', $title); $export->exportTable('分佣提成明细', $data, 8, '分佣提成明细表', $title);
return ; return;
} }
/** /**
...@@ -593,12 +640,13 @@ class Finance extends Basic ...@@ -593,12 +640,13 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function addRealIncome() { public function addRealIncome()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '新增实收参数错误'); return $this->response(101, '新增实收参数错误');
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
$bargain_data = $m_bargain->getCheckBargain('id,agent_id,role', $this->params['bargain_id']); $bargain_data = $m_bargain->getCheckBargain('id,agent_id,role', $this->params['bargain_id']);
//排除成交报告其它状态 //排除成交报告其它状态
...@@ -606,11 +654,11 @@ class Finance extends Basic ...@@ -606,11 +654,11 @@ class Finance extends Basic
return $this->response(101, '新增失败,成交报告数据异常'); return $this->response(101, '新增失败,成交报告数据异常');
} }
$m_partial = new OPartialCommission(); $m_partial = new OPartialCommission();
$insert_data = $this->params; $insert_data = $this->params;
$insert_data['role'] = $bargain_data['role']; $insert_data['role'] = $bargain_data['role'];
$insert_data['agent_id'] = $bargain_data['agent_id']; $insert_data['agent_id'] = $bargain_data['agent_id'];
$data = $m_partial->addCommission($this->params, $this->userId); $data = $m_partial->addCommission($this->params, $this->userId);
return $this->response("200", "request success", $data); return $this->response("200", "request success", $data);
} }
...@@ -622,25 +670,26 @@ class Finance extends Basic ...@@ -622,25 +670,26 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getTallAge() { public function getTallAge()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '查询开票税费参数错误!'); return $this->response(101, '查询开票税费参数错误!');
} }
$m_fee = new OTaxes(); $m_fee = new OTaxes();
$field = 'a.id,a.total_fee,a.operation_date,a.bargain_id'; $field = 'a.id,a.total_fee,a.operation_date,a.bargain_id';
$data = $m_fee->getBargainFeeDetail($this->params['bargain_id'], $field); $data = $m_fee->getBargainFeeDetail($this->params['bargain_id'], $field);
return $this->response("200", "request success", $data); return $this->response("200", "request success", $data);
} }
/** /**
* 新增开票 * 新增开票
* *
* @return \think\Response * @return \think\Response
* @throws \Exception * @throws \Exception
*/ */
public function addTallAge() { public function addTallAge()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
...@@ -665,7 +714,7 @@ class Finance extends Basic ...@@ -665,7 +714,7 @@ class Finance extends Basic
return $this->response(101, '分佣方角色为空'); return $this->response(101, '分佣方角色为空');
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
$bargain_data = $m_bargain->getCheckBargain('id', $this->params['bargain_id']); $bargain_data = $m_bargain->getCheckBargain('id', $this->params['bargain_id']);
//排除成交报告其它状态 //排除成交报告其它状态
...@@ -673,23 +722,23 @@ class Finance extends Basic ...@@ -673,23 +722,23 @@ class Finance extends Basic
return $this->response(101, '成交报告数据异常!'); return $this->response(101, '成交报告数据异常!');
} }
$bargain_id = $this->params['bargain_id']; $bargain_id = $this->params['bargain_id'];
$operation_date = $this->params['operation_date']; $operation_date = $this->params['operation_date'];
$insert_data['bargain_id'] = $bargain_id; $insert_data['bargain_id'] = $bargain_id;
$insert_data['total_fee'] = $this->params['total_fee']; //开票金额 $insert_data['total_fee'] = $this->params['total_fee']; //开票金额
$insert_data['father_id'] = 0; $insert_data['father_id'] = 0;
$insert_data['operation_id'] = $this->userId; //操作人 $insert_data['operation_id'] = $this->userId; //操作人
$insert_data['operation_date'] = $operation_date; //开票日期 $insert_data['operation_date'] = $operation_date; //开票日期
$m_fee = new OTaxes(); $m_fee = new OTaxes();
$ids= $m_fee->editData($insert_data, $this->params['id']); //开票新增和编辑 $ids = $m_fee->editData($insert_data, $this->params['id']); //开票新增和编辑
echo $ids; echo $ids;
$father_id = $m_fee->id; $father_id = $m_fee->id;
$m_agent = new AAgents(); $m_agent = new AAgents();
foreach ($tax as $k=>$v) { foreach ($tax as $k => $v) {
$tax[$k]['agent_name'] = $m_agent->getAgentsById($v['agent_id'], 'name'); $tax[$k]['agent_name'] = $m_agent->getAgentsById($v['agent_id'], 'name');
} }
...@@ -712,7 +761,7 @@ class Finance extends Basic ...@@ -712,7 +761,7 @@ class Finance extends Basic
return $this->response(101, '请求参数错误!'); return $this->response(101, '请求参数错误!');
} }
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$data = $bargain->getAgentTypeByBargainId($this->params['bargain_id']); $data = $bargain->getAgentTypeByBargainId($this->params['bargain_id']);
return $this->response(200, "", $data); return $this->response(200, "", $data);
} }
...@@ -725,13 +774,14 @@ class Finance extends Basic ...@@ -725,13 +774,14 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getTaxesById() { public function getTaxesById()
{
if (empty($this->params['taxes_id'])) { if (empty($this->params['taxes_id'])) {
return $this->response(101, '查询开票税费参数错误!'); return $this->response(101, '查询开票税费参数错误!');
} }
$m_fee = new OTaxes(); $m_fee = new OTaxes();
$field = 'id,bargain_id,fee,total_fee,father_id,operation_id,operation_date,agent_id,agent_name,role,scale,is_del'; $field = 'id,bargain_id,fee,total_fee,father_id,operation_id,operation_date,agent_id,agent_name,role,scale,is_del';
$data = $m_fee->getTaxesId($this->params['taxes_id'], $field); $data = $m_fee->getTaxesId($this->params['taxes_id'], $field);
return $this->response("200", "request success", $data); return $this->response("200", "request success", $data);
} }
...@@ -743,7 +793,8 @@ class Finance extends Basic ...@@ -743,7 +793,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getTalllAgeList() { public function getTalllAgeList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('tax'); return view('tax');
} }
...@@ -757,38 +808,38 @@ class Finance extends Basic ...@@ -757,38 +808,38 @@ class Finance extends Basic
$fields = 'a.id,a.create_time,e.name,e.phone,a.fee,b.house_number,d.internal_address,b.agent_id'; $fields = 'a.id,a.create_time,e.name,e.phone,a.fee,b.house_number,d.internal_address,b.agent_id';
$where['c.is_del'] = 0; $where['c.is_del'] = 0;
$where['b.status'] = ['in', 10,11]; //10已提交 11审核成功 $where['b.status'] = [ 'in', 10, 11 ]; //10已提交 11审核成功
if(!empty($this->params['create_time']) && empty($this->params['end_time'])) { if (!empty($this->params['create_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['create_time'] . ' 00:00:00']; $where['a.create_time'] = [ '> time', $this->params['create_time'] . ' 00:00:00' ];
} }
if(!empty($this->params['end_time']) && empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && empty($this->params['create_time'])) {
$where['a.create_time'] = ['< time', $this->params['create_time'] . ' 23:59:59']; $where['a.create_time'] = [ '< time', $this->params['create_time'] . ' 23:59:59' ];
} }
if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['create_time'])) {
$where['a.create_time'] = ['between time', [$this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59']]; $where['a.create_time'] = [ 'between time', [ $this->params['create_time'] . ' 00:00:00', $this->params['create_time'] . ' 23:59:59' ] ];
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%']; $where['d.internal_address'] = [ 'like', '%' . $this->params['internal_address'] . '%' ];
} }
if (!empty($this->params['phone'])) { if (!empty($this->params['phone'])) {
$where['e.phone'] = ['like', '%'.$this->params['phone'].'%']; $where['e.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
} }
if (!empty($this->params['name'])) { if (!empty($this->params['name'])) {
$where['e.name'] = ['like', '%'.$this->params['name'].'%']; $where['e.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
} }
if (!empty($this->params['house_number'])) { if (!empty($this->params['house_number'])) {
$where['b.house_number'] = ['like', '%'.$this->params['house_number'].'%']; $where['b.house_number'] = [ 'like', '%' . $this->params['house_number'] . '%' ];
} }
$m_fee = new OTaxes(); $m_fee = new OTaxes();
$data['data']['list'] = $m_fee->getTaxesList($pageNo, $pageSize, 'a.id desc', $fields, $where); $data['data']['list'] = $m_fee->getTaxesList($pageNo, $pageSize, 'a.id desc', $fields, $where);
$data['data']['total'] = $m_fee->getTaxesListTotal($where); $data['data']['total'] = $m_fee->getTaxesListTotal($where);
...@@ -803,7 +854,8 @@ class Finance extends Basic ...@@ -803,7 +854,8 @@ class Finance extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getCommissionTotalList() { public function getCommissionTotalList()
{
if (!$this->request->isAjax() && $this->params['excel'] != 1) { if (!$this->request->isAjax() && $this->params['excel'] != 1) {
return view('commission_total'); return view('commission_total');
} }
...@@ -811,66 +863,66 @@ class Finance extends Basic ...@@ -811,66 +863,66 @@ class Finance extends Basic
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
$whereOr = []; $whereOr = [];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$where['c.is_del'] = 0; //订单状态 $where['c.is_del'] = 0; //订单状态
// $where['a.status'] = ['in', '10,11']; //10已提交 11审核成功 // $where['a.status'] = ['in', '10,11']; //10已提交 11审核成功
// $where['b.father_id'] = ['<>', 0]; //去除税费总佣金 // $where['b.father_id'] = ['<>', 0]; //去除税费总佣金
// $where['c.confirm_status'] = 1; //确认分佣 // $where['c.confirm_status'] = 1; //确认分佣
/**收佣日期 start**/ /**收佣日期 start**/
if(!empty($this->params['commission_start_date']) && empty($this->params['commission_end_date'])) { if (!empty($this->params['commission_start_date']) && empty($this->params['commission_end_date'])) {
$where['b.operatiof.income_time'] = ['> time', $this->params['commission_start_time']]; $where['b.operatiof.income_time'] = [ '> time', $this->params['commission_start_time'] ];
} }
if(!empty($this->params['commission_end_date']) && empty($this->params['commission_start_date'])) { if (!empty($this->params['commission_end_date']) && empty($this->params['commission_start_date'])) {
$where['f.income_time'] = ['< time', $this->params['commission_end_time']]; $where['f.income_time'] = [ '< time', $this->params['commission_end_time'] ];
} }
if (!empty($this->params['commission_start_date']) && !empty($this->params['commission_end_date'])) { 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']]]; $where['f.income_time'] = [ 'between time', [ $this->params['commission_start_date'], $this->params['commission_end_date'] ] ];
} }
/**收佣日期 end**/ /**收佣日期 end**/
/**提交成交报告日期 start**/ /**提交成交报告日期 start**/
if (!empty($this->params['deal_start_date']) && empty($this->params['deal_end_date'])) { 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'; $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'])) { 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'; $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'])) { 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']]; $where['a.create_time'] = [ 'between time', [ $this->params['deal_start_date'] . ' 00:00:00', $this->params['deal_end_date'] . '23:59:59' ] ];
} }
/**提交成交报告日期 end**/ /**提交成交报告日期 end**/
/**开票日期 start**/ /**开票日期 start**/
if (!empty($this->params['operation_start_date']) && empty($this->params['operation_end_date'])) { if (!empty($this->params['operation_start_date']) && empty($this->params['operation_end_date'])) {
$where_fee['b.operation_date'] = ['> time', $this->params['operation_start_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'])) { if (!empty($this->params['operation_end_date']) && empty($this->params['operation_start_date'])) {
$where_fee['b.operation_date'] = ['> time', $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'])) { 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']]]; $where_fee['b.operation_date'] = [ 'between time', [ $this->params['operation_start_date'], $this->params['operation_end_date'] ] ];
} }
/**开票日期 end**/ /**开票日期 end**/
/**经纪人手机号**/ /**经纪人手机号**/
if (!empty($this->params['phone'])) { if (!empty($this->params['phone'])) {
$where['b.phone'] = ['like', '%'.$this->params['phone'].'%']; $where['b.phone'] = [ 'like', '%' . $this->params['phone'] . '%' ];
} }
/**经纪人姓名**/ /**经纪人姓名**/
if (!empty($this->params['name'])) { if (!empty($this->params['name'])) {
$where['d.name'] = ['like', '%'.$this->params['name'].'%']; $where['d.name'] = [ 'like', '%' . $this->params['name'] . '%' ];
} }
/**部门id**/ /**部门id**/
...@@ -880,19 +932,19 @@ class Finance extends Basic ...@@ -880,19 +932,19 @@ class Finance extends Basic
/**门店名**/ /**门店名**/
if (!empty($this->params['store_name'])) { if (!empty($this->params['store_name'])) {
$m_store = new AStore(); $m_store = new AStore();
$store_id = $m_store->findStore('id', ['store_name' => ['like', '%'.$this->params['store_name'].'%']]); $store_id = $m_store->findStore('id', [ 'store_name' => [ 'like', '%' . $this->params['store_name'] . '%' ] ]);
$where['d.store_id'] = $store_id['id']; $where['d.store_id'] = $store_id['id'];
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
if (empty($this->params['excel']) && $this->params['excel'] != 1) { if (empty($this->params['excel']) && $this->params['excel'] != 1) {
$fields = 'f.income_time,a.create_time,a.id,a.agent_id,sum(b.fee) as fee,sum(c.practical_fee) as practical_fee,sum(c.cash) as cash,'; $fields = 'f.income_time,a.create_time,a.id,a.agent_id,sum(b.fee) as fee,sum(c.practical_fee) as practical_fee,sum(c.cash) as cash,';
$fields .= 'sum(c.service_charge) as service_charge,sum(b.fee) as fee,sum(c.real_fee) as real_fee,'; $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'; $fields .= 'd.name,d.phone';
$data['data']['list'] = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr); $data['data']['list'] = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr);
$data['data']['total'] = $m_bargain->getCommissionTotalListTotal($where, $whereOr); $data['data']['total'] = $m_bargain->getCommissionTotalListTotal($where, $whereOr);
} else { } else {
//导出Excel //导出Excel
...@@ -902,39 +954,39 @@ class Finance extends Basic ...@@ -902,39 +954,39 @@ class Finance extends Basic
$fields .= 'd.name,d.phone,sum(c.charity_fund) as charity_fund, sum(should_commission) as should_commission'; $fields .= 'd.name,d.phone,sum(c.charity_fund) as charity_fund, sum(should_commission) as should_commission';
$pageSize = 25000; $pageSize = 25000;
$data = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr); $data = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr);
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$excel_data[$k]['income_time'] = $v['income_time']; //收佣日期 $excel_data[$k]['income_time'] = $v['income_time']; //收佣日期
$excel_data[$k]['create_time'] = $v['create_time']; //成交日期 $excel_data[$k]['create_time'] = $v['create_time']; //成交日期
$excel_data[$k]['district_store'] = $v['district_store']; //所属部门/门店 $excel_data[$k]['district_store'] = $v['district_store']; //所属部门/门店
$excel_data[$k]['name'] = $v['name'] .'-'.$v['phone']; //业务员 $excel_data[$k]['name'] = $v['name'] . '-' . $v['phone']; //业务员
$excel_data[$k]['should_commission'] = $v['should_commission']; //应分佣金 $excel_data[$k]['should_commission'] = $v['should_commission']; //应分佣金
$excel_data[$k]['service_charge'] = $v['service_charge']; //手续费 $excel_data[$k]['service_charge'] = $v['service_charge']; //手续费
$excel_data[$k]['cash'] = $v['cash']; //现金奖 $excel_data[$k]['cash'] = $v['cash']; //现金奖
$excel_data[$k]['charity_fund'] = $v['charity_fund']; //慈善基金 $excel_data[$k]['charity_fund'] = $v['charity_fund']; //慈善基金
$excel_data[$k]['money'] = $v['money']; //实收佣金 $excel_data[$k]['money'] = $v['money']; //实收佣金
$excel_data[$k]['fee'] = $v['fee']; //税费 $excel_data[$k]['fee'] = $v['fee']; //税费
$excel_data[$k]['over_fee'] = $v['real_fee'] - $v['charity_fund']; $excel_data[$k]['over_fee'] = $v['real_fee'] - $v['charity_fund'];
} }
$num = count($excel_data) + 1; $num = count($excel_data) + 1;
$excel_data[$num]['income_time'] = '合计'; //收佣日期 $excel_data[$num]['income_time'] = '合计'; //收佣日期
$excel_data[$num]['create_time'] = ''; //成交日期 $excel_data[$num]['create_time'] = ''; //成交日期
$excel_data[$num]['district_store'] = ''; //所属部门/门店 $excel_data[$num]['district_store'] = ''; //所属部门/门店
$excel_data[$num]['name'] = ''; //业务员 $excel_data[$num]['name'] = ''; //业务员
$excel_data[$num]['should_commission'] = "=SUM(E3:E{$num})"; //应分佣金 $excel_data[$num]['should_commission'] = "=SUM(E3:E{$num})"; //应分佣金
$excel_data[$num]['service_charge'] = "=SUM(F3:F{$num})"; //手续费 $excel_data[$num]['service_charge'] = "=SUM(F3:F{$num})"; //手续费
$excel_data[$num]['cash'] = "=SUM(G3:G{$num})"; //现金奖 $excel_data[$num]['cash'] = "=SUM(G3:G{$num})"; //现金奖
$excel_data[$num]['charity_fund'] = "=SUM(H3:H{$num})"; //慈善基金 $excel_data[$num]['charity_fund'] = "=SUM(H3:H{$num})"; //慈善基金
$excel_data[$num]['money'] = "=SUM(I3:I{$num})"; //实收佣金 $excel_data[$num]['money'] = "=SUM(I3:I{$num})"; //实收佣金
$excel_data[$num]['fee'] = "=SUM(J3:J{$num})"; //税费 $excel_data[$num]['fee'] = "=SUM(J3:J{$num})"; //税费
$excel_data[$num]['over_fee'] = "=SUM(K3:K{$num})"; $excel_data[$num]['over_fee'] = "=SUM(K3:K{$num})";
$export = new ExportExcelUntil(); $export = new ExportExcelUntil();
$title = ['收佣日期/开票日期','成交日期/开票日期','所属部门/门店','业务员','应分佣金(元)','手续费(元)','现金奖(元)','慈善基金(元)','实收佣金(元)','税费(元)','最终实收(元)']; $title = [ '收佣日期/开票日期', '成交日期/开票日期', '所属部门/门店', '业务员', '应分佣金(元)', '手续费(元)', '现金奖(元)', '慈善基金(元)', '实收佣金(元)', '税费(元)', '最终实收(元)' ];
$export->exportTable('分佣提成汇总表',$excel_data, 11, '分佣提成汇总表', $title); $export->exportTable('分佣提成汇总表', $excel_data, 11, '分佣提成汇总表', $title);
return ; return;
} }
return $this->response($data['code'], $data['msg'], $data['data']); return $this->response($data['code'], $data['msg'], $data['data']);
...@@ -945,15 +997,16 @@ class Finance extends Basic ...@@ -945,15 +997,16 @@ class Finance extends Basic
* *
* @return \think\Response * @return \think\Response
*/ */
public function toReportListOne() { public function toReportListOne()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '参数错误'); return $this->response(101, '参数错误');
} }
$m_financial = new OFinancialAudit(); $m_financial = new OFinancialAudit();
$data['status'] = 3; $data['status'] = 3;
$data = $m_financial->editData($data, $this->params['bargain_id'], 'bargain_id'); $data = $m_financial->editData($data, $this->params['bargain_id'], 'bargain_id');
$msg = ''; $msg = '';
if ($data > 0) { if ($data > 0) {
...@@ -962,7 +1015,7 @@ class Finance extends Basic ...@@ -962,7 +1015,7 @@ class Finance extends Basic
$code = 101; $code = 101;
$msg = '操作失败!'; $msg = '操作失败!';
} }
return $this->response( $code, $msg); return $this->response($code, $msg);
} }
/** /**
...@@ -974,25 +1027,26 @@ class Finance extends Basic ...@@ -974,25 +1027,26 @@ class Finance extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function checkOver() { public function checkOver()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '参数错误'); return $this->response(101, '参数错误');
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
$insert_data['audit_id'] = $this->userId; $insert_data['audit_id'] = $this->userId;
$insert_data['audit_name'] = $this->userName; $insert_data['audit_name'] = $this->userName;
$insert_data['audit_level'] = 3; $insert_data['audit_level'] = 3;
$data = $m_bargain->addCheckBargain($this->params['bargain_id'], $insert_data, 1, 10); $data = $m_bargain->addCheckBargain($this->params['bargain_id'], $insert_data, 1, 10);
$code = 200; $code = 200;
$msg = ""; $msg = "";
if (!$data) { if (!$data) {
$code = 101; $code = 101;
$msg = '参数错误结单失败!'; $msg = '参数错误结单失败!';
} }
return $this->response( $code, $msg); return $this->response($code, $msg);
} }
} }
...@@ -14,22 +14,11 @@ class ORealIncome extends BaseModel ...@@ -14,22 +14,11 @@ class ORealIncome extends BaseModel
/** /**
* 增加实收佣金 * 增加实收佣金
* *
* @param $data * @param $insert_data
* @param $bargain_id
* @param $agent_id
* @return array|false * @return array|false
* @throws \Exception * @throws \Exception
*/ */
public function addRealIncome($data, $bargain_id, $agent_id) { public function addRealIncome($insert_data) {
$insert_data = [];
foreach ($data as $k => $v) {
$insert_data[$k]['id'] = $v['fee_id'];
$insert_data[$k]['bargain_id'] = $bargain_id;
$insert_data[$k]['operation_id'] = $agent_id;
$insert_data[$k]['money'] = $v['fee'];
$insert_data[$k]['income_time'] = $v['operation_date'];
}
return $this->saveAll($insert_data); return $this->saveAll($insert_data);
} }
......
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