From d1c4eda641c2e4ae9a73dcf82fe108470148ed44 Mon Sep 17 00:00:00 2001 From: zengchaoxin Date: Sun, 20 Oct 2019 02:24:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A1=A5=E7=82=B9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/controllers/FinanceController.php | 78 ++++++------------ frontend/views/finance/budian-list.php | 96 ++++++++++++++++++++-- 2 files changed, 115 insertions(+), 59 deletions(-) diff --git a/frontend/controllers/FinanceController.php b/frontend/controllers/FinanceController.php index 62cbc47..6279d15 100644 --- a/frontend/controllers/FinanceController.php +++ b/frontend/controllers/FinanceController.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; } diff --git a/frontend/views/finance/budian-list.php b/frontend/views/finance/budian-list.php index 968e572..545eb59 100644 --- a/frontend/views/finance/budian-list.php +++ b/frontend/views/finance/budian-list.php @@ -16,12 +16,65 @@ use \common\libs\MyLib;
-
+
- - + +
- +
+ + +
+
+ + +
+
+ +
+ +
-
+ +
+
+
+ +
+ +
+
-
+ +
+
+
+ +
+
+ +
+ +
%
+
+
+
@@ -53,20 +106,26 @@ use \common\libs\MyLib; endBlock(); ?>