php定时生成图片(有底图)【larveral框架】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/han_cui/article/details/86508135

控制器:

<?php

namespace App\Console\Commands\certificate;

use App\Model\Nk\ListNotice;
use App\Model\Nk\KindergartenPayLog;
use App\Model\Nk\TeacherClasstype;
use App\Model\Nk\Product;
use App\Model\Partner\ClassRoom;
use App\Model\Partner\Kindergarten;
use Illuminate\Console\Command;
use zgldh\QiniuStorage\QiniuStorage;//七牛
use Log;


class ClassCertificate extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'certificate:ClassCertificate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '统计前十天的开课证';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $interval_time = 180;          //间隔时间/查询时间间距
        try {
            $starttime = date('Y-m-d 00:00:00', strtotime('-10 day',time()));
            $endtime = date('Y-m-d 23:59:59', strtotime('-1 day',time()));
            $res = KindergartenPayLog::get_certificates_url($starttime, $endtime);

            if ($res) {
                foreach ($res as $k => $v) {
                    //更新数据
                    $data = array(
                        'certificates_url' => $this->create_open_class_img($v->id),
                        'updated_at' => date('Y-m-d H:i:s',time()),
                    );
                    $res = KindergartenPayLog::where('id','=',$v->id)->update($data);
                    if (!$res) {
                        self::info('脚本处理更新失败:' . json_encode($data));
                        Log::error('脚本处理更新失败:' . json_encode($data));
                    }
                }
            }
        } catch (Exception $e) {
            self::info('脚本错误:' . $e);
            Log::error('脚本错误:' . $e);
        }
    }

    /**
     * 注释:生成开课证图片
     * @Author   TGHan
     * @DateTime 2018-06-21
     * @param    Request    $request [description]
     * @return   [type]              [description]
     */
    public function create_open_class_img($id){
        if(empty($id)) return $this->responseJsonError(0, '参数空');
        $info = KindergartenPayLog::getOne($id);
        $info = json_decode(json_encode($info),true);
        if (empty($info)) return $this->responseJsonError(0, '订单未找到');
        $product_payment_type = $info['product_payment_type'];
        $num = explode(',',trim($product_payment_type,','));
        $num1 = array_unique($num);
        $nums = array_values($num1);
        $product_payment_types = implode(',',$nums);
        
        //幼儿园名称
        $kid_name = Kindergarten::get_kdg_info_from_kdgid($info['kid']);
        $kid_name = json_decode(json_encode($kid_name),true);
        if (empty($kid_name)) return $this->responseJsonError(0, '暂无幼儿园信息');
        $kid_names = $kid_name[0]['kdg_name'];

        //班级总数
        $class_count = count(explode(',',$info['class_id']));
        //缴费日期
        $pay_time = $info['pay_time'];
        //总计费用
        $pay_price = $info['pay_price'];

        if($info['parent_orderid'] == 1){
            if($product_payment_types == '1'){
                /*1.定义素材路径*/
                $beijing = public_path('images/certificate_img')."/fei.png";//海报最底层得背景
                $datalist1 = KindergartenPayLog::get_suborders($info['id'],1);
                $datalist1 = json_decode(json_encode($datalist1),true);
                if($datalist1){
                    //班级课时数
                    $product_id1 = TeacherClasstype::get_product_id_from_teacher_classtype($datalist1[0]['class_id']);
                    $product_id1 = json_decode(json_encode($product_id1),true);
                    if($product_id1){
                        $class_hour1 = Product::get_class_hours_from_product($product_id1[0]['product_id']);
                        $class_hour1 = json_decode(json_encode($class_hour1),true);
                        $class_hours1 = $class_hour1[0]['class_hours']; 
                    }else{
                        $class_hours1 = 0;
                    }
                    //上课时间
                    $product_start1 = $datalist1[0]['product_start'];
                    $product_end1 = $datalist1[0]['product_end'];
                    $class_times1 = $product_start1.'/'.$product_end1;
                    //单价
                    $product_market_price1 = $datalist1[0]['product_market_price'];
                    //缴费单位
                    $product_payment_set1 = $datalist1[0]['product_payment_set'];
                    if($product_payment_set1 == '1'){
                        $product_payment_sets1 = '学期'; 
                    }elseif ($product_payment_set1 == '2') {
                        $product_payment_sets1 = '月';
                    }elseif ($product_payment_set1 == '3') {
                        $product_payment_sets1 = '年';
                    }
                    //班级数量
                    $class_num1 = count($datalist1);
                    //实付价格
                    $sum1 = 0;  
                    foreach($datalist1 as $item1){
                        $sum1 += $item1['pay_price'];
                    }
                    $pay_price_num1 = $sum1;

                    /*2.从文件或 URL 载入一幅图像*/
                    $beijing = $this->imagecreatefrom_gif_jpeg_png($beijing);//图像兼容格式
                    $image_3 = imageCreatetruecolor(imagesx($beijing),imagesy($beijing));//新建一个真彩色图像
                    imagecopyresampled($image_3,$beijing,0,0,0,0,imagesx($beijing),imagesy($beijing),imagesx($beijing),imagesy($beijing));//重采样拷贝部分图像并调整大小

                    //字体颜色
                    $font = public_path('images/certificate_img')."/regular.ttf";//写的文字用到的字体。华文圆体
                    $font_bold = public_path('images/certificate_img')."/regular-bold.ttf";//写的文字用到的字体。华文圆体加粗
                    $green = imagecolorallocate($image_3, 38,183,188);
                    $black = imagecolorallocate($image_3, 102,102,102);
                    $black_bold = imagecolorallocate($image_3, 51,51,51);

                    imagettftext($image_3,26,0,109,360,$green,$font,$kid_names);//用 TrueType 字体向图像写入文本幼儿园名称

                    imagettftext($image_3,20,0,202,576,$green,$font,$class_hours1);//用 TrueType 字体向图像写入文本课时
                    imagettftext($image_3,20,0,215,615,$black,$font,$class_times1);//用 TrueType 字体向图像写入文本上课时间
                    imagettftext($image_3,20,0,170,658,$black,$font,$product_market_price1);//用 TrueType 字体向图像写入文本单价
                    imagettftext($image_3,18,0,335,656,$black,$font,$product_payment_sets1);//用 TrueType 字体向图像写入文本缴费单位
                    imagettftext($image_3,20,0,218,700,$black,$font,$class_num1);//用 TrueType 字体向图像写入文本班级数量
                    imagettftext($image_3,20,0,520,700,$black_bold,$font,$pay_price_num1);//用 TrueType 字体向图像写入文本实付价格

                    imagettftext($image_3,20,0,233,880,$green,$font,$class_count);//用 TrueType 字体向图像写入文本班级总数
                    imagettftext($image_3,20,0,230,915,$black_bold,$font,$pay_time);//用 TrueType 字体向图像写入文本缴费日期
                    imagettftext($image_3,26,0,480,980,$black_bold,$font_bold,$pay_price);//用 TrueType 字体向图像写入文本总缴费用
                }

            }elseif ($product_payment_types == '2') {
                $beijing = public_path('images/certificate_img')."/chun.png";
                $datalist2 = KindergartenPayLog::get_suborders($info['id'],2);
                $datalist2 = json_decode(json_encode($datalist2),true);
                if($datalist2){
                    //班级课时数
                    $product_id2 = TeacherClasstype::get_product_id_from_teacher_classtype($datalist2[0]['class_id']);
                    $product_id2 = json_decode(json_encode($product_id2),true);
                    $class_hour2 = Product::get_class_hours_from_product($product_id2[0]['product_id']);
                    $class_hour2 = json_decode(json_encode($class_hour2),true);
                    $class_hours2 = $class_hour2[0]['class_hours'];
                    //上课时间
                    $product_start2 = $datalist2[0]['product_start'];
                    $product_end2 = $datalist2[0]['product_end'];
                    $class_times2 = $product_start2.'/'.$product_end2;
                    //单价
                    $product_market_price2 = $datalist2[0]['product_market_price'];
                    //缴费单位
                    $product_payment_set2 = $datalist2[0]['product_payment_set'];
                    if($product_payment_set2 == '1'){
                        $product_payment_sets2 = '学期'; 
                    }elseif ($product_payment_set2 == '2') {
                        $product_payment_sets2 = '月';
                    }elseif ($product_payment_set2 == '3') {
                        $product_payment_sets2 = '年';
                    }
                    //班级数量
                    $class_num2 = count($datalist2);
                    //实付价格
                    $sum2 = 0;  
                    foreach($datalist2 as $item2){  
                        $sum2 += $item2['pay_price'];  
                    }
                    $pay_price_num2 = $sum2;

                    /*2.从文件或 URL 载入一幅图像*/
                    $beijing = $this->imagecreatefrom_gif_jpeg_png($beijing);//图像兼容格式
                    $image_3 = imageCreatetruecolor(imagesx($beijing),imagesy($beijing));//新建一个真彩色图像
                    imagecopyresampled($image_3,$beijing,0,0,0,0,imagesx($beijing),imagesy($beijing),imagesx($beijing),imagesy($beijing));//重采样拷贝部分图像并调整大小

                    //字体颜色
                    $font = public_path('images/certificate_img')."/regular.ttf";//写的文字用到的字体。华文圆体
                    $font_bold = public_path('images/certificate_img')."/regular-bold.ttf";//写的文字用到的字体。华文圆体加粗
                    $green = imagecolorallocate($image_3, 38,183,188);
                    $black = imagecolorallocate($image_3, 102,102,102);
                    $black_bold = imagecolorallocate($image_3, 51,51,51);

                    imagettftext($image_3,26,0,109,360,$green,$font,$kid_names);//用 TrueType 字体向图像写入文本幼儿园名称

                    imagettftext($image_3,20,0,202,576,$green,$font,$class_hours2);//用 TrueType 字体向图像写入文本课时
                    imagettftext($image_3,20,0,215,615,$black,$font,$class_times2);//用 TrueType 字体向图像写入文本上课时间
                    imagettftext($image_3,20,0,170,658,$black,$font,$product_market_price2);//用 TrueType 字体向图像写入文本单价
                    imagettftext($image_3,18,0,335,656,$black,$font,$product_payment_sets2);//用 TrueType 字体向图像写入文本缴费单位
                    imagettftext($image_3,20,0,218,700,$black,$font,$class_num2);//用 TrueType 字体向图像写入文本班级数量
                    imagettftext($image_3,20,0,520,700,$black_bold,$font,$pay_price_num2);//用 TrueType 字体向图像写入文本实付价格

                    imagettftext($image_3,20,0,233,880,$green,$font,$class_count);//用 TrueType 字体向图像写入文本班级总数
                    imagettftext($image_3,20,0,230,915,$black_bold,$font,$pay_time);//用 TrueType 字体向图像写入文本缴费日期
                    imagettftext($image_3,26,0,480,980,$black_bold,$font_bold,$pay_price);//用 TrueType 字体向图像写入文本总缴费用

                }
            }elseif ($product_payment_types == '1,2' || $product_payment_types == '2,1') {
                $beijing = public_path('images/certificate_img')."/all.png";
                //子订单数据
                $datalist1 = KindergartenPayLog::get_suborders($info['id'],1);
                $datalist1 = json_decode(json_encode($datalist1),true);
                $datalist2 = KindergartenPayLog::get_suborders($info['id'],2);
                $datalist2 = json_decode(json_encode($datalist2),true);

                //菲扬班
                //班级课时数
                $product_id1 = TeacherClasstype::get_product_id_from_teacher_classtype($datalist1[0]['class_id']);
                $product_id1 = json_decode(json_encode($product_id1),true);
                $class_hour1 = Product::get_class_hours_from_product($product_id1[0]['product_id']);
                $class_hour1 = json_decode(json_encode($class_hour1),true);
                $class_hours1 = $class_hour1[0]['class_hours'];
                //上课时间
                $product_start1 = $datalist1[0]['product_start'];
                $product_end1 = $datalist1[0]['product_end'];
                $class_times1 = $product_start1.'/'.$product_end1;
                //单价
                $product_market_price1 = $datalist1[0]['product_market_price'];
                //缴费单位
                $product_payment_set1 = $datalist1[0]['product_payment_set'];
                if($product_payment_set1 == '1'){
                    $product_payment_sets1 = '学期';
                }elseif ($product_payment_set1 == '2') {
                    $product_payment_sets1 = '月';
                }elseif ($product_payment_set1 == '3') {
                    $product_payment_sets1 = '年';
                }
                //班级数量
                $class_num1 = count($datalist1);
                //实付价格
                $sum1 = 0;  
                foreach($datalist1 as $item1){
                    $sum1 += $item1['pay_price'];
                }
                $pay_price_num1 = $sum1;
                

                //春蕾班
                //班级课时数
                $product_id2 = TeacherClasstype::get_product_id_from_teacher_classtype($datalist2[0]['class_id']);
                $product_id2 = json_decode(json_encode($product_id2),true);
                $class_hour2 = Product::get_class_hours_from_product($product_id2[0]['product_id']);
                $class_hour2 = json_decode(json_encode($class_hour2),true);
                $class_hours2 = $class_hour2[0]['class_hours'];
                //上课时间
                $product_start2 = $datalist2[0]['product_start'];
                $product_end2 = $datalist2[0]['product_end'];
                $class_times2 = $product_start2.'/'.$product_end2;
                //单价
                $product_market_price2 = $datalist2[0]['product_market_price'];
                //缴费单位
                $product_payment_set2 = $datalist2[0]['product_payment_set'];
                if($product_payment_set2 == '1'){
                    $product_payment_sets2 = '学期'; 
                }elseif ($product_payment_set2 == '2') {
                    $product_payment_sets2 = '月';
                }elseif ($product_payment_set2 == '3') {
                    $product_payment_sets2 = '年';
                }
                //班级数量
                $class_num2 = count($datalist2);
                //实付价格
                $sum2 = 0;  
                foreach($datalist2 as $item2){  
                    $sum2 += $item2['pay_price'];  
                }
                $pay_price_num2 = $sum2;

                /*2.从文件或 URL 载入一幅图像*/
                $beijing = $this->imagecreatefrom_gif_jpeg_png($beijing);//图像兼容格式
                $image_3 = imageCreatetruecolor(imagesx($beijing),imagesy($beijing));//新建一个真彩色图像
                imagecopyresampled($image_3,$beijing,0,0,0,0,imagesx($beijing),imagesy($beijing),imagesx($beijing),imagesy($beijing));//重采样拷贝部分图像并调整大小

                //字体颜色
                $font = public_path('images/certificate_img')."/regular.ttf";//写的文字用到的字体。华文圆体
                $font_bold = public_path('images/certificate_img')."/regular-bold.ttf";//写的文字用到的字体。华文圆体加粗
                $green = imagecolorallocate($image_3, 38,183,188);
                $black = imagecolorallocate($image_3, 102,102,102);
                $black_bold = imagecolorallocate($image_3, 51,51,51);

                imagettftext($image_3,26,0,109,360,$green,$font,$kid_names);//用 TrueType 字体向图像写入文本幼儿园名称

                imagettftext($image_3,20,0,202,474,$green,$font,$class_hours2);//用 TrueType 字体向图像写入文本课时
                imagettftext($image_3,20,0,215,514,$black,$font,$class_times2);//用 TrueType 字体向图像写入文本上课时间
                imagettftext($image_3,20,0,170,558,$black,$font,$product_market_price2);//用 TrueType 字体向图像写入文本单价
                imagettftext($image_3,18,0,335,556,$black,$font,$product_payment_sets2);//用 TrueType 字体向图像写入文本缴费单位
                imagettftext($image_3,20,0,218,600,$black,$font,$class_num2);//用 TrueType 字体向图像写入文本班级数量
                imagettftext($image_3,20,0,520,600,$black_bold,$font,$pay_price_num2);//用 TrueType 字体向图像写入文本实付价格

                imagettftext($image_3,20,0,202,676,$green,$font,$class_hours1);//用 TrueType 字体向图像写入文本课时
                imagettftext($image_3,20,0,215,716,$black,$font,$class_times1);//用 TrueType 字体向图像写入文本上课时间
                imagettftext($image_3,20,0,170,760,$black,$font,$product_market_price1);//用 TrueType 字体向图像写入文本单价
                imagettftext($image_3,18,0,335,758,$black,$font,$product_payment_sets1);//用 TrueType 字体向图像写入文本缴费单位
                imagettftext($image_3,20,0,218,804,$black,$font,$class_num1);//用 TrueType 字体向图像写入文本班级数量
                imagettftext($image_3,20,0,520,804,$black_bold,$font,$pay_price_num1);//用 TrueType 字体向图像写入文本实付价格

                imagettftext($image_3,20,0,233,880,$green,$font,$class_count);//用 TrueType 字体向图像写入文本班级总数
                imagettftext($image_3,20,0,230,915,$black_bold,$font,$pay_time);//用 TrueType 字体向图像写入文本缴费日期
                imagettftext($image_3,26,0,480,980,$black_bold,$font_bold,$pay_price);//用 TrueType 字体向图像写入文本总缴费用

            }
        }elseif ($info['parent_orderid'] == 0) {
            if($info['product_payment_type'] == '1'){
                /*1.定义素材路径*/
                $beijing = public_path('images/certificate_img')."/fei.png";//海报最底层得背景
            }elseif ($info['product_payment_type'] == '2') {
                $beijing = public_path('images/certificate_img')."/chun.png";
            }

            //班级课时数
            $product_id3 = TeacherClasstype::get_product_id_from_teacher_classtype($info['class_id']);
            $product_id3 = json_decode(json_encode($product_id3),true);
            $class_hour3 = Product::get_class_hours_from_product($product_id3[0]['product_id']);
            $class_hour3 = json_decode(json_encode($class_hour3),true);
            $class_hours3 = $class_hour3[0]['class_hours'];
            //上课时间
            $product_start3 = $info['product_start'];
            $product_end3 = $info['product_end'];
            $class_times3 = $product_start3.'/'.$product_end3;
            //单价
            $product_market_price3 = $info['product_market_price'];
            //缴费单位
            $product_payment_set3 = $info['product_payment_set'];
            if($product_payment_set3 == '1'){
                $product_payment_sets3 = '学期'; 
            }elseif ($product_payment_set3 == '2') {
                $product_payment_sets3 = '月';
            }elseif ($product_payment_set3 == '3') {
                $product_payment_sets3 = '年';
            }
            if(!isset($product_payment_sets3)){
                $explode = explode(',',$product_payment_set3);
                switch ($explode['0']){
                    case 1:
                        $product_payment_sets3 = '学期';
                        break;
                    case 2:
                        $product_payment_sets3 = '月';
                        break;
                    case 3:
                        $product_payment_sets3 = '年';
                        break;
                    default:
                        $product_payment_sets3 = '年';
                        break;
                }
            }else{
                $product_payment_sets3 = '年';
            }

            //班级数量
            $class_num3 = 1;
            //实付价格
            $pay_price_num3 = $info['pay_price'];

            /*2.从文件或 URL 载入一幅图像*/
            $beijing = $this->imagecreatefrom_gif_jpeg_png($beijing);//图像兼容格式
            $image_3 = imageCreatetruecolor(imagesx($beijing),imagesy($beijing));//新建一个真彩色图像
            imagecopyresampled($image_3,$beijing,0,0,0,0,imagesx($beijing),imagesy($beijing),imagesx($beijing),imagesy($beijing));//重采样拷贝部分图像并调整大小

            //字体颜色
            $font = public_path('images/certificate_img')."/regular.ttf";//写的文字用到的字体。华文圆体
            $font_bold = public_path('images/certificate_img')."/regular-bold.ttf";//写的文字用到的字体。华文圆体加粗
            $green = imagecolorallocate($image_3, 38,183,188);
            $black = imagecolorallocate($image_3, 102,102,102);
            $black_bold = imagecolorallocate($image_3, 51,51,51);

            imagettftext($image_3,26,0,109,360,$green,$font,$kid_names);//用 TrueType 字体向图像写入文本幼儿园名称

            imagettftext($image_3,20,0,202,576,$green,$font,$class_hours3);//用 TrueType 字体向图像写入文本课时
            imagettftext($image_3,20,0,215,615,$black,$font,$class_times3);//用 TrueType 字体向图像写入文本上课时间
            imagettftext($image_3,20,0,170,658,$black,$font,$product_market_price3);//用 TrueType 字体向图像写入文本单价
            imagettftext($image_3,18,0,335,656,$black,$font,$product_payment_sets3);//用 TrueType 字体向图像写入文本缴费单位
            imagettftext($image_3,20,0,218,700,$black,$font,$class_num3);//用 TrueType 字体向图像写入文本班级数量
            imagettftext($image_3,20,0,520,700,$black_bold,$font,$pay_price_num3);//用 TrueType 字体向图像写入文本实付价格

            imagettftext($image_3,20,0,233,880,$green,$font,$class_count);//用 TrueType 字体向图像写入文本班级总数
            imagettftext($image_3,20,0,230,915,$black_bold,$font,$pay_time);//用 TrueType 字体向图像写入文本缴费日期
            imagettftext($image_3,26,0,480,980,$black_bold,$font_bold,$pay_price);//用 TrueType 字体向图像写入文本总缴费用

        }

        //生成图片
        $random = $this->getRandomStr();
        $time = 'certificate-'.$random.'-'.time();
        imagepng($image_3,public_path().'/images/certificate_img/'.$time.".png");//保存到本地   以 PNG 格式将图像输出到浏览器或文件
        $img_url = public_path().'/images/certificate_img/'.$time.'.png';
        imagedestroy($image_3);//销毁图像

        //上传七牛云
        $file = file_get_contents($img_url);
        $disk = \Storage::disk('qiniu'); //使用七牛云上传
        $img_name = $time.'.png';
        $filename = $disk->put($img_name,$file);//上传
        if(!$filename) {
            return $this->responseJsonError(500, '上传失败');
        }
        unlink($img_url);
        $img_url = $disk->getDriver()->downloadUrl($img_name); //获取下载链接
        $img_url = json_decode(json_encode($img_url),true);
        return $img_url;

    }

     /**
     * 载入图像兼容 GIF, JPEG, PNG, WBMP
     * @param string $img_name
     * @return resource|string
     */
    public function imagecreatefrom_gif_jpeg_png($img_name=''){
        $ename = getimagesize($img_name);
        $ename = explode('/',$ename['mime']);
        $sub = '.'.$ename[1];
        switch($sub){
            case '.jpeg':
            case '.jpg':
                $data = imagecreatefromjpeg($img_name);
                break;
            case '.png':
                $data = imagecreatefrompng($img_name);
                break;
            case '.gif':
                $data = imagecreatefromgif($img_name);
                break;
            case '.webmp':
                $data = imagecreatefromwbmp($img_name);
                break;
            default:
                $data = '';
                break;
        }
        return $data;
    }

    /**
     * 随机生成16位字符串
     * @return string 生成的字符串
     */
    public function getRandomStr(){
        $str = "";
        $str_pol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
        $max = strlen($str_pol) - 1;
        for ($i = 0; $i < 16; $i++) {
            $str .= $str_pol[mt_rand(0, $max)];
        }
        return $str;
    }

}
 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

模型:

<?php 
namespace App\Model\Nk;
use Illuminate\Database\Eloquent\Model;
use Auth, Input, Request, Cache;
use Illuminate\Support\Facades\DB;

class KindergartenDepositLog extends Model
{
    protected $connection = 'mysql_new';
    protected $table = 'kindergarten_deposit_log';

    static $cacheMinutes = 1440;

    protected $fillable = [
        'id',
        'type',
        'order_num',
        'phone',
        'uid',
        'uname',
        'kdg_id',
        'kdg_name',
        'province',
        'city',
        'district',
        'address_detail',
        'market_phone',
        'order_price',
        'pay_price',
        'pay_way',
        'pay_time',
        'trade_no',
        'prepay_id',
        'product_name',
        'pay_status',
        'status',
        'client_ip',
        'wx_request',
        'wx_response',
        'settlement_status',
        'certificates_url',
        'created_at',
        'updated_at',
        'deleted_at',
    ];

    public function status()
    {
        return $this->hasOne('App\Model\KindergartenDepositLogStatus', 'id');
    }

    /**
     * 通过ID获取一条数据
     * @param int $id
     * @return array
     */
    public static function getOne($id=0){
        if(!$id)return [];
        return self::from('kindergarten_deposit_log')
            ->where('id', $id)
            ->first();
    }

    /**
     * 根据时间查询相应的是否有开课证(查询已支付的订单判断开课证certificates_url是否为空)
     */
    public static function get_certificates_url($start_time,$end_time){
        return DB::connection('mysql_new')->select("select id,certificates_url from kindergarten_deposit_log where pay_time>='".$start_time."' and pay_time<='".$end_time."' and status=1 and type=2 and pay_status=1 and settlement_status=3 and (certificates_url is null or certificates_url='') ",[]);
    }

}
 

》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》

https://www.jb51.net/article/26861.htm

https://www.jb51.net/article/83837.htm

https://blog.csdn.net/liu85875669/article/details/53995139

https://www.zhaokeli.com/article/8031.html

http://www.kuitao8.com/20160616/4386.shtml

猜你喜欢

转载自blog.csdn.net/han_cui/article/details/86508135