Commit 494e29e7 authored by hujun's avatar hujun

统计

parent e0f495f2
...@@ -4238,59 +4238,70 @@ class Finance extends Basic ...@@ -4238,59 +4238,70 @@ class Finance extends Basic
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('daily_total'); return view('daily_total');
} }
// $this->params['create_start_time'] = '2019-1-4';
// $this->params['create_end_time'] = '2019-4-1';
//
// $this->params['start_time'] = '2019-1-4';
// $this->params['end_time'] = '2019-4-1';
// $this->params['start_time'] = '2019-4-9';
// $this->params['end_time'] = '2019-4-10'; if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
if (empty($this->params['start_time']) || empty($this->params['end_time'])) { if (!strtotime($this->params['start_time']) || !strtotime($this->params['end_time'])) {
return $this->response(101, '参数错误'); return $this->response(101, '时间格式错误');
}
$where['income_time'] = ['between', [$this->params['start_time'].' 00:00:00', $this->params['end_time']. ' 23:59:59']];
} }
if (!strtotime($this->params['start_time']) || !strtotime($this->params['end_time'])) { if (!empty($this->params['create_start_time']) && !empty($this->params['create_end_time'])) {
return $this->response(101, '时间格式错误'); if (!strtotime($this->params['create_start_time']) || !strtotime($this->params['create_end_time'])) {
return $this->response(101, '时间格式错误');
}
$where['create_time'] = ['between', [$this->params['start_time'].' 00:00:00', $this->params['end_time']. ' 23:59:59']];
} }
$income_start = $this->params['start_time'] . ' 00:00:00'; if (empty($where)) {
$income_end = $this->params['end_time']. ' 23:59:59'; return $this->response(101, '请输入时间条件查询');
}
//付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他 90佣金 91中介费 92 案场费 //付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他 90佣金 91中介费 92 案场费
//调整类型 意向金:1转中介费 2转案场费 3转意向金 保管金:4转中介费 5转案场费 6转保管金 //调整类型 意向金:1转中介费 2转案场费 3转意向金 保管金:4转中介费 5转案场费 6转保管金
//退款类型:0退意向金1意向金转定2退保管金3保管金转定4退中介费5退案场 //退款类型:0退意向金1意向金转定2退保管金3保管金转定4退中介费5退案场
$agent_fee = $this->sumPayLogBargainByType(91, 0, $income_start, $income_end);//未开业中介费 $agent_fee = $this->sumPayLogBargainByType(91, 0, $where);//未开业中介费
$case_fee = $this->sumPayLogBargainByType(92, 0, $income_start, $income_end);//未开业案场费 $case_fee = $this->sumPayLogBargainByType(92, 0, $where);//未开业案场费
$agent_refund_fee = $this->sumPayLogRefundByType(4, 0, 1,$income_start, $income_end);//未开业中介费退款 $agent_refund_fee = $this->sumPayLogRefundByType(4, 0, 1, $where);//未开业中介费退款
$case_refund_fee = $this->sumPayLogRefundByType(5, 0, 1,$income_start, $income_end);//未开业案场费退款 $case_refund_fee = $this->sumPayLogRefundByType(5, 0, 1, $where);//未开业案场费退款
$data['not_open_commission'] = $agent_fee + $case_fee - $agent_refund_fee - $case_refund_fee; //未开业佣金 $data['not_open_commission'] = $agent_fee + $case_fee - $agent_refund_fee - $case_refund_fee; //未开业佣金
$open_agent_fee = $this->sumPayLogBargainByType(91, 1, $income_start, $income_end);//开业中介费 $open_agent_fee = $this->sumPayLogBargainByType(91, 1, $where);//开业中介费
$open_case_fee = $this->sumPayLogBargainByType(92, 1, $income_start, $income_end);//开业案场费 $open_case_fee = $this->sumPayLogBargainByType(92, 1, $where);//开业案场费
$open_agent_refund = $this->sumPayLogRefundByType(4, 1, 1,$income_start, $income_end);//开业中介费退款 $open_agent_refund = $this->sumPayLogRefundByType(4, 1, 1, $where);//开业中介费退款
$open_case_refund = $this->sumPayLogRefundByType(5, 1, 1,$income_start, $income_end);//开业案场费退款 $open_case_refund = $this->sumPayLogRefundByType(5, 1, 1, $where);//开业案场费退款
$data['open_commission'] = $open_agent_fee + $open_case_fee - $open_agent_refund - $open_case_refund; //已开业佣金 $data['open_commission'] = $open_agent_fee + $open_case_fee - $open_agent_refund - $open_case_refund; //已开业佣金
//佣金总计:中介费入账+案场费入账-中介费退款-案场费退款 //佣金总计:中介费入账+案场费入账-中介费退款-案场费退款
$data['total_commission'] = $data['not_open_commission'] + $data['open_commission']; $data['total_commission'] = $data['not_open_commission'] + $data['open_commission'];
$data['intention_recorded'] = $this->sumPayLogPriceByType(10, 0, $income_start, $income_end);//意向金入账 $data['intention_recorded'] = $this->sumPayLogPriceByType(10, 0, $where);//意向金入账
$agent_fee = $this->sumPayLogPriceByType(1, 1, $income_start, $income_end);//意向金转中介费 $agent_fee = $this->sumPayLogPriceByType(1, 1, $where);//意向金转中介费
$case_fee = $this->sumPayLogPriceByType(2, 1, $income_start, $income_end);//意向金转案场费 $case_fee = $this->sumPayLogPriceByType(2, 1, $where);//意向金转案场费
$intention_fee = $this->sumPayLogPriceByType(3, 1, $income_start, $income_end);//意向金转意向金 $intention_fee = $this->sumPayLogPriceByType(3, 1, $where);//意向金转意向金
$custody_fee = $this->sumPayLogPriceByType(7, 1, $income_start, $income_end);//意向金转保管金 $custody_fee = $this->sumPayLogPriceByType(7, 1, $where);//意向金转保管金
//意向金转意向金+意向金转中介费+意向金转案场费 //意向金转意向金+意向金转中介费+意向金转案场费
$data['intention_adjustment'] = $agent_fee + $case_fee + $intention_fee + $custody_fee;//意向金调整 $data['intention_adjustment'] = $agent_fee + $case_fee + $intention_fee + $custody_fee;//意向金调整
$data['intention_refund'] = $this->sumPayLogRefundByType(0, 0, 0, $income_start, $income_end);//意向金退款 $data['intention_refund'] = $this->sumPayLogRefundByType(0, 0, 0, $where);//意向金退款
$data['intention_refund'] += $this->sumPayLogRefundByType(1, 0, 0, $income_start, $income_end);//意向金退款 $data['intention_refund'] += $this->sumPayLogRefundByType(1, 0, 0, $where);//意向金退款
$data['intention_refund'] = round($data['intention_refund'], 2); $data['intention_refund'] = round($data['intention_refund'], 2);
//意向金入账-意向金调整-意向金退款 //意向金入账-意向金调整-意向金退款
$data['total_intention_recorded'] = $data['intention_recorded'] - $data['intention_adjustment'] - $data['intention_refund']; //账上意向金 $data['total_intention_recorded'] = $data['intention_recorded'] - $data['intention_adjustment'] - $data['intention_refund']; //账上意向金
$data['custody_recorded'] = $this->sumPayLogPriceByType(30, 0, $income_start, $income_end);//保管金入账 $data['custody_recorded'] = $this->sumPayLogPriceByType(30, 0, $where);//保管金入账
$agent_fee = $this->sumPayLogPriceByType(4, 1, $income_start, $income_end);//保管金转中介费 $agent_fee = $this->sumPayLogPriceByType(4, 1, $where);//保管金转中介费
$case_fee = $this->sumPayLogPriceByType(5, 1, $income_start, $income_end);//保管金转案场费 $case_fee = $this->sumPayLogPriceByType(5, 1, $where);//保管金转案场费
$custody_fee = $this->sumPayLogPriceByType(6, 1, $income_start, $income_end);//保管金转保管金 $custody_fee = $this->sumPayLogPriceByType(6, 1, $where);//保管金转保管金
//保管金调整:保管金转保管金+保管金转中介费+保管金转案场费 //保管金调整:保管金转保管金+保管金转中介费+保管金转案场费
$data['custody_adjustment'] = $agent_fee + $case_fee + $custody_fee;//保管金调整 $data['custody_adjustment'] = $agent_fee + $case_fee + $custody_fee;//保管金调整
$data['custody_refund'] = $this->sumPayLogRefundByType(3, 0, 0, $income_start, $income_end);//保管金转定 $data['custody_refund'] = $this->sumPayLogRefundByType(3, 0, 0, $where);//保管金转定
$data['custody_refund'] += $this->sumPayLogRefundByType(2, 0, 0, $income_start, $income_end);//保管金转定 $data['custody_refund'] += $this->sumPayLogRefundByType(2, 0, 0, $where);//保管金转定
//意向金入账-意向金调整-意向金退款 //意向金入账-意向金调整-意向金退款
$data['total_custody_recorded'] = $data['custody_recorded'] - $data['custody_adjustment'] - $data['custody_refund']; //账上保管金 $data['total_custody_recorded'] = $data['custody_recorded'] - $data['custody_adjustment'] - $data['custody_refund']; //账上保管金
...@@ -4305,18 +4316,22 @@ class Finance extends Basic ...@@ -4305,18 +4316,22 @@ class Finance extends Basic
* *
* @param $type * @param $type
* @param int $is_open * @param int $is_open
* @param $income_time_start * @param $params
* @param $income_time_end
* @return float|int|string * @return float|int|string
*/ */
private function sumPayLogBargainByType($type, $is_open = 0, $income_time_start, $income_time_end) { private function sumPayLogBargainByType($type, $is_open = 0, $params) {
$m_pay = new OPayLogModel(); $m_pay = new OPayLogModel();
if (isset($params['income_time'])) {
$where['a.income_time'] = $params['income_time'];
}
if (isset($params['create_time'])) {
$where['a.create_time'] = $params['create_time'];
}
$where['b.is_open'] = $is_open; $where['b.is_open'] = $is_open;
$where['a.type'] = $type; $where['a.type'] = $type;
$where['b.status'] = ['<>', '30']; $where['b.status'] = ['<>', '30'];
$where['b.father_id'] = $where['a.is_del'] = 0; $where['b.father_id'] = $where['a.is_del'] = 0;
$where['a.income_time'] = ['between', [$income_time_start, $income_time_end]];
$price = $m_pay->sumBargainPrice('a.money', $where); //未开业中介费 $price = $m_pay->sumBargainPrice('a.money', $where); //未开业中介费
return empty($price) ? '' : $price; return empty($price) ? '' : $price;
} }
...@@ -4327,25 +4342,30 @@ class Finance extends Basic ...@@ -4327,25 +4342,30 @@ class Finance extends Basic
* @param $type * @param $type
* @param $is_open * @param $is_open
* @param $is_bargain * @param $is_bargain
* @param $income_start * @param $params
* @param $income_end
* @return float|int|string * @return float|int|string
*/ */
private function sumPayLogRefundByType($type, $is_open, $is_bargain, $income_start, $income_end) { private function sumPayLogRefundByType($type, $is_open, $is_bargain, $params) {
$m_pay = new ORefundModel(); $m_pay = new ORefundModel();
if (isset($params['income_time'])) {
$where['b.income_time'] = $params['income_time'];
}
if (isset($where['create_time'])) {
$where['b.create_time'] = $params['create_time'];
}
if ($is_bargain) { if ($is_bargain) {
$where['c.is_open'] = $is_open; $where['c.is_open'] = $is_open;
$where['a.type'] = $type; $where['a.type'] = $type;
$where['c.status'] = ['<>', '30']; $where['c.status'] = ['<>', '30'];
$where['c.father_id'] = $where['a.is_del'] = 0; $where['c.father_id'] = $where['a.is_del'] = 0;
$where['b.income_time'] = ['between', [$income_start, $income_end]];
$where['a.status'] = ['<>', 4]; $where['a.status'] = ['<>', 4];
$price = $m_pay->sumBargainPrice('a.refund_money', $where); //未开业中介费 $price = $m_pay->sumBargainPrice('a.refund_money', $where); //未开业中介费
} else { } else {
$where['a.type'] = $type; $where['a.type'] = $type;
$where['a.status'] = ['<>', 4]; $where['a.status'] = ['<>', 4];
$where['b.income_time'] = ['between', [$income_start, $income_end]];
$price = $m_pay->getRefundSumV2('a.refund_money', $where); $price = $m_pay->getRefundSumV2('a.refund_money', $where);
} }
...@@ -4359,21 +4379,29 @@ class Finance extends Basic ...@@ -4359,21 +4379,29 @@ class Finance extends Basic
* @param $income_end * @param $income_end
* @return float|int * @return float|int
*/ */
private function sumPayLogPriceByType(int $type, int $is_adjustment, $income_start, $income_end) { private function sumPayLogPriceByType(int $type, int $is_adjustment, $params) {
if (isset($params['income_time'])) {
$where['b.income_time'] = $params['income_time'];
$where_2['income_time'] = $params['income_time'];
}
if (isset($params['create_time'])) {
$where['b.create_time'] = $params['create_time'];
$where_2['create_time'] = $params['create_time'];
}
if ($is_adjustment) { if ($is_adjustment) {
$m_pay_adjustment = new OPayLogAdjustment(); $m_pay_adjustment = new OPayLogAdjustment();
$where['a.type'] = $type; $where['a.type'] = $type;
$where['b.source'] = 2; $where['b.source'] = 2;
$where['a.is_del'] = 0; $where['a.is_del'] = 0;
$where['b.is_del'] = 0; $where['b.is_del'] = 0;
$where['b.income_time'] = ['between', [$income_start, $income_end]];
$price = $m_pay_adjustment->sumMoney('a.money', $where); $price = $m_pay_adjustment->sumMoney('a.money', $where);
} else { } else {
$m_pay = new OPayLogModel(); $m_pay = new OPayLogModel();
$where['type'] = $type; $where_2['type'] = $type;
$where['is_del'] = 0; $where_2['is_del'] = 0;
$where['income_time'] = ['between', [$income_start, $income_end]]; $price = $m_pay->sumPayLog('money', $where_2);
$price = $m_pay->sumPayLog('money', $where);
} }
return $price; return $price;
} }
......
...@@ -21,11 +21,17 @@ ...@@ -21,11 +21,17 @@
<td colspan="15"> <td colspan="15">
<form id="form_search"> <form id="form_search">
<span class="fore-span ld-Marheight">入账日期:</span> <span class="fore-span ld-Marheight">入账日期:</span>
<input id="comit_time_start" class="form-control btn4 ld-Marheight" type="text" placeholder="开始时间" <input id="comit_time_start" class="form-control btn4 ld-Marheight" type="text" placeholder="开始时间"
onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',maxDate:'#F{ $dp.$D(\'comit_time_end\')||\'%y-%M-%d\'}',readOnly:'readonly' })"> onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',maxDate:'#F{ $dp.$D(\'comit_time_end\')||\'%y-%M-%d\'}',readOnly:'readonly' })">
<span class="fore-span ld-Marheight">-</span> <span class="fore-span ld-Marheight">-</span>
<input id="comit_time_end" class="form-control btn4 ld-Marheight" type="text" placeholder="结束时间" <input id="comit_time_end" class="form-control btn4 ld-Marheight" type="text" placeholder="结束时间"
onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',minDate:'#F{ $dp.$D(\'comit_time_start\' )}',maxDate:'%y-%M-%d',readOnly:'readOnly'})"> onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',minDate:'#F{ $dp.$D(\'comit_time_start\' )}',maxDate:'%y-%M-%d',readOnly:'readOnly'})">
<span class="fore-span ld-Marheight">收款的提交时间(财务日报日期):</span>
<input id="create_start_time" class="form-control btn4 ld-Marheight" type="text" placeholder="开始时间"
onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',maxDate:'#F{ $dp.$D(\'comit_time_end\')||\'%y-%M-%d\'}',readOnly:'readonly' })">
<span class="fore-span ld-Marheight">-</span>
<input id="create_end_time" class="form-control btn4 ld-Marheight" type="text" placeholder="结束时间"
onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',minDate:'#F{ $dp.$D(\'comit_time_start\' )}',maxDate:'%y-%M-%d',readOnly:'readOnly'})">
<span class="btn btn-info btn3 ld-Marheight" id="search" style="float:left">统计</span> <span class="btn btn-info btn3 ld-Marheight" id="search" style="float:left">统计</span>
<span class="btn btn-info btn3 ld-Marheight" id="reset" style="float:left">重置</span> <span class="btn btn-info btn3 ld-Marheight" id="reset" style="float:left">重置</span>
......
...@@ -15,12 +15,11 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', ' ...@@ -15,12 +15,11 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', '
init: function() { init: function() {
//初始化dot //初始化dot
$(document.body).append(template); $(document.body).append(template);
adjustment.getList();
adjustment.event(); adjustment.event();
}, },
event: function() { event: function() {
var that = adjustment; var that = adjustment;
var _doc = $(document); // var _doc = $(document);
//搜索 //搜索
$(document).on('click','#search',function(e){ $(document).on('click','#search',function(e){
...@@ -33,15 +32,31 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', ' ...@@ -33,15 +32,31 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', '
}); });
}, },
getList : function(no){ buildParams: function() {
var start_time = $('#comit_time_start').val();
var end_time = $('#comit_time_end').val();
var create_start_time = $('#create_start_time').val();
var create_end_time = $('#create_end_time').val();
var params_string = "";
if (start_time) {
params_string += "start_time="+start_time+"&";
}
if (end_time) {
params_string += "end_time="+end_time+"&";
}
if (create_start_time) {
params_string += "create_start_time="+create_start_time+"&";
}
if (create_end_time) {
params_string += "create_end_time="+create_end_time+"&";
}
return params_string;
},
getList : function(){
$.ajax({ $.ajax({
url: '/index/getPaylogTotalPrice', url: '/index/getPaylogTotalPrice?' + adjustment.buildParams(),
type: 'GET', type: 'GET',
async: true, async: true,
data: {
"start_time": $('#comit_time_start').val(),
"end_time": $('#comit_time_end').val()
},
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
if(data.code == 200) { if(data.code == 200) {
...@@ -52,15 +67,14 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', ' ...@@ -52,15 +67,14 @@ define(['doT', 'text!temp/adjustment_template_tpl.html', 'css!style/home.css', '
$('.intention_recorded').html(data.data.intention_recorded); $('.intention_recorded').html(data.data.intention_recorded);
$('.intention_adjustment').html(data.data.intention_adjustment); $('.intention_adjustment').html(data.data.intention_adjustment);
$('.intention_refund').html(data.data.intention_refund); $('.intention_refund').html(data.data.intention_refund);
$('.total_custody_recorded').html(data.data.total_custody_recorded); $('.total_custody_recorded').html(data.data.total_custody_recorded);
$('.custody_recorded').html(data.data.custody_recorded); $('.custody_recorded').html(data.data.custody_recorded);
$('.custody_adjustment').html(data.data.custody_adjustment); $('.custody_adjustment').html(data.data.custody_adjustment);
$('.custody_refund').html(data.data.custody_refund); $('.custody_refund').html(data.data.custody_refund);
$('.wait_total_fee').html(data.data.wait_total_fee); $('.wait_total_fee').html(data.data.wait_total_fee);
} else {
} alert(data.msg);
}
} }
}); });
}, },
......
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