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;
...@@ -69,28 +74,28 @@ class Finance extends Basic ...@@ -69,28 +74,28 @@ class Finance extends Basic
$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']) {
...@@ -140,7 +145,8 @@ class Finance extends Basic ...@@ -140,7 +145,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 checkReport() { public function checkReport()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -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'] = [];
...@@ -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 = [];
...@@ -239,8 +250,36 @@ class Finance extends Basic ...@@ -239,8 +250,36 @@ class Finance extends Basic
$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'] = [];
...@@ -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'] = [];
...@@ -297,7 +338,7 @@ class Finance extends Basic ...@@ -297,7 +338,7 @@ class Finance extends Basic
} 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'] = [];
...@@ -327,7 +369,7 @@ class Finance extends Basic ...@@ -327,7 +369,7 @@ class Finance extends Basic
$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');
} }
} }
...@@ -364,20 +406,21 @@ class Finance extends Basic ...@@ -364,20 +406,21 @@ 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;
...@@ -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,10 +480,10 @@ class Finance extends Basic ...@@ -436,10 +480,10 @@ 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;
...@@ -460,7 +504,8 @@ class Finance extends Basic ...@@ -460,7 +504,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 refundOrderList() { public function refundOrderList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('refund_order_list'); return view('refund_order_list');
} }
...@@ -485,7 +530,8 @@ class Finance extends Basic ...@@ -485,7 +530,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 partialCommissionList() { public function partialCommissionList()
{
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('commission'); return view('commission');
} }
...@@ -496,32 +542,32 @@ class Finance extends Basic ...@@ -496,32 +542,32 @@ class Finance extends Basic
$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';
...@@ -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; $pageNo = 1;
$pageSize = 250000; $pageSize = 250000;
$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,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,7 +640,8 @@ class Finance extends Basic ...@@ -593,7 +640,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 addRealIncome() { public function addRealIncome()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '新增实收参数错误'); return $this->response(101, '新增实收参数错误');
} }
...@@ -622,7 +670,8 @@ class Finance extends Basic ...@@ -622,7 +670,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 getTallAge() { public function getTallAge()
{
if (empty($this->params['bargain_id'])) { if (empty($this->params['bargain_id'])) {
return $this->response(101, '查询开票税费参数错误!'); return $this->response(101, '查询开票税费参数错误!');
} }
...@@ -633,14 +682,14 @@ class Finance extends Basic ...@@ -633,14 +682,14 @@ class Finance extends Basic
} }
/** /**
* 新增开票 * 新增开票
* *
* @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'])) {
...@@ -683,13 +732,13 @@ class Finance extends Basic ...@@ -683,13 +732,13 @@ class Finance extends Basic
$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');
} }
...@@ -725,7 +774,8 @@ class Finance extends Basic ...@@ -725,7 +774,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 getTaxesById() { public function getTaxesById()
{
if (empty($this->params['taxes_id'])) { if (empty($this->params['taxes_id'])) {
return $this->response(101, '查询开票税费参数错误!'); return $this->response(101, '查询开票税费参数错误!');
} }
...@@ -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');
} }
...@@ -758,34 +809,34 @@ class Finance extends Basic ...@@ -758,34 +809,34 @@ 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();
...@@ -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');
} }
...@@ -821,56 +873,56 @@ class Finance extends Basic ...@@ -821,56 +873,56 @@ class Finance extends Basic
// $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**/
...@@ -881,7 +933,7 @@ class Finance extends Basic ...@@ -881,7 +933,7 @@ 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'];
} }
...@@ -908,7 +960,7 @@ class Finance extends Basic ...@@ -908,7 +960,7 @@ class Finance extends Basic
$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']; //现金奖
...@@ -932,9 +984,9 @@ class Finance extends Basic ...@@ -932,9 +984,9 @@ class Finance extends Basic
$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,7 +997,8 @@ class Finance extends Basic ...@@ -945,7 +997,8 @@ 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, '参数错误');
...@@ -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,7 +1027,8 @@ class Finance extends Basic ...@@ -974,7 +1027,8 @@ 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, '参数错误');
} }
...@@ -993,6 +1047,6 @@ class Finance extends Basic ...@@ -993,6 +1047,6 @@ class Finance extends Basic
$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