审查视图

app/index/model/SubjoinInsuranceModel.php 1.9 KB
王晓刚 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/27
 * Time: 17:33
 */

namespace app\index\model;


use think\Model;

class SubjoinInsuranceModel extends Model
{
    public function subjoinSum($where){
        $where['c.delete_time'] = ['eq',0];
        $where['s.delete_time'] = ['eq',0];
王晓刚 authored
19
//        $where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
王晓刚 authored
20 21 22 23
        $data = $this
            ->alias('s')
            ->join('collocation c','s.collocation_id = c.id')
            ->where($where)
王晓刚 authored
24
            ->sum('s.subjoin_pay_method_price');
王晓刚 authored
25 26
        return $data;
    }
王晓刚 authored
27
    public function selectData($where,$whereor=null){
王晓刚 authored
28 29
        $where['s_i.delete_time'] = ['eq',0];
        $where['c.delete_time'] = ['eq',0];
王晓刚 authored
30
        //$where['o.status'] = ['eq',3];
王晓刚 authored
31 32
        $data = $this
            ->alias('s_i')
王晓刚 authored
33
            ->field('s_i.*,c.insurer,o.order_expire_time,o.status,o.order_about_time,o.order_expire_time2')
王晓刚 authored
34
            ->join('cmf_collocation c','c.id = s_i.collocation_id')
王晓刚 authored
35
            ->join('cmf_order_info o_i','c.id = o_i.collocation_id')
王晓刚 authored
36
            ->join('cmf_order o','o_i.order_id = o.id')
王晓刚 authored
37
            ->where($where)
王晓刚 authored
38
            ->whereOr($whereor)
王晓刚 authored
39
            ->order('c.create_time','desc')
王晓刚 authored
40 41
//            ->fetchSql()
            ->select()->toArray();
王晓刚 authored
42 43 44 45 46
        $new_data = [];
        foreach($data as $k1=>$v1 ){
            $new_data[$v1['subjoin_product_name']][] = $v1;
        }
        return $new_data;
王晓刚 authored
47
    }
王晓刚 authored
48 49
    public function selectData2($where){
        $where['delete_time'] = ['eq',0];
王晓刚 authored
50
        $data = $this->where($where)->select()->toArray();
王晓刚 authored
51 52
        return $data;
    }
王晓刚 authored
53 54 55 56 57
    public function findData($where){
        $where['delete_time'] = ['eq',0];
        $data = $this->where($where)->find();
        return $data;
    }
王晓刚 authored
58 59 60 61
    public function deleteData($where){
        $result = $this->where($where)->delete();
        return $result;
    }
王晓刚 authored
62
}