InstallController.class.php 57.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
<?php
/**
 * Created by PhpStorm.
 * User: liyifei2012it
 * Date: 17/6/13
 * Time: 18:13
 */

namespace Rpc\Controller\Common;

use Think\Db;
use Think\Log;

class InstallController extends AbstractController
{
    private $qyDomain = QY_DOMAIN;
    private $nowTime = MILLI_TIME;

    /**
     * 应用默认数据安装接口
     * @author tangxingguo
     */
    public function Index()
    {
        // 添加分类
        $this->_addClass();
        // 添加素材
        $this->_addSource();
        // 添加课程
        $this->_addCourse();
    }

    /**
     * 执行sql语句
     * @param $sql
     */
    private function _exeSql($sql)
    {
        if (empty($sql)) {
            return ;
        }

        $db = Db::getInstance();
        try {
            return $db->query($sql);
        } catch (\Exception $e) {

        }
    }

    /**
     * 默认分类数据
     * @author tangxingguo
     * @return string
     */
    private function _addClass()
    {
        // 兼容多次操作
        $db = &Db::getInstance();
        $classSql = "select * from `oa_course_class` WHERE `domain` = '{$this->qyDomain}'  and `status` < 3";
        $classInfo = $db->query($classSql);
        if (!empty($classInfo)) {
            return;
        }

        // 默认分类数据
        $defaultClass = [
            [
                'class_name' => '管理常识',
                'parent_id' => 0,
                'description' => '',
                'is_open' => 2,
            ],
            [
                'class_name' => '市场营销',
                'parent_id' => 0,
                'description' => '',
                'is_open' => 2,
            ],
            [
                'class_name' => '办公技能',
                'parent_id' => 0,
                'description' => '',
                'is_open' => 2,
            ],
            [
                'class_name' => '职业发展',
                'parent_id' => 0,
                'description' => '',
                'is_open' => 2,
            ],
            [
                'class_name' => '思维框架',
                'parent_id' => 0,
                'description' => '',
                'is_open' => 2,
            ],
        ];

        // sql
        $sql = "INSERT INTO `oa_course_class` (`parent_id`, `class_name`, `description`, `is_open`, `domain`, `status`, `created`) VALUES ";
        foreach ($defaultClass as $k => $v) {
            $sql .= "('{$v['parent_id']}', '{$v['class_name']}', '{$v['description']}', '{$v['is_open']}', '{$this->qyDomain}', 1, '{$this->nowTime}')";
            if (end($defaultClass) == $v) {
                $sql .= ";";
            } else {
                $sql .= ",";
            }
        }

        $this->_exeSql($sql);
    }

    /**
     * 默认素材
     * @author tangxingguo
     */
    private function _addSource()
    {
        // 兼容多次操作
        $db = &Db::getInstance();
        $sourceSql = "select * from `oa_course_source` WHERE `domain` = '{$this->qyDomain}'  and `status` < 3";
        $sourceInfo = $db->query($sourceSql);
        if (!empty($sourceInfo)) {
            return;
        }

        // 默认数据 1
        $defaultData = [
            'source_title' => '欢迎开启员圈,开始学习成长之旅',
            'source_key' => 'I' . rgmdate(MILLI_TIME, 'ymdHi') . rand(10, 99),
            'author' => '员圈小助手',
            'source_type' => 1,
            'is_download' => 1,
            'ea_id' => '',
            'ea_name' => '员圈小助手',
            'audio_imgs' => '',
            'content' => '<section style="background-color: rgb(255, 255, 255); box-sizing: border-box;">
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    员圈,是基于企业微信的企业员工学习成长生态圈。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px; box-sizing: border-box; ">
            <section class="" style="margin-bottom: -12px;text-align: center;box-sizing: border-box;">
                <section style="display: inline-block;vertical-align: bottom;width: 6px;box-sizing: border-box;">
                    <section style="width: 2px;margin: auto;height: 16px;background-color: rgb(17, 19, 22);box-sizing: border-box;"></section>
                    <section style="width: 6px;height: 6px;border-radius: 50%;background-color: rgb(17, 19, 22);box-sizing: border-box;"></section>
                </section>
                <section style="display: inline-block;vertical-align: bottom;width: 60%;box-sizing: border-box;"></section>
                <section style="display: inline-block;vertical-align: bottom;width: 6px;box-sizing: border-box;">
                    <section style="width: 2px;margin: auto;height: 16px;background-color: rgb(17, 19, 22);box-sizing: border-box;"></section>
                    <section style="width: 6px;height: 6px;border-radius: 50%;background-color: rgb(17, 19, 22);box-sizing: border-box;"></section>
                </section>
            </section>
            <section class="" style="transform: rotate(0deg);-webkit-transform: rotate(0deg);-moz-transform: rotate(0deg);-o-transform: rotate(0deg);margin-bottom: -5px;width: 5px;height: 5px;background-color: rgb(254, 255, 255);box-sizing: border-box;"></section>
            <section class="" style="border-left: 5px solid rgb(255, 222, 3);border-bottom: 5px solid rgb(255, 222, 3);border-top-color: rgb(255, 222, 3);border-right-color: rgb(255, 222, 3);box-sizing: border-box;">
                <section class="" style="background-color: rgb(214, 240, 252);padding: 10px;box-sizing: border-box;">
                    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
                        <section class="" style="  box-sizing: border-box; ">
                            <section class="" style="font-size: 14px;line-height: 2;box-sizing: border-box;">
                                <p style="box-sizing: border-box;">
                                    <strong style="box-sizing: border-box;">完整的员工成长体系,支持随时随地学习与检验</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                </p>
                                <p style="box-sizing: border-box;">
                                    <strong style="box-sizing: border-box;">互动问答社区,打造企业内浓厚学习氛围</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                </p>
                                <p style="box-sizing: border-box;">
                                    <strong style="box-sizing: border-box;">积分与勋章,激励员工自发、主动学习提升</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                </p>
                            </section>
                        </section>
                    </section>
                </section>
            </section>
            <section class="" style="margin-left: auto;margin-top: -5px;width: 5px;height: 5px;background-color: rgb(254, 255, 255);box-sizing: border-box;"></section>
        </section>
    </section>
    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    <br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;padding-left: 0.2em;font-size: 10px; box-sizing: border-box; ">
            <section class="" style="display: inline-block;box-sizing: border-box;">
                <section class="" style="width: 3.3em;height: 3.3em;display: inline-block;vertical-align: top;margin-left: -0.2em;border-width: 3px;border-style: solid;border-color: white;margin-right: -3.3em;transform: rotate(0deg);border-radius: 100%;background-position: center center;background-repeat: no-repeat;background-size: cover;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png&quot;);box-sizing: border-box;">
                    <section class="" style="width: 100%;height: 100%;overflow: hidden;box-sizing: border-box;">
                        <img class="" style="opacity: 0; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png" data-ratio="1" data-w="640" width="100%" data-type="png" _width="100%" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_logo.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    </section>
                </section>
                <section style="padding-left: 3.4em;margin-top: -3em;border-radius: 1.5em;background-color: rgb(214, 240, 252);box-sizing: border-box;">
                    <section class="" style="display: inline-block;vertical-align: top;color: rgb(58, 55, 55);font-size: 16px;text-align: center;padding-right: 15px;padding-left: 10px;box-sizing: border-box;">
                        <p style="box-sizing: border-box;">
                            <strong style="box-sizing: border-box;">基于企业微信,打造移动学习新生态</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        </p>
                    </section>
                </section>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    员工可以快速加入员圈。在实际应用中,<strong style="box-sizing: border-box;">仅仅2天时间,就将全国近1000家门店,8000名员工加入员圈</strong>。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" text-align: center;margin-top: 10px;margin-bottom: 10px;font-size: 2px; box-sizing: border-box; ">
            <section class="" style="max-width: 100%;vertical-align: middle;display: inline-block;width: 35%;overflow: hidden !important;box-sizing: border-box;">
                <img data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuN6rTS7KSolGBp7WcpHiblYy7NWBdqyssCWHEAobZic0oiaavU44VYDCIQ/0?wx_fmt=png" style="vertical-align: middle; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-ratio="2.0936709" data-w="395" width="100%" data-type="png" _width="100%" class="" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_1.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            </section>
        </section>
    </section>
    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    <br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;padding-left: 0.2em;font-size: 10px; box-sizing: border-box; ">
            <section class="" style="display: inline-block;box-sizing: border-box;">
                <section class="" style="width: 3.3em;height: 3.3em;display: inline-block;vertical-align: top;margin-left: -0.2em;border-width: 3px;border-style: solid;border-color: white;margin-right: -3.3em;transform: rotate(0deg);border-radius: 100%;background-position: center center;background-repeat: no-repeat;background-size: cover;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png&quot;);box-sizing: border-box;">
                    <section class="" style="width: 100%;height: 100%;overflow: hidden;box-sizing: border-box;">
                        <img class="" style="opacity: 0; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png" data-ratio="1" data-w="640" width="100%" data-type="png" _width="100%" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_logo.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    </section>
                </section>
                <section style="padding-left: 3.4em;margin-top: -3em;border-radius: 1.5em;background-color: rgb(214, 240, 252);box-sizing: border-box;">
                    <section class="" style="display: inline-block;vertical-align: top;color: rgb(58, 55, 55);font-size: 16px;text-align: center;padding-right: 15px;padding-left: 10px;box-sizing: border-box;">
                        <p style="box-sizing: border-box;">
                            <strong style="box-sizing: border-box;">高频带动低频,员工主动学习</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        </p>
                    </section>
                </section>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;line-height: 2;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    学习从来都是低频的,容易偷懒倦怠的。过去的线上培训往往是员工收到企业邮件/口头通知,在电脑上登陆培训平台,打开课程学习。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;line-height: 2;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    现在,员圈利用企业微信高频次的打开率和消息查看率,<strong style="box-sizing: border-box;">将课程、考试直接推送到每一位员工的企业微信,员工学习频次提升,主动性增强。</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" text-align: center;margin-top: 10px;margin-bottom: 10px; box-sizing: border-box; ">
            <section class="" style="max-width: 100%;vertical-align: middle;display: inline-block;overflow: hidden !important;box-sizing: border-box;">
                <img data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxudChSBhO6NWOLlSibX7JFvFDlChQwlhKc7crHKlHNXKA8YDhpSboJEaw/0?wx_fmt=png" style="vertical-align: middle; box-sizing: border-box; width: auto !important; height: auto !important; visibility: visible !important;" data-ratio="0.5546875" data-w="640" data-type="png" class="" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_2.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            </section>
        </section>
    </section>
    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    <br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;padding-left: 0.2em;font-size: 10px; box-sizing: border-box; ">
            <section class="" style="display: inline-block;box-sizing: border-box;">
                <section class="" style="width: 3.3em;height: 3.3em;display: inline-block;vertical-align: top;margin-left: -0.2em;border-width: 3px;border-style: solid;border-color: white;margin-right: -3.3em;transform: rotate(0deg);border-radius: 100%;background-position: center center;background-repeat: no-repeat;background-size: cover;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png&quot;);box-sizing: border-box;">
                    <section class="" style="width: 100%;height: 100%;overflow: hidden;box-sizing: border-box;">
                        <img class="" style="opacity: 0; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png" data-ratio="1" data-w="640" width="100%" data-type="png" _width="100%" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_logo.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    </section>
                </section>
                <section style="padding-left: 3.4em;margin-top: -3em;border-radius: 1.5em;background-color: rgb(214, 240, 252);box-sizing: border-box;">
                    <section class="" style="display: inline-block;vertical-align: top;color: rgb(58, 55, 55);font-size: 16px;text-align: center;padding-right: 15px;padding-left: 10px;box-sizing: border-box;">
                        <p style="box-sizing: border-box;">
                            <strong style="box-sizing: border-box;">完整的员工学习成长体系</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        </p>
                    </section>
                </section>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;text-align: center;line-height: 1;font-size: 11px; box-sizing: border-box; ">
            <section class="" style="width: 0px;display: inline-block;border-top: 1.2em solid rgb(255, 223, 0);border-left: 0.7em solid transparent !important;border-right: 0.7em solid transparent !important;box-sizing: border-box;"></section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="text-align: center;box-sizing: border-box;">
                    <strong style="box-sizing: border-box;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 课程</strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    形式丰富的线上课堂,支持图文、音频、视频、文件、外部链接多类课程。
                </p>
                <p style="box-sizing: border-box;">
                    支持根据岗位进行课程定制,将培训精细化、个性化,落实到每一位员工。
                </p>
                <p style="box-sizing: border-box;">
                    课程可关联考试,形成学习-检测的闭环。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;text-align: center;line-height: 1;font-size: 11px; box-sizing: border-box; ">
            <section class="" style="width: 0px;display: inline-block;border-top: 1.2em solid rgb(255, 223, 0);border-left: 0.7em solid transparent !important;border-right: 0.7em solid transparent !important;box-sizing: border-box;"></section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="text-align: center;box-sizing: border-box;">
                    <strong style="box-sizing: border-box;">考试<br style="box-sizing: border-box;"/></strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    自主题库配置,多种试卷组合。
                </p>
                <p style="box-sizing: border-box;">
                    支持30000+员工同时在线考试。
                </p>
                <p style="box-sizing: border-box;">
                    考试数据一键导出,成绩一目了然。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;text-align: center;line-height: 1;font-size: 11px; box-sizing: border-box; ">
            <section class="" style="width: 0px;display: inline-block;border-top: 1.2em solid rgb(255, 223, 0);border-left: 0.7em solid transparent !important;border-right: 0.7em solid transparent !important;box-sizing: border-box;"></section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="text-align: center;box-sizing: border-box;">
                    <strong style="box-sizing: border-box;">资料库</strong><br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    随身携带的知识宝库,充分利用碎片化时间学习充电。资料库权限明确,文件安全有保障
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" text-align: center;margin-top: 10px;margin-bottom: 10px; box-sizing: border-box; ">
            <section class="" style="max-width: 100%;vertical-align: middle;display: inline-block;overflow: hidden !important;box-sizing: border-box;">
                <img data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuXbmPmqYaFEm5RM3TBL0REy7EMH9O1JonWqvx6MrQbH3Q46ttibDfObw/0?wx_fmt=png" style="vertical-align: middle; box-sizing: border-box; width: auto !important; height: auto !important; visibility: visible !important;" data-ratio="0.58125" data-w="640" data-type="png" class="" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_3.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            </section>
        </section>
    </section>
    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    <br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;padding-left: 0.2em;font-size: 10px; box-sizing: border-box; ">
            <section class="" style="display: inline-block;box-sizing: border-box;">
                <section class="" style="width: 3.3em;height: 3.3em;display: inline-block;vertical-align: top;margin-left: -0.2em;border-width: 3px;border-style: solid;border-color: white;margin-right: -3.3em;transform: rotate(0deg);border-radius: 100%;background-position: center center;background-repeat: no-repeat;background-size: cover;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png&quot;);box-sizing: border-box;">
                    <section class="" style="width: 100%;height: 100%;overflow: hidden;box-sizing: border-box;">
                        <img class="" style="opacity: 0; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png" data-ratio="1" data-w="640" width="100%" data-type="png" _width="100%" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_logo.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    </section>
                </section>
                <section style="padding-left: 3.4em;margin-top: -3em;border-radius: 1.5em;background-color: rgb(214, 240, 252);box-sizing: border-box;">
                    <section class="" style="display: inline-block;vertical-align: top;color: rgb(58, 55, 55);font-size: 16px;text-align: center;padding-right: 15px;padding-left: 10px;box-sizing: border-box;">
                        <p style="box-sizing: border-box;">
                            <strong style="box-sizing: border-box;">你问我答,共同进步</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        </p>
                    </section>
                </section>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    问答社区是员工提供<strong style="box-sizing: border-box;">知识共享</strong>的天地,通过员工间问答互动,<strong style="box-sizing: border-box;">在企业内部形成知识共享的浓厚氛围,推动全员进步。</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
                <p style="box-sizing: border-box;">
                    <strong style="box-sizing: border-box;">支持悬赏提问</strong>,提问者可使用积分悬赏,吸引更多优质回答,同时答题者也可以获得实际回报。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" text-align: center;margin-top: 10px;margin-bottom: 10px; box-sizing: border-box; ">
            <section class="" style="max-width: 100%;vertical-align: middle;display: inline-block;width: 35%;overflow: hidden !important;box-sizing: border-box;">
                <img data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuqWSwBWF2jYX4WmicFedXr1NFqiatCvz5jlxeicTVBKpscxkd0RVpSeGww/0?wx_fmt=png" style="vertical-align: middle; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-ratio="2.0949721" data-w="537" width="100%" data-type="png" _width="100%" class="" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_4.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            </section>
        </section>
    </section>
    <section class="" style="box-sizing: border-box;" powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    <br style="box-sizing: border-box;"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" margin-top: 10px;margin-bottom: 10px;padding-left: 0.2em;font-size: 10px; box-sizing: border-box; ">
            <section class="" style="display: inline-block;box-sizing: border-box;">
                <section class="" style="width: 3.3em;height: 3.3em;display: inline-block;vertical-align: top;margin-left: -0.2em;border-width: 3px;border-style: solid;border-color: white;margin-right: -3.3em;transform: rotate(0deg);border-radius: 100%;background-position: center center;background-repeat: no-repeat;background-size: cover;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png&quot;);box-sizing: border-box;">
                    <section class="" style="width: 100%;height: 100%;overflow: hidden;box-sizing: border-box;">
                        <img class="" style="opacity: 0; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuDpDxPHXP0036Xcvqhpcp9Vayial9UQTndGJ1iagH4Wu17MeQ14YppIrw/0?wx_fmt=png" data-ratio="1" data-w="640" width="100%" data-type="png" _width="100%" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_logo.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    </section>
                </section>
                <section style="padding-left: 3.4em;margin-top: -3em;border-radius: 1.5em;background-color: rgb(214, 240, 252);box-sizing: border-box;">
                    <section class="" style="display: inline-block;vertical-align: top;color: rgb(58, 55, 55);font-size: 16px;text-align: center;padding-right: 15px;padding-left: 10px;box-sizing: border-box;">
                        <p style="box-sizing: border-box;">
                            <strong style="box-sizing: border-box;">积分与勋章,激发员工主动性</strong>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        </p>
                    </section>
                </section>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style="  box-sizing: border-box; ">
            <section class="" style="font-size: 14px;line-height: 2;letter-spacing: 1px;padding-right: 1px;padding-left: 1px;box-sizing: border-box;">
                <p style="box-sizing: border-box;">
                    企业员工在完成课程学习、通过考试,积极参与问答后,可以获得积分或者勋章奖励。
                </p>
                <p style="box-sizing: border-box;">
                    积分可以在积分商城中兑换丰厚奖品,勋章彰显了员工的学习成果和能力,从而激励员工更加主动的去学习、去成长,为企业创造更高的效益。
                </p>
            </section>
        </section>
    </section>
    <section class="" style="  box-sizing: border-box; " powered-by="xiumi.us">
        <section class="" style=" text-align: center;margin-top: 10px;margin-bottom: 10px; box-sizing: border-box; ">
            <section class="" style="max-width: 100%;vertical-align: middle;display: inline-block;width: 35%;overflow: hidden !important;box-sizing: border-box;">
                <img data-src="http://mmbiz.qpic.cn/mmbiz_png/3TtZaOekb6NlkAVhyiaoqFppz9ckF3xxuVncrFncZlSphKaNNG1f9O7yyNwicpvnYW6WIfk11HBYIztclyhOlcNQ/0?wx_fmt=png" style="vertical-align: middle; box-sizing: border-box; width: 100% !important; height: auto !important; visibility: visible !important;" data-ratio="2.0949721" data-w="537" width="100%" data-type="png" _width="100%" class="" src="http://st.vchangyi.com/yuanquan/course/default_banner_course_5.png" data-fail="0"/>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            </section>
        </section>
    </section>
</section>',
            'update_time' => $this->nowTime,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        // sql
        $sql = $this->_formatInsert('oa_course_source', $defaultData);
        $this->_exeSql($sql);

        // 默认数据 2
        $defaultData = [
            'source_title' => '员工如何进行课程学习',
            'source_key' => 'I' . rgmdate(MILLI_TIME, 'ymdHi') . rand(10, 99),
            'author' => '员圈小助手',
            'source_type' => 1,
            'is_download' => 1,
            'ea_id' => '',
            'ea_name' => '员圈小助手',
            'audio_imgs' => '',
            'content' => '<p style="text-align:center;line-height:150%"><strong><span style="font-size:21px;line-height:150%;font-family: &#39;微软雅黑&#39;,&#39;sans-serif&#39;">员工如何进行课程学习</span></strong></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">&nbsp;</span></p><p style="line-height:150%"><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">一、 <span style="font-variant-numeric: normal;font-weight: normal;font-stretch: normal;font-size: 9px;line-height: normal;font-family: &#39;Times New Roman&#39;">&nbsp;</span></span></strong><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">功能简介</span></strong></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">员工在手机上打开【员圈】系统,进入【课程中心】可以选择课程进行学习,获得进步与提升;还可以参与课后小测验,挑战自我,巩固学习成果。</span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">除此之外,员工完成指定的学习任务之后,还能 <strong><span style="color:red">获得积分或勋章奖励</span></strong>。 </span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">&nbsp;</span></p><p style="line-height:150%"><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">二、 <span style="font-variant-numeric: normal;font-weight: normal;font-stretch: normal;font-size: 9px;line-height: normal;font-family: &#39;Times New Roman&#39;">&nbsp;</span></span></strong><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">如何学习课程</span></strong></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">打开【员圈】系统,进入【课程中心】,点击任意课程即可开始学习。</span></p><p style="line-height:150%"><span style="font-family: 微软雅黑, sans-serif;">(1) <span style="font-variant-numeric: normal;font-stretch: normal;font-size: 9px;line-height: normal;font-family: &#39;Times New Roman&#39;">&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 微软雅黑, sans-serif;">课程类型有两种,分为单课程和系列课程,系列课程有多个素材内容,必须把全部内容学习完成才算学完;</span></p><p style="line-height:150%"><span style="font-family: 微软雅黑, sans-serif;">(2) <span style="font-variant-numeric: normal;font-stretch: normal;font-size: 9px;line-height: normal;font-family: &#39;Times New Roman&#39;">&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 微软雅黑, sans-serif;">课程素材类型包括“图文/音图/视频/附件/外部链接”五种,附件支持在线预览学习。</span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;"><img src="https://st.vchangyi.com/yuanquan/course/image01.png" title="image01.png" alt="image01.png"/></span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">(3)学习过课程内容之后,我们可以进行点赞、评论、收藏;为了保证课程内容的安全性,如果管理员开启了保密功能,则页面上将会有水印出现。 </span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;"><img src="https://st.vchangyi.com/yuanquan/course/image02.png" title="image02.png" alt="image02.png"/></span></p><p style="line-height:150%"><strong><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;;color:red">小技巧:点赞和收藏可以通过再次点击按钮进行取消,自己发表的评论也可以删除。</span></strong></p><p style="line-height:150%"><strong><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;;color:red">&nbsp;</span></strong></p><p style="line-height:150%"><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">三、 <span style="font-variant-numeric: normal;font-weight: normal;font-stretch: normal;font-size: 9px;line-height: normal;font-family: &#39;Times New Roman&#39;">&nbsp;</span></span></strong><strong><span style="line-height: 150%; font-family: 微软雅黑, sans-serif;">如何进行课后测试</span></strong></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">如果课程设置了课后测试题目,那么必须答对全部题目才算真正完成了课程的学习,才有可能获得积分/勋章的奖励。</span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">(1)点击课程底部的“我要测试“按钮,开始答题;</span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;"><img src="https://st.vchangyi.com/yuanquan/course/image03.png" title="image03.png" alt="image03.png"/></span></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">(2)课后测试题目必须全部答对才算通过,如果有答错的,系统会提示重新答题;</span></p><p><img src="https://st.vchangyi.com/yuanquan/course/image04.jpg" title="image04.jpg" alt="image04.jpg"/></p><p style="line-height:150%"><span style="font-family:&#39;微软雅黑&#39;,&#39;sans-serif&#39;">(3)只有全部答对,才会显示通过通过测试,并且可能获得积分/勋章的奖励。</span></p><p style="line-height:150%"><img src="https://st.vchangyi.com/yuanquan/course/image05.png" title="image05.png" alt="image05.png"/></p><p><br/></p>',
            'update_time' => $this->nowTime,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        // sql
        $sql = $this->_formatInsert('oa_course_source', $defaultData);
        $this->_exeSql($sql);
    }

    /**
     * 添加课程
     */
    private function _addCourse()
    {
        // 兼容多次操作
        $db = &Db::getInstance();
        $courseSql = "select * from `oa_course_article` WHERE `domain` = '{$this->qyDomain}'  and `status` < 3";
        $courseInfo = $db->query($courseSql);
        if (!empty($courseInfo)) {
            return;
        }

        // 分类
        $classSql = "select * from `oa_course_class` WHERE `class_name` = '办公技能' and `domain` = '{$this->qyDomain}'  and `status` < 3";
        $classInfo = $db->query($classSql);
        if (empty($classInfo)) {
            Log::record('---Add Course fail info:没有找到分类信息', Log::ERR);
            return;
        }

        // 后来发现顺序不对 但内容对的 就不更换 注释 和 命名了
        // 课程数据2
        $this->addCourseTwo($classInfo);
        // 课程数据1
        $this->addCourseOne($classInfo);

        return ;
    }

    /**
     * 添加 第一条 默认课程数据
     * @param $classInfo
     * @return bool
     */
    private function addCourseOne($classInfo)
    {
        $db = &Db::getInstance();

        $courseData = [
            'article_title' => '【系统预设】欢迎开启员圈,开始学习成长之旅',
            'article_type' => 1,
            'summary' => '员圈【课程中心】旨在帮助企业将最优质的培训内容跨时空的传递给员工伙伴,帮助员工系统化的成长;功能上,支持5种素材/2种课程类型/10余种特性,真正实现企业生态化赋能,提高经营管理效率,降低企业管理成本。',
            'is_show_cover' => 1,
            'is_secret' => 2,
            'is_share' => 1,
            'is_notice' => 1,
            'is_comment' => 2,
            'is_like' => 2,
            'is_recommend' => 2,
            'is_exam' => 1,
            'is_step' => 1,
            'course_type' => 1,
            'author' => '员圈小助手',
            'article_status' => 2,
            'class_id' => $classInfo[0]['class_id'],
            'cover_id' => 'course-install-pic',
            'cover_url' => 'https://st.vchangyi.com/yuanquan/course/default_banner_1.png',
            'strategy_setting' => 2,
            'strategys' => '',
            'source_type' => 1,
            'ea_id' => '',
            'ea_name' => '系统默认',
            'et_ids' => '',
            'update_time' => $this->nowTime,
            'data_id' => md5(sprintf('%s_%s_%s', QY_DOMAIN, APP_DIR, MILLI_TIME)),
            'content' => '',
            'status' => 1,
            'domain' => $this->qyDomain,
            'created' => $this->nowTime,
            'cm_id' => 0,
            'rand_num' => 0,
            'study_total' => 0,
            'unstudy_total' => 0,
            'comment_total' => 0,
            'like_total' => 0,
        ];
        $sql = $this->_formatInsert('oa_course_article', $courseData);
        $this->_exeSql($sql);
        // 章节数据
        $articleSql = "select * from `oa_course_article` WHERE `article_title` = '【系统预设】欢迎开启员圈,开始学习成长之旅' and `domain` = '{$this->qyDomain}'  and `status` < 3";
        $articleInfo = $db->query($articleSql);
        if (empty($articleInfo)) {
            Log::record('---Add Course fail info:没有找到课程数据', Log::ERR);
            return true;
        }
        $chapterData = [
            'article_id' => $articleInfo[0]['article_id'],
            'parent_id' => 0,
            'source_id' => 0,
            'chapter_name' => '章节',
            'et_ids' => '',
            'rand_num' => 0,
            'order' => 1,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $courseChapterSql = $this->_formatInsert('oa_course_article_chapter', $chapterData);
        $this->_exeSql($courseChapterSql);
        // 子章节数据
        $chapterSql = "select * from `oa_course_article_chapter` WHERE `article_id` = '{$articleInfo[0]['article_id']}' AND `domain` = '{$this->qyDomain}'  and `status` < 3";
        $chapterInfo = $db->query($chapterSql);
        if (empty($chapterInfo)) {
            Log::record('---Add Course fail info:没有找到章节数据', Log::ERR);
            return true;
        }
        $sourceSql = "select * from `oa_course_source` WHERE `source_title` = '欢迎开启员圈,开始学习成长之旅' AND `domain` = '{$this->qyDomain}'  and `status` < 3";
        $sourceInfo = $db->query($sourceSql);
        if (empty($sourceInfo)) {
            Log::record('---Add Course fail info:没有找到素材数据', Log::ERR);
            return true;
        }
        $chapterChildData = [
            'article_id' => $articleInfo[0]['article_id'],
            'parent_id' => $chapterInfo[0]['article_chapter_id'],
            'source_id' => $sourceInfo[0]['source_id'],
            'chapter_name' => '章节',
            'et_ids' => '',
            'rand_num' => 0,
            'order' => 1,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $chapterChildSql = $this->_formatInsert('oa_course_article_chapter', $chapterChildData);
        $this->_exeSql($chapterChildSql);
        // 课程权限数据
        $rightData = [
            'class_id' => $classInfo[0]['class_id'],
            'article_id' => $articleInfo[0]['article_id'],
            'award_id' => 0,
            'obj_type' => 1,
            'obj_id' => 2,
            'domain' => $this->qyDomain,
            'status' => 1,
        ];
        $rightSql = $this->_formatInsert('oa_course_right', $rightData);
        $this->_exeSql($rightSql);
        // 添加运营中心首页数据
        $this->_addRecommend($articleInfo[0]);
        // 添加运营中心 Banner
        $this->addBanner($courseData, $classInfo, $articleInfo);
    }

    /**
     * 添加 第二条 默认课程数据
     * @param $classInfo
     * @return bool
     */
    private function addCourseTwo($classInfo)
    {
        $db = &Db::getInstance();

        $courseData = [
            'article_title' => '【系统预设】员工如何进行课程学习',
            'article_type' => 1,
            'summary' => '员圈【课程中心】旨在帮助企业将最优质的培训内容跨时空的传递给员工伙伴,帮助员工系统化的成长;功能上,支持5种素材/2种课程类型/10余种特性,真正实现企业生态化赋能,提高经营管理效率,降低企业管理成本。',
            'is_show_cover' => 1,
            'is_secret' => 2,
            'is_share' => 1,
            'is_notice' => 1,
            'is_comment' => 2,
            'is_like' => 2,
            'is_recommend' => 2,
            'is_exam' => 1,
            'is_step' => 1,
            'course_type' => 1,
            'author' => '员圈小助手',
            'article_status' => 2,
            'class_id' => $classInfo[0]['class_id'],
            'cover_id' => 'course-install-pic',
            'cover_url' => 'https://st.vchangyi.com/yuanquan/course/default_banner_2.png',
            'strategy_setting' => 2,
            'strategys' => '',
            'source_type' => 1,
            'ea_id' => '',
            'ea_name' => '系统默认',
            'et_ids' => '',
            'update_time' => $this->nowTime,
            // 数据标识 +1 为了 跟上一个 区别开来
            'data_id' => md5(sprintf('%s_%s_%s', QY_DOMAIN, APP_DIR, MILLI_TIME + 1)),
            'content' => '',
            'status' => 1,
            'domain' => $this->qyDomain,
            'created' => $this->nowTime,
            'cm_id' => 0,
            'rand_num' => 0,
            'study_total' => 0,
            'unstudy_total' => 0,
            'comment_total' => 0,
            'like_total' => 0,
        ];
        $sql = $this->_formatInsert('oa_course_article', $courseData);
        $this->_exeSql($sql);
        // 章节数据
        $articleSql = "select * from `oa_course_article` WHERE `article_title` = '【系统预设】员工如何进行课程学习' and `domain` = '{$this->qyDomain}'  and `status` < 3";
        $articleInfo = $db->query($articleSql);
        if (empty($articleInfo)) {
            Log::record('---Add Course fail info:没有找到课程数据', Log::ERR);
            return true;
        }
        $chapterData = [
            'article_id' => $articleInfo[0]['article_id'],
            'parent_id' => 0,
            'source_id' => 0,
            'chapter_name' => '章节',
            'et_ids' => '',
            'rand_num' => 0,
            'order' => 1,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $courseChapterSql = $this->_formatInsert('oa_course_article_chapter', $chapterData);
        $this->_exeSql($courseChapterSql);
        // 子章节数据
        $chapterSql = "select * from `oa_course_article_chapter` WHERE `article_id` = '{$articleInfo[0]['article_id']}' AND `domain` = '{$this->qyDomain}'  and `status` < 3";
        $chapterInfo = $db->query($chapterSql);
        if (empty($chapterInfo)) {
            Log::record('---Add Course fail info:没有找到章节数据', Log::ERR);
            return true;
        }
        $sourceSql = "select * from `oa_course_source` WHERE `source_title` = '员工如何进行课程学习' AND `domain` = '{$this->qyDomain}'  and `status` < 3";
        $sourceInfo = $db->query($sourceSql);
        if (empty($sourceInfo)) {
            Log::record('---Add Course fail info:没有找到素材数据', Log::ERR);
            return true;
        }
        $chapterChildData = [
            'article_id' => $articleInfo[0]['article_id'],
            'parent_id' => $chapterInfo[0]['article_chapter_id'],
            'source_id' => $sourceInfo[0]['source_id'],
            'chapter_name' => '章节',
            'et_ids' => '',
            'rand_num' => 0,
            'order' => 1,
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $chapterChildSql = $this->_formatInsert('oa_course_article_chapter', $chapterChildData);
        $this->_exeSql($chapterChildSql);
        // 课程权限数据
        $rightData = [
            'class_id' => $classInfo[0]['class_id'],
            'article_id' => $articleInfo[0]['article_id'],
            'award_id' => 0,
            'obj_type' => 1,
            'obj_id' => 2,
            'domain' => $this->qyDomain,
            'status' => 1,
        ];
        $rightSql = $this->_formatInsert('oa_course_right', $rightData);
        $this->_exeSql($rightSql);
        // 添加运营中心 Banner
        $this->addBanner($courseData, $classInfo, $articleInfo);
    }

    // 营运中心首页
    private function _addRecommend($articleInfo)
    {
        $db = &Db::getInstance();
        $recommendSql = "select `recommender_id` from `oa_common_recommender` WHERE `status` < 3 ORDER BY `recommender_id` DESC LIMIT 1";
        $recommendNum = $db->query($recommendSql);

        // 首页推荐数据
        $defaultData = [
            'type' => 3,
            'displayorder' => $recommendNum[0]['recommender_id'] + 1,
            'hide' => 1,
            'system' => 2,
            'title' => $articleInfo['article_title'],
            'attach_id' => $articleInfo['cover_id'],
            'pic' => $articleInfo['cover_url'],
            'url' => 'Course/Frontend/Index/Detail/Index?article_id=' . $articleInfo['article_id'] . '&data_id=' . $articleInfo['data_id'] . '&article_type=' . $articleInfo['article_type'],
            'description' => $articleInfo['summary'],
            'app_dir' => 'Course',
            'app_identifier' => APP_IDENTIFIER,
            'data_id' => $articleInfo['article_id'],
            'data_category_id' => $articleInfo['class_id'],
            'data_type' => '图文',
            'data' => '',
            'dateline' => $articleInfo['update_time'],
            'adminer_id' => '',
            'adminer' => '员圈小助手',
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $defaultSql = $this->_formatInsert('oa_common_recommender', $defaultData);
        $this->_exeSql($defaultSql);

        // 添加权限数据
        $recommendSql = "select * from `oa_common_recommender` WHERE `title` = '{$articleInfo['article_title']}' and `domain` = '{$this->qyDomain}'  and `status` < 3";
        $recommendInfo = $db->query($recommendSql);
        if (empty($recommendInfo)) {
            Log::record('---Add Course fail info:没有找到推荐数据', Log::ERR);
            return;
        }
        $rightData = [
            'recommender_id' => $recommendInfo[0]['recommender_id'],
            'obj_type' => 1,
            'obj_id' => -1,
            'type' => 3,
            'displayorder' => $recommendNum[0]['recommender_id'] + 1,
            'hide' => 1,
            'system' => 2,
            'app_dir' => 'Course',
            'app_identifier' => APP_IDENTIFIER,
            'data_id' => $articleInfo['article_id'],
            'data_category_id' => $articleInfo['class_id'],
            'dateline' => $articleInfo['update_time'],
            'adminer_id' => '',
            'adminer' => '员圈小助手',
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime,
        ];
        $rightSql = $this->_formatInsert('oa_common_recommender_right', $rightData);
        $this->_exeSql($rightSql);
    }

    const TYPE_BANNER = 1;
    const VALUE_DISPLAYORDER_MIN = 1;
    const HIDE_NO = 1;
    const SYSTEM_NO = 2;

    /**
     * 添加运营中心 Banner
     */
    private function addBanner($courseData, $classInfo, $articleInfo)
    {
        $banner = [
            'type' => self::TYPE_BANNER,
            'displayorder' => self::VALUE_DISPLAYORDER_MIN,
            'hide' => self::HIDE_NO,
            'system' => self::SYSTEM_NO,
            'title' => $courseData['article_title'],
            'attach_id' => $courseData['cover_id'],
            'pic' => $courseData['cover_url'],
            'url' => 'Course/Frontend/Index/Detail/Index?article_id=' . $articleInfo[0]['article_id'] . '&data_id=' . $courseData['data_id'] . '&article_type=1',
            'description' => '',
            'app_dir' => 'Course',
            'app_identifier' => APP_IDENTIFIER,
            'data_id' => $articleInfo[0]['article_id'],
            'data_category_id' => $articleInfo[0]['class_id'],
            'data' => serialize([[
                'id' => $classInfo[0]['class_id'],
                'name' => $classInfo[0]['class_name'],
                'upId' => 0,
                'url' => frontUrl('/app/page/course/list/list', ['class_id' => $classInfo[0]['class_id']], 'Course'),
            ]]),
            'dateline' => MILLI_TIME,
            'adminer_id' => '',
            'adminer' => '员圈小助手',
            'domain' => $this->qyDomain,
            'status' => 1,
            'created' => $this->nowTime
        ];

        $defaultSql = $this->_formatInsert('oa_common_recommender', $banner);
        $this->_exeSql($defaultSql);

        // 更新 displayorder
        $id = Db::getInstance()->getLastLinkID()->lastInsertId();
        $this->_exeSql("UPDATE `oa_common_recommender` SET `displayorder` = {$id} WHERE `recommender_id` = {$id}");
    }

    /**
     * 根据数组数据格式化为添加sql语句
     * @author tangxingguo
     * @param string $tableName 表名
     * @param array $data 数据
     * @return string|void
     */
    private function _formatInsert($tableName, $data)
    {
        if (empty($data) && !is_array($data)) {
            return;
        }

        // 拼接sql
        $sql = "INSERT INTO `{$tableName}` ";
        $keys = "(";
        $values = "(";
        foreach ($data as $k => $v) {
            if (array_slice($data, -1, 1) == [$k => $v]) {
                $symbol = "";
            } else {
                $symbol = ",";
            }
            $keys .= "`{$k}`{$symbol} ";
            if (is_numeric($v)) {
                $values .= "{$v}{$symbol} ";
            } else {
                $values .= "'{$v}'{$symbol} ";
            }
        }
        $keys .= ") VALUES ";
        $values .= ");";

        $sql .= $keys . $values;

        return $sql;
    }
}