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