<?php
/**
 * User: gq
 * Email: m@9026.com
 * Date: 2017/11/15
 * Time: 16:49
 */

namespace App\Widget\Tools;


use Illuminate\Support\Facades\DB;

class InsertSql
{

//    免费模板 createCompanyInfo
    public static function createFreeInfo($appid)
    {
        \DB::table('cp_company_info')->insert(array (
            0 =>
                array (
                    'appid' => $appid,
                    'name' => '公司名称',
                    'desc' => '公司简介',
                    'address' => '省市区地址',
                    'map' => '四川省成都市金牛区金泉街道蜀西路46-附23-24号盛大国际',
                    'lat' => '30.715277',
                    'lon' => '103.989748',
                    'detail_address' => '四川省成都市金牛区金泉街道蜀西路46-附23-24号盛大国际',
                    'start_time' => '09:00',
                    'end_time' => '18:00',
                    'phone' => '15281772600',
                    'pic' => env('APP_URL').'/upload/agent_pic/20171024/27d254fdcee75a632e9c9548f336403c.jpg',
                    'show' => env('APP_URL').'/upload/agent_show/20171024/faccf0bd12292b713f33238281454fe2.jpg',
                ),
            )
        );
    }
//    公司模板  （跨域）
    public static function createCompanyInfo($uniacid)
    {
//        创建幻灯片 分类 内容 表单设置 站点设置
        \DB::table('ims_yyf_company_slide')->insert(array (
                array (
                        'sortrank' => 0,
                        'images' => 'https://u5.9026.com/attachment/images/3/2017/10/f8yj7l8eGguH2EzilhfQqEzGeVZVlQ.png',
                        'uniacid' => $uniacid,   //小程序id
                        'aid' => 0,
                 ),
                array (
                        'sortrank' => 0,
                        'images' => 'https://u5.9026.com/attachment/images/3/2017/10/BnApna9DnhP4sOGeKHnVw4n53eOMO1.png',
                        'uniacid' => $uniacid,
                        'aid' => 0,
                 ),
                array (
                        'sortrank' => 0,
                        'images' => 'https://u5.9026.com/attachment/images/3/2017/10/BnApna9DnhP4sOGeKHnVw4n53eOMO1.png',
                        'uniacid' => $uniacid,
                        'aid' => 0,
                 ),
            )
        );


        \DB::table('ims_yyf_company_category')->insert(array (
                array (
                        'name' => '公司简介',
                        'sortrank' => 0,
                        'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/HhLn5T6nMo1MQGtqXoYtc11ncgtMNN.png',
                        'uniacid' => $uniacid,
                        'type' => 3,
                        'content' => '',
                        'isshow' => 1,
                        'isshow_nav' => 0,
                        'show_num' => 4,
                        'fid' => 0,
                 ),
                array (
                          'name' => '公司案列',
                        'sortrank' => 0,
                        'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/FE9Ly9Bf7ZTyLe7zSlftZ98K3N0l3t.png',
                        'uniacid' => $uniacid,
                        'type' => 1,
                        'content' => '',
                        'isshow' => 1,
                        'isshow_nav' => 0,
                        'show_num' => 4,
                        'fid' => 0,
                 ),
                array (
                        'name' => '新闻资讯',
                        'sortrank' => 0,
                        'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/YxHtw0v8toT8ztvZWTK8tTcHs486t6.png',
                        'uniacid' => $uniacid,
                        'type' => 2,
                        'content' => '',
                        'isshow' => 1,
                        'isshow_nav' => 0,
                        'show_num' => 4,
                        'fid' => 0,
                 ),

            )
        );
//        获取分类最后插入记录的id
        $last_id = \DB::table('ims_yyf_company_category')->insertGetId(
                array (
                        'name' => '服务内容',
                        'sortrank' => 0,
                        'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/YxHtw0v8toT8ztvZWTK8tTcHs486t6.png',
                        'uniacid' => $uniacid,
                        'type' => 1,
                        'content' => '',
                        'isshow' => 1,
                        'isshow_nav' => 0,
                        'show_num' => 4,
                        'fid' => 0,
                 )
        );

        \DB::table('ims_yyf_company_news')->insert(array (
                array (
                    'title' => '微信开发',
                    'cid' => $last_id,
                    'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                    'uniacid' => $uniacid,
                    'addtime' => time(),
                    'content' => '这里是微信开发内容',
                    'sortrank' => 1,
                    'videosrc' => '',
                    'appid' => '',
                    'pageaddress' => '',
                ),
                array (
                    'title' => '新闻资讯的标题',
                    'cid' => $last_id-1,
                    'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                    'uniacid' => $uniacid,
                    'addtime' => time(),
                    'content' => '这里是新闻资讯的标题内容',
                    'sortrank' => 1,
                    'videosrc' => '',
                    'appid' => '',
                    'pageaddress' => '',
                ),
                array (
                    'title' => '电商小程序',
                    'cid' => $last_id-2,
                    'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                    'uniacid' => $uniacid,
                    'addtime' => time(),
                    'content' => '这里是电商小程序内容',
                    'sortrank' => 1,
                    'videosrc' => '',
                    'appid' => '',
                    'pageaddress' => '',
                ),
            )
        );
//        获取公司简介的文章id
        $news_id = \DB::table('ims_yyf_company_news')->insertGetId(
            array (
                'title' => '公司简介的标题',
                'cid' => $last_id-3,
                'thumb' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                'uniacid' => $uniacid,
                'addtime' => time(),
                'content' => '这里是公司简介的内容',
                'sortrank' => 1,
                'videosrc' => '',
                'appid' => '',
                'pageaddress' => '',
            )
        );

        \DB::table('ims_yyf_company_form')->insert(array (
                array (
                    'uniacid' => $uniacid,
                    't1name' => '姓名',
                    't1full' => 0,
                    't1show' => 1,
                    't2name' => '联系方式',
                    't2full' => 0,
                    't2show' => 1,
                    't3name' => '邮箱',
                    't3full' => 0,
                    't3show' => 1,
                    't4name' => '其他',
                    't4full' => 0,
                    't4show' => 1,
                    'rname' => '',
                    'rvalue' => '',
                    'rfull' => 0,
                    'rshow' => 0,
                    'cname' => '',
                    'cvalue' => '',
                    'cfull' => 0,
                    'cshow' => 0,
                    'aname' => '请输入您的意见',
                    'afull' => 0,
                    'ashow' => 1,
                    'desc' => '在线留言',
                    'catname' => '在线留言',
                    'interval' => 1,
                    'successtext' => '提交成功',
                ),
            )
        );

        \DB::table('ims_yyf_company_tabbar')->insert(array (
                array (
                    'uniacid' => $uniacid,
                    'm1_name' => '首页',
                    'm2_name' => '公司简介',
                    'm3_name' => '联系我们',
                    'm4_name' => '业务咨询',
                    'm1_path' => 'index',
                    'm2_path' => "a{$news_id}",  //分类id 或是文章id 文章id前缀a 例a393
                    'm3_path' => 'contact',
                    'm4_path' => 'message',
                    'm1_img' => 'https://u5.9026.com/attachment/images/3/2017/10/EyYSVysAqWYya1vmV1HmHsuJaM2uj9.png',
                    'm2_img' => 'https://u5.9026.com/attachment/images/3/2017/10/W6aWlUAi6F2LdaQf2fcccFzClAFcLZ.png',
                    'm3_img' => 'https://u5.9026.com/attachment/images/3/2017/10/XDNuwYdF9du0cWJNc4Nu9dDM9ufYD4.png',
                    'm4_img' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                    'm1_selimg' => 'https://u5.9026.com/attachment/images/3/2017/10/EyYSVysAqWYya1vmV1HmHsuJaM2uj9.png',
                    'm2_selimg' => 'https://u5.9026.com/attachment/images/3/2017/10/W6aWlUAi6F2LdaQf2fcccFzClAFcLZ.png',
                    'm3_selimg' => 'https://u5.9026.com/attachment/images/3/2017/10/XDNuwYdF9du0cWJNc4Nu9dDM9ufYD4.png',
                    'm4_selimg' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',
                    'border_color' => '#ffffff',
                    'background_color' => '#ffffff',
                    'color' => '#d9d9d9',
                    'sel_color' => '#666666',
                ),
            )
        );
//        站点设置  设置首页的标题 联系我们的信息等
        \DB::table('ims_yyf_company_sysinfo')->insert(array (
                array (
                    'uniacid' => $uniacid,
                    'title' => '首页网站标题',
                    'notice' => '网站公告',
                    'phone' => '13880988888',
                    'jing' => '30.714650',
                    'wei' => '103.990120',
                    'qq' => 12345678,
                    'address' => '蜀西路',
                    'email' => '88qq.com',
                    'copyright' => '底部版权信息',
                    'name' => '首页转发标题',
                    'message_email' => '88qq.com',
                    'message_title' => '您有新的业务咨询',
                    'smtp_email' => '88qq.com',
                    'smtp_key' => '授权码',
                ),
            )
        );

        //        联系我们页数据 图片 公司log 名称
        \DB::table('ims_yyf_company_style')->insert(array (
                array (
                    'uniacid' => $uniacid,
                    'tcolor' => '#2d7dee',
                    'slide_close' => '0',
                    'nav_close' => '0',
                    'notice_close' => '0',
                    'custom_close' => '0',
                    'contact_background' => 'https://u5.9026.com/attachment/images/3/2017/10/eu80NQI0M9q70NTMg0MAfUG0FDu0gN.png',  //联系我们背景图片
                    'contact_name' => 'xxx公司名称',
                    'contact_logo' => 'https://u5.9026.com/attachment/images/3/2017/10/eu80NQI0M9q70NTMg0MAfUG0FDu0gN.png',  //公司log
                    'horn' => 'https://u5.9026.com/attachment/images/3/2017/10/knWWN1p14S9o3mZ69X55S0xZnFSOEF.png',  //首页公告栏图标
                    'title_style' => '0',
                    'nav_style' => '0',
                    'slide_height' => '330',
                ),
            )
        );
    }

//    高级商城
    public static function  createMallInfo($uniacid,$user_id)
    {
//        商城设置 插入两张表
        $name = DB::connection('we7')->select("select name from `ims_uni_account` where uniacid=$uniacid");  //小程序名称
        DB::connection('we7')->insert("INSERT INTO `hjmall_wechat_app` VALUES (null,$uniacid,$user_id,$name,'wx7881c559997a5d6d','62110047ee7ac85d4e915aecdd397493',NULL,'1398823402','c1891122765718911227657189112276','a7acea59b817587','09bfb8f08dec066d2',time(),0);");
        DB::connection('we7')->insert("INSERT INTO `hjmall_store` VALUES 
        (null,0,0,$uniacid,$user_id,0,1,'演示分销商城','','13888888888',1,'底部版权文字','https://u5.9026.com/addons/zjhj_mall/core/web/uploads/image/67/67ee41430bc96c6848a49eee7a6d6be3.png',
        '/pages/article-detail/article-detail?id=about_us',10,7,0,'888','apikey',3,'[{\"name\":\"banner\"},{\"name\":\"search\"},{\"name\":\"nav\"},{\"name\":\"topic\"},{\"name\":\"coupon\"},{\"name\":\"single_cat-1\"},{\"name\":\"banner\"},{\"name\":\"coupon\"},{\"name\":\"coupon\"},{\"name\":\"coupon\"}]','',3,0,0,1,6,1);");
//        首页排版
        DB::connection('we7')->insert("INSERT INTO `hjmall_home_block` VALUES (null,1,'案例展示','{\"pic_list\":[{\"pic_url\":\"https:\/\/u5.9026.com\/addons\/zjhj_mall\/core\/web\/uploads\/image\/a7\/a7acea59b81758709bfb8f08dec066d2.jpg\",\"url\":\"\",\"open_type\":\"\"}]}',time(),0);");
  //      门店设置
        $store_id = DB::connection('we7')->select("select id from `hjmall_store` where uniacid=$uniacid where user_id=$user_id");
        DB::connection('we7')->insert("INSERT INTO `hjmall_shop` VALUES (null,$store_id,'门店1','13880642883','蜀西路100号',0,time());");
    }

    public static function createBaseMallInfo($uniacid)
    {

    }
//    基础商城
}