完成补点设置功能开发

dev
曾超新 5 years ago
parent baeb914545
commit d1c4eda641
  1. 78
      frontend/controllers/FinanceController.php
  2. 96
      frontend/views/finance/budian-list.php

@ -30,6 +30,7 @@ use common\models\GiftType3T;
use common\models\GroupT; use common\models\GroupT;
use common\models\Gz2T; use common\models\Gz2T;
use common\models\GzT; use common\models\GzT;
use common\models\InsurerCompany2T;
use common\models\InsurerCompanyT; use common\models\InsurerCompanyT;
use common\models\InsurerTypeT; use common\models\InsurerTypeT;
use common\models\OrderCaiwuT; use common\models\OrderCaiwuT;
@ -6538,7 +6539,10 @@ class FinanceController extends \frontend\controllers\UserBaseController
} }
public function actionBudianList() { public function actionBudianList() {
return $this->render('budian-list'); $company_items = InsurerCompany2T::find()->all();
return $this->render('budian-list',[
'company_items' => $company_items
]);
} }
public function actionBudianListJson() public function actionBudianListJson()
{ {
@ -6552,29 +6556,18 @@ class FinanceController extends \frontend\controllers\UserBaseController
$company_id = $request->get('company_id'); $company_id = $request->get('company_id');
$insurer_type = $request->get('insurer_type'); $insurer_type = $request->get('insurer_type');
$budian_rate = $request->get('budian_rate');
$offset = $request->get('offset',0); $offset = $request->get('offset',0);
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$query = CaiwuT::find() $query = CaiwuT::find()
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") ->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id")
->orderBy('order_t.print_date DESC'); ->orderBy('order_t.print_date DESC');
if( $insurer_type > 0) { if( $insurer_type > 0) {
$query->andWhere('caiwu_t.insurer_type='.$insurer_type); $query->andWhere('caiwu_t.insurer_type='.$insurer_type);
} }
if( $company_id > 0) { if( $company_id > 0) {
$query->andWhere('order_t.company_id='.$company_id); $query->andWhere('order_t.company2_id='.$company_id);
} }
if($car_no_type == 1){ if($car_no_type == 1){
$query->andWhere('caiwu_t.car_no like "' . '京' . '%"'); $query->andWhere('caiwu_t.car_no like "' . '京' . '%"');
}elseif($car_no_type == 2){ }elseif($car_no_type == 2){
@ -6588,17 +6581,12 @@ class FinanceController extends \frontend\controllers\UserBaseController
$query->andWhere('caiwu_t.total_clear <=' . $end_totalclear); $query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
} }
if ($begin_date != "") { if ($begin_date != "") {
$query->andWhere('order_t.print_date>="' . $begin_date . '"'); $query->andWhere('order_t.print_date>="' . $begin_date . '"');
} }
if ($end_date != "") { if ($end_date != "") {
$query->andWhere('order_t.print_date<="' . $end_date . '"'); $query->andWhere('order_t.print_date<="' . $end_date . '"');
} }
$total1_clear_all = $query->sum('total_clear');
$total_money_all = $query->sum('budian_money');
$total = $query->count(); $total = $query->count();
$query->offset($offset)->limit($limit); $query->offset($offset)->limit($limit);
@ -6609,6 +6597,11 @@ class FinanceController extends \frontend\controllers\UserBaseController
$data['rows'] = []; $data['rows'] = [];
foreach($items as $item) { foreach($items as $item) {
$row = $item->toArray(); $row = $item->toArray();
$row['company_name'] = $item->order->company2->name;
$row['print_date'] = $item->order->print_date;
$row['insurer_type'] = '商业';
if($item->insurer_type != 1)
$row['insurer_type'] = '交强';
$row['user'] = $item->user?$item->user->getShowName():''; $row['user'] = $item->user?$item->user->getShowName():'';
$data['rows'][] = $row; $data['rows'][] = $row;
} }
@ -6625,84 +6618,65 @@ class FinanceController extends \frontend\controllers\UserBaseController
$result['success'] = false; $result['success'] = false;
$result['msg'] = '操作失败'; $result['msg'] = '操作失败';
$begin_date = $request->get('begin_date',date('Y-m-d'));
$begin_date = $request->get('begin_date'); $end_date = $request->get('end_date',date('Y-m-d'));
$end_date = $request->get('end_date');
$user_names = $request->get('user_names');
$begin_totalclear = $request->get('begin_totalclear'); $begin_totalclear = $request->get('begin_totalclear');
$end_totalclear = $request->get('end_totalclear'); $end_totalclear = $request->get('end_totalclear');
$car_no_type = $request->get('car_no_type'); $car_no_type = $request->get('car_no_type');
$company_id = $request->get('company_id'); $company_id = $request->get('company_id');
$insurer_type = $request->get('insurer_type'); $insurer_type = $request->get('insurer_type');
$budian_rate = $request->get('budian_rate'); $budian_rate = $request->get('budian_rate');
$query = CaiwuT::find() $query = CaiwuT::find()
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") ->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id")
// ->where('caiwu_t.insurer_type=1')
->orderBy('order_t.print_date DESC'); ->orderBy('order_t.print_date DESC');
if( $insurer_type > 0) { if( $insurer_type > 0) {
$query = $query->andWhere('caiwu_t.insurer_type='.$insurer_type); $query->andWhere('caiwu_t.insurer_type='.$insurer_type);
} }
if( $company_id > 0) { if( $company_id > 0) {
$query = $query->andWhere('order_t.company_id='.$company_id); $query->andWhere('order_t.company2_id='.$company_id);
} }
if($car_no_type == 1){ if($car_no_type == 1){
$query = $query->andWhere('caiwu_t.car_no like "' . '京' . '%"'); $query->andWhere('caiwu_t.car_no like "' . '京' . '%"');
}elseif($car_no_type == 2){ }elseif($car_no_type == 2){
$query = $query->andWhere('caiwu_t.car_no not like "' . '京' . '%"'); $query->andWhere('caiwu_t.car_no not like "' . '京' . '%"');
} }
if($begin_totalclear != ''){ if($begin_totalclear != ''){
$query = $query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear); $query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear);
} }
if($end_totalclear != ''){ if($end_totalclear != ''){
$query = $query->andWhere('caiwu_t.total_clear <=' . $end_totalclear); $query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
} }
if ($begin_date != "") { if ($begin_date != "") {
$query = $query->andWhere('order_t.print_date>="' . $begin_date . '"'); $query->andWhere('order_t.print_date>="' . $begin_date . '"');
} }
if ($end_date != "") { if ($end_date != "") {
$query = $query->andWhere('order_t.print_date<="' . $end_date . '"'); $query->andWhere('order_t.print_date<="' . $end_date . '"');
} }
$items = $query->all(); $items = $query->all();
$tran = OrderCaiwuT::getDb()->beginTransaction(); $tran = OrderCaiwuT::getDb()->beginTransaction();
try { try {
foreach ($items as $item){ foreach ($items as $item){
// $order_caiwu_info = $item->orderCaiwu;
// $order_info = $item->order;
if($budian_rate != '') { if($budian_rate != '') {
$item->budian_rate = $budian_rate; $item->budian_rate = $budian_rate;
$item->budian_money = $item->total_clear * $budian_rate / 100; $item->budian_money = $item->total_clear * $budian_rate / 100;
} }
$item->save(); if(!$item->save()) {
throw new \Exception(print_r($item->getErrors(), true));
} }
}
$tran->commit();
$result['success'] = true; $result['success'] = true;
$result['msg'] = '保存成功'; $result['msg'] = '保存成功';
$tran->commit();
} catch(\Exception $e) { } catch(\Exception $e) {
$tran->rollBack(); $tran->rollBack();
throw $e; $result['msg'] = $e->getMessage();
} }
return $result; return $result;
} }

@ -16,12 +16,65 @@ use \common\libs\MyLib;
</div> </div>
</div> </div>
<div class="ibox-content"> <div class="ibox-content">
<form role="form" class="form-inline" onsubmit="return search();"> <form role="form" id="searchFrm" class="form-inline" onsubmit="return search();">
<div class="form-group" style="margin-bottom: 8px;"> <div class="form-group" style="margin-bottom: 8px;">
<label for="name">补点比例</label> <label for="name">保险类型</label>
<input type="text" id="name" name="name" class="form-control"> <select name="insurer_type" class="form-control">
<option value="0" >所有类型</option>
<option value="1">商业险</option>
<option value="2">交强险</option>
</select>
</div> </div>
<button type="submit" class="btn btn-primary mb-8">计算</button> <div class="form-group" style="margin-bottom: 8px;">
<label for="name">车牌类型</label>
<select name="car_no_type" class="form-control">
<option value="0" >所有类型</option>
<option value="1">京牌</option>
<option value="2">非京牌</option>
</select>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">保险公司</label>
<select name="company_id" class="form-control">
<option value="0">所有公司</option>
<?php
foreach($company_items as $item) {
echo '<option value="'.$item->id.'"';
if($item->id == $company_id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">出单日期</label>
<div class="input-daterange input-group">
<input type="text" id="begin_date" name="begin_date" class="form-control date" value="<?=date('Y-m-d')?>" autocomplete="off">
<div class="input-group-addon">-</div>
<input type="text" id="end_date" name="end_date" class="form-control date" value="<?=date('Y-m-d')?>" autocomplete="off">
</div>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">商业净保费</label>
<div class="input-group">
<input type="text" id="begin_totalclear" name="begin_totalclear" class="form-control">
<div class="input-group-addon"></div>
<div class="input-group-addon">-</div>
<input type="text" id="end_totalclear" name="end_totalclear" class="form-control">
<div class="input-group-addon"></div>
</div>
</div>
<button type="submit" class="btn btn-primary mb-8">搜索</button>
<br>
<div class="form-group" style="margin-bottom: 8px;">
<label for="name">设置补点比例</label>
<div class="input-group">
<input type="text" id="budian_rate" name="budian_rate" class="form-control">
<div class="input-group-addon">%</div>
</div>
</div>
<button type="button" class="btn btn-primary mb-8 btn-save">保存</button>
</form> </form>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -53,20 +106,26 @@ use \common\libs\MyLib;
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script> <script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script> <script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script> <script>
var o = {};
function refreshList() { function refreshList() {
$('#listTable').bootstrapTable('refresh'); $('#listTable').bootstrapTable('refresh');
} }
function search() { function search() {
o = {};
var params = $("#searchFrm").serializeArray();
$.each(params, function(index) {
o[this['name']] = this['value'];
});
$('#listTable').bootstrapTable('destroy'); $('#listTable').bootstrapTable('destroy');
$('#listTable').bootstrapTable({ $('#listTable').bootstrapTable({
url: "/finance/budian-list-json", url: "/finance/budian-list-json",
pagination: true, pagination: true,
sidePagination: 'server', sidePagination: 'server',
queryParams: function(params) { queryParams: function(params) {
params.type_id = $('#type_id').val(); o['offset'] = params['offset'];
params.name = $('#name').val(); o['limit'] = params['limit'];
return params; return o;
} }
}); });
return false; return false;
@ -74,6 +133,29 @@ use \common\libs\MyLib;
$(function() { $(function() {
search(); search();
$('.input-daterange').datepicker({
keyboardNavigation: false,
forceParse: false,
autoclose: true
});
$(".btn-save").click(function(){
layer.confirm('是否保存当前条件下的所有记录补点比例?', {
btn: ['保存','取消'], //按钮
shade: false //不显示遮罩
}, function(){
var last_url = '/finance/budian-save';
var params = $("#searchFrm").serialize();
$.get(last_url,params,function(obj){
layer.msg(obj.msg);
if(obj.success){
refreshList();
}
},'json');
}, function(){
//
});
});
}); });
</script> </script>
<?php $this->endBlock(); ?> <?php $this->endBlock(); ?>

Loading…
Cancel
Save