SubjoinInsuranceModel.php 1.9 KB
<?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];
//        $where['c.expire_time'] = ['>',time()];//判断保单是否还在缴费期限内
        $data = $this
            ->alias('s')
            ->join('collocation c','s.collocation_id = c.id')
            ->where($where)
            ->sum('s.subjoin_pay_method_price');
        return $data;
    }
    public function selectData($where,$whereor=null){
        $where['s_i.delete_time'] = ['eq',0];
        $where['c.delete_time'] = ['eq',0];
        //$where['o.status'] = ['eq',3];
        $data = $this
            ->alias('s_i')
            ->field('s_i.*,c.insurer,o.order_expire_time,o.status,o.order_about_time,o.order_expire_time2')
            ->join('cmf_collocation c','c.id = s_i.collocation_id')
            ->join('cmf_order_info o_i','c.id = o_i.collocation_id')
            ->join('cmf_order o','o_i.order_id = o.id')
            ->where($where)
            ->whereOr($whereor)
            ->order('c.create_time','desc')
//            ->fetchSql()
            ->select()->toArray();
        $new_data = [];
        foreach($data as $k1=>$v1 ){
            $new_data[$v1['subjoin_product_name']][] = $v1;
        }
        return $new_data;
    }
    public function selectData2($where){
        $where['delete_time'] = ['eq',0];
        $data = $this->where($where)->select()->toArray();
        return $data;
    }
    public function findData($where){
        $where['delete_time'] = ['eq',0];
        $data = $this->where($where)->find();
        return $data;
    }
    public function deleteData($where){
        $result = $this->where($where)->delete();
        return $result;
    }
}