<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\common\model;

use think\Model;
use think\Db;
use think\Cache;
 
class UpdateSql{
    
    public static function execute(){
        
        try {
            $adminFields = Db::name("admin")->getTableFields();
            $fenxiaoFields = Db::name("bbfx_fenxiao")->getTableFields();
            $baseFields = Db::name("bbfx_base")->getTableFields();
            $platformFields = Db::name("platform")->getTableFields();
            $attachmentFields = Db::name("attachment")->getTableFields();
            $orderFields = Db::name("bbfx_order")->getTableFields();
            $order_goodsFields = Db::name("bbfx_order_goods")->getTableFields();
            $userFields = Db::name("bbfx_user")->getTableFields();
            $goodsFields = Db::name("bbfx_goods")->getTableFields();
            $user_cartFields = Db::name("bbfx_user_cart")->getTableFields();
            $fenxiao_levelFields = Db::name("bbfx_fenxiao_level")->getTableFields();
            $agentFields = Db::name("bbfx_agent")->getTableFields();
            $fenxiao_orderFields = Db::name("bbfx_fenxiao_order")->getTableFields();
            $withdrawal_logFields = Db::name("bbfx_withdrawal_log")->getTableFields();
            $diypageFields = Db::name("bbfx_diypage")->getTableFields();
            $pay_orderFields = Db::name("bbfx_pay_order")->getTableFields();
            $recharge_orderFields = Db::name("bbfx_recharge_order")->getTableFields();
            $admin_logFields = Db::name("admin_log")->getTableFields();
            $fenxiao_applyFields = Db::name("bbfx_fenxiao_apply")->getTableFields();
            $fenxiao_posterFields = Db::name("bbfx_fenxiao_poster")->getTableFields();
            $scoreshop_goodsFields = Db::name("bbfx_scoreshop_goods")->getTableFields();
            $scoreshop_orderFields = Db::name("bbfx_scoreshop_order")->getTableFields();
            $scoreshop_order_goodsFields = Db::name("bbfx_scoreshop_order_goods")->getTableFields();
            $categoryFields = Db::name("bbfx_category")->getTableFields();
            $transfer_account_logFields = Db::name("bbfx_transfer_account_log")->getTableFields();
            $returnFields = Db::name("bbfx_return")->getTableFields();
            $return_itemFields = Db::name("bbfx_return_item")->getTableFields();
            $return_logFields = Db::name("bbfx_return_log")->getTableFields();
            $transfer_accountFields = Db::name("bbfx_transfer_account")->getTableFields();
            $money_logFields = Db::name("bbfx_money_log")->getTableFields();
            $order_refundFields = Db::name("bbfx_order_refund")->getTableFields();
            $expressFields = Db::name("bbfx_express")->getTableFields();
            $verifcodeFields = Db::name("bbfx_verifcode")->getTableFields();
            $return_ruleFields = Db::name("bbfx_return_rule")->getTableFields();
            
            if(!in_array('selfbuy_achievement',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `selfbuy_achievement` INT(10) NOT NULL DEFAULT '0' COMMENT '自购业绩:1=开启,0=关闭' AFTER `abonus`;");
            }
            
            if(!in_array('selfbuy_achievement',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `become_team_achievement` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分销商条件团队业绩' AFTER `selfbuy_achievement`;");
            }
            
            if(!in_array('is_pay_password',$baseFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_pay_password` INT(10) NOT NULL DEFAULT '0' COMMENT '' AFTER `is_balancepay`;");
            }
            if(!in_array('is_gzh_login',$baseFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_gzh_login` INT(10) NOT NULL DEFAULT '0' AFTER `is_pay_password`;");
            }
            
            if(!pdo_tableexists("bbfx")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `version_name` varchar(255) NOT NULL,
                  `version` int(10) NOT NULL DEFAULT '0',
                  `sversion_name` VARCHAR(100) NULL,
                  `sversion` int(10) NOT NULL DEFAULT '0',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $bbfxFields = Db::name("bbfx")->getTableFields();
                $bbfx = Db::name("bbfx")->find();
            }
            else{
                $bbfxFields = Db::name("bbfx")->getTableFields();
                $bbfx = Db::name("bbfx")->find();
            }
            
            //v1.0.2
            if(!in_array('is_user',$attachmentFields)){
                Db::execute("ALTER TABLE ".tablename("attachment")." ADD `is_user` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('order_oper',$baseFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `order_oper` INT(10) UNSIGNED NOT NULL DEFAULT '1';");
            }
            if(!in_array('user_coupon_id',$orderFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `user_coupon_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('user_coupon_id',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `user_coupon_id` INT(10) NOT NULL DEFAULT '0';");
            }
            
            if(!pdo_tableexists("bbfx_coupon")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_coupon")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(11) NOT NULL,
                  `name` varchar(100) NOT NULL COMMENT '优惠券名称',
                  `money` decimal(10,2) UNSIGNED NOT NULL COMMENT '优惠券金额',
                  `mj_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '满减金额（0为不限制）',
                  `validitytime` int(10) NOT NULL DEFAULT '0' COMMENT '有效期（天）,0为为不限制',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:0=禁用,1=正常(已领取的优惠券禁用无效)',
                  `goods_ids` varchar(500) DEFAULT NULL COMMENT '指定商品',
                  `total` int(10) NOT NULL DEFAULT '-1' COMMENT '优惠券数量',
                  `condition_type` int(10) NOT NULL DEFAULT '0' COMMENT '使用条件:0=无条件,1=指定商品,2=满减金额',
                  `createtime` int(11) NOT NULL COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $couponFields = Db::name("bbfx_coupon")->getTableFields();
            }
            else{
                $couponFields = Db::name("bbfx_coupon")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_user_coupon")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_coupon")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(11) NOT NULL,
                  `user_id` int(11) NOT NULL COMMENT '用户ID',
                  `coupon_id` int(11) NOT NULL COMMENT '优惠券ID',
                  `name` varchar(100) NOT NULL COMMENT '优惠券名称',
                  `money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '优惠券金额',
                  `mj_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '满减金额',
                  `endtime` int(11) NOT NULL COMMENT '到期时间，0为不限制',
                  `goods_ids` varchar(500) DEFAULT NULL COMMENT '指定商品',
                  `info` text NULL COMMENT '优惠券信息',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已使用,0=未使用',
                  `condition_type` int(10) NOT NULL DEFAULT '0',
                  `receive_type` int(10) NOT NULL DEFAULT '0' COMMENT '领取类型:0=后台发送,1=免费领取',
                  `createtime` int(11) NOT NULL COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_couponFields = Db::name("bbfx_user_coupon")->getTableFields();
            }
            else{
                $user_couponFields = Db::name("bbfx_user_coupon")->getTableFields();
            }
            
            //v1.0.3
            if(!in_array('become_card',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `become_card` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('freeze_money',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `freeze_money` INT(10) UNSIGNED NOT NULL DEFAULT '0';");
            }
            if(!in_array('freeze_money',$userFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `freeze_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00';");
            }
            
            if(!pdo_tableexists("bbfx_member_card")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_member_card")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '会员卡名称',
                  `give` varchar(255) DEFAULT NULL COMMENT '赠送:1=积分,2=优惠券',
                  `give_score` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '赠送积分',
                  `give_coupon` text NULL COMMENT '赠送优惠券',
                  `style` varchar(255) NOT NULL COMMENT '样式',
                  `yx_day` int(10) NOT NULL DEFAULT '10' COMMENT '有效期天数，-1=永久',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '价格',
                  `discount` decimal(10,1) UNSIGNED NOT NULL DEFAULT '10.0' COMMENT '折扣',
                  `content` text NULL COMMENT '使用说明',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $member_cardFields = Db::name("bbfx_member_card")->getTableFields();
            }
            else{
                $member_cardFields = Db::name("bbfx_member_card")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_member_card_order")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_member_card_order")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_no` varchar(100) DEFAULT NULL COMMENT '订单号',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '订单金额',
                  `member_card_id` int(10) NOT NULL DEFAULT '0' COMMENT '会员卡ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '支付状态:1=已支付,0=未支付',
                  `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型',
                  `paytime` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间',
                  `endtime` int(11) NOT NULL DEFAULT '0' COMMENT '会员卡到期时间，-1永久',
                  `info` text NULL COMMENT '会员卡数据',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $member_card_orderFields = Db::name("bbfx_member_card_order")->getTableFields();
            }
            else{
                $member_card_orderFields = Db::name("bbfx_member_card_order")->getTableFields();
            }
            
            //v1.0.4
            if(!in_array('is_spec',$goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_spec` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('is_management',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_management` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('management_reward',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `management_reward` TEXT NULL;");
            }
            if(!in_array('oper',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `oper` INT(10) UNSIGNED NOT NULL DEFAULT '1';");
            }
            
            if(!pdo_tableexists("bbfx_goods_spec")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_spec")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '规格名称',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_specFields = Db::name("bbfx_goods_spec")->getTableFields();
            }
            else{
                $goods_specFields = Db::name("bbfx_goods_spec")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_goods_spec_item")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_spec_item")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '规格ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '规格项名称',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_spec_itemFields = Db::name("bbfx_goods_spec_item")->getTableFields();
            }
            else{
                $goods_spec_itemFields = Db::name("bbfx_goods_spec_item")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_goods_spec_sku")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_spec_sku")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `sku` text NULL COMMENT '规格组合ID',
                  `sku_name` text NULL COMMENT '规格组合名称',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '价格',
                  `stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '库存',
                  `thumb` varchar(255) DEFAULT NULL COMMENT '商品图片',
                  `original_price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '原价',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_spec_skuFields = Db::name("bbfx_goods_spec_sku")->getTableFields();
            }
            else{
                $goods_spec_skuFields = Db::name("bbfx_goods_spec_sku")->getTableFields();
            }
            
            if(!in_array('sku_id',$user_cartFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_user_cart")." ADD `sku_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('sku_id',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `sku_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('sku_name',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `sku_name` varchar(500) NULL;");
            }
            if(!in_array('sku',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `sku` TEXT NULL;");
            }
            
            if(!pdo_tableexists("bbfx_news_article")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_news_article")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '文章标题',
                  `thumb` text NULL COMMENT '文章封面',
                  `content` longtext NULL COMMENT '文章内容',
                  `link` text NULL COMMENT '文章链接',
                  `type` int(10) NOT NULL DEFAULT '1' COMMENT '类型:1=普通文章,2=公众号文章',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `browse` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '浏览量',
                  `createtime` int(11) NOT NULL COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $news_articleFields = Db::name("bbfx_news_article")->getTableFields();
            }
            else{
                $news_articleFields = Db::name("bbfx_news_article")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_news_video")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_news_video")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '视频标题',
                  `thumb` varchar(255) DEFAULT NULL COMMENT '视频封面',
                  `content` text NULL COMMENT '视频链接',
                  `link` text NULL COMMENT '视频链接',
                  `type` int(10) NOT NULL DEFAULT '1' COMMENT '类型:1=普通视频,2=视频链接',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `browse` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '浏览量',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $news_videoFields = Db::name("bbfx_news_video")->getTableFields();
            }
            else{
                $news_videoFields = Db::name("bbfx_news_video")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_news_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_news_category")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `type` int(10) NOT NULL DEFAULT '1' COMMENT '类型:1=文章,2=视频',
                  `title` varchar(100) NOT NULL COMMENT '分类标题',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $news_categoryFields = Db::name("bbfx_news_category")->getTableFields();
            }
            else{
                $news_categoryFields = Db::name("bbfx_news_category")->getTableFields();
            }
            
            //v1.0.5
            if(!in_array('sversion_name',$bbfxFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx")." ADD `sversion_name` VARCHAR(100) NULL;");
            }
            if(!in_array('sversion',$bbfxFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx")." ADD `sversion` int(10) NOT NULL DEFAULT '0';");
            }
            if(!pdo_tableexists("bbfx_plugin")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_plugin")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `name` varchar(100) DEFAULT NULL,
                  `ident` varchar(100) DEFAULT NULL,
                  `type` int(10) NOT NULL DEFAULT '0',
                  `status` int(10) NOT NULL DEFAULT '1',
                  `icon` varchar(255) DEFAULT NULL,
                  `sort` int(10) NOT NULL DEFAULT '0',
                  `url` varchar(255) DEFAULT NULL,
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pluginFields = Db::name("bbfx_plugin")->getTableFields();
                
                Db::execute("INSERT INTO ".tablename("bbfx_plugin")." (`id`, `name`, `ident`, `type`, `status`, `icon`, `sort`, `url`) VALUES
                (1, '分销中心', 'fenxiao', 2, 1, '/assets/images/plugin/plugin-fenxiao.png', 99, '/fenxiao/index'),
                (2, 'DIY页面', 'diypage', 1, 1, '/assets/images/plugin/plugin-diypage.png', 98, '/diypage/index'),
                (3, '积分商城', 'scoreshop', 1, 1, '/assets/images/plugin/plugin-scoreshop.png', 98, '/scoreshop/index'),
                (4, '资金转账', 'transfer_account', 1, 1, '/assets/images/plugin/plugin-transfer_account.png', 98, '/transfer_account/index'),
                (5, '区域代理', 'agent', 1, 1, '/assets/images/plugin/plugin-agent.png', 98, '/agent/index'),
                (6, '会员卡', 'card', 1, 1, '/assets/images/plugin/plugin-card.png', 98, '/card/index'),
                (7, '文章视频', 'news', 1, 1, '/assets/images/plugin/plugin-news.png', 98, '/news/index'),
                (8, '返还奖', 'return', 2, 1, '/assets/images/plugin/plugin-return.png', 98, '/return/index'),
                (9, '链动2+1模式', 'transfer21_mode', 2, 1, '/assets/images/plugin/plugin-transfer21_mode.png', 98, '/transfer21_mode/index'),
                (10, '三三复制', 'transfer_mode', 2, 1, '/assets/images/plugin/plugin-transfer_mode.png', 98, '/transfer_mode/index'),
                (11, '加权分红', 'abonus', 2, 1, '/assets/images/plugin/plugin-abonus.png', 98, '/abonus/index'),
                (12, '双轨模式', 'double_track', 2, 1, '/assets/images/plugin/plugin-double_track.png', 98, '/double_track/index');");
            }
            else{
                $pluginFields = Db::name("bbfx_plugin")->getTableFields();
            }
            
            
            
            //v1.0.6
            if(!in_array('repurchase_reward1',$fenxiao_levelFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `repurchase_reward1` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00';");
            }
            if(!in_array('repurchase_reward2',$fenxiao_levelFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `repurchase_reward2` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00';");
            }
            if(!in_array('repurchase_reward3',$fenxiao_levelFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `repurchase_reward3` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00';");
            }
            if(!in_array('repurchase_reward1',$goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `repurchase_reward1` TEXT NULL;");
            }
            if(!in_array('repurchase_reward2',$goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `repurchase_reward2` TEXT NULL;");
            }
            if(!in_array('repurchase_reward3',$goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `repurchase_reward3` TEXT NULL;");
            }
            if(!in_array('mch_id',$platformFields)){
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `mch_id` VARCHAR(100) NULL COMMENT '公众号商户号';");
            }
            if(!in_array('paykey',$platformFields)){
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `paykey` VARCHAR(255) NULL COMMENT '公众号支付秘钥';");
            }
            if(!in_array('cert',$platformFields)){
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `cert` VARCHAR(255) NULL COMMENT '公众号支付证书';");
            }
            if(!in_array('certkey',$platformFields)){
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `certkey` VARCHAR(255) NULL COMMENT '公众号支付证书秘钥';");
            }
            if(!in_array('platform',$orderFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `platform` VARCHAR(100) NOT NULL DEFAULT 'wxapp';");
            }
            if(!in_array('kefu_link',$baseFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `kefu_link` TEXT NULL COMMENT '客服链接';");
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","jicha")->find();
            if(empty($plugin)){
                Db::execute("INSERT INTO ".tablename("bbfx_plugin")." (`id`, `name`, `ident`, `type`, `status`, `icon`, `sort`, `url`) VALUES
                (14, '级差奖', 'jicha', 2, 1, '/assets/images/plugin/plugin-jicha.png', 98, '/jicha/index'),
                (15, '复购奖', 'repurchase', 2, 1, '/assets/images/plugin/plugin-repurchase.png', 98, '/repurchase/index'),
                (16, '见单奖', 'jiandan', 2, 1, '/assets/images/plugin/plugin-jiandan.png', 98, '/jiandan/index'),
                (17, '平级奖', 'pingji', 2, 1, '/assets/images/plugin/plugin-pingji.png', 98, '/pingji/index'),
                (18, '管理奖', 'management', 2, 1, '/assets/images/plugin/plugin-management.png', 98, '/management/index');");
            }
            
            $config = Db::name("config")->where("name","logo")->find();
            if(empty($config)){
                Db::execute("INSERT INTO ".tablename("config")." (`name`, `group`, `title`, `tip`, `type`, `visible`, `value`, `content`, `rule`, `extend`, `setting`) VALUES
                ('logo', 'basic', 'LOGO', '', 'image', '', '/assets/images/avatar.jpg', '', '', '', '{\"table\":\"\",\"conditions\":\"\",\"key\":\"\",\"value\":\"\"}'),
                ('login_bg', 'basic', '登录背景', '', 'image', '', '/assets/images/login-bg.jpg', '', '', '', '{\"table\":\"\",\"conditions\":\"\",\"key\":\"\",\"value\":\"\"}');");
            }
            
            //v2.0.7
            if(!in_array('type',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `type` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('seckill_activity_id',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `seckill_activity_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('seckill_goods_id',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `seckill_goods_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('yies_mode',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `yies_mode` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('yiestransfer_sup_uid',$userFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `yiestransfer_sup_uid` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('management_type',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `management_type` INT(10) NOT NULL DEFAULT '2';");
            }
            if(!in_array('is_management',$fenxiao_levelFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `is_management` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('management_reward',$fenxiao_levelFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `management_reward` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0';");
            }
            
            //v2.0.40
            if(!in_array('pingji_layer',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `pingji_layer` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '平级奖代数';");
            }
            else{
                if(!in_array('pj_reward_layer',$fenxiao_levelFields)){
                    Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `pj_reward_layer` TEXT NULL COMMENT '平级奖';");
                }
            }
            
            //v2.0.41
            if(!in_array('is_jiandan_jicha',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_jiandan_jicha` INT(10) NOT NULL DEFAULT '0';");
            }
            
            //v2.0.45
            if(!in_array('pingji_calculate',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." CHANGE `pingji_type` `pingji_calculate` INT(10) NOT NULL DEFAULT '2';");
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `pingji_type` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('pingji_type',$fenxiaoFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `pingji_type` INT(10) NOT NULL DEFAULT '0';");
            }
            
            //v2.0.46
            
            if(!in_array('yiestransfer_sup_uid',$userFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `yiestransfer_sup_uid` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!pdo_tableexists("bbfx_seckill_activity")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_seckill_activity")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `seckill_goods_ids` text NULL COMMENT '特价商品',
                  `name` varchar(255) DEFAULT NULL COMMENT '活动名称',
                  `starttime` int(11) DEFAULT '0' COMMENT '开启时间',
                  `endtime` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $seckill_activityFields = Db::name("bbfx_seckill_activity")->getTableFields();
            }
            else{
                $seckill_activityFields = Db::name("bbfx_seckill_activity")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_seckill_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_seckill_goods")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `type` int(10) NOT NULL DEFAULT '1' COMMENT '折扣类型:1=固定金额,2=折扣',
                  `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '秒杀价格',
                  `discount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '活动折扣',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `is_fenxiao` int(10) NOT NULL DEFAULT '1' COMMENT '参与分销:1=开启,0=关闭',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $seckill_goodsFields = Db::name("bbfx_seckill_goods")->getTableFields();
            }
            else{
                $seckill_goodsFields = Db::name("bbfx_seckill_goods")->getTableFields();
            }
            if(!in_array('seckill_activity_id',$order_goodsFields)){
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `seckill_activity_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('seckill_goods_id',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `seckill_goods_id` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('type',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `type` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('withdrawal',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `withdrawal` TEXT NULL;");
            }
            $menu_dashboard = Db::name("auth_rule")->where(['name'=>'dashboard','ismenu'=>1])->find();
            if(!empty($menu_dashboard)){
                Db::name("auth_rule")->where(['name'=>'dashboard','ismenu'=>1])->update(['ismenu'=>0]);
            }
            $profile_dashboard = Db::name("auth_rule")->where(['name'=>'general/profile','title'=>'Profile'])->find();
            if(!empty($profile_dashboard)){
                Db::name("auth_rule")->where(['id'=>$profile_dashboard['id']])->update(['title'=>'账号信息']);
            }
            $beian = Db::name("config")->where(['name'=>'beian','title'=>'Beian'])->find();
            if(!empty($beian)){
                Db::name("config")->where(['id'=>$beian['id']])->update(['title'=>'底部信息']);
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","seckill")->find();
            if(empty($plugin)){
                
                Db::name("bbfx_plugin")->where(['ident'=>'transfer21_mode'])->update(['type'=>3]);
                Db::name("bbfx_plugin")->where(['ident'=>'transfer_mode'])->update(['type'=>3]);
                Db::name("bbfx_plugin")->where(['ident'=>'double_track'])->update(['type'=>3]);
                Db::name("bbfx_plugin")->where(['ident'=>'return'])->update(['name'=>'返还奖']);
                Db::execute("INSERT INTO ".tablename("bbfx_plugin")." (`name`, `ident`, `type`, `status`, `icon`, `sort`, `url`) VALUES
                ('限时特价', 'seckill', 1, 1, '/assets/images/plugin/plugin-seckill.png', 98, '/seckill/index'),
                ('321模式', 'yies_mode', 3, 1, '/assets/images/plugin/plugin-yies_mode.png', 98, '/yies_mode/index');");
            }
            Db::name("bbfx_plugin")->where(['ident'=>'fenxiao','type'=>1])->update(['type'=>2]);
            
            //v2.0.47
            if(!in_array('subtitle',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `subtitle` varchar(255) DEFAULT NULL;");
            }
            if(!in_array('login_template',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `login_template` int(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('category_template',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `category_template` int(10) NOT NULL DEFAULT '0';");
            }
            if(!pdo_tableexists("bbfx_attachment_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_attachment_category")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '分类标题',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $attachment_categoryFields = Db::name("bbfx_attachment_category")->getTableFields();
            }
            else{
                $attachment_categoryFields = Db::name("bbfx_attachment_category")->getTableFields();
            }
            if(!in_array('category_id',$attachmentFields)){ 
                Db::execute("ALTER TABLE ".tablename("attachment")." ADD `category_id` int(10) NOT NULL DEFAULT '0';");
            }
            $menu_attachment = Db::name("auth_rule")->where(['name'=>'general/attachment','ismenu'=>1])->find();
            if(!empty($menu_attachment)){
                Db::name("auth_rule")->where(['name'=>'general/attachment','ismenu'=>1])->update(['ismenu'=>0]);
            }
            if(!in_array('withdrawal_balance_check',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `withdrawal_balance_check` int(10) NOT NULL DEFAULT '0';");
            }
            
            //v2.0.50
            if(!in_array('is_jiandan_interval',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_jiandan_interval` int(10) NOT NULL DEFAULT '0';");
            }
            
            //v2.0.51
            if(!in_array('is_abonus_gld',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_abonus_gld` int(10) NOT NULL DEFAULT '0';");
            }
            
            
            //v2.0.52
            if(!in_array('transfer_mode_pinji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `transfer_mode_pinji` int(10) NOT NULL DEFAULT '0';");
            }
            
            //v2.0.53
            if(!in_array('yies_mode_pingji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `yies_mode_pingji` int(10) NOT NULL DEFAULT '0';");
            }
            
            
            //v2.0.58
            if(!in_array('is_agent_xyok',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `is_agent_xyok` int(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('is_show_yx',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `is_show_yx` int(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('xy_title',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `xy_title` VARCHAR(100) NULL;");
            }
            if(!in_array('xy_content',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `xy_content` TEXT NULL;");
            }
            
            
            //v2.0.64
            $repurchasepingji = Db::name("bbfx_plugin")->where("ident","repurchasepingji")->find();
            if(empty($repurchasepingji)){
                Db::execute("INSERT INTO ".tablename("bbfx_plugin")." (`name`, `ident`, `type`, `status`, `icon`, `sort`, `url`) VALUES
                ( '复购平级奖', 'repurchasepingji', '2', '1', '/assets/images/plugin/plugin-repurchasepingji.png', '98', '/repurchasepingji/index');");
            }
            if(!in_array('is_repurchase_pingji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_repurchase_pingji` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('repurchase_pingji_layer',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `repurchase_pingji_layer` INT(10) NOT NULL DEFAULT '3';");
            }
            if(!in_array('is_repurchase',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_repurchase`  INT(10) NOT NULL DEFAULT '1';");
            }
            if(!in_array('is_repurchase_pingji',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_repurchase_pingji`  INT(10) NOT NULL DEFAULT '1';");
            }
            if(!in_array('is_repurchase_pingji_rule',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_repurchase_pingji_rule`  INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('repurchase_pingji_reward',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `repurchase_pingji_reward` TEXT NULL;");
            }
            if(!in_array('is_repurchase_pingji',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `is_repurchase_pingji` INT(10) NOT NULL DEFAULT '1';");
            }
            if(!in_array('repurchase_pingji_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `repurchase_pingji_reward` TEXT NULL;");
            }
            if(!in_array('layer',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `layer` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('skqrcode',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `skqrcode` VARCHAR(500) NULL;");
            }
            
            
            //v2.0.65
            if(in_array('repurchase_pingji_reward',$fenxiao_levelFields) && $bbfx['sversion'] == 2064){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." CHANGE `repurchase_pingji_reward` `repurchase_pingji_reward` TEXT NULL;");
            }
            
            //v2.0.67
            if(!in_array('buylevel_tips',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `buylevel_tips` VARCHAR(255) NULL COMMENT '购买商品等级不足提示';");
            }
            if(!in_array('is_fenxiao',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `is_fenxiao` INT(10) NOT NULL DEFAULT '0' COMMENT '分销状态:1=开启,0=关闭';");
            }
            if(!in_array('commission_rule',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `commission_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '分销规则:0=不开启,1=统一佣金,2=详细佣金';");
            }
            if(!in_array('commission1',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `commission1` TEXT NULL COMMENT '一级佣金配置';");
            }
            if(!in_array('commission2',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `commission2` TEXT NULL COMMENT '二级佣金配置';");
            }
            if(!in_array('commission3',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `commission3` TEXT NULL COMMENT '三级佣金配置';");
            }
            if(!in_array('one_share',$member_card_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." ADD `one_share` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('two_share',$member_card_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." ADD `two_share` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('three_share',$member_card_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." ADD `three_share` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('order_type',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `order_type` INT(10) NOT NULL DEFAULT '0' COMMENT '订单类型:0=普通商品订单,1=会员卡订单';");
            }
            
            //v2.0.71
            if(!pdo_tableexists("bbfx_agent_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_agent_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `province` varchar(100) NULL COMMENT '省份',
                  `city` varchar(100) NULL COMMENT '城区',
                  `area` varchar(100) NULL COMMENT '区县',
                  `street` varchar(100) NULL COMMENT '街道',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $agent_logFields = Db::name("bbfx_agent_log")->getTableFields();
            }
            else{
                $agent_logFields = Db::name("bbfx_agent_log")->getTableFields();
            }
            if(!in_array('is_give',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_give` INT(10) NOT NULL DEFAULT '0' COMMENT '复购赠送:1=开启,0=关闭';");
            }
            if(!in_array('give_type',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `give_type` INT(10) NOT NULL DEFAULT '0' COMMENT '赠送类型:1=赠送余额,2=赠送积分';");
            }
            if(!in_array('give',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `give` TEXT NULL COMMENT '复购赠送配置';");
            }
            if(!in_array('money_type',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `money_type` INT(10) NOT NULL DEFAULT '3' COMMENT '金额类型:1=余额,2=积分,3=佣金';");
            }
            if(!in_array('commission1_score',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `commission1_score` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '已级积分';");
            }
            if(!in_array('commission2_score',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `commission2_score` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '二级积分';");
            }
            if(!in_array('commission3_score',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `commission3_score` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '三级积分';");
            }
            if(!in_array('fenzhang_status',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `fenzhang_status` INT(10) NOT NULL DEFAULT '0' COMMENT '佣金分账:1=开启,0=关闭';");
            }
            if(!in_array('is_fenzhang',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_fenzhang` INT(10) NOT NULL DEFAULT '0' COMMENT '分账:1=开启,0=关闭';");
            }
            if(!in_array('transaction_id',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `transaction_id` VARCHAR(100) NULL COMMENT '微信支付单号';");
            }
            if(!in_array('fenzhang_rate',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `fenzhang_rate` INT(10) UNSIGNED NOT NULL DEFAULT '30' COMMENT '分账比例(最大30%)';");
            }
            
            //v2.0.72 
            if(!in_array('level',$agent_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent_log")." ADD `level` INT(10) NOT NULL DEFAULT '0' COMMENT '代理等级:1=省份,2=城市,3=区县,4=街道';");
            }
            if(in_array('is_fenxiao',$member_card_orderFields) && !in_array('is_fenzhang',$member_card_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." CHANGE `is_fenxiao` `is_fenzhang` INT(10) NOT NULL DEFAULT '0' COMMENT '分账:1=开启,0=关闭';");
            }
            else{
                if(!in_array('is_fenzhang',$member_card_orderFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." ADD `is_fenzhang` INT(10) NOT NULL DEFAULT '0' COMMENT '分账:1=开启,0=关闭';");
                }
            }
            
            
            //v2.0.73
            if(!in_array('access_permissions_levels',$diypageFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_diypage")." ADD `access_permissions_levels` TEXT NULL COMMENT '访问权限等级';");
            }
            if(in_array('nickname',$userFields) && $bbfx['sversion'] < 2073){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `nickname` `nickname` VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '昵称';");
            }
            
            //v2.0.74
            $plugin = Db::name("bbfx_plugin")->where("ident","apopup")->find();
            if(empty($plugin)){ 
                $apopup = array(
                    "name"=>"活动弹窗",
                    "ident"=>"apopup",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-apopup.png",
                    "sort"=>0,
                    "url"=>"/apopup/index"
                );
                Db::name("bbfx_plugin")->insert($apopup);
            }
            if(!pdo_tableexists("bbfx_apopup")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_apopup")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '单页名称',
                  `thumb` varchar(255) NOT NULL COMMENT '单页图片',
                  `link` text NULL COMMENT '跳转链接',
                  `width` int(10) UNSIGNED NOT NULL DEFAULT '80' COMMENT '宽度',
                  `height` int(10) UNSIGNED NOT NULL DEFAULT '80' COMMENT '高度',
                  `tanchu` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '弹出次数,0为不限制',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $apopupFields = Db::name("bbfx_apopup")->getTableFields();
            }
            else{
                $apopupFields = Db::name("bbfx_apopup")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_apopup_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_apopup_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '单页ID',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $apopup_logFields = Db::name("bbfx_apopup_log")->getTableFields();
            }
            else{
                $apopup_logFields = Db::name("bbfx_apopup_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_apopup_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_apopup_set")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `mode` int(10) NOT NULL DEFAULT '0' COMMENT '展示类型:0=重叠展示,1=轮播展示',
                  `width` int(10) NOT NULL DEFAULT '80' COMMENT '宽度',
                  `height` int(10) NOT NULL DEFAULT '60' COMMENT '高度',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $apopup_setFields = Db::name("bbfx_apopup_set")->getTableFields();
            }
            else{
                $apopup_setFields = Db::name("bbfx_apopup_set")->getTableFields();
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","contract")->find();
            if(empty($plugin)){ 
                $contract = array(
                    "name"=>"电子合同",
                    "ident"=>"contract",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-contract.png",
                    "sort"=>0,
                    "url"=>"/contract/index"
                );
                Db::name("bbfx_plugin")->insert($contract);
            }
            if(!pdo_tableexists("bbfx_contract")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contract")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '活动名称',
                  `content` varchar(255) NOT NULL COMMENT '活动内容',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '合同类型:1=商品合同',
                  `signing_type` int(10) NOT NULL DEFAULT '0' COMMENT '签约类型:0=强制签约,1=普通签约',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contractFields = Db::name("bbfx_contract")->getTableFields();
            }
            else{
                $contractFields = Db::name("bbfx_contract")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_contract_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contract_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '合同名称',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '合同ID',
                  `og_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单商品ID',
                  `content` varchar(255) NOT NULL COMMENT '合同路径',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '合同类型:1=商品合同',
                  `signing_type` int(10) NOT NULL DEFAULT '0' COMMENT '签约类型:0=强制签约,1=普通签约	',
                  `signingtime` int(11) NOT NULL COMMENT '签约时间',
                  `signing_image` varchar(255) DEFAULT NULL COMMENT '签名图片',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '签约状态:0=已签约,1=未签约',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contract_recordFields = Db::name("bbfx_contract_record")->getTableFields();
            }
            else{
                $contract_recordFields = Db::name("bbfx_contract_record")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_contract_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contract_set")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contract_setFields = Db::name("bbfx_contract_set")->getTableFields();
            }
            else{
                $contract_setFields = Db::name("bbfx_contract_set")->getTableFields();
            }
            
            
            $plugin = Db::name("bbfx_plugin")->where("ident","feedback")->find();
            if(empty($plugin)){ 
                $feedback = array(
                    "name"=>"意见反馈",
                    "ident"=>"feedback",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-feedback.png",
                    "sort"=>0,
                    "url"=>"/feedback/index"
                );
                Db::name("bbfx_plugin")->insert($feedback);
            }
            if(!pdo_tableexists("bbfx_feedback")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_feedback")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT,
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `content` varchar(1000) DEFAULT NULL COMMENT '反馈内容',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待处理,1=已处理',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $feedbackFields = Db::name("bbfx_feedback")->getTableFields();
            }
            else{
                $feedbackFields = Db::name("bbfx_feedback")->getTableFields();
            }
            
            if(!in_array('is_contract',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_contract` INT(10) NOT NULL DEFAULT '0' COMMENT '电子合同:1=开启,0=关闭';");
            }
            if(!in_array('contract',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `contract` TEXT NULL COMMENT '电子合同';");
            }
            if(!in_array('fastest_delivery',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `fastest_delivery` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '最快发货';");
            }
            if(!in_array('arrive_day',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `arrive_day` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '送达天数';");
            }
            if(!in_array('express_name',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `express_name` VARCHAR(100) NULL COMMENT '发货快递';");
            }
            if(!in_array('vip_free_shipping',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `vip_free_shipping` INT(10) NOT NULL DEFAULT '0' COMMENT '会员包邮:0=关闭,1=开启';");
            }
            if(!in_array('guarantee',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `guarantee` TEXT NULL COMMENT '购买保障';");
            }
            if(!in_array('is_authentic',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_authentic` INT(10) NOT NULL DEFAULT '0' COMMENT '正品:1=开启,0=关闭';");
            }
            if(!in_array('authentic_name',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `authentic_name` VARCHAR(10) NULL DEFAULT '100%正品' COMMENT '正品名称';");
            }
            if(!in_array('authentic_desc',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `authentic_desc` VARCHAR(100) NULL DEFAULT '官方自营·品牌授权·中国人保承保·全链路品控' COMMENT '正品描述';");
            }
            if(!in_array('single_column_thumb',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD  `single_column_thumb` VARCHAR(255) NULL COMMENT '单列展现';");
            }
            if(!in_array('authentic_icon',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD  `authentic_icon` VARCHAR(255) NULL COMMENT '正品图标';");
            }
            
            if(!in_array('fenxiao_template',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD  `fenxiao_template` INT(10) NOT NULL DEFAULT '0' COMMENT '分销中心样式';");
            }
            
            //v2.0.78
            $plugin = Db::name("bbfx_plugin")->where(['ident'=>'jicha','name'=>'复购奖'])->find();
            if(!empty($plugin)){
                Db::name("bbfx_plugin")->where(['id'=>$plugin['id']])->update(['ident'=>'repurchase']);
            }
            if(!in_array('settlement_abonus_stype',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `settlement_abonus_stype` INT(10) NOT NULL DEFAULT '0' COMMENT '分红结算类型:0=立即发放,1=日结周发';");
            }
            if(!in_array('is_daozhang',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `is_daozhang` INT(10) NOT NULL DEFAULT '0' COMMENT '是否到账:1=是,0=否';");
            }
            if(!in_array('dztime',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `dztime` INT(11) NOT NULL DEFAULT '0' COMMENT '到账时间';");
            }
            if(!in_array('is_repurchase_gold',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_repurchase_gold` INT(10) NOT NULL DEFAULT '0' COMMENT '复购金:1=开启,0=关闭';");
            }
            if(!in_array('repurchase_gold',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `repurchase_gold` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '复购金比例';");
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","repurchasegold")->find();
            if(empty($plugin)){ 
                $repurchasegold = array(
                    "name"=>"复购金",
                    "ident"=>"repurchasegold",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-repurchasegold.png",
                    "sort"=>0,
                    "url"=>"/repurchasegold/index"
                );
                Db::name("bbfx_plugin")->insert($repurchasegold);
            }
            if(!in_array('repurchase_currency',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `repurchase_currency` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '复购金';");
            }
            if(!in_array('repurchase_currency',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `repurchase_currency` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '复购金';");
            }
            if(!in_array('wxapp_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `wxapp_login` INT(10) NOT NULL DEFAULT '0' COMMENT '小程序端登录:0=小程序登录,1=手机号登录';");
            }
            if(!in_array('openid',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `openid` VARCHAR(255) NULL;");
            }
            if(!in_array('goodsset',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `goodsset` TEXT NULL COMMENT '商品设置';");
            }
            if(!in_array('recharge',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `recharge` TEXT NULL COMMENT '商品设置';");
            }
            if(!in_array('mode',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `mode` INT(10) NOT NULL DEFAULT '1' COMMENT '充值方式:1=微信充值,2=银行卡充值,3=支付宝充值';");
            }
            if(!in_array('pay_pingzheng',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `pay_pingzheng` VARCHAR(255) NULL COMMENT '支付凭证';");
            }
            if(!in_array('status',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `status` INT(10) NOT NULL DEFAULT '1' COMMENT '状态:0=待审核,1=已通过,2=已拒绝';");
            }
            
            //v2.0.79
            if(!in_array('repurchase_mode',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `repurchase_mode` INT(10) NOT NULL DEFAULT '0' COMMENT '复购奖模式:0=普通模式,1=下单扣除';");
            }
            
            //v2.0.80
            if(!in_array('is_ladder_abonus',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_ladder_abonus` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯分红:1=开启,0=关闭';");
            }
            if(!in_array('is_ladder_abonus_gld',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_ladder_abonus_gld` INT(10) NOT NULL DEFAULT '0' COMMENT '高等级参与低等级分红:1=开启,0=关闭';");
            }
            if(!in_array('ladder_abonus',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `ladder_abonus` TEXT NULL COMMENT '阶梯分红配置';");
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","ladderabonus")->find();
            if(empty($plugin)){ 
                $ladderabonus = array(
                    "name"=>"阶梯分红",
                    "ident"=>"ladderabonus",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-ladderabonus.png",
                    "sort"=>0,
                    "url"=>"/ladderabonus/index"
                );
                Db::name("bbfx_plugin")->insert($ladderabonus);
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","coupon")->find();
            if(empty($plugin)){ 
                $coupon = array(
                    "name"=>"优惠券",
                    "ident"=>"coupon",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-coupon.png",
                    "sort"=>0,
                    "url"=>"/coupon/index"
                );
                Db::name("bbfx_plugin")->insert($coupon);
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","cumulative_fanhuan")->find();
            if(empty($plugin)){ 
                $cumulative_fanhuan = array(
                    "name"=>"累计返还",
                    "ident"=>"cumulative_fanhuan",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-cumulative_fanhuan.png",
                    "sort"=>0,
                    "url"=>"/cumulative_fanhuan/index"
                );
                Db::name("bbfx_plugin")->insert($cumulative_fanhuan);
            }
            
            if(!pdo_tableexists("bbfx_cumulative_fanhuan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cumulative_fanhuan")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `fanhuan_total` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '返还比例',
                  `everyday_rate` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每天返还(‰)',
                  `settlement_currency` int(10) NOT NULL DEFAULT '1' COMMENT '结算币种:1=余额,2=积分',
                  `settlement_status` INT(10) NOT NULL DEFAULT '1' COMMENT '结算状态:1=订单付款后,2=订单完成后',
                  `oper` int(10) UNSIGNED NOT NULL DEFAULT '1',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                
                $cumulative_fanhuanFields = Db::name("bbfx_cumulative_fanhuan")->getTableFields();
            }
            else{
                $cumulative_fanhuanFields = Db::name("bbfx_cumulative_fanhuan")->getTableFields();
            }
            if(!in_array('is_cumulative_fanhuan',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_cumulative_fanhuan` INT(10) NOT NULL DEFAULT '0' COMMENT '累计返还:1=开启,0=关闭';");
            }
            if(!in_array('is_cumulative_fanhuan',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `is_cumulative_fanhuan` INT(10) NOT NULL DEFAULT '0' COMMENT '累计返还:1=完成,0=未完成';");
            }
            if(!in_array('cumulative_fanhuan_rule',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cumulative_fanhuan_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '累计返还独立规则:0=不开启,1=统一规则,2=详细规则';");
            }
            if(!in_array('cumulative_fanhuan',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cumulative_fanhuan` TEXT NULL COMMENT '累计返还配置';");
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","cloud_warehouse")->find();
            if(empty($plugin)){ 
                $cloud_warehouse = array(
                    "name"=>"云仓",
                    "ident"=>"cloud_warehouse",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-cloud_warehouse.png",
                    "sort"=>0,
                    "url"=>"/cloud_warehouse/index"
                );
                Db::name("bbfx_plugin")->insert($cloud_warehouse);
            }
            
            if(!in_array('cloud_warehouse_stock',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `cloud_warehouse_stock` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓库存';");
            }
            if(!in_array('cloud_warehouse_stock',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `cloud_warehouse_stock` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '云仓商品库存';");
            }
            if(!in_array('cloud_warehouse_jinhuo_stock',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `cloud_warehouse_jinhuo_stock` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '云仓商品进货库存';");
            }
            if(!in_array('cloud_warehouse_rule',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cloud_warehouse_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓商品独立规则:0=不开启,1=统一规则,2=详细规则';");
            }
            if(!in_array('cloud_warehouse',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cloud_warehouse` TEXT NULL COMMENT '云仓商品返还配置';");
            }
            
            if(!pdo_tableexists("bbfx_cloud_warehouse_stock_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cloud_warehouse_stock_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '操作类型',
                  `item_type` int(10) NOT NULL DEFAULT '0' COMMENT '项目类型',
                  `item_id` int(10) NOT NULL DEFAULT '0' COMMENT '项目ID',
                  `stock` int(11) NOT NULL DEFAULT '0' COMMENT '变动库存',
                  `befores` int(10) NOT NULL DEFAULT '0' COMMENT '变动前',
                  `afters` int(10) NOT NULL DEFAULT '0' COMMENT '变动后',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `info` text NULL COMMENT '数据',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cloud_warehouse_stock_recordFields = Db::name("bbfx_cloud_warehouse_stock_record")->getTableFields();
            }
            else{
                $cloud_warehouse_stock_recordFields = Db::name("bbfx_cloud_warehouse_stock_record")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_cloud_warehouse")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cloud_warehouse")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `cw_goods` int(10) NOT NULL DEFAULT '0' COMMENT '云仓商品',
                  `fanhuan_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '返还比例',
                  `fanhuan_currency` int(10) NOT NULL DEFAULT '1' COMMENT '返还币种:1=余额,2=积分',
                  `level` int(10) NOT NULL DEFAULT '0' COMMENT '云仓开启等级',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cloud_warehouseFields = Db::name("bbfx_cloud_warehouse")->getTableFields();
            }
            else{
                $cloud_warehouseFields = Db::name("bbfx_cloud_warehouse")->getTableFields();
            }
            
            //v2.0.81
            if(!in_array('cloud_warehouse_chuhuo',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cloud_warehouse_chuhuo` TEXT NULL COMMENT '出货奖配置';");
            }
            
            //v2.0.86
            if(!in_array('ladder_abonus_mode',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `ladder_abonus_mode` INT(10) NOT NULL DEFAULT '1' COMMENT '分红模式:1=统一分红,2=多组分红';");
            }
            if(!in_array('ladder_abonus_multiple',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `ladder_abonus_multiple` TEXT NULL COMMENT '多组分红配置';");
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","ladderpush")->find();
            if(empty($plugin)){ 
                $ladderpush = array(
                    "name"=>"阶梯直推",
                    "ident"=>"ladderpush",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-ladderpush.png",
                    "sort"=>0,
                    "url"=>"/ladderpush/index"
                );
                Db::name("bbfx_plugin")->insert($ladderpush);
            }
            if(!in_array('is_ladder_push',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_ladder_push` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯直推:1=开启,0=关闭';");
            }
            if(!in_array('is_ladder_push_loop',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_ladder_push_loop` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯循环:1=开启,0=关闭';");
            }
            if(!in_array('is_ladder_push',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_ladder_push` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯直推:1=开启,0=关闭';");
            }
            if(!in_array('is_ladder_push_loop',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_ladder_push_loop` INT(10) NOT NULL DEFAULT '1' COMMENT '阶梯循环:1=开启,0=关闭';");
            }
            if(!in_array('ladder_push',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `ladder_push` TEXT NULL COMMENT '阶梯直推配置';");
            }
            if(!in_array('ladder_push_rule',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `ladder_push_rule` INT(10) NOT NULL DEFAULT '1' COMMENT '独立规则:0=不开启,1=统一规则,2=详细规则';");
            }
            
            //v2.0.87
            $plugin = Db::name("bbfx_plugin")->where("ident","appoint")->find();
            if(empty($plugin)){ 
                $appoint = array(
                    "name"=>"指定奖",
                    "ident"=>"appoint",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-appoint.png",
                    "sort"=>0,
                    "url"=>"/appoint/index"
                );
                Db::name("bbfx_plugin")->insert($appoint);
            }
            if(!in_array('is_appoint',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_appoint` INT(10) NOT NULL DEFAULT '0' COMMENT '指定奖:1=开启,0=关闭';");
            }
            if(!in_array('appoint',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `appoint` TEXT NULL COMMENT '指定奖配置';");
            }
            if(!pdo_tableexists("bbfx_fenxiao_upgrade_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_fenxiao_upgrade_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `sup_uid` int(10) NOT NULL DEFAULT '0' COMMENT '推荐人',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '升级类型:0=自动升级,1=后台升级,2=申请升级,3=指定升级',
                  `before_level` int(10) NOT NULL DEFAULT '-1' COMMENT '以前等级',
                  `level` int(10) NOT NULL DEFAULT '0' COMMENT '升级等级',
                  `sup_level` int(10) NOT NULL DEFAULT '0' COMMENT '推荐人等级',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $fenxiao_upgrade_recordFields = Db::name("bbfx_fenxiao_upgrade_record")->getTableFields();
            }
            else{
                $fenxiao_upgrade_recordFields = Db::name("bbfx_fenxiao_upgrade_record")->getTableFields();
            }
            
            //v2.0.88
            Db::name("auth_rule")->where(['name'=>'general'])->update(['status'=>'hidden']);
            Db::name("bbfx_plugin")->where(['ident'=>'double_track'])->update(['type'=>3]);
            Db::name("bbfx_plugin")->where(['ident'=>'cloud_warehouse'])->update(['type'=>3]);
            if(!pdo_tableexists("bbfx_cumulative_fanhuan_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cumulative_fanhuan_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `total` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '返还总额',
                  `surplus` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '剩余返还',
                  `sdate` date DEFAULT NULL COMMENT '上次返还日期',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cumulative_fanhuan_userFields = Db::name("bbfx_cumulative_fanhuan_user")->getTableFields();
            }
            else{
                $cumulative_fanhuan_userFields = Db::name("bbfx_cumulative_fanhuan_user")->getTableFields();
            }
            if(in_array('zfb_',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `zfb_` `zfb` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '提现支付宝账号';");
            }
            
            //v2.0.92
            if(!in_array('is_directpush_achievement',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_directpush_achievement` INT(10) NOT NULL DEFAULT '0' COMMENT '直推业绩奖:1=开启,0=关闭';");
            }
            if(!in_array('directpush_achievement',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `directpush_achievement` TEXT NULL COMMENT '直推业绩奖配置';");
            }
            
            //v2.0.93
            $plugin = Db::name("bbfx_plugin")->where("ident","directpush_achievement")->find();
            if(empty($plugin)){ 
                $directpush_achievement = array(
                    "name"=>"直推业绩奖",
                    "ident"=>"directpush_achievement",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-directpush_achievement.png",
                    "sort"=>0,
                    "url"=>"/directpush_achievement/index"
                );
                Db::name("bbfx_plugin")->insert($directpush_achievement);
            }
            
            
            //v2.0.94
            $plugin = Db::name("bbfx_plugin")->where("ident","directpush_jiandan")->find();
            if(empty($plugin)){ 
                $directpush_jiandan = array(
                    "name"=>"直推见单奖",
                    "ident"=>"directpush_jiandan",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-directpush_jiandan.png",
                    "sort"=>0,
                    "url"=>"/directpush_jiandan/index"
                );
                Db::name("bbfx_plugin")->insert($directpush_jiandan);
            }
            if(!in_array('is_directpush_jiandan',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_directpush_jiandan` INT(10) NOT NULL DEFAULT '0' COMMENT '直推见单奖:1=开启,0=关闭';");
            }
            if(!in_array('directpush_jiandan',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `directpush_jiandan` TEXT NULL COMMENT '直推见单奖配置';");
            }
            
            //v2.0.96
            if(!in_array('info',$admin_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin_log")." ADD `info` TEXT NULL COMMENT '数据';");
            }
            
            //v2.0.97
            if(!in_array('is_cloud_warehouse',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_cloud_warehouse` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓商品:1=是,0=否';");
            }
            
            if(!pdo_tableexists("bbfx_cloud_warehouse_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cloud_warehouse_goods")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '库存',
                  `jinhuo_stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '进货库存(最多还可进多少货)',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cloud_warehouse_goodsFields = Db::name("bbfx_cloud_warehouse_goods")->getTableFields();
            }
            else{
                $cloud_warehouse_goodsFields = Db::name("bbfx_cloud_warehouse_goods")->getTableFields();
            }
            if(!in_array('goods_id',$cloud_warehouse_stock_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cloud_warehouse_stock_record")." ADD `goods_id` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓商品';");
            }
            if($bbfx['sversion'] <= 2096){
                // 处理云仓商品
                $user_list = Db::name("bbfx_user")->where(function ($query){
                    $whereOr = ['cloud_warehouse_stock'=>['>',0],'cloud_warehouse_jinhuo_stock'=>['>',0]];
                	$query->whereOr($whereOr);
                })->field("id,uniacid,cloud_warehouse_stock,cloud_warehouse_jinhuo_stock")->select();
                
                $cw_goods = Db::name("bbfx_cloud_warehouse")->where("uniacid",1)->value("cw_goods");
                if(!empty($cw_goods)){
                    $cw_goods = explode(",",(string)$cw_goods);
                    Db::name("bbfx_cloud_warehouse_stock_record")->where(['goods_id'=>0])->update(['goods_id'=>$cw_goods[0]]);
                    if(!empty($user_list)){
                        $cw_goods_list = [];
                        foreach ($user_list as $key => $val){
                            if(empty($cw_goods_list[$val['uniacid']])){
                                $cw_goods = Db::name("bbfx_cloud_warehouse")->where("uniacid",$val['uniacid'])->value("cw_goods");
                                $cw_goods = explode(",",(string)$cw_goods);
                                $cw_goods_list[$val['uniacid']] = $cw_goods;
                            }
                            else{
                                $cw_goods = $cw_goods_list[$val['uniacid']];
                            }
                            
                            if(!empty($cw_goods)){
                                foreach ($cw_goods as $k => $v){
                                    if($k == 0){
                                        $goods = Db::name("bbfx_cloud_warehouse_goods")->where(['user_id'=>$val['id'],'goods_id'=>$v])->find();
                                        if(empty($goods)){
                                            $data = array(
                                                "uniacid"=>$val['uniacid'],
                                                "user_id"=>$val['id'],
                                                "goods_id"=>$v,
                                                "stock"=>$val['cloud_warehouse_stock'],
                                                "jinhuo_stock"=>$val['cloud_warehouse_jinhuo_stock'],
                                            );
                                            Db::name("bbfx_cloud_warehouse_goods")->insert($data);
                                        }
                                    }
                                }
                            }
                            
                        }
                    }
                }
                
                // 退款处理
                $fenxiao_order = Db::name("bbfx_fenxiao_order")->alias("a")->join("bbfx_order b","a.order_id=b.id","LEFT")->where(['a.status'=>0,'b.status'=>['in',[1,2,3]]])->field("a.*,b.refund_status,b.status as o_status")->select();
                foreach ($fenxiao_order as $key => $val){
                    if($val['refund_status'] == 1){
                        Db::name("bbfx_fenxiao_order")->where("id",$val['id'])->update(['status'=>-1]);
                    }
                    else{
                        Db::name("bbfx_fenxiao_order")->where("id",$val['id'])->update(['status'=>1]);
                    }
                }
            }
            
            
            //v2.0.98
            if(!in_array('delivery_method',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `delivery_method` INT(10) NOT NULL DEFAULT '1' COMMENT '配送方式:1=快递配送,2=门店核销,3=快递配送和门店核销';");
            }
            if(!in_array('hexiao_store_type',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `hexiao_store_type` INT(10) NOT NULL DEFAULT '0' COMMENT '核销门店:0=全部门店,1=指定门店';");
            }
            if(!in_array('hexiao_num',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `hexiao_num` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '核销次数';");
            }
            if(!in_array('is_dealer',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `is_dealer` INT(10) NOT NULL DEFAULT '0' COMMENT '经销商:1=是,0=否';");
            }
            if(!in_array('dealer_reward',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dealer_reward` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '经销商奖励';");
            }
            if(!in_array('dealer_province',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dealer_province` VARCHAR(100) NULL COMMENT '经销商管理城市';");
            }
            if(!in_array('dealer_city',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dealer_city` VARCHAR(100) NULL COMMENT '经销商管理城市';");
            }
            if(!in_array('become_dealer_time',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `become_dealer_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '成为经销商时间';");
            }
            if(!in_array('delivery_method',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `delivery_method` INT(10) NOT NULL DEFAULT '1' COMMENT '配送方式:1=快递配送,2=门店核销';");
            }
            if(!in_array('is_hexiao',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '核销订单:1=是,0=否';");
            }
            if(!in_array('hexiao_realname',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_realname` VARCHAR(100) NULL COMMENT '用户姓名';");
            }
            if(!in_array('hexiao_mobile',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_mobile` VARCHAR(100) NULL COMMENT '用户电话';");
            }
            if(!in_array('hexiao_num',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '核销次数';");
            }
            if(!in_array('hexiao_total',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_total` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '核销总次数';");
            }
            if(!in_array('hexiao_uid',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_uid` INT(10) NOT NULL DEFAULT '0' COMMENT '核销用户';");
            }
            if(!in_array('hexiao_time',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_time` BIGINT(16) NULL DEFAULT '0' COMMENT '核销时间';");
            }
            if(!in_array('hexiao_store',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_store` TEXT NULL COMMENT '核销门店';");
            }
            if(!in_array('hexiao_qrcode',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_qrcode` VARCHAR(255) NULL COMMENT '核销二维码';");
            }
            if(!in_array('hexiao_wxacode',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_wxacode` VARCHAR(255) NULL COMMENT '核销小程序码';");
            }
            if(!in_array('hexiao_code',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `hexiao_code` VARCHAR(20) NULL COMMENT '核销码';");
            }
            if(!in_array('hexiao_realname',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `hexiao_realname` VARCHAR(100) NULL COMMENT '核销用户姓名';");
            }
            if(!in_array('hexiao_mobile',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `hexiao_mobile` VARCHAR(100) NULL COMMENT '核销用户电话';");
            }
            
            if(!in_array('decimal_type',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `decimal_type` INT(10) NOT NULL DEFAULT '2' COMMENT '释放数值:1=向下取值,2=四舍五入,3=向上取值';");
            }
            if(!in_array('release_method',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `release_method` INT(10) NOT NULL DEFAULT '1' COMMENT '释放方式:1=常规释放,2=递减释放';");
            }
            if(!in_array('is_below',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_below` INT(10) NOT NULL DEFAULT '0' COMMENT '下二代奖:1=开启,0=关闭';");
            }
            if(!in_array('below',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `below` TEXT NULL COMMENT '下二代奖配置';");
            }
            if(!in_array('is_team_building',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_team_building` INT(10) NOT NULL DEFAULT '0' COMMENT '团建奖:1=开启,0=关闭';");
            }
            if(!in_array('team_building',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `team_building` TEXT NULL COMMENT '团建奖配置';");
            }
            if(!in_array('is_strikeout',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_strikeout` INT(10) NOT NULL DEFAULT '0' COMMENT '出局设置:1=开启,0=关闭';");
            }
            if(!in_array('strikeout_multiple',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `strikeout_multiple` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '出局倍数';");
            }
            if(!in_array('store',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `store` TEXT NULL COMMENT '门店配置';");
            }
            if(!pdo_tableexists("bbfx_store")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_store")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '店长ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '门店名称',
                  `logo` varchar(255) DEFAULT NULL COMMENT '门店logo',
                  `realname` varchar(100) DEFAULT NULL COMMENT '店长姓名',
                  `mobile` varchar(100) DEFAULT NULL COMMENT '联系电话',
                  `province` varchar(100) DEFAULT NULL COMMENT '身份',
                  `city` varchar(100) DEFAULT NULL COMMENT '城市',
                  `area` varchar(100) DEFAULT NULL COMMENT '区县',
                  `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
                  `lng` double NOT NULL DEFAULT '0' COMMENT '经度',
                  `lat` double NOT NULL DEFAULT '0' COMMENT '纬度',
                  `commission` text NULL COMMENT '核销佣金设置',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $storeFields = Db::name("bbfx_store")->getTableFields();
            }
            else{
                $storeFields = Db::name("bbfx_store")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_store_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_store_goods")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $store_goodsFields = Db::name("bbfx_store_goods")->getTableFields();
            }
            else{
                $store_goodsFields = Db::name("bbfx_store_goods")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_order_hexiao_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_order_hexiao_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `info` longtext NULL COMMENT '数据',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '核销时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $order_hexiao_recordFields = Db::name("bbfx_order_hexiao_record")->getTableFields();
            }
            else{
                $order_hexiao_recordFields = Db::name("bbfx_order_hexiao_record")->getTableFields();
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","below")->find();
            if(empty($plugin)){ 
                $below = array(
                    "name"=>"下二代奖",
                    "ident"=>"below",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-below.png",
                    "sort"=>0,
                    "url"=>"/below/index"
                );
                Db::name("bbfx_plugin")->insert($below);
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","team_building")->find();
            if(empty($plugin)){ 
                $team_building = array(
                    "name"=>"团建奖",
                    "ident"=>"team_building",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-team_building.png",
                    "sort"=>0,
                    "url"=>"/team_building/index"
                );
                Db::name("bbfx_plugin")->insert($team_building);
            }
            
            //v2.0.99
            if(!in_array('is_hexiao',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '门店核销(type=4):1=开启,0=关闭';");
            }
            
            //v2.1.1
            if(!in_array('store_id',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `store_id` INT(10) NOT NULL DEFAULT '0' COMMENT '门店ID';");
            }
            
            $result = Db::query("SHOW CREATE TABLE ".tablename("bbfx_goods"));
            if(!strstr($result[0]['Create Table'], 'ENGINE=MyISAM')){
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ENGINE=MyISAM;");
            }
            
            //v2.1.3
            if(!in_array('yy_time',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `yy_time` VARCHAR(100) NULL COMMENT '营业时间';");
            }
            
            //v2.1.5
            if(!in_array('strikeout_multiple',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `strikeout_multiple` INT(10) NOT NULL DEFAULT '-1' COMMENT '出局倍数:-1=不单独设置,0=不显示';");
            }
            
            //v2.1.6
            if(!in_array('plugin',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `plugin` LONGTEXT NULL COMMENT '应用配置';");
            }
            if(!in_array('max_money',$couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon")." ADD `max_money` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '使用金额限制(%)';");
            }
            if(!in_array('max_money',$user_couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_coupon")." ADD `max_money` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '使用金额限制(%)';");
            }
            if(!in_array('item_id',$user_couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_coupon")." ADD `item_id` INT(10) NOT NULL DEFAULT '0';");
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","strikeout")->find();
            if(empty($plugin)){ 
                $strikeout = array(
                    "name"=>"出局倍数",
                    "ident"=>"strikeout",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-strikeout.png",
                    "sort"=>0,
                    "url"=>"/strikeout/index"
                );
                Db::name("bbfx_plugin")->insert($strikeout);
            }
            if(!in_array('withdrawal_balance_score_free',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `withdrawal_balance_score_free` INT(10) NOT NULL DEFAULT '0' COMMENT '提现到积分余额免手续费:1=开启,0=关闭';");
            }
            if(!in_array('delayed_daozhang',$cloud_warehouseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cloud_warehouse")." ADD `delayed_daozhang` INT(10) NOT NULL DEFAULT '0' COMMENT '延时到账天数';");
            }
            
            
            
            //v2.1.9
            //排队免单
            $plugin = Db::name("bbfx_plugin")->where("ident","queue_mode")->find();
            if(empty($plugin)){ 
                $queue_mode = array(
                    "name"=>"排队免单",
                    "ident"=>"queue_mode",
                    "type"=>3,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-queue_mode.png",
                    "sort"=>0,
                    "url"=>"/queue_mode/index"
                );
                Db::name("bbfx_plugin")->insert($queue_mode);
            }
            if(!pdo_tableexists("bbfx_queue_mode")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_queue_mode")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `miandan_total` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '免单比例',
                  `each_order_rate` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '每单比例',
                  `oper` int(10) unsigned NOT NULL DEFAULT '1',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $queue_modeFields = Db::name("bbfx_queue_mode")->getTableFields();
            }
            else{
                $queue_modeFields = Db::name("bbfx_queue_mode")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_queue_mode_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_queue_mode_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '免单总额',
                  `surplus_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '剩余免单',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '免单订单',
                  `info` longtext NULL COMMENT '数据',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $queue_mode_userFields = Db::name("bbfx_queue_mode_user")->getTableFields();
            }
            else{
                $queue_mode_userFields = Db::name("bbfx_queue_mode_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_queue_mode_user_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_queue_mode_user_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '免单用户ID',
                  `money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '免单金额',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `info` longtext NULL COMMENT '数据',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $queue_mode_user_recordFields = Db::name("bbfx_queue_mode_user_record")->getTableFields();
            }
            else{
                $queue_mode_user_recordFields = Db::name("bbfx_queue_mode_user_record")->getTableFields();
            }
            if(!in_array('is_queue_modeok',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_queue_modeok` INT(10) NOT NULL DEFAULT '0' COMMENT '执行免单:1=是,0=否';");
            }
            if(!in_array('show_month_commission',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `show_month_commission` INT(10) NOT NULL DEFAULT '0' COMMENT '显示本月管理奖:1=是,0=否';");
            }
            
            
            //v2.1.10
            if(!in_array('address_type',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `address_type` INT(10) NOT NULL DEFAULT '0' COMMENT '地址类型:0=订单收货地址,1=用户所属区域';");
            }
            if(!in_array('ss_region',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `ss_region` VARCHAR(100) NULL COMMENT '所属区域';");
            }
            if(!in_array('pay_password',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `pay_password` VARCHAR(255) NULL COMMENT '支付密码';");
            }
            
            
            //v2.1.12
            $plugin = Db::name("bbfx_plugin")->where("ident","directpush_team")->find();
            if(empty($plugin)){ 
                $directpush_team = array(
                    "name"=>"直推团队奖",
                    "ident"=>"directpush_team",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-directpush_team.png",
                    "sort"=>0,
                    "url"=>"/directpush_team/index"
                );
                Db::name("bbfx_plugin")->insert($directpush_team);
            }
            if(!pdo_tableexists("bbfx_directpush_team")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_directpush_team")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `show_month_commission` int(10) NOT NULL DEFAULT '0' COMMENT '显示本月收益',
                  `rule` text NULL COMMENT '奖金规则',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $directpush_teamFields = Db::name("bbfx_directpush_team")->getTableFields();
            }
            else{
                $directpush_teamFields = Db::name("bbfx_directpush_team")->getTableFields();
            }
            
            //v2.1.13
            if(!in_array('management_jisuan',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `management_jisuan` INT(10) NOT NULL DEFAULT '1' COMMENT '管理奖计算方式:1=逐级减,2=直推减';");
            }
            
            //v2.1.14
            if(!in_array('profit_amount',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `profit_amount` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '利润金额';");
            }
            if(!in_array('profit_amount',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `profit_amount` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '利润金额';");
            }
            if(!in_array('profit_amount',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `profit_amount` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商品利润金额';");
            }
            if(!in_array('profit_amount',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `profit_amount` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '利润金额';");
            }
            if(!in_array('is_rebind',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_rebind` INT(10) NOT NULL DEFAULT '0' COMMENT '重新绑定关系:1=开启,0=关闭';");
            }
            if(!in_array('rebind_day',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `rebind_day` INT(10) NOT NULL DEFAULT '0' COMMENT '多少天未消费解除绑定';");
            }
            if(!in_array('user_shenhe_apply',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `user_shenhe_apply` INT(10) NOT NULL DEFAULT '0' COMMENT '用户审核升级申请:1=开启,0=,关闭';");
            }
            if(!in_array('user_shenhe_apply',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `user_shenhe_apply` INT(10) NOT NULL DEFAULT '0' COMMENT '用户审核升级申请:1=开启,0=,关闭';");
            }
            if(!in_array('bindtime',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `bindtime` INT(11) NOT NULL DEFAULT '0' COMMENT '绑定时间';");
            }
            if(!in_array('sh_user_id',$fenxiao_applyFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_apply")." ADD `sh_user_id` INT(10) NOT NULL DEFAULT '0' COMMENT '审核用户';");
            }
            
            
            //v2.1.15
            if(!in_array('daily_buy',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `daily_buy` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '用户每日购买';");
            }
            if(!in_array('completetime',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `completetime` INT(11) NOT NULL DEFAULT '0' COMMENT '完成时间';");
            }
            if(!in_array('is_asales_end',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_asales_end` INT(10) NOT NULL DEFAULT '0' COMMENT '售后期结束:1=是,0=否';");
            }
            if(!in_array('asales_end_time',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `asales_end_time` INT(11) NOT NULL DEFAULT '0' COMMENT '售后期结束时间';");
            }
            if(!in_array('is_jiandan_pingji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_jiandan_pingji` INT(10) NOT NULL DEFAULT '0' COMMENT '见单平级:1=开启,0=关闭';");
            }
            if(!in_array('jd_pingji_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `jd_pingji_reward` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '见单平级';");
            }
            
            //v2.1.16 
            if(!in_array('is_deduct_daquachievement',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_deduct_daquachievement` INT(10) NOT NULL DEFAULT '0' COMMENT '扣除大区业绩:1=开启,0=关闭';");
            }
            if(!pdo_tableexists("bbfx_sabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sabonus")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `abonus_reward` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '分红比例',
                  `abonus_day` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红天数',
                  `calculate_mode` int(10) NOT NULL DEFAULT '1' COMMENT '分红计算:1=全部总份数计算,2=购买后总份数计算',
                  `sdate` date DEFAULT NULL COMMENT '最近分红日期',
                  `calculate_order_status` int(10) NOT NULL DEFAULT '1' COMMENT '到账份数:1=订单付款后,2=订单完成后',
                  PRIMARY KEY (`id`) 
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sabonusFields = Db::name("bbfx_sabonus")->getTableFields();
            }
            else{
                $sabonusFields = Db::name("bbfx_sabonus")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sabonus_part")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sabonus_part")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `order_goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单商品ID',
                  `part` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '份数',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sabonus_partFields = Db::name("bbfx_sabonus_part")->getTableFields();
            }
            else{
                $sabonus_partFields = Db::name("bbfx_sabonus_part")->getTableFields();
            }
            $plugin = Db::name("bbfx_plugin")->where("ident","sabonus")->find();
            if(empty($plugin)){ 
                $sabonus = array(
                    "name"=>"股份加权分红",
                    "ident"=>"sabonus",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-sabonus.png",
                    "sort"=>0,
                    "url"=>"/sabonus/index"
                );
                Db::name("bbfx_plugin")->insert($sabonus);
            }
            Db::name("bbfx_plugin")->where("ident","abonus")->update(['name'=>'常规加权分红']);
            
            
            //v2.1.17
            $plugin = Db::name("bbfx_plugin")->where("ident","dynamic_redpacket")->find();
            if(empty($plugin)){ 
                $dynamic_redpacket = array(
                    "name"=>"动态红包",
                    "ident"=>"dynamic_redpacket",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-dynamic_redpacket.png",
                    "sort"=>0,
                    "url"=>"/dynamic_redpacket/index"
                );
                Db::name("bbfx_plugin")->insert($dynamic_redpacket);
            }
            if(!pdo_tableexists("bbfx_dynamic_redpacket")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_dynamic_redpacket")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `rucang_redpacket_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '入仓红包比例',
                  `rucang_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '仓内总资金',
                  `price_bridge` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '价格桥',
                  `black_box` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '黑匣子',
                  `redpacket_part` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '红包总份数',
                  `calculate_order_status` int(10) NOT NULL DEFAULT '1' COMMENT '计算时间:1=订单付款后,2=订单完成后',
                  `chucang_redpacket_price` int(10) NOT NULL DEFAULT '0' COMMENT '出仓红包实时价格',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $dynamic_redpacketFields = Db::name("bbfx_dynamic_redpacket")->getTableFields();
            }
            else{
                $dynamic_redpacketFields = Db::name("bbfx_dynamic_redpacket")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_dynamic_redpacket_sequence")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_dynamic_redpacket_sequence")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `rucang_redpacket_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '入仓红包金额',
                  `rucang_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '仓内总资金',
                  `price_bridge` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '价格桥',
                  `redpacket_part` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '仓内红包总份数',
                  `black_box` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '黑匣子',
                  `redpacket_realtime_price` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '红包实时价格',
                  `property_part` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '资产总份数',
                  `dividend_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '分出资产总金额',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=进行中,1=已完成',
                  `completetime` int(11) NOT NULL DEFAULT '0' COMMENT '完成时间',
                  `updatetime` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $dynamic_redpacket_sequenceFields = Db::name("bbfx_dynamic_redpacket_sequence")->getTableFields();
            }
            else{
                $dynamic_redpacket_sequenceFields = Db::name("bbfx_dynamic_redpacket_sequence")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_dynamic_redpacket_sequence_item")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_dynamic_redpacket_sequence_item")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `pid` int(10) NOT NULL DEFAULT '0',
                  `rucang_redpacket_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '入仓红包金额	',
                  `rucang_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '仓内总资金',
                  `price_bridge` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '价格桥',
                  `redpacket_part` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '仓内红包总份数',
                  `black_box` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '黑匣子',
                  `redpacket_realtime_price` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '红包实时价格',
                  `user_redpacket_part` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '用户拥有红包份数',
                  `user_property_part` decimal(12,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '用户资产份数',
                  `user_dividend_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '用户资产本轮红利',
                  `money` decimal(10,4) UNSIGNED NOT NULL DEFAULT '0.0000' COMMENT '用户可提现红包金额',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待发放,1=已发放',
                  `completetime` int(11) NOT NULL DEFAULT '0',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $dynamic_redpacket_sequence_itemFields = Db::name("bbfx_dynamic_redpacket_sequence_item")->getTableFields();
            }
            else{
                $dynamic_redpacket_sequence_itemFields = Db::name("bbfx_dynamic_redpacket_sequence_item")->getTableFields();
            }
            
            //v2.1.19
            Db::name("bbfx_plugin")->where("ident","ladderpush")->update(['name'=>'阶梯直推奖']);
            Db::name("bbfx_plugin")->where("ident","ladderabonus")->update(['name'=>'阶梯加权分红']);
            
            if(!in_array('rank',$queue_mode_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_mode_user")." ADD `rank` INT(10) NOT NULL DEFAULT '0';");
            }
            if(!in_array('queue_stype',$queue_modeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_mode")." ADD `queue_stype` INT(10) NOT NULL DEFAULT '1' COMMENT '排单类型:1=订单付款后排单,2=订单完成后排单';");
            }
            if(!in_array('data',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `data` LONGTEXT NULL COMMENT '数据';");
            }
            if(!in_array('oss_domain',$attachmentFields)){ 
                Db::execute("ALTER TABLE ".tablename("attachment")." ADD `oss_domain` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'OSS域名 ';");
            }
            
            //v2.1.20
            $plugin = Db::name("bbfx_plugin")->where("ident","short_video")->find();
            if(empty($plugin)){ 
                $short_video = array(
                    "name"=>"短视频",
                    "ident"=>"short_video",
                    "type"=>1,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-short_video.png",
                    "sort"=>0,
                    "url"=>"/short_video/index"
                );
                Db::name("bbfx_plugin")->insert($short_video);
            }
            if(!pdo_tableexists("bbfx_short_video")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=开启,0=关闭',
                  `page_bgcolor` varchar(100) NOT NULL DEFAULT '#000' COMMENT '页面背景',
                  `page_bg` varchar(255) DEFAULT NULL COMMENT '页面背景',
                  `publisher` varchar(100) DEFAULT NULL COMMENT '发布者',
                  `publisher_avatar` varchar(255) DEFAULT NULL COMMENT '发布者头像',
                  `goods_show` int(10) NOT NULL DEFAULT '0' COMMENT '商品显示:1=是,0=否',
                  `comment_verify` int(10) NOT NULL DEFAULT '0' COMMENT '评论审核:1=开启,0=关闭',
                  `show_publisher` int(10) NOT NULL DEFAULT '0' COMMENT '显示发布者:1=是,0=否',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_videoFields = Db::name("bbfx_short_video")->getTableFields();
            }
            else{
                $short_videoFields = Db::name("bbfx_short_video")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_short_video_collect")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_collect")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_collectFields = Db::name("bbfx_short_video_collect")->getTableFields();
            }
            else{
                $short_video_collectFields = Db::name("bbfx_short_video_collect")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_short_video_comment")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_comment")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `reply_id` int(10) NOT NULL DEFAULT '0' COMMENT '回复ID',
                  `reply_pid` int(10) NOT NULL DEFAULT '0' COMMENT '回复主ID',
                  `content` varchar(500) DEFAULT NULL COMMENT '回复内容',
                  `dz_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '点赞数',
                  `cai_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '踩数',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:0=待审核,1=通过,2=拒绝',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_commentFields = Db::name("bbfx_short_video_comment")->getTableFields();
            }
            else{
                $short_video_commentFields = Db::name("bbfx_short_video_comment")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_short_video_comment_dianzan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_comment_dianzan")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `comment_id` int(10) NOT NULL DEFAULT '0' COMMENT '评论ID',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=赞,0=踩',
                  `updatetime` int(11) NOT NULL DEFAULT '0',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_comment_dianzanFields = Db::name("bbfx_short_video_comment_dianzan")->getTableFields();
            }
            else{
                $short_video_comment_dianzanFields = Db::name("bbfx_short_video_comment_dianzan")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_short_video_list")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_list")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `title` varchar(200) DEFAULT NULL COMMENT '标题',
                  `video` varchar(255) NOT NULL COMMENT '视频',
                  `pageview` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '浏览量',
                  `collect_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '收藏数',
                  `share_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分享数',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '绑定商品',
                  `is_recommend` int(10) NOT NULL DEFAULT '0' COMMENT '推荐:1=是,0=否',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `sh_status` int(10) NOT NULL DEFAULT '0' COMMENT '审核状态:0=待审核,1=通过,2=驳回',
                  `sh_time` int(11) NOT NULL DEFAULT '0' COMMENT '审核时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_listFields = Db::name("bbfx_short_video_list")->getTableFields();
            }
            else{
                $short_video_listFields = Db::name("bbfx_short_video_list")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_short_video_share")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_share")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_shareFields = Db::name("bbfx_short_video_share")->getTableFields();
            }
            else{
                $short_video_shareFields = Db::name("bbfx_short_video_share")->getTableFields();
            }
            
            if(!in_array('jump_type',$fenxiao_posterFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_poster")." ADD `jump_type` INT(10) NOT NULL DEFAULT '0' COMMENT '海报跳转类型:0=首页,1=注册页';");
            }
            
            //v2.1.24
            Db::name("bbfx_plugin")->where(['ident'=>'fenxiao'])->update(['type'=>1,'sort'=>99]);
            Db::name("bbfx_plugin")->where(['ident'=>'abonus'])->update(['type'=>1,'sort'=>98]);
            Db::name("bbfx_plugin")->where(['ident'=>'jicha'])->update(['type'=>1,'sort'=>97]);
            Db::name("bbfx_plugin")->where(['ident'=>'repurchase'])->update(['type'=>1,'sort'=>96]);
            Db::name("bbfx_plugin")->where(['ident'=>'jiandan'])->update(['type'=>1,'sort'=>95]);
            Db::name("bbfx_plugin")->where(['ident'=>'pingji'])->update(['type'=>1,'sort'=>94]);
            Db::name("bbfx_plugin")->where(['ident'=>'management'])->update(['type'=>1,'sort'=>93]);
            Db::name("bbfx_plugin")->where(['ident'=>'repurchasepingji'])->update(['type'=>1,'sort'=>92]);
            Db::name("bbfx_plugin")->where(['ident'=>'ladderpush'])->update(['type'=>1,'sort'=>91]);
            
            Db::name("bbfx_plugin")->where(['ident'=>'agent'])->update(['type'=>2,'sort'=>99]);
            Db::name("bbfx_plugin")->where(['ident'=>'return'])->update(['type'=>2,'sort'=>98,'name'=>'返还奖']);
            Db::name("bbfx_plugin")->where(['ident'=>'cumulative_fanhuan'])->update(['type'=>2,'sort'=>97,'name'=>'累计返还奖']);
            Db::name("bbfx_plugin")->where(['ident'=>'appoint'])->update(['type'=>2,'sort'=>96]);
            Db::name("bbfx_plugin")->where(['ident'=>'directpush_achievement'])->update(['type'=>2,'sort'=>95]);
            Db::name("bbfx_plugin")->where(['ident'=>'directpush_jiandan'])->update(['type'=>2,'sort'=>94]);
            Db::name("bbfx_plugin")->where(['ident'=>'directpush_team'])->update(['type'=>2,'sort'=>93]);
            Db::name("bbfx_plugin")->where(['ident'=>'team_building'])->update(['type'=>2,'sort'=>92]);
            Db::name("bbfx_plugin")->where(['ident'=>'below'])->update(['type'=>2,'sort'=>91]);
            Db::name("bbfx_plugin")->where(['ident'=>'ladderabonus'])->update(['type'=>2,'sort'=>90]);
            Db::name("bbfx_plugin")->where(['ident'=>'sabonus'])->update(['type'=>2,'sort'=>89]);
            Db::name("bbfx_plugin")->where(['ident'=>'dynamic_redpacket'])->update(['type'=>2,'sort'=>88]);
            Db::name("bbfx_plugin")->where(['ident'=>'queue_mode'])->update(['type'=>2,'sort'=>87]);
            
            Db::name("bbfx_plugin")->where(['ident'=>'transfer21_mode'])->update(['type'=>3,'sort'=>99]);
            Db::name("bbfx_plugin")->where(['ident'=>'transfer_mode'])->update(['type'=>3,'sort'=>98]);
            Db::name("bbfx_plugin")->where(['ident'=>'double_track'])->update(['type'=>3,'sort'=>97]);
            Db::name("bbfx_plugin")->where(['ident'=>'yies_mode'])->update(['type'=>3,'sort'=>96]);
            
            Db::name("bbfx_plugin")->where(['ident'=>'repurchasegold'])->update(['type'=>4,'sort'=>99]);
            Db::name("bbfx_plugin")->where(['ident'=>'strikeout'])->update(['type'=>4,'sort'=>98]);
            Db::name("bbfx_plugin")->where(['ident'=>'transfer_account'])->update(['type'=>4,'sort'=>97]);
            Db::name("bbfx_plugin")->where(['ident'=>'cloud_warehouse'])->update(['type'=>4,'sort'=>96]);
            
            Db::name("bbfx_plugin")->where(['ident'=>'card'])->update(['type'=>5,'sort'=>99]);
            Db::name("bbfx_plugin")->where(['ident'=>'seckill'])->update(['type'=>5,'sort'=>98]);
            Db::name("bbfx_plugin")->where(['ident'=>'coupon'])->update(['type'=>5,'sort'=>97]);
            
            Db::name("bbfx_plugin")->where(['ident'=>'diypage'])->update(['type'=>6,'sort'=>99,'name'=>'页面装修']);
            Db::name("bbfx_plugin")->where(['ident'=>'scoreshop'])->update(['type'=>6,'sort'=>98]);
            Db::name("bbfx_plugin")->where(['ident'=>'news'])->update(['type'=>6,'sort'=>97]);
            Db::name("bbfx_plugin")->where(['ident'=>'apopup'])->update(['type'=>6,'sort'=>96]);
            Db::name("bbfx_plugin")->where(['ident'=>'contract'])->update(['type'=>6,'sort'=>95]);
            Db::name("bbfx_plugin")->where(['ident'=>'feedback'])->update(['type'=>6,'sort'=>94]);
            Db::name("bbfx_plugin")->where(['ident'=>'short_video'])->update(['type'=>6,'sort'=>93]);
            
            //v2.1.25
            if(!in_array('is_reservation',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `is_reservation` INT(10) NOT NULL DEFAULT '0' COMMENT '预约功能:1=开启,0=关闭';");
            }
            if(!in_array('content',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `content` LONGTEXT NULL COMMENT '门店详情';");
            }
            if(!in_array('images',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `images` TEXT NULL COMMENT '门店图片';");
            }
            if(!in_array('score',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `score` INT(10) UNSIGNED NOT NULL DEFAULT '5' COMMENT '评分';");
            }
            if(!in_array('introduction',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `introduction` VARCHAR(255) NULL COMMENT '门店简介';");
            }
            if(!pdo_tableexists("bbfx_store_reservation")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_store_reservation")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `mobile` varchar(100) DEFAULT NULL COMMENT '手机号',
                  `reservation_time` int(11) NOT NULL DEFAULT '0' COMMENT '预约时间',
                  `notes` varchar(500) DEFAULT NULL COMMENT '备注',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待处理,1=已处理',
                  `handle_time` int(11) NOT NULL DEFAULT '0' COMMENT '处理时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $store_reservationFields = Db::name("bbfx_store_reservation")->getTableFields();
            }
            else{
                $store_reservationFields = Db::name("bbfx_store_reservation")->getTableFields();
            }
            
            $plugin = Db::name("bbfx_plugin")->where("ident","problem")->find();
            if(empty($plugin)){ 
                $problem = array(
                    "name"=>"常见问题",
                    "ident"=>"problem",
                    "type"=>6,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-problem.png",
                    "sort"=>92,
                    "url"=>"/problem/index"
                );
                Db::name("bbfx_plugin")->insert($problem);
            }
            if(!pdo_tableexists("bbfx_problem")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_problem")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `content` text NULL COMMENT '内容',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $problemFields = Db::name("bbfx_problem")->getTableFields();
            }
            else{
                $problemFields = Db::name("bbfx_problem")->getTableFields();
            }
            
            //v2.1.26
            $plugin = Db::name("bbfx_plugin")->where("ident","deposit_release")->find();
            if(empty($plugin)){ 
                $deposit_release = array(
                    "name"=>"预存释放",
                    "ident"=>"deposit_release",
                    "type"=>2,
                    "status"=>1,
                    "icon"=>"/assets/images/plugin/plugin-deposit_release.png",
                    "sort"=>87,
                    "url"=>"/deposit_release/index"
                );
                Db::name("bbfx_plugin")->insert($deposit_release);
            }
            if(!in_array('deposit_money',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `deposit_money` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '预存款';");
            }
            if(!pdo_tableexists("bbfx_deposit_release")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_deposit_release")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `release_score` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '释放积分',
                  `release_balance` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '释放余额',
                  `release_currency` varchar(255) DEFAULT NULL COMMENT '释放币种',
                  `release_limit` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '释放额度',
                  `release_time_type` int(10) NOT NULL DEFAULT '1' COMMENT '释放时间类型:1=每月,2=每天',
                  `release_month` varchar(100) NOT NULL DEFAULT '2024-09' COMMENT '释放月份',
                  `deposit_paytype` varchar(255) DEFAULT NULL COMMENT '预存款支付方式',
                  `withdrawal` text NULL COMMENT '提现设置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $deposit_releaseFields = Db::name("bbfx_deposit_release")->getTableFields();
            }
            else{
                $deposit_releaseFields = Db::name("bbfx_deposit_release")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_deposit_release_order")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_deposit_release_order")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `order_no` varchar(100) DEFAULT NULL COMMENT '订单编号',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `money` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '存款金额',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待支付,1=已支付',
                  `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型:1=微信支付,2=余额支付',
                  `paytime` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间',
                  `one_share` int(10) NOT NULL DEFAULT '0',
                  `two_share` int(10) NOT NULL DEFAULT '0',
                  `three_share` int(10) NOT NULL DEFAULT '0',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $deposit_release_orderFields = Db::name("bbfx_deposit_release_order")->getTableFields();
            }
            else{
                $deposit_release_orderFields = Db::name("bbfx_deposit_release_order")->getTableFields();
            }
            
            if(!in_array('delivery_method',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `delivery_method` INT(10) NOT NULL DEFAULT '1' COMMENT '配送方式:1=快递配送,2=门店核销,3=快递配送和门店核销';");
            }
            if(!in_array('hexiao_store_type',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `hexiao_store_type` INT(10) NOT NULL DEFAULT '0' COMMENT '核销门店:0=全部门店,1=指定门店';");
            }
            if(!in_array('hexiao_num',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `hexiao_num` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '核销次数';");
            }
            if(!in_array('is_hexiao',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '门店核销(type=4):1=开启,0=关闭';");
            }
            if(!pdo_tableexists("bbfx_scoreshop_store_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_scoreshop_store_goods")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $store_goodsFields = Db::name("bbfx_scoreshop_store_goods")->getTableFields();
            }
            else{
                $store_goodsFields = Db::name("bbfx_scoreshop_store_goods")->getTableFields();
            }
            if(!in_array('delivery_method',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `delivery_method` INT(10) NOT NULL DEFAULT '1' COMMENT '配送方式:1=快递配送,2=门店核销';");
            }
            if(!in_array('is_hexiao',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '核销订单:1=是,0=否';");
            }
            if(!in_array('hexiao_realname',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_realname` VARCHAR(100) NULL COMMENT '用户姓名';");
            }
            if(!in_array('hexiao_mobile',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_mobile` VARCHAR(100) NULL COMMENT '用户电话';");
            }
            if(!in_array('hexiao_num',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '核销次数';");
            }
            if(!in_array('hexiao_total',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_total` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '核销总次数';");
            }
            if(!in_array('hexiao_uid',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_uid` INT(10) NOT NULL DEFAULT '0' COMMENT '核销用户';");
            }
            if(!in_array('hexiao_time',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_time` BIGINT(16) NULL DEFAULT '0' COMMENT '核销时间';");
            }
            if(!in_array('hexiao_store',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_store` TEXT NULL COMMENT '核销门店';");
            }
            if(!in_array('hexiao_qrcode',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_qrcode` VARCHAR(255) NULL COMMENT '核销二维码';");
            }
            if(!in_array('hexiao_wxacode',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_wxacode` VARCHAR(255) NULL COMMENT '核销小程序码';");
            }
            if(!in_array('hexiao_code',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `hexiao_code` VARCHAR(20) NULL COMMENT '核销码';");
            }
            if(!pdo_tableexists("bbfx_scoreshop_order_hexiao_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_scoreshop_order_hexiao_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `info` longtext NULL COMMENT '数据',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '核销时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $scoreshop_order_hexiao_recordFields = Db::name("bbfx_scoreshop_order_hexiao_record")->getTableFields();
            }
            else{
                $scoreshop_order_hexiao_recordFields = Db::name("bbfx_scoreshop_order_hexiao_record")->getTableFields();
            }
            
            //v2.1.30
            if(!in_array('virtual_sale',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `virtual_sale` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '虚拟销量';");
            }
            
            //v2.1.31
            if(!in_array('store_id',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `store_id` INT(10) NOT NULL DEFAULT '0' COMMENT '门店ID';");
            }
            
            //v2.1.32
            if(!in_array('hide_close_plugin',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `hide_close_plugin` INT(10) NOT NULL DEFAULT '0' COMMENT '隐藏关闭应用:1=是,0=否';");
            }
            
            //v2.1.33
            if(!pdo_tableexists("bbfx_goods_comment")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_comment")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `goods_name` varchar(255) DEFAULT NULL COMMENT '商品名称',
                  `content` varchar(500) DEFAULT NULL COMMENT '评论内容',
                  `images` text NULL COMMENT '评论图片',
                  `score` int(10) NOT NULL DEFAULT '1' COMMENT '评论',
                  `sh_status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待审核,1=已通过,2=已拒绝',
                  `sh_time` int(11) NOT NULL DEFAULT '0' COMMENT '审核时间',
                  `info` text,
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_commentFields = Db::name("bbfx_goods_comment")->getTableFields();
            }
            else{
                $goods_commentFields = Db::name("bbfx_goods_comment")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_comment_zan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_comment_zan")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=商品',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '主ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $comment_zanFields = Db::name("bbfx_comment_zan")->getTableFields();
            }
            else{
                $comment_zanFields = Db::name("bbfx_comment_zan")->getTableFields();
            }
            if(!in_array('uniacid',$admin_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin_log")." ADD `uniacid` INT(10) NOT NULL DEFAULT '1' COMMENT '平台ID';");
            }
            
            if($bbfx['sversion'] <= 2133){
                if(in_array('status',$categoryFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_category")." CHANGE `status` `status` INT(10) NOT NULL DEFAULT '1' COMMENT '是否显示:1=显示,0=隐藏';");
                }
                if(in_array('stock',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `stock` `stock` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '库存';");
                }
                if(in_array('status',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `status` `status` INT(10) NOT NULL DEFAULT '1' COMMENT '状态:1=上架,0=下架';");
                }
                if(in_array('is_recommend',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_recommend` `is_recommend` INT(10) NOT NULL DEFAULT '0' COMMENT '首页推荐:1=开启,0=关闭';");
                }
                if(in_array('is_recommend',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_recommend` `is_recommend` INT(10) NOT NULL DEFAULT '0' COMMENT '推荐:1=开启,0=关闭';");
                }
                if(in_array('is_new',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_new` `is_new` INT(10) NOT NULL DEFAULT '0' COMMENT '新品:1=开启,0=关闭';");
                }
                if(in_array('is_hot',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_hot` `is_hot` INT(10) NOT NULL DEFAULT '0' COMMENT '热卖:1=开启,0=关闭';");
                }
                if(in_array('is_nodiscount',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_nodiscount` `is_nodiscount` INT(10) NOT NULL DEFAULT '0' COMMENT '不参与会员折扣:1=是,0=否';");
                }
                if(in_array('share_title',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `share_title` `share_title` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分享标题';");
                }
                if(in_array('share_title',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `share_title` `share_title` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分享标题';");
                }
                if(in_array('share_desc',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `share_desc` `share_desc` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分享描述';");
                }
                if(in_array('share_img',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `share_img` `share_img` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分享图片';");
                }
                if(in_array('is_fenxiao',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_fenxiao` `is_fenxiao` INT(10) NOT NULL DEFAULT '1' COMMENT '分销功能:1=开启,0=关闭';");
                }
                if(in_array('is_hexiao',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_hexiao` `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '门店核销:1=开启,0=关闭';");
                }
                if(in_array('is_jicha_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_jicha_rule` `is_jicha_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '独立级差奖:1=开启,0=关闭';");
                }
                if(in_array('is_jiandan_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_jiandan_rule` `is_jiandan_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '独立见单奖:1=开启,0=关闭';");
                }
                if(in_array('is_pingji_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_pingji_rule` `is_pingji_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '独立平级奖:1=开启,0=关闭';");
                }
                if(in_array('is_abonus_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_abonus_rule` `is_abonus_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '独立分红配置:1=开启,0=关闭';");
                }
                if(in_array('is_leveldiscount_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_leveldiscount_rule` `is_leveldiscount_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '商品独立会员折扣:1=开启,0=关闭';");
                }
                if(in_array('is_return',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_return` `is_return` INT(10) NOT NULL DEFAULT '1' COMMENT '返还奖:1=开启,0=关闭';");
                }
                if(in_array('is_return_rule',$goodsFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `is_return_rule` `is_return_rule` INT(10) NOT NULL DEFAULT '0' COMMENT '返还奖独立规则:1=开启,0=关闭';");
                }
                if(in_array('sex',$userFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `sex` `sex` INT(10) NOT NULL DEFAULT '0' COMMENT '性别:1=男,2=女';");
                }
                if(in_array('status',$userFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `status` `status` INT(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,2=冻结';");
                }
                if(in_array('is_distributor',$userFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `is_distributor` `is_distributor` INT(10) NOT NULL DEFAULT '0' COMMENT '分销商:1=是,0=否';");
                }
                // if(in_array('field',$userFields)){ 
                //     Db::execute("ALTER TABLE ".tablename("bbfx_user")." ");
                // }
            } 
            
            //v2.1.37
            if(!in_array('pid',$categoryFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_category")." ADD `pid` INT(10) NOT NULL DEFAULT '0' COMMENT '上级分类ID';");
            }
            if(in_array('sign_time',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `sign_time` `signin_time` INT(11) NOT NULL DEFAULT '0' COMMENT '签到时间';");
            }
            if(in_array('continuity_day',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `continuity_day` `continuity_signin_day` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '连续签到天数';");
            }
            if(in_array('totalsign_day',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `totalsign_day` `total_signin_day` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '总签到天数';");
            }
            
            if(!in_array('pintuan_price',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `pintuan_price` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '拼团价格';");
            }
            if(!in_array('kaituan_price',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `kaituan_price` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '开团价';");
            }
            if(!in_array('signin_remind',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `signin_remind` INT(10) NOT NULL DEFAULT '0' COMMENT '签到提醒';");
            }
            if(!in_array('last_login_time',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `last_login_time` INT(11) NOT NULL DEFAULT '0' COMMENT '最后登录时间';");
            }
            if(!in_array('total_continuity_signin_day',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `total_continuity_signin_day` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '总连续签到天数';");
            }
            if(!in_array('order_source',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `order_source` INT(10) NOT NULL DEFAULT '0' COMMENT '订单来源:0=商城订单,1=秒杀订单,2=云仓提货订单,3=拼团订单';");
            }
            if(!in_array('pintuan_order_id',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `pintuan_order_id` INT(10) NOT NULL DEFAULT '0' COMMENT '拼团主订单ID';");
            }
            if(!in_array('pintuan_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `pintuan_status` INT(10) NOT NULL DEFAULT '-1' COMMENT '拼团状态:-1=待支付,0=拼团中,1=拼团成功,2=拼团失败';");
            }
            if(!in_array('pintuan_goods_id',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `pintuan_goods_id` INT(10) NOT NULL DEFAULT '0' COMMENT '拼团商品ID';");
            }
            if(!in_array('withdrawal_integer_multiple',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `withdrawal_integer_multiple` INT(10) NOT NULL DEFAULT '0' COMMENT '提现限制倍数';");
            }
            
            if(!pdo_tableexists("bbfx_pintuan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pintuan")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `bg` varchar(255) NOT NULL DEFAULT '/assets/images/plugin/pintuan/bg.jpg' COMMENT '拼团背景',
                  `bg_color` varchar(255) NOT NULL DEFAULT '#FD4349,#FF6A4E' COMMENT '背景颜色',
                  `pintuan_desc` TEXT NULL COMMENT '拼团玩法',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pintuanFields = Db::name("bbfx_pintuan")->getTableFields();
            }
            else{
                $pintuanFields = Db::name("bbfx_pintuan")->getTableFields();
            }
            
            if(!in_array('pintuan_desc',$pintuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pintuan")." ADD `pintuan_desc` TEXT NULL COMMENT '拼团玩法';");
            }
            
            if(!pdo_tableexists("bbfx_pintuan_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pintuan_goods")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '绑定商品',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '拼团价格',
                  `pintuan_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '成团人数',
                  `buy` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '购买次数',
                  `virtual_pintian` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '虚拟成团',
                  `stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动库存',
                  `is_limitedtime` int(10) NOT NULL DEFAULT '0' COMMENT '组团限时:1=开启,0=关闭',
                  `yx_day` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '有效天数',
                  `is_tuanzhangyh` int(10) NOT NULL DEFAULT '0' COMMENT '团长优惠:1=开启,0=关闭',
                  `kaituan_price` decimal(10,0) UNSIGNED NOT NULL DEFAULT '0' COMMENT '开团价格',
                  `auto_pintuan_success` int(10) NOT NULL DEFAULT '0' COMMENT '自动拼团成功:1=开启,0=关闭',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=上架,0=下架',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `endtime` int(11) NOT NULL DEFAULT '0' COMMENT '截止时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pintuan_goodsFields = Db::name("bbfx_pintuan_goods")->getTableFields();
            }
            else{
                $pintuan_goodsFields = Db::name("bbfx_pintuan_goods")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_pintuan_order")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pintuan_order")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `pintuan_goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '拼团商品',
                  `total` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '成团人数',
                  `residue` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '剩余人数',
                  `tz_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '团长ID',
                  `tz_price` decimal(10,0) UNSIGNED NOT NULL DEFAULT '0' COMMENT '团长购买价格',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '拼团价格',
                  `status` int(10) NOT NULL DEFAULT '-1' COMMENT '状态:-1=待支付,0=拼团中,1=拼团成功,2=拼团失败,-2=关闭拼团',
                  `starttime` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
                  `endtime` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
                  `jiesuantime` int(11) NOT NULL DEFAULT '0' COMMENT '结算时间',
                  `goods` longtext NULL COMMENT '商品数据',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pintuan_orderFields = Db::name("bbfx_pintuan_order")->getTableFields();
            }
            else{
                $pintuan_orderFields = Db::name("bbfx_pintuan_order")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_signin")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_signin")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `day` int(10) UNSIGNED NOT NULL DEFAULT '15' COMMENT '签到天数',
                  `signin_reward` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '签到奖励',
                  `reward_type` int(10) NOT NULL DEFAULT '2' COMMENT '奖励类型:1=余额,2=积分',
                  `continuity_signin_rule` text NULL COMMENT '连续签到规则',
                  `bg` varchar(255) DEFAULT NULL COMMENT '签到背景',
                  `signin_on_color` varchar(255) DEFAULT '#ED7398,#EE7ACD' COMMENT '已签到背景',
                  `signin_color` varchar(100) DEFAULT '#FAE5F1' COMMENT '未签到背景',
                  `signin_icon` varchar(255) DEFAULT NULL COMMENT '签到图标',
                  `sdesc` text NULL COMMENT '签到说明',
                  `pop_image` varchar(255) DEFAULT NULL COMMENT '签到弹窗图片',
                  `haowu_recommend_image` varchar(255) DEFAULT NULL COMMENT '好物推荐图片',
                  `btn_right_image` varchar(255) DEFAULT NULL COMMENT '按钮右侧图片',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $signinFields = Db::name("bbfx_signin")->getTableFields();
            }
            else{
                $signinFields = Db::name("bbfx_signin")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_signin_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_signin_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `total` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '奖励',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '奖励类型:1=余额,2=积分',
                  `date` date DEFAULT NULL COMMENT '签到日期',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $signin_recordFields = Db::name("bbfx_signin_record")->getTableFields();
            }
            else{
                $signin_recordFields = Db::name("bbfx_signin_record")->getTableFields();
            }
            
            //v2.1.39
            if(!in_array('service_provider_status',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_status` INT(10) NOT NULL DEFAULT '0' COMMENT '服务商支付:1=开启,0=关闭';");
            }
            if(!in_array('service_provider_appid',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_appid` VARCHAR(100) NULL COMMENT '服务商APPID';");
            }
            if(!in_array('service_provider_mchid',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_mchid` VARCHAR(100) NULL COMMENT '服务商商户号';");
            }
            if(!in_array('service_provider_paykey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_paykey` VARCHAR(255) NULL COMMENT '服务商支付秘钥';");
            }
            if(!in_array('service_provider_cert',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_cert` VARCHAR(255) NULL COMMENT '服务商支付证书';");
            }
            if(!in_array('service_provider_certkey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `service_provider_certkey` VARCHAR(255) NULL COMMENT '服务商支付证书秘钥';");
            }
            
            //v2.1.42
            if(!in_array('is_chaoyue',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `is_chaoyue` INT(10) NOT NULL DEFAULT '0' COMMENT '超越奖:1=开启,0=关闭';");
            }
            if(!in_array('cy_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `cy_reward` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '超越奖';");
            }
            
            if(!pdo_tableexists("bbfx_sinterest")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sinterest")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `settlement_type` int(10) NOT NULL DEFAULT '0' COMMENT '结算类型:0=每天结算,1=每月结算,2=每年结算',
                  `settlement_currency` varchar(255) NOT NULL DEFAULT '' COMMENT '结算币种:1=余额,2=积分',
                  `settlement_balance_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '结算余额比例',
                  `settlement_score_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '结算积分比例',
                  `sdate` date DEFAULT NULL COMMENT '结算日期',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sinterestFields = Db::name("bbfx_sinterest")->getTableFields();
            }
            else{
                $sinterestFields = Db::name("bbfx_sinterest")->getTableFields();
            }
            
            if(!pdo_tableexists("bbfx_chaoyue")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chaoyue")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chaoyueFields = Db::name("bbfx_chaoyue")->getTableFields();
            }
            else{
                $chaoyueFields = Db::name("bbfx_chaoyue")->getTableFields();
            }
            
            //v2.1.44
            if($bbfx['sversion'] <= 2144){
                if(in_array('reward_type',$signinFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_signin")." CHANGE `reward_type` `reward_type` INT(10) NOT NULL DEFAULT '2' COMMENT '奖励类型:1=余额,2=积分';");
                }
            }
            if(!in_array('is_shipping',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `is_shipping` INT(10) NOT NULL DEFAULT '0' COMMENT '是否上传发货信息:1=是,0=否'");
            }
            if(!in_array('monthly_buy',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `monthly_buy` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '每月最多购买'");
            }
            
            //v2.1.45
            if(!in_array('platform',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `platform` VARCHAR(255) NULL COMMENT '下单平台';");
            }
            if(in_array('settlement_currency',$sinterestFields) && $bbfx['sversion'] <= 2145){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sinterest")."  CHANGE `settlement_currency` `settlement_currency` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '结算币种:1=余额,2=积分';");
            }
            
            //v2.1.46
            
            
            //v2.1.47
            if(!in_array('management_remove_daqu',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `management_remove_daqu` INT(10) NOT NULL DEFAULT '0' COMMENT '去除大区业绩:1=开启,0=关闭';");
            }
            
            //v2.1.49
            if(!in_array('transaction_id',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `transaction_id` VARCHAR(255) NULL COMMENT '微信订单号'");
            }
             
            //v2.1.49
            if(!in_array('is_management_assistant_reward',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_management_assistant_reward` INT(10) NOT NULL DEFAULT '0' COMMENT '管理奖辅助奖:1=开启,0=关闭'");
            }
            if(!in_array('management_assistant_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `management_assistant_reward` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '管理奖辅助奖'");
            }
            
            //v2.1.51
            if(!in_array('jiandan_level',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `jiandan_level` INT(10) NOT NULL DEFAULT '0' COMMENT '见单奖层级'"); 
            }
            
            //v2.1.53
            if(!in_array('extend',$fenxiao_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_order")." ADD `extend` TEXT NULL COMMENT '扩展参数'"); 
            }
            if(!in_array('part_calculate',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `part_calculate` INT(10) NOT NULL DEFAULT '0' COMMENT '到账股份用户:0=用户上级,1=用户自己'"); 
            }
            
            //v2.1.55
            if(in_array('money',$transfer_account_logFields) && $bbfx['sversion'] <= 2155){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account_log")." CHANGE `money` `money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '转账金额/积分'"); 
            }
            
            //v2.1.56
            if(!pdo_tableexists("bbfx_ladderpingji")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_ladderpingji")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `condition_type` int(10) NOT NULL DEFAULT '0' COMMENT '条件类型:0=直推指定等级用户,1=直推人数,2=团队人数',
                  `reward_source` varchar(1000) DEFAULT NULL COMMENT '奖励来源',
                  `rule` text NULL COMMENT '规则',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $ladderpingjiFields = Db::name("bbfx_ladderpingji")->getTableFields();
            }
            else{
                $ladderpingjiFields = Db::name("bbfx_ladderpingji")->getTableFields();
            }
            
            //v2.1.57
            if(!in_array('type',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `type` INT(10) NOT NULL DEFAULT '0' COMMENT '类型:1=商户门店,0=平台门店'"); 
            }
            if(!in_array('main',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `main` INT(10) NOT NULL DEFAULT '0' COMMENT '主门店:1=是,0=否'"); 
            }
            if(!in_array('mid',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('detail_images',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `detail_images` TEXT NULL COMMENT '详情图片'"); 
            }
            if(!in_array('mid',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('mid',$categoryFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_category")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('mid',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('mid',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('mid',$user_cartFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_cart")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID'"); 
            }
            if(!in_array('sh_status',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `sh_status` INT(10) NOT NULL DEFAULT '0' COMMENT '审核状态:0=待审核,1=通过,2=驳回'"); 
            }
            if(!in_array('sh_time',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `sh_time` INT(11) NOT NULL DEFAULT '0' COMMENT '审核时间'"); 
            } 
            if(!in_array('updatetime',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `updatetime` INT(11) NOT NULL DEFAULT '0' COMMENT '更新时间'"); 
            } 
            if(!in_array('jiesuan_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `jiesuan_status` INT(10) NOT NULL DEFAULT '0' COMMENT '商户订单结算状态:0=待结算,1=已结算,2=已到账'"); 
            }
            if(!in_array('daozhang_time',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `daozhang_time` INT(11) NOT NULL DEFAULT '0' COMMENT '商户订单到账时间'"); 
            }
            if(!pdo_tableexists("bbfx_merchant_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_merchant_set")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `apply_status` int(10) NOT NULL DEFAULT '0' COMMENT '商户申请:1=开启,0=关闭',
                  `apply_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '申请审核:1=开启,0=关闭',
                  `apply_condition_type` int(10) NOT NULL DEFAULT '0' COMMENT '申请条件:0=无条件,1=购买商品,2=直推指定等级人数,3=直推人数,4=团队人数',
                  `apply_condition` text NULL COMMENT '申请条件',
                  `goods_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '商品审核:1=开启,0=关闭',
                  `daozhang_type` int(10) NOT NULL DEFAULT '0' COMMENT '到账时间:0=订单完成后,1=订单过售后期后',
                  `is_fenxiao` int(10) NOT NULL DEFAULT '0' COMMENT '分销功能:1=开启,0=关闭',
                  `edit_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '编辑审核:1=开启,0=关闭',
                  `edit_goods_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '编辑商品审核:1=开启,0=关闭',
                  `withdrawal` text NULL COMMENT '提现配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $merchant_setFields = Db::name("bbfx_merchant_set")->getTableFields();
            }
            else{
                $merchant_setFields = Db::name("bbfx_merchant_set")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_merchant")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_merchant")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '绑定用户',
                  `name` varchar(100) DEFAULT NULL COMMENT '商户名称',
                  `logo` varchar(255) DEFAULT NULL COMMENT '商家logo',
                  `realname` varchar(100) DEFAULT NULL COMMENT '联系人',
                  `mobile` varchar(100) DEFAULT NULL COMMENT '联系电话',
                  `balance` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '余额',
                  `balance_total` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '累计余额',
                  `province` varchar(100) DEFAULT NULL COMMENT '省份',
                  `city` varchar(100) DEFAULT NULL COMMENT '城市',
                  `area` varchar(100) DEFAULT NULL COMMENT '区县',
                  `address` varchar(100) DEFAULT NULL COMMENT '详细地址',
                  `lng` double NOT NULL DEFAULT '0' COMMENT '经度',
                  `lat` double NOT NULL DEFAULT '0' COMMENT '纬度',
                  `yy_time` varchar(100) DEFAULT NULL COMMENT '营业时间',
                  `introduction` varchar(255) DEFAULT NULL COMMENT '门店简介',
                  `content` longtext NULL COMMENT '门店介绍',
                  `detail_images` text NULL COMMENT '详情图片',
                  `images` text NULL COMMENT '门店图片',
                  `is_fenxiao` int(10) NOT NULL DEFAULT '0' COMMENT '分销功能:1=开启,0=关闭',
                  `commission_rate` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '分润佣金比例',
                  `yy_status` int(10) NOT NULL DEFAULT '1' COMMENT '营业状态:1=开启,0=关闭',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                  `is_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '审核通过:1=是,0=否',
                  `sh_status` int(10) NOT NULL DEFAULT '0' COMMENT '审核状态:0=待审核,1=通过,2=驳回',
                  `sh_time` int(11) NOT NULL DEFAULT '0' COMMENT '审核时间',
                  `sh_data` longtext NULL COMMENT '审核数据',
                  `updatetime` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $merchantFields = Db::name("bbfx_merchant")->getTableFields();
            }
            else{
                $merchantFields = Db::name("bbfx_merchant")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_merchant_money_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_merchant_money_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `mid` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动金额',
                  `befores` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动前',
                  `afters` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动后',
                  `remarks` varchar(255) NOT NULL COMMENT '备注',
                  `info` text NULL COMMENT '数据',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '金额类型:1=余额',
                  `item_type` int(10) NOT NULL DEFAULT '0' COMMENT '操作类型:1=商品订单结算,2=余额提现,3=提现驳回',
                  `item_id` varchar(100) NOT NULL COMMENT '项目ID',
                  `createtime` int(11) NOT NULL,
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $merchant_money_logFields = Db::name("bbfx_merchant_money_log")->getTableFields();
            }
            else{
                $merchant_money_logFields = Db::name("bbfx_merchant_money_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_crazy")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_crazy")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `daozhang_type` int(10) NOT NULL DEFAULT '0' COMMENT '份额到账类型:1=付款后到账,0=完成后到账',
                  `repurchase_goods` varchar(255) DEFAULT NULL COMMENT '复购商品',
                  `abonus_num` int(10) NOT NULL DEFAULT '1' COMMENT '分红次数',
                  `abonus_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每份金额',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $crazyFields = Db::name("bbfx_crazy")->getTableFields();
            }
            else{
                $crazyFields = Db::name("bbfx_crazy")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_crazy_group")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_crazy_group")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '分红用户ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '组长ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `total` int(10) NOT NULL DEFAULT '0' COMMENT '人数',
                  `stime` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
                  `etime` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待分红,1=已分红',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $crazy_groupFields = Db::name("bbfx_crazy_group")->getTableFields();
            }
            else{
                $crazy_groupFields = Db::name("bbfx_crazy_group")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_crazy_group_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_crazy_group_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '分红用户ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `group_id` int(10) NOT NULL DEFAULT '0' COMMENT '分组ID',
                  `money` decimal(10,0) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红金额',
                  `contribution_value` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $crazy_group_userFields = Db::name("bbfx_crazy_group_user")->getTableFields();
            }
            else{
                $crazy_group_userFields = Db::name("bbfx_crazy_group_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_crazy_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_crazy_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `num` int(10) NOT NULL DEFAULT '0' COMMENT '分红次数',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                  `contribution_value` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值',
                  `info` text NULL COMMENT '信息',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已完成,0=进行中',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $crazy_userFields = Db::name("bbfx_crazy_user")->getTableFields();
            }
            else{
                $crazy_userFields = Db::name("bbfx_crazy_user")->getTableFields();
            }
            
            if(!in_array('is_crazy',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_crazy` INT(10) NOT NULL DEFAULT '0' COMMENT '疯狂卖货模式订单'"); 
            }
            
            //v2.1.58
            if(!in_array('weixin',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `weixin` VARCHAR(255) NULL COMMENT '微信号'"); 
            }  
            if(!pdo_tableexists("bbfx_sconnection")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sconnection")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `interval_upgrade` int(10) NOT NULL DEFAULT '0' COMMENT '隔代升级:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sconnectionFields = Db::name("bbfx_sconnection")->getTableFields();
            }
            else{
                $sconnectionFields = Db::name("bbfx_sconnection")->getTableFields();
            }   
            if(!pdo_tableexists("bbfx_sconnection_upgrade_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sconnection_upgrade_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `sh_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '审核用户ID',
                  `level` int(10) NOT NULL DEFAULT '0' COMMENT '申请等级',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已审核,0=待审核',
                  `upgradetime` int(11) NOT NULL DEFAULT '0' COMMENT '升级时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sconnection_upgrade_logFields = Db::name("bbfx_sconnection_upgrade_log")->getTableFields();
            }
            else{
                $sconnection_upgrade_logFields = Db::name("bbfx_sconnection_upgrade_log")->getTableFields();
            }   
            if(!pdo_tableexists("bbfx_notice")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_notice")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=系统通知,1=消息推送',
                  `itype` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `title` varchar(255) DEFAULT NULL COMMENT '标题',
                  `content` longtext NULL COMMENT '内容',
                  `link` varchar(255) DEFAULT NULL COMMENT '跳转链接',
                  `is_read` int(10) NOT NULL DEFAULT '0' COMMENT '已读:1=是,0=否',
                  `readtime` int(11) NOT NULL DEFAULT '0' COMMENT '阅读时间',
                  `extend` text NULL COMMENT '信息',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $noticeFields = Db::name("bbfx_notice")->getTableFields();
            }
            else{
                $noticeFields = Db::name("bbfx_notice")->getTableFields();
            }   
            if(!pdo_tableexists("bbfx_notice_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_notice_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `pid` int(10) NOT NULL DEFAULT '0',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $notice_logFields = Db::name("bbfx_notice_log")->getTableFields();
            }
            else{
                $notice_logFields = Db::name("bbfx_notice_log")->getTableFields();
            }           
            
            
            //v2.1.61
            if(!in_array('group_id',$crazy_groupFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_crazy_group")." ADD `group_id` INT(10) NOT NULL DEFAULT '0' COMMENT '主分红组ID'"); 
            }
            if(!in_array('upgrade_commission',$sconnectionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sconnection")." ADD `upgrade_commission` TEXT NULL COMMENT '升级手续费'"); 
            }
            
            //v2.1.62
            if(!in_array('apply_upgrade_zhitui_user',$sconnectionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sconnection")." ADD `apply_upgrade_zhitui_user` INT(10) NOT NULL DEFAULT '0' COMMENT '申请升级直推人数（默认等级除外）'"); 
            }
            
            //v2.1.63
            if(!pdo_tableexists("bbfx_sconnection_upgrade_order")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sconnection_upgrade_order")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `order_no` varchar(100) DEFAULT NULL COMMENT '订单编号',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '升级记录ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '订单金额',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '支付状态:1=已支付,0=未支付',
                  `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型:1=微信,2=余额',
                  `paytime` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间',
                  `info` text NULL COMMENT '信息',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sconnection_upgrade_orderFields = Db::name("bbfx_sconnection_upgrade_order")->getTableFields();
            }
            else{
                $sconnection_upgrade_orderFields = Db::name("bbfx_sconnection_upgrade_order")->getTableFields();
            }     
            if(!in_array('ordinary_user_share',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `ordinary_user_share` INT(10) NOT NULL DEFAULT '0' COMMENT '普通用户分享:1=开启,0=关闭'"); 
            }
            
            
            //v2.1.65
            if(!in_array('plugin',$pintuan_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pintuan_goods")." ADD `plugin` TEXT NULL COMMENT '插件数据'"); 
            }    
            if(!in_array('rebate_pintuan_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `rebate_pintuan_status` INT(10) NOT NULL DEFAULT '-1' COMMENT '返利拼团:-1=未参与,0=未拼中,1=已拼中'"); 
            }  
            if(!in_array('wealth_point_uid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `wealth_point_uid` INT(10) NOT NULL DEFAULT '0' COMMENT '财富点位用户'"); 
            }
            if(!pdo_tableexists("bbfx_rebate_pintuan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_rebate_pintuan")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `daozhang_type` int(10) NOT NULL DEFAULT '0' COMMENT '到账时间:0=拼中后,1=发货后,2=完成后',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $rebate_pintuanFields = Db::name("bbfx_rebate_pintuan")->getTableFields();
            }
            else{
                $rebate_pintuanFields = Db::name("bbfx_rebate_pintuan")->getTableFields();
            } 
            
            //v2.1.66
            if(!in_array('is_npingji',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `is_npingji` INT(10) NOT NULL DEFAULT '0' COMMENT '内缩平级奖:1=开启,0=关闭'"); 
            }
            if(!in_array('npingji_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `npingji_reward` INT(10) NULL DEFAULT '0' COMMENT '内缩平级奖'"); 
            }
            if(!in_array('is_jicha',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `is_jicha` INT(10) NOT NULL DEFAULT '0' COMMENT '代理级差:1=开启,0=关闭'"); 
            }
            if(!in_array('is_deputy_city_agent',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `is_deputy_city_agent` INT(10) NOT NULL DEFAULT '0' COMMENT '副市级代理:1=开启,0=关闭'"); 
            }
            if(!in_array('achievement_subsidy',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `achievement_subsidy` TEXT NULL COMMENT '业绩补贴'"); 
            }
            if(!in_array('is_deputy_city_agent',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `is_deputy_city_agent` INT(10) NOT NULL DEFAULT '0' COMMENT '副市级代理:1=是,0=否'"); 
            }
            if(!in_array('is_tixian_activate',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `is_tixian_activate` INT(10) NOT NULL DEFAULT '1' COMMENT '提现激活:1=开启,0=关闭'"); 
            }
            if(!in_array('tixian_activate_time',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `tixian_activate_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '提现激活时间'"); 
            }
            if(!in_array('is_deputy_city_agent',$agent_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent_log")." ADD `is_deputy_city_agent` INT(10) NOT NULL DEFAULT '0' COMMENT '副市级代理:1=是,0=否'"); 
            }
            if(!in_array('jiandan',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `jiandan` TEXT NULL COMMENT '见单业绩'"); 
            }
            if(!in_array('is_withdrawal_limit',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_withdrawal_limit` INT(10) NOT NULL DEFAULT '0' COMMENT '提现限制:1=开启,0=关闭'"); 
            }
            if(!in_array('withdrawal_limit_amount',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `withdrawal_limit_amount` INT(10) NOT NULL DEFAULT '0' COMMENT '提现限制金额'"); 
            }
            if(!in_array('withdrawal_unlimit_order',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `withdrawal_unlimit_order` INT(10) NOT NULL DEFAULT '0' COMMENT '解除限制单数'"); 
            }
            if(!in_array('withdrawal_unlimit_buygoods',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD  `withdrawal_unlimit_buygoods` VARCHAR(255) NULL COMMENT '激活提现购买商品'"); 
            }
            if(!in_array('abonus_cycle',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `abonus_cycle` INT(10) NOT NULL DEFAULT '0' COMMENT '分红周期:0=日,1=周,2=月'"); 
            }
            if(!in_array('reward_source',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `reward_source` INT(10) NOT NULL DEFAULT '0' COMMENT '奖励来源:0=商品订单业绩,1=商品分红金额'"); 
            }
            if(!in_array('part_source',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `part_source` INT(10) NOT NULL DEFAULT '0' COMMENT '股份来源:0=商品股份,1=直推股份'"); 
            }
            if(!in_array('zhitui_order',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `zhitui_order` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '直推单数'"); 
            }
            if(!in_array('abonus_money',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `abonus_money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '累计可分红金额'"); 
            }
            if(!in_array('is_add_sabonus',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_add_sabonus` INT(10) NOT NULL DEFAULT '0' COMMENT '加入股份分红:1=是,0=否'"); 
            }
            if(!in_array('part_source',$sabonus_partFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus_part")." ADD `part_source` INT(10) NOT NULL DEFAULT '0' COMMENT '股份来源:0=商品股份,1=直推股份'"); 
            }
            if(!pdo_tableexists("bbfx_npingji")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_npingji")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `layer` int(10) NOT NULL DEFAULT '1' COMMENT '平级奖层数',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $npingjiFields = Db::name("bbfx_npingji")->getTableFields();
            }
            else{
                $npingjiFields = Db::name("bbfx_npingji")->getTableFields();
            } 
            if(!pdo_tableexists("bbfx_txabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_txabonus")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `team_subsidy` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '团队补贴',
                  `tixian_extract_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '提现抽取比例',
                  `buy_goods` varchar(255) DEFAULT NULL COMMENT '购买商品',
                  `abonus_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红人数',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $txabonusFields = Db::name("bbfx_txabonus")->getTableFields();
            }
            else{
                $txabonusFields = Db::name("bbfx_txabonus")->getTableFields();
            } 
            if(!pdo_tableexists("bbfx_txabonus_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_txabonus_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '抽取金额',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '提现ID',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $txabonus_logFields = Db::name("bbfx_txabonus_log")->getTableFields();
            }
            else{
                $txabonus_logFields = Db::name("bbfx_txabonus_log")->getTableFields();
            } 
            if(!pdo_tableexists("bbfx_txabonus_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_txabonus_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $txabonus_userFields = Db::name("bbfx_txabonus_user")->getTableFields();
            }
            else{
                $txabonus_userFields = Db::name("bbfx_txabonus_user")->getTableFields();
            } 
            if(!in_array('extend',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `extend` LONGTEXT NULL COMMENT '扩展数据'"); 
            }
            
            
            //v2.1.68
            if(!in_array('pingji_reward_num',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `pingji_reward_num` INT(10) NOT NULL DEFAULT '0' COMMENT '平级奖获得人数'"); 
            }
            if(!in_array('daily_buy',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `daily_buy` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '每日最多购买'"); 
            }
            if(!in_array('monthly_buy',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `monthly_buy` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '每月最多购买'"); 
            }
            if(!in_array('shippingfee_template_id',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `shippingfee_template_id` INT(10) NOT NULL DEFAULT '0' COMMENT '运费模板ID'"); 
            }
            if(!in_array('weight',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `weight` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '重量（kg）'"); 
            }
            if(!in_array('volume',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `volume` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '体积（m³）'"); 
            }
            if(!in_array('shippingfee_template_id',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `shippingfee_template_id` INT(10) NOT NULL DEFAULT '0' COMMENT '运费模板ID'"); 
            }
            if(!in_array('weight',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `weight` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '重量（kg）'"); 
            }
            if(!in_array('volume',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `volume` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '体积（m³）'"); 
            }
            if(!in_array('weight',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `weight` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '重量（kg）'"); 
            }
            if(!in_array('volume',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `volume` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '体积（m³）'"); 
            }
            if(!pdo_tableexists("bbfx_shippingfee_template")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_shippingfee_template")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '模板名称',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=按重量计费,1=按体积计费,2=按件计费',
                  `rule` text NULL COMMENT '运费规则',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $shippingfee_templateFields = Db::name("bbfx_shippingfee_template")->getTableFields();
            }
            else{
                $shippingfee_templateFields = Db::name("bbfx_shippingfee_template")->getTableFields();
            } 
            
            //v2.1.70  
            if(!in_array('detail_images',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `detail_images` VARCHAR(1000) NULL COMMENT '详情图片'"); 
                $goodsFields[] = 'detail_images';
            }
            Db::name("bbfx_merchant")->where(['sh_status'=>1,'is_shenhe'=>0])->update(['is_shenhe'=>1]);
            
            
            //v2.1.71  
            if(!pdo_tableexists("bbfx_capitalpool")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_capitalpool")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `abonus_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '资金池金额',
                  `capital_rate` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '资金比例',
                  `capital_settlement_type` int(10) NOT NULL DEFAULT '1' COMMENT '资金结算:1=付款后结算,2=完成后结算,3=每进指定单量计算',
                  `capital_settlement_order` int(10) NOT NULL DEFAULT '0' COMMENT '资金池结算单量',
                  `capital_settlement_finally_order` int(10) NOT NULL DEFAULT '0' COMMENT '最后结算资金池订单',
                  `settlement_type` int(10) NOT NULL DEFAULT '0' COMMENT '结算类型:0=手动结算,1=每月结算,2=每季结算,3=每年结算',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $capitalpoolFields = Db::name("bbfx_capitalpool")->getTableFields();
            }
            else{
                $capitalpoolFields = Db::name("bbfx_capitalpool")->getTableFields();
            } 
            if(!pdo_tableexists("bbfx_capitalpool_money_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_capitalpool_money_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                  `title` varchar(255) DEFAULT NULL COMMENT '标题',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动金额',
                  `before` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动前',
                  `after` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动后',
                  `extend` varchar(255) DEFAULT NULL,
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $capitalpool_money_logFields = Db::name("bbfx_capitalpool_money_log")->getTableFields();
            }
            else{
                $capitalpool_money_logFields = Db::name("bbfx_capitalpool_money_log")->getTableFields();
            } 
            if(!pdo_tableexists("bbfx_paihangbang")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_paihangbang")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `ranking_method` int(10) NOT NULL DEFAULT '1' COMMENT '排名方式:1=团队业绩,2=直推业绩',
                  `achievement_time` int(10) NOT NULL DEFAULT '1' COMMENT '业绩计算时间:1=本月,2=本季度,3=本年',
                  `reward_rate` int(10) NOT NULL DEFAULT '0' COMMENT '奖励比例（资金池金额）',
                  `reward_ranking` int(10) NOT NULL DEFAULT '0' COMMENT '奖励排名',
                  `reward_rule` text NULL COMMENT '奖励规则',
                  `bg_image` varchar(255) DEFAULT NULL COMMENT '背景图片',
                  `banner_image` varchar(255) DEFAULT NULL COMMENT 'banner图片',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $paihangbangFields = Db::name("bbfx_paihangbang")->getTableFields();
            }
            else{
                $paihangbangFields = Db::name("bbfx_paihangbang")->getTableFields();
            } 
            
            //v2.1.72
            if(!in_array('zfb_appid',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `zfb_appid` VARCHAR(100) NULL COMMENT '支付宝应用ID'"); 
            }
            if(!in_array('zfb_publickey_cert',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `zfb_publickey_cert` VARCHAR(255) NULL COMMENT '支付宝公钥证书'"); 
            }
            if(!in_array('zfb_app_cert',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `zfb_app_cert` VARCHAR(255) NULL COMMENT '应用证书'"); 
            }
            if(!in_array('zfb_root_cert',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `zfb_root_cert` VARCHAR(255) NULL COMMENT '支付宝根证书'"); 
            }
            if(!in_array('zfb_privateKey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `zfb_privateKey` TEXT NULL COMMENT '应用私钥'"); 
            }
            if(!in_array('is_super_maihuo',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_super_maihuo` int(10) NOT NULL DEFAULT '0' COMMENT '超级卖货模式订单:1=是,0=否'"); 
            }
            if(!pdo_tableexists("bbfx_super_maihuo")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_super_maihuo")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `daozhang_type` int(10) NOT NULL DEFAULT '0' COMMENT '份额到账类型:1=付款后到账,0=完成后到账',
                  `repurchase_goods` varchar(255) DEFAULT NULL COMMENT '复购商品',
                  `abonus_num` int(10) NOT NULL DEFAULT '1' COMMENT '分红次数',
                  `abonus_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每份金额',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $super_maihuoFields = Db::name("bbfx_super_maihuo")->getTableFields();
            }
            else{
                $super_maihuoFields = Db::name("bbfx_super_maihuo")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_super_maihuo_group")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_super_maihuo_group")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `num` int(10) NOT NULL DEFAULT '0' COMMENT '序号',
                  `group_id` int(10) NOT NULL DEFAULT '0' COMMENT '主分红组ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '分红用户ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '组长ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                  `total` int(10) NOT NULL DEFAULT '0' COMMENT '人数',
                  `stime` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
                  `etime` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待分红,1=已分红',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $super_maihuo_groupFields = Db::name("bbfx_super_maihuo_group")->getTableFields();
            }
            else{
                $super_maihuo_groupFields = Db::name("bbfx_super_maihuo_group")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_super_maihuo_group_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_super_maihuo_group_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '分红用户ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `group_id` int(10) NOT NULL DEFAULT '0' COMMENT '分组ID',
                  `money` decimal(10,0) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红金额',
                  `contribution_value` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值',
                  `num` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `utime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $super_maihuo_group_userFields = Db::name("bbfx_super_maihuo_group_user")->getTableFields();
            }
            else{
                $super_maihuo_group_userFields = Db::name("bbfx_super_maihuo_group_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_super_maihuo_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_super_maihuo_user")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                  `num` int(10) NOT NULL DEFAULT '0' COMMENT '分红次数',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                  `contribution_value` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值',
                  `info` text NULL COMMENT '信息',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已完成,0=进行中',
                  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $super_maihuo_userFields = Db::name("bbfx_super_maihuo_user")->getTableFields();
            }
            else{
                $super_maihuo_userFields = Db::name("bbfx_super_maihuo_user")->getTableFields();
                if(in_array('utime',$super_maihuo_userFields)){
                    Db::execute("DROP TABLE ".tablename("bbfx_super_maihuo_user"));
                    Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_super_maihuo_user")." (
                      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                      `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                      `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                      `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                      `num` int(10) NOT NULL DEFAULT '0' COMMENT '分红次数',
                      `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                      `contribution_value` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值',
                      `info` text NULL COMMENT '信息',
                      `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已完成,0=进行中',
                      `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
                      PRIMARY KEY (`id`)
                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                    $super_maihuo_userFields = Db::name("bbfx_super_maihuo_user")->getTableFields();
                }
            }
            
            //v2.1.73
            if(!in_array('pyramid_transfer',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `pyramid_transfer` INT(10) NOT NULL DEFAULT '0' COMMENT '三三复制转移:1=是,0=否'"); 
            }
            if(!pdo_tableexists("bbfx_pyramid")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pyramid")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `pingji_calculate` int(10) NOT NULL DEFAULT '0' COMMENT '平级奖计算:0=当前关系计算,1=原始关系计算',
                  `is_transfer` int(10) NOT NULL DEFAULT '0' COMMENT '跳出模式:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pyramidFields = Db::name("bbfx_pyramid")->getTableFields();
            }
            else{
                $pyramidFields = Db::name("bbfx_pyramid")->getTableFields();
            }
            
            //v2.1.74
            if(!in_array('settlement_score',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `settlement_score` INT(10) NOT NULL DEFAULT '0' COMMENT '结算积分奖励'"); 
            }
            if(!in_array('settlement_score_rate',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `settlement_score_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '结算积分比例'"); 
            }
            if(!in_array('freeze_commission',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `freeze_commission` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '冻结收益'"); 
            }
            if(!in_array('commission1_calculate',$pyramidFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pyramid")." ADD `commission1_calculate` INT(10) NOT NULL DEFAULT '0' COMMENT '直推奖计算:0=当前关系计算,1=原始关系计算'"); 
            }
            if(!in_array('sup_user_buyorder',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `sup_user_buyorder` INT(10) NOT NULL DEFAULT '0' COMMENT '有推荐人下单:1=开启,0=关闭'"); 
            }
            if(!in_array('is_ladder_abonus_pingji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_ladder_abonus_pingji` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯分红平级奖:1=开启,0=关闭'"); 
            }
            if(!in_array('ladder_abonus_pingji_rate',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `ladder_abonus_pingji_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '阶梯分红平级平级奖比例'"); 
            }
            
            //v2.1.75
            if(!in_array('abonus_score',$super_maihuoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_super_maihuo")." ADD `abonus_score` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红积分'"); 
            }
            if(!in_array('mode',$pyramidFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pyramid")." ADD `mode` INT(10) NOT NULL DEFAULT '0' COMMENT '模式:0=常规模式,1=大公排模式'"); 
            }
            
            //v2.1.76
            if(!in_array('sup_reward',$super_maihuoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_super_maihuo")." ADD `sup_reward` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '推荐奖励'"); 
            }
            if(!in_array('score_achievement',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `score_achievement` INT(10) NOT NULL DEFAULT '0' COMMENT '积分业绩:1=开启,0=关闭'"); 
            }
            if(!in_array('is_alipay',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_alipay` INT(10) NOT NULL DEFAULT '0' COMMENT '支付宝支付:1=开启,0=关闭'"); 
            }
            
            //v2.1.77
            if(!in_array('layer_upgrade',$sconnectionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sconnection")." ADD `layer_upgrade` INT(10) NOT NULL DEFAULT '0' COMMENT '按层升级:1=开启,0=关闭'"); 
            }
            
            //v2.1.78
            if(!in_array('discount_vip_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `discount_vip_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '会员折扣'"); 
            }
            if(!in_array('discount_coupon_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `discount_coupon_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '优惠券折扣'"); 
            }
            if(!in_array('discount_vip_price',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `discount_vip_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '会员折扣'"); 
            }
            if(!in_array('discount_coupon_price',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `discount_coupon_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '优惠券折扣'"); 
            }
            if(!in_array('alipay_trade_no',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `alipay_trade_no` varchar(255) DEFAULT NULL COMMENT '支付宝交易单号'"); 
            }
            if(!pdo_tableexists("bbfx_goods_stock_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_stock_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                  `sku_id` int(10) NOT NULL DEFAULT '0' COMMENT '规格ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '用户类型:0=管理员,1=用户',
                  `itype` int(10) NOT NULL DEFAULT '0' COMMENT '操作类型',
                  `item_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                  `stock` int(10) NOT NULL DEFAULT '0' COMMENT '变动库存',
                  `before` int(10) NOT NULL DEFAULT '0' COMMENT '变动前',
                  `after` int(10) NOT NULL DEFAULT '0' COMMENT '变动后',
                  `title` varchar(255) DEFAULT NULL COMMENT '标题',
                  `remarks` varchar(255) NOT NULL COMMENT '备注',
                  `info` text NULL COMMENT '数据',
                  `goods` text NULL COMMENT '商品信息',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_stock_logFields = Db::name("bbfx_goods_stock_log")->getTableFields();
            }
            else{
                $goods_stock_logFields = Db::name("bbfx_goods_stock_log")->getTableFields();
            }
            
            //v2.1.79
            if(!in_array('apply_upgrade_bg',$sconnectionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sconnection")." ADD `apply_upgrade_bg` VARCHAR(255) NULL COMMENT '申请晋升背景'");  
            }
            if(!in_array('wu_apply_user',$sconnectionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sconnection")." ADD `wu_apply_user` VARCHAR(255) NULL COMMENT '无审核用户时指定审核用户'");  
            }
            
            //v2.1.79
            if(!in_array('consume_money',$txabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_txabonus")." ADD `consume_money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '消费金额'");  
            }
            
            //v2.1.80
            if(!in_array('reward_source',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `reward_source` INT(10) NOT NULL DEFAULT '0' COMMENT '奖励来源:0=奖金池,1=购买商品'");  
            }
            if(!in_array('reward_buy_goods',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `reward_buy_goods` VARCHAR(500) NULL COMMENT '奖励购买商品'");  
            }
            if(!in_array('reward_buy_count',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `reward_buy_count` INT(10) NOT NULL DEFAULT '0' COMMENT '每多少单分红'");  
            }
            if(!in_array('reward_buy_ok',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `reward_buy_ok` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '已购单数'");  
            }
            if(!in_array('reward_buy_money',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `reward_buy_money` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '购买商品累计金额'");  
            }
            if(!pdo_tableexists("bbfx_sverify")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sverify")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `query_success_image` varchar(255) DEFAULT NULL COMMENT '查询成功图片',
                  `query_fail_image` varchar(255) DEFAULT NULL COMMENT '查询失败图片',
                  `wxapp_qrcode` int(10) NOT NULL DEFAULT '0' COMMENT '小程序二维码:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sverifyFields = Db::name("bbfx_sverify")->getTableFields();
            }
            else{
                $sverifyFields = Db::name("bbfx_sverify")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sverify_product")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sverify_product")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `code` varchar(255) DEFAULT NULL COMMENT '防伪code',
                  `name` varchar(100) DEFAULT NULL COMMENT '产品名称',
                  `image` varchar(255) DEFAULT NULL COMMENT '产品图片',
                  `images` varchar(2000) DEFAULT NULL COMMENT 'banner图片',
                  `number_prefix` varchar(100) DEFAULT NULL COMMENT '前缀',
                  `number_digits` int(10) NOT NULL DEFAULT '6' COMMENT '编号位数',
                  `query_first_tips` varchar(255) DEFAULT NULL COMMENT '查询正品首次提示',
                  `query_success_tips` varchar(255) DEFAULT NULL COMMENT '查询正品成功提示',
                  `query_fail_tips` varchar(255) DEFAULT NULL COMMENT '查询正品失败提示',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                  `extend` text NULL COMMENT '扩展内容',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sverify_productFields = Db::name("bbfx_sverify_product")->getTableFields();
            }
            else{
                $sverify_productFields = Db::name("bbfx_sverify_product")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sverify_product_code")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sverify_product_code")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `product_id` int(10) NOT NULL DEFAULT '0' COMMENT '产品ID',
                  `code` varchar(255) DEFAULT NULL COMMENT 'code',
                  `query_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '查询次数',
                  `qrcode` varchar(255) DEFAULT NULL COMMENT 'H5二维码',
                  `wxapp_qrcode` varchar(255) DEFAULT NULL COMMENT '小程序二维码',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sverify_product_codeFields = Db::name("bbfx_sverify_product_code")->getTableFields();
            }
            else{
                $sverify_product_codeFields = Db::name("bbfx_sverify_product_code")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sverify_product_query_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sverify_product_query_log")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `product_id` int(10) NOT NULL DEFAULT '0' COMMENT '产品ID',
                  `code` varchar(255) DEFAULT NULL COMMENT '防伪码',
                  `ip` varchar(255) NOT NULL COMMENT '查询IP',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sverify_product_query_logFields = Db::name("bbfx_sverify_product_query_log")->getTableFields();
            }
            else{
                $sverify_product_query_logFields = Db::name("bbfx_sverify_product_query_log")->getTableFields();
            }
            
            //v2.1.81
            if(!in_array('cost_price',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `cost_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '成本价'");  
            }
            if(!in_array('cost_price',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `cost_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '成本价'");  
            }
            if(!in_array('cost_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `cost_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '成本价'");  
            }
            if(!in_array('cost_price',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `cost_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '成本价'");  
            }
            
            //v2.1.82
            if(!in_array('wap_AppId',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_AppId` VARCHAR(100) NULL COMMENT '微信H5支付AppId'");  
            }
            if(!in_array('wap_AppSecret',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_AppSecret` VARCHAR(255) NULL COMMENT '微信H5支付AppSecret'");  
            }
            if(!in_array('wap_mch_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_mch_id` VARCHAR(100) NULL COMMENT '微信H5支付商户号'");  
            }
            if(!in_array('wap_paykey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_paykey` VARCHAR(255) NULL COMMENT '微信H5支付秘钥'");  
            }
            if(!in_array('wap_cert',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_cert` VARCHAR(255) NULL COMMENT '微信H5支付证书'");  
            }
            if(!in_array('wap_certkey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wap_certkey` VARCHAR(100) NULL COMMENT '微信H5支付证书秘钥'");  
            }
            if(!in_array('new_order_id',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `new_order_id` INT(10) NOT NULL DEFAULT '0' COMMENT '新订单ID'");  
            }
            if(!pdo_tableexists("bbfx_mode")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_mode")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `name` varchar(100) DEFAULT NULL COMMENT '模式名称',
                  `sdesc` text NULL COMMENT '模式描述',
                  `content` text NULL COMMENT '模式内容',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $modeFields = Db::name("bbfx_mode")->getTableFields();
            }
            else{
                $modeFields = Db::name("bbfx_mode")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_diypage_template")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_diypage_template")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '模板',
                  `image` varchar(255) DEFAULT NULL COMMENT '图片',
                  `data` longtext NULL COMMENT '数据',
                  `type` int(10) NOT NULL DEFAULT '1' COMMENT '页面类型:1=自定义页面,2=个人中心',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $diypage_templateFields = Db::name("bbfx_diypage_template")->getTableFields();
            }
            else{
                $diypage_templateFields = Db::name("bbfx_diypage_template")->getTableFields();
            }
            if(!in_array('bg_color',$super_maihuoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_super_maihuo")." ADD `bg_color` VARCHAR(100) NULL COMMENT '背景色'");  
            }
            if(!pdo_tableexists("bbfx_laddermanage")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_laddermanage")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `show_month_income` int(10) NOT NULL DEFAULT '0' COMMENT '显示本月收益:1=开启,0=关闭',
                  `manage_remove_daqu` int(10) NOT NULL DEFAULT '0' COMMENT '去除大区业绩:1=开启,0=关闭',
                  `manage_jisuan` int(10) NOT NULL DEFAULT '1' COMMENT '计算方式:1=逐级减,2=直推减',
                  `rule` text NULL COMMENT '管理奖规则',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $laddermanageFields = Db::name("bbfx_laddermanage")->getTableFields();
            }
            else{
                $laddermanageFields = Db::name("bbfx_laddermanage")->getTableFields();
            }
            
            //v2.1.83
            if(!in_array('is_merch_transfer_new',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_merch_transfer_new` INT(10) NOT NULL DEFAULT '0' COMMENT '商家转账到零钱新版本:1=开启,0=关闭'");  
            }
            if(!in_array('package_info',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `package_info` TEXT NULL");  
            }
            if(!in_array('is_confirm',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `is_confirm` INT(10) NOT NULL DEFAULT '-1' COMMENT '确认收款:-1=未同意,0=待确认,1=已确认'");  
            }
            if(!in_array('confirmtime',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `confirmtime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '确认时间'");  
            }
            if(!pdo_tableexists("bbfx_yajin")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_yajin")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  `yajin_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '押金金额',
                  `refund` text NULL COMMENT '退还配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $yajinFields = Db::name("bbfx_yajin")->getTableFields();
            }
            else{
                $yajinFields = Db::name("bbfx_yajin")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_yajin_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_yajin_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=分销升级押金',
                  `order_no` varchar(100) DEFAULT NULL COMMENT '订单号',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '押金金额',
                  `refund_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '退还金额',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待支付,1=待退还,2=已退还',
                  `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型',
                  `paytime` bigint(16) NOT NULL DEFAULT '0' COMMENT '支付时间',
                  `refundtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '退还时间',
                  `extend` text NULL COMMENT '扩展参数',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $yajin_recordFields = Db::name("bbfx_yajin_record")->getTableFields();
            }
            else{
                $yajin_recordFields = Db::name("bbfx_yajin_record")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_yajin_refund_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_yajin_refund_record")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                  `refund_no` varchar(100) NOT NULL COMMENT '退还单号',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '押金记录ID',
                  `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '押金金额',
                  `refund_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '退还金额',
                  `type` int(10) NOT NULL DEFAULT '0' COMMENT '提现方式:1=余额,2=微信零钱,3=支付宝,4=银行卡,5=收款码',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `realname` varchar(100) DEFAULT NULL COMMENT '姓名',
                  `alipay` varchar(100) DEFAULT NULL COMMENT '支付宝账号',
                  `bankname` varchar(100) DEFAULT NULL COMMENT '银行名称',
                  `bankcard` varchar(100) DEFAULT NULL COMMENT '银行卡号',
                  `skqrcode` varchar(255) DEFAULT NULL COMMENT '收款码',
                  `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待审核,1=通过,2=驳回',
                  `shtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '审核时间',
                  `reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
                  `out_batch_no` varchar(100) DEFAULT NULL,
                  `batch_id` varchar(100) DEFAULT NULL,
                  `package_info` text,
                  `is_confirm` int(10) NOT NULL DEFAULT '-1' COMMENT '确认收款:-1=未同意,0=待确认,1=已确认',
                  `confirmtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '确认时间',
                  `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $yajin_refund_recordFields = Db::name("bbfx_yajin_refund_record")->getTableFields();
            }
            else{
                $yajin_refund_recordFields = Db::name("bbfx_yajin_refund_record")->getTableFields();
            }
            
            //v2.1.84
            if(!in_array('bg_color',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `bg_color` VARCHAR(100) NOT NULL DEFAULT '#F1F8F4' COMMENT '背景色'");  
            }
            if(!in_array('top_bg',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `top_bg` VARCHAR(255) NOT NULL DEFAULT '/assets/images/newui/mobile/page_bg.png' COMMENT '顶部背景'");  
            }
            
            //v2.1.85
            if(!in_array('is_electronic_waybill_print',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_electronic_waybill_print` INT(10) NOT NULL DEFAULT '0' COMMENT '电子面单订单:1=是,0=否'");  
            }
            if($bbfx['sversion'] <= 2185){
                Db::name("bbfx_express")->where(['id'=>['>',0]])->delete();
                Db::execute("INSERT INTO ".tablename("bbfx_express")." (`id`, `name`, `express`, `status`, `sort`, `code`, `coding`) VALUES
                (1, '顺丰速运', 'shunfeng', 1, 0, '', 'SF'),
                (2, '申通快递', 'shentong', 1, 0, '', 'STO'),
                (3, '韵达速递', 'yunda', 1, 0, '', 'YD'),
                (5, '圆通速递', 'yuantong', 1, 0, '', 'YTO'),
                (6, '中通快递', 'zhongtong', 1, 0, '', 'ZTO'),
                (8, '百世快递', 'baishikuaidi', 1, 0, '', 'HTKY'),
                (98, '极兔速递', 'jitukuaidi', 1, 0, '', 'JTSD'),
                (20, '德邦快递', 'debangwuliu', 1, 0, '', 'DBL'),
                (78, '邮政快递包裹', 'youzhengguonei', 1, 0, '', 'YZPY'),
                (92, '京东快递', 'jd', 1, 0, '', 'JD');");
            }
            
            //v2.1.86
            if(!in_array('become_cz_balance',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `become_cz_balance` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '分销商条件充值余额'");  
            }
            if(!in_array('level_jicha',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `level_jicha` INT(10) NOT NULL DEFAULT '0' COMMENT '层级级差:1=开启,0=关闭'");  
            }
            if(!in_array('chuhuo_deduct_pingji',$cloud_warehouseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cloud_warehouse")." ADD `chuhuo_deduct_pingji` INT(10) NOT NULL DEFAULT '0' COMMENT '出货奖扣除平级奖:1=开启,0=关闭'");  
            }
            //v2.1.87
            if(!in_array('hexiao_total',$order_hexiao_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_hexiao_record")." ADD `hexiao_total` INT(10) NOT NULL DEFAULT '0' COMMENT '待核销次数'");  
            }
            if(!in_array('hexiao_num',$order_hexiao_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_hexiao_record")." ADD `hexiao_num` INT(10) NOT NULL DEFAULT '0' COMMENT '待核销次数'");  
            }
			//v2.1.88
            if(!pdo_tableexists("bbfx_smaterial")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_smaterial")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $smaterialFields = Db::name("bbfx_smaterial")->getTableFields();
            }
            else{
                $smaterialFields = Db::name("bbfx_smaterial")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_smaterial_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_smaterial_category")." (
                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                  `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                  `pid` int(10) NOT NULL DEFAULT '0' COMMENT '上级ID',
                  `title` varchar(100) DEFAULT NULL COMMENT '标题',
                  `image` varchar(255) DEFAULT NULL COMMENT '图片',
                  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $smaterial_categoryFields = Db::name("bbfx_smaterial_category")->getTableFields();
            }
            else{
                $smaterial_categoryFields = Db::name("bbfx_smaterial_category")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_smaterial_item")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_smaterial_item")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                `title` varchar(255) DEFAULT NULL COMMENT '标题',
                `content` text NULL COMMENT '分享内容',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=图片,1=视频',
                `image` text NULL COMMENT '分享图片',
                `video` varchar(255) DEFAULT NULL COMMENT '分享视频',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $smaterial_itemFields = Db::name("bbfx_smaterial_item")->getTableFields();
            }
            else{
                $smaterial_itemFields = Db::name("bbfx_smaterial_item")->getTableFields();
            }
            //v2.1.89
            if(in_array('signingtime',$contract_recordFields) && $bbfx['sversion'] <= 2189){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_contract_record")." CHANGE `signingtime` `signingtime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '签约时间'");  
            }
            if(in_array('score',$scoreshop_order_goodsFields) && $bbfx['sversion'] <= 2189){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order_goods")."  CHANGE `score` `score` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商品积分'");  
            }

            //v2.1.90
            if(!in_array('author',$news_articleFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_news_article")." ADD `author` VARCHAR(100) NULL COMMENT '作者'");  
            }
            if(!in_array('author_avatar',$news_articleFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_news_article")." ADD `author_avatar` VARCHAR(255) NULL COMMENT '作者头像'");  
            }
            if(in_array('deposit_paytype',$deposit_releaseFields) && $bbfx['sversion'] <= 2190){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_deposit_release")." CHANGE `deposit_paytype` `deposit_paytype` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '预存款支付方式';");
            }

            //v2.1.92
            if(!in_array('return_total_score',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `return_total_score` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '返还总额(积分)'");  
            }
            if(!in_array('deduct_direction',$npingjiFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_npingji")." ADD `deduct_direction` INT(10) NOT NULL DEFAULT '0' COMMENT '扣除方向:0=向下扣除,1=向上扣除'");  
            }
            if(!in_array('deduct_item',$npingjiFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_npingji")." ADD `deduct_item` VARCHAR(255) NOT NULL DEFAULT '1' COMMENT '扣除奖项'");  
            }
            if($bbfx['sversion'] <= 2191){
                Db::execute("ALTER TABLE ".tablename("bbfx_return_item")." DROP INDEX `order_id`, ADD UNIQUE `order_id` (`order_id`, `order_goods_id`, `type`) USING BTREE;"); 
            }
            if(!in_array('parameter',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `parameter` TEXT NULL COMMENT '商品参数'");  
            }
            if(!in_array('ntime',$return_itemFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_item")." ADD `ntime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '下次返还时间'");  
            }

            //v2.1.94
            if(in_array('goods_info',$orderFields) && $bbfx['sversion'] <= 2193){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." CHANGE `goods_info` `goods_info` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品信息'");  
            }
            if(in_array('banner_image',$paihangbangFields) && $bbfx['sversion'] <= 2193){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." CHANGE `banner_image` `banner_image` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'banner图片'");  
            }

            //v2.1.95
            if(!in_array('is_becomedue',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_becomedue` INT(10) NOT NULL DEFAULT '0' COMMENT '分销商到期:1=开启,0=关闭'");  
            }
            if(!in_array('becomedue_time',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `becomedue_time` INT(10) NOT NULL DEFAULT '0' COMMENT '分销商到期时间（月）'");  
            } 
            if(!in_array('fenxiao_becomedue_time',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `fenxiao_becomedue_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '分销到期时间'");  
            }

            //v2.1.96
            if(!in_array('is_crossline',$transfer_accountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account")." ADD `is_crossline` INT(10) NOT NULL DEFAULT '1' COMMENT '跨线转移:1=开启,0=关闭'");  
            }

            //v2.1.97
            if(!in_array('is_mergelevel',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_mergelevel` INT(10) NOT NULL DEFAULT '0' COMMENT '合并等级:1=开启,0=关闭';");  
            }
            if(!pdo_tableexists("bbfx_qwen")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_qwen")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `apikey` varchar(100) DEFAULT NULL COMMENT 'API KEY',
                `model` varchar(100) DEFAULT 'qwen-max' COMMENT '模型',
                `levels` varchar(255) DEFAULT NULL COMMENT '使用等级',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $qwenFields = Db::name("bbfx_qwen")->getTableFields();
            }
            else{
                $qwenFields = Db::name("bbfx_qwen")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_qwen_chat")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_qwen_chat")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `ckey` varchar(100) DEFAULT NULL COMMENT '对话KEY',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '回答ID',
                `content` text NULL COMMENT '对话内容',
                `role` varchar(100) NOT NULL DEFAULT 'user' COMMENT '类型:user=用户,system=AI',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已完成,0=未完成',
                `ctime` bigint(16) NOT NULL DEFAULT '0' COMMENT '完成时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $qwen_chatFields = Db::name("bbfx_qwen_chat")->getTableFields();
            }
            else{
                $qwen_chatFields = Db::name("bbfx_qwen_chat")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_shuziren")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_shuziren")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `apikey` varchar(100) DEFAULT NULL COMMENT 'API KEY',
                `model` varchar(100) DEFAULT 'videoretalk' COMMENT '声动人像VideoRetalk模型',
                `audio_model` varchar(100) NOT NULL DEFAULT 'qwen-tts' COMMENT '声音复刻模型',
                `levels` varchar(255) DEFAULT NULL COMMENT '使用等级',
                `btn_bg` TEXT NULL COMMENT '按钮背景',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $shuzirenFields = Db::name("bbfx_shuziren")->getTableFields();
            }
            else{
                $shuzirenFields = Db::name("bbfx_shuziren")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_shuziren_video")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_shuziren_video")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `voice_id` int(10) NOT NULL DEFAULT '0' COMMENT '音色ID',
                `video_id` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `text` text NULL COMMENT '文字内容',
                `original_video` varchar(255) DEFAULT NULL COMMENT '原视频',
                `voice_url` varchar(255) DEFAULT NULL COMMENT '语音连接',
                `url` varchar(255) DEFAULT NULL COMMENT '视频链接',
                `task_id` varchar(255) DEFAULT NULL COMMENT '作业ID',
                `status` varchar(100) DEFAULT NULL COMMENT '状态',
                `completetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '完成时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $shuziren_videoFields = Db::name("bbfx_shuziren_video")->getTableFields();
            }
            else{
                $shuziren_videoFields = Db::name("bbfx_shuziren_video")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_shuziren_video_tpl")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_shuziren_video_tpl")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `title` varchar(100) DEFAULT NULL COMMENT '视频标题',
                `url` varchar(255) DEFAULT NULL COMMENT '视频链接',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $shuziren_video_tplFields = Db::name("bbfx_shuziren_video_tpl")->getTableFields();
            }
            else{
                $shuziren_video_tplFields = Db::name("bbfx_shuziren_video_tpl")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_shuziren_voice")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_shuziren_voice")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `url` varchar(255) DEFAULT NULL COMMENT '声音链接',
                `voice_id` varchar(100) DEFAULT NULL COMMENT '音色ID',
                `apikey` varchar(100) DEFAULT NULL COMMENT '所属KEY',
                `status` varchar(100) NOT NULL COMMENT '状态',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $shuziren_voiceFields = Db::name("bbfx_shuziren_voice")->getTableFields();
            }
            else{
                $shuziren_voiceFields = Db::name("bbfx_shuziren_voice")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_import_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_import_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=订单物流单号导入',
                `admin_id` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID',
                `content` text NULL COMMENT '日志内容',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $import_logFields = Db::name("bbfx_import_log")->getTableFields();
            }
            else{
                $import_logFields = Db::name("bbfx_import_log")->getTableFields();
            }

            //v2.1.98
            if(!in_array('extend',$money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_money_log")." ADD `extend` TEXT NULL COMMENT '附加数据'");  
            }
            if(!in_array('contribution_value',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `contribution_value` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献值'");  
            }
            if(!in_array('dialogue_title',$qwenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_qwen")." ADD `dialogue_title` VARCHAR(100) NULL COMMENT '对话标题'");  
            }
            if(!in_array('dialogue_icon',$qwenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_qwen")." ADD `dialogue_icon` VARCHAR(255) NULL COMMENT '对话图标'");  
            }
            if(!in_array('dialogue_tips',$qwenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_qwen")." ADD  `dialogue_tips` VARCHAR(255) NULL COMMENT '对话提示'");  
            }
            if(!pdo_tableexists("bbfx_contribution")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contribution")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `source` text NULL COMMENT '贡献值来源',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contributionFields = Db::name("bbfx_contribution")->getTableFields();
            }
            else{
                $contributionFields = Db::name("bbfx_contribution")->getTableFields();
            }
            if(!in_array('gift_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `gift_status` INT(10) NOT NULL DEFAULT '-1' COMMENT '礼品状态:-1=不是礼品,0=待领取,1=已领取'");  
            }
            if(!in_array('gift_user_id',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `gift_user_id` INT(10) NOT NULL DEFAULT '0' COMMENT '礼品领取用户'");  
            }
            if(!in_array('gift_receive_time',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `gift_receive_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '礼品领取时间'");  
            }
            if(!pdo_tableexists("bbfx_gift")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_gift")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $giftFields = Db::name("bbfx_gift")->getTableFields();
            }
            else{
                $giftFields = Db::name("bbfx_gift")->getTableFields();
            }

            //v2.1.99
            if(!in_array('type',$couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon")." ADD `type` INT(10) NOT NULL DEFAULT '0' COMMENT '优惠券类型:0=一次性,1=持续性'");  
            }
            if(!in_array('type',$user_couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_coupon")." ADD `type` INT(10) NOT NULL DEFAULT '0' COMMENT '优惠券类型:0=一次性,1=持续性'");  
            }
            if(!in_array('residue_money',$user_couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_coupon")." ADD `residue_money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '剩余金额'");  
            }
            if(!in_array('merch_transfer_scene',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `merch_transfer_scene` VARCHAR(20) NOT NULL DEFAULT '1005' COMMENT '微信商家转账场景'");  
            }

            //v2.2.2508201
            if(!in_array('is_hexiao_quantity',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_hexiao_quantity` INT(10) NOT NULL DEFAULT '0' COMMENT '核销数量:1=开启,0=关闭'");  
            }
            if(!in_array('is_hexiao_quantity',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_hexiao_quantity` INT(10) NOT NULL DEFAULT '0' COMMENT '核销数量:1=开启,0=关闭'");  
            }
            if(!in_array('hxcode_id',$order_hexiao_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_hexiao_record")." ADD `hxcode_id` INT(10) NOT NULL DEFAULT '0' COMMENT '核销码ID'");  
            }
            if(!in_array('buy_btn',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `buy_btn` VARCHAR(10) NULL COMMENT '购买按钮'");  
            }
            if(!in_array('username',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `username` VARCHAR(100) NULL COMMENT '用户名'");  
            }
            if(empty(showTableIndex("bbfx_user","uniacid"))){
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD UNIQUE `uniacid` (`uniacid`, `username`) USING BTREE;"); 
            }
            if(in_array('mobile',$order_refundFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_refund")." CHANGE `mobile` `mobile` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '联系人'");  
            }
            if(!in_array('fahuo_content',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `fahuo_content` TEXT NULL COMMENT '发货内容'");  
            }
            if(!in_array('platform',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `platform` VARCHAR(100) NULL COMMENT '下单平台'");  
            }
            
            //v2.2.2508281
            if(!in_array('commission_calculation_mode',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `commission_calculation_mode` INT(10) NOT NULL DEFAULT '0' COMMENT '佣金计算模式:0=按商品计算,1=按订单计算'");  
            }
            if(!in_array('wxapp_publickeyId',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_publickeyId` VARCHAR(255) NULL COMMENT '微信支付公钥ID'");  
            }
            if(!in_array('publickeyId',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `publickeyId` VARCHAR(255) NULL COMMENT '微信支付公钥ID'");  
            }

            //v2.2.2509051
            if(!in_array('wxapp_upload_privateKey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_upload_privateKey` VARCHAR(255) NULL COMMENT '小程序代码上传密钥'");  
            }
            if($bbfx['sversion'] <= 222508281 && !in_array('sh_status',$goodsFields)){ 
                Db::name("bbfx_goods")->where(['mid'=>0])->update(['sh_status'=>1]); 
            }
            if($bbfx['sversion'] <= 222508281){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." CHANGE `id` `id` INT(10) UNSIGNED NOT NULL COMMENT 'ID'");  
            }
            if(!in_array('balance',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `balance` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '抵扣余额';");
            }
            if(!pdo_tableexists("bbfx_order_goods_hxcode")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_order_goods_hxcode")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '订单商品ID',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                `hexiao_code` varchar(100) DEFAULT NULL COMMENT '核销码',
                `hexiao_qrcode` varchar(255) DEFAULT NULL COMMENT '核销二维码',
                `hexiao_wxacode` varchar(255) DEFAULT NULL COMMENT '核销小程序码',
                `hexiao_total` int(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '核销总次数',
                `hexiao_num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '核销次数',
                `hexiao_uid` int(10) NOT NULL DEFAULT '0' COMMENT '核销用户',
                `hexiao_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '核销时间',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '核销状态:1=已核销,0=待核销',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $order_goods_hxcodeFields = Db::name("bbfx_order_goods_hxcode")->getTableFields();
            }
            else{
                $order_goods_hxcodeFields = Db::name("bbfx_order_goods_hxcode")->getTableFields();
            }

            //v2.2.2509181
            if(!in_array('uniacid',$expressFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_express")." ADD `uniacid` INT(10) NOT NULL DEFAULT '0' COMMENT '平台ID';");
            }
            if(!in_array('paytype',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `paytype` INT(10) NOT NULL DEFAULT '1' COMMENT '支付类型:1=微信支付,2=银行卡,3=支付宝';");
            }

            //v2.2.2509221
            if(!in_array('cash_pay_shenhe',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `cash_pay_shenhe` INT(10) NOT NULL DEFAULT '-1' COMMENT '线下支付:-1=否,0=待审核,1=已通过,2=已驳回';");
            }
            if(!in_array('is_cashpay',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_cashpay` INT(10) NOT NULL DEFAULT '0' COMMENT '线下支付:1=开启,0=关闭';");
            }
            if(!in_array('gzh_template_msg',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `gzh_template_msg` TEXT NULL COMMENT '公众号模板消息';");
            }

            //v2.2.2510011
            if(!in_array('uid_prefix',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `uid_prefix` VARCHAR(100) NULL COMMENT '用户ID前缀';");
            }
            if(!in_array('wxapp_openid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `wxapp_openid` VARCHAR(100) NULL COMMENT '小程序openid';");
            }
            if(!in_array('gzh_openid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `gzh_openid` VARCHAR(100) NULL COMMENT '公众号openid';");
            }
            if(!in_array('createtime',$shuziren_voiceFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren_voice")." ADD `createtime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '创建时间';");
            }
            if(!in_array('score_convert',$contributionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_contribution")." ADD `score_convert` INT(10) NOT NULL DEFAULT '0' COMMENT '积分转换:1=开启,0=关闭';");
            }
            if(!in_array('score_convert_rate',$contributionFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_contribution")." ADD `score_convert_rate` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '积分转换比例';");
            }
            if(!in_array('contribution_value_total',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `contribution_value_total` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '累计贡献值'");  
                \app\common\model\bbfxshop\Contribution::syncContributionValueTotal();
            }
            if(!in_array('zt_buy_goods',$txabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_txabonus")." ADD `zt_buy_goods` VARCHAR(255) NULL COMMENT '直推购买商品';");
            }
            if(!in_array('dianzan_num',$short_video_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_short_video_list")." ADD `dianzan_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '点赞数量';");
            }
            if(!in_array('chat_uuid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `chat_uuid` VARCHAR(100) NULL COMMENT '聊天ID';");
            }
            if(!pdo_tableexists("bbfx_short_video_dianzan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_short_video_dianzan")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '视频ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $short_video_dianzanFields = Db::name("bbfx_short_video_dianzan")->getTableFields();
            }
            else{
                $short_video_dianzanFields = Db::name("bbfx_short_video_dianzan")->getTableFields();
            }

            //v2.2.2510101
            if(!in_array('is_abonus_out_amount',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_abonus_out_amount` INT(10) NOT NULL DEFAULT '0' COMMENT '分红出局金额:1=开启,0=关闭';");
            }
            if(!in_array('abonus_out_amount',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `abonus_out_amount` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红出局金额';");
            }
            if(!pdo_tableexists("bbfx_user_wxapp_subscribe")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_wxapp_subscribe")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `tid` varchar(100) DEFAULT NULL COMMENT '模板ID',
                `tid_name` varchar(100) DEFAULT NULL COMMENT '模板名称',
                `num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '消息次数',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_wxapp_subscribeFields = Db::name("bbfx_user_wxapp_subscribe")->getTableFields();
            }
            else{
                $user_wxapp_subscribeFields = Db::name("bbfx_user_wxapp_subscribe")->getTableFields();
            }
            
            //v2.2.2510221
            if(!in_array('management_jiesuan_day',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `management_jiesuan_day` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '管理奖结算日';");
            }
            if(!in_array('sup_uid_show',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `sup_uid_show` INT(10) NOT NULL DEFAULT '0' COMMENT '上级ID显示:1=是,0=否';");
            }
            if(!in_array('sk_balance',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `sk_balance` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '收款码余额';");
            }
            if(!in_array('repurchase_jiandan_transfer',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `repurchase_jiandan_transfer` INT(10) NOT NULL DEFAULT '0' COMMENT '复购见单转移:1=是,0=否'");
            }
            if(!in_array('hexiao_info_required',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `hexiao_info_required` INT(10) NOT NULL DEFAULT '0' COMMENT '核销信息必填:1=开启,0=关闭';");
            }
            if(!in_array('telephone',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `telephone` VARCHAR(100) NULL COMMENT '电话';");
            }
            if(!in_array('transfer_mode_type',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `transfer_mode_type` INT(10) NOT NULL DEFAULT '0' COMMENT '2+1模式类型:0=普通升级,2=自由升级';");
            }
            if(!in_array('is_gzh_show',$apopupFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_apopup")." ADD `is_gzh_show` INT(10) NOT NULL DEFAULT '0' COMMENT '公众号网页展示:1=是,0=否';");
            }
            if(!pdo_tableexists("bbfx_chat")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chat")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `port` int(10) NOT NULL DEFAULT '2000' COMMENT '端口',
                `ssl_cert` varchar(255) DEFAULT NULL COMMENT 'SSL证书文件',
                `ssl_certkey` varchar(255) DEFAULT NULL COMMENT 'SSL私钥文件',
                `tip` varchar(500) DEFAULT NULL COMMENT '聊天提示',
                `kefu_uid` varchar(500) DEFAULT NULL COMMENT '客服ID',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chaFields = Db::name("bbfx_chat")->getTableFields();
            }
            else{
                $chaFields = Db::name("bbfx_chat")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_chat_dialogue")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chat_dialogue")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `rid` varchar(100) DEFAULT NULL COMMENT '对话ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=朋友聊天,1=群聊天',
                `from_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '发起用户ID',
                `to_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '接收用户ID',
                `name` varchar(255) DEFAULT NULL COMMENT '会话名称',
                `from_user_status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=显示,0=隐藏',
                `to_user_status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=显示,0=隐藏',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chat_dialogueFields = Db::name("bbfx_chat_dialogue")->getTableFields();
            }
            else{
                $chat_dialogueFields = Db::name("bbfx_chat_dialogue")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_chat_friend")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chat_friend")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `friend_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '好友用户ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待同意,1=同意,2=拒绝',
                `user_del` int(10) NOT NULL DEFAULT '0' COMMENT '删除:1=是,0=否',
                `friend_user_del` int(10) NOT NULL DEFAULT '0' COMMENT '删除:1=是,0=否',
                `shtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '审核时间',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chat_friendFields = Db::name("bbfx_chat_friend")->getTableFields();
            }
            else{
                $chat_friendFields = Db::name("bbfx_chat_friend")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_chat_list")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chat_list")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `from_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '发送用户ID',
                `to_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '接收用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '会话ID',
                `type` int(10) NOT NULL DEFAULT '1' COMMENT '类型:1=文字,2=图片,3=视频,4=语音',
                `content` varchar(1000) DEFAULT NULL COMMENT '消息内容',
                `is_read` int(10) NOT NULL DEFAULT '0' COMMENT '已读:1=是,0=否',
                `readtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '已读时间',
                `from_user` varchar(1000) DEFAULT NULL COMMENT '发送用户信息',
                `to_user` varchar(1000) DEFAULT NULL COMMENT '接收用户信息',
                `is_revoke` int(10) NOT NULL DEFAULT '0' COMMENT '撤回:1=是,0=否',
                `revoketime` bigint(16) NOT NULL DEFAULT '0' COMMENT '撤回时间',
                `from_user_del` int(10) NOT NULL DEFAULT '0' COMMENT '发送用户删除:1=是,0=否',
                `to_user_del` int(10) NOT NULL DEFAULT '0' COMMENT '接收用户删除:1=是,0=否',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chat_listFields = Db::name("bbfx_chat_list")->getTableFields();
            }
            else{
                $chat_listFields = Db::name("bbfx_chat_list")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_chat_read")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_chat_read")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `chat_id` int(10) NOT NULL DEFAULT '0' COMMENT '消息ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '对话ID',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $chat_readFields = Db::name("bbfx_chat_read")->getTableFields();
            }
            else{
                $chat_readFields = Db::name("bbfx_chat_read")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_activity")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_activity")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `is_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '活动审核:1=开启,0=关闭',
                `edit_shenhe` int(10) NOT NULL DEFAULT '0' COMMENT '活动编辑审核:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $activityFields = Db::name("bbfx_activity")->getTableFields();
            }
            else{
                $activityFields = Db::name("bbfx_activity")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_activity_list")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_activity_list")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `title` varchar(100) DEFAULT NULL COMMENT '活动标题',
                `baoming_fee` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '报名费',
                `poster_image` varchar(255) DEFAULT NULL COMMENT '海报图片',
                `slide_images` text NULL COMMENT '轮播图',
                `slide_videos` text NULL COMMENT '轮播视频',
                `advert_image` varchar(255) DEFAULT NULL COMMENT '广告图',
                `starttime` bigint(16) NOT NULL DEFAULT '0' COMMENT '开始时间',
                `endtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '结束时间',
                `bm_stime` bigint(16) NOT NULL DEFAULT '0' COMMENT '报名开始时间',
                `bm_etime` bigint(16) NOT NULL DEFAULT '0' COMMENT '报名结束时间',
                `baoming_total` int(10) NOT NULL DEFAULT '0' COMMENT '报名人数',
                `virtual_baoming` int(10) NOT NULL DEFAULT '0' COMMENT '虚拟报名人数',
                `detail_images` text NULL COMMENT '详情图片',
                `mobile` varchar(100) DEFAULT NULL COMMENT '联系电话',
                `music` varchar(255) DEFAULT NULL COMMENT '音乐',
                `address` varchar(255) DEFAULT NULL COMMENT '活动地址',
                `detail_address` varchar(255) DEFAULT NULL COMMENT '详细地址',
                `lat` double NOT NULL DEFAULT '0' COMMENT '纬度',
                `lng` double NOT NULL DEFAULT '0' COMMENT '经度',
                `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=启用,0=禁用',
                `sh_status` int(10) NOT NULL DEFAULT '1' COMMENT '审核状态:0=待审核,1=通过,2=驳回',
                `sh_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '审核时间',
                `browse` int(10) NOT NULL DEFAULT '0' COMMENT '浏览人数',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $activity_listFields = Db::name("bbfx_activity_list")->getTableFields();
            }
            else{
                $activity_listFields = Db::name("bbfx_activity_list")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_activity_baoming")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_activity_baoming")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `activity_id` int(10) NOT NULL DEFAULT '0' COMMENT '活动ID',
                `order_no` varchar(100) DEFAULT NULL COMMENT '订单号',
                `balance` decimal(12,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '抵扣余额',
                `baoming_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '报名费',
                `realname` varchar(100) DEFAULT NULL COMMENT '姓名',
                `mobile` varchar(100) DEFAULT NULL COMMENT '电话',
                `sex` int(10) NOT NULL DEFAULT '1' COMMENT '性别:1=男,2=女',
                `jiesuan_status` int(10) NOT NULL DEFAULT '0' COMMENT '结算状态:0=待结算,1=已结算',
                `jiesuan_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '结算时间',
                `is_pay` int(10) NOT NULL DEFAULT '0' COMMENT '报名支付:1=已支付,0=未支付',
                `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型',
                `paytime` bigint(16) NOT NULL DEFAULT '0' COMMENT '支付时间',
                `info` text NULL COMMENT '数据',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $activity_baomingFields = Db::name("bbfx_activity_baoming")->getTableFields();
            }
            else{
                $activity_baomingFields = Db::name("bbfx_activity_baoming")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_repurchase_jiandan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_repurchase_jiandan")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `repurchase_goods` varchar(255) DEFAULT NULL COMMENT '复购商品',
                `mode` int(10) NOT NULL DEFAULT '0' COMMENT '模式:0=常规模式,1=大公排模式	',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $repurchase_jiandanFields = Db::name("bbfx_repurchase_jiandan")->getTableFields();
            }
            else{
                $repurchase_jiandanFields = Db::name("bbfx_repurchase_jiandan")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_repurchase_jiandan_rermission")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_repurchase_jiandan_rermission")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `layer` int(10) NOT NULL DEFAULT '0' COMMENT '奖励层数',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $repurchase_jiandan_rermissionFields = Db::name("bbfx_repurchase_jiandan_rermission")->getTableFields();
            }
            else{
                $repurchase_jiandan_rermissionFields = Db::name("bbfx_repurchase_jiandan_rermission")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_repurchase_jiandan_rermission_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_repurchase_jiandan_rermission_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT 'PID',
                `og_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品订单ID',
                `createtime` varchar(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $repurchase_jiandan_rermission_logFields = Db::name("bbfx_repurchase_jiandan_rermission_log")->getTableFields();
            }
            else{
                $repurchase_jiandan_rermission_logFields = Db::name("bbfx_repurchase_jiandan_rermission_log")->getTableFields();
            }
            $express = Db::name("bbfx_express")->where(['id'=>['>',0]])->find();
            if(empty($express)){
                Db::execute("INSERT INTO ".tablename("bbfx_express")." (`id`, `name`, `express`, `status`, `sort`, `code`, `coding`) VALUES
                (1, '顺丰速运', 'shunfeng', 1, 0, '', 'SF'),
                (2, '申通快递', 'shentong', 1, 0, '', 'STO'),
                (3, '韵达速递', 'yunda', 1, 0, '', 'YD'),
                (5, '圆通速递', 'yuantong', 1, 0, '', 'YTO'),
                (6, '中通快递', 'zhongtong', 1, 0, '', 'ZTO'),
                (8, '百世快递', 'baishikuaidi', 1, 0, '', 'HTKY'),
                (98, '极兔速递', 'jitukuaidi', 1, 0, '', 'JTSD'),
                (20, '德邦快递', 'debangwuliu', 1, 0, '', 'DBL'),
                (78, '邮政快递包裹', 'youzhengguonei', 1, 0, '', 'YZPY'),
                (92, '京东快递', 'jd', 1, 0, '', 'JD');");
            }
            


            //v2.2.2510271
            if(!in_array('image',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `image` VARCHAR(255) NULL COMMENT '活动图片';");
            }
            if(!in_array('type',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `type` INT(10) NOT NULL DEFAULT '1' COMMENT '活动类型:1=线下活动,2=线上活动';");
            }
            if(!in_array('is_public',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `is_public` INT(10) NOT NULL DEFAULT '1' COMMENT '公开活动:1=是,0=否';");
            }
            if(!in_array('is_hexiao',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `is_hexiao` INT(10) NOT NULL DEFAULT '0' COMMENT '活动核销:1=开启,0=关闭';");
            }
            if(!in_array('baoming_user_scroll',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `baoming_user_scroll` INT(10) NOT NULL DEFAULT '0' COMMENT '报名用户滚动:1=开启,0=关闭';");
            }
            if(!in_array('hexiao_status',$activity_baomingFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_baoming")." ADD `hexiao_status` INT(10) NOT NULL DEFAULT '0' COMMENT '核销状态:0=待核销,1=已核销';");
            }
            if(!in_array('hexiao_time',$activity_baomingFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_baoming")." ADD `hexiao_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '核销时间';");
            }
            if(!in_array('hexiao_code',$activity_baomingFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_baoming")." ADD `hexiao_code` varchar(100) DEFAULT NULL COMMENT '核销码';");
            }
            if(!in_array('order_user_scroll',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `order_user_scroll` INT(10) NOT NULL DEFAULT '0' COMMENT '下单用户滚动:1=开启,0=关闭';");
            }
            if(!in_array('sup_path',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `sup_path` TEXT NULL COMMENT '推荐路径';");
            }
            if(!in_array('sup_path',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `sup_path` TEXT NULL COMMENT '推荐路径';");
            }
            if(!in_array('sup_path',$member_card_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card_order")." ADD `sup_path` TEXT NULL COMMENT '推荐路径';");
            }
            if(!in_array('achievement_jisuan',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `achievement_jisuan` INT(10) NOT NULL DEFAULT '0' COMMENT '业绩计算方式:0=当前关系,1=原始关系';");
            }

            //v2.2.2511051
            if(!in_array('is_manage_assistant_reward',$laddermanageFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_laddermanage")." ADD `is_manage_assistant_reward` INT(10) NOT NULL DEFAULT '0' COMMENT '管理辅助奖:1=开启,0=关闭';");
            }
            if(!in_array('laddermanage_assistant_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `laddermanage_assistant_reward` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '阶梯管理奖辅助奖';");
            }
            if(!in_array('layer',$repurchase_jiandanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_repurchase_jiandan")." ADD `layer` INT(10) NOT NULL DEFAULT '12' COMMENT '奖励最高层数';");
            }
            if(!in_array('fund_money',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `fund_money` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '发展基金';");
            }
            if(!in_array('unlock_fund_num',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `unlock_fund_num` INT(10) NOT NULL DEFAULT '0' COMMENT '解锁发展金额人数';");
            }
            if(!in_array('fund_money',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `fund_money` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '发展基金';");
            }
            if(!pdo_tableexists("bbfx_saward")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_saward")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `reward` text NULL COMMENT '奖励配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sawardFields = Db::name("bbfx_saward")->getTableFields();
            }
            else{
                $sawardFields = Db::name("bbfx_saward")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_below_welfare")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_below_welfare")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `reward` text NULL COMMENT '奖励配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $below_welfareFields = Db::name("bbfx_below_welfare")->getTableFields();
            }
            else{
                $below_welfareFields = Db::name("bbfx_below_welfare")->getTableFields();
            }
            

            //v2.2.2511141
            if(!in_array('is_recharge_balance',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_recharge_balance` INT(10) NOT NULL DEFAULT '1' COMMENT '余额充值:1=开启,0=关闭';");
            }
            if(!in_array('recharge_score_ratio',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `recharge_score_ratio` INT(10) NOT NULL DEFAULT '1' COMMENT '积分充值比例';");
            }
            if(!in_array('recharge_score',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `recharge_score` TEXT NULL COMMENT '积分充值设置';");
            }
            if(!in_array('tx_date_limit',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `tx_date_limit` VARCHAR(500) NULL COMMENT '提现日期限制';");
            }
            if(!in_array('wexin_tx_check',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `wexin_tx_check` INT(10) NOT NULL DEFAULT '0' COMMENT '微信提现免审:1=开启,0=关闭';");
            }
            if(!in_array('wexin_tx_check_max',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `wexin_tx_check_max` INT(10) NOT NULL DEFAULT '0' COMMENT '微信提现免审额度';");
            }
            if(!pdo_tableexists("bbfx_leveljicha")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_leveljicha")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $leveljichaFields = Db::name("bbfx_leveljicha")->getTableFields();
            }
            else{
                $leveljichaFields = Db::name("bbfx_leveljicha")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sachievement")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sachievement")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sachievementFields = Db::name("bbfx_sachievement")->getTableFields();
            }
            else{
                $sachievementFields = Db::name("bbfx_sachievement")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_mergelevel")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_mergelevel")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $mergelevelFields = Db::name("bbfx_mergelevel")->getTableFields();
            }
            else{
                $mergelevelFields = Db::name("bbfx_mergelevel")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_scorereward")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_scorereward")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `reward_rate` int(10) NOT NULL DEFAULT '0' COMMENT '奖励比例',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $scorerewardFields = Db::name("bbfx_scorereward")->getTableFields();
            }
            else{
                $scorerewardFields = Db::name("bbfx_scorereward")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_fenxiaoscore")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_fenxiaoscore")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $fenxiaoscoreFields = Db::name("bbfx_fenxiaoscore")->getTableFields();
            }
            else{
                $fenxiaoscoreFields = Db::name("bbfx_fenxiaoscore")->getTableFields();
            }
            

            //v2.2.2511201
            if(!in_array('clerk_user_id',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `clerk_user_id` VARCHAR(500) NULL COMMENT '店员ID';");
            }
            if(!in_array('score',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `score` `score` DECIMAL(10,1) NOT NULL DEFAULT '5' COMMENT '评分';");
            }
            if(!in_array('dealer_store',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dealer_store` VARCHAR(500) NULL COMMENT '经销商指定门店';");
            }
            if(!in_array('dealer_store_reward',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dealer_store_reward` INT(10) NOT NULL DEFAULT '0' COMMENT '门店指定经销商奖励';");
            }
            if(!in_array('category_id',$storeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_store")." ADD `category_id` VARCHAR(500) NULL COMMENT '商户分类';");
            }
            if(!in_array('category_id',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `category_id` VARCHAR(500) NULL COMMENT '商户分类';");
            }
            if(!in_array('score',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `score` DECIMAL(10,1) NOT NULL DEFAULT '5' COMMENT '评分';");
            }
            if(!in_array('sup_uid',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `sup_uid` INT(10) NOT NULL DEFAULT '0' COMMENT '推荐人ID';");
            }
            if(!in_array('sup_commission',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `sup_commission` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '推荐佣金比例';");
            }
            if(!in_array('banner',$merchant_setFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant_set")." ADD `banner` VARCHAR(255) NULL COMMENT '商户banner';");
            }
            if(!in_array('dish',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `dish` TEXT NULL COMMENT '品相';");
            }
            if(!in_array('is_setmeal',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `is_setmeal` INT(10) NOT NULL DEFAULT '0' COMMENT '套餐模式:1=开启,0=关闭';");
            }
            if(!in_array('mid',$goods_commentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_comment")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID';");
            }
            if(!in_array('store_id',$goods_commentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_comment")." ADD `store_id` INT(10) NOT NULL DEFAULT '0' COMMENT '门店ID';");
            }
            if(!in_array('score',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `score` DECIMAL(10,1) NOT NULL DEFAULT '5' COMMENT '评分';");
            }
            if(!pdo_tableexists("bbfx_merchant_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_merchant_category")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `name` varchar(100) DEFAULT NULL COMMENT '分类名称',
                `image` varchar(255) DEFAULT NULL COMMENT '分类图片',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $merchant_categoryFields = Db::name("bbfx_merchant_category")->getTableFields();
            }
            else{
                $merchant_categoryFields = Db::name("bbfx_merchant_category")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_slide")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_slide")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `image` varchar(255) DEFAULT NULL COMMENT '图片',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `link` varchar(500) NOT NULL COMMENT '链接',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $slideFields = Db::name("bbfx_slide")->getTableFields();
            }
            else{
                $slideFields = Db::name("bbfx_slide")->getTableFields();
            }

            //v2.2.2511281
            if(!pdo_tableexists("bbfx_form_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_form_set")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $form_setFields = Db::name("bbfx_form_set")->getTableFields();
            }
            else{
                $form_setFields = Db::name("bbfx_form_set")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_form")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_form")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `image` varchar(255) DEFAULT NULL COMMENT '图片',
                `content` text NULL COMMENT '内容',
                `is_repeat` int(10) NOT NULL DEFAULT '0' COMMENT '重复提交:1=开启,0=关闭',
                `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $formFields = Db::name("bbfx_form")->getTableFields();
            }
            else{
                $formFields = Db::name("bbfx_form")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_form_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_form_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `form_id` int(10) NOT NULL DEFAULT '0' COMMENT '表单ID',
                `content` text NULL COMMENT '表单内容',
                `info` text NULL COMMENT '表单内容',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $form_recordFields = Db::name("bbfx_form_record")->getTableFields();
            }
            else{
                $form_recordFields = Db::name("bbfx_form_record")->getTableFields();
            }
             

            //v2.2.2512051
            if(!in_array('user_id',$capitalpool_money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_capitalpool_money_log")." ADD `user_id` INT(10) NOT NULL DEFAULT '0' COMMENT '用户ID';");
            }
            if(!in_array('float_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `float_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '浮动金额';");
            }
            if(!in_array('float_price',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `float_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '浮动金额';");
            }
            if(in_array('detail_images',$goodsFields) && $bbfx['sversion'] <= 222512051){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `detail_images` `detail_images` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '详情图片';");
            }
            if(in_array('cw_goods',$cloud_warehouseFields) && $bbfx['sversion'] <= 222512051){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cloud_warehouse")." CHANGE `cw_goods` `cw_goods` VARCHAR(1000) NULL COMMENT '云仓商品';");
            }
            if(!pdo_tableexists("bbfx_pingji")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pingji")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `pingji_calculate` int(10) NOT NULL DEFAULT '2' COMMENT '计算方式:1=订单金额百分比,2=下级收入百分比',
                `pingji_layer` int(10) NOT NULL DEFAULT '1' COMMENT '平级奖代数',
                `pingji_type` int(10) NOT NULL DEFAULT '0' COMMENT '平级奖类型:0=普通平级,1=下单平级',
                `pingji_reward_num` int(10) NOT NULL DEFAULT '0' COMMENT '平级奖获得人数',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pingjiFields = Db::name("bbfx_pingji")->getTableFields();
            }
            else{
                $pingjiFields = Db::name("bbfx_pingji")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_abonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_abonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `abonus_rule` int(10) NOT NULL DEFAULT '1' COMMENT '分红规则:1=商品分红,2=订单分红',
                `is_abonus_gld` int(10) NOT NULL DEFAULT '0' COMMENT '高等级拿低等级:1=开启,0=关',
                `is_abonus_out_amount` int(10) NOT NULL DEFAULT '0' COMMENT '分红出局金额:1=开启,0=关闭',
                `settlement_abonus_stype` int(10) NOT NULL DEFAULT '0' COMMENT '分红结算类型:0=立即发放,1=日结周发,2=日结月发',
                `abonus` text NULL COMMENT '分红配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $abonusFields = Db::name("bbfx_abonus")->getTableFields();
            }
            else{
                $abonusFields = Db::name("bbfx_abonus")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_ladderabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_ladderabonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `is_ladder_abonus_gld` int(10) NOT NULL DEFAULT '0' COMMENT '高等级参与低等级分红:1=开启,0=关闭',
                `ladder_abonus_mode` int(10) NOT NULL DEFAULT '1' COMMENT '分红模式:1=统一分红,2=多组分红',
                `is_deduct_daquachievement` int(10) NOT NULL DEFAULT '0' COMMENT '扣除大区业绩:1=开启,0=关闭',
                `ladder_abonus` text NULL COMMENT '阶梯分红配置',
                `ladder_abonus_multiple` text NULL COMMENT '多组分红配置',
                `is_ladder_abonus_pingji` int(10) NOT NULL DEFAULT '0' COMMENT '阶梯分红平级奖:1=开启,0=关闭',
                `ladder_abonus_pingji_rate` int(10) NOT NULL DEFAULT '0' COMMENT '阶梯分红平级平级奖比例',
                `settlement_abonus_stype` int(10) NOT NULL DEFAULT '0' COMMENT '分红结算类型:0=立即发放,1=日结周发,2=日结月发',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $ladderabonusFields = Db::name("bbfx_ladderabonus")->getTableFields();
            }
            else{
                $ladderabonusFields = Db::name("bbfx_ladderabonus")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `fz_user_id` varchar(10) NOT NULL DEFAULT '0' COMMENT '负责人',
                `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                `title` varchar(100) DEFAULT NULL COMMENT '工单标题',
                `images` text NULL COMMENT '问题图片',
                `content` varchar(5000) DEFAULT NULL COMMENT '问题描述',
                `reply_content` varchar(1000) DEFAULT NULL COMMENT '回复内容',
                `reply_images` text NULL COMMENT '回复图片',
                `form` text NULL COMMENT '工单表单',
                `info` text NULL COMMENT '工单数据',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待处理,1=处理中,2=已完成,3=已关闭',
                `cltime` bigint(16) NOT NULL DEFAULT '0' COMMENT '处理时间',
                `completetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '完成时间',
                `closetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '关单时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorderFields = Db::name("bbfx_workorder")->getTableFields();
            }
            else{
                $workorderFields = Db::name("bbfx_workorder")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder_set")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorder_setFields = Db::name("bbfx_workorder_set")->getTableFields();
            }
            else{
                $workorder_setFields = Db::name("bbfx_workorder_set")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder_user")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `name` varchar(100) DEFAULT NULL COMMENT '名称',
                `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorder_userFields = Db::name("bbfx_workorder_user")->getTableFields();
            }
            else{
                $workorder_userFields = Db::name("bbfx_workorder_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder_probe")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder_probe")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `fz_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '工单用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '所属工单',
                `content` varchar(2000) DEFAULT NULL COMMENT '追问内容',
                `images` text NULL COMMENT '问题图片',
                `reply_content` varchar(2000) DEFAULT NULL COMMENT '回复内容',
                `reply_images` text NULL COMMENT '回复图片',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待回复,1=已回复',
                `replytime` bigint(16) NOT NULL DEFAULT '0' COMMENT '回复时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorder_probeFields = Db::name("bbfx_workorder_probe")->getTableFields();
            }
            else{
                $workorder_probeFields = Db::name("bbfx_workorder_probe")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `fz_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '工单用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '工单ID',
                `probe_id` int(10) NOT NULL DEFAULT '0' COMMENT '追问ID',
                `username` varchar(255) DEFAULT NULL COMMENT '操作用户',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `content` varchar(500) DEFAULT NULL COMMENT '操作内容',
                `info` text NULL COMMENT '工单数据',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorder_logFields = Db::name("bbfx_workorder_log")->getTableFields();
            }
            else{
                $workorder_logFields = Db::name("bbfx_workorder_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_workorder_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_workorder_category")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `image` varchar(255) DEFAULT NULL COMMENT '图标',
                `form` text NULL COMMENT '表单',
                `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,0=禁用',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $workorder_categoryFields = Db::name("bbfx_workorder_category")->getTableFields();
            }
            else{
                $workorder_categoryFields = Db::name("bbfx_workorder_category")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_floatamount")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_floatamount")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $floatamountFields = Db::name("bbfx_floatamount")->getTableFields();
            }
            else{
                $floatamountFields = Db::name("bbfx_floatamount")->getTableFields();
            }
            

            //v2.2.2512091
            if(!in_array('plugin_collect',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `plugin_collect` TEXT NULL COMMENT '积分充值设置';");
            }

            //v2.2.2512121
            if(!in_array('type',$workorder_probeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_workorder_probe")." ADD `type` INT(10) NOT NULL DEFAULT '1' COMMENT '类型:1=提问,2=回复';");
            }
            if(!in_array('is_check',$workorderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_workorder")." ADD `is_check` INT(10) NOT NULL DEFAULT '0' COMMENT '是否已查看:0=否,1=是';");
            }
            if(!in_array('checktime',$workorderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_workorder")." ADD `checktime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '查看时间';");
            }
            if(!in_array('lottery_num',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `lottery_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '抽奖次数';");
            }
            if(!in_array('app_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `app_login` INT(10) NOT NULL DEFAULT '1' COMMENT 'app登录:1=验证码登录,3=账号密码登录';");
                $bases = Db::name("bbfx_base")->where(['uniacid'=>['>',0]])->field("id,wxapp_login")->select();
                if(!empty($bases)){
                    foreach ($bases as $key => $value) {
                        if($val['wxapp_login'] == 1 || $val['wxapp_login'] == 3){
                            Db::name("bbfx_base")->where(['id'=>$value['id']])->update(['app_login'=>$val['wxapp_login']]);
                        }
                    }
                }
            }
            if(!in_array('h5_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `h5_login` INT(10) NOT NULL DEFAULT '1' COMMENT 'H5登录:1=验证码登录,3=账号密码登录';");
                $bases = Db::name("bbfx_base")->where(['uniacid'=>['>',0]])->field("id,wxapp_login")->select();
                if(!empty($bases)){
                    foreach ($bases as $key => $value) {
                        if($val['wxapp_login'] == 1 || $val['wxapp_login'] == 3){
                            Db::name("bbfx_base")->where(['id'=>$value['id']])->update(['h5_login'=>$val['wxapp_login']]);
                        }
                    }
                }
            }
            if(!in_array('is_cloud_warehouse',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `is_cloud_warehouse` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓商品:0=否,1=是';");
            }
            if(!in_array('is_cloud_warehouse_jinhuo',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `is_cloud_warehouse_jinhuo` INT(10) NOT NULL DEFAULT '0' COMMENT '云仓商品进货:0=否,1=是';");
            }
            
            if(!pdo_tableexists("bbfx_coupon_set")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_coupon_set")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '1' COMMENT '状态:1=开启,0=关闭',
                `share_reward` text NULL COMMENT '分享奖励',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $coupon_setFields = Db::name("bbfx_coupon_set")->getTableFields();
            }
            else{
                $coupon_setFields = Db::name("bbfx_coupon_set")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_luckywheel")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_luckywheel")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `lottery_obtain` int(10) NOT NULL DEFAULT '1' COMMENT '抽奖获取方式:1=购买商品,2=消费金额',
                `lottery_obtain_rule` text NULL COMMENT '抽奖次数获取规则',
                `bg` varchar(255) DEFAULT NULL COMMENT '抽奖背景',
                `yp_bg` varchar(255) DEFAULT NULL COMMENT '转盘背景',
                `title_image` varchar(255) DEFAULT NULL COMMENT '标题图片',
                `pointer_image` varchar(255) DEFAULT NULL COMMENT '指针图片',
                `lottery_btn_image` varchar(255) DEFAULT NULL COMMENT '抽奖按钮图片',
                `record_btn_image` varchar(255) DEFAULT NULL COMMENT '记录按钮图片',
                `rule_btn_image` varchar(255) DEFAULT NULL COMMENT '规则按钮图片',
                `lottery_rule` text NULL COMMENT '抽奖规则',
                `popup_image` varchar(255) DEFAULT NULL COMMENT '弹窗图片',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $luckywheelFields = Db::name("bbfx_luckywheel")->getTableFields();
            }
            else{
                $luckywheelFields = Db::name("bbfx_luckywheel")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_luckywheel_prize")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_luckywheel_prize")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '奖励类型:0=谢谢参与,1=余额,2=积分,3=其他',
                `image` varchar(255) DEFAULT NULL COMMENT '奖励图片',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `reward` text NULL COMMENT '奖励内容',
                `probability` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '中奖概率',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=正常,0=禁用',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $luckywheel_prizeFields = Db::name("bbfx_luckywheel_prize")->getTableFields();
            }
            else{
                $luckywheel_prizeFields = Db::name("bbfx_luckywheel_prize")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_luckywheel_zhiding")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_luckywheel_zhiding")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `prize_id` int(10) NOT NULL DEFAULT '0' COMMENT '奖品ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已抽奖,0=待抽奖',
                `cjtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '抽奖时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $luckywheel_zhidingFields = Db::name("bbfx_luckywheel_zhiding")->getTableFields();
            }
            else{
                $luckywheel_zhidingFields = Db::name("bbfx_luckywheel_zhiding")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_luckywheel_lottery_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_luckywheel_lottery_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '奖品类型',
                `prize_id` int(10) NOT NULL DEFAULT '0' COMMENT '奖品ID',
                `prize` text NULL COMMENT '奖品信息',
                `code` varchar(100) DEFAULT NULL COMMENT '兑换码',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=已兑换,0=待兑换',
                `dhtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '兑换时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $luckywheel_lottery_recordFields = Db::name("bbfx_luckywheel_lottery_record")->getTableFields();
            }
            else{
                $luckywheel_lottery_recordFields = Db::name("bbfx_luckywheel_lottery_record")->getTableFields();
            }
            
            
            //v2.2.2512201
            if(!in_array('pay_voucher',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `pay_voucher` VARCHAR(255) NULL COMMENT '线下支付凭证';");
            }
            if(!in_array('tongue_diagnosis_num',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `tongue_diagnosis_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'AI舌诊次数';");
            }
            if(!in_array('zsil_nojumpout',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `zsil_nojumpout` INT(10) NOT NULL DEFAULT '0' COMMENT '直升初始等级之上不跳出:1=开启,0=关闭';");
            }
            if(!in_array('reward_calculate',$npingjiFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_npingji")." ADD `reward_calculate` INT(10) NOT NULL DEFAULT '1' COMMENT '奖励计算方式:1=订单金额百分比,2=直推收入百分比';");
            }
            if(!in_array('goods_detail_style',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `goods_detail_style` INT(10) NOT NULL DEFAULT '0' COMMENT '商品详情样式:0=样式1,1=样式2';");
            }
            if(!in_array('product_code',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `product_code` VARCHAR(255) NULL COMMENT '商品编码';");
            }
            if(!in_array('product_code',$goods_spec_skuFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods_spec_sku")." ADD `product_code` VARCHAR(255) NULL COMMENT '商品编码';");
            }
            if(!in_array('team_tongji',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `team_tongji` INT(10) NOT NULL DEFAULT '0' COMMENT '团队统计:0=包含普通用户,1=不包含普通用户';");
            }
            if(!pdo_tableexists("bbfx_tongue_diagnosis")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_tongue_diagnosis")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `appcode` varchar(255) DEFAULT NULL COMMENT 'AppCode',
                `instructions` text NULL COMMENT '说明',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $tongue_diagnosisFields = Db::name("bbfx_tongue_diagnosis")->getTableFields();
            }
            else{
                $tongue_diagnosisFields = Db::name("bbfx_tongue_diagnosis")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_tongue_diagnosis_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_tongue_diagnosis_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `scene` int(10) NOT NULL DEFAULT '1' COMMENT '场景值:1=舌诊会话,2=舌诊报告',
                `score` int(10) NOT NULL DEFAULT '100' COMMENT '评分',
                `ff_image` varchar(255) DEFAULT NULL COMMENT '舌照图片',
                `tf_image` varchar(255) DEFAULT NULL COMMENT '面照图片',
                `tb_image` varchar(255) DEFAULT NULL COMMENT '舌下脉络图片',
                `gender` varchar(100) DEFAULT NULL COMMENT '性别',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待诊断,1=诊断中,2=已诊断',
                `result` text NULL COMMENT '诊断结果',
                `report` text NULL COMMENT '诊断报告',
                `stime` bigint(16) NOT NULL DEFAULT '0' COMMENT '诊断时间',
                `ctime` bigint(16) NOT NULL DEFAULT '0' COMMENT '完成诊断时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $tongue_diagnosis_recordFields = Db::name("bbfx_tongue_diagnosis_record")->getTableFields();
            }
            else{
                $tongue_diagnosis_recordFields = Db::name("bbfx_tongue_diagnosis_record")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_pabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pabonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pabonusFields = Db::name("bbfx_pabonus")->getTableFields();
            }
            else{
                $pabonusFields = Db::name("bbfx_pabonus")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_pabonus_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pabonus_goods")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `name` varchar(255) DEFAULT NULL COMMENT '项目名称',
                `status` varchar(100) DEFAULT NULL COMMENT '项目状态',
                `edate` datetime DEFAULT NULL COMMENT '截止日期',
                `content` text NULL COMMENT '项目内容',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '绑定商品',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pabonus_goodsFields = Db::name("bbfx_pabonus_goods")->getTableFields();
            }
            else{
                $pabonus_goodsFields = Db::name("bbfx_pabonus_goods")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_pabonus_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pabonus_user")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '项目ID',
                `num` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '分红股份',
                `money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pabonus_userFields = Db::name("bbfx_pabonus_user")->getTableFields();
            }
            else{
                $pabonus_userFields = Db::name("bbfx_pabonus_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_pabonus_goods_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pabonus_goods_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '项目ID',
                `money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '分红金额',
                `each_money` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每股金额',
                `num` int(10) NOT NULL DEFAULT '0' COMMENT '分红人数',
                `abonus_num` int(10) NOT NULL DEFAULT '0' COMMENT '分红分数',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pabonus_goods_recordFields = Db::name("bbfx_pabonus_goods_record")->getTableFields();
            }
            else{
                $pabonus_goods_recordFields = Db::name("bbfx_pabonus_goods_record")->getTableFields();
            }


            //v2.2.2512221
            


            //v2.2.2512231
            if(!pdo_tableexists("bbfx_management")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_management")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `is_management_assistant_reward` int(10) NOT NULL DEFAULT '0' COMMENT '管理奖辅助奖:1=开启,0=关闭',
                `management_type` int(10) NOT NULL DEFAULT '1' COMMENT '管理奖类型:1=跟随等级,2=单独计算',
                `management_reward` text NULL COMMENT '管理奖配置',
                `management_jisuan` int(10) NOT NULL DEFAULT '1' COMMENT '管理奖计算方式:1=逐级减,2=直推减',
                `management_remove_daqu` int(10) NOT NULL DEFAULT '0' COMMENT '去除大区业绩:1=开启,0=关闭',
                `management_jiesuan_day` int(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '管理奖结算日',
                `show_month_commission` int(10) NOT NULL DEFAULT '0' COMMENT '显示本月管理奖:1=是,0=否',
                `repurchase_xd_calculate` int(10) NOT NULL DEFAULT '0' COMMENT '复购下单计算:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $managementFields = Db::name("bbfx_management")->getTableFields();
            }
            else{
                $managementFields = Db::name("bbfx_management")->getTableFields();
            }
            if(!in_array('plugin_tongue_diagnosis',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `plugin_tongue_diagnosis` INT(10) NOT NULL DEFAULT '0' COMMENT '舌诊商品状态:1=开启,0=关闭';");
            }
            if(!in_array('main_recommendation_goods',$tongue_diagnosisFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_tongue_diagnosis")." ADD `main_recommendation_goods` VARCHAR(255) NULL COMMENT '主推商品';");
            }

            //v2.2.2601051
            if(!in_array('is_fenxiao',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `is_fenxiao` INT(10) NOT NULL DEFAULT '0' COMMENT '分销功能:1=开启,0=关闭';");
            }
            if(!in_array('plugin',$scoreshop_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_goods")." ADD `plugin` LONGTEXT NULL COMMENT '插件数据内容';");
            }
            $result = Db::query("SHOW CREATE TABLE ".tablename("bbfx_base"));
            if(!strstr($result[0]['Create Table'], 'ENGINE=MyISAM')){
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ENGINE=MyISAM;");
            }
            if(!pdo_tableexists("bbfx_goods_collection")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_collection")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_collectiontFields = Db::name("bbfx_goods_collection")->getTableFields();
            }
            else{
                $goods_collectiontFields = Db::name("bbfx_goods_collection")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_atransfer")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_atransfer")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $atransferFields = Db::name("bbfx_atransfer")->getTableFields();
            }
            else{
                $atransferFields = Db::name("bbfx_atransfer")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_atransfer_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_atransfer_user")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `m_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '转移用户ID',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '转移业绩',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $atransfer_userFields = Db::name("bbfx_atransfer_user")->getTableFields();
            }
            else{
                $atransfer_userFields = Db::name("bbfx_atransfer_user")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_user_txaccount")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_txaccount")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `dg_huifu_id` varchar(100) DEFAULT NULL COMMENT '主商户',
                `name` varchar(100) DEFAULT NULL COMMENT '姓名',
                `cert_type` varchar(10) NOT NULL DEFAULT '00' COMMENT '个人证件类型:00=身份证',
                `cert_no` varchar(100) DEFAULT NULL COMMENT '个人证件号码',
                `cert_validity_type` int(10) NOT NULL DEFAULT '0' COMMENT '个人证件有效期类型:1=长期有效,0=非长期有效',
                `cert_begin_date` date DEFAULT NULL COMMENT '个人证件有效期开始日期',
                `cert_end_date` date DEFAULT NULL COMMENT '个人证件有效期结束日期',
                `mobile_no` varchar(100) DEFAULT NULL COMMENT '手机号',
                `card_type` int(10) NOT NULL DEFAULT '0' COMMENT '卡类型:0=对公,1=对私法人,2=对私非法人,4=对公非同名',
                `card_no` varchar(100) DEFAULT NULL COMMENT '银行卡号',
                `prov_id` varchar(100) DEFAULT NULL COMMENT '银行所在省',
                `area_id` varchar(100) DEFAULT NULL COMMENT '银行所在市',
                `kh_status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待提交,1=已开户',
                `huifu_id` varchar(100) DEFAULT NULL COMMENT '汇付ID',
                `login_name` varchar(100) DEFAULT NULL COMMENT '管理员账号',
                `login_password` varchar(100) DEFAULT NULL COMMENT '管理员密码',
                `kh_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '开户时间',
                `req_seq_id` varchar(100) DEFAULT NULL COMMENT '流水号',
                `apply_no` varchar(100) DEFAULT NULL COMMENT '申请单号',
                `rz_status` int(10) NOT NULL DEFAULT '0' COMMENT '业务入驻状态:0=待入驻,1=已入驻',
                `token_no` varchar(255) DEFAULT NULL COMMENT '取现卡序列号',
                `rz_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '入驻时间',
                `qx_status` int(10) NOT NULL DEFAULT '0' COMMENT '取现状态:1=成功,0=失败',
                `js_status` int(10) NOT NULL DEFAULT '0' COMMENT '结算状态:1=成功,0=失败',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_txaccountFields = Db::name("bbfx_user_txaccount")->getTableFields();
            }
            else{
                $user_txaccountFields = Db::name("bbfx_user_txaccount")->getTableFields();
            }
            if(!in_array('order_trade_no',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `order_trade_no` VARCHAR(255) NULL COMMENT '交易流水号';");
            }
            if(!in_array('third_party',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `third_party` INT(10) NOT NULL DEFAULT '0' COMMENT '第三方支付:0=否,1=斗拱';");
            }
            if(!in_array('third_party_no',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `third_party_no` VARCHAR(255) NULL COMMENT '第三方支付单号';");
            }
            if(!in_array('third_party_info',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `third_party_info` TEXT NULL COMMENT '第三方订单信息';");
            }
            if(!in_array('order_id',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `order_id` INT(10) NOT NULL DEFAULT '0' COMMENT '订单ID';");
            }
            if(!in_array('third_party',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `third_party` INT(10) NOT NULL DEFAULT '0' COMMENT '第三方支付:0=否,1=斗拱';");
            }
            if(!in_array('dg_status',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_status` INT(10) NOT NULL DEFAULT '0' COMMENT '斗拱支付:1=开启,0=关闭';");
            }
            if(!in_array('dg_sys_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_sys_id` VARCHAR(100) NULL COMMENT '斗拱系统号';");
            }
            if(!in_array('dg_product_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_product_id` VARCHAR(100) NULL COMMENT '斗拱产品号';");
            }
            if(!in_array('dg_huifu_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_huifu_id` VARCHAR(100) NULL COMMENT '斗拱商户号';");
            }
            if(!in_array('dg_wxapp_huifu_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_wxapp_huifu_id` VARCHAR(100) NULL COMMENT '斗拱微信小程序商户号';");
            }
            if(!in_array('dg_gzh_huifu_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_gzh_huifu_id` VARCHAR(100) NULL COMMENT '斗拱微信公众号商户号';");
            }
            if(!in_array('dg_zfb_huifu_id',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_zfb_huifu_id` VARCHAR(100) NULL COMMENT '斗拱支付宝商户号';");
            }
            if(!in_array('dg_rsaPrivateKey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_rsaPrivateKey` TEXT NULL COMMENT '服务商私钥';");
            }
            if(!in_array('dg_rsaPublicKey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_rsaPublicKey` TEXT NULL COMMENT '斗拱汇付公钥';");
            }
            if(!in_array('dg_fenzhang',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_fenzhang` INT(10) NOT NULL DEFAULT '0' COMMENT '斗拱分账:1=开启,0=关闭';");
            }
            if(!in_array('dg_fenzhang_rate',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_fenzhang_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '分账比例';");
            }
            if(!in_array('upgrade_score',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `upgrade_score` INT(10) NOT NULL DEFAULT '0' COMMENT '商品单位';");
            }
            

            //v2.2.2601101
            if(!in_array('a_version_name',$bbfxFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx")." ADD `a_version_name` VARCHAR(100) NULL COMMENT '安卓APP端版本名称';");
            }
            if(!in_array('a_version',$bbfxFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx")." ADD `a_version` VARCHAR(100) NULL COMMENT '安卓APP端版本号';");
            }
            if(!in_array('bankopen',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `bankopen` VARCHAR(100) NULL COMMENT '开户行支行';");
            }
            if(!in_array('bankname',$user_txaccountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_txaccount")." ADD `bankname` VARCHAR(100) NULL COMMENT '开户行银行名称';");
            }
            if(!in_array('bankopen',$user_txaccountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user_txaccount")." ADD `bankopen` VARCHAR(100) NULL COMMENT '开户行支行';");
            }
            if(!in_array('bankopen',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `bankopen` VARCHAR(100) NULL COMMENT '开户行支行';");
            }
            if(!in_array('zhitui_reward',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `zhitui_reward` TEXT NULL COMMENT '直推奖励';");
            }
            if(!in_array('dt_release',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `dt_release` INT(10) NOT NULL DEFAULT '0' COMMENT '当天返还:1=开启,0=关闭';");
            }
            if(!in_array('sign_release',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `sign_release` INT(10) NOT NULL DEFAULT '0' COMMENT '签到释放:1=开启,0=关闭';");
            }
            if(!in_array('fixed_service_charge',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `fixed_service_charge` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '固定手续费';");
            }
            if(!in_array('item_type',$return_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_log")." ADD `item_type` INT(10) NOT NULL DEFAULT '1' COMMENT '返还类型:1=正常返还,2=直推加速返还';");
            }
            if(!in_array('item_id',$return_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_log")." ADD `item_id` INT(10) NOT NULL DEFAULT '0' COMMENT '来源ID';");
            }
            if(!in_array('day',$signin_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_signin_record")." ADD `day` INT(10) NOT NULL DEFAULT '0' COMMENT '天';");
            }
            if(!in_array('dk_status',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `dk_status` INT(10) NOT NULL DEFAULT '0' COMMENT '打款状态:0=处理中,1=成功,2=失败';");
            }
            if(!in_array('dk_time',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `dk_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '打款时间';");
            }
            if(!in_array('info',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `info` TEXT NULL COMMENT '信息';");
            }
            if($bbfx['sversion'] <= 222601081){
                Db::execute("ALTER TABLE ".tablename("bbfx_return_log")." DROP INDEX `user_id`, ADD UNIQUE `user_id` (`user_id`, `pid`, `sdate`, `item_id`) USING BTREE;");
            }

            //v2.2.2601141
            if(!in_array('is_automatic',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `is_automatic` INT(10) NOT NULL DEFAULT '0' COMMENT '自动打款:1=是,0=否';");
            }
            if(!in_array('a_bversion',$bbfxFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx")." ADD `a_bversion` VARCHAR(100) NULL COMMENT '安卓基座版本';");
            }
            if(!in_array('fanhuan_score_total',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `fanhuan_score_total` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '积分返还比例';");
            }
            if(!in_array('everyday_score_rate',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `everyday_score_rate` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '每天返还积分比例';");
            }
            if(!in_array('switch_duration',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `switch_duration` INT(10) NOT NULL DEFAULT '30' COMMENT '模式切换时长';");
            }
            if(!in_array('type',$cumulative_fanhuan_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan_user")." ADD `type` INT(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分';");
            }
            if(!in_array('mode',$cumulative_fanhuan_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan_user")." ADD `mode` INT(10) NOT NULL DEFAULT '0' COMMENT '模式:0=常规模式,1=增益模式';");
            }
            if(!in_array('modetime',$cumulative_fanhuan_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan_user")." ADD `modetime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '模式切换时间';");
            }
            if(!in_array('is_accelerate',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `is_accelerate` INT(10) NOT NULL DEFAULT '0' COMMENT '加速返还:1=开启,0=关闭';");
            }
            if(!in_array('accelerate_rule',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `accelerate_rule` TEXT NULL COMMENT '奖励加速规则';");
            }
            if(!in_array('plugin',$activity_listFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_list")." ADD `plugin` LONGTEXT NULL COMMENT '插件数据';");
            }
            if(!in_array('is_cumulative_fanhuan',$activity_baomingFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_baoming")." ADD `is_cumulative_fanhuan` INT(10) NOT NULL DEFAULT '0' COMMENT '累计返还:1=完成,0=未完成';");
            }
            if(!in_array('o_sup_path',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `o_sup_path` LONGTEXT NULL COMMENT '原始推荐路径';");
            }
            
            if(!pdo_tableexists("bbfx_cumulative_fanhuan_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cumulative_fanhuan_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '来源ID',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分',
                `itype` int(10) NOT NULL DEFAULT '0' COMMENT '来源类型:0=商品,1=活动,2=增益模式',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cumulative_fanhuan_logFields = Db::name("bbfx_cumulative_fanhuan_log")->getTableFields();
            }
            else{
                $cumulative_fanhuan_logFields = Db::name("bbfx_cumulative_fanhuan_log")->getTableFields();
            }
            
 
            //v2.2.2601141
            if(!in_array('management_pingji_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `management_pingji_reward` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '管理奖平级奖';");
            }
            if(!in_array('relationship_type',$managementFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_management")." ADD `relationship_type` INT(10) NOT NULL DEFAULT '0' COMMENT '关系计算:0=当前关系,1=原始关系';");
            }
            //v2.2.2601141
            if($bbfx['sversion'] <= 222601141 && in_array('info',$money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_money_log")."  CHANGE `info` `info` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据';");
            }
            if(!in_array('third_party',$scoreshop_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_scoreshop_order")." ADD `third_party` INT(10) NOT NULL DEFAULT '0' COMMENT '第三方支付:0=否,1=斗拱';");
            }
            if(!in_array('agent_develop_reward',$agentFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_agent")." ADD `agent_develop_reward` TEXT NULL COMMENT '代理发展奖';");
            }

            //v2.2.2601201
            if(!in_array('consume_reward',$coupon_setFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon_set")." ADD `consume_reward` TEXT NULL COMMENT '消费奖励';");
            }
            if(!in_array('team_upgrade_score',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `team_upgrade_score` INT(10) NOT NULL DEFAULT '0' COMMENT '团队商品单位';");
            }
            if(!in_array('sign_release',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `sign_release` INT(10) NOT NULL DEFAULT '0' COMMENT '签到释放:1=开启,0=关闭';");
            }
            if(!in_array('zhitui_user_atransfer',$atransferFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_atransfer")." ADD `zhitui_user_atransfer` INT(10) NOT NULL DEFAULT '0' COMMENT '直推用户业绩转移:1=开启,0=关闭';");
            }
            if(!in_array('f_user_id',$atransfer_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_atransfer_user")." ADD `f_user_id` INT(10) NOT NULL DEFAULT '0' COMMENT '直推用户ID';");
            }
            if(!in_array('type',$atransfer_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_atransfer_user")." ADD `type` INT(10) NOT NULL DEFAULT '0' COMMENT '类型:0=自身直推业绩转移,1=直推用户业绩转移';");
            }
            if(!pdo_tableexists("bbfx_coupon_reward_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_coupon_reward_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `coupon_id` int(10) NOT NULL DEFAULT '0' COMMENT '优惠券ID',
                `consume_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '消费金额',
                `expand` text NOT NULL COMMENT '扩展数据',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $coupon_reward_recordFields = Db::name("bbfx_coupon_reward_record")->getTableFields();
            }
            else{
                $coupon_reward_recordFields = Db::name("bbfx_coupon_reward_record")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_queue_award")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_queue_award")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `queue_goods` text NULL COMMENT '排队商品',
                `queue_award_num` int(10) NOT NULL DEFAULT '0' COMMENT '排队人数',
                `queue_award_rate` int(10) NOT NULL DEFAULT '0' COMMENT '排队奖励比例',
                `is_multiple_queue` int(10) NOT NULL DEFAULT '0' COMMENT '单人多排:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $queue_awardFields = Db::name("bbfx_queue_award")->getTableFields();
            }
            else{
                $queue_awardFields = Db::name("bbfx_queue_award")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_queue_award_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_queue_award_user")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `rank` int(10) NOT NULL COMMENT '排队',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $queue_award_userFields = Db::name("bbfx_queue_award_user")->getTableFields();
            }
            else{
                $queue_award_userFields = Db::name("bbfx_queue_award_user")->getTableFields();
            }
            


            //v2.2.2601221
            if(!in_array('unionid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `unionid` VARCHAR(200) NULL COMMENT '开放平台ID';");
            }
            if(!pdo_tableexists("bbfx_user_suplog")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_suplog")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `ip` varchar(100) NOT NULL COMMENT 'IP',
                `sup_uid` int(10) NOT NULL DEFAULT '0' COMMENT '推荐人ID',
                `utk` varchar(100) DEFAULT NULL COMMENT 'UTK',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_suplogFields = Db::name("bbfx_user_suplog")->getTableFields();
            }
            else{
                $user_suplogFields = Db::name("bbfx_user_suplog")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_jiandan_recommend")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_jiandan_recommend")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $jiandan_recommendFields = Db::name("bbfx_jiandan_recommend")->getTableFields();
            }
            else{
                $jiandan_recommendFields = Db::name("bbfx_jiandan_recommend")->getTableFields();
            }
            if(!in_array('jiandan_recommend_reward',$fenxiao_levelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao_level")." ADD `jiandan_recommend_reward` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '见单推荐奖';");
            }

            //v2.2.2601271
            if(!in_array('is_manual_jiesuan',$paihangbangFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_paihangbang")." ADD `is_manual_jiesuan` INT(10) NOT NULL DEFAULT '0' COMMENT '手动结算:1=开启,0=关闭';");
            }
            if(!pdo_tableexists("bbfx_aabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_aabonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `reward_rate` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励比例（资金池金额的百分比）',
                `rule` text NULL COMMENT '奖励规则',
                `jiesuan_date` int(10) NOT NULL DEFAULT '1' COMMENT '指定发放日期，每月某日',
                `jiesuan_confirm` int(10) NOT NULL DEFAULT '0' COMMENT '结算确认:1=开启,0=关闭',
                `jiesuan_confirm_user` varchar(1000) DEFAULT NULL COMMENT '结算确认用户',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $aabonusFields = Db::name("bbfx_aabonus")->getTableFields();
            }
            else{
                $aabonusFields = Db::name("bbfx_aabonus")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_aabonus_confirm_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_aabonus_confirm_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `sdate` date DEFAULT NULL COMMENT '指定发放日期',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '确认时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $aabonus_confirm_recordFields = Db::name("bbfx_aabonus_confirm_record")->getTableFields();
            }
            else{
                $aabonus_confirm_recordFields = Db::name("bbfx_aabonus_confirm_record")->getTableFields();
            }
            if(!in_array('dg_qx_no',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `dg_qx_no` VARCHAR(100) NULL COMMENT '斗拱取现单号';");
            }
            if(!in_array('yezf_dk',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `yezf_dk` INT(10) NOT NULL DEFAULT '0' COMMENT '汇付余额支付打款:1=是,0=否';");
            }
            if(!in_array('yezf_dk_status',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `yezf_dk_status` INT(10) NOT NULL DEFAULT '0' COMMENT '余额支付状态:0=处理中,1=成功,2=失败';");
            }

            //v2.2.2601281
            if(!in_array('login_password_update_type',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `login_password_update_type` INT(10) NOT NULL DEFAULT '0' COMMENT '登录密码修改方式:0=短信验证修改,1=直接修改';");
            }
            if(!in_array('agent_develop_user_id',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `agent_develop_user_id` INT(10) NOT NULL DEFAULT '0' COMMENT '发展用户ID';");
            }

            //v2.2.26311
            if(!in_array('introduction',$news_articleFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_news_article")." ADD `introduction` VARCHAR(500) NULL COMMENT '文章简介';");
            }
            if(!in_array('login_ip',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `login_ip` VARCHAR(100) NULL COMMENT '登录IP';");
            }
            if(!in_array('ip_gs',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `ip_gs` VARCHAR(100) NULL COMMENT 'IP归属地';");
            }
            if(!in_array('dqtime',$adminFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin")." ADD `dqtime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '到期时间';");
            }
            if(!in_array('pay_tip',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `pay_tip` TEXT NULL COMMENT '支付提示';");
            }
            if(!in_array('pay_call_text',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `pay_call_text` TEXT NULL COMMENT '支付拨号按钮';");
            }
            if(!in_array('wxapp_native_tabbar',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_native_tabbar` INT(10) NOT NULL DEFAULT '0' COMMENT '小程序原生导航:1=开启,0=关闭';");
            }
            if(!in_array('wxapp_native_tabbar_shenhe',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_native_tabbar_shenhe` INT(10) NOT NULL DEFAULT '0' COMMENT '小程序原生导航审核通过:1=是,0=否';");
            }
            if(!in_array('wxapp_tabbar',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_tabbar` TEXT NULL COMMENT '小程序原生导航配置';");
            }

            //v2.2.2602051
            if(!in_array('dg_quxian_fee_rate',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_quxian_fee_rate` DECIMAL(10,2) NOT NULL DEFAULT '0.02' COMMENT '提现手续费率';");
            }
            if(!in_array('icon',$member_cardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_member_card")." ADD `icon` VARCHAR(255) NULL COMMENT '会员卡图标';");
            }
            if(!in_array('platform',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `platform` VARCHAR(100) NULL COMMENT '平台';");
            }
            if(!in_array('dg_quxian_out_fee_flag',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `dg_quxian_out_fee_flag` INT(10) NOT NULL DEFAULT '2' COMMENT '取现手续费:1=外扣,2=内扣';");
            }
            if(!in_array('jiandan_num',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `jiandan_num` INT(10) NOT NULL DEFAULT '0' COMMENT '见单奖限制人数';");
            }
            if(!in_array('reward_source',$queue_awardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_award")." ADD `reward_source` INT(10) NOT NULL DEFAULT '0' COMMENT '奖励来源:0=见单奖';");
            }
            if(!pdo_tableexists("bbfx_goods_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_goods_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=浏览,1=访问',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                `utk` varchar(100) DEFAULT NULL COMMENT 'UTK',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $goods_logFields = Db::name("bbfx_goods_log")->getTableFields();
            }
            else{
                $goods_logFields = Db::name("bbfx_goods_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_user_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=访客',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `utk` varchar(100) DEFAULT NULL COMMENT 'UTK',
                `platform` varchar(100) DEFAULT NULL COMMENT '平台',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_logFields = Db::name("bbfx_user_log")->getTableFields();
            }
            else{
                $user_logFields = Db::name("bbfx_user_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_ddashboard")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_ddashboard")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `title` varchar(255) DEFAULT NULL COMMENT '标题',
                `avatar` varchar(255) DEFAULT NULL COMMENT '头像',
                `background1` varchar(255) DEFAULT NULL COMMENT '背景1',
                `background2` varchar(255) DEFAULT NULL COMMENT '背景2',
                `replace_home` int(10) NOT NULL DEFAULT '0' COMMENT '替换首页:1=开启,0=关闭	',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $ddashboardFields = Db::name("bbfx_ddashboard")->getTableFields();
            }
            else{
                $ddashboardFields = Db::name("bbfx_ddashboard")->getTableFields();
            }

            //v2.2.2602071
            

            //v2.2.2602141
            if(!in_array('publickey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `publickey` VARCHAR(255) NULL COMMENT '公众号微信支付公钥';");
            }
            if(!in_array('wxapp_publickey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_publickey` VARCHAR(255) NULL COMMENT '小程序微信支付公钥';");
            }
            if(!in_array('fenzhang_order_no',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `fenzhang_order_no` VARCHAR(100) NULL COMMENT '分账单号';");
            }
            if(!in_array('fenzhang_status',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `fenzhang_status` INT(10) NOT NULL DEFAULT '-1' COMMENT '分账状态:-1=不分账,0=待分账,1=已分账';");
            }
            if(!in_array('fenzhang_time',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `fenzhang_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '分账时间';");
            }
            if(!in_array('map_show_goods_unit',$ddashboardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_ddashboard")." ADD `map_show_goods_unit` INT(10) NOT NULL DEFAULT '0' COMMENT '地图显示商品单位';");
            }
            if(!in_array('loginfailure',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `loginfailure` INT(10) NOT NULL DEFAULT '0' COMMENT '登录失败次数';");
            }
            if(!in_array('logintime',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `logintime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '登录时间';");
            }
            if(!in_array('payfailure',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `payfailure` INT(10) NOT NULL DEFAULT '0' COMMENT '支付失败次数';");
            }
            if(!in_array('paytime',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `paytime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '支付时间';");
            }
            if(!in_array('ip',$verifcodeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_verifcode")." ADD `ip` VARCHAR(100) NULL COMMENT 'IP';");
            }
            if(!in_array('is_reply',$workorderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_workorder")." ADD `is_reply` INT(10) NOT NULL DEFAULT '0' COMMENT '是否回复:1=是,0=否';");
            }
            if(!in_array('team_reward_layer',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `team_reward_layer` INT(10) NOT NULL DEFAULT '0' COMMENT '团队奖励层数';");
            }
            if(!in_array('backend_notice',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `backend_notice` TEXT NULL COMMENT '后台公告';");
            }
            if(!in_array('backend_notice_image',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `backend_notice_image` VARCHAR(255) NULL COMMENT '后台公告图片';");
            }
            if(!in_array('backend_notice_image_link',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `backend_notice_image_link` VARCHAR(255) NULL COMMENT '后台公告图片链接';");
            }

            //v2.2.2602271
            if(!in_array('is_restore',$admin_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin_log")." ADD `is_restore` INT(10) NOT NULL DEFAULT '0' COMMENT '日志操作:-1=不可恢复,0=待恢复,1=已恢复';");
            }
            if(!in_array('search',$admin_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin_log")." ADD `search` VARCHAR(2000) NULL COMMENT '搜索数据';");
            }
            if(!in_array('share_reward',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `share_reward` TEXT NULL COMMENT '分享奖励';");
            }
            if(!in_array('content_type',$noticeFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_notice")." ADD `content_type` INT(10) NOT NULL DEFAULT '1' COMMENT '内容类型:1=文本,2=链接';");
            }
            if(!in_array('is_accelerate',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `is_accelerate` INT(10) NOT NULL DEFAULT '0' COMMENT '加速返还:1=开启,0=关闭';");
            } 
            if(!in_array('accelerate_rule',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `accelerate_rule` TEXT NULL COMMENT '加速规则';");
            } 
            if(!in_array('status',$return_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_log")." ADD `status` INT(10) NOT NULL DEFAULT '1' COMMENT '状态:0=待到账,1=已到账';");
            } 
            if(!in_array('dztime',$return_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_log")." ADD `dztime` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '到账时间';");
            } 
            if(!pdo_tableexists("bbfx_cumulative_fanhuan_release_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cumulative_fanhuan_release_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '来源ID',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '释放金额',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分',
                `itype` int(10) NOT NULL DEFAULT '0' COMMENT '来源类型:0=释放,1=增益',
                `mtype` int(10) NOT NULL DEFAULT '0' COMMENT '奖励类型',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待到账,1=已到账',
                `dztime` bigint(16) NOT NULL DEFAULT '0' COMMENT '到账时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cumulative_fanhuan_release_logFields = Db::name("bbfx_cumulative_fanhuan_release_log")->getTableFields();
            }
            else{
                $cumulative_fanhuan_release_logFields = Db::name("bbfx_cumulative_fanhuan_release_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_user_share_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_user_share_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=朋友,2=朋友圈',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $user_share_logFields = Db::name("bbfx_user_share_log")->getTableFields();
            }
            else{
                $user_share_logFields = Db::name("bbfx_user_share_log")->getTableFields();
            }

            //v2.2.2603021
            if(!in_array('register_required_sup_uid',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `register_required_sup_uid` INT(10) NOT NULL DEFAULT '0' COMMENT '注册需要绑定上级:1=开启,0=关闭';");
            }
            if(!in_array('is_scorepay',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_scorepay` INT(10) NOT NULL DEFAULT '0' COMMENT '积分支付:1=开启,0=关闭';");
            }
            if(!in_array('score',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `score` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '抵扣积分';");
            }

            //v2.2.2603031
            if(!pdo_tableexists("bbfx_apabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_apabonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `show_month_income` int(10) NOT NULL DEFAULT '0' COMMENT '显示本月管理奖:1=是,0=否',
                `remove_daqu` int(10) NOT NULL DEFAULT '0' COMMENT '去除大区业绩:1=开启,0=关闭',
                `jiesuan_day` int(10) NOT NULL DEFAULT '1' COMMENT '分红结算日',
                `achievement_jisuan` int(10) NOT NULL DEFAULT '1' COMMENT '业绩计算:1=月业绩,2=季业绩,3=年业绩',
                `rule` text NULL COMMENT '规则配置',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $apabonusFields = Db::name("bbfx_apabonus")->getTableFields();
            }
            else{
                $apabonusFields = Db::name("bbfx_apabonus")->getTableFields();
            }

            //v2.2.2603051
            if(!in_array('manabonus_money',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `manabonus_money` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '分红管理奖金额';");
            }
            if(!pdo_tableexists("bbfx_manabonus")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_manabonus")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `rule` text NULL COMMENT '规则配置',
                `jiesuan_day` int(10) NOT NULL DEFAULT '1' COMMENT '分红结算日',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $manabonusFields = Db::name("bbfx_manabonus")->getTableFields();
            }
            else{
                $manabonusFields = Db::name("bbfx_manabonus")->getTableFields();
            }
 
            //v2.2.2603091
            if(!in_array('repurchase_vip_jicha_level',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `repurchase_vip_jicha_level` INT(10) NOT NULL DEFAULT '-1' COMMENT '复购会员级差等级';");
            }

            //v2.2.2603111
            if(!in_array('apabonus_money',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `apabonus_money` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '业绩占比分红金额';");
            }
            if(!in_array('is_auto_dakuan',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `is_auto_dakuan` INT(10) NOT NULL DEFAULT '0' COMMENT '自动打款:1=开启,0=关闭';");
            }
            if(!in_array('huifubafang',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `huifubafang` TEXT NULL DEFAULT NULL COMMENT '汇付八方支付';");
            }
            if(!in_array('auto_tixian',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `auto_tixian` INT(10) NOT NULL DEFAULT '0' COMMENT '自动提现微信:0=关闭,1=开启';");
            }
            if(!in_array('hfbf_dk',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `hfbf_dk` INT(10) NOT NULL DEFAULT '0' COMMENT '汇付八方打款:1=是,0=否';");
            }
            if(!in_array('rule',$queue_awardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_award")." ADD `rule` TEXT NULL DEFAULT NULL COMMENT '规则配置';");
            }
            if(!in_array('rule_index',$queue_award_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_award_user")." ADD `rule_index` INT(10) NOT NULL DEFAULT '-1' COMMENT '规则下标';");
            }
            if(!in_array('goods_id',$queue_award_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_award_user")." ADD `goods_id` INT(10) NOT NULL DEFAULT '0' COMMENT '商品ID';");
            }
            if(!in_array('goods_price',$queue_award_userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_queue_award_user")." ADD `goods_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '商品金额';");
            }
            if(!in_array('year_month_jisuan',$managementFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_management")." ADD `year_month_jisuan` INT(10) NOT NULL DEFAULT '0' COMMENT '年累计月计算:1=开启,0=关闭';");
            }

            //v2.2.2603191
            if(!in_array('is_hide_team_mobile',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `is_hide_team_mobile` INT(10) NOT NULL DEFAULT '0' COMMENT '隐藏团队成员手机号:1=开启,0=关闭';");
            }
            if(!in_array('zhitui_pingji',$pingjiFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pingji")." ADD `zhitui_pingji` INT(10) NOT NULL DEFAULT '0' COMMENT '直推平级:1=开启,0=关闭';");
            }
            if(!in_array('limit_num',$pingjiFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pingji")." ADD `limit_num` INT(10) NOT NULL DEFAULT '0' COMMENT '平级奖限制层数';");
            }

            //v2.2.2603271
            if(!in_array('merchant_commission_rate',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `merchant_commission_rate` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '商户商品分润佣金比例';");
            }
            if(!in_array('hexiao_user_id',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `hexiao_user_id` VARCHAR(2000) NULL DEFAULT NULL COMMENT '核销员';");
            }
            if(!in_array('goods_detail_fontsize',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `goods_detail_fontsize` INT(10) NOT NULL DEFAULT '1' COMMENT '商品详情字体:1=正常';");
            }

            //v2.2.2604111
            if(!in_array('slip_method',$pyramidFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pyramid")." ADD `slip_method` INT(10) NOT NULL DEFAULT '0' COMMENT '滑落方式:0=顺序滑落,1=平均滑落';");
            }
            if(!in_array('slip_method',$repurchase_jiandanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_repurchase_jiandan")." ADD `slip_method` INT(10) NOT NULL DEFAULT '0' COMMENT '滑落方式:0=顺序滑落,1=平均滑落';");
            }

            //v2.2.2604181
            if(in_array('status',$luckywheelFields)){ 
                if(!in_array('lottery_obtain',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_obtain` INT(10) NOT NULL DEFAULT '1' COMMENT '抽奖获取方式:1=购买商品,2=消费金额';");
                }
                if(!in_array('lottery_obtain_rule',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_obtain_rule` text NULL DEFAULT NULL COMMENT '抽奖次数获取规则';");
                }
                if(!in_array('bg',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `bg` varchar(255) DEFAULT NULL COMMENT '抽奖背景';");
                }
                if(!in_array('yp_bg',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `yp_bg` varchar(255) DEFAULT NULL COMMENT '转盘背景';");
                }
                if(!in_array('title_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `title_image` varchar(255) DEFAULT NULL COMMENT '标题图片';");
                }
                if(!in_array('pointer_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `pointer_image` varchar(255) DEFAULT NULL COMMENT '指针图片';");
                }
                if(!in_array('lottery_btn_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_btn_image` varchar(255) DEFAULT NULL COMMENT '抽奖按钮图片';");
                }
                if(!in_array('record_btn_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `record_btn_image` varchar(255) DEFAULT NULL COMMENT '记录按钮图片';");
                }
                if(!in_array('rule_btn_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `rule_btn_image` varchar(255) DEFAULT NULL COMMENT '规则按钮图片';");
                }
                if(!in_array('lottery_rule',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_rule` text NULL DEFAULT NULL COMMENT '抽奖规则';");
                }
                if(!in_array('popup_image',$luckywheelFields)){ 
                    Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `popup_image` varchar(255) DEFAULT NULL COMMENT '弹窗图片';");
                }
            }

            //v2.2.2604211
            if(!in_array('create_method',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `create_method` INT(10) NOT NULL DEFAULT '0' COMMENT '创建方式:0=用户下单,1=后台录单';");
            }
            if(!pdo_tableexists("bbfx_salequota")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_salequota")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `stock` text NULL COMMENT '库存设置                   ',
                `level` varchar(255) DEFAULT NULL COMMENT '库存等级',
                `association_stock` varchar(255) DEFAULT NULL COMMENT '关联库存',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $salequotaFields = Db::name("bbfx_salequota")->getTableFields();
            }
            else{
                $salequotaFields = Db::name("bbfx_salequota")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_salequota_user_stock")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_salequota_user_stock")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                `stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '库存',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $salequota_user_stockFields = Db::name("bbfx_salequota_user_stock")->getTableFields();
            }
            else{
                $salequota_user_stockFields = Db::name("bbfx_salequota_user_stock")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_salequota_user_stock_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_salequota_user_stock_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `stock` int(10) NOT NULL DEFAULT '0' COMMENT '库存',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `before_stock` int(10) NOT NULL DEFAULT '0' COMMENT '变动前',
                `after_stock` int(10) NOT NULL DEFAULT '0' COMMENT '变动后',
                `info` longtext NULL COMMENT '数据',
                `item_id` int(10) NOT NULL DEFAULT '0' COMMENT '项目ID',
                `item_type` int(10) NOT NULL DEFAULT '0' COMMENT '项目类型',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $salequota_user_stock_logFields = Db::name("bbfx_salequota_user_stock_log")->getTableFields();
            }
            else{
                $salequota_user_stock_logFields = Db::name("bbfx_salequota_user_stock_log")->getTableFields();
            }


            //v2.2.2604221
            if(!in_array('tx_tip',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `tx_tip` TEXT NULL DEFAULT NULL COMMENT '提现提示';");
            }
            if(!in_array('manual_abonus',$capitalpoolFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_capitalpool")." ADD `manual_abonus` TEXT NULL DEFAULT NULL COMMENT '手动分红';");
            }
            if($bbfx['sversion'] == 222604211 && in_array('level',$salequotaFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_salequota")." CHANGE `level` `level` VARCHAR(255) NULL DEFAULT NULL COMMENT '库存等级';");
            }

            //v2.2.2604251
            if(!in_array('is_achievement_jisuan',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `is_achievement_jisuan` INT(10) NOT NULL DEFAULT '1' COMMENT '业绩计算:1=开启.0=关闭';");
            }
            if(!in_array('reason',$recharge_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_recharge_order")." ADD `reason` VARCHAR(500) NULL DEFAULT NULL COMMENT '拒绝原因';");
            }
            if(!in_array('info',$cumulative_fanhuan_release_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan_release_log")." ADD `info` LONGTEXT NULL DEFAULT NULL COMMENT '数据';");
            }

            //v2.2.2604291
            if(!in_array('discount_bargain_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `discount_bargain_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '砍价优惠';");
            }
            if(!in_array('discount_bargain_price',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `discount_bargain_price` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '砍价优惠';");
            }
            if(!in_array('bargain_goods_id',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `bargain_goods_id` INT(10) NOT NULL DEFAULT '0' COMMENT '砍价商品ID';");
            }
            if(!in_array('is_bargain_order',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_bargain_order` INT(10) NOT NULL DEFAULT '0' COMMENT '砍价订单:1=是,0=否';");
            }
            if(!in_array('is_manual_abonus',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `is_manual_abonus` INT(10) NOT NULL DEFAULT '1' COMMENT '手动分红:1=开启,0=关闭';");
            }
            if(!pdo_tableexists("bbfx_bargain")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_bargain")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `slide` text NULL COMMENT '轮播图',
                `description` longtext NULL COMMENT '砍价说明',
                `qun_qrcode` varchar(255) DEFAULT NULL COMMENT '群二维码',
                `qun_banner` varchar(255) DEFAULT NULL COMMENT '群背景',
                `slide1` text NULL COMMENT '轮播图1',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $bargainFields = Db::name("bbfx_bargain")->getTableFields();
            }
            else{
                $bargainFields = Db::name("bbfx_bargain")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_bargain_goods")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_bargain_goods")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                `buy_interval_day` int(10) NOT NULL DEFAULT '0' COMMENT '购买间隔天数',
                `effective_day` int(10) NOT NULL DEFAULT '0' COMMENT '有效天数',
                `stock` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '砍价库存',
                `s_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '起始价格',
                `e_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '最低价',
                `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '当前价格',
                `rule` text NULL COMMENT '砍价规则',
                `check_num` int(10) NOT NULL DEFAULT '0' COMMENT '查看数量',
                `virtual_check_num` int(10) NOT NULL DEFAULT '0' COMMENT '虚拟浏览',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=上架.0=下架',
                `stime` bigint(16) NOT NULL DEFAULT '0' COMMENT '开始时间',
                `etime` bigint(16) NOT NULL DEFAULT '0' COMMENT '结束时间',
                `use_desc` text NULL COMMENT '使用说明',
                `updatetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '更新时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $bargain_goodsFields = Db::name("bbfx_bargain_goods")->getTableFields();
            }
            else{
                $bargain_goodsFields = Db::name("bbfx_bargain_goods")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_bargain_goods_category")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_bargain_goods_category")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $bargain_goods_categoryFields = Db::name("bbfx_bargain_goods_category")->getTableFields();
            }
            else{
                $bargain_goods_categoryFields = Db::name("bbfx_bargain_goods_category")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_bargain_goods_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_bargain_goods_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品ID',
                `bargain_goods_id` int(10) NOT NULL DEFAULT '0' COMMENT '砍价商品ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '砍价金额',
                `o_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '原价',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $bargain_goods_logFields = Db::name("bbfx_bargain_goods_log")->getTableFields();
            }
            else{
                $bargain_goods_logFields = Db::name("bbfx_bargain_goods_log")->getTableFields();
            }

            //v2.2.2605131
            if(!pdo_tableexists("bbfx_image_check")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_image_check")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `accessKeyId` varchar(100) DEFAULT NULL COMMENT '阿里云accessKeyId',
                `accessKeySecret` varchar(100) DEFAULT NULL COMMENT '阿里云accessKeySecret',
                `endpoint` varchar(255) NOT NULL DEFAULT 'green-cip.cn-beijing.aliyuncs.com' COMMENT '支持地域',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $image_checkFields = Db::name("bbfx_image_check")->getTableFields();
            }
            else{
                $image_checkFields = Db::name("bbfx_image_check")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_image_check_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_image_check_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `url` varchar(255) DEFAULT NULL COMMENT '图片链接',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待检测,1=通过,2=拒绝',
                `result` text NULL COMMENT '检测结果',
                `checktime` bigint(16) NOT NULL DEFAULT '0' COMMENT '检测时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $image_check_logFields = Db::name("bbfx_image_check_log")->getTableFields();
            }
            else{
                $image_check_logFields = Db::name("bbfx_image_check_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_pintuan_miandan")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_pintuan_miandan")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $pintuan_miandanFields = Db::name("bbfx_pintuan_miandan")->getTableFields();
            }
            else{
                $pintuan_miandanFields = Db::name("bbfx_pintuan_miandan")->getTableFields();
            }
            if(!in_array('dyapp_openid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dyapp_openid` VARCHAR(100) NULL DEFAULT NULL COMMENT '抖音openid';");
            }
            if(!in_array('dy_unionid',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `dy_unionid` VARCHAR(100) NULL DEFAULT NULL COMMENT '抖音开放平台ID';");
            }
            if(!in_array('douyin',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `douyin` TEXT NULL DEFAULT NULL COMMENT '抖音配置';");
            }
            if(!in_array('check_status',$attachmentFields)){ 
                Db::execute("ALTER TABLE ".tablename("attachment")." ADD `check_status` INT(10) NOT NULL DEFAULT '1' COMMENT '图片检测:1=通过,0=拒绝';");
            }
            if($bbfx['sversion'] <= 222605061 && !in_array('sh_data',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD CHANGE `sh_data` `sh_data` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核数据';");
            }
            if(!in_array('is_sync_stock',$pintuan_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pintuan_goods")." ADD `is_sync_stock` INT(10) NOT NULL DEFAULT '0' COMMENT '同步库存:1=开启,0=关闭';");
            }
            if(!in_array('transfer_status',$coupon_setFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon_set")." ADD `transfer_status` INT(10) NOT NULL DEFAULT '0' COMMENT '转赠状态:1=开启,0=关闭';");
            }
            if(!in_array('score_exchange',$coupon_setFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon_set")." ADD `score_exchange` INT(10) NOT NULL DEFAULT '0' COMMENT '积分兑换:1=开启,0=关闭';");
            }
            if(!in_array('is_repurchase_currency_deduct',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `is_repurchase_currency_deduct` INT(10) NOT NULL DEFAULT '1' COMMENT '复购金抵扣:1=开启,0=关闭';");
            }
            if(!in_array('obtain_method',$couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon")." ADD `obtain_method` INT(10) NOT NULL DEFAULT '0' COMMENT '获取方式:0=其他,1=免费领取,2=积分兑换';");
            }
            if(!in_array('dh_score',$couponFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon")." ADD `dh_score` INT(10) NOT NULL DEFAULT '0' COMMENT '兑换积分';");
            }
            if(!in_array('mid',$pintuan_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pintuan_goods")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID';");
            }
            if(!in_array('mid',$pintuan_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pintuan_order")." ADD `mid` INT(10) NOT NULL DEFAULT '0' COMMENT '商户ID';");
            }
            if(!in_array('pintuan_miandan_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `pintuan_miandan_status` INT(10) NOT NULL DEFAULT '-1' COMMENT '拼团免单:-1=否,0=未拼中,1=拼中';");
            }
            if(!in_array('strikeout_rewards',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `strikeout_rewards` VARCHAR(500) NULL DEFAULT NULL COMMENT '出局倍数奖励';");
            }

            //v2.2.2605181
            if(!pdo_tableexists("bbfx_payroute")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_payroute")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $payrouteFields = Db::name("bbfx_payroute")->getTableFields();
            }
            else{
                $payrouteFields = Db::name("bbfx_payroute")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_payroute_pay")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_payroute_pay")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `level` int(10) NOT NULL DEFAULT '0' COMMENT '分销等级',
                `pay` text NULL COMMENT '支付配置',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $payroute_payFields = Db::name("bbfx_payroute_pay")->getTableFields();
            }
            else{
                $payroute_payFields = Db::name("bbfx_payroute_pay")->getTableFields();
            }
            if(!in_array('payroute_id',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `payroute_id` INT(10) NOT NULL DEFAULT '0' COMMENT '支付ID';");
            }
            if(!in_array('payroute_level',$pay_orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_pay_order")." ADD `payroute_level` INT(10) NOT NULL DEFAULT '-1' COMMENT '支付用户等级';");
            }

            //v2.2.2605231
            if(!pdo_tableexists("bbfx_ladderpush")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_ladderpush")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `is_ladder_push_loop` int(10) NOT NULL DEFAULT '0' COMMENT '阶梯循环:1=开启,0=关闭',
                `rule` text NULL COMMENT '阶梯规则',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $ladderpushFields = Db::name("bbfx_ladderpush")->getTableFields();
            }
            else{
                $ladderpushFields = Db::name("bbfx_ladderpush")->getTableFields();
            }
            if(!in_array('slide2',$bargainFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_bargain")." ADD `slide2` TEXT NULL DEFAULT NULL COMMENT '轮播图';");
            }
            if(!in_array('zhiding',$bargain_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_bargain_goods")." ADD `zhiding` INT(10) NOT NULL DEFAULT '0' COMMENT '置顶:1=是,0=否';");
            }
            if(in_array('lottery_obtain',$luckywheelFields) && $bbfx['sversion'] <= 222605221){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." CHANGE `lottery_obtain` `lottery_obtain` VARCHAR(255) NOT NULL DEFAULT '1' COMMENT '抽奖获取方式:1=购买商品,2=消费金额';");
            }
            if(!in_array('lottery_method',$luckywheelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_method` VARCHAR(255) NOT NULL DEFAULT '1' COMMENT '抽奖方式:1=次数抽奖,2=积分抽奖';");
            }
            if(!in_array('lottery_score',$luckywheelFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel")." ADD `lottery_score` INT(10) NOT NULL DEFAULT '0' COMMENT '抽奖积分';");
            }
            if(!in_array('lottery_method',$luckywheel_lottery_recordFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_luckywheel_lottery_record")." ADD `lottery_method` INT(10) NOT NULL DEFAULT '1' COMMENT '抽奖方式:1=次数抽奖,2=积分抽奖';");
            }
            if(in_array('share_title',$goodsFields) && $bbfx['sversion'] <= 222605221){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." CHANGE `share_title` `share_title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分享标题';");
            }
            if(!in_array('ai_nickname',$qwenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_qwen")." ADD `ai_nickname` VARCHAR(255) NOT NULL DEFAULT 'AI助手' COMMENT 'AI昵称';");
            }

            //v2.2.2606041
            if(!in_array('strikeout_goods',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `strikeout_goods` TEXT NULL DEFAULT NULL COMMENT '出局倍数商品';");
            }
            if(!in_array('deduct_stock',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `deduct_stock` INT(10) NOT NULL DEFAULT '1' COMMENT '扣除库存:1=是,0=否';");
            }
            if(!in_array('password',$ddashboardFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_ddashboard")." ADD `password` VARCHAR(100) NULL DEFAULT NULL COMMENT '访问密码';");
            }
            if(!in_array('pt_commission',$merchantFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_merchant")." ADD `pt_commission` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '平台抽成比例';");
            }
            if(!in_array('cashlottery_lottery_num',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `cashlottery_lottery_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '现金抽奖次数';");
            }
            if(!pdo_tableexists("bbfx_cashlottery")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cashlottery")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `lottery_method` varchar(255) DEFAULT NULL COMMENT '抽奖方式:0=每天抽奖(1次),1=消费抽奖',
                `lottery_consume_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '抽奖消费金额',
                `lottery_stime` bigint(16) NOT NULL DEFAULT '0' COMMENT '抽奖开启时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cashlotteryFields = Db::name("bbfx_cashlottery")->getTableFields();
            }
            else{
                $cashlotteryFields = Db::name("bbfx_cashlottery")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_cashlottery_reward")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cashlottery_reward")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=固定奖励,1=随机奖励',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励金额',
                `min` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励金额',
                `max` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励金额',
                `probability` int(10) NOT NULL DEFAULT '0' COMMENT '抽中权重概率',
                `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cashlottery_rewardFields = Db::name("bbfx_cashlottery_reward")->getTableFields();
            }
            else{
                $cashlottery_rewardFields = Db::name("bbfx_cashlottery_reward")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_cashlottery_reward_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_cashlottery_reward_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `out_batch_no` varchar(100) DEFAULT NULL COMMENT '提现单号',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `lottery_method` int(10) NOT NULL DEFAULT '0' COMMENT '抽奖方式:0=每天免费次数抽奖,1=消费金额次数抽奖',
                `tixian_method` int(10) NOT NULL DEFAULT '0' COMMENT '提现方式:0=提现余额,1=提现到微信零钱',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '奖励ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '奖励类型',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励金额',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待审核,1=已打款,2=已驳回',
                `is_confirm` int(10) NOT NULL DEFAULT '-1' COMMENT '确认收款:-1=未打款,0=待收款,1=已收款',
                `confirmtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '收款时间',
                `paytime` bigint(16) NOT NULL DEFAULT '0' COMMENT '打款时间',
                `info` text NULL COMMENT '数据',
                `batch_id` varchar(100) DEFAULT NULL COMMENT '提现批次ID',
                `package_info` text NULL COMMENT '提现数据',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $cashlottery_reward_recordFields = Db::name("bbfx_cashlottery_reward_record")->getTableFields();
            }
            else{
                $cashlottery_reward_recordFields = Db::name("bbfx_cashlottery_reward_record")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_site_message")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_site_message")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `content` longtext NULL COMMENT '内容',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $site_messageFields = Db::name("bbfx_site_message")->getTableFields();
            }
            else{
                $site_messageFields = Db::name("bbfx_site_message")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_site_message_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_site_message_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `admin_id` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=站内消息,2=系统消息',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $site_message_logFields = Db::name("bbfx_site_message_log")->getTableFields();
            }
            else{
                $site_message_logFields = Db::name("bbfx_site_message_log")->getTableFields();
            }

            //v2.2.2606081
            if(!hasIndex("bbfx_user_log","aid_p_u_u")){
                Db::execute("ALTER TABLE ".tablename("bbfx_user_log")." ADD INDEX aid_p_u_u (`uniacid`,`platform`,`user_id`,`utk`);");
            }

            //v2.2.2606xx1
            if(!in_array('openid',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `openid` VARCHAR(100) NULL DEFAULT NULL COMMENT '用户标识';");
            }
            if(!in_array('platform',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `platform` VARCHAR(20) NULL DEFAULT NULL COMMENT '提现平台';");
            }
            if($bbfx['sversion'] <= 222606081 && in_array('wxapp_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." CHANGE `wxapp_login` `wxapp_login` VARCHAR(100) NOT NULL DEFAULT '0' COMMENT '小程序端登录:0=小程序登录,1=验证码登录,2=手机号授权登录,3=账号密码登录';");
            }
            if($bbfx['sversion'] <= 222606081 && in_array('h5_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." CHANGE `h5_login` `h5_login` VARCHAR(100) NOT NULL DEFAULT '1' COMMENT 'H5登录:1=验证码登录,3=账号密码登录';");
            }
            if($bbfx['sversion'] <= 222606081 && in_array('app_login',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." CHANGE `app_login` `app_login` VARCHAR(100) NOT NULL DEFAULT '1' COMMENT 'app登录:1=验证码登录,3=账号密码登录';");
            }
            if(!in_array('yuyue_status',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `yuyue_status` INT(10) NOT NULL DEFAULT '0' COMMENT '预约状态:1=开启,0=关闭';");
            }
            if(!in_array('yuyue_valid_day',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `yuyue_valid_day` INT(10) NOT NULL DEFAULT '0' COMMENT '预约有效天数';");
            }
            if(!in_array('yuyue_status',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `yuyue_status` INT(10) NOT NULL DEFAULT '0' COMMENT '预约状态:1=开启,0=关闭';");
            }
            if(!in_array('yuyu_time_period',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `yuyu_time_period` VARCHAR(1000) NULL DEFAULT NULL COMMENT '预约时间段';");
            }
            if(!pdo_tableexists("bbfx_order_yuyue")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_order_yuyue")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID', 
                `order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单ID', 
                `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID', 
                `yy_stime` bigint(16) NOT NULL DEFAULT '0' COMMENT '预约开始时间', 
                `yy_etime` bigint(16) NOT NULL DEFAULT '0' COMMENT '预约结束时间', 
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID', 
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待核销,1=已核销', 
                `hx_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '核销时间', 
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $order_yuyueFields = Db::name("bbfx_order_yuyue")->getTableFields();
            }
            else{
                $order_yuyueFields = Db::name("bbfx_order_yuyue")->getTableFields();
            }
            if(!in_array('wxapp_merchant_AppId',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_merchant_AppId` VARCHAR(100) NULL DEFAULT NULL COMMENT '商户端小程序AppId';");
            }
            if(!in_array('wxapp_merchant_AppSecret',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_merchant_AppSecret` VARCHAR(100) NULL DEFAULT NULL COMMENT '商户端小程序上传秘钥';");
            }
            if(!in_array('wxapp_merchant_upload_privateKey',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `wxapp_merchant_upload_privateKey` VARCHAR(255) NULL DEFAULT NULL COMMENT '商户端小程序AppSecret';");
            }
            if(!in_array('up_condition_mode',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `up_condition_mode` INT(10) NOT NULL DEFAULT '0' COMMENT '升级条件模式:1=对外分销模式,0=内部分销模式';");
            }
            if(!in_array('up_condition_mode_sign_result',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `up_condition_mode_sign_result` INT(10) NOT NULL DEFAULT '0' COMMENT '条件模式协议选择结果:0=未签订,1=同意,2=拒绝';");
            }
            if(!in_array('plugin_xieyi',$baseFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_base")." ADD `plugin_xieyi` VARCHAR(500) NULL DEFAULT NULL COMMENT '插件协议同意';");
            }
            if(!in_array('achievement_rate',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `achievement_rate` DECIMAL(10,2) NOT NULL DEFAULT '0' COMMENT '业绩返还比例';");
            }
            if(!in_array('directpush_achievement_level',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `directpush_achievement_level` VARCHAR(255) NULL DEFAULT NULL COMMENT '直推业绩等级';");
            }
            if(!in_array('team_building_level',$fenxiaoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_fenxiao")." ADD `team_building_level` VARCHAR(500) NULL DEFAULT NULL COMMENT '团队业绩奖等级';");
            }

            //v2.2.2606181
            if($bbfx['sversion'] <= 222606181 && in_array('apikey',$qwenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_qwen")." CHANGE `apikey` `apikey` VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'API KEY';");
            }
            if($bbfx['sversion'] <= 222606181 && in_array('apikey',$shuzirenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren")." CHANGE `apikey` `apikey` VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'API KEY';");
            }
            if(!in_array('use_way',$shuzirenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren")." ADD `use_way` INT(10) NOT NULL DEFAULT '1' COMMENT '使用方式:1=达到等级,2=消耗次数';");
            }
            if(!in_array('shuziren_num',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `shuziren_num` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生成数字人次数';");
            }
            if(!in_array('main_recommendation_goods',$shuzirenFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren")." ADD `main_recommendation_goods` VARCHAR(255) NULL DEFAULT NULL COMMENT '主推商品';");
            }
            if(!in_array('plugin_shuziren',$goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_goods")." ADD `plugin_shuziren` INT(10) NOT NULL DEFAULT '0' COMMENT '数字人:0=关闭,1=开启';");
            }

            //v2.2.2606241
            if(!pdo_tableexists("bbfx_contribute_vadded")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contribute_vadded")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `current_contribute` decimal(16,6) UNSIGNED NOT NULL DEFAULT '0.000000' COMMENT '当前贡献分',
                `current_price` decimal(16,6) UNSIGNED NOT NULL DEFAULT '0.000000' COMMENT '当前价格',
                `user_contribute_total` decimal(16,6) UNSIGNED NOT NULL DEFAULT '0.000000' COMMENT '增值池',
                `rewards` varchar(500) DEFAULT NULL COMMENT '奖金选择',
                `withdrawal` text NULL COMMENT '提现配置',
                `reward_rate` int(10) NOT NULL DEFAULT '200' COMMENT '奖励比例',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contribute_vaddedFields = Db::name("bbfx_contribute_vadded")->getTableFields();
            }
            else{
                $contribute_vaddedFields = Db::name("bbfx_contribute_vadded")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_contribute_vadded_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contribute_vadded_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型',
                `money` decimal(16,6) NOT NULL DEFAULT '0.000000' COMMENT '变动贡献分',
                `before` decimal(16,6) NOT NULL DEFAULT '0.000000' COMMENT '变动前',
                `after` decimal(16,6) NOT NULL DEFAULT '0.000000' COMMENT '变动后',
                `remark` varchar(100) DEFAULT NULL COMMENT '备注',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
                `info` longtext NULL COMMENT '数据',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contribute_vadded_logFields = Db::name("bbfx_contribute_vadded_log")->getTableFields();
            }
            else{
                $contribute_vadded_logFields = Db::name("bbfx_contribute_vadded_log")->getTableFields();
            }
            if(!in_array('fail_reason',$shuziren_videoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren_video")." ADD `fail_reason` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '失败原因';");
            }
            if(!in_array('contribute_vadded',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." ADD `contribute_vadded` DECIMAL(16,6) NOT NULL DEFAULT '0' COMMENT '提现贡献分';");
            }
            if(!in_array('contribute_vadded_status',$transfer_accountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account")." ADD `contribute_vadded_status` INT(10) NOT NULL DEFAULT '0' COMMENT '贡献分转账:1=开启,0=关闭';");
            }
            if(!in_array('service_charges3',$transfer_accountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account")." ADD `service_charges3` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献分转账手续费';");
            }
            if(!in_array('contribute_vadded',$userFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_user")." ADD `contribute_vadded` DECIMAL(16,6) UNSIGNED NOT NULL DEFAULT '0' COMMENT '贡献分';");
            }
            if($bbfx['sversion'] <= 222606241 && in_array('money',$money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_money_log")." CHANGE `money` `money` DECIMAL(16,6) NOT NULL DEFAULT '0.00' COMMENT '变动金额';");
            }
            if($bbfx['sversion'] <= 222606241 && in_array('befores',$money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_money_log")." CHANGE `befores` `befores` DECIMAL(16,6) NOT NULL DEFAULT '0.00' COMMENT '变动前';");
            }
            if($bbfx['sversion'] <= 222606241 && in_array('afters',$money_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_money_log")." CHANGE `afters` `afters` DECIMAL(16,6) NOT NULL DEFAULT '0.00' COMMENT '变动后';");
            }
            if($bbfx['sversion'] <= 222606241 && in_array('money',$withdrawal_logFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_withdrawal_log")." CHANGE `money` `money` DECIMAL(16,6) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '提现金额';");
            }
            if(!in_array('type',$shuziren_voiceFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren_voice")." ADD `type` INT(10) NOT NULL DEFAULT '1' COMMENT '类型:0=系统,1=用户';");
            }
            if(!in_array('lang',$shuziren_videoFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_shuziren_video")." ADD `lang` VARCHAR(10) NULL DEFAULT NULL COMMENT '语言';");
            }
            
            //v2.2.2607031
            if(!in_array('is_crossline',$coupon_setFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_coupon_set")." ADD `is_crossline` INT(10) NOT NULL DEFAULT '0' COMMENT '跨线转赠:1=开启,0=关闭';");
            }
            if(!in_array('return_score_rate',$return_ruleFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_rule")." ADD `return_score_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '返还积分';");
            }
            if(!in_array('return_score_day',$return_ruleFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return_rule")." ADD `return_score_day` INT(10) NOT NULL DEFAULT '0' COMMENT '积分返还天数';");
            }
            if(!in_array('return_day_score',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `return_day_score` INT(10) NOT NULL DEFAULT '0' COMMENT '返还天数(积分)'");  
            }
            if($bbfx['sversion'] <= 222607031 && in_array('currency',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." CHANGE `currency` `currency` VARCHAR(100) NOT NULL DEFAULT '1' COMMENT '返还币种:1=余额,2=积分'");  
            }
            if($bbfx['sversion'] <= 222607031 && in_array('currency',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." CHANGE `currency` `currency` VARCHAR(100) NOT NULL DEFAULT '1' COMMENT '返还币种:1=余额,2=积分'");  
            }
            if(!in_array('consume_rate',$contribute_vaddedFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_contribute_vadded")." ADD `consume_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '自购贡献分比例'");  
            }

            //v2.2.2607111
            if(!in_array('fundpool_rate',$contribute_vaddedFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_contribute_vadded")." ADD `fundpool_rate` INT(10) NOT NULL DEFAULT '0' COMMENT '增值池比例'");  
            }
            if(!in_array('contribute_vadded_price',$orderFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order")." ADD `contribute_vadded_price` DECIMAL(16,6) NOT NULL DEFAULT '-1' COMMENT '贡献分价格(-1=未读取)'");  
            }
            if(!in_array('type',$repurchase_jiandanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_repurchase_jiandan")." ADD `type` INT(10) NOT NULL DEFAULT '1' COMMENT '类型:1=标准模式,2=逐级模式'");  
            }
            if(!in_array('achievement_return_limit',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `achievement_return_limit` INT(10) NOT NULL DEFAULT '0' COMMENT '业绩加权返还限制比例'");  
            }
            if(!pdo_tableexists("bbfx_contribute_vadded_exchange_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_contribute_vadded_exchange_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '1' COMMENT '类型:1=余额,2=积分',
                `contribute_vadded` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '兑换贡献分',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '兑换总金额',
                `realmoney` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '实际到账',
                `service_charge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '手续费',
                `createtime` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $contribute_vadded_exchange_logFields = Db::name("bbfx_contribute_vadded_exchange_log")->getTableFields();
            }
            else{
                $contribute_vadded_exchange_logFields = Db::name("bbfx_contribute_vadded_exchange_log")->getTableFields();
            }

            //v2.2.2607131
            if(!in_array('rule_detailed',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `rule_detailed` INT(10) NOT NULL DEFAULT '0' COMMENT '详细规则:1=开启,0=关闭'");  
            }
            if(!in_array('rule_content',$cumulative_fanhuanFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cumulative_fanhuan")." ADD `rule_content` TEXT NULL DEFAULT NULL COMMENT '详细规则'");  
            }
            if(!in_array('everyday_lottery_incentivead',$cashlotteryFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_cashlottery")." ADD `everyday_lottery_incentivead` INT(10) NOT NULL DEFAULT '0' COMMENT '每天抽奖看激励广告:1=开启,0=关闭'");  
            }
            if(!pdo_tableexists("bbfx_incentivead")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_incentivead")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `ad_id` varchar(500) DEFAULT NULL COMMENT '广告ID',
                `view_count` int(10) NOT NULL DEFAULT '0' COMMENT '观看次数',
                `reward_score` int(10) NOT NULL DEFAULT '0' COMMENT '奖励积分',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $incentiveadFields = Db::name("bbfx_incentivead")->getTableFields();
            }
            else{
                $incentiveadFields = Db::name("bbfx_incentivead")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_incentivead_view_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_incentivead_view_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:0=奖励积分',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励积分',
                `createtime` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $incentivead_view_logFields = Db::name("bbfx_incentivead_view_log")->getTableFields();
            }
            else{
                $incentivead_view_logFields = Db::name("bbfx_incentivead_view_log")->getTableFields();
            }

            //v2.2.2607231
            if($bbfx['sversion'] <= 222607231){
                Db::name("bbfx_auth")->where(['id'=>['>',0]])->delete();
                Db::execute("INSERT INTO ".tablename("bbfx_auth")." (`id`, `name`, `pid`, `rule`, `type`, `sort`) VALUES
                (1, '数据总览', 0, '/dashboard', 0, 170),
                (2, '用户管理', NULL, '/user', 0, 160),
                (3, '用户列表', 2, '/user/index', 0, 0),
                (4, '余额提现', 355, '/finance/withdrawal/withdrawal', 0, 0),
                (5, '商品管理', NULL, '/goods', 0, 150),
                (6, '商品列表', 5, '/goods/index', 0, 0),
                (8, '商品分类', 5, '/goods/categroy', 0, 0),
                (9, '订单管理', NULL, '/order', 0, 140),
                (10, '订单列表', 9, '/order/index', 0, 0),
                (15, '售后订单', 9, '/order/sales', 0, 0),
                (17, '分销基础', 0, '/fenxiao', 0, 130),
                (18, '全局配置', 17, '/fenxiao/index', 0, 0),
                (19, '分销用户', 2, '/user/user', 0, 0),
                (20, '等级配置', 17, '/fenxiao/level', 0, 0),
                (21, '提现管理', 355, '/finance/withdrawal/commissionWithdrawal', 0, 0),
                (22, '海报配置', 17, '/fenxiao/poster', 0, 0),
                (23, '分销树', 17, '/fenxiao/tree', 0, 0),
                (24, '分销订单', 19, 'fenxiao/order/list', 1, 0),
                (25, '应用管理', NULL, '/plugin/index', 0, 120),
                (26, '积分商城', 25, '/scoreshop/index', 0, 110),
                (27, '基本设置', 26, '/scoreshop', 0, 0),
                (28, '商品管理', 26, '/scoreshop/goods', 0, 0),
                (29, '商品分类', 26, '/scoreshop/category', 0, 0),
                (30, '兑换记录', 26, '/scoreshop/order', 0, 0),
                (31, '资金转账', 25, '/transfer_account/index', 0, 100),
                (32, '区域代理', 25, '/agent/index', 0, 90),
                (33, '基本设置', 32, '/agent', 0, 0),
                (34, '代理用户', 32, '/agent/user', 0, 0),
                (35, '返还奖', 25, '/return/index', 0, 80),
                (36, '基础设置', 35, '/return', 0, 0),
                (37, '返还列表', 35, '/return/list', 0, 0),
                (38, '返还记录', 35, '/return/log', 0, 0),
                (39, '链动2+1模式', 25, '/transfer21_mode/index', 0, 70),
                (40, '链动3+1模式', 25, '/transfer_mode/index', 0, 60),
                (41, '加权分红', 25, '/abonus/index', 0, 50),
                (42, '页面装修', 0, '/diypage', 0, 40),
                (43, '权限管理', NULL, '/auth', 0, 30),
                (44, '管理员', 43, '/auth/index', 0, 0),
                (45, '角色管理', 43, '/auth/role', 0, 0),
                (46, '权限列表', 43, '/auth/auth', 0, 0),
                (47, '商城配置', 0, '/config', 0, 1),
                (48, '基础配置', 47, '/config/basics', 0, 0),
                (49, '支付相关', 47, '/config/pay', 0, 0),
                (50, '消息通知', 47, '/config/message', 0, 0),
                (51, '充值', 3, 'user/recharge/post', 1, 0),
                (52, '删除', 3, 'user/user/delete', 1, 0),
                (53, '修改状态', 3, 'user/user/status', 1, 0),
                (56, '提现审核', 4, 'user/withdrawal/check', 1, 0),
                (57, '设置状态', 6, 'goods/goods/status', 1, 0),
                (58, '删除', 6, 'goods/goods/delete', 1, 0),
                (59, '编辑', 6, 'goods/goods/post', 1, 0),
                (60, '设置状态', 8, 'goods/category/status', 1, 0),
                (61, '删除', 8, 'goods/category/delete', 1, 0),
                (62, '编辑', 8, 'goods/category/post', 1, 0),
                (63, '添加卡密', 6, 'goods/serialNumber/post', 1, 0),
                (64, '删除卡密', 6, 'goods/serialNumber/delete', 1, 0),
                (65, '订单详情', 10, 'order/order/detail', 1, 0),
                (66, '订单发货', 10, 'order/order/send', 1, 0),
                (67, '修改收货信息', 10, 'order/order/updateDeliver', 1, 0),
                (68, '订单收货', 10, 'order/order/takeDelivery', 1, 0),
                (69, '订单退款', 10, 'order/order/refund', 1, 0),
                (70, '编辑', 18, 'fenxiao/config/set', 1, 0),
                (71, '设置分销商', 19, 'fenxiao/user/setSupuser', 1, 0),
                (72, '删除身份', 19, 'fenxiao/user/delete', 1, 0),
                (73, '删除', 20, 'fenxiao/level/delete', 1, 0),
                (74, '编辑', 20, 'fenxiao/level/post', 1, 0),
                (75, '提现审核', 21, 'fenxiao/withdrawal/check', 1, 0),
                (76, '删除', 22, 'fenxiao/poster/delete', 1, 0),
                (77, '编辑', 22, 'fenxiao/poster/post', 1, 0),
                (78, '基本设置编辑', 27, 'scoreshop/config/set', 1, 0),
                (79, '删除', 28, 'scoreshop/goods/delete', 1, 0),
                (80, '设置状态', 28, 'scoreshop/goods/status', 1, 0),
                (81, '编辑', 28, 'scoreshop/goods/post', 1, 0),
                (82, '添加卡密', 28, 'scoreshop/goods/serialnumberPost', 1, 0),
                (83, '删除卡密', 28, 'scoreshop/goods/serialnumberDel', 1, 0),
                (84, '设置状态', 29, 'scoreshop/category/status', 1, 0),
                (85, '删除', 29, 'scoreshop/category/delete', 1, 0),
                (86, '编辑', 29, 'scoreshop/category/post', 1, 0),
                (87, '兑换详情', 30, 'scoreshop/order/detail', 1, 0),
                (88, '退款', 30, 'scoreshop/order/refund', 1, 0),
                (89, '发货', 30, 'scoreshop/order/send', 1, 0),
                (90, '收货', 30, 'scoreshop/order/takeDelivery', 1, 0),
                (91, '修改收货信息', 30, 'scoreshop/order/updateDeliver', 1, 0),
                (92, '修改备注', 30, 'scoreshop/order/updateRemarks', 1, 0),
                (93, '基本设置编辑', 31, 'transfer_account/config/set', 1, 0),
                (94, '代理设置编辑', 33, 'agent/config/set', 1, 0),
                (95, '删除区域代理身份', 34, 'agent/user/delete', 1, 0),
                (96, '修改状态', 34, 'agent/user/status', 1, 0),
                (97, '基本设置编辑', 36, 'return/config/set', 1, 0),
                (98, '基本设置编辑', 39, 'transfer_mode/config/set', 1, 0),
                (99, '基础设置编辑', 41, 'abonus/config/set', 1, 0),
                (100, '设置默认页面', 304, 'diypage/index/setDefault', 1, 0),
                (101, '删除', 304, 'diypage/index/delete', 1, 0),
                (102, '编辑', 304, 'diypage/index/post', 1, 0),
                (103, '装修', 304, 'diypage/index/updateDiypage', 1, 0),
                (104, '删除', 46, 'auth/authDel', 1, 0),
                (105, '编辑', 46, 'auth/authPost', 1, 0),
                (106, '删除', 45, 'auth/roleDel', 1, 0),
                (107, '编辑', 45, 'auth/rolePost', 1, 0),
                (108, '删除', 44, 'auth/delete', 1, 0),
                (109, '编辑', 44, 'auth/post', 1, 0),
                (110, '编辑', 48, 'config/baseSubmit', 1, 0),
                (111, '编辑', 426, 'config/paySubmit', 1, 0),
                (112, '编辑', 50, 'config/messageSubmit', 1, 0),
                (113, '积分提现', 355, '/finance/withdrawal/scoreWithdrawal', 0, 0),
                (114, '提现审核', 113, 'user/withdrawal/score_check', 1, 0),
                (115, '查看', 3, 'user/user/list', 1, 0),
                (116, '优惠券', 25, '/coupon/index', 0, 10),
                (117, '优惠券管理', 116, '/coupon', 0, 0),
                (118, '手动发放', 116, '/coupon/sendCoupon', 0, 0),
                (119, '查看', 117, 'sale/coupon/getList', 1, 0),
                (120, '修改状态', 117, 'sale/coupon/status', 1, 0),
                (121, '编辑', 117, 'sale/coupon/post', 1, 0),
                (122, '删除', 117, 'sale/coupon/delete', 1, 0),
                (123, '发放', 118, 'sale/coupon/sendCoupon', 1, 0),
                (124, '分销审核', 2, '/user/apply', 0, 0),
                (125, '审核', 124, 'fenxiao/apply/check', 1, 0),
                (126, '打印设置', 47, '/config/printer', 0, 0),
                (127, '打印机管理', 47, '/config/printerList', 0, 0),
                (128, '编辑', 126, 'config/printerSubmit', 1, 0),
                (129, '编辑', 127, 'printer/post', 1, 0),
                (130, '删除', 127, 'printer/delete', 1, 0),
                (131, '余额明细', 356, '/finance/log/money', 0, 0),
                (132, '积分明细', 356, '/finance/log/score', 0, 0),
                (133, '佣金明细', 356, '/finance/log/commission', 0, 0),
                (134, '会员卡', 25, '/card/index', 0, 0),
                (135, '会员卡', 134, '/card', 0, 0),
                (136, '购买记录', 134, '/card/order', 0, 0),
                (137, '编辑', 135, 'card/card/post', 1, 0),
                (138, '删除', 135, 'card/card/delete', 1, 0),
                (139, '修改状态', 135, 'card/card/status', 1, 0),
                (140, '文章视频', 25, '/news/index', 0, 0),
                (141, '查看', 135, 'card/card/getList', 1, 0),
                (142, '文章列表', 140, '/news', 0, 0),
                (143, '查看', 142, 'news/article/getList', 1, 0),
                (144, '编辑', 142, 'news/article/post', 1, 0),
                (145, '删除', 142, 'news/article/delete', 1, 0),
                (146, '修改状态', 142, 'news/article/status', 1, 0),
                (147, '视频列表', 140, '/news/video', 0, 0),
                (148, '查看', 147, 'news/video/getList', 1, 0),
                (149, '编辑', 147, 'news/video/post', 1, 0),
                (150, '删除', 147, 'news/video/delete', 1, 0),
                (151, '修改状态', 147, 'news/video/status', 1, 0),
                (152, '分类列表', 140, '/news/category', 0, 0),
                (153, '查看', 152, 'news/category/getList', 1, 0),
                (154, '编辑', 152, 'news/category/post', 1, 0),
                (155, '删除', 152, 'news/category/delete', 1, 0),
                (156, '修改状态', 152, 'news/category/status', 1, 0),
                (157, '双轨模式', 25, '/double_track/index', 0, 0),
                (158, '双轨模式', 157, '/double_track', 0, 0),
                (159, '基础设置', 158, 'double_track/config/set', 1, 0),
                (160, '管理等级', 157, '/double_track/level', 0, 0),
                (161, '查看', 160, 'double_track/level/getList', 1, 0),
                (162, '编辑', 160, 'double_track/level/post', 1, 0),
                (163, '删除', 160, 'double_track/level/delete', 1, 0),
                (164, '清除数据', 47, '/config/clear', 0, 0),
                (165, '清除', 164, 'common/clearData', 1, 0),
                (166, '核销订单', 10, 'order/order/hexiao', 1, 0),
                (167, '关闭订单', 10, 'order/order/close', 1, 0),
                (168, '删除订单', 10, 'order/order/delete', 1, 0),
                (169, '充值管理', 354, '/finance/rechargeLog', 0, 0),
                (170, '查看业绩', 19, 'fenxiao/user/getTeamAchievement', 1, 0),
                (171, '查看团队', 19, 'fenxiao/user/team', 1, 0),
                (172, '门店管理', NULL, '/store', 0, 0),
                (173, '门店列表', 172, '/store/index', 0, 0),
                (174, '查看', 173, 'store/store/getList', 1, 0),
                (175, '编辑', 173, 'store/store/post', 1, 0),
                (176, '删除', 173, 'store/store/delete', 1, 0),
                (177, '经销商', 172, '/store/dealer', 0, 0),
                (178, '查看', 177, 'store/dealer/getList', 1, 0),
                (179, '编辑', 177, 'store/dealer/post', 1, 0),
                (180, '删除', 177, 'store/dealer/delete', 1, 0),
                (181, '级差奖', 25, '/jicha/index', 0, 0),
                (182, '设置', 181, 'jicha/config/set', 1, 0),
                (183, '复购奖', 25, '/repurchase/index', 0, 0),
                (184, '设置', 183, 'repurchase/config/set', 1, 0),
                (185, '见单奖', 25, '/jiandan/index', 0, 0),
                (186, '设置', 185, 'jiandan/config/set', 1, 0),
                (187, '平级奖', 25, '/pingji/index', 0, 0),
                (188, '设置', 187, 'pingji/config/set', 1, 0),
                (189, '管理奖', 25, '/management/index', 0, 0),
                (190, '设置', 189, 'management/config/set', 1, 0),
                (191, '限时特价', 25, '/seckill/index', 0, 0),
                (192, '活动列表', 191, '/seckill', 0, 0),
                (193, '查看', 192, 'seckill/index/getList', 1, 0),
                (194, '编辑', 192, 'seckill/index/post', 1, 0),
                (195, '删除', 192, 'seckill/index/delete', 1, 0),
                (196, '设置状态', 192, 'seckill/index/status', 1, 0),
                (197, '商品列表', 191, '/seckill/goods', 0, 0),
                (198, '查看', 197, 'seckill/goods/getList', 1, 0),
                (199, '编辑', 197, 'seckill/goods/post', 1, 0),
                (200, '删除', 197, 'seckill/goods/delete', 1, 0),
                (201, '设置状态', 197, 'seckill/goods/status', 1, 0),
                (202, '321模式', 25, '/yies_mode/index', 0, 0),
                (203, '设置', 202, 'yies_mode/config/set', 1, 0),
                (204, '复购平级奖', 25, '/repurchasepingji/index', 0, 0),
                (205, '设置', 204, 'repurchasepingji/config/set', 1, 0),
                (206, '活动弹窗', 25, '/apopup/index', 0, 0),
                (207, '基础设置', 206, 'apopup/config/set', 1, 0),
                (208, '活动单页', 206, '/apopup/list', 0, 0),
                (209, '查看', 208, 'apopup/index/getList', 1, 0),
                (210, '编辑', 208, 'apopup/index/post', 1, 0),
                (211, '删除', 208, 'apopup/index/delete', 1, 0),
                (212, '设置状态', 208, 'apopup/index/status', 1, 0),
                (213, '电子合同', 25, '/contract/index', 0, 0),
                (214, '基础设置', 213, 'contract/config/set', 1, 0),
                (215, '合同列表', 213, '/contract/list', 0, 0),
                (216, '查看', 215, 'contract/contract/getList', 1, 0),
                (217, '编辑', 215, 'contract/contract/post', 1, 0),
                (218, '删除', 215, 'contract/contract/delete', 1, 0),
                (219, '用户合同', 213, '/contract/record', 0, 0),
                (220, '意见反馈', 25, '/feedback/index', 0, 0),
                (221, '处理', 220, 'feedback/feedback/status', 1, 0),
                (222, '删除', 220, 'feedback/feedback/delete', 1, 0),
                (223, '复购金', 25, '/repurchasegold/index', 0, 0),
                (224, '设置', 223, 'repurchasegold/config/set', 1, 0),
                (225, '累计返还奖', 25, '/cumulative_fanhuan/index', 0, 0),
                (226, '基础设置', 225, 'cumulative_fanhuan/config/set', 1, 0),
                (227, '返还用户', 225, '/cumulative_fanhuan/user', 0, 0),
                (228, '云仓', 25, '/cloud_warehouse/index', 0, 0),
                (229, '基础配置', 228, 'cloud_warehouse/config/set', 1, 0),
                (230, '阶梯直推', 25, '/ladderpush/index', 0, 0),
                (231, '设置', 230, 'ladderpush/config/set', 1, 0),
                (232, '阶梯加权分红', 25, '/ladderabonus/index', 0, 0),
                (233, '设置', 232, 'ladderabonus/config/set', 1, 0),
                (234, '指定奖', 25, '/appoint/index', 0, 0),
                (235, '设置', 234, 'appoint/config/set', 1, 0),
                (236, '直推业绩奖', 25, '/directpush_achievement/index', 0, 0),
                (237, '设置', 236, 'directpush_achievement/config/set', 1, 0),
                (238, '直推见单奖', 25, '/directpush_jiandan/index', 0, 0),
                (239, '设置', 238, 'directpush_jiandan/config/set', 1, 0),
                (240, '下二代奖', 25, '/below/index', 0, 0),
                (241, '设置', 240, 'below/config/set', 1, 0),
                (242, '团建奖', 25, '/team_building/index', 0, 0),
                (243, '设置', 242, 'team_building/config/set', 1, 0),
                (244, '出局倍数', 25, '/strikeout/index', 0, 0),
                (245, '设置', 244, 'strikeout/config/set', 1, 0),
                (246, '排队免单', 25, '/queue_mode/index', 0, 0),
                (247, '基础设置', 246, 'queue_mode/config/set', 1, 0),
                (248, '排队用户', 246, '/queue_mode/user', 0, 0),
                (249, '返还铭记', 246, '/queue_mode/record', 0, 0),
                (250, '直推团队奖', 25, '/directpush_team/index', 0, 0),
                (251, '设置', 250, 'directpush_team/config/set', 1, 0),
                (252, '股份加权分红', 25, '/sabonus/index', 0, 0),
                (253, '设置', 252, 'sabonus/config/set', 1, 0),
                (254, '动态红包', 25, '/dynamic_redpacket/index', 0, 0),
                (255, '基础设置', 254, 'dynamic_redpacket/config/set', 1, 0),
                (256, '红包提现', 254, '/dynamic_redpacket/withdrawal', 0, 0),
                (257, '审核', 256, 'dynamic_redpacket/withdrawal/check', 1, 0),
                (258, '短视频', 25, '/short_video/index', 0, 0),
                (259, '基础设置', 258, 'short_video/config/set', 1, 0),
                (260, '视频列表', 258, '/short_video/video', 0, 0),
                (261, '查看', 260, 'short_video/video/getList', 1, 0),
                (262, '编辑', 260, 'short_video/video/post', 1, 0),
                (263, '删除', 260, 'short_video/video/delete', 1, 0),
                (264, '设置状态', 260, 'short_video/video/status', 1, 0),
                (265, '评论列表', 258, '/short_video/comment', 0, 0),
                (266, '审核', 265, 'short_video/comment/shenhe', 1, 0),
                (267, '删除', 265, 'short_video/comment/delete', 1, 0),
                (268, '常见问题', 25, '/problem/index', 0, 0),
                (269, '查看', 268, 'problem/problem/getList', 1, 0),
                (270, '编辑', 268, 'problem/problem/post', 1, 0),
                (271, '删除', 268, 'problem/problem/delete', 1, 0),
                (272, '设置状态', 268, 'problem/category/status', 1, 0),
                (273, '预存释放', 25, '/deposit_release/index', 0, 0),
                (274, '基础设置', 273, 'deposit_release/config/set', 1, 0),
                (275, '预存订单', 273, '/deposit_release/order', 0, 0),
                (276, '预存记录', 356, '/finance/log/deposit', 0, 0),
                (277, '提现记录', 273, '/deposit_release/withdrawal', 0, 0),
                (278, '审核', 277, 'deposit_release/withdrawal/check', 1, 0),
                (279, '操作日志', 43, '/auth/operLog', 0, 0),
                (280, '编辑', 3, 'user/user/post', 1, 0),
                (281, '商品评价', 5, '/goods/comment', 0, 0),
                (282, '查看', 281, 'goods/comment/getList', 1, 0),
                (283, '删除', 281, 'goods/comment/delete', 1, 0),
                (284, '审核', 281, 'goods/comment/shenhe', 1, 0),
                (285, '审核', 169, 'user/recharge/check', 1, 0),
                (286, '设置', 34, 'agent/user/setUser', 1, 0),
                (287, '设置库存', 228, 'cloud_warehouse/user/setStock', 1, 0),
                (288, '库存记录', 228, '/cloud_warehouse/log', 0, 0),
                (289, '签到有礼', 25, '/signin/index', 0, 0),
                (290, '基础设置', 289, 'signin/config/set', 1, 0),
                (291, '签到记录', 289, '/signin/signin', 0, 0),
                (292, '拼团活动', 25, '/pintuan/index', 0, 0),
                (293, '基础设置', 292, 'pintuan/config/set', 1, 0),
                (294, '拼团商品', 292, '/pintuan/pintuan', 0, 0),
                (295, '查看', 294, 'pintuan/goods/getList', 1, 0),
                (296, '编辑', 294, 'pintuan/goods/post', 1, 0),
                (297, '删除', 294, 'pintuan/goods/delete', 1, 0),
                (298, '上/下架', 294, 'pintuan/goods/status', 1, 0),
                (299, '拼团订单', 292, '/pintuan/pintuan/order', 0, 0),
                (300, '查看', 299, 'pintuan/order/getList', 1, 0),
                (301, '强制操作', 299, 'pintuan/order/force', 1, 0),
                (302, '储值利息', 25, '/sinterest/index', 0, 0),
                (303, '基础设置', 302, 'sinterest/config/set', 1, 0),
                (304, '页面装修', 42, '/diypage/index', 0, 0),
                (305, '样式风格', 42, '/diypage/style', 0, 0),
                (306, '编辑', 305, 'config/styleSubmit', 1, 0),
                (307, '超越奖', 25, '/chaoyue/index', 0, 0),
                (308, '基础设置', 307, 'chaoyue/config/set', 1, 0),
                (309, '阶梯平级奖', 25, '/ladderpingji/index', 0, 0),
                (310, '基础设置', 309, 'ladderpingji/config/set', 1, 0),
                (311, '多商户', 25, '/merchant/index', 0, 0),
                (312, '基础设置', 311, 'merchant/config/set', 1, 0),
                (313, '商户管理', 311, '/merchant/merchantList', 0, 0),
                (314, '查看', 313, 'merchant/merchant/getList', 1, 0),
                (315, '编辑', 313, 'merchant/merchant/post', 1, 0),
                (316, '删除', 313, 'merchant/merchant/delete', 1, 0),
                (317, '审核', 313, 'merchant/merchant/shenhe', 1, 0),
                (318, '商品管理', 311, '/merchant/goods', 0, 0),
                (319, '查看', 318, 'merchant/goods/getList', 1, 0),
                (320, '编辑', 318, 'merchant/goods/post', 1, 0),
                (321, '上架/下架', 318, 'merchant/goods/status', 1, 0),
                (322, '审核', 318, 'merchant/goods/shenhe', 1, 0),
                (323, '商品评价', 318, '/merchant/goods/comment', 0, 0),
                (324, '查看', 323, 'merchant/comment/getList', 1, 0),
                (325, '商品分类', 311, '/merchant/categroy', 0, 0),
                (326, '查看', 325, 'merchant/category/getList', 1, 0),
                (327, '删除', 325, 'merchant/category/delete', 1, 0),
                (328, '提现管理', 311, '/merchant/withdrawal', 0, 0),
                (329, '查看', 328, 'merchant/withdrawal/getList', 1, 0),
                (330, '打款审核', 328, 'merchant/withdrawal/check', 1, 0),
                (331, '疯狂卖货模式', 25, '/crazy/index', 0, 0),
                (332, '基础设置', 331, 'crazy/config/set', 1, 0),
                (333, '人脉互助模式', 25, '/sconnection/index', 0, 0),
                (334, '基础设置', 333, 'sconnection/config/set', 1, 0),
                (335, '返利拼团', 25, '/rebate_pintuan/index', 0, 0),
                (336, '基础设置', 335, 'rebate_pintuan/config/set', 1, 0),
                (337, '内缩平级奖', 25, '/npingji/index', 0, 0),
                (338, '基础设置', 337, 'npingji/config/set', 1, 0),
                (339, '提现分红', 25, '/txabonus/index', 0, 0),
                (340, '基础设置', 339, 'txabonus/config/set', 1, 0),
                (341, '发放奖励', 339, 'txabonus/config/releaseReward', 1, 0),
                (342, '运费模板', 25, '/shippingfee/index', 0, 0),
                (343, '模板列表', 342, 'shippingfee/template/getList', 1, 0),
                (344, '资金池', 25, '/capitalpool/index', 0, 0),
                (345, '基础设置', 344, 'capitalpool/config/set', 1, 0),
                (346, '手动分红', 344, 'capitalpool/config/setAbonus', 1, 0),
                (347, '排行榜', 25, '/paihangbang/index', 0, 0),
                (348, '基础设置', 347, 'paihangbang/config/set', 1, 0),
                (349, '排行榜用户', 347, '/paihangbang/user', 0, 0),
                (350, '超级卖货模式', 25, '/super_maihuo/index', 0, 0),
                (351, '基础配置', 350, 'super_maihuo/config/set', 1, 0),
                (352, '新三三复制', 25, '/pyramid/index', 0, 0),
                (353, '基础配置', 352, 'pyramid/config/set', 1, 0),
                (354, '财务管理', NULL, '/finance', 0, 0),
                (355, '提现管理', 354, '/finance/withdrawal', 0, 0),
                (356, '财务明细', 354, '/finance/financeDetail', 0, 0),
                (357, '复购金记录', 356, '/finance/log/repurchasegold', 0, 0),
                (358, '扫码验真', 25, '/sverify/index', 0, 0),
                (359, '基础配置', 358, 'sverify/config/set', 1, 0),
                (360, '产品管理', 358, '/sverify/product', 0, 0),
                (361, '防伪码管理', 358, '/sverify/code', 0, 0),
                (362, '查询记录', 358, '/sverify/record', 0, 0),
                (363, '查看', 360, 'sverify/product/getList', 1, 0),
                (364, '编辑', 360, 'sverify/product/post', 1, 0),
                (365, '删除', 360, 'sverify/product/delete', 1, 0),
                (366, '生成防伪码', 360, 'sverify/product/batchCreate', 1, 0),
                (367, '查看', 361, 'sverify/product_code/getList', 1, 0),
                (368, '删除', 361, 'sverify/product_code/delete', 1, 0),
                (369, '删除', 362, 'sverify/query/delete', 1, 0),
                (370, '阶梯管理奖', 25, '/laddermanage/index', 0, 0),
                (371, '基础设置', 370, 'laddermanage/config/set', 1, 0),
                (372, '押金', 25, '/yajin/index', 0, 0),
                (373, '基础配置', 372, 'yajin/config/set', 1, 0),
                (374, '押金记录', 372, '/yajin/order', 0, 0),
                (375, '退还记录', 372, '/yajin/refund', 0, 0),
                (376, '审核', 375, 'yajin/refund/shenhe', 1, 0),
                (377, '模式预设', 25, '/preset/index', 0, 0),
                (378, '使用模式', 377, 'mode/initMode', 1, 0),
                (379, '电子面单', 47, '/config/aliyunEWaybill', 0, 0),
                (380, '编辑', 379, 'config/electronicWaybillSubmit', 1, 0),
                (381, '分享素材', 25, '/smaterial/index', 0, 0),
                (382, '分享素材', 381, 'smaterial/smaterial/getList', 1, 0),
                (383, '素材分类', 381, '/smaterial/category', 0, 0),
                (384, 'Ai问答', 25, '/qwen/index', 0, 0),
                (385, '基础配置', 384, 'qwen/config/set', 1, 0),
                (386, 'Ai数字人', 25, '/shuziren/index', 0, 0),
                (387, '基础配置', 386, 'shuziren/config/set', 1, 0),
                (388, '快递公司', 47, '/config/deliveryList', 0, 0),
                (389, '贡献值', 25, '/contribution/index', 0, 0),
                (390, '基础配置', 389, 'contribution/config/set', 1, 0),
                (391, '删除', 318, 'merchant/goods/delete', 1, 0),
                (392, '编辑', 325, 'merchant/category/post', 1, 0),
                (393, '礼品', 25, '/gift/index', 0, 0),
                (394, '基础配置', 393, 'gift/config/set', 1, 0),
                (395, '消息通知', 25, '/notice/index', 0, 0),
                (396, '发送通知', 395, 'notice/notice/send', 1, 0),
                (397, '删除通知', 395, 'notice/notice/delete', 1, 0),
                (398, '超级聊天', 25, '/chat/index', 0, 0),
                (399, '基础配置', 398, 'chat/config/set', 1, 0),
                (400, '活动报名', 25, '/activity/index', 0, 0),
                (401, '基础配置', 400, 'activity/config/set', 1, 0),
                (402, '活动列表', 400, '/activity/list', 0, 0),
                (403, '详情', 402, 'activity/activity/detail', 1, 0),
                (404, '编辑', 402, 'activity/activity/post', 1, 0),
                (405, '审核', 402, 'activity/activity/shenhe', 1, 0),
                (406, '删除', 402, 'activity/activity/delete', 1, 0),
                (407, '报名列表', 400, '/activity/baominList', 0, 0),
                (408, '复购见单', 25, '/repurchase_jiandan/index', 0, 0),
                (409, '基础配置', 408, 'repurchase_jiandan/config/set', 1, 0),
                (410, '下二代福利奖', 25, '/below_welfare/index', 0, 0),
                (411, '基础配置', 410, 'below_welfare/config/set', 1, 0),
                (412, '分享奖', 25, '/saward/index', 0, 0),
                (413, '基础配置', 412, 'saward/config/set', 1, 0),
                (414, '系统信息', 0, '/site', 0, 0),
                (415, '后台登录页', 414, '/site/login', 0, 0),
                (416, '微信公众号', 414, '/site/wechatGZH', 0, 0),
                (417, '微信小程序', 414, '/site/miniProgram', 0, 0),
                (418, '公众号支付', 414, '/site/wechatGZHPay', 0, 0),
                (419, '微信小程序支付', 414, '/site/miniProgramPay', 0, 0),
                (420, '服务商支付', 414, '/site/servicePay', 0, 0),
                (421, '支付宝支付', 414, '/site/alipay', 0, 0),
                (422, '微信H5支付', 414, '/site/wechatH5', 0, 0),
                (423, '环境信息', 414, '/site/system', 0, 0),
                (426, '支付开关', 49, '/config/pay/pay', 0, 0),
                (427, '余额充值', 49, '/config/pay/balance', 0, 0),
                (428, '编辑', 427, 'config/rechargebalanceSubmit', 1, 0),
                (429, '积分充值', 49, '/config/pay/score', 0, 0),
                (430, '编辑', 429, 'config/rechargescoreSubmit', 1, 0),
                (431, '余额提现', 49, '/config/pay/balancewithdrawl', 0, 0),
                (432, '编辑', 431, 'config/withdrawalSubmit', 1, 0),
                (433, '积分提现', 49, '/config/pay/scorewithdrawl', 0, 0),
                (434, '编辑', 433, 'config/withdrawalscoreSubmit', 1, 0),
                (435, '佣金提现', 49, '/config/pay/commissionwithdrawl', 0, 0),
                (436, '编辑', 435, 'fenxiao/config/withdrawalSet', 1, 0),
                (437, '层级级差', 25, '/leveljicha/index', 0, 0),
                (438, '基础配置', 437, 'leveljicha/config/set', 1, 0),
                (439, '积分业绩', 25, '/sachievement/index', 0, 0),
                (440, '基础配置', 439, 'sachievement/config/set', 1, 0),
                (441, '合并等级', 25, '/mergelevel/index', 0, 0),
                (442, '基础配置', 441, 'mergelevel/config/set', 1, 0),
                (443, '积分奖励', 25, '/scorereward/index', 0, 0),
                (444, '基础配置', 443, 'scorereward/config/set', 1, 0),
                (445, '分销积分', 25, '/fenxiaoscore/index', 0, 0),
                (446, '基础配置', 445, 'fenxiaoscore/config/set', 1, 0),
                (447, '前端入口', 42, '/diypage/front', 0, 0),
                (448, '文字替换', 42, '/diypage/textReplace', 0, 0),
                (449, '前端模板', 42, '/diypage/template', 0, 0),
                (450, '轮播管理', 311, '/merchant/slide', 0, 0),
                (451, '编辑', 448, 'config/textSubmit', 1, 0),
                (452, '编辑', 450, 'slide/post', 1, 0),
                (453, '删除', 450, 'slide/delete', 1, 0),
                (454, '商户分类', 311, '/merchant/mchCategroy', 0, 0),
                (455, '编辑', 454, 'merchant/merchant_category/post', 1, 0),
                (456, '删除', 454, 'merchant/merchant_category/delete', 1, 0),
                (457, '鸣谢', 414, '/site/thanks', 0, 0),
                (458, '激活授权', 414, '/site/index', 0, 0),
                (459, '系统更新', 414, '/site/update', 0, 0),
                (460, '自定义表单', 25, '/form/index', 0, 0),
                (461, '基础配置', 460, 'form/config/set', 1, 0),
                (462, '工单', 25, '/workorder/index', 0, 0),
                (463, '基础配置', 462, 'workorder/config/set', 1, 0),
                (464, '工单列表', 462, '/workorder/list', 0, 0),
                (465, '删除', 464, 'workorder/workorder/delete', 1, 0),
                (466, '分配', 464, 'workorder/workorder/allocate', 1, 0),
                (467, '转单', 464, 'workorder/workorder/transfer', 1, 0),
                (468, '详情', 464, 'workorder/workorder/detail', 1, 0),
                (469, '工单分类', 462, '/workorder/category', 0, 0),
                (470, '编辑', 469, 'workorder/category/post', 1, 0),
                (471, '删除', 469, 'workorder/category/delete', 1, 0),
                (472, '工单用户', 462, '/workorder/user', 0, 0),
                (473, '编辑', 472, 'workorder/user/post', 1, 0),
                (474, '删除', 472, 'workorder/user/delete', 1, 0),
                (475, '浮动金额', 25, '/floatamount/index', 0, 0),
                (476, '基础配置', 475, 'floatamount/config/set', 1, 0),
                (477, '转盘抽奖', 25, '/luckywheel', 0, 0),
                (478, '编辑', 485, 'luckywheel/config/set', 1, 0),
                (479, '奖励列表', 477, '/luckywheel/award', 0, 0),
                (480, '编辑', 479, 'luckywheel/prize/post', 1, 0),
                (481, '删除', 479, 'luckywheel/prize/delete', 1, 0),
                (482, '指定中奖', 477, '/luckywheel/appoint', 0, 0),
                (483, '编辑', 482, 'luckywheel/zhiding/post', 1, 0),
                (484, '删除', 482, 'luckywheel/zhiding/delete', 1, 0),
                (485, '基础配置', 477, '/luckywheel/set', 0, 0),
                (486, '抽奖记录', 477, '/luckywheel/index', 0, 0),
                (487, '发放配置', 116, '/coupon/sendSet', 0, 0),
                (488, '编辑', 487, 'sale/config/set', 1, 0),
                (489, '地图配置', 47, '/config/map', 0, 0),
                (490, '编辑', 489, 'config/mapSubmit', 1, 0),
                (491, 'AI舌诊', 25, '/tongue_diagnosis', 0, 0),
                (492, '舌诊记录', 491, '/tongue_diagnosis/index', 0, 0),
                (493, '详情', 492, 'tongue_diagnosis/diagnose/detail', 1, 0),
                (494, '删除', 492, 'tongue_diagnosis/diagnose/delete', 1, 0),
                (495, '基础配置', 491, '/tongue_diagnosis/set', 0, 0),
                (496, '编辑', 495, 'tongue_diagnosis/config/set', 1, 0),
                (497, '项目分红', 25, '/pabonus', 0, 0),
                (498, '项目列表', 497, '/pabonus/index', 0, 0),
                (499, '编辑', 498, 'pabonus/goods/post', 1, 0),
                (500, '删除', 498, 'pabonus/goods/delete', 1, 0),
                (501, '分红', 498, 'pabonus/goods/setAbonus', 1, 0),
                (502, '股东列表', 497, '/pabonus/shareholder', 0, 0),
                (503, '删除', 502, 'pabonus/user/delete', 1, 0),
                (504, '分红记录', 497, '/pabonus/log', 0, 0),
                (505, '删除', 504, 'pabonus/record/delete', 1, 0),
                (506, '基础配置', 497, '/pabonus/set', 0, 0),
                (507, '编辑', 506, 'pabonus/config/set', 1, 0),
                (508, '用户优惠券', 116, '/coupon/list', 0, 0),
                (509, '删除', 508, 'sale/coupon/deleteUserCoupon', 1, 0),
                (510, '直推业绩转移', 25, '/atransfer', 0, 0),
                (511, '基础配置', 510, '/atransfer/index', 0, 0),
                (512, '余额记录', 225, '/cumulative_fanhuan/list', 0, 0),
                (513, '积分记录', 225, '/cumulative_fanhuan/scoreList', 0, 0),
                (514, '排队奖', 25, '/queue_award', 0, 0),
                (515, '排队记录', 514, '/queue_award/index', 0, 0),
                (516, '基础配置', 514, '/queue_award/set', 0, 0),
                (517, '见单推荐奖', 25, '/jiandan_recommend/index', 0, 0),
                (518, '基础配置', 517, 'jiandan_recommend/config/set', 1, 0),
                (519, '灵动加权分红', 25, '/aabonus/index', 0, 0),
                (520, '基础配置', 519, 'aabonus/config/set', 1, 0),
                (521, '手动分红', 347, 'paihangbang/user/setAbonus', 1, 0),
                (522, '云仓库存', 3, 'cloud_warehouse/user/setStock', 1, 0),
                (523, '查看', 10, 'order/order/list', 1, 0),
                (524, '物流单号导入', 10, 'order/order/import', 1, 0),
                (525, '打印小票', 10, 'order/order/print', 1, 0),
                (526, '修改备注', 10, 'order/order/updateRemarks', 1, 0),
                (527, '查询物流', 10, 'order/order/queryExpressDelivery', 1, 0),
                (528, '订单导出', 10, 'order/order/export', 1, 0),
                (529, '模板下载', 10, 'order/order/download', 1, 0),
                (530, '线下支付审核', 10, 'order/order/cashShenhe', 1, 0),
                (531, '生成/打印面单', 10, 'order/order/createElectronicWaybill', 1, 0),
                (532, '导入', 3, 'user/user/import', 1, 0),
                (533, '导出', 3, 'user/user/export', 1, 0),
                (534, '数据总览', 1, 'data_overview', 2, 0),
                (535, '刷新等级', 3, 'user/user/refreshLevel', 1, 0),
                (536, '模板下载', 3, 'user/user/download', 1, 0),
                (537, '显示手机号', 3, 'user_mobile', 2, 0),
                (538, '查看', 1, '/dashboard/index', 0, 0),
                (539, '统计显示', 1, 'config/tongjiSubmit', 1, 0),
                (540, '数据大屏', 25, '/ddashboard/index', 0, 0),
                (541, '基础配置', 540, 'ddashboard/config/set', 1, 0),
                (542, '数据统计', 0, '/statistics', 0, 0),
                (543, '奖金统计', 542, '/statistics/awards', 0, 0),
                (544, '商品统计', 542, '/statistics/goods', 0, 0),
                (545, '订单统计', 542, '/statistics/order', 0, 0),
                (546, '用户统计', 542, '/statistics/user', 0, 0),
                (547, '数据大屏', 1, 'ddashboard/ddashboard/index', 1, 0),
                (548, '显示余额', 3, 'user_balance', 2, 0),
                (549, '显示积分', 3, 'user_score', 2, 0),
                (550, '显示复购金', 3, 'user_repurchase_currency', 2, 0),
                (551, '后台录单', 10, 'order/create/submit', 1, 0),
                (552, '业绩占比分红', 25, '/apabonus/index', 0, 0),
                (553, '基础配置', 552, 'apabonus/config/set', 1, 0),
                (554, '分红管理奖', 25, '/manabonus/index', 0, 0),
                (555, '基础配置', 554, 'manabonus/config/set', 1, 0),
                (556, '利润统计', 542, '/statistics/profit', 0, 0),
                (557, '销售配额', 25, '/salequota/index', 0, 0),
                (558, '基础配置', 557, 'salequota/config/set', 1, 0),
                (559, '用户库存', 557, '/salequota/list', 0, 0),
                (560, '手动分红', 344, '/capitalpool/distribute', 0, 0),
                (561, '入池记录', 344, '/capitalpool/list', 0, 0),
                (562, '出池记录', 344, '/capitalpool/list1', 0, 0),
                (563, '手动入池记录', 344, '/capitalpool/list2', 0, 0),
                (564, '砍价活动', 25, '/bargain', 0, 0),
                (565, '砍价管理', 564, '/bargain/index', 0, 0),
                (566, '编辑', 565, 'bargain/goods/post', 1, 0),
                (567, '删除', 565, 'bargain/goods/delete', 1, 0),
                (568, '查看', 565, 'bargain/goods/detail', 1, 0),
                (569, '砍价分类', 564, '/bargain/category', 0, 0),
                (570, '编辑', 569, 'bargain/category/post', 1, 0),
                (571, '删除', 569, 'bargain/category/delete', 1, 0),
                (572, '砍价设置', 564, '/bargain/set', 0, 0),
                (573, '编辑', 572, 'bargain/config/set', 1, 0),
                (574, '重置', 565, 'bargain/goods/resetPrice', 1, 0),
                (575, '手动分红订单', 344, '/capitalpool/order', 0, 0),
                (576, '切换分红开关', 575, 'capitalpool/capitalpool/setManualAbonusOrder', 1, 0),
                (577, '商品收藏', 5, '/goods/collection', 0, 0),
                (578, '购买插件', 25, 'buy_plugin', 2, 0),
                (579, '图片合规检测', 25, '/image_check/index', 0, 0),
                (580, '基础配置', 579, 'image_check/config/set', 1, 0),
                (581, '检测记录', 579, '/image_check/list', 0, 0),
                (582, '拼团免单', 25, '/pintuan_miandan/index', 0, 0),
                (583, '基础配置', 582, 'pintuan_miandan/config/set', 1, 0),
                (584, '优惠券设置', 116, '/coupon/set', 0, 0),
                (585, '分渠支付路由', 25, '/payroute/index', 0, 0),
                (586, '基础配置', 585, 'payroute/config/set', 1, 0),
                (587, '支付路由', 585, '/payroute/list', 0, 0),
                (588, '编辑', 587, 'payroute/payroute/post', 1, 0),
                (589, '删除', 587, 'payroute/payroute/delete', 1, 0),
                (590, '现金抽奖', 25, '/cashlottery', 0, 0),
                (591, '基础配置', 590, 'cashlottery/config/set', 1, 0),
                (592, '中奖记录', 590, '/cashlottery/index', 0, 0),
                (593, '删除', 592, 'cashlottery/record/delete', 1, 0),
                (594, '抽奖奖励', 590, '/cashlottery/award', 0, 0),
                (595, '编辑', 594, 'cashlottery/reward/post', 1, 0),
                (596, '删除', 594, 'cashlottery/reward/delete', 1, 0),
                (597, '贡献增值', 25, '/contribute_vadded', 0, 0),
                (598, '提现管理', 597, '/contribute_vadded/index', 0, 0),
                (599, '提现审核', 598, 'contribute_vadded/withdrawal/check', 1, 0),
                (600, '基础配置', 597, '/contribute_vadded/set', 0, 0),
                (601, '修改贡献分', 600, 'contribute_vadded/config/setContribute', 1, 0),
                (602, '增值池记录', 597, '/contribute_vadded/contribute', 0, 0),
                (603, '贡献记录', 597, '/contribute_vadded/poolLog', 0, 0),
                (604, '激励广告', 25, '/incentivead/index', 0, 0),
                (605, '基础配置', 604, 'incentivead/config/set', 1, 0),
                (606, '静态返还模式', 25, '/sreturn', 0, 0),
                (607, '基础配置', 606, 'sreturn/config/set', 1, 0),
                (608, '返还用户', 606, '/sreturn/user', 0, 0),
                (609, '余额记录', 606, '/sreturn/list', 0, 0),
                (610, '积分记录', 606, '/sreturn/scoreList', 0, 0);");
            }
            if(!in_array('service_charges4',$transfer_accountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account")." ADD `service_charges4` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '复购金转账手续费'");  
            }
            if(!in_array('repurchase_currency_status',$transfer_accountFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_transfer_account")." ADD `repurchase_currency_status` INT(10) NOT NULL DEFAULT '0' COMMENT '复购奖转账:1=开启,0=关闭'");  
            }
            if(!in_array('thirdparty_pay',$platformFields)){ 
                Db::execute("ALTER TABLE ".tablename("platform")." ADD `thirdparty_pay` LONGTEXT NULL DEFAULT NULL COMMENT '第三方支付'");  
            }
            if(!pdo_tableexists("bbfx_sreturn")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sreturn")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:1=开启,0=关闭',
                `fanhuan_total` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '余额返还比例',
                `everyday_rate` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每天余额返还(‰)',
                `everyday_fixed` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '每日返还固定金额',
                `fanhuan_score_total` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '积分返还比例',
                `everyday_score_rate` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '每天返还积分比例',
                `everyday_score_fixed` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '每日返还固定积分',
                `settlement_currency` int(10) NOT NULL DEFAULT '1' COMMENT '结算币种:1=余额,2=积分',
                `settlement_status` int(10) NOT NULL DEFAULT '1' COMMENT '结算状态:1=已付款,2=已完成',
                `release_method` int(10) NOT NULL DEFAULT '1' COMMENT '释放方式:1=常规释放,2=递减释放',
                `decimal_type` int(10) NOT NULL DEFAULT '2' COMMENT '释放数值:1=向下取值,2=四舍五入,3=向上取值',
                `oper` int(10) UNSIGNED NOT NULL DEFAULT '1',
                `is_accelerate` int(10) NOT NULL DEFAULT '0' COMMENT '加速返还:1=开启,0=关闭',
                `accelerate_rule` text COMMENT '加速规则',
                `switch_duration` int(10) NOT NULL DEFAULT '30' COMMENT '模式切换时长',
                `sign_release` int(10) NOT NULL DEFAULT '0' COMMENT '释放方式:0=自动释放,1=签到释放,2=分享释放',
                `share_reward` text COMMENT '分享奖励',
                `rule_detailed` int(10) NOT NULL DEFAULT '0' COMMENT '详细规则:1=开启,0=关闭',
                `rule_content` text COMMENT '详细规则',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sreturnFields = Db::name("bbfx_sreturn")->getTableFields();
            }
            else{
                $sreturnFields = Db::name("bbfx_sreturn")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sreturn_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sreturn_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '来源ID',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分',
                `itype` int(10) NOT NULL DEFAULT '0' COMMENT '来源类型:0=商品,1=活动,2=增益模式',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sreturn_logFields = Db::name("bbfx_sreturn_log")->getTableFields();
            }
            else{
                $sreturn_logFields = Db::name("bbfx_sreturn_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sreturn_release_log")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sreturn_release_log")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `pid` int(10) NOT NULL DEFAULT '0' COMMENT '来源ID',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '释放金额',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分',
                `itype` int(10) NOT NULL DEFAULT '0' COMMENT '来源类型:0=释放,1=增益',
                `mtype` int(10) NOT NULL DEFAULT '0' COMMENT '奖励类型',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待到账,1=已到账',
                `info` longtext COMMENT '数据',
                `dztime` bigint(16) NOT NULL DEFAULT '0' COMMENT '到账时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sreturn_release_logFields = Db::name("bbfx_sreturn_release_log")->getTableFields();
            }
            else{
                $sreturn_release_logFields = Db::name("bbfx_sreturn_release_log")->getTableFields();
            }
            if(!pdo_tableexists("bbfx_sreturn_user")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_sreturn_user")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `total` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '返还总额',
                `surplus` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '剩余返还',
                `sdate` date DEFAULT NULL COMMENT '上次返还日期',
                `type` int(10) NOT NULL DEFAULT '0' COMMENT '类型:1=余额,2=积分',
                `mode` int(10) NOT NULL DEFAULT '0' COMMENT '模式:0=常规模式,1=增益模式',
                `modetime` bigint(16) NOT NULL DEFAULT '0' COMMENT '模式切换时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $sreturn_userFields = Db::name("bbfx_sreturn_user")->getTableFields();
            }
            else{
                $sreturn_userFields = Db::name("bbfx_sreturn_user")->getTableFields();
            }

            //v2.2.2608071
            if(!in_array('order_notify',$adminFields)){ 
                Db::execute("ALTER TABLE ".tablename("admin")." ADD `order_notify` INT(10) NOT NULL DEFAULT '1' COMMENT '订单通知'");  
            }
            if(!in_array('abonus_levels',$sabonusFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_sabonus")." ADD `abonus_levels` VARCHAR(255) NULL COMMENT '分红等级'");  
            }
            if(!in_array('video_return_second',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `video_return_second` INT(10) NOT NULL DEFAULT '30' COMMENT '看视频触发秒数'");  
            }
            if(in_array('sign_release',$returnFields) && !in_array('release_method',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." CHANGE `sign_release` `release_method` VARCHAR(100) NOT NULL DEFAULT '0' COMMENT '触发方式:0=自动触发,1=签到触发,2=分享触发,3=直推下单触发,4=看视频触发'");  
            }
            if(!in_array('is_sreturn',$order_goodsFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_order_goods")." ADD `is_sreturn` INT(10) NOT NULL DEFAULT '0' COMMENT '静态返还:1=完成,0=未完成'");  
            }
            if(!in_array('is_sreturn',$activity_baomingFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_activity_baoming")." ADD `is_sreturn` INT(10) NOT NULL DEFAULT '0' COMMENT '静态返还:1=完成,0=未完成'");  
            }
            if(!in_array('achievement_return_stime',$returnFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_return")." ADD `achievement_return_stime` INT(10) NOT NULL DEFAULT '0' COMMENT '业绩返还开始释放时间:0=明日发放,1=后天发放'");  
            }

            //v2.2.2608181
            if(!in_array('huoqu_num_method',$tongue_diagnosisFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_tongue_diagnosis")." ADD `huoqu_num_method` VARCHAR(100) NOT NULL DEFAULT '1' COMMENT '获取次数方法:1=购买商品,2=直接购买'");  
            }
            if(!in_array('buy_rule',$tongue_diagnosisFields)){ 
                Db::execute("ALTER TABLE ".tablename("bbfx_tongue_diagnosis")." ADD `buy_rule` TEXT NULL DEFAULT NULL COMMENT '购买规则'");  
            }
            if(!pdo_tableexists("bbfx_tongue_diagnosis_buy_record")){
                Db::execute("CREATE TABLE IF NOT EXISTS ".tablename("bbfx_tongue_diagnosis_buy_record")." (
                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                `uniacid` int(10) NOT NULL DEFAULT '0' COMMENT '平台ID',
                `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
                `order_no` varchar(100) DEFAULT NULL COMMENT '订单号',
                `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '支付金额',
                `num` int(10) NOT NULL DEFAULT '0' COMMENT '舌诊次数',
                `title` varchar(100) DEFAULT NULL COMMENT '标题',
                `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态:0=待支付,1=已支付',
                `paytype` int(10) NOT NULL DEFAULT '0' COMMENT '支付类型',
                `paytime` bigint(16) NOT NULL DEFAULT '0' COMMENT '支付时间',
                `createtime` bigint(16) NOT NULL DEFAULT '0' COMMENT '创建时间',
                  PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
                $tongue_diagnosis_buy_recordFields = Db::name("bbfx_tongue_diagnosis_buy_record")->getTableFields();
            }
            else{
                $tongue_diagnosis_buy_recordFields = Db::name("bbfx_tongue_diagnosis_buy_record")->getTableFields();
            }

        } 
        catch (\Exception $e) {
            addFileLog("up111",$e->getMessage()." ".$e->getLine());
            $bbfx = Db::name("bbfx")->find();
            if(!empty($bbfx['sversion_name'])){
                Db::name("bbfx")->where("id",$bbfx['id'])->update(['version_name'=>$bbfx['sversion_name'],'version'=>$bbfx['sversion']]);
            }
            __error($e->getMessage());
        }
        
    }

    public static function updateSuccessful(){
        $bbfx = Db::name("bbfx")->find();
        $sversion = $bbfx['sversion'];
        $version = $bbfx['version'];
        
        $err = [];

        try {

            if($sversion < 222510271){
                \app\common\model\bbfxshop\Order::initOrderSuppath();
            }

        } catch (\Exception $e) {
            $err['e0'] = $e->getMessage();
        }

        try {
            if($sversion < 222601141){
                $cumulative_fanhuan = Db::name("bbfx_cumulative_fanhuan")->where(['uniacid'=>UNIACID])->find();
                if(!empty($cumulative_fanhuan)){
                    $fanhuan_user = Db::name("bbfx_cumulative_fanhuan_user")->where(['uniacid'=>$cumulative_fanhuan['uniacid'],'type'=>0])->select();
                    if(!empty($fanhuan_user)){
                        Db::name("bbfx_cumulative_fanhuan_user")->where(['uniacid'=>$cumulative_fanhuan['uniacid'],'type'=>0])->update(['type'=>$cumulative_fanhuan['settlement_currency']]);
                    }

                    if($cumulative_fanhuan['settlement_currency'] != 1){
                        $data = [
                            'fanhuan_score_total'=>$cumulative_fanhuan['fanhuan_total'],
                            'everyday_score_rate'=>$cumulative_fanhuan['everyday_rate'],
                            'fanhuan_total'=>0,
                            'everyday_rate'=>0
                        ];
                        Db::name("bbfx_cumulative_fanhuan")->where(['uniacid'=>UNIACID])->update($data);
                    }

                }
            }
            else{
                $settlement_currency = Db::name("bbfx_cumulative_fanhuan")->where(['uniacid'=>UNIACID])->value("settlement_currency");
                $fanhuan_user = Db::name("bbfx_cumulative_fanhuan_user")->where(['uniacid'=>UNIACID,'type'=>0])->select();
                if(!empty($fanhuan_user) && $settlement_currency > 0){
                    Db::name("bbfx_cumulative_fanhuan_user")->where(['type'=>0])->update(['type'=>$settlement_currency]);
                }
            }
        } catch (\Exception $e) {
            $err['e1'] = $e->getMessage();
        }

        try {

            if($sversion < 222601201){
                $achievement_jisuan = Db::name("bbfx_fenxiao")->where(['uniacid'=>UNIACID])->value("achievement_jisuan");
                if($achievement_jisuan == 1){
                    \app\common\model\bbfxshop\User::initOriginalSupPath();
                }
            }

        } catch (\Exception $e) {
            $err['e2'] = $e->getMessage();
        }

        try {

            if($sversion < 222602101){
                $attachment_list = Db::name("attachment")->where(['oss_domain'=>['neq','']])->field("id,url,oss_domain")->select();
                if(!empty($attachment_list)){
                    foreach($attachment_list as $val){
                        if(!strstr($val['url'],'http')){
                            if(strstr($val['oss_domain'],'http')){
                                $oss_domain = $val['oss_domain'];
                            }
                            else{
                                $oss_domain = "https://".$val['oss_domain'];
                            }
                            $url = $oss_domain.$val['url'];
                            $adata = ['url'=>$url];
                            Db::name("attachment")->where(['id'=>$val['id']])->update($adata);
                        }
                    }
                }
            }

        } catch (\Exception $e) {
            $err['e3'] = $e->getMessage();
        }

        try {

            if($sversion < 222604211){
                $order_list = Db::name("bbfx_order")->where(['order_source'=>7,'create_method'=>0])->field("id")->select();
                if(!empty($order_list)){
                    foreach($order_list as $key => $val){
                        Db::name("bbfx_order")->where(['id'=>$val['id']])->update(['create_method'=>1]);
                    }
                }
            }

        } catch (\Exception $e) {
            $err['e4'] = $e->getMessage();
        }

        try {

            if($sversion < 222606241){
                $voiceList = [
                    'Cherry' => '芊悦',
                    'Serena' => '苏瑶',
                    'Ethan' => '晨煦',
                    'Chelsie' => '千雪',
                    'Momo' => '茉兔',
                    'Vivian' => '十三',
                    'Moon' => '月白',
                    'Maia' => '四月',
                    'Kai' => '凯',
                    'Nofish' => '不吃鱼',
                    'Bella' => '萌宝',
                    'Jennifer' => '詹妮弗',
                    'Ryan' => '甜茶',
                    'Katerina' => '卡捷琳娜',
                    'Aiden' => '艾登',
                    'Eldric Sage' => '沧明子',
                    'Mia' => '乖小妹',
                    'Mochi' => '沙小弥',
                    'Bellona' => '燕铮莺',
                    'Vincent' => '田叔',
                    'Bunny' => '萌小姬',
                    'Neil' => '阿闻',
                    'Elias' => '墨讲师',
                    'Arthur' => '徐大爷',
                    'Nini' => '邻家妹妹',
                    'Seren' => '小婉',
                    'Pip' => '顽屁小孩',
                    'Stella' => '少女阿月',
                    'Bodega' => '博德加',
                    'Sonrisa' => '索尼莎',
                    'Alek' => '阿列克',
                    'Dolce' => '多尔切',
                    'Sohee' => '素熙',
                    'Ono Anna' => '小野杏',
                    'Lenn' => '莱恩',
                    'Emilien' => '埃米尔安',
                    'Andre' => '安德雷',
                    'Radio Gol' => '拉迪奥·戈尔',
                    'Jada' => '上海-阿珍',
                    'Dylan' => '北京-晓东',
                    'Li' => '南京-老李',
                    'Marcus' => '陕西-秦川',
                    'Roy' => '闽南-阿杰',
                    'Peter' => '天津-李彼得',
                    'Sunny' => '四川-晴儿',
                    'Eric' => '四川-程川',
                    'Rocky' => '粤语-阿强',
                    'Kiki' => '粤语-阿清',
                ];
                $voices = Db::name("bbfx_shuziren_voice")->where(['status'=>'OK'])->field("id,voice_id")->select();
                if(!empty($voices)){
                    $voices = array_skey($voices,"voice_id");
                }
                foreach($voiceList as $key => $value){
                    if(!empty($voices[$key])){
                        continue;
                    }
                    $data = [
                        'uniacid'=>1,
                        'type'=>0,
                        'user_id'=>0,
                        'title'=>$value,
                        'url'=>'',
                        'voice_id'=>$key,
                        'apikey'=>'',
                        'status'=>'OK',
                        'createtime'=>1782219600
                    ];

                    Db::name("bbfx_shuziren_voice")->insert($data);
                }
            }

        } catch (\Exception $e) {
            $err['e5'] = $e->getMessage();
        }

        try {
            if($sversion < 222607031){
                $return_list = Db::name("bbfx_return")->where(["uniacid"=>['>',0]])->find();
                if(!empty($return_list)){
                    foreach($return_list as $return){
                        $uniacid = $return['uniacid'];
                        $return_data = [];
                        $return_rule_content = iunserializer($return['return_rule_content']);
                        if(!empty($return_rule_content)){
                            foreach($return_rule_content as $key => $val){
                                if($return['currency'] == 2){
                                    $return_rule_content[$key]['return_total_score'] = $val['return_total'];
                                    $return_rule_content[$key]['return_total'] = '';
                                    $return_rule_content[$key]['return_day_score'] = $val['return_day'];
                                    $return_rule_content[$key]['return_day'] = '';
                                }
                                else{
                                    $return_rule_content[$key]['return_total_score'] = '';
                                    $return_rule_content[$key]['return_day_score'] = '';
                                }
                            }
                            $return_data['return_rule_content'] = iserializer($return_rule_content);
                        }

                        $zhitui_reward = iunserializer($return['zhitui_reward']);
                        if(!empty($zhitui_reward)){
                            foreach($zhitui_reward as $key => $val){
                                if($return['currency'] == 2){
                                    $zhitui_reward[$key]['reward_rate_score'] = $val['reward_rate'];
                                    $zhitui_reward[$key]['reward_rate'] = '';
                                }
                                else{
                                    $zhitui_reward[$key]['reward_rate_score'] = '';
                                }
                            }
                            $return_data['zhitui_reward'] = iserializer($zhitui_reward);
                        }
                        $accelerate_rule = iunserializer($return['accelerate_rule']);
                        if(!empty($accelerate_rule['jiandan_reward'])){
                            foreach($accelerate_rule['jiandan_reward'] as $key => $val){
                                if($return['currency'] == 2){
                                    $accelerate_rule['jiandan_reward'][$key]['reward_rate_score'] = $val['reward_rate'];
                                    $accelerate_rule['jiandan_reward'][$key]['reward_rate'] = '';
                                }
                                else{
                                    $accelerate_rule['jiandan_reward'][$key]['reward_rate_score'] = '';
                                }
                            }
                        }
                        if(!empty($accelerate_rule['pingji_reward'])){
                            foreach($accelerate_rule['pingji_reward'] as $key => $val){
                                if($return['currency'] == 2){
                                    $accelerate_rule['pingji_reward'][$key]['reward_rate_score'] = $val['reward_rate'];
                                    $accelerate_rule['pingji_reward'][$key]['reward_rate'] = '';
                                }
                                else{
                                    $accelerate_rule['pingji_reward'][$key]['reward_rate_score'] = '';
                                }
                            }
                        }
                        if(!empty($accelerate_rule['zhitui_jiasu_reward'])){
                            foreach($accelerate_rule['zhitui_jiasu_reward'] as $key => $val){
                                if($return['currency'] == 2){
                                    $accelerate_rule['zhitui_jiasu_reward'][$key]['reward_rate_score'] = $val['reward_rate'];
                                    $accelerate_rule['zhitui_jiasu_reward'][$key]['reward_rate'] = '';
                                }
                                else{
                                    $accelerate_rule['zhitui_jiasu_reward'][$key]['reward_rate_score'] = '';
                                }
                            }
                        }
                        if(!empty($accelerate_rule['zhitui_reward'])){
                            foreach($accelerate_rule['zhitui_reward'] as $key => $val){
                                if($return['currency'] == 2){
                                    $accelerate_rule['zhitui_reward'][$key]['reward_rate_score'] = $val['reward_rate'];
                                    $accelerate_rule['zhitui_reward'][$key]['reward_rate'] = '';
                                }
                                else{
                                    $accelerate_rule['zhitui_reward'][$key]['reward_rate_score'] = '';
                                }
                            }
                        }

                        $return_data['accelerate_rule'] = iserializer($accelerate_rule);
                        Db::name("bbfx_return")->where(['id'=>$return['id']])->update($return_data); 
                        
                        $return_rule_list = Db::name("bbfx_return_rule")->where(['uniacid'=>$uniacid])->order("single_purchase_money asc")->select();
                        if(!empty($return_rule_list)){
                            foreach($return_rule_list as $key => $val){
                                if($return['currency'] == 2){
                                    $udata = [
                                        'return_score_rate'=>$val['return_rate'],
                                        'return_score_day'=>$val['return_day'],
                                        'return_rate'=>0,
                                        'return_day'=>0
                                    ];
                                    Db::name("bbfx_return_rule")->where(['id'=>$val['id']])->update($udata);
                                }
                            }
                        }

                        $goods_list = Db::name("bbfx_goods")->where(['uniacid'=>$uniacid])->order("id asc")->field("id,is_return,is_return_rule,returns")->select();
                        if(!empty($goods_list)){
                            foreach($goods_list as $key => $val){
                                $goods_returns = iunserializer($val['returns']);
                                if(!empty($goods_returns)){
                                    if($return['currency'] == 2){
                                        $goods_returns['day_score'] = $goods_returns['day'];
                                        $goods_returns['day'] = '';
                                        $goods_returns['money1_score'] = $goods_returns['money1'];
                                        $goods_returns['money1'] = '';
                                        $goods_returns['money2_score'] = $goods_returns['money2'];
                                        $goods_returns['money2'] = '';
                                    }
                                    else{
                                        $goods_returns['day_score'] = '';
                                        $goods_returns['money1_score'] = '';
                                        $goods_returns['money2_score'] = '';
                                    }
                                    if(!empty($goods_returns['level'])){
                                        foreach($goods_returns['level'] as $key1 => $val1){
                                            if($return['currency'] == 2){
                                                $goods_returns['level'][$key1]['money1_score'] = $val1['money1'];
                                                $goods_returns['level'][$key1]['money1'] = '';
                                                $goods_returns['level'][$key1]['money2_score'] = $val1['money2'];
                                                $goods_returns['level'][$key1]['money2'] = '';
                                                $goods_returns['level'][$key1]['day_score'] = $goods_returns['day_score'];
                                                $goods_returns['level'][$key1]['day'] = '';
                                            }
                                            else{
                                                $goods_returns['level'][$key1]['money1_score'] = '';
                                                $goods_returns['level'][$key1]['money2_score'] = '';
                                                $goods_returns['level'][$key1]['day_score'] = '';
                                                $goods_returns['level'][$key1]['day'] = $goods_returns['day'];
                                            }

                                        }
                                    }
                                    if(!empty($goods_returns['month'])){
                                        if($return['currency'] == 2){
                                            $goods_returns['month_score'] = $goods_returns['month'];
                                            $goods_returns['month'] = [];
                                        }
                                        else{
                                            $goods_returns['month_score'] = [];
                                        }
                                    }

                                    Db::name("bbfx_goods")->where(['id'=>$val['id']])->update(['returns'=>iserializer($goods_returns)]);
                                }
                            }
                        }
                    }
                }
            }
        } catch (\Exception $e) {
            $err['e6'] = $e->getMessage();
        }
        
        if(!empty($err)){
            addFileLog("uperr111",json_encode($err));
        }

        return __json(0,"操作成功",$err);
    }
}