ALTER TABLE `biz_user`
    ADD COLUMN `withdrawal_cash` double(20, 2) NULL COMMENT '可提现金额' AFTER `fenxiao_state`,
    ADD COLUMN `salesman_grade` bigint(20) NULL COMMENT '推广员等级' AFTER `withdrawal_cash`;

ALTER TABLE `shop_sku`
    ADD COLUMN `seales_price` decimal(20, 2) NULL COMMENT '推广提成' AFTER `company_id`,
ADD COLUMN `invitation_price` decimal(20, 2) NULL COMMENT '邀请提成' AFTER `seales_price`;

ALTER TABLE  `bus_parameter_settings`
    MODIFY COLUMN `param_value3` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `param_value2`;


/**
 * 分销单明细
 * @author yourName
 * @date 2021-03-12 13:17
 */
CREATE TABLE shop_salesman_order_item(
                                         create_by varchar(100) NOT NULL COMMENT '创建人',
                                         create_time datetime NOT NULL COMMENT '创建时间',
                                         update_by varchar(100) NOT NULL COMMENT '更新人',
                                         update_time datetime NOT NULL COMMENT '更新时间',
                                         id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                         order_id  bigint(20)    COMMENT '订单id',

                                         salesman_order_id bigint(20)    COMMENT '分销订单id',

                                         order_item_id bigint(20)    COMMENT '订单明细id',

                                         amount double(20,2)    COMMENT '收益金额',

PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分销单明细';

/**
 * 收益流水
 * @author yourName
 * @date 2021-03-10 17:34
 */
CREATE TABLE shop_revenue_flow(
                                  create_by varchar(100) NOT NULL COMMENT '创建人',
                                  create_time datetime NOT NULL COMMENT '创建时间',
                                  update_by varchar(100) NOT NULL COMMENT '更新人',
                                  update_time datetime NOT NULL COMMENT '更新时间',
                                  id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                  user_id varchar(100)    COMMENT '用户id',

                                  revenue_content varchar(40)    COMMENT '收益说明',

                                  amount double(20,2)    COMMENT '收益金额',

 business_id bigint(20)    COMMENT '原始订单ID',

 company_id bigint(20)    COMMENT '公司ID',

PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='收益流水';


/**
 * 订单结算记录
 * @author yourName
 * @date 2021-03-10 17:34
 */
CREATE TABLE shop_saleman_settlement(
                                        create_by varchar(100) NOT NULL COMMENT '创建人',
                                        create_time datetime NOT NULL COMMENT '创建时间',
                                        update_by varchar(100) NOT NULL COMMENT '更新人',
                                        update_time datetime NOT NULL COMMENT '更新时间',
                                        id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                        order_no varchar(40)    COMMENT '结算编号',

                                        settlement_way int(2)    COMMENT '结算方式1，线下结算，2余额结算',

                                        man_count int(11)    COMMENT '结算人数',

                                        order_count int(11)    COMMENT '结算单数',

                                        amount double(20,2)    COMMENT '结算金额',

 user_id int(11)    COMMENT '结算人',

 remark varchar(400)    COMMENT '备注',

 company_id bigint(20)    COMMENT '公司ID',

PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单结算记录';



/**
 * 推广员申请记录
 * @author yourName
 * @date 2021-03-10 17:34
 */
CREATE TABLE shop_salesman_apply(
                                    create_by varchar(100) NOT NULL COMMENT '创建人',
                                    create_time datetime NOT NULL COMMENT '创建时间',
                                    update_by varchar(100) NOT NULL COMMENT '更新人',
                                    update_time datetime NOT NULL COMMENT '更新时间',
                                    id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                    apply_way int(2)    COMMENT '申请方式1、自主申请，2、自动添加，3上级邀请，4、手动添加',

                                    user_id varchar(100)    COMMENT '申请用户id',

                                    parent_user_id varchar(100)    COMMENT '邀请用户ID',

                                    apply_status int(2)    COMMENT '申请状态1、待审核，2通过，3未通过',

                                    remark varchar(4000)    COMMENT '备注',

                                    company_id bigint(20)    COMMENT '公司ID',

                                    PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='推广员申请记录';


/**
 * 推广员等级
 * @author yourName
 * @date 2021-03-10 17:34
 */
CREATE TABLE shop_salesman_grade(
                                    create_by varchar(100) NOT NULL COMMENT '创建人',
                                    create_time datetime NOT NULL COMMENT '创建时间',
                                    update_by varchar(100) NOT NULL COMMENT '更新人',
                                    update_time datetime NOT NULL COMMENT '更新时间',
                                    id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                    name varchar(200)    COMMENT '等级名称',

                                    seales_commission double(20,2)    COMMENT '推广提成%',

 invitation_commission double(20,2)    COMMENT '邀请提成 %',

 grade_condition double(20,2)    COMMENT '等级条件（推广金额额）',

 is_default int(2)    COMMENT '默认等级1是，2不是',

 company_id bigint(20)    COMMENT '公司ID',

PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='推广员等级';



/**
 * 分销订单
 * @author yourName
 * @date 2021-03-10 17:34
 */
CREATE TABLE shop_salesman_order(
                                    create_by varchar(100) NOT NULL COMMENT '创建人',
                                    create_time datetime NOT NULL COMMENT '创建时间',
                                    update_by varchar(100) NOT NULL COMMENT '更新人',
                                    update_time datetime NOT NULL COMMENT '更新时间',
                                    id bigint(20)   NOT NULL  AUTO_INCREMENT  COMMENT '主键',

                                    order_id  bigint(20)    COMMENT '订单id',

                                    user_id varchar(100)    COMMENT '用户id',

                                    sales_user_id varchar(100)    COMMENT '收益人id',

                                    revenue_type int(2)    COMMENT '收益类型1，推广收益，2邀请收益',

                                    amount double(20,2)    COMMENT '收益金额',

 order_status int(2)    COMMENT '结算状态',

 settlement_id bigint(20)    COMMENT '结算单ID',

 company_id bigint(20)    COMMENT '公司ID',

PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分销订单';

biz_user原来的userId改成了自增长的bigint


ALTER TABLE `shop_sku`
    ADD COLUMN `score_price` decimal(10, 2) NULL COMMENT '积分兑换价格' AFTER `invitation_price`;

ALTER TABLE `shop_product`
    ADD COLUMN `score_category_id` bigint(20) NULL COMMENT '积分商城分类ID' AFTER `company_id`,
ADD COLUMN `able_sales` int(2) NULL COMMENT '是否为分销产品1是2不是' AFTER `score_category_id`,
ADD COLUMN `able_score_pay` int(2) NULL COMMENT '是否可用积分支付1是2不是' AFTER `able_sales`;

ALTER TABLE `shop_shopping_cart`
    ADD COLUMN `cart_type` int(2) NOT NULL COMMENT '购物车类型 1微商城  2积分商城' AFTER `company_id`;

update shop_product set able_score_pay=1;
update shop_product set able_sales=2;

ALTER TABLE `shop_sku`
    MODIFY COLUMN `score_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '兑换所需支付价格' AFTER `invitation_price`,
    ADD COLUMN `score_count` decimal(10, 2) NULL COMMENT '兑换所需积分数量' AFTER `score_price`;

ALTER TABLE `shop_order_details`
    ADD COLUMN `pay_type` int(2) NULL COMMENT '支付方式1 直接购买 2，积分兑换' AFTER `company_id`,
ADD COLUMN `score_count` decimal(20, 2) NULL COMMENT '支付积分单价' AFTER `pay_type`,
ADD COLUMN `total_score_count` decimal(20, 2) NULL COMMENT '支付总积分' AFTER `score_count`;

ALTER TABLE `shop_order`
DROP COLUMN `score_pay`,
ADD COLUMN `score_pay` int(20) NULL COMMENT '支付积分' AFTER `company_id`;


ALTER TABLE `shop_advertis`
    ADD COLUMN `page_id` bigint(0) NULL COMMENT '连接页面' AFTER `company_id`;

ALTER TABLE `shop_sku`
DROP COLUMN `self_price`,
ADD COLUMN `self_price`  decimal(20,2) NULL AFTER `score_count`;

ALTER TABLE `shop_salesman_grade`
DROP COLUMN `self_commission`,
ADD COLUMN `self_commission`  double(20,2) NULL COMMENT '自购返佣比例%' AFTER `company_id`;