完成补点设置功能开发

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\Gz2T;
use common\models\GzT;
use common\models\InsurerCompany2T;
use common\models\InsurerCompanyT;
use common\models\InsurerTypeT;
use common\models\OrderCaiwuT;
@ -6538,7 +6539,10 @@ class FinanceController extends \frontend\controllers\UserBaseController
}
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()
{
@ -6552,29 +6556,18 @@ class FinanceController extends \frontend\controllers\UserBaseController
$company_id = $request->get('company_id');
$insurer_type = $request->get('insurer_type');
$budian_rate = $request->get('budian_rate');
$offset = $request->get('offset',0);
$limit = $request->get('limit', 10);
$query = CaiwuT::find()
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id")
->orderBy('order_t.print_date DESC');
if( $insurer_type > 0) {
$query->andWhere('caiwu_t.insurer_type='.$insurer_type);
}
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){
$query->andWhere('caiwu_t.car_no like "' . '京' . '%"');
}elseif($car_no_type == 2){
@ -6588,17 +6581,12 @@ class FinanceController extends \frontend\controllers\UserBaseController
$query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
}
if ($begin_date != "") {
$query->andWhere('order_t.print_date>="' . $begin_date . '"');
}
if ($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();
$query->offset($offset)->limit($limit);
@ -6609,6 +6597,11 @@ class FinanceController extends \frontend\controllers\UserBaseController
$data['rows'] = [];
foreach($items as $item) {
$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():'';
$data['rows'][] = $row;
}
@ -6625,84 +6618,65 @@ class FinanceController extends \frontend\controllers\UserBaseController
$result['success'] = false;
$result['msg'] = '操作失败';
$begin_date = $request->get('begin_date');
$end_date = $request->get('end_date');
$user_names = $request->get('user_names');
$begin_date = $request->get('begin_date',date('Y-m-d'));
$end_date = $request->get('end_date',date('Y-m-d'));
$begin_totalclear = $request->get('begin_totalclear');
$end_totalclear = $request->get('end_totalclear');
$car_no_type = $request->get('car_no_type');
$company_id = $request->get('company_id');
$insurer_type = $request->get('insurer_type');
$budian_rate = $request->get('budian_rate');
$query = CaiwuT::find()
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id")
// ->where('caiwu_t.insurer_type=1')
->orderBy('order_t.print_date DESC');
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) {
$query = $query->andWhere('order_t.company_id='.$company_id);
$query->andWhere('order_t.company2_id='.$company_id);
}
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){
$query = $query->andWhere('caiwu_t.car_no not like "' . '京' . '%"');
$query->andWhere('caiwu_t.car_no not like "' . '京' . '%"');
}
if($begin_totalclear != ''){
$query = $query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear);
$query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear);
}
if($end_totalclear != ''){
$query = $query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
$query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
}
if ($begin_date != "") {
$query = $query->andWhere('order_t.print_date>="' . $begin_date . '"');
$query->andWhere('order_t.print_date>="' . $begin_date . '"');
}
if ($end_date != "") {
$query = $query->andWhere('order_t.print_date<="' . $end_date . '"');
$query->andWhere('order_t.print_date<="' . $end_date . '"');
}
$items = $query->all();
$tran = OrderCaiwuT::getDb()->beginTransaction();
try {
foreach ($items as $item){
// $order_caiwu_info = $item->orderCaiwu;
// $order_info = $item->order;
if($budian_rate != '') {
$item->budian_rate = $budian_rate;
$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['msg'] = '保存成功';
$tran->commit();
} catch(\Exception $e) {
$tran->rollBack();
throw $e;
$result['msg'] = $e->getMessage();
}
return $result;
}

@ -16,12 +16,65 @@ use \common\libs\MyLib;
</div>
</div>
<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;">
<label for="name">补点比例</label>
<input type="text" id="name" name="name" class="form-control">
<label for="name">保险类型</label>
<select name="insurer_type" class="form-control">
<option value="0" >所有类型</option>
<option value="1">商业险</option>
<option value="2">交强险</option>
</select>
</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>
<div class="row">
<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/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
var o = {};
function refreshList() {
$('#listTable').bootstrapTable('refresh');
}
function search() {
o = {};
var params = $("#searchFrm").serializeArray();
$.each(params, function(index) {
o[this['name']] = this['value'];
});
$('#listTable').bootstrapTable('destroy');
$('#listTable').bootstrapTable({
url: "/finance/budian-list-json",
pagination: true,
sidePagination: 'server',
queryParams: function(params) {
params.type_id = $('#type_id').val();
params.name = $('#name').val();
return params;
o['offset'] = params['offset'];
o['limit'] = params['limit'];
return o;
}
});
return false;
@ -74,6 +133,29 @@ use \common\libs\MyLib;
$(function() {
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>
<?php $this->endBlock(); ?>

Loading…
Cancel
Save