OrderInfoModel.php
6.4 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
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/12/28
* Time: 16:52
*/
namespace app\index\model;
use think\Model;
use think\Db;
class OrderInfoModel extends Model
{
public function findData($where){
$field = "c.*,i_c.thumbnail,i_c.insurance_company_name,o.order_expire_time,o.order_about_time,o.status,o.id o_id";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->join('cmf_insurance_company i_c','c.insurance_company_id = i_c.id')
->where($where)
->find();
return $data;
}
public function selectData1($where1=null,$whereor=null){
$where1['o.delete_time'] = ['eq',0];
$where1['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
//$where1['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
//$where1['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*,i_c.thumbnail,i_c.insurance_company_name,o.order_expire_time,o.order_about_time,o.status,o.id o_id";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->join('cmf_insurance_company i_c','c.insurance_company_id = i_c.id')
->where($where1)
->whereOr($whereor)
->order('c.create_time','desc')
// ->fetchSql()
->select()->toArray();
// echo $data;
// exit();
return $data;
}
public function selectData($where1,$whereor=null){
$time = time();
$where1['o.delete_time'] = ['eq',0];
$where1['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
$where1['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
$where1['o.order_about_time'] = ['>',(time()-30*24*60*60)];//筛选出托管中状态
//$where1['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*,o.order_expire_time,o.status";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->where($where1)
->whereOr($whereor)
->order('c.create_time','desc')
// ->fetchSql()
->select()->toArray();
// echo $data;
// exit();
$new_data = [];
foreach($data as $k1=>$v1 ){
$new_data[$v1['product_name']][] = $v1;
}
//获取附加险的信息
// foreach($data as $key => $vo){
// $where2['collocation_id'] = ['eq',$vo['id']];
// $where2['delete_time'] = ['eq',0];
// $subjoin_insurance = Db::name('subjoin_insurance')->where($where2)->select()->toArray();
// $data[$key]['subjoin_insurance'] = $subjoin_insurance;
// }
return $new_data;
}
//在托管中状态的保单份数
public function collocationCount($where){
$where['o.delete_time'] = ['eq',0];
$where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
$where['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
$where['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->where($where)
->count();
return $data;
}
public function peopleCount($where){
$where['o.delete_time'] = ['eq',0];
$where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
$where['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
$where['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->where($where)
->group('c.insurer')
->count();
return $data;
}
public function totalSum($where){
$where['o.delete_time'] = ['eq',0];
$where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
$where['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
$where['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->where($where)
->sum('c.insurance_price');
return $data;
}
public function subjoinSum($where){
$where['o.delete_time'] = ['eq',0];
$where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
$where['o.order_expire_time'] = ['>',time()];//筛选出托管中状态
$where['o.status'] = ['eq',3];//筛选出托管中状态
$field = "c.*";
$data = $this
->alias('o_i')
->field($field)
->join('cmf_order o','o.id = o_i.order_id')
->join('cmf_collocation c','c.id = o_i.collocation_id')
->where($where)
->order('c.create_time','desc')
->select()->toArray();
//获取附加险的信息
foreach($data as $key => $vo){
$subjoin_insurance_sum = Db::name('subjoin_insurance')->where(array('collocation_id'=>$vo['id'],'delete_time'=>0))->sum('subjoin_price');
$data[$key]['subjoin_insurance_sum'] = $subjoin_insurance_sum;
}
//计算附加险的保险之和
$sum = 0;
foreach($data as $key => $vo){
$sum += $vo['subjoin_insurance_sum'];
}
return $sum;
}
public function countInsuranceType(){
}
public function insertData($data){
$result = $this->insertGetId($data);
return $result;
}
public function findData2($where){
$data = $this->where($where)->find();
return $data;
}
}