zoukankan      html  css  js  c++  java
  • qrcode 生成二维码的代码

    <?php
    /**
     * 关于员工的信息处理
     * @author anyuan
     */
    namespace apprecruitcardservice;
    
    use appcommonbaseserviceBaseService;
    use applibraryErrorCode;
    use appmodelShopStaffInfo;
    use doushenframeResponseBath;
    use phpDocumentorReflectionTypesInteger;
    use Yii;
    use doushenrequestHttp;
    
    class RecruitStaffService extends BaseService
    {
        const STAFF_STATUS = 2;//员工状态-正常
        const STAFF_SOURCE_SCHOOL = 1;//正常分校老师
        const STAFF_SOURCE_ORGAN = 2;//机构
        const STAFF_SOURCE_JOIN = 4;//加盟校
        const STAFF_TITLE_COMMON = 3;//普通员工
        ####图片风格####
        const STAFF_CODE_STYLE_1 = 1;//大语文培优班
        const STAFF_CODE_STYLE_2 = 2;//大语文拔尖班
        const STAFF_CODE_STYLE_3 = 3;//写作拔尖班
        const STAFF_CODE_STYLE_4 = 4;//阅读拔尖班
        const STAFF_CODE_STYLE_5 = 5;//大语文王者班
        const STAFF_CODE_STYLE_6 = 6;//诸葛学堂
        ####图片风格####
        ####2020暑秋课程代理商分销图片风格####
        const STAFF_CODE_STYLE_SA_1 = 1;//暑期线上培优班
        const STAFF_CODE_STYLE_SA_2 = 2;//其他
        ####2020暑秋课程代理商分销图片风格####
        ####特殊机构####
        const ORGAN_CODE_STYLE_1 = 1;//大语文培优班
        const ORGAN_CODE_STYLE_2 = 2;//大语文拔尖班
        const ORGAN_CODE_STYLE_3 = 3;//写作拔尖班
        const ORGAN_CODE_STYLE_4 = 4;//阅读拔尖班
        const ORGAN_CODE_STYLE_5 = 5;//大语文王者班
        const ORGAN_CODE_STYLE_6 = 6;//诸葛学堂会员/大英语
        const ORGAN_CODE_STYLE_7 = 7;//理科前线
        const ORGAN_CODE_STYLE_8 = 8;//纳约数学
        const ORGAN_CODE_STYLE_9 = 9;//拼音识字
        const ORGAN_CODE_STYLE_10 = 10;//诸葛学堂课程分销
        ####特殊机构####
        const ORGAN_FLAG_KAISA = 10001;//凯撒旅游
        const ORGAN_FLAG_CCT_BJ = 10002;//北京康辉
        const ORGAN_FLAG_CCT_JS = 10003;//集善康辉
        const ORGAN_FLAG_CCT_QD = 10004;//青岛康辉
        const ORGAN_FLAG_CCT_HB = 10005;//湖北康辉
        const ORGAN_FLAG_CCT_JSU = 10006;//江苏康辉
        const ORGAN_FLAG_CCT_GL = 10007;//桂林康辉
        const ORGAN_FLAG_CCT_GX = 10008;//广西康辉
        const ORGAN_FLAG_CCT_SC = 10009;//四川康辉
        const ORGAN_FLAG_CCT_HN = 10010;//海南康辉
        const ORGAN_FLAG_CCT_GZ = 10011;//贵州康辉
        const ORGAN_FLAG_CCT_ZJ = 10012;//浙江康辉
        const ORGAN_FLAG_CCT_XA = 10013;//西安康辉
        const ORGAN_FLAG_CCT_GM = 10014;//昆明康辉
        const ORGAN_FLAG_CCT_SH = 10015;//上海康辉
        const ORGAN_FLAG_CCT_GS = 10016;//甘肃康辉
        const ORGAN_FLAG_CCT_AH = 10017;//安徽康辉
        const ORGAN_FLAG_CCT_HNA = 10018;//河南康辉
        const ORGAN_FLAG_CCT_DL = 10019;//大连康辉
        const ORGAN_FLAG_CCT_HLJ = 10020;//黑龙江康辉
        const ORGAN_FLAG_CCT_JX = 10021;//江西康辉
        const ORGAN_FLAG_CCT_NX = 10022;//宁夏康辉
        const ORGAN_FLAG_CCT_SD = 10023;//山东康辉
        const ORGAN_FLAG_CCT_HUN = 10024;//湖南康辉
        const ORGAN_FLAG_CCT_SZ = 10025;//深圳康辉
        const ORGAN_FLAG_CCT_QH = 10026;//青海康辉
        const ORGAN_FLAG_CCT_HUNX = 10027;//湖南新康辉国旅
        const ORGAN_FLAG_CCT_ST = 10028;//汕头康辉
        const ORGAN_FLAG_CCT_DG = 10029;//东莞康辉
        const ORGAN_FLAG_CCT_TJ = 10038;//天津康辉
        const ORGAN_FLAG_CCT_XJ = 10054;//新疆康辉
        const ORGAN_FLAG_LUYIZAITU = 10030;//旅途路易 安旅
        const ORGAN_FLAG_HELI = 10031;//禾力旅行
        const ORGAN_FLAG_XISHU = 10032;//義学书院
        const ORGAN_FLAG_DIERKETANG = 10033;//第二课堂
        const ORGAN_FLAG_JIUFANG = 10034;//九方书院
        const ORGAN_FLAG_RULIN = 10035;//儒林学院
        const ORGAN_FLAG_KANG = 10036;//康爸爸
        const ORGAN_FLAG_DOUSHENSHUANGSHI = 10037;//豆神双师
        const ORGAN_FLAG_KANGWEIXUETANG = 10039; //康微学堂
        const ORGAN_FLAG_HOUDEIJY = 10040; //厚德教育
        const ORGAN_FLAG_SUIXINKT = 10041; //随心课堂
        const ORGAN_FLAG_LISICHENLIUXUE = 10042; //立思辰留学
        const ORGAN_FLAG_LISICHENMEITEJY = 10043; //立思辰敏特教育
        const ORGAN_FLAG_LISICHENRTW_YXH = 10044; //立思辰瑞特威-新疆乌鲁木齐优学汇
        const ORGAN_FLAG_LISICHENRTW_XEZ = 10045; //立思辰瑞特威-新疆乌鲁木齐学而知
        const ORGAN_FLAG_LISICHENRTW_TXH = 10046; //立思辰瑞特威-新疆石河子市童学汇
        const ORGAN_FLAG_LISICHENRTW_WLWYJY = 10047; //立思辰瑞特威-新疆乌市联众文化艺术教育
        const ORGAN_FLAG_LISICHENRTW_XJBNYC = 10048; //立思辰瑞特威-新疆百年英才
        const ORGAN_FLAG_LISICHENQUYUFZ = 10049; //立思辰区域发展
        const ORGAN_FLAG_LISICHENJITUANZB = 10050; //立思辰集团总部
        const ORGAN_FLAG_LISICHENBAINIANYC = 10051; //立思辰百年英才
        const ORGAN_FLAG_LISICHENZONGBUKANGB = 10052; //立思辰总部康邦
        const ORGAN_FLAG_LISICHENZONGBUNX = 10053; //立思辰总部宁夏
        const ORGAN_FLAG_LISICHENKUAXUEWANG = 10055; //立思辰跨学网
        const ORGAN_FLAG_LISICHENJTSHICHANGBU = 10056; //立思辰集团市场部
        const ORGAN_FLAG_YIQI= 10057; //易启
        const ORGAN_FLAG_ZHONGQIAOGUOLV= 10058; //中侨国旅
        const ORGAN_FLAG_LISICHENHUIRONGEXUE= 10059; //立思辰集团 汇融e学
        const ORGAN_FLAG_GAINIANXING= 10060; //概念行
        const ORGAN_FLAG_LAOJIN = 10061;//老金
        const ORGAN_FLAG_CAICAI = 10062;//蔡蔡
        const ORGAN_FLAG_ZJXT = 10063;//诸葛学堂课程分销
        const ORGAN_ARRAY = array(10001,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,
                                    10016,10017,10018,10019,10020,10021,10022,10023,10024,10025,10026,10027,10028,10029,10030,
                                    10031,10032,10033,10034,10035,10036,10037,10038,10039,10040,10041,10042,10043,10044,10045,
                                    10046,10047,10048,10049,10050,10051,10052,10053,10054,10055,10056,10057,10058,10059,10060,
                                    10061,10062,10063);
        const ORGAN_NO_DEPARTMENT_INITIAL_ARRAY = array(10001,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,
            10016,10017,10018,10019,10020,10021,10022,10023,10024,10025,10026,10027,10028,10029,10030,
            10031,10032,10033,10034,10035,10036,10037,10038,10039,10040,10041,10054,10057,10058,10060,10061,10062,10063);  //非立思辰集团子公司机构
        const ORGAN_NO_DEPARTMENT_LATER_ARRAY = array(
            10042,10043,10044,10045,10046,10047,10048,10053,10055,10056,10059
        );//后加的没有部门的机构
        const ORGAN_DEPARTMENT_LATER_ARRAY = array(
            10049,10050,10051,10052
        );//后来的有部门的机构
        const ORGAN_CHANNEL_ARRAY = array(
            10047,10049,10050,10051,10052,10055,10056
        );//后加的有二级渠道的
        const ORGAN_LONG_MAP_TIME = array(10062);
        const ORGAN_DEPARTMENT_INFO = array(
            self::ORGAN_FLAG_LISICHENQUYUFZ => array(
                "总经办",
                "综合管理部",
                "项目实施部",
                "外企与国际教育事业部",
                "售前咨询部",
                "区域教育事业部-鲁西南",
                "区域教育事业部-华中",
                "区域教育事业部-华南",
                "区域教育事业部-华北",
                "军校与集成事业部",
            ),
            self::ORGAN_FLAG_LISICHENJITUANZB => array(
                "总裁办",
                "人力资源管理中心",
                "财务管理中心",
                "行政管理中心",
                "物业管理中心",
                "投资管理与金融合作部",
                "战略与创新发展部",
                "证券事务部",
                "市场部",
                "互联网运营部",
                "风险管理部",
                "公共关系部",
                "信息安全集团",
            ),
            self::ORGAN_FLAG_LISICHENBAINIANYC => array(
                "市场部",
            ),
            self::ORGAN_FLAG_LISICHENZONGBUKANGB => array(
                "业务三部",
                "业务四部",
                "业务五部",
                "业务六部",
                "业务七部",
                "业务八部",
                "新渠道事业部",
                "郑州分公司",
                "天津分公司",
                "上海分公司",
                "济南分公司",
                "南京分公司",
                "成都分公司",
                "西南大区",
            ),
        );//有部门的机构 详细部门信息
        const ORGAN_CCT_ARRAY = array(10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10012,10013,10014,10015,
            10016,10017,10018,10019,10020,10021,10022,10023,10024,10025,10026,10027,10028,10029,10038,10054);//其实都是康辉的,不同城市区分
        public static $name;
        public static $city;
        public static $city_id;
        public static $campus;
        public static $campus_id;
        public static $staff_source;
        public static $id;
        public static $title;
        private static $jiangsusanxiao = ['常熟分校','张家港分校','江阴分校'];//江苏三校
        private static $special_school = ['台州分校','湘潭分校','长春分校'];//三个特殊的分校走全国
        public static $second_id;
        /**
         * 验证员工身份正确性
         * @param int $tel
         * @param string $name
         * @return bool
         */
        public static function checkStaff(int $tel, string $name ) {
            #验证信息
            $staff_info = ShopStaffInfo::find()->select('id,city,staff_source,city_id,campus,campus_id,title')
                ->where(['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'name'=>trim($name)])->asArray()->one();
            if (!$staff_info) {
                return false;
            }
            #赋值 为创建二维码省一条sql
            self::$name = $name;
            self::$city = $staff_info['city'];
            self::$city_id = $staff_info['city_id'];
            self::$campus = $staff_info['campus'];
            self::$campus_id = $staff_info['campus_id'];
            self::$staff_source = $staff_info['staff_source'];
            self::$id = $staff_info['id'];
            self::$title = $staff_info['title'];
    
            return true;
        }
    
        /**
         * 验证员工身份正确性
         * @param int $tel
         * @param string $name
         * @return bool
         */
        public static function checkStaffWithSource(int $tel, string $name, int $staff_source ) {
            #验证信息
            $staff_info = ShopStaffInfo::find()->select('id,city,staff_source,city_id,campus,campus_id,title')
                ->where(['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'name'=>trim($name), 'staff_source'=>$staff_source])->asArray()->one();
            if (!$staff_info) {
                return false;
            }
    
            #赋值 为创建二维码省一条sql
            self::$name = $name;
            self::$city = $staff_info['city'];
            self::$city_id = $staff_info['city_id'];
            self::$campus = $staff_info['campus'];
            self::$campus_id = $staff_info['campus_id'];
            self::$staff_source = $staff_info['staff_source'];
            self::$id = $staff_info['id'];
            self::$title = $staff_info['title'];
    
            return true;
        }
    
        public static function checkDistributestaff(int $tel, string $name ) {
            #验证信息
            $staff_info = ShopStaffInfo::find()->select('id,city,staff_source,city_id,campus,campus_id,title')
                ->where(['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'name'=>trim($name),"staff_source"=>100001])->asArray()->one();
            if (!$staff_info) {
                return false;
            }
            #赋值 为创建二维码省一条sql
            self::$name = $name;
            self::$city = $staff_info['city'];
            self::$city_id = $staff_info['city_id'];
            self::$campus = $staff_info['campus'];
            self::$campus_id = $staff_info['campus_id'];
            self::$staff_source = $staff_info['staff_source'];
            self::$id = $staff_info['id'];
            self::$title = $staff_info['title'];
    
            return true;
        }
    
        /**
         * 以手机号验证机构 没有则添加,有则修改名字
         * @param int $tel
         * @param string $name
         * @return bool
         */
        public static function CheckOrgan (int $tel, string $name,int $organ,int $second,string $second_name, string $department)
        {
            $where = ['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'staff_source'=>$organ];
            if ($department) {
                $data['org_department'] = trim($department);
    //            $where['org_department'] = trim($department);
            }
            $staff_info = ShopStaffInfo::find()->select('id,staff_source')
                ->where($where)->asArray()->one();
            if ($staff_info) {
                #修改
                $data['name'] = $name;
                ShopStaffInfo::getDb()->createCommand()->update(ShopStaffInfo::tableName(), $data,
                    'id = ' . $staff_info['id'] )->execute();
            } else {
                #添加
                $data['name'] = $name;
                $data['staff_source'] = $organ;
                $data['tel'] = trim($tel);
                ShopStaffInfo::getDb()->createCommand()->insert(ShopStaffInfo::tableName(),
                    $data)->execute();//未生成
                $staff_info = ShopStaffInfo::find()->select('id,staff_source')
                    ->where($where)->asArray()->one();
            }
            if ($second) {
                #查看二级渠道是否存在
                $second_info = ShopStaffInfo::find()->select('id,staff_source')
                    ->where(['name'=>$second_name,'from_staff_id'=>$staff_info['id']])->asArray()->one();
                if (!$second_info) {
                    ShopStaffInfo::getDb()->createCommand()->insert(ShopStaffInfo::tableName(),
                        ['name'=>$second_name,'from_staff_id'=>$staff_info['id'],'staff_source'=>$organ])->execute();//未生成
                    #这块需要改进下,省掉这条sql
                    $second_info = ShopStaffInfo::find()->select('id,staff_source')
                        ->where(['name'=>$second_name,'from_staff_id'=>$staff_info['id']])->asArray()->one();
                }
                self::$second_id = $second_info['id'];
            }
        }
    
        /**
         * 判断二级渠道是否存在
         */
        public static function chekSecond (int $tel, string $name,int $organ,int $second,string $second_name, string $department)
        {
            $where = ['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'staff_source'=>$organ];
            if ($department) {
                $data['org_department'] = trim($department);
            }
            $staff_info = ShopStaffInfo::find()->select('id,staff_source')
                ->where($where)->asArray()->one();
            if (!$staff_info) {
                return false;
            }
            if ($second) {
                #查看二级渠道是否存在
                $second_info = ShopStaffInfo::find()->select('id,staff_source')
                    ->where(['name'=>$second_name,'from_staff_id'=>$staff_info['id']])->asArray()->one();
                if (!$second_info) {
                    #当二级渠道不存在时生成对应的二级渠道
                    ShopStaffInfo::getDb()->createCommand()->insert(ShopStaffInfo::tableName(),
                        ['name'=>$second_name,'from_staff_id'=>$staff_info['id'],'staff_source'=>$organ])->execute();//未生成
                    $second_info = ShopStaffInfo::find()->select('id,staff_source')
                        ->where(['name'=>$second_name,'from_staff_id'=>$staff_info['id']])->asArray()->one();
                }
                self::$second_id = $second_info['id'];
            }
            return true;
        }
    
        /**
         * 生成用户二维码
         * @param
         */
        public static function get_qr_code($tel, int $action)
        {
            #生成二维码底图选择
            if ($action == self::STAFF_CODE_STYLE_1) {
                $code_x = 586;   $code_y = 2930;
                $text1_x = 20;   $text1_y = 2950;
                $text2_x = 20;   $text2_y = 2992;
                $text3_x = 20;   $text3_y = 3032;
                $red = 255; $green = 255; $blue = 255;
                $imagePath = '/library/gentlemanImg/staff1.png';//大语文培优班
            } elseif ($action == self::STAFF_CODE_STYLE_2) {
                $code_x = 586;   $code_y = 3150;
                $text1_x = 20;   $text1_y = 3170;
                $text2_x = 20;   $text2_y = 3212;
                $text3_x = 20;   $text3_y = 3252;
                $red = 0; $green = 0; $blue = 0;
                $imagePath = '/library/gentlemanImg/staff2.png';//大语文拔尖班
            }elseif ($action == self::STAFF_CODE_STYLE_3) {
                $code_x = 586;   $code_y = 2730;
                $text1_x = 20;   $text1_y = 2750;
                $text2_x = 20;   $text2_y = 2792;
                $text3_x = 20;   $text3_y = 2832;
                $red = 0; $green = 0; $blue = 0;
                $imagePath = '/library/gentlemanImg/staff3.png';//大语文拔尖班
            }elseif ($action == self::STAFF_CODE_STYLE_4) {
                $code_x = 586;   $code_y = 2730;
                $text1_x = 25;   $text1_y = 2750;
                $text2_x = 25;   $text2_y = 2792;
                $text3_x = 25;   $text3_y = 2832;
                $red = 0; $green = 0; $blue = 0;
                $imagePath = '/library/gentlemanImg/staff4.png';//大语文拔尖班
            }elseif ($action == self::STAFF_CODE_STYLE_5) {
                $code_x = 586;   $code_y = 3230;
                $text1_x = 20;   $text1_y = 3250;
                $text2_x = 20;   $text2_y = 3292;
                $text3_x = 20;   $text3_y = 3332;
                $red = 0; $green = 0; $blue = 0;
                $imagePath = '/library/gentlemanImg/staff5.png';//大语文拔尖班
            }elseif ($action == self::STAFF_CODE_STYLE_6){
                $code_x = 586;   $code_y = 2930;
                $text1_x = 20;   $text1_y = 2950;
                $text2_x = 20;   $text2_y = 2992;
                $text3_x = 20;   $text3_y = 3032;
                $text4_x = 20;   $text4_y = 3072;
                $red = 255; $green = 255; $blue = 255;
                $imagePath = '/library/gentlemanImg/staff6.png';//诸葛学堂会员
            } else {
                return ['check' => false,'data' => '生成二维码底图参数错误'];
            }
            #特殊校区的校验跳转
            if (in_array(trim(self::$city),self::$jiangsusanxiao) ) {
                self::$city_id = 1003;//江苏三校
            } elseif (in_array(trim(self::$city),self::$special_school) ) {
                self::$city_id = 1002;//全国
            } elseif (mb_substr(self::$city,-2,2) == "分校" && !self::$city_id) {
                self::$city_id = 1002;//有分校名称,但是未找到school_id异常的
            }
            //跳转地址
            $path = '/tmp/recruitcard';
            if (self::$staff_source != self::STAFF_SOURCE_SCHOOL) {//机构或加盟校
                if (self::$staff_source == self::STAFF_SOURCE_JOIN) {//加盟校
                    $url = "https://bm.zhugexuetang.com?school_id=".self::$city_id."&fromEntrance=2&entrance=2&staff_code=";
                    $text = '大语文'.str_replace('分校','',self::$city).self::$campus.'诚挚为您推荐';
                } else {//机构
                    $url = "https://bm.zhugexuetang.com?fromEntrance=1&entrance=2&staff_code=";//bm.zhugexuetang.com
                    $text = self::$name.'诚挚为您推荐豆神大语文';
                }
            } else {//分校
                if (self::$title == self::STAFF_TITLE_COMMON) {//普通员工
                    if (mb_substr(self::$city,-2,2) == "分校") {//存在分校字段
                        $url = "https://bm.zhugexuetang.com?school_id=".self::$city_id."&fromEntrance=2&entrance=2&staff_code=";
                        $text = '我是'.self::$name.'老师,很荣幸为您推荐';
                    } else {
                        $url = "https://bm.zhugexuetang.com?fromEntrance=1&entrance=2&staff_code=";
                        $text = '我是'.self::$name.'老师,很荣幸为您推荐';
                    }
                } else {//绩效员工
                    if (mb_substr(self::$city,-2,2) == "分校") {//存在分校字段
                        $url = "https://bm.zhugexuetang.com?school_id=".self::$city_id."&fromEntrance=2&entrance=2&staff_code=";
                        $text = '我是'.self::$name.'老师,很荣幸为您推荐';
                    } else {
                        $url = "https://bm.zhugexuetang.com?fromEntrance=1&entrance=2&staff_code=";
                        $text = '我是'.self::$name.'老师,很荣幸为您推荐';
                    }
                }
            }
    
            // 诸葛学堂链接
            if($action == self::STAFF_CODE_STYLE_6){
                $url = "https://m.zhugexuetang.com/zgxt_vip?source=135&staff_code=";
            }
    
            $code = self::get_qr_tel($tel);
            $staff_code = self::$staff_source.'_'.self::$city_id.'_'.self::$campus_id.'_'.$code;
            #会写员工表code
            self::updateInfoData(['code'=>$staff_code],['id'=>self::$id]);
            if (!is_dir($path)) {
                @mkdir($path);
            }
            include(ROOT_PATH . '/library/phpqrcode/qrlib.php');
            $qrcodePath = $path . '/' . $tel . '.png';
            QRcode::png($url.$staff_code, $qrcodePath, 3, 2);
    
            #制作图片
            #原始图像
            $dst = (ROOT_PATH . $imagePath);
            #得到原始图片信息
            $dst_im1 = imagecreatefrompng($dst);
            $dst_info1 = getimagesize($dst);
            #二维码图片
            $src1 = $qrcodePath;
            $src1_im = imagecreatefrompng($src1);
            $src1_info = getimagesize($src1);
            #合并水印图片
            imagecopymerge($dst_im1,$src1_im,$code_x,$code_y,0,0,$src1_info[0],$src1_info[1],100);
            #合成图片的路径
            $path = '/tmp/gentlemancard';
            if (!is_dir($path)) {
                @mkdir($path);
            }
            $poster_marge_path =$path . '/' . date('Y-m-d').'-'.$tel . '.png';
            #输出合并后水印图片
            ob_start();
            imagepng($dst_im1,$poster_marge_path);
            imagedestroy($dst_im1);
            imagedestroy($src1_im);
    
            #添加图片文字
            $dst_path = $poster_marge_path;
            $dst_new = imagecreatefromstring(file_get_contents($dst_path));
            $font = (ROOT_PATH . '/library/gentlemanImg/fzlthk.ttf');
            $im = imagecreatetruecolor(400, 30);
            $colour =imagecolorallocate($im, $red,$green,$blue);
            #判断字数
            $size = 20;
            if (mb_strlen($text) > 16) {
                $size = 15;
            }
            imagefttext($dst_new, $size, 0,$text1_x, $text1_y, $colour, $font, $text);//城市
            if($action == self::STAFF_CODE_STYLE_6){
                imagefttext($dst_new, $size, 0,$text2_x, $text2_y, $colour, $font, '诸葛学堂会员大礼包');
                imagefttext($dst_new, $size, 0,$text3_x, $text3_y, $colour, $font, '愿你畅游文化世界');
                imagefttext($dst_new, $size, 0,$text4_x, $text4_y, $colour, $font, '扫描右方二维码即可购买');
            }else{
                imagefttext($dst_new, $size, 0,$text2_x, $text2_y, $colour, $font, '扫描右方二维码会看到');
                imagefttext($dst_new, $size, 0,$text3_x, $text3_y, $colour, $font, '最适合您孩子的1~4个班级');
            }
            header('Content-type: image/png');
            imagepng($dst_new);
            @unlink($dst_new);
            $sImage = ob_get_contents();
            ob_end_clean();
            $base64_img = base64_encode($sImage);
            @unlink($qrcodePath);
    
            return ['check' => true,'data' => $base64_img];
    
        }
    
        /**
         * 生成用户分销二维码-99元分销
         * @param $tel
         * @param int $action
         * @return array
         */
        public static function get_dr_code($tel)
        {
            #生成二维码底图选择
            $code_x = 521;   $code_y = 1188;
            $imagePath = '/library/gentlemanImg/distribute99.png';//大语文培优班
            //跳转地址
            $path = '/tmp/recruitcarddistribute';
    //        $url = "https://bm.zhugexuetang.com?school_id=".self::$city_id."&fromEntrance=2&entrance=2&staff_code=";  //测试地址春季招生的无用
    //        $url = "http://bmdev.zhugexuetang.com/activity/ninety-nine/classlist?school_id=".self::$city_id."&fromEntrance=3&entrance=3&staff_code=";//测试地址
            $url = "https://jm.doushen.com/activity/99list?school_id=".self::$city_id."&fromEntrance=3&entrance=3&staff_code=";
    
            $code = self::get_qr_tel($tel);
            $staff_code = self::$staff_source.'_'.self::$city_id.'_'.self::$campus_id.'_'.$code;
            #会写员工表code
            self::updateInfoData(['code'=>$staff_code],['id'=>self::$id]);
            if (!is_dir($path)) {
                @mkdir($path);
            }
            include(ROOT_PATH . '/library/phpqrcode/qrlib.php');
            $qrcodePath = $path . '/' . $tel . '.png';
            QRcode::png($url.$staff_code, $qrcodePath, 3, 2);
    
            #制作图片
            #原始图像
            $dst = (ROOT_PATH . $imagePath);
            #得到原始图片信息
            $dst_im1 = imagecreatefrompng($dst);
            $dst_info1 = getimagesize($dst);
            #二维码图片
            $src1 = $qrcodePath;
    
            $src1_im = imagecreatefrompng($src1);
            $src1_info = getimagesize($src1);
            #合并水印图片
            imagecopymerge($dst_im1,$src1_im,$code_x,$code_y,0,0,$src1_info[0],$src1_info[1],100);
            #合成图片的路径
            $path = '/tmp/distribute';
            if (!is_dir($path)) {
                @mkdir($path);
            }
            $poster_marge_path =$path . '/' . date('Y-m-d').'-'.$tel . '.png';
            #输出合并后水印图片
            ob_start();
            imagepng($dst_im1,$poster_marge_path);
    
            imagedestroy($dst_im1);
            imagedestroy($src1_im);
    
            #添加图片文字
            $dst_path = $poster_marge_path;
            $dst_new = imagecreatefromstring(file_get_contents($dst_path));
            header('Content-type: image/png');
            imagepng($dst_new);
            @unlink($dst_new);
            $sImage = ob_get_contents();
            ob_end_clean();
            $base64_img = base64_encode($sImage);
            @unlink($qrcodePath);
    
            return ['check' => true,'data' => $base64_img];
    
        }
    
        /**
         * 生成用户分销二维码-2020暑秋课程代理商分销
         * @param $tel
         * @param int $action
         * @return array
         */
        public static function get_sa_qr_code($tel, $name = '', $organ, $action, $second)
        {
            if ($action == self::STAFF_CODE_STYLE_SA_1) {
                $code_xy = "231,450";
                $imagePath = '/library/sa_distribute_2020/sadistribute2.png';
                $url = "https://bm.zhugexuetang.com?school_id=".self::$city_id."&fromEntrance=4&entrance=4&staff_code=";  //正式地址春季招生的无用
                // $url = "http://bmdev.zhugexuetang.com/activity/ninety-nine/classlist?school_id=".self::$city_id."&fromEntrance=4&entrance=4&staff_code=";//测试地址
                $text = [$name];
                $textCoordinates = ['325,357'];
                $color = '116,87,58';
                $size = 25;
                $code_level = 5;
            } elseif ($action == self::STAFF_CODE_STYLE_SA_2) {
                $code_xy = "231,450";
                $imagePath = '/library/sa_distribute_2020/sadistribute1.png';
                $url = "https://jm.doushen.com/activity/99newlist?school_id=".self::$city_id."&fromEntrance=4&entrance=4&staff_code=";
                $text = [$name];
                $textCoordinates = ['325,357'];
                $color = '116,87,58';
                $size = 25;
                $code_level = 4;
            }
    
            #生成organ_code并加入二维码的跳转url中,然后回写至shop_staff_info表
            $code = self::get_qr_tel($tel);
            $organ_code = $organ.'_0_0_'.$code;
            if ($second) {//二级机构
                $organ_code = $organ_code.':'.self::$second_id;
            }
            #回写员工表code
            if ($second) {
                $staff_info = ShopStaffInfo::find()->select('id')
                    ->where(['is_deleted'=>self::STAFF_STATUS,'id'=>self::$second_id])->asArray()->one();
            } else {
                $staff_info = ShopStaffInfo::find()->select('id')
                    ->where(['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'staff_source'=>$organ])->asArray()->one();
            }
            self::updateInfoData(['code'=>$organ_code],['id'=>$staff_info['id']]);
            #url中增加organ_code
            $url .= $organ_code;
    
            $return = self::CreatCard($url,$imagePath,$code_xy,$text,$textCoordinates,$color,$size,$code_level);
            if ($return['check'] == false) {
                return false;
            }
            // echo "<img src="data:image/png;base64,".$return["data"].""/>";
            return $return;
        }
    
        /**
         * 生成特殊机构二维码
         * @param $tel
         * @param int $action
         */
        public static function get_organ_card ($tel, int $action,$organ,$name,$second,$second_name) {
            #生成二维码底图选择
            if ($organ == self::ORGAN_FLAG_KAISA) {
                $fileCata = "kaisa";
                $text = [
                    '战略合作伙伴凯撒旅游'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "战略合作伙伴凯撒旅游".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=120';//http://m.dev.zhugexuetang.com/zgxt_vip
                }
            } elseif (in_array($organ,self::ORGAN_CCT_ARRAY)) {//康辉
                if ($organ == self::ORGAN_FLAG_CCT_BJ) {
                    $organ_name = '北京';
                } elseif ($organ == self::ORGAN_FLAG_CCT_JS) {
                    $organ_name = '集善';
                } elseif ($organ == self::ORGAN_FLAG_CCT_QD) {
                    $organ_name = '青岛';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HB) {
                    $organ_name = '湖北';
                } elseif ($organ == self::ORGAN_FLAG_CCT_JSU) {
                    $organ_name = '江苏';
                } elseif ($organ == self::ORGAN_FLAG_CCT_GL) {
                    $organ_name = '桂林';
                } elseif ($organ == self::ORGAN_FLAG_CCT_GX) {
                    $organ_name = '广西';
                } elseif ($organ == self::ORGAN_FLAG_CCT_SC) {
                    $organ_name = '四川';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HN) {
                    $organ_name = '海南';
                } elseif ($organ == self::ORGAN_FLAG_CCT_GZ) {
                    $organ_name = '贵州';
                } elseif ($organ == self::ORGAN_FLAG_CCT_ZJ) {
                    $organ_name = '浙江';
                } elseif ($organ == self::ORGAN_FLAG_CCT_XA) {
                    $organ_name = '西安';
                } elseif ($organ == self::ORGAN_FLAG_CCT_GM) {
                    $organ_name = '昆明';
                } elseif ($organ == self::ORGAN_FLAG_CCT_SH) {
                    $organ_name = '上海';
                } elseif ($organ == self::ORGAN_FLAG_CCT_GS) {
                    $organ_name = '甘肃';
                } elseif ($organ == self::ORGAN_FLAG_CCT_AH) {
                    $organ_name = '安徽';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HNA) {
                    $organ_name = '河南';
                } elseif ($organ == self::ORGAN_FLAG_CCT_DL) {
                    $organ_name = '大连';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HLJ) {
                    $organ_name = '黑龙江';
                } elseif ($organ == self::ORGAN_FLAG_CCT_JX) {
                    $organ_name = '江西';
                } elseif ($organ == self::ORGAN_FLAG_CCT_NX) {
                    $organ_name = '宁夏';
                } elseif ($organ == self::ORGAN_FLAG_CCT_SD) {
                    $organ_name = '山东';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HUN) {
                    $organ_name = '湖南';
                } elseif ($organ == self::ORGAN_FLAG_CCT_SZ) {
                    $organ_name = '深圳';
                } elseif ($organ == self::ORGAN_FLAG_CCT_QH) {
                    $organ_name = '青海';
                } elseif ($organ == self::ORGAN_FLAG_CCT_HUNX) {
                    $organ_name = '湖南新康辉国旅';
                } elseif ($organ == self::ORGAN_FLAG_CCT_ST) {
                    $organ_name = '汕头';
                } elseif ($organ == self::ORGAN_FLAG_CCT_DG) {
                    $organ_name = '东莞';
                } elseif ($organ == self::ORGAN_FLAG_CCT_TJ){
                    $organ_name = "天津";
                } elseif ($organ == self::ORGAN_FLAG_CCT_XJ){
                    $organ_name = "新疆";
                }
                $fileCata = "CCT";
                $text = [
                    $organ_name.'康辉旅游'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($organ == self::ORGAN_FLAG_CCT_HUNX) {
                    $text = [
                        $organ_name.$name,
                        '愿您足不出户纵览文学世界',
                        '停课不停学,学好大语文,做有修养的中国人',
                        '扫描右方二维码会看到最适合您孩子的1~4个班级'
                    ];
                }
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        $organ_name."康辉旅游".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    if ($organ == self::ORGAN_FLAG_CCT_HUNX) {
                        $text = [
                            $organ_name.$name,
                            '诚挚为您推荐诸葛学堂会员大礼包',
                            '愿你畅游文化世界',
                            '扫描右方二维码即可购买'
                        ];
                    }
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=121';
                }
            } elseif ($organ == self::ORGAN_FLAG_LUYIZAITU) {
                $fileCata = "luyizaitu";
                $text = [
                    '路易在途'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "路易在途".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=122';
                }
            } elseif ($organ == self::ORGAN_FLAG_HELI) {
                $fileCata = "heli";
                $text = [
                    '禾力旅行'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "禾力旅行".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=123';
                }
            } elseif ($organ == self::ORGAN_FLAG_XISHU) {
                $fileCata = "other";
                $text = [
                    '義学书院'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "義学书院".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=124';
                }
            } elseif ($organ == self::ORGAN_FLAG_DIERKETANG) {
                $fileCata = "other";
                $text = [
                    '第二课堂'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "第二课堂".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=125';
                }
            } elseif ($organ == self::ORGAN_FLAG_JIUFANG) {
                $fileCata = "other";
                $text = [
                    '九方书院'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "九方书院".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=126';
                }
            } elseif ($organ == self::ORGAN_FLAG_RULIN) {
                $fileCata = "other";
                $text = [
                    '儒林学院'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "儒林学院".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=127';
                }
            } elseif ($organ == self::ORGAN_FLAG_KANG) {
                $fileCata = "other";
                $text = [
                    '康爸爸'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "康爸爸".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=128';
                }
            } elseif ($organ == self::ORGAN_FLAG_DOUSHENSHUANGSHI) {
                $fileCata = "doushenshuangshi";
                $text = [
                    '豆神双师'.$name,
                    '诚挚为您推荐豆神大语文',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级',
                ];
                if ($action == self::ORGAN_CODE_STYLE_3 || $action == self::ORGAN_CODE_STYLE_4 || $action == self::ORGAN_CODE_STYLE_5) {
                    return ['check' => false,'data' => '豆神双师只有大语文拔尖班,培优班海报哦!'];
                }
            } elseif ($organ == self::ORGAN_FLAG_KANGWEIXUETANG){
                //康微学堂
                $fileCata = "other";
                $text = [
                    '康微学堂'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "康微学堂".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=129';
                }
            } elseif ($organ == self::ORGAN_FLAG_HOUDEIJY){
                //厚德教育
                $fileCata = "other";
                $text = [
                    '兰德文化教育'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "兰德文化教育".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=130';
                }
            } elseif ($organ == self::ORGAN_FLAG_SUIXINKT){
                //随心课堂
                $fileCata = "other";
                $text = [
                    '随心课堂'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "随心课堂".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=131';
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENLIUXUE){
                $fileCata = "lsc_other";
                $text = [
                    '立思辰留学'.$name,
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENMEITEJY){
                $fileCata = "minte";
                $text = [
                    '敏特教育'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENRTW_YXH){
                $fileCata = "lsc_other";
                $text = [
                    '优学汇'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENRTW_XEZ){
                $fileCata = "lsc_other";
                $text = [
                    '学而知'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENRTW_TXH){
                $fileCata = "lsc_other";
                $text = [
                    '童学汇'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENRTW_WLWYJY){
                $fileCata = "lianzhong";
                $text = [
                    '联众教育培训学校'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        '联众教育-'.$second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENRTW_XJBNYC){
                $fileCata = "xj_bainianyingcai";
                $text = [
                    '新疆百年英才'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif ($organ == self::ORGAN_FLAG_LISICHENQUYUFZ){
                $fileCata = "lsc_other";
                $text = [
                    '立思辰区域'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENJITUANZB){
                $fileCata = "lsc_other";
                $text = [
                    '立思辰集团'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENBAINIANYC){
                $fileCata = "lsc_bainianyingcai";
                $text = [
                    '百年英才'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENZONGBUKANGB){
                $fileCata = "lsc_other";
                $text = [
                    '康邦科技'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            } elseif ($organ == self::ORGAN_FLAG_LISICHENZONGBUNX){
                $fileCata = "lsc_other";
                $text = [
                    '我是窦昕老师',
                    '很荣幸为您推荐,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            } elseif($organ == self::ORGAN_FLAG_LISICHENKUAXUEWANG){
                $fileCata = "lsc_other";
                $text = [
                    '跨学网'.$name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            }elseif($organ == self::ORGAN_FLAG_LISICHENJTSHICHANGBU){
                $fileCata = "lsc_other";
                $text = [
                     $name.'老师',
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
                if ($second) {//二级渠道
                    $text = [
                        $second_name,
                        '诚挚为您推荐豆神大语文,',
                        '扫描右方二维码',
                        '会看到最适合您孩子的1~4个班级'
                    ];
                }
            }elseif($organ == self::ORGAN_FLAG_YIQI){
                //易启
                $fileCata = "other";
                $text = [
                    '易启'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "易启".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=133';
                }
            }elseif($organ == self::ORGAN_FLAG_ZHONGQIAOGUOLV){
                $fileCata = "zhongqiaoguolv";
                $text = [
                    '中侨国旅'.$name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "中侨国旅".$name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=134';
                }
            }elseif($organ == self::ORGAN_FLAG_LISICHENHUIRONGEXUE){
                $fileCata = "huirongexue";
                $text = [
                    $name,
                    '诚挚为您推荐豆神大语文,',
                    '扫描右方二维码',
                    '会看到最适合您孩子的1~4个班级'
                ];
            }elseif($organ == self::ORGAN_FLAG_GAINIANXING){
                $fileCata = "gainianxing";
                $text = [
                     $name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        "我是".$name,
                        '很荣幸为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=137';
                }
            } elseif($organ == self::ORGAN_FLAG_LAOJIN) {
                //老金
                $fileCata = "other";
                $text = [
                    $name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        $name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=138';
                }
            } elseif($organ == self::ORGAN_FLAG_CAICAI) {
                //蔡蔡机构
                $fileCata = "other";
                $text = [
                    $name,
                    '愿您足不出户纵览文学世界',
                    '停课不停学,学好大语文,做有修养的中国人',
                    '扫描右方二维码会看到最适合您孩子的1~4个班级'
                ];
                if ($action == self::ORGAN_CODE_STYLE_6) {
                    $text = [
                        $name,
                        '诚挚为您推荐诸葛学堂会员大礼包',
                        '愿你畅游文化世界',
                        '扫描右方二维码即可购买'
                    ];
                    $newUrl = 'https://m.zhugexuetang.com/zgxt_vip?source=139';
                }
            }elseif($organ == self::ORGAN_FLAG_ZJXT) {
                //诸葛学堂
                $fileCata = "other";
                $text = [
                    '',
                    '',
                    '',
                    ''
                ];
                // if ($action == self::ORGAN_CODE_STYLE_6) {
                //     $text = [
                //         $name,
                //         '诚挚为您推荐诸葛学堂会员大礼包',
                //         '愿你畅游文化世界',
                //         '扫描右方二维码即可购买'
                //     ];
                    $newUrl = 'https://m.zhugexuetang.com/zhugexuetang/course?type=10004';//正式
                    // $newUrl = 'http://m.dev.zhugexuetang.com/zhugexuetang/course?type=10004';//测试
                // }
            }
            #生成code
            $code = self::get_qr_tel($tel);
            $organ_code = $organ.'_0_0_'.$code;
            if ($second) {//二级机构
                $organ_code = $organ_code.':'.self::$second_id;
            }
            #二维码调整链接
            $url = "https://bm.zhugexuetang.com?fromEntrance=1&entrance=2&staff_code=".$organ_code; //打开注释
    
            #机构区分
            if (in_array($organ,array_diff(self::ORGAN_ARRAY,self::ORGAN_NO_DEPARTMENT_INITIAL_ARRAY))) {//立思辰下集团
                if ($action == self::ORGAN_CODE_STYLE_1) {
                    $code_xy = '590,2930';
                    $text1_xy = '20,2940';
                    $text2_xy = '20,2975';
                    $text3_xy = '20,3010';
                    $text4_xy = '20,3045';
                    $color = '0,0,88';
                    $imagePath = '/library/'.$fileCata.'/1.png';//大语文培优班
                } elseif ($action == self::ORGAN_CODE_STYLE_2) {
                    $code_xy = '590,3160';
                    $text1_xy = '20,3170';
                    $text2_xy = '20,3205';
                    $text3_xy = '20,3240';
                    $text4_xy = '20,3275';
                    $color = '0,0,0';
                    $imagePath = '/library/'.$fileCata.'/2.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_3) {
                    $code_xy = '590,2740';
                    $text1_xy = '20,2750';
                    $text2_xy = '20,2785';
                    $text3_xy = '20,2820';
                    $text4_xy = '20,2855';
                    $color = '0,0,0';
                    $imagePath = '/library/'.$fileCata.'/3.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_4) {
                    $code_xy = '590,2740';
                    $text1_xy = '20,2750';
                    $text2_xy = '20,2785';
                    $text3_xy = '20,2820';
                    $text4_xy = '20,2855';
                    $color = '0,0,0';
                    $imagePath = '/library/'.$fileCata.'/4.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_5) {
                    $code_xy = '590,3220';
                    $text1_xy = '20,3230';
                    $text2_xy = '20,3265';
                    $text3_xy = '20,3305';
                    $text4_xy = '20,3345';
                    $color = '0,0,0';
                    $imagePath = '/library/'.$fileCata.'/5.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_6) {
                    $code_xy = '850,3950';
                    $text1_xy = '50,4010';
                    $text2_xy = '50,4045';
                    $text3_xy = '50,4080';
                    $text4_xy = '50,4115';
                    $color = '0,0,179';
                    $imagePath = '/library/'.$fileCata.'/6.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_8) {
                    $code_xy = '850,6150';
                    $text1_xy = '50,6210';
                    $text2_xy = '50,6245';
                    $text3_xy = '50,6280';
                    $text4_xy = '50,6315';
                    $color = '0,0,88';
                    $imagePath = '/library/'.$fileCata.'/8.png';
                }  elseif ($action == self::ORGAN_CODE_STYLE_9) {
                    $code_xy = '850,3950';
                    $text1_xy = '50,4010';
                    $text2_xy = '50,4045';
                    $text3_xy = '50,4080';
                    $text4_xy = '50,4115';
                    $color = '0,0,88';
                    $imagePath = '/library/'.$fileCata.'/9.png';
                }else {
                    return ['check' => false,'data' => '生成二维码底图参数错误'];
                }
            } elseif (in_array($organ,self::ORGAN_NO_DEPARTMENT_INITIAL_ARRAY)) {//其他外部机构
                #坐标参数
                if ($organ == self::ORGAN_FLAG_ZJXT) {
                    //针对诸葛学堂课程分销单独处理
                    $code_xy = '535,1350';
                    $text1_xy = '50,4010';
                    $text2_xy = '50,4045';
                    $text3_xy = '50,4080';
                    $text4_xy = '50,4115';
                    $color = '0,0,88';
                    $imagePath = '/library/'.$fileCata.'/7.png';
                    $url = $newUrl.'&staff_code='.$organ_code;
                } else {
                    if ($action == self::ORGAN_CODE_STYLE_1) {
                        $code_xy = '586,2930';
                        $text1_xy = '20,2950';
                        $text2_xy = '20,2985';
                        $text3_xy = '20,3020';
                        $text4_xy = '20,3055';
                        $color = '0,0,88';
                        $imagePath = '/library/'.$fileCata.'/1.png';//大语文培优班
                    } elseif ($action == self::ORGAN_CODE_STYLE_2) {
                        $code_xy = '586,3150';
                        $text1_xy = '20,3170';
                        $text2_xy = '20,3205';
                        $text3_xy = '20,3240';
                        $text4_xy = '20,3275';
                        $color = '0,0,0';
                        if ($organ == self::ORGAN_FLAG_DOUSHENSHUANGSHI) {
                            $color = '0,0,88';
                        }
                        $imagePath = '/library/'.$fileCata.'/2.png';
                    }elseif ($action == self::ORGAN_CODE_STYLE_3) {
                        $code_xy = '586,2730';
                        $text1_xy = '20,2750';
                        $text2_xy = '20,2785';
                        $text3_xy = '20,2820';
                        $text4_xy = '20,2855';
                        $color = '0,0,0';
                        $imagePath = '/library/'.$fileCata.'/3.png';
                    }elseif ($action == self::ORGAN_CODE_STYLE_4) {
                        $code_xy = '586,2730';
                        $text1_xy = '20,2750';
                        $text2_xy = '20,2785';
                        $text3_xy = '20,2820';
                        $text4_xy = '20,2855';
                        $color = '0,0,0';
                        $imagePath = '/library/'.$fileCata.'/4.png';
                    }elseif ($action == self::ORGAN_CODE_STYLE_5) {
                        $code_xy = '586,3230';
                        $text1_xy = '20,3250';
                        $text2_xy = '20,3285';
                        $text3_xy = '20,3320';
                        $text4_xy = '20,3355';
                        $color = '0,0,0';
                        $imagePath = '/library/'.$fileCata.'/5.png';
                    }elseif ($action == self::ORGAN_CODE_STYLE_6) {
                        $code_xy = '590,2935';
                        $text1_xy = '25,2955';
                        $text2_xy = '25,2990';
                        $text3_xy = '25,3025';
                        $text4_xy = '25,3060';
                        $color = '0,0,0';
                        $imagePath = '/library/'.$fileCata.'/6.png';
                        $url = $newUrl.'&staff_code='.$organ_code;
                    }else {
                        return ['check' => false,'data' => '生成二维码底图参数错误'];
                    }
                }
                
            }
            $textCoordinates = [$text1_xy,$text2_xy,$text3_xy,$text4_xy];
            $size = 18;$code_level = 2;
            if (in_array($action,[self::ORGAN_CODE_STYLE_6,self::ORGAN_CODE_STYLE_8,self::ORGAN_CODE_STYLE_9])&&
                in_array($organ,array_diff(self::ORGAN_ARRAY,self::ORGAN_NO_DEPARTMENT_INITIAL_ARRAY))) {
                $size = 20;
                $code_level = 3;
            } elseif ($action == self::ORGAN_CODE_STYLE_10) {
                $size = 20;
                $code_level = 2.2;
            }
            $return = self::CreatCard($url,$imagePath,$code_xy,$text,$textCoordinates,$color,$size,$code_level);
            if ($return['check'] == false) {
                return false;
            }
            #回写code
            if ($second) {
                $staff_info = ShopStaffInfo::find()->select('id')
                    ->where(['is_deleted'=>self::STAFF_STATUS,'id'=>self::$second_id])->asArray()->one();
            } else {
                $staff_info = ShopStaffInfo::find()->select('id')
                    ->where(['is_deleted'=>self::STAFF_STATUS,'tel'=>trim($tel),'staff_source'=>$organ])->asArray()->one();
            }
            self::updateInfoData(['code'=>$organ_code],['id'=>$staff_info['id']]);
    
            return ['check' => true,'data' => $return['data']];
    
        }
    
        /**
         * 抽象生成二维码接口水印文字等
         * @param $url 二维码调整的链接
         * @param $backgroundImage 背景图文件地址
         * @param string $qr_code_coordinates 二维码坐标 '100,200'
         * @param array $text 要水印上去的文字 可以是多个
         * @param array $coordinates 要水印上去的文字 对应的坐标 多组文字对应多组坐标
         * @param $colour  水印文字 颜色rgb值
         * @return base64 image
         */
        public static function CreatCard ($url,$backgroundImage,string $qr_code_coordinates,array $text = [],array $coordinates = [],$colour,$size,$code_level)
        {
            #参数校验
            if (!$url || !$qr_code_coordinates) {
                return ['check' => false,'data' => '二维码跳转链接或者二维码坐标不能为空'];
            }
            if (count($text) != count($coordinates)) {
                return ['check' => false,'data' => '水印文字的数量与提供的坐标不符'];
            }
            //生成二维码图片
            $path = '/tmp/recruitcard';
            if (!is_dir($path)) {
                @mkdir($path);
            }
            include(ROOT_PATH . '/library/phpqrcode/qrlib.php');
            $qrcodePath = $path . '/' . date('Y-m-d').'-'.rand(10000,99999) . '.png';
            QRcode::png($url, $qrcodePath, 3,$code_level);
    
            #原始图像
            $dst = (ROOT_PATH . $backgroundImage);
            #得到原始图片信息
            $dst_im1 = imagecreatefrompng($dst);
            $dst_info1 = getimagesize($dst);
            #二维码图片
            $src1 = $qrcodePath;
            $src1_im = imagecreatefrompng($src1);
            $src1_info = getimagesize($src1);
            #合并水印图片
            $code_xy = explode(',',$qr_code_coordinates);
            imagecopymerge($dst_im1,$src1_im,$code_xy[0],$code_xy[1],0,0,$src1_info[0],$src1_info[1],100);
            #合成图片的路径
            $path = '/tmp/gentlemancard';
            if (!is_dir($path)) {
                @mkdir($path);
            }
            $poster_marge_path =$path . '/' . date('Y-m-d').'-'.rand(0,9999) . '.png';
            #输出合并后水印图片
            ob_start();
            imagepng($dst_im1,$poster_marge_path);
            imagedestroy($dst_im1);
            imagedestroy($src1_im);
            #添加图片文字
            $dst_path = $poster_marge_path;
            $dst_new = imagecreatefromstring(file_get_contents($dst_path));
            $font = (ROOT_PATH . '/library/gentlemanImg/fzlthk.ttf');
            $im = imagecreatetruecolor(400, 30);
            $colour = explode(',',$colour);
            $colour =imagecolorallocate($im, $colour[0],$colour[1],$colour[2]);
            #文字处理
            foreach ($text as $key=>$value) {
                $text_xy = explode(',',$coordinates[$key]);
                imagefttext($dst_new, $size, 0,$text_xy[0], $text_xy[1], $colour, $font, $value);
            }
    
            header('Content-type: image/png');
            imagepng($dst_new);
            @unlink($dst_new);
            $sImage = ob_get_contents();
            ob_end_clean();
            $base64_img = base64_encode($sImage);
            @unlink($qrcodePath);
    
            return ['check' => true,'data' => $base64_img];
    
        }
    
        /**
         * 获得uid 加密串
         * 生成规则数字0-9按从小到大顺序变成RIZBHGECFO,替换完成后在第5个字符后面加AKMN
         * @param $mobile
         * @return mixed
         */
        public static function get_qr_tel($tel)
        {
            $tel = str_replace("0", "R", $tel);
            $tel = str_replace("1", "I", $tel);
            $tel = str_replace("2", "Z", $tel);
            $tel = str_replace("3", "B", $tel);
            $tel = str_replace("4", "H", $tel);
            $tel = str_replace("5", "G", $tel);
            $tel = str_replace("6", "E", $tel);
            $tel = str_replace("7", "C", $tel);
            $tel = str_replace("8", "F", $tel);
            $tel = str_replace("9", "O", $tel);
            $tel = substr_replace($tel, 'AKMN', 11, 0);
            return $tel;
            // return uniqid(crc32('qr_code_' . $mobile)) . rand(10000, 99999);
        }
    
        public static function updateInfoData($data,$where) {
            ShopStaffInfo::getDb()->createCommand()->
            update(ShopStaffInfo::tableName(), $data, $where )
            ->execute();
        }
    
        public static function getOrganDepartmentInfo($organ)
        {
            $OrganInfo  = array(
                "department" => 1,
                "department_list" => array(),
                "secondChannel" => 0,
            );
            if(in_array($organ,self::ORGAN_NO_DEPARTMENT_INITIAL_ARRAY)){
    
            }elseif(in_array($organ,self::ORGAN_NO_DEPARTMENT_LATER_ARRAY)){
                //没有部门的
                $OrganInfo["department"] = 2;
                $OrganInfo["department_list"] = array();
            }elseif(in_array($organ,self::ORGAN_DEPARTMENT_LATER_ARRAY)){
                //有部门的
                $OrganInfo["department"] = 3;
                $OrganInfo["department_list"] = self::ORGAN_DEPARTMENT_INFO[$organ];
            }
            //二级渠道信息
            if(in_array($organ,self::ORGAN_CHANNEL_ARRAY)){
                $OrganInfo["secondChannel"] = 1;
            }else{
                $OrganInfo["secondChannel"] = 2;
            }
            return $OrganInfo;
        }
    
    
    }
    
  • 相关阅读:
    uC/OS-II内核的服务文件
    uC/OS-II汇编代码
    uC/OS-II类型定义
    uC/OS-II核心(Os_core)块
    uC/OS-II配置文件
    uC/OS-II应用程序exe
    uC/OS-II应用程序代码
    技术人员如何创业《四》- 打造超强执行力团队(转载)
    最近做抽奖的活动
    install docker
  • 原文地址:https://www.cnblogs.com/liuqun/p/13622297.html
Copyright © 2011-2022 走看看