完成C库整理工作

dev
曾超新 5 years ago
parent af7e6c87e2
commit 2f48862f07
  1. 147
      frontend/controllers/DatabaseController.php
  2. 2
      frontend/views/database/a-index.php
  3. 92
      frontend/views/database/b-index-search.php
  4. 148
      frontend/views/database/c-index.php

@ -1055,9 +1055,6 @@ class DatabaseController extends BaseController
'invalid_items' => $invalid_items 'invalid_items' => $invalid_items
]); ]);
} }
public function actionCSearch() {
return $this->render('c-index-search');
}
public function actionCIndexJson() public function actionCIndexJson()
{ {
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
@ -1128,11 +1125,15 @@ class DatabaseController extends BaseController
$order_row->engine_no = $c_info->car->engine_no; $order_row->engine_no = $c_info->car->engine_no;
$order_row->car_frame_no = $c_info->car->car_frame_no; $order_row->car_frame_no = $c_info->car->car_frame_no;
$order_row->car_man = $c_info->car->car_man; $order_row->car_man = $c_info->car->car_man;
$order_row->car_man_number = $c_info->car->car_man_number;
$order_row->car_man_phone = $c_info->car->phone;
$order_row->user_id = $user_id; $order_row->user_id = $user_id;
$order_row->status_id = 1; $order_row->status_id = 1;
$order_row->id_man = $c_info->car->car_man; $order_row->id_man = $c_info->car->car_man;
$order_row->id_man_number = $c_info->car->id_number;
$order_row->link_man = $c_info->car->car_man; $order_row->link_man = $c_info->car->car_man;
$order_row->link_phone = $c_info->car->phone; $order_row->link_man_phone = $c_info->car->phone;
$order_row->link_man_number = $c_info->car->id_number;
if(!$order_row->save()) { if(!$order_row->save()) {
throw new \Exception(print_r($order_row->getErrors(),true)); throw new \Exception(print_r($order_row->getErrors(),true));
} }
@ -1212,7 +1213,7 @@ class DatabaseController extends BaseController
foreach($ids as $id) { foreach($ids as $id) {
$c_info = CarCT::findOne(['id'=>$id]); $c_info = CarCT::findOne(['id'=>$id]);
if($c_info->user_id > 0) if($c_info->user_id > 0)
$this->addLog($c_info->id,'从业务员:'.$c_info->user->getShowName().'回收跟踪数据',1); $this->addLog($c_info->id,'从业务员:'.$c_info->user->getShowName().'回收数据',1);
//删除预约 //删除预约
AppointmentT::deleteAll('user_id='.$c_info->user_id.' and car_id='.$c_info->id); AppointmentT::deleteAll('user_id='.$c_info->user_id.' and car_id='.$c_info->id);
@ -1298,25 +1299,37 @@ class DatabaseController extends BaseController
$order_row->engine_no = $c_info->car->engine_no; $order_row->engine_no = $c_info->car->engine_no;
$order_row->car_frame_no = $c_info->car->car_frame_no; $order_row->car_frame_no = $c_info->car->car_frame_no;
$order_row->car_man = $c_info->car->car_man; $order_row->car_man = $c_info->car->car_man;
$order_row->car_man_number = $c_info->car->car_man_number;
$order_row->car_man_phone = $c_info->car->phone;
$order_row->user_id = $c_info->user_id; $order_row->user_id = $c_info->user_id;
$order_row->status_id = 1; $order_row->status_id = 1;
$order_row->id_man = $c_info->car->car_man; $order_row->id_man = $c_info->car->car_man;
$order_row->id_man_number = $c_info->car->id_number;
$order_row->link_man = $c_info->car->car_man; $order_row->link_man = $c_info->car->car_man;
$order_row->link_phone = $c_info->car->phone; $order_row->link_man_phone = $c_info->car->phone;
$order_row->return_status_id = 0; $order_row->link_man_number = $c_info->car->id_number;
$order_row->return_remark = '';
if(!$order_row->save()) { if(!$order_row->save()) {
throw new \Exception(print_r($order_row->getErrors(),true)); throw new \Exception(print_r($order_row->getErrors(),true));
} }
//添加保单操作员
$order_user_info = new OrderUserT();
$order_user_info->user_id = $c_info->user_id;
$order_user_info->order_id = $order_row->id;
$order_user_info->type_id = 1;
$order_user_info->status = 0;
if(!$order_user_info->save()) {
throw new \Exception(print_r($order_user_info->getErrors(),true));
}
//添加预约 //添加预约
AppointmentT::deleteAll('car_id='.$c_info->id); AppointmentT::deleteAll('car_id='.$c_info->id);
$row = new AppointmentT(); $row = new AppointmentT();
$row->car_id = $c_info->id; $row->car_id = $c_info->id;
$row->user_id = $c_info->user_id; $row->user_id = $c_info->user_id;
$row->pdate = date('Y-m-d'); $row->pdate = date('Y-m-d');
$row->ptime = '09:00';
$row->ptype = 0; $row->ptype = 0;
$row->ptime = '09:00';
$row->remark = '首次分配'; $row->remark = '首次分配';
$row->is_first = 1; $row->is_first = 1;
$row->xdate = date('Y-m-d'); $row->xdate = date('Y-m-d');
@ -1331,8 +1344,8 @@ class DatabaseController extends BaseController
$h_row->car_id = $c_info->id; $h_row->car_id = $c_info->id;
$h_row->user_id = $c_info->user_id; $h_row->user_id = $c_info->user_id;
$h_row->pdate = date('Y-m-d'); $h_row->pdate = date('Y-m-d');
$h_row->ptime = '09:00';
$h_row->ptype = 0; $h_row->ptype = 0;
$h_row->ptime = '09:00';
$h_row->remark = '首次分配'; $h_row->remark = '首次分配';
$h_row->xdate = date('Y-m-d'); $h_row->xdate = date('Y-m-d');
$h_row->xtime = '09:00'; $h_row->xtime = '09:00';
@ -1355,6 +1368,75 @@ class DatabaseController extends BaseController
} }
return $result; return $result;
} }
public function actionCReturnAll()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$status = $request->post('status');
$register_begin = $request->post('register_begin');
$register_end = $request->post('register_end');
$insurer1_begin = $request->post('insurer1_begin');
$insurer1_end = $request->post('insurer1_end');
$query = CarCT::find()
->leftJoin('car_t','`car_t`.`id`=`car_c_t`.`id`');
if($register_begin != '') {
$query->andWhere('car_t.register_date>="'.$register_begin.'"');
}
if($register_end != '') {
$query->andWhere('car_t.register_date<="'.$register_end.'"');
}
if($insurer1_begin != '') {
$query->andWhere('car_t.insurer1_date>="'.$insurer1_begin.'"');
}
if($insurer1_end != '') {
$query->andWhere('car_t.insurer1_end<="'.$insurer1_end.'"');
}
$tran = CarT::getDb()->beginTransaction();
try {
foreach($query->each(1000) as $item) {
//删除预约
AppointmentT::deleteAll('car_id='.$item->id);
//删除保单 还没有正本生成的保单可以直接删除,正本生成后,需要退单操作
//删除操作人员
$orders = OrderT::find()
->where('car_id='.$item->id.' and status_id<5')
->all();
foreach($orders as $order_info) {
OrderUserT::deleteAll('order_id='.$order_info->id);
//删除保单
$order_info->delete();
}
$item->user_id = 0;
if(!$item->save()) {
throw new \Exception(print_r($item->getErrors(), true));
}
// FiltrationT
//删除预约拨打
// FiltrationT::deleteAll('car_id='.$c_info->id);
$this->addLog($item->id,'从C库业务员手中批量回收数据',1);
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
$result['msg'] = $e->getMessage();
}
}
return $result;
}
public function actionCD() public function actionCD()
{ {
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
@ -1405,6 +1487,51 @@ class DatabaseController extends BaseController
} }
return $result; return $result;
} }
public function actionCAllD()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$data = $this->getCQuery($request);
$query = $data['query'];
$tran = CarT::getDb()->beginTransaction();
try {
foreach($query->each(100) as $c_info) {
$car_info = $c_info->car;
if($car_info->location == 3) {
$car_info->location = 4;
if(!$car_info->save(false)) {
throw new Exception(print_r($car_info->getFirstErrors(),true));
}
CarCT::deleteAll(['id'=>$car_info->id]);
$d_info = CarDT::findOne(['id'=>$car_info->id]);
if(!$d_info) {
$d_info = new CarDT(false);
$d_info->id = $car_info->id;
$d_info->user_id = 0;
if(!$d_info->save(false)) {
throw new Exception(print_r($d_info->getFirstErrors(),true));
}
}
$this->addLog($car_info->id,'从C库分配到D库',1);
}
}
$result['success'] = true;
$result['msg'] = '操作成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
$result['msg'] = $e->getMessage();
}
}
return $result;
}
//D库列表页 //D库列表页
private function getDQuery($request) private function getDQuery($request)

@ -92,7 +92,7 @@ use \common\libs\MyLib;
</div> </div>
<button type="submit" class="btn btn-primary mb-8">搜索</button> <button type="submit" class="btn btn-primary mb-8">搜索</button>
</div> </div>
<div class="form-group"> <div class="form-group" style="margin-bottom: 8px;">
<button type="button" class="btn btn-primary btn-a-b">勾选A-&gt;B</button> <button type="button" class="btn btn-primary btn-a-b">勾选A-&gt;B</button>
<button type="button" class="btn btn-primary btn-a-c">勾选A-&gt;C</button> <button type="button" class="btn btn-primary btn-a-c">勾选A-&gt;C</button>
<button type="button" class="btn btn-primary btn-a-b-all">批量A-&gt;B</button> <button type="button" class="btn btn-primary btn-a-b-all">批量A-&gt;B</button>

@ -1,92 +0,0 @@
<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<?php $this->endBlock(); ?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-content">
<form role="form" class="form-horizontal" id="searchFrm" onsubmit="return search();">
<div class="form-group">
<label class="control-label col-sm-1">车牌</label>
<div class="col-sm-3">
<input type="text" id="car_no" name="car_no" class="form-control">
</div>
<label class="control-label col-sm-1">车主</label>
<div class="col-sm-3">
<input type="text" id="car_man" name="car_man" class="form-control">
</div>
<label class="control-label col-sm-1">联系电话</label>
<div class="col-sm-3">
<input type="text" id="phone" name="phone" class="form-control">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1">初登日期</label>
<div class="col-sm-3">
<div class="input-daterange input-group" id="datepicker">
<input type="text" class="input-sm form-control" name="register_begin" value="" autocomplete="off" />
<span class="input-group-addon"></span>
<input type="text" class="input-sm form-control" name="register_end" value="" autocomplete="off" />
</div>
</div>
<label class="control-label col-sm-1">保险日期</label>
<div class="col-sm-3">
<div class="input-daterange input-group" id="datepicker">
<input type="text" class="input-sm form-control" name="insurer1_begin" value="" autocomplete="off" />
<span class="input-group-addon"></span>
<input type="text" class="input-sm form-control" name="insurer1_end" value="" autocomplete="off" />
</div>
</div>
<label class="control-label col-sm-1">保险公司</label>
<div class="col-sm-3">
<input type="text" id="company" name="company" class="form-control">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1">状态</label>
<div class="col-sm-3">
<select name="status" class="form-control">
<option value="0">全部</option>
<option value="1">未分配</option>
<option value="2">已分配</option>
</select>
</div>
<label class="control-label col-sm-1">业务员</label>
<div class="col-sm-3">
<input type="text" id="username" name="username" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-sm-3 col-sm-offset-5">
<button type="submit" class="btn btn-primary">搜索</button>
</div>
</div>
</form>
</div>
</div>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript">
function search() {
var o = {};
var params = $("#searchFrm").serializeArray();
$.each(params, function(index) {
o[this['name']] = this['value'];
});
parent.o = o;
parent.refreshList();
layer_close();
}
$(function () {
$('.input-daterange').datepicker({
keyboardNavigation: false,
forceParse: false,
autoclose: true
});
})
</script>
<?php $this->endBlock('footer_js'); ?>

@ -10,18 +10,62 @@ use \common\libs\MyLib;
<div class="ibox-title"> <div class="ibox-title">
<h5>C库</h5> <h5>C库</h5>
<div class="ibox-tools"> <div class="ibox-tools">
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="searchDlg()">
<i class="fa fa-search"></i> 搜索
</a>
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');"> <a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
<i class="fa fa-refresh"></i> 刷新 <i class="fa fa-refresh"></i> 刷新
</a> </a>
</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;">
<label for="car_no">车牌</label>
<input type="text" id="car_no" name="car_no" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="car_man">车主</label>
<input type="text" id="car_man" name="car_man" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="phone">联系电话</label>
<input type="text" id="phone" name="phone" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="datepicker1">出单日期</label>
<div class="input-daterange input-group" id="datepicker1">
<input type="text" class="input-sm form-control" id="print_begin" name="print_begin" value="" autocomplete="off" />
<span class="input-group-addon"></span>
<input type="text" class="input-sm form-control" id="print_end" name="print_end" value="" autocomplete="off" />
</div>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="datepicker2">保险日期</label>
<div class="input-daterange input-group" id="datepicker2">
<input type="text" class="input-sm form-control" id="insurer1_begin" name="insurer1_begin" value="" autocomplete="off" />
<span class="input-group-addon"></span>
<input type="text" class="input-sm form-control" id="insurer1_end" name="insurer1_end" value="" autocomplete="off" />
</div>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="company">保险公司</label>
<input type="text" id="company" name="company" class="form-control">
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="status">状态</label>
<select id="status" name="status" 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="username">业务员</label>
<input type="text" id="username" name="username" class="form-control">
</div>
<button type="submit" class="btn btn-primary mb-8">搜索</button>
<div class="form-group">
<button type="button" class="btn btn-primary btn-c-all-d">批量C-&gt;D</button>
</div>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-primary btn-c-d">勾选C-&gt;D</button>
<select class="form-control" id="user_id" name="user_id"> <select class="form-control" id="user_id" name="user_id">
<option value="0">请选择业务员</option> <option value="0">请选择业务员</option>
<?php foreach($user_items as $item) { <?php foreach($user_items as $item) {
@ -31,14 +75,19 @@ use \common\libs\MyLib;
</select> </select>
<button type="button" class="btn btn-primary btn-assign">勾选分配</button> <button type="button" class="btn btn-primary btn-assign">勾选分配</button>
<button type="button" class="btn btn-primary btn-assign-return">勾选收回</button> <button type="button" class="btn btn-primary btn-assign-return">勾选收回</button>
<button type="button" class="btn btn-primary btn-c-d">勾选移动D库</button>
</div>
<div class="form-group">
<label class="form-control-static">分配给业务员</label> <label class="form-control-static">分配给业务员</label>
<input type="text" name="assign_users" id="assign_users" class="form-control"> <input type="text" name="assign_users" id="assign_users" class="form-control">
<label class="form-control-static">每个业务员分配</label> <label class="form-control-static">每个业务员分配</label>
<input type="text" name="assign_count" id="assign_count" class="form-control"> <input type="text" name="assign_count" id="assign_count" class="form-control">
<label class="form-control-static">条记录</label> <label class="form-control-static">条记录</label>
<button type="button" class="btn btn-primary btn-assign-all">批量分配</button> <button type="button" class="btn btn-primary btn-assign-all">批量分配</button>
<button type="button" class="btn btn-danger btn-clear">清空搜索条件</button> <button type="button" class="btn btn-primary btn-assign-all-return">批量收回</button>
<select class="form-control" id="invalid_id" name="invalid_id"> </div>
<div class="form-group">
<select class="form-control" id="invalid_id" name="invalid_id" style="width:200px;">
<option value="0">请选择无效理由</option> <option value="0">请选择无效理由</option>
<?php foreach($invalid_items as $item) { <?php foreach($invalid_items as $item) {
echo '<option value="'.$item->id.'">'.$item->name.'</option>'; echo '<option value="'.$item->id.'">'.$item->name.'</option>';
@ -78,6 +127,7 @@ use \common\libs\MyLib;
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script> <script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<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 src="/assets/js/plugins/layer/laydate/laydate.js"></script>
<script> <script>
var o = {}; var o = {};
function searchDlg() { function searchDlg() {
@ -90,6 +140,11 @@ use \common\libs\MyLib;
} }
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: "/database/c-index-json", url: "/database/c-index-json",
@ -102,24 +157,28 @@ use \common\libs\MyLib;
return o; return o;
} }
}); });
return false;
} }
$(function() { $(function() {
search(); search();
laydate({
$('.btn-c-d').click(function() { elem:'#print_begin',
var rows = $('#listTable').bootstrapTable('getSelections'); format: 'YYYY-MM-DD'
var params = [];
rows.forEach(function(item,index,array){
params.push(item.id);
}); });
$.post('/database/c-d', {ids:params.join(',')}, function(data) { laydate({
parent.layer.msg(data.msg); elem:'#print_end',
if(data.success == true) { format: 'YYYY-MM-DD'
refreshList();
}
},'json');
}); });
laydate({
elem:'#insurer1_begin',
format: 'YYYY-MM-DD'
});
laydate({
elem:'#insurer1_end',
format: 'YYYY-MM-DD'
});
$('.btn-assign').click(function(){ $('.btn-assign').click(function(){
layer.confirm('是否确认分配操作?', { layer.confirm('是否确认分配操作?', {
btn: ['确认','取消'], //按钮 btn: ['确认','取消'], //按钮
@ -178,9 +237,56 @@ use \common\libs\MyLib;
// //
}); });
}); });
$('.btn-clear').click(function() { $('.btn-assign-all-return').click(function() {
o = {}; layer.confirm('是否确认批量收回操作?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
$.post('/database/c-return-all',o,function(obj){
layer.msg(obj.msg);
if(obj.success) {
search(); search();
}
},'json');
}, function(){
//
});
});
$('.btn-c-d').click(function() {
layer.confirm('是否确认移动?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
var user_id = $('#user_id').val();
var rows = $('#listTable').bootstrapTable('getSelections');
var params = [];
rows.forEach(function(item,index,array){
params.push(item.id);
});
$.post('/database/c-d',{ids:params.join(','),user_id:user_id},function(obj){
layer.msg(obj.msg);
if(obj.success) {
search();
}
},'json');
}, function(){
//
});
});
$('.btn-c-all-d').click(function() {
layer.confirm('是否确认批量移动到D库操作?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
$.post('/database/c-all-d',o,function(obj){
layer.msg(obj.msg);
if(obj.success) {
search();
}
},'json');
}, function(){
//
});
}); });
$('.btn-a-invalid').click(function() { $('.btn-a-invalid').click(function() {
layer.confirm('是否确认移动?', { layer.confirm('是否确认移动?', {

Loading…
Cancel
Save