审查视图

app/index/server/IndexServer.php 6.0 KB
王晓刚 authored
1 2 3 4 5 6 7
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/28
 * Time: 17:22
 */
王晓刚 authored
8
namespace app\index\server;
王晓刚 authored
9
王晓刚 authored
10
use app\index\model\OrderInfoModel;
王晓刚 authored
11
use app\index\model\SubjoinInsuranceModel;
王晓刚 authored
12
王晓刚 authored
13 14
class IndexServer
{
王晓刚 authored
15
    //点击保单类型判断当前用户在当前类型下的箭头现实情况
王晓刚 authored
16
    public function main_arrows($data1,$data2,$question,$user,$insurance_type_id){
王晓刚 authored
17
        foreach($data1 as $key1 => $vo1){
王晓刚 authored
18 19 20 21 22
            $total = [];
            foreach($vo1 as $key111 => $vo111){
                $total[] = $vo111['insurance_price'];
            }
            foreach($vo1 as $key11 => $vo11){
王晓刚 authored
23 24 25 26
                if($vo11['insurer'] == $user['name']){
                    if($vo11['insurance_type_id'] == 1){
                        //重疾
                        $standard = ($question['personage_year_income']*5)+($question['not_return']*0.3);
王晓刚 authored
27
                        if($standard >= array_sum($total)){
王晓刚 authored
28
                            //绿油油
王晓刚 authored
29
                            $data1[$key1][$key11]['main_arrows'] = 1;
王晓刚 authored
30 31
                        }else{
                            //红彤彤
王晓刚 authored
32
                            $data1[$key1][$key11]['main_arrows'] = 2;
王晓刚 authored
33 34 35 36
                        }
                    }else if($vo11['insurance_type_id'] == 2){
                        //人寿
                        $standard = $question['personage_year_income']*10+$question['not_return'];
王晓刚 authored
37
                        if($standard >= array_sum($total)){
王晓刚 authored
38
                            //绿油油
王晓刚 authored
39
                            $data1[$key1][$key11]['main_arrows'] = 1;
王晓刚 authored
40 41
                        }else{
                            //红彤彤
王晓刚 authored
42
                            $data1[$key1][$key11]['main_arrows'] = 2;
王晓刚 authored
43 44 45 46
                        }
                    }else if($vo11['insurance_type_id'] == 3){
                        //出行
                        $standard = $question['personage_year_income']*10+$question['not_return'];
王晓刚 authored
47
                        if($standard >= array_sum($total)){
王晓刚 authored
48
                            //绿油油
王晓刚 authored
49
                            $data1[$key1][$key11]['main_arrows'] = 1;
王晓刚 authored
50 51
                        }else{
                            //红彤彤
王晓刚 authored
52
                            $data1[$key1][$key11]['main_arrows'] = 2;
王晓刚 authored
53 54 55 56
                        }
                    }else if($vo11['insurance_type_id'] == 4){
                        //医疗
                        $standard = 1000000;
王晓刚 authored
57
                        if($standard >= array_sum($total)){
王晓刚 authored
58
                            //绿油油
王晓刚 authored
59
                            $data1[$key1][$key11]['main_arrows'] = 1;
王晓刚 authored
60 61
                        }else{
                            //红彤彤
王晓刚 authored
62
                            $data1[$key1][$key11]['main_arrows'] = 2;
王晓刚 authored
63
                        }
王晓刚 authored
64
                    }
王晓刚 authored
65
                }
王晓刚 authored
66
            }
王晓刚 authored
67
        }
王晓刚 authored
68
        foreach($data2 as $key2 => $vo2){
王晓刚 authored
69 70
            $total = [];
            foreach($vo2 as $key222 => $vo222){
王晓刚 authored
71
                $total[] = $vo222['subjoin_price'];
王晓刚 authored
72 73
            }
            foreach($vo2 as $key22 => $vo22){
王晓刚 authored
74 75 76 77
                if($vo22['insurer'] == $user['name']) {
                    if ($vo22['insurance_type_id'] == 1) {
                        //重疾
                        $standard = ($question['personage_year_income'] * 5) + ($question['not_return'] * 0.3);
王晓刚 authored
78
                        if ($standard >= array_sum($total)) {
王晓刚 authored
79
                            //绿油油
王晓刚 authored
80
                            $data2[$key2][$key22]['main_arrows'] = 1;
王晓刚 authored
81 82
                        } else {
                            //红彤彤
王晓刚 authored
83
                            $data2[$key2][$key22]['main_arrows'] = 2;
王晓刚 authored
84 85 86 87
                        }
                    } else if ($vo22['insurance_type_id'] == 2) {
                        //人寿
                        $standard = $question['personage_year_income'] * 10 + $question['not_return'];
王晓刚 authored
88
                        if ($standard >= array_sum($total)) {
王晓刚 authored
89
                            //绿油油
王晓刚 authored
90
                            $data2[$key2][$key22]['main_arrows'] = 1;
王晓刚 authored
91 92
                        } else {
                            //红彤彤
王晓刚 authored
93
                            $data2[$key2][$key22]['main_arrows'] = 2;
王晓刚 authored
94 95 96 97
                        }
                    } else if ($vo22['insurance_type_id'] == 3) {
                        //出行
                        $standard = $question['personage_year_income'] * 10 + $question['not_return'];
王晓刚 authored
98
                        if ($standard >= array_sum($total)) {
王晓刚 authored
99
                            //绿油油
王晓刚 authored
100
                            $data2[$key2][$key22]['main_arrows'] = 1;
王晓刚 authored
101 102
                        } else {
                            //红彤彤
王晓刚 authored
103
                            $data2[$key2][$key22]['main_arrows'] = 2;
王晓刚 authored
104 105 106 107
                        }
                    } else if ($vo22['insurance_type_id'] == 4) {
                        //医疗
                        $standard = 1000000;
王晓刚 authored
108
                        if ($standard >= array_sum($total)) {
王晓刚 authored
109
                            //绿油油
王晓刚 authored
110
                            $data2[$key2][$key22]['main_arrows'] = 1;
王晓刚 authored
111 112
                        } else {
                            //红彤彤
王晓刚 authored
113
                            $data2[$key2][$key22]['main_arrows'] = 2;
王晓刚 authored
114
                        }
王晓刚 authored
115
                    }
王晓刚 authored
116
                }
王晓刚 authored
117
            }
王晓刚 authored
118
        }
王晓刚 authored
119 120
        $data['insurance'] = $data1;
        $data['subjoin'] = $data2;
王晓刚 authored
121
        return $data;
王晓刚 authored
122 123
    }
    public function vice_arrows(){
王晓刚 authored
124 125

    }
王晓刚 authored
126
    public function regroup($data){
王晓刚 authored
127
        $arr = [];
王晓刚 authored
128
王晓刚 authored
129
        foreach($data as $key => $vo){
王晓刚 authored
130
            $result1 = [];
王晓刚 authored
131
            $result2 = [];
王晓刚 authored
132
王晓刚 authored
133 134 135

            foreach($vo as $k=>$v){
王晓刚 authored
136
                $result1[] = $v['insurance_price'];
王晓刚 authored
137
                if($v['order_expire_time'] > time()){
王晓刚 authored
138
                    $result2[] = $v['insurance_price'];
王晓刚 authored
139 140
                }
            }
王晓刚 authored
141
王晓刚 authored
142 143
            $arr['name'] = $key;
            $arr['sum'] = array_sum($result2);
王晓刚 authored
144
            if(empty($result1)){//未有保单
王晓刚 authored
145
                $arr['type'] = 1;
王晓刚 authored
146
            }else if(empty($result2)){//保障缺失
王晓刚 authored
147
                $arr['type'] = 2;
王晓刚 authored
148
            }else{
王晓刚 authored
149
                $arr['type'] = 3;
王晓刚 authored
150 151
            }
        }
王晓刚 authored
152
王晓刚 authored
153
        return $arr;
王晓刚 authored
154
    }
王晓刚 authored
155
}