diff --git a/common/models/CaiwuT.php b/common/models/CaiwuT.php index b3c93fd..4207219 100644 --- a/common/models/CaiwuT.php +++ b/common/models/CaiwuT.php @@ -125,4 +125,9 @@ class CaiwuT extends \common\models\Base { return $this->hasOne(OrderCaiwuT::className(),['order_id'=>'order_id']); } + + public function getPayOrderUser() + { + return $this->hasMany(PayOrderUserT::className(),['order_id'=>'order_id']); + } } diff --git a/common/models/GiftT.php b/common/models/GiftT.php index 26d42af..3726e92 100644 --- a/common/models/GiftT.php +++ b/common/models/GiftT.php @@ -62,7 +62,7 @@ class GiftT extends \common\models\Base public function getShowType() { - if($this->type_id == 1) return '实名礼品'; + if($this->type_id == 1) return '实物礼品'; if($this->type_id == 2) return '礼券'; return ''; } diff --git a/common/models/GiftUseLogT.php b/common/models/GiftUseLogT.php new file mode 100644 index 0000000..878495e --- /dev/null +++ b/common/models/GiftUseLogT.php @@ -0,0 +1,63 @@ + 50], + [['group_name', 'remark','info'], 'string', 'max' => 100], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'gift_use_id' => 'Gift Use ID', + 'op_man' => 'Op Man', + 'op_time' => 'Op Time', + 'group_name' => 'Group Name', + 'type' => 'Type', + 'remark' => 'Remark', + 'info' => 'Info', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } +} \ No newline at end of file diff --git a/frontend/controllers/CarController.php b/frontend/controllers/CarController.php index c706d63..27af841 100644 --- a/frontend/controllers/CarController.php +++ b/frontend/controllers/CarController.php @@ -1879,15 +1879,8 @@ class CarController extends BaseController $order_info->link_man_number = $link_man_number; $order_info->company_id = $company_id; - if($order_info->status_id != $status_id) { - if($order_info->return_status_id > 0) { - $order_info->status_id = $order_info->return_status_id; - $order_info->return_status_id = 0; - } else { - $order_info->status_id = $status_id; - $order_info->return_status_id = 0; - } - } + $order_info->status_id = $status_id; + $order_info->return_status_id = 0; $order_info->submit_date = date('Y-m-d'); //商业保险日期 $order_info->insurer1_begin_date = $insurer1_begin_date; diff --git a/frontend/controllers/CommonController.php b/frontend/controllers/CommonController.php index 533e403..9f28501 100644 --- a/frontend/controllers/CommonController.php +++ b/frontend/controllers/CommonController.php @@ -385,6 +385,9 @@ class CommonController extends \yii\web\Controller } public function actionCallPhone() { - return $this->render('call-phone'); + $user_info = $this->my; + return $this->render('call-phone',[ + 'user_info' => $user_info + ]); } } diff --git a/frontend/controllers/DatabaseController.php b/frontend/controllers/DatabaseController.php index 010f73f..6ff3012 100644 --- a/frontend/controllers/DatabaseController.php +++ b/frontend/controllers/DatabaseController.php @@ -207,7 +207,7 @@ class DatabaseController extends BaseController } if($has_phone == 1) { - $query->andWhere('phone<>""'); + $query->andWhere('car_man_phone<>""'); } if($no_insurerdate == 1) { $query->andWhere('insurer1_date="" or insurer1_date is null or insurer1_date="0000-00-00"'); @@ -285,7 +285,7 @@ class DatabaseController extends BaseController $car_info = CarT::findOne(['id'=>$id]); if($car_info->location == 1) { $car_info->location = 2; - $car_info->xubao_num = 0; + $car_info->is_xubao = 0; if(!$car_info->save(false)) { throw new Exception(print_r($car_info->getFirstErrors(),true)); } @@ -333,7 +333,7 @@ class DatabaseController extends BaseController foreach($query->each(1000) as $car_info) { if($car_info->location == 1) { $car_info->location = 2; - $car_info->xubao_num = 0; + $car_info->is_xubao = 0; if(!$car_info->save(false)) { throw new Exception(print_r($car_info->getFirstErrors(),true)); } @@ -383,7 +383,7 @@ class DatabaseController extends BaseController $car_info = CarT::findOne(['id'=>$id]); if($car_info->location == 1) { $car_info->location = 3; - $car_info->xubao_num = 1; + $car_info->is_xubao = 1; if(!$car_info->save(false)) { throw new Exception(print_r($car_info->getFirstErrors(),true)); } diff --git a/frontend/controllers/FinanceController.php b/frontend/controllers/FinanceController.php index 00e5bba..fae5ebf 100644 --- a/frontend/controllers/FinanceController.php +++ b/frontend/controllers/FinanceController.php @@ -7781,12 +7781,26 @@ class FinanceController extends \frontend\controllers\UserBaseController ]); } - public function actionReceiptLirun() + public function actionReceiptLirun() { + $company_items = InsurerCompany2T::find()->all(); + $group_items = GroupT::getTree((int)$this->my->group_id); + if($this->my->id == 1) + $group_items = GroupT::getTree(); + + return $this->render('receipt-lirun',[ + 'company_items' => $company_items, + 'group_items' => $group_items + ]); + } + + public function actionReceiptLirunJson() { + Yii::$app->response->format = Response::FORMAT_JSON; set_time_limit(0); ini_set('memory_limit', '3072M'); $request = Yii::$app->request; - $page = $request->get('page', 1); + $offset = $request->get('offset', 0); + $limit = $request->get('limit', 10); $insurer_type = $request->get('insurer_type', 0); $begin_date = $request->get('begin_date',date('Y-m-d')); $end_date = $request->get('end_date',date('Y-m-d')); @@ -7804,7 +7818,7 @@ class FinanceController extends \frontend\controllers\UserBaseController //级别 $group_id = $request->get('group_id'); $group_items = GroupT::getTree((int)$this->my->group_id); - if($this->my->id == 1 || $this->my->username=='6002' || $this->my->username=='7053') + if($this->my->id == 1) $group_items = GroupT::getTree(); $group_ids[] = $group_id; @@ -7815,14 +7829,10 @@ class FinanceController extends \frontend\controllers\UserBaseController $group_ids[] = $group_info->id; } } -// var_dump($group_ids); - - if ($page < 1) $page = 1; $query = CaiwuT::find() ->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") ->where('order_t.status_id>1'); -// ->orderBy('order_t.print_date DESC'); switch ($sort_key) { case 'total': @@ -7850,20 +7860,20 @@ class FinanceController extends \frontend\controllers\UserBaseController break; } - $query = $query->orderBy($sort); + $query->orderBy($sort); 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 ($username != "") { // $userdata = UserT::findOne(['username'=>$username]); $userdata = UserT::find()->where('username="'.$username.'"')->andwhere('is_leave=0')->one(); if($userdata){ - $query = $query->andWhere('caiwu_t.user_id = ' . $userdata->id . ''); + $query->andWhere('caiwu_t.user_id = ' . $userdata->id . ''); } } @@ -7871,7 +7881,7 @@ class FinanceController extends \frontend\controllers\UserBaseController // $userdata = UserT::findOne(['username'=>$username]); $userdata = UserT::find()->where('username="'.$hebaoname.'"')->andwhere('is_leave=0')->one(); if($userdata){ - $query = $query->andWhere('order_t.op1_id = ' . $userdata->id . ''); + $query->andWhere('order_t.op1_id = ' . $userdata->id . ''); } } @@ -7879,57 +7889,49 @@ class FinanceController extends \frontend\controllers\UserBaseController // $userdata = UserT::findOne(['username'=>$username]); $userdata = UserT::find()->where('username="'.$zbname.'"')->andwhere('is_leave=0')->one(); if($userdata){ - $query = $query->andWhere('order_t.op2_id = ' . $userdata->id . ''); + $query->andWhere('order_t.op2_id = ' . $userdata->id . ''); } } if ($car_no != "") { - $query = $query->andWhere('caiwu_t.car_no like "%' . $car_no . '%"'); + $query->andWhere('caiwu_t.car_no like "%' . $car_no . '%"'); } if ($insurer_no != "") { - $query = $query->andWhere('caiwu_t.insurer_no like "' . $insurer_no . '%"'); + $query->andWhere('caiwu_t.insurer_no like "' . $insurer_no . '%"'); } if ($status > 0) { if ($status == 1) { - $query = $query->andWhere('r_date="" or r_date is null'); + $query->andWhere('r_date="" or r_date is null'); } if ($status == 2) { - $query = $query->andWhere('r_date<>"" and total_dis=0'); + $query->andWhere('r_date<>"" and total_dis=0'); } if($status == 3) { - $query = $query->andWhere('r_date<>"" and total_dis<>0'); + $query->andWhere('r_date<>"" and total_dis<>0'); } } 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 . '"'); } if ($r_begin_date != "") { - $query = $query->andWhere('caiwu_t.r_date>="' . $r_begin_date . '"'); + $query->andWhere('caiwu_t.r_date>="' . $r_begin_date . '"'); } if ($r_end_date != "") { - $query = $query->andWhere('caiwu_t.r_date<="' . $r_end_date . '"'); + $query->andWhere('caiwu_t.r_date<="' . $r_end_date . '"'); } //找出$group_id 有多少在职的user_ids // 现在的搜索条件 $userSql = ''; -// if($username != '') { -// $userSql = ' username like "'.$username.'" and '; -// } - //$userSql .= 'is_locked=0 and is_login=1'; $user_items = $this->my->getChildren($userSql); - if($this->my->username == '6002' || $this->my->username == '7053') - $user_items = $this->my->getChildren($userSql,1); $user_items[] = $this->my; $row = array(); foreach($user_items as $user_info) { -// if ($user_info->is_leave == 1) continue; -// var_dump($user_info); if ($group_id > 0) { if (!in_array($user_info->group_id, $group_ids)) { continue; @@ -7940,17 +7942,13 @@ class FinanceController extends \frontend\controllers\UserBaseController } -// var_dump($row); //加上级别筛选 if($group_id > 0){ -// $query = $query->andWhere('order_t.company_id='.$company_id); - $query = $query->andWhere(['in','caiwu_t.user_id',$row]); -// $query = $query->andWhere('caiwu_t.user_id ="' . $group_id . '"'); + $query->andWhere(['in','caiwu_t.user_id',$row]); } $query1 = clone $query; - $item1s = $query1->all(); // echo $query->createCommand()->rawSql; @@ -7965,83 +7963,44 @@ class FinanceController extends \frontend\controllers\UserBaseController $sum_total_dis = $query->sum('total_dis'); - $pagination = new Pagination(['totalCount' => $total, 'pageSize' => 20]); - $pagination->setPage($page - 1); - - $query = $query->offset($pagination->offset)->limit($pagination->limit); + $query = $query->offset($offset)->limit($limit); $items = $query->all(); - $lirun_all = 0; - $gongzi_all = 0; - $liwu_all = 0; - $total1_dis_all = 0; - $bu_dian_all = 0; - $r_bu_dian_all = 0; - foreach($item1s as $item){ - - +// var_dump($items); + $data = []; + $data['total'] = $total; + $data['rows'] = []; + foreach($items as $item) { $order_info = $item->order; - - $total_clear_real = $item->total_clear * $item->total_rate/100; - $total1_dis = $item->insurer_type == 1?($order_info->total1_dis + $order_info->yuangong_money):0; - - $gongzi = $item->insurer_type == 1?$item->getPayOrderUser()->sum('real_pay'):0; + $user_info = $item->user; + $row = $item->toArray(); + $row['username'] = $user_info->username; + $row['company_name'] = $order_info ? $order_info->company2->name : ''; + $row['group_name'] = $user_info->group ? $user_info->group->path : ''; + $row['submit_date'] = $order_info ? $order_info->submit_date : ''; + $row['print_date'] = $order_info ? $order_info->print_date : ''; + if($item->insurer_type == 1) { + $row['insurer_type'] = '商业'; + } else { + $row['insurer_type'] = '交强'; + } + $row['total_real'] = round($item->total * $item->total_rate/100,2); + $row['total_clear_real'] = round($item->total_clear * $item->total_rate/100,2); + $row['bu_dian'] = $item->budian_rate?round($item->budian_rate * $item->total_clear,2) / 100:0; + $row['r_bu_dian'] = $item->insurer_type == 1?round($item->b1_total+$item->b2_total+$item->b3_total,2):0; + $row['total1_dis'] = $item->insurer_type == 1?round($order_info->total1_dis + $order_info->yuangong_money,2):0; $ticket = $item->insurer_type == 1?$order_info->getGiftPrice(1,1):0; $gift = $item->insurer_type == 1?$order_info->getGiftPrice(1,2):0; - $r_bu_dian = $item->insurer_type == 1?($item->b1_total+$item->b2_total+$item->b3_total):0; - $bu_dian = $item->budian_rate?$item->budian_rate * $item->total_clear / 100:0; - $liwu = $ticket + $gift; - - $lirun_all += $total_clear_real + $bu_dian - $total1_dis - $gongzi - $liwu; - - $gongzi_all += $gongzi; - $liwu_all += $liwu; - $total1_dis_all += $total1_dis; - $bu_dian_all += $bu_dian; - $r_bu_dian_all += $r_bu_dian; - + $row['liwu'] = round($ticket + $gift,2); + $row['gongzi'] = $item->insurer_type == 1?round($item->getPayOrderUser()->sum('real_pay'),2):0; + $row['lirun'] = round($row['total_clear_real'] + $row['bu_dian'] - $row['total1_dis'] - $row['gongzi'] - $row['liwu'],2); + $data['rows'][] = $row; } -// var_dump($items); - - $page_info = MyLib::getPageInfo($pagination); - - $company_items = InsurerCompanyT::find()->all(); + return $data; - return $this->render('receipt-lirun', [ - 'items' => $items, - 'username' => $username, - 'hebaoname' => $hebaoname, - 'zbname' => $zbname, - 'page' => $page, - 'car_no' => $car_no, - 'insurer_no' => $insurer_no, - 'status' => $status, - 'begin_date' => $begin_date, - 'end_date' => $end_date, - 'r_begin_date' => $r_begin_date, - 'r_end_date' => $r_end_date, - 'page_info' => $page_info, - 'sort_key' => $sort_key, - 'sort_value' => $sort_value, - 'sum_r_total' => $sum_r_total, - 'sum_total_clear' => $sum_total_clear, - 'sum_total' => $sum_total, - 'sum_total_dis' => $sum_total_dis, - 'company_items' => $company_items, - 'group_id' => $group_id, - 'group_items' => $group_items, - 'company_id' => $company_id, - 'insurer_type' => $insurer_type, - 'lirun_all'=>$lirun_all, - 'gongzi_all'=>$gongzi_all, - 'liwu_all'=>$liwu_all, - 'total1_dis_all'=>$total1_dis_all, - 'bu_dian_all'=>$bu_dian_all, - 'r_bu_dian_all'=>$r_bu_dian_all - ]); } public function actionGongziAllReturnSave() diff --git a/frontend/controllers/GiftController.php b/frontend/controllers/GiftController.php index 9a1145d..2c63b38 100644 --- a/frontend/controllers/GiftController.php +++ b/frontend/controllers/GiftController.php @@ -59,7 +59,7 @@ class GiftController extends \yii\web\Controller $query = GiftT::find() ->where('is_delete=0'); if($type_id > 0) { - $query = $query->andWhere('typeid='.$type_id); + $query = $query->andWhere('type_id='.$type_id); } if($name != '') { $query = $query->andWhere('name like "'.$name.'"'); @@ -75,7 +75,7 @@ class GiftController extends \yii\web\Controller $data['rows'] = []; foreach($items as $item) { $row = $item->toArray(); - $row['type'] = $item->getShowType(); + $row['type'] = $item->showType; $data['rows'][] = $row; } @@ -818,7 +818,7 @@ class GiftController extends \yii\web\Controller ->leftJoin('order_t','order_t.id=gift_ticket_t_use.order_id') ->leftJoin('gift_t','gift_t.id=gift_ticket_t_use.type_id') ->leftJoin('user_t','user_t.id=gift_ticket_t_use.user_id') - ->where('gift_t.type_id=2') + ->where('gift_t.type_id=1') ->orderBy('id DESC'); if($code != '') { $query->andWhere('gift_ticket_t_use.code="'.$code.'"'); @@ -1095,6 +1095,25 @@ class GiftController extends \yii\web\Controller return $data; } + + public function actionGiftUseEdit() + { + $request = Yii::$app->request; + $id = $request->get('id',0); + $back_params = $request->get('back_params'); + if($id > 0) { + $info = GiftTicketTUse::findOne(['id'=>$id]); + } else { + $info = new GiftTicketTUse(); + } + + + + return $this->render('gift-use-edit',[ + 'info' => $info + ]); + } + public function actionTicketUseEdit() { $request = Yii::$app->request; @@ -1114,7 +1133,6 @@ class GiftController extends \yii\web\Controller } public function actionHistoryLogJson() { - Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $id = $request->get('id'); diff --git a/frontend/controllers/InsurerController.php b/frontend/controllers/InsurerController.php index 5cce2a7..5b44fd8 100644 --- a/frontend/controllers/InsurerController.php +++ b/frontend/controllers/InsurerController.php @@ -131,20 +131,6 @@ class InsurerController extends BaseController if($order_info->non_id){ $nonitems=NonAutoInsurance::findOne(['id'=>$order_info->non_id]); } -// dd($order_info->non_id); - //快递 -// dd($car_info->id); -// $ems_items = EmsT::find() -// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id]) -// ->orderBy('id ASC') -// ->all(); -// $ems_items1=(object)array(); -// if(!$ems_items){ -// $ems_items1 = ExpressT::find() -// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id]) -// ->orderBy('id ASC') -// ->all(); -// } //礼品 $gift_free_group_items = GiftGroupT::find() ->where('is_free=1') @@ -177,8 +163,6 @@ class InsurerController extends BaseController return $this->render('info',[ 'order_info'=>$order_info, 'car_info'=>$car_info, -// 'ems_items' => $ems_items, -// 'ems_items1' => $ems_items1, 'money_man' => $money_man, 'money_no' => $money_no, 'money_bank' => $money_bank, @@ -930,6 +914,26 @@ class InsurerController extends BaseController $insurer2_no= trim($insurer2_no); $insurer2_no=str_replace(" ","",$insurer2_no); + if($insurer1_no == $insurer2_no) { + $result['msg'] = '商业保单号和交强保单号不能相同!'; + return $result; + } + $tmp_count = OrderT::find() + ->where('insurer1_no=:insurer1_no or insurer2_no=:insurer1_no', [':insurer1_no'=>$insurer1_no]) + ->andWhere('id<>'.$order_id) + ->count(); + if($tmp_count > 0) { + $result['msg'] = '商业保单号已经存在!'; + return $result; + } + $tmp_count = OrderT::find() + ->where('insurer1_no=:insurer2_no or insurer2_no=:insurer2_no', [':insurer2_no'=>$insurer2_no]) + ->andWhere('id<>'.$order_id) + ->count(); + if($tmp_count > 0) { + $result['msg'] = '交强保单号已经存在!'; + return $result; + } $tran = OrderT::getDb()->beginTransaction(); try { @@ -2371,8 +2375,8 @@ class InsurerController extends BaseController $limit = $request->get('limit', 10); $query = OrderT::find() - ->where('status_id>1') - ->orderBy('car_no desc,submit_date asc'); + ->andWhere('status_id>1') + ->orderBy('status_id desc,car_no desc,submit_date asc'); if($id_man != '') { $query->andWhere(['like','id_man',$id_man]); } @@ -2403,13 +2407,11 @@ class InsurerController extends BaseController if($date3_end != '') { $query->andWhere('insurer1_begin_date<=:end_date or insurer2_begin_date<=:end_date', [':end_date'=>$date3_end]); } - if($status > 0) { - if($status == 1) { - $query->andWhere('status_id>1 and status_id<10'); - } - if($status == 2) { - $query->andWhere('status_id=10'); - } + if($status == 1) { + $query->andWhere('status_id>1 and status_id<10'); + } + if($status == 2) { + $query->andWhere('status_id=10'); } $total = $query->count(); @@ -3485,12 +3487,69 @@ class InsurerController extends BaseController $tran->commit(); } catch (\Exception $e) { +// var_dump($e->getTrace()); $tran->rollBack(); $result['msg'] = $e->getMessage(); } } return $result; } + + /** + * 礼品状态回退 + * @return array + */ + public function actionGiftCancel() + { + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $id = $request->post('order_id'); + $msg= $request->post('return_msg'); + $result = array('success'=>false,'msg'=>'操作成功'); + if(!$request->isPost){ + $result['msg'] = '请求方式错误'; + return $result; + } + if(!$this->my->id == 1){ + $result['msg'] = '无此操作权限'; + return $result; + } + if ($id < 0) { + $result['msg'] = '订单ID无效'; + return $result; + } + if ($msg == '') { + $result['msg'] = '退单理由必须'; + return $result; + } + + $order_info = OrderT::findOne($id); + if (!$order_info) { + $result['msg'] = '订单不存在'; + return $result; + } + + $tran = OrderT::getDb()->beginTransaction(); + try { + // 删除礼品/券库信息 + GiftTicketTUse::deleteAll('order_id=' . $order_info->id); + // 修改订单礼品/券信息 + OrderGiftT::updateAll(['gift_src' => ''], ['order_id' => $order_info->id]); + // 修改订单状态 + $order_info->gift_status = 0; + $order_info->save(); + $this->addLog($order_info->car_id, '回退礼品状态,理由:' . $msg, 1); + $tran->commit(); + } catch (\Exception $e) { + $tran->rollBack(); + $result['msg'] = '订单不存在'; + $result['msg'] = $e->getMessage(); + return $result; + } + $result['success'] = true; + return $result; + } + public function getGift($k, $v, $car_no, $order_info, $order_gift_id) { $result = array(); @@ -3505,7 +3564,6 @@ class InsurerController extends BaseController //礼券 if ($gift_info && $gift_info->type_id == 2) { $pinyin_arr = explode(' ', $gift_info->pinyin_name); -// dd($pinyin_arr); $liquan_str = 'ch'; //获取礼券拼音首字母 foreach ($pinyin_arr as $first) { @@ -3523,13 +3581,12 @@ class InsurerController extends BaseController if ($gift_use) { $liquan_str .= sprintf("%04d", $gift_use->gift_shuzi + 1); $new_gift_use->gift_shuzi = $gift_use->gift_shuzi + 1; - $new_gift_use->code = $liquan_str; } else { $liquan_str .= sprintf("%04d", 1); $new_gift_use->gift_shuzi = 1; - $new_gift_use->code = strtoupper($liquan_str); } + $new_gift_use->code = strtoupper($liquan_str); $new_gift_use->op_id = $this->my->id; $new_gift_use->type_id = $v; //礼券ID $new_gift_use->input_date = date('Y-m-d H:i:s'); @@ -3554,7 +3611,7 @@ class InsurerController extends BaseController if ($shiwu_use) { $new_shiwu->gift_shuzi = $shiwu_use->gift_shuzi + 1; - $new_shiwu->code = sprintf("%04d", $gift_use->gift_shuzi + 1); + $new_shiwu->code = sprintf("%04d", $shiwu_use->gift_shuzi + 1); } else { $new_shiwu->gift_shuzi = 1; $new_shiwu->code = sprintf("%04d", 1); @@ -3584,7 +3641,6 @@ class InsurerController extends BaseController $imgstr = '@frontend/web/upload/images/'.date('Ym'); $imgstr .= '/gift' . $name . '' . $datetime . '.png'; FileHelper::createDirectory(dirname(str_replace('@frontend/web/', '',$imgstr))); - //生成新的图片 if ($gift_info && $gift_info->type_id == 1) { // 实物 \yii\imagine\Image::thumbnail('@frontend/web/images/gift.png', 400, 252) @@ -3603,6 +3659,9 @@ class InsurerController extends BaseController ->save(Yii::getAlias($imgstr)); } elseif ($gift_info && $gift_info->type_id == 2) { + if($gift_info->original_img == '') { + throw new \Exception('礼券文件不存在'); + } $liquanSrc = '@frontend/web' . $gift_info->original_img; \yii\imagine\Image::thumbnail($liquanSrc, 1097, 979) ->save(Yii::getAlias($imgstr), @@ -3619,7 +3678,6 @@ class InsurerController extends BaseController ->save(Yii::getAlias($imgstr)); } - $gift_src = str_replace('@frontend/web', '', $imgstr); //保存order_gift_t表里png文件地址 @@ -3630,4 +3688,89 @@ class InsurerController extends BaseController } } -} + /** + * 退单操作(超管权限任意状态退单) + * @return array + * @throws \Exception + */ + public function actionSupperReturn() + { + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $result = array(); + $result['success'] = false; + $result['msg'] = '操作失败'; + if($request->isPost) { + $order_id = $request->post('order_id',0); + $return_remark = $request->post('return_remark'); + if ($order_id < 0) { + $result['msg'] = '订单ID无效'; + return $result; + } + if($return_remark == ''){ + $result['msg'] = '请填写退单理由!'; + return $result; + } + + $order_info = OrderT::findOne(['id'=>$order_id]); + if(empty($order_info)) { + $result['msg'] = '保单信息不存在!'; + return $result; + } + + // 订单信息更新 + $order_info->return_status_id = $order_info->status_id; + $order_info->lock_id = 0; + $order_info->status_id = 1; + $order_info->return_remark = $return_remark; + $order_info->return_time = time(); + $order_info->gift_status = 0; + // 车辆信息处理 + if ($order_info->car->op2_id > 0) { //续保 + $order_info->car->location = 4; + }else { + $order_info->car->location = 2; + $order_info->car->is_xubao = 0; + } + $order_info->car->user_id = $order_info->user_id; + + $tran = OrderT::getDb()->beginTransaction(); + try { + // 财务处理 + CaiwuT::deleteAll(['order_id'=>$order_info->id]); + OrderCaiwuT::deleteAll(['order_id'=>$order_info->id]); + OrderUserT::deleteAll(['order_id'=>$order_info->id]); + + // 车辆信息 + CarCT::deleteAll(['id' => $order_info->car_id]); + // 检测车辆是否移库 + if($order_info->car->op2_id > 0 && $order_info->car->location != 4){ + $car_db_info = new CarDT(false); + $car_db_info->id = $order_info->car_id; + $car_db_info->user_id = $order_info->user_id; + $order_info->car->save(); + } + if(!$order_info->car->op2_id && $order_info->car->location != 2){ + $car_db_info = new CarBT(false); + $car_db_info->id = $order_info->car_id; + $car_db_info->user_id = $order_info->user_id; + $order_info->car->save(); + } + + // 礼品状态回退 + GiftTicketTUse::deleteAll('order_id=' . $order_info->id); + OrderGiftT::updateAll(['gift_src' => ''], ['order_id' => $order_info->id]); + + $this->addLog($order_info->car_id,'超管退单,理由是:'.$return_remark,1); + $order_info->save(); + $tran->commit(); + $result['success'] = true; + $result['msg'] = '操作成功'; + } catch (\Exception $e) { + $tran->rollBack(); + $result['msg'] = '操作失败,' . $e->getMessage(); + } + } + return $result; + } +} \ No newline at end of file diff --git a/frontend/controllers/MarketingStrategyController.php b/frontend/controllers/MarketingStrategyController.php index ce49943..f675186 100644 --- a/frontend/controllers/MarketingStrategyController.php +++ b/frontend/controllers/MarketingStrategyController.php @@ -492,7 +492,7 @@ class MarketingStrategyController extends UserBaseController $total1_clear = $request->post('total1_clear', 0); $car_no = $request->post('car_no'); $car_use_id = $request->post('car_use_id', 0); - $company2_id = $request->post('company2_id', 0); + $company_id = $request->post('company_id', 0); $car_info = CarT::findOne($car_id); if(!$car_info) { @@ -521,48 +521,61 @@ class MarketingStrategyController extends UserBaseController ->andWhere(['<=','baofei', $total1_clear]) ->all(); $ids = []; + $flags = []; foreach($items as $item) { - $flag = false; //车牌 + $flags[0] = 0; if($item->car_type_id != '') { $car_type_ids = explode(',',$item->car_type_id); $tmp_type_id = 1; if(mb_substr($car_no, 0, 1, 'utf-8') != '京') $tmp_type_id = 2; if(in_array($tmp_type_id, $car_type_ids)) { - $flag = true; + $flags[0] = 1; } else { - $flag = false; + $flags[0] = -1; } } //保险公司 + $flags[1] = 0; if($item->company_ids != '') { $company_ids = explode(',',$item->company_ids); - if(in_array($company2_id, $company_ids)) { - $flag = true; + if(in_array($company_id, $company_ids)) { + $flags[1] = 1; } else { - $flag = false; + $flags[1] = -1; } } //车辆使用类型 + $flags[2] = 0; if($item->car_use_id != '') { $car_use_ids = explode(',',$item->car_use_id); if(in_array($car_use_id, $car_use_ids)) { - $flag = true; + $flags[2] = 1; } else { - $flag = false; + $flags[2] = -1; } } //新保、续保 + $flags[3] = 0; if($item->type_ids != '') { $type_ids = explode(',',$item->type_ids); $tmp_type_id = 1; if($car_info->is_xubao > 0) $tmp_type_id = 2; if(in_array($tmp_type_id, $type_ids)) { - $flag = true; + $flags[3] = 1; } else { + $flags[3] = -1; + } + } + + $flag = true; + foreach($flags as $tmp_flag) { + if($tmp_flag == 0) continue; + if($tmp_flag == -1) { $flag = false; + break; } } if($flag) { diff --git a/frontend/controllers/PhoneCenterController.php b/frontend/controllers/PhoneCenterController.php index eaf24a3..4d7b850 100644 --- a/frontend/controllers/PhoneCenterController.php +++ b/frontend/controllers/PhoneCenterController.php @@ -277,6 +277,10 @@ public function actionDownload(){ $data['rows'] = []; foreach($sub_items as $item) { $row = $item->toArray(); + $row['status'] = ''; + if($item->bind_id != '') { + $row['status'] = '已绑定'; + } $data['rows'][] = $row; } diff --git a/frontend/controllers/StatisticsController.php b/frontend/controllers/StatisticsController.php index e4cb4f6..73eb836 100644 --- a/frontend/controllers/StatisticsController.php +++ b/frontend/controllers/StatisticsController.php @@ -21,8 +21,21 @@ class StatisticsController extends BaseController public $enableCsrfValidation = false; public $layout = 'blue-main'; - public function actionWork() + public function actionWork() { + $group_items = GroupT::getTree((int)$this->my->group_id); + if($this->my->id == 1 || $this->my->username=='6002') + $group_items = GroupT::getTree(); + $company_items = InsurerCompanyT::find() + ->all(); + return $this->render('work',[ + 'group_items' => $group_items, + 'company_items' => $company_items + ]); + } + + public function actionWorkJson() { + Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $date_begin = $request->get('date_begin',date('Y-m-d')); $date_end = $request->get('date_end',date('Y-m-d')); @@ -31,9 +44,7 @@ class StatisticsController extends BaseController $username = $request->get('username'); $group_id = $request->get('group_id'); $company_id = $request->get('company_id'); - $group_items = GroupT::getTree((int)$this->my->group_id); - if($this->my->id == 1 || $this->my->username=='6002') - $group_items = GroupT::getTree(); + $group_ids[] = $group_id; if($group_id > 0) { $items = GroupT::getTree($group_id); @@ -42,12 +53,6 @@ class StatisticsController extends BaseController } } -// 原来的搜索条件 -// $userSql = ''; -// if($username != '') { -// $userSql = ' username like "'.$username.'"'; -// } - // 现在的搜索条件 $userSql = ''; if($username != '') { @@ -58,8 +63,6 @@ class StatisticsController extends BaseController $user_items = $this->my->getChildren($userSql); if($this->my->username == '6002') $user_items = $this->my->getChildren($userSql,1); -// $user_items[] = $this->my; -//var_dump($user_items); $user_rows = array(); $sum_total = array(); $sum_total[0] = ''; @@ -95,22 +98,21 @@ class StatisticsController extends BaseController ->where('user_id='.$user_info->id.' and status_id>1') ->andWhere('insurance_status=1 or insurance_status=3'); if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date_end.'"'); } if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); + $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); } if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('print_date<="'.$date2_end.'"'); + $tmp_query->andWhere('print_date<="'.$date2_end.'"'); } if($company_id > 0) { - $tmp_query = $tmp_query->andWhere('company_id='.$company_id); + $tmp_query->andWhere('company_id='.$company_id); } -// exit; foreach($tmp_query->each() as $item) { $total[0]++; //提单总数 @@ -129,16 +131,16 @@ class StatisticsController extends BaseController $tmp_query = FixCarT::find() ->where('user_id='.$user_info->id.' and status>0'); if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date_end.'"'); } if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); } if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); } $total[7] = $tmp_query->count(); @@ -146,7 +148,6 @@ class StatisticsController extends BaseController $phone_time = ''; $query = PhoneDayT::find() ->where('user_id='.$user_info->id.' and call_date>="'.$date_begin.'" and call_date<="'.$date_end.'"'); -// echo $query->createCommand()->rawSql; $items = $query->all(); $call_time = 0; foreach($items as $item) { @@ -163,7 +164,6 @@ class StatisticsController extends BaseController $row['total'] = $total; $user_rows[] = $row; -// $sum_total[0] += $total[0]; $sum_total[1] += $total[1]; $sum_total[2] += $total[2]; $sum_total[3] += $total[3]; @@ -173,23 +173,37 @@ class StatisticsController extends BaseController $sum_total[7] += $total[7]; } - $company_items = InsurerCompanyT::find() - ->all(); - - return $this->render('work',[ - 'user_rows' => $user_rows, - 'date_begin' => $date_begin, - 'date_end' => $date_end, - 'date2_begin' => $date2_begin, - 'date2_end' => $date2_end, - 'username' => $username, - 'sum_total' => $sum_total, - 'group_id' => $group_id, - 'group_items' => $group_items, - 'company_items' => $company_items, - 'company_id' => $company_id - ]); + $data = []; + $data['total'] = count($user_rows); + $data['rows'] = []; + foreach($user_rows as $item) { + $row = $item; + $row['total_0'] = $item['total'][0]!=''?$item['total'][0]:''; + $row['total_7'] = $item['total'][7]>0?$item['total'][7]:''; + $row['total_1'] = $item['total'][1]>0?$item['total'][1]:''; + $row['total_2'] = $item['total'][2]>0?'¥'.number_format($item['total'][2],2):''; + $row['total_3'] = $item['total'][3]>0?'¥'.number_format($item['total'][3],2):''; + $row['total_4'] = $item['total'][4]>0?'¥'.number_format($item['total'][4],2):''; + $row['total_5'] = $item['total'][5]>0?'¥'.number_format($item['total'][5],2):''; + $row['total_6'] = $item['total'][6]>0?'¥'.number_format($item['total'][6],2):''; + $row['op'] = 1; + $data['rows'][] = $row; + } + $row = []; + $row['username'] = '汇总'; + $row['total_7'] = $sum_total[7]>0?$sum_total[7]:''; + $row['total_1'] = $sum_total[1]>0?$sum_total[1]:''; + $row['total_2'] = $sum_total[2]>0?'¥'.number_format($sum_total[2],2):''; + $row['total_3'] = $sum_total[3]>0?'¥'.number_format($sum_total[3],2):''; + $row['total_4'] = $sum_total[4]>0?'¥'.number_format($sum_total[4],2):''; + $row['total_5'] = $sum_total[5]>0?'¥'.number_format($sum_total[5],2):''; + $row['total_6'] = $sum_total[6]>0?'¥'.number_format($sum_total[6],2):''; + $row['op'] = 0; + $data['rows'][] = $row; + + return $data; } + public function actionCleanWork() { $request = Yii::$app->request; @@ -210,7 +224,6 @@ class StatisticsController extends BaseController } } -// 现在的搜索条件 $userSql = ''; if($username != '') { $userSql = ' username like "'.$username.'" and '; @@ -221,7 +234,7 @@ class StatisticsController extends BaseController if($this->my->username == '6002') $user_items = $this->my->getChildrenClean($userSql,1); $user_items[] = $this->my; -//var_dump($user_items); + $user_rows = array(); $sum_total = array(); $sum_total[0] = 0; @@ -255,21 +268,6 @@ class StatisticsController extends BaseController $tmp_query = $tmp_query->andWhere('company_id='.$company_id); } -// exit; -// foreach($tmp_query->each() as $item) { -// $total[0]++; -// //提单总数 -// if ($item->status_id > 0) { -// $total[1]++; -// $total[2] += $item->total1_clear;//提单总净保费 -// $total[3] += $item->total2_clear;//交强总净保费 -// if($item->status_id > 5) { -// $total[4] += $item->total1_clear;//商业已收净保费 -// $total[5] += $item->total2_clear;//商业已收净保费 -// } -// $total[6] += $item->total1_clear + $item->total2_clear;//总签单净保费 -// } -// } $total['right_num']=$tmp_query->sum('right_num'); $total['wrong_num']=$tmp_query->sum('wrong_num'); $total['yuyue_num']=$tmp_query->sum('yuyue_num'); @@ -285,11 +283,6 @@ class StatisticsController extends BaseController $sum_total[1] += $total['wrong_num']; $sum_total[2] += $total['yuyue_num']; -// $sum_total[3] += $total[3]; -// $sum_total[4] += $total[4]; -// $sum_total[5] += $total[5]; -// $sum_total[6] += $total[6]; - } $company_items = InsurerCompanyT::find() @@ -321,7 +314,7 @@ class StatisticsController extends BaseController if($date_end != '') { $query = $query->andWhere('fenpei_date<="'.$date_end.'"'); } - $CleanFenpei=$query ->count(); + $CleanFenpei=$query ->count(); return $this->render('clean-work-zj',[ 'CleanFenpei' => $CleanFenpei, @@ -510,198 +503,17 @@ class StatisticsController extends BaseController 'company_id' => $company_id ]); } - - public function actionWorkOutput() - { - $objectPHPExcel = new \PHPExcel(); - $index = 1; - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'工号'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'真实姓名'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'通时'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'提车总数'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'提单总数'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'商业总净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'交强总净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'商业已收净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'交强已收净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'总签单净保费'); - + public function actionWorkInfo() { $request = Yii::$app->request; - $date_begin = $request->get('date_begin',date('Y-m-d')); - $date_end = $request->get('date_end',date('Y-m-d')); - $date2_begin = $request->get('date2_begin'); - $date2_end = $request->get('date2_end'); - $username = $request->get('username'); - $group_id = $request->get('group_id'); - $company_id = $request->get('company_id'); - $group_items = GroupT::getTree((int)$this->my->group_id); - if($this->my->id == 1 || $this->my->username=='6002') - $group_items = GroupT::getTree(); - $group_ids[] = $group_id; - if($group_id > 0) { - $items = GroupT::getTree($group_id); - foreach($items as $group_info) { - $group_ids[] = $group_info->id; - } - } - -// 原来的搜索条件 -// $userSql = ''; -// if($username != '') { -// $userSql = ' username like "'.$username.'"'; -// } - -// 现在的搜索条件 - $userSql = ''; - if($username != '') { - $userSql = ' username like "'.$username.'" and '; - } - //$userSql .= 'is_locked=0 and is_login=1'; - - $user_items = $this->my->getChildren($userSql); - if($this->my->username == '6002') - $user_items = $this->my->getChildren($userSql,1); - $user_items[] = $this->my; -//var_dump($user_items); - $user_rows = array(); - $sum_total = array(); - $sum_total[0] = ''; - $sum_total[1] = 0; - $sum_total[2] = 0; - $sum_total[3] = 0; - $sum_total[4] = 0; - $sum_total[5] = 0; - $sum_total[6] = 0; - $sum_total[7] = 0; - foreach($user_items as $user_info) { - if($user_info->is_leave == 1) continue; - - if($group_id > 0) { - if(!in_array($user_info->group_id,$group_ids)) { - continue; - } - } - $total[0] = 0; - $total[1] = 0; - $total[2] = 0; - $total[3] = 0; - $total[4] = 0; - $total[5] = 0; - $total[6] = 0; - $total[7] = 0; - - $row = array(); - $row['id'] = $user_info->id; - $row['username'] = trim($user_info->username); - $row['truename'] = $user_info->name; - $tmp_query = OrderT::find() - ->where('user_id='.$user_info->id.' and status_id>1'); - if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); - } - if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); - } - if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); - } - if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('print_date<="'.$date2_end.'"'); - } - if($company_id > 0) { - $tmp_query = $tmp_query->andWhere('company_id='.$company_id); - } - $index++; -// exit; - foreach($tmp_query->each() as $item) { - - $total[0]++; - //提单总数 - if ($item->status_id > 0) { - $total[1]++; - $total[2] += $item->total1_clear;//提单总净保费 - $total[3] += $item->total2_clear;//交强总净保费 - if($item->status_id > 5) { - $total[4] += $item->total1_clear;//商业已收净保费 - $total[5] += $item->total2_clear;//商业已收净保费 - } - $total[6] += $item->total1_clear + $item->total2_clear;//总签单净保费 - } - - } - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$row['username']); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$row['truename']); - - - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$total[1]>0?$total[1]:''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$total[2]>0?'¥'.number_format($total[2],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$total[3]>0?'¥'.number_format($total[3],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$total[4]>0?'¥'.number_format($total[4],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$total[5]>0?'¥'.number_format($total[5],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$total[6]>0?'¥'.number_format($total[6],2):''); - //提单总数 - $tmp_query = FixCarT::find() - ->where('user_id='.$user_info->id.' and status>0'); - if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); - } - if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); - } - if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); - } - if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); - } - $total[7] = $tmp_query->count(); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$total[7]>0?$total[7]:''); - - //通时 - $phone_time = ''; - $query = PhoneDayT::find() - ->where('user_id='.$user_info->id.' and call_date>="'.$date_begin.'" and call_date<="'.$date_end.'"'); -// echo $query->createCommand()->rawSql; - $items = $query->all(); - $call_time = 0; - foreach($items as $item) { - $call_time += $item->call_time; - } - if($call_time > 0) { - $h = floor($call_time/3600); - $m = floor(($call_time - $h * 3600)/60); - $s = $call_time - $h * 3600 - $m * 60; - $phone_time = $h.':'.$m.':'.$s; - } - - $total[0] = $phone_time; - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$total[0]!=''?$total[0]:''); - $row['total'] = $total; - $user_rows[] = $row; - - - -// $sum_total[0] += $total[0]; -// $sum_total[1] += $total[1]; -// $sum_total[2] += $total[2]; -// $sum_total[3] += $total[3]; -// $sum_total[4] += $total[4]; -// $sum_total[5] += $total[5]; -// $sum_total[6] += $total[6]; -// $sum_total[7] += $total[7]; - } - - header('Content-Type: application/vnd.ms-excel;charset=utf-8'); - header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"'); - header('Cache-Control: max-age=0'); - $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5'); - $objWriter->save('php://output'); - + $user_id = $request->get('user_id'); + return $this->render('work-info',[ + 'user_id' => $user_id + ]); } - - public function actionWorkInfo() + public function actionWorkInfoJson() { + Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $user_id = $request->get('user_id'); $date_begin = $request->get('date_begin'); @@ -726,8 +538,7 @@ class StatisticsController extends BaseController //提交单数 $tmp_query = OrderT::find() - ->where('user_id='.$user_info->id.' and status_id>1') - ->andWhere('insurance_status=1 or insurance_status=3'); + ->where('user_id='.$user_info->id.' and status_id>1'); if($date_begin != '') { $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } @@ -763,17 +574,29 @@ class StatisticsController extends BaseController $phone_time = ''; $total[0] = $phone_time; - return $this->render('work-info',[ - 'user_info' => $user_info, - 'items' => $items, - 'date_begin' => $date_begin, - 'date_end' => $date_end, - 'date2_begin' => $date2_begin, - 'date2_end' => $date2_end, - 'username' => $username, - 'total' => $total - ]); + $data = []; + $data['total'] = count($items); + $data['rows'] = []; + foreach($items as $item) { + $row = $item->toArray(); + $row['total1_clear'] = '¥'.$item->total1_clear; + $row['total1_real'] = '¥'.$item->total1_real; + $row['total1_dis'] = '¥'.$item->total1_dis; + $row['total1_percent'] = '¥'.$item->total1_percent; + $row['status_name'] = '¥'.$item->status->name; + $row['op'] = 1; + $data['rows'][] = $row; + } + $row = []; + $row['id'] = '汇总'; + $row['total1_clear'] = $total[2]?'¥'.number_format($total[2],2):''; + $row['total1_real'] = $total[8]?'¥'.number_format($total[8],2):''; + $row['total1_dis'] = $total[9]?'¥'.number_format($total[9],2):''; + $row['op'] = 0; + $data['rows'][] = $row; + return $data; } + public function actionFixWorkInfo() { $request = Yii::$app->request; @@ -1054,4 +877,4 @@ class StatisticsController extends BaseController 'total' => $total ]); } -} +} \ No newline at end of file diff --git a/frontend/controllers/SystemController.php b/frontend/controllers/SystemController.php index 97a6ec6..9d24355 100644 --- a/frontend/controllers/SystemController.php +++ b/frontend/controllers/SystemController.php @@ -212,4 +212,23 @@ class SystemController extends \yii\web\Controller return $result; } } + + public function actionTest() { + $items = OrderT::find() + ->where('status_id=10') + ->all(); + foreach($items as $item) { + $car_info = $item->car; + if(!$car_info) { + echo 'error'; + break; + } + $car_info->op1_id = $item->user_id; + if(!$car_info->save()) { + print_r($car_info->getErrors()); + break; + } + } + return count($items); + } } diff --git a/frontend/views/appointment/all.php b/frontend/views/appointment/all.php index d9d6680..7a36285 100644 --- a/frontend/views/appointment/all.php +++ b/frontend/views/appointment/all.php @@ -16,21 +16,27 @@ use \common\libs\MyLib;